class browser done

This commit is contained in:
royqh1979@gmail.com 2021-09-26 16:25:17 +08:00
parent 36fa23634d
commit 1d2357c374
10 changed files with 354 additions and 137 deletions

Binary file not shown.

View File

@ -679,7 +679,7 @@ Are you really want to continue?</source>
<translation>:</translation>
</message>
<message>
<location filename="editor.cpp" line="3092"/>
<location filename="editor.cpp" line="3039"/>
<source>Readonly</source>
<translation></translation>
</message>
@ -2175,7 +2175,7 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.ui" line="300"/>
<location filename="mainwindow.cpp" line="2214"/>
<location filename="mainwindow.cpp" line="2396"/>
<source>Issues</source>
<translation></translation>
</message>
@ -2377,10 +2377,10 @@ Are you really want to continue?</source>
<location filename="mainwindow.ui" line="965"/>
<location filename="mainwindow.ui" line="1110"/>
<location filename="mainwindow.ui" line="1113"/>
<location filename="mainwindow.cpp" line="1103"/>
<location filename="mainwindow.cpp" line="1114"/>
<location filename="mainwindow.cpp" line="1942"/>
<location filename="mainwindow.cpp" line="1953"/>
<location filename="mainwindow.cpp" line="1161"/>
<location filename="mainwindow.cpp" line="1172"/>
<location filename="mainwindow.cpp" line="2124"/>
<location filename="mainwindow.cpp" line="2135"/>
<source>Compile</source>
<translation></translation>
</message>
@ -2426,7 +2426,7 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.ui" line="1181"/>
<location filename="mainwindow.cpp" line="1410"/>
<location filename="mainwindow.cpp" line="1468"/>
<source>Copy</source>
<translation></translation>
</message>
@ -2780,7 +2780,7 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.ui" line="1598"/>
<location filename="mainwindow.cpp" line="2997"/>
<location filename="mainwindow.cpp" line="3179"/>
<source>Clear all breakpoints</source>
<translation></translation>
</message>
@ -2885,32 +2885,32 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="405"/>
<location filename="mainwindow.cpp" line="407"/>
<location filename="mainwindow.cpp" line="437"/>
<location filename="mainwindow.cpp" line="439"/>
<location filename="mainwindow.cpp" line="466"/>
<location filename="mainwindow.cpp" line="468"/>
<location filename="mainwindow.cpp" line="463"/>
<location filename="mainwindow.cpp" line="465"/>
<location filename="mainwindow.cpp" line="495"/>
<location filename="mainwindow.cpp" line="497"/>
<location filename="mainwindow.cpp" line="524"/>
<location filename="mainwindow.cpp" line="526"/>
<source>Debugging</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="410"/>
<location filename="mainwindow.cpp" line="412"/>
<location filename="mainwindow.cpp" line="443"/>
<location filename="mainwindow.cpp" line="445"/>
<location filename="mainwindow.cpp" line="471"/>
<location filename="mainwindow.cpp" line="473"/>
<location filename="mainwindow.cpp" line="468"/>
<location filename="mainwindow.cpp" line="470"/>
<location filename="mainwindow.cpp" line="501"/>
<location filename="mainwindow.cpp" line="503"/>
<location filename="mainwindow.cpp" line="529"/>
<location filename="mainwindow.cpp" line="531"/>
<source>Running</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="415"/>
<location filename="mainwindow.cpp" line="417"/>
<location filename="mainwindow.cpp" line="449"/>
<location filename="mainwindow.cpp" line="451"/>
<location filename="mainwindow.cpp" line="476"/>
<location filename="mainwindow.cpp" line="478"/>
<location filename="mainwindow.cpp" line="473"/>
<location filename="mainwindow.cpp" line="475"/>
<location filename="mainwindow.cpp" line="507"/>
<location filename="mainwindow.cpp" line="509"/>
<location filename="mainwindow.cpp" line="534"/>
<location filename="mainwindow.cpp" line="536"/>
<source>Compiling</source>
<translation></translation>
</message>
@ -2919,292 +2919,317 @@ Are you really want to continue?</source>
<translation type="vanished">:%1 :%2 :%3 :%4 :%5</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="610"/>
<location filename="mainwindow.cpp" line="668"/>
<source>Line:%1 Col:%2 Selected:%3 Lines:%4 Length:%5</source>
<translation>:%1 :%2 :%3 :%4 :%5</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="628"/>
<location filename="mainwindow.cpp" line="686"/>
<source>Read Only</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="630"/>
<location filename="mainwindow.cpp" line="688"/>
<source>Insert</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="632"/>
<location filename="mainwindow.cpp" line="690"/>
<source>Overwrite</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="695"/>
<location filename="mainwindow.cpp" line="753"/>
<source>Close project</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="696"/>
<location filename="mainwindow.cpp" line="754"/>
<source>Are you sure you want to close %1?</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="889"/>
<location filename="mainwindow.cpp" line="904"/>
<location filename="mainwindow.cpp" line="947"/>
<location filename="mainwindow.cpp" line="962"/>
<source>Confirm</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="890"/>
<location filename="mainwindow.cpp" line="898"/>
<location filename="mainwindow.cpp" line="1104"/>
<location filename="mainwindow.cpp" line="948"/>
<location filename="mainwindow.cpp" line="956"/>
<location filename="mainwindow.cpp" line="1162"/>
<source>Source file is not compiled.</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="891"/>
<location filename="mainwindow.cpp" line="1104"/>
<location filename="mainwindow.cpp" line="949"/>
<location filename="mainwindow.cpp" line="1162"/>
<source>Compile now?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="905"/>
<location filename="mainwindow.cpp" line="1115"/>
<location filename="mainwindow.cpp" line="963"/>
<location filename="mainwindow.cpp" line="1173"/>
<source>Source file is more recent than executable.</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="906"/>
<location filename="mainwindow.cpp" line="964"/>
<source>Recompile now?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="967"/>
<location filename="mainwindow.cpp" line="1025"/>
<source>No compiler set</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="968"/>
<location filename="mainwindow.cpp" line="1026"/>
<source>No compiler set is configured.</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="968"/>
<location filename="mainwindow.cpp" line="1026"/>
<source>Can&apos;t start debugging.</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="983"/>
<location filename="mainwindow.cpp" line="1072"/>
<location filename="mainwindow.cpp" line="1041"/>
<location filename="mainwindow.cpp" line="1130"/>
<source>Enable debugging</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="984"/>
<location filename="mainwindow.cpp" line="1073"/>
<location filename="mainwindow.cpp" line="1042"/>
<location filename="mainwindow.cpp" line="1131"/>
<source>You have not enabled debugging info (-g3) and/or stripped it from the executable (-s) in Compiler Options.&lt;BR /&gt;&lt;BR /&gt;Do you want to correct this now?</source>
<translation>(-g3)(-s)&lt;br /&gt;&lt;br/&gt;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1003"/>
<location filename="mainwindow.cpp" line="1061"/>
<source>Project not built</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1004"/>
<location filename="mainwindow.cpp" line="1062"/>
<source>Project hasn&apos;t been built. Build it now?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1018"/>
<location filename="mainwindow.cpp" line="1076"/>
<source>Host applcation missing</source>
<translation>宿</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1019"/>
<location filename="mainwindow.cpp" line="1077"/>
<source>DLL project needs a host application to run.</source>
<translation>DLL宿</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1021"/>
<location filename="mainwindow.cpp" line="1079"/>
<source>But it&apos;s missing.</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1026"/>
<location filename="mainwindow.cpp" line="1084"/>
<source>Host application not exists</source>
<translation>宿</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1027"/>
<location filename="mainwindow.cpp" line="1085"/>
<source>Host application file &apos;%1&apos; doesn&apos;t exist.</source>
<translation>宿&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1115"/>
<location filename="mainwindow.cpp" line="1173"/>
<source>Recompile?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1423"/>
<location filename="mainwindow.cpp" line="1481"/>
<source>Copy all</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1436"/>
<location filename="mainwindow.cpp" line="1494"/>
<source>Clear</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1448"/>
<location filename="mainwindow.cpp" line="1506"/>
<source>Remove this search</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1458"/>
<location filename="mainwindow.cpp" line="1516"/>
<source>Clear all searches</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1470"/>
<location filename="mainwindow.cpp" line="1528"/>
<source>Breakpoint condition...</source>
<translation>...</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1482"/>
<location filename="mainwindow.cpp" line="1540"/>
<source>Break point condition</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1483"/>
<location filename="mainwindow.cpp" line="1541"/>
<source>Enter the condition of the breakpoint:</source>
<translation>:</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1492"/>
<location filename="mainwindow.cpp" line="1550"/>
<source>Remove all breakpoints</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1504"/>
<location filename="mainwindow.cpp" line="1562"/>
<source>Rename File</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1512"/>
<location filename="mainwindow.cpp" line="1531"/>
<location filename="mainwindow.cpp" line="1570"/>
<location filename="mainwindow.cpp" line="1589"/>
<source>Add Folder</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1528"/>
<location filename="mainwindow.cpp" line="1586"/>
<source>New folder</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1532"/>
<location filename="mainwindow.cpp" line="1590"/>
<source>Folder name:</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1546"/>
<location filename="mainwindow.cpp" line="1604"/>
<source>Rename Folder</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1554"/>
<location filename="mainwindow.cpp" line="1612"/>
<source>Remove Folder</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1637"/>
<source>Sort By Type</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1642"/>
<source>Sort alphabetically</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1647"/>
<source>Show inherited members</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1652"/>
<source>Goto declaration</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1655"/>
<source>Goto definition</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1793"/>
<source>%1 files autosaved</source>
<translation>%1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1862"/>
<location filename="mainwindow.cpp" line="2044"/>
<source>Save project</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1863"/>
<location filename="mainwindow.cpp" line="2045"/>
<source>The project &apos;%1&apos; has modifications.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1865"/>
<location filename="mainwindow.cpp" line="2047"/>
<source>Do you want to save it?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2998"/>
<location filename="mainwindow.cpp" line="3180"/>
<source>Do you really want to clear all breakpoints in this file?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3177"/>
<location filename="mainwindow.cpp" line="3359"/>
<source>New project</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3178"/>
<location filename="mainwindow.cpp" line="3360"/>
<source>Close %1 and start new project?</source>
<translation>&apos;%1&apos;?</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3190"/>
<location filename="mainwindow.cpp" line="3372"/>
<source>Folder not exist</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3191"/>
<location filename="mainwindow.cpp" line="3373"/>
<source>Folder &apos;%1&apos; doesn&apos;t exist. Create it now?</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3198"/>
<location filename="mainwindow.cpp" line="3380"/>
<source>Can&apos;t create folder</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3199"/>
<location filename="mainwindow.cpp" line="3381"/>
<source>Failed to create folder &apos;%1&apos;.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3214"/>
<location filename="mainwindow.cpp" line="3396"/>
<source>Save new project as</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3216"/>
<location filename="mainwindow.cpp" line="3398"/>
<source>Red panda Dev-C++ project file (*.dev)</source>
<translation>Dev-C++ (*.dev)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3227"/>
<location filename="mainwindow.cpp" line="3409"/>
<source>New project fail</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3228"/>
<location filename="mainwindow.cpp" line="3410"/>
<source>Can&apos;t assign project template</source>
<translation>使</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3285"/>
<location filename="mainwindow.cpp" line="3467"/>
<source>Add to project</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="679"/>
<location filename="mainwindow.cpp" line="1949"/>
<location filename="mainwindow.cpp" line="2014"/>
<location filename="mainwindow.cpp" line="2034"/>
<location filename="mainwindow.cpp" line="2122"/>
<location filename="mainwindow.cpp" line="2134"/>
<location filename="mainwindow.cpp" line="2461"/>
<location filename="mainwindow.cpp" line="2473"/>
<location filename="mainwindow.cpp" line="737"/>
<location filename="mainwindow.cpp" line="2131"/>
<location filename="mainwindow.cpp" line="2196"/>
<location filename="mainwindow.cpp" line="2216"/>
<location filename="mainwindow.cpp" line="2304"/>
<location filename="mainwindow.cpp" line="2316"/>
<location filename="mainwindow.cpp" line="2643"/>
<location filename="mainwindow.cpp" line="2655"/>
<source>Error</source>
<translation></translation>
</message>
@ -3214,75 +3239,75 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1943"/>
<location filename="mainwindow.cpp" line="2125"/>
<source>File &apos;%1&apos; was changed.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1943"/>
<location filename="mainwindow.cpp" line="2125"/>
<source>Reload its content from disk?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1954"/>
<location filename="mainwindow.cpp" line="2136"/>
<source>File &apos;%1&apos; was removed.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1954"/>
<location filename="mainwindow.cpp" line="2136"/>
<source>Keep it open?</source>
<translation>C++</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2030"/>
<location filename="mainwindow.cpp" line="2212"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2309"/>
<location filename="mainwindow.cpp" line="2491"/>
<source>Compile Failed</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2314"/>
<location filename="mainwindow.cpp" line="2496"/>
<source>Run Failed</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2490"/>
<location filename="mainwindow.cpp" line="2504"/>
<location filename="mainwindow.cpp" line="2672"/>
<location filename="mainwindow.cpp" line="2686"/>
<source>Confirm Convertion</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2491"/>
<location filename="mainwindow.cpp" line="2505"/>
<location filename="mainwindow.cpp" line="2673"/>
<location filename="mainwindow.cpp" line="2687"/>
<source>The editing file will be saved using %1 encoding. &lt;br /&gt;This operation can&apos;t be reverted. &lt;br /&gt;Are you sure to continue?</source>
<translation>使%1&lt;br /&gt;&lt;br /&gt;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2671"/>
<location filename="mainwindow.cpp" line="2853"/>
<source>New Watch Expression</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2672"/>
<location filename="mainwindow.cpp" line="2854"/>
<source>Enter Watch Expression (it is recommended to use &apos;this-&gt;&apos; for class members):</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2718"/>
<location filename="mainwindow.cpp" line="2900"/>
<source>Parsing file %1 of %2: &quot;%3&quot;</source>
<translation>%1/%2&quot;%3&quot;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2740"/>
<location filename="mainwindow.cpp" line="2746"/>
<location filename="mainwindow.cpp" line="2922"/>
<location filename="mainwindow.cpp" line="2928"/>
<source>Done parsing %1 files in %2 seconds</source>
<translation>%1,%2</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2743"/>
<location filename="mainwindow.cpp" line="2925"/>
<source>(%1 files per second)</source>
<translation>(%1</translation>
</message>
@ -4353,27 +4378,27 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="utils.cpp" line="332"/>
<location filename="utils.cpp" line="334"/>
<source>Index %1 out of range</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<location filename="utils.cpp" line="674"/>
<location filename="utils.cpp" line="676"/>
<source>bytes</source>
<translation></translation>
</message>
<message>
<location filename="utils.cpp" line="676"/>
<location filename="utils.cpp" line="678"/>
<source>KB</source>
<translation>KB</translation>
</message>
<message>
<location filename="utils.cpp" line="678"/>
<location filename="utils.cpp" line="680"/>
<source>MB</source>
<translation>MB</translation>
</message>
<message>
<location filename="utils.cpp" line="680"/>
<location filename="utils.cpp" line="682"/>
<source>GB</source>
<translation>GB</translation>
</message>

View File

@ -1630,17 +1630,102 @@ void MainWindow::buildContextMenus()
});
//context menu signal for class browser
ui->classBrowser->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->classBrowser,&QWidget::customContextMenuRequested,
ui->tabStructure->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->tabStructure,&QWidget::customContextMenuRequested,
this, &MainWindow::onClassBrowserContextMenu);
mClassBrowser_Sort_By_Type = createActionFor(
tr("Sort By Type"),
ui->classBrowser);
ui->tabStructure);
mClassBrowser_Sort_By_Type->setCheckable(true);
mClassBrowser_Sort_By_Type->setIcon(QIcon(":/icons/images/newlook24/077-sort-type.png"));
QAction * mClassBrowser_Sort_By_Name;
QAction * mClassBrowser_Show_Inheritance;
QAction * mClassBrowser_goto_declaration;
QAction * mClassBrowser_goto_definition;
mClassBrowser_Sort_By_Name = createActionFor(
tr("Sort alphabetically"),
ui->tabStructure);
mClassBrowser_Sort_By_Name->setCheckable(true);
mClassBrowser_Sort_By_Name->setIcon(QIcon(":/icons/images/newlook24/076-sort-alpha.png"));
mClassBrowser_Show_Inherited = createActionFor(
tr("Show inherited members"),
ui->tabStructure);
mClassBrowser_Show_Inherited->setCheckable(true);
mClassBrowser_Show_Inherited->setIcon(QIcon(":/icons/images/newlook24/075-show-inheritance.png"));
mClassBrowser_goto_declaration = createActionFor(
tr("Goto declaration"),
ui->tabStructure);
mClassBrowser_goto_definition = createActionFor(
tr("Goto definition"),
ui->tabStructure);
mClassBrowser_Sort_By_Name->setChecked(pSettings->ui().classBrowserSortAlpha());
mClassBrowser_Sort_By_Type->setChecked(pSettings->ui().classBrowserSortType());
mClassBrowser_Show_Inherited->setChecked(pSettings->ui().classBrowserShowInherited());
connect(mClassBrowser_Sort_By_Name, &QAction::toggled,
[this](){
pSettings->ui().setClassBrowserSortAlpha(mClassBrowser_Sort_By_Name->isChecked());
pSettings->ui().save();
mClassBrowserModel.fillStatements();
});
connect(mClassBrowser_Sort_By_Type, &QAction::toggled,
[this](){
pSettings->ui().setClassBrowserSortType(mClassBrowser_Sort_By_Type->isChecked());
pSettings->ui().save();
mClassBrowserModel.fillStatements();
});
connect(mClassBrowser_Show_Inherited, &QAction::toggled,
[this](){
pSettings->ui().setClassBrowserShowInherited(mClassBrowser_Show_Inherited->isChecked());
pSettings->ui().save();
mClassBrowserModel.fillStatements();
});
connect(mClassBrowser_goto_definition,&QAction::triggered,
[this](){
QModelIndex index = ui->classBrowser->currentIndex();
if (!index.isValid())
return ;
ClassBrowserNode * node = static_cast<ClassBrowserNode*>(index.internalPointer());
if (!node)
return ;
PStatement statement = node->statement;
if (!statement) {
return;
}
QString filename;
int line;
filename = statement->definitionFileName;
line = statement->definitionLine;
Editor* e = pMainWindow->editorList()->getEditorByFilename(filename);
if (e) {
e->setCaretPositionAndActivate(line,1);
}
});
connect(mClassBrowser_goto_declaration,&QAction::triggered,
[this](){
on_classBrowser_doubleClicked(ui->classBrowser->currentIndex());
});
//toolbar for class browser
mClassBrowserToolbar = new QWidget();
QVBoxLayout* layout = dynamic_cast<QVBoxLayout*>( ui->tabStructure->layout());
layout->insertWidget(0,mClassBrowserToolbar);
QHBoxLayout* hlayout = new QHBoxLayout();
hlayout->setContentsMargins(2,2,2,2);
mClassBrowserToolbar->setLayout(hlayout);
QToolButton * toolButton;
toolButton = new QToolButton;
toolButton->setDefaultAction(mClassBrowser_Sort_By_Type);
hlayout->addWidget(toolButton);
toolButton = new QToolButton;
toolButton->setDefaultAction(mClassBrowser_Sort_By_Name);
hlayout->addWidget(toolButton);
QFrame * vLine = new QFrame();
vLine->setFrameShape(QFrame::VLine);
vLine->setFrameShadow(QFrame::Sunken);
hlayout->addWidget(vLine);
toolButton = new QToolButton;
toolButton->setDefaultAction(mClassBrowser_Show_Inherited);
hlayout->addWidget(toolButton);
hlayout->addStretch();
}
void MainWindow::maximizeEditor()
@ -1799,6 +1884,32 @@ void MainWindow::onProjectViewContextMenu(const QPoint &pos)
menu.exec(ui->projectView->mapToGlobal(pos));
}
void MainWindow::onClassBrowserContextMenu(const QPoint &pos)
{
QMenu menu(this);
bool canGoto = false;
QModelIndex index = ui->classBrowser->currentIndex();
if (index.isValid()) {
ClassBrowserNode * node = static_cast<ClassBrowserNode*>(index.internalPointer());
if (node) {
PStatement statement = node->statement;
if (statement) {
canGoto = true;
}
}
}
mClassBrowser_goto_declaration->setEnabled(canGoto);
mClassBrowser_goto_definition->setEnabled(canGoto);
menu.addAction(mClassBrowser_goto_declaration);
menu.addAction(mClassBrowser_goto_definition);
menu.addSeparator();
menu.addAction(mClassBrowser_Sort_By_Name);
menu.addAction(mClassBrowser_Sort_By_Type);
menu.addAction(mClassBrowser_Show_Inherited);
menu.exec(ui->projectView->mapToGlobal(pos));
}
void MainWindow::onEditorContextMenu(const QPoint &pos)
{
Editor * editor = mEditorList->getEditor();
@ -3449,6 +3560,22 @@ const std::shared_ptr<QHash<StatementKind, QColor> > &MainWindow::statementColor
void MainWindow::on_classBrowser_doubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return ;
ClassBrowserNode * node = static_cast<ClassBrowserNode*>(index.internalPointer());
if (!node)
return ;
PStatement statement = node->statement;
if (!statement) {
return;
}
QString filename;
int line;
filename = statement->fileName;
line = statement->line;
Editor* e = pMainWindow->editorList()->getEditorByFilename(filename);
if (e) {
e->setCaretPositionAndActivate(line,1);
}
}

View File

@ -164,6 +164,7 @@ private slots:
void onSearchViewContextMenu(const QPoint& pos);
void onBreakpointsViewContextMenu(const QPoint& pos);
void onProjectViewContextMenu(const QPoint& pos);
void onClassBrowserContextMenu(const QPoint& pos);
void on_actionNew_triggered();
@ -414,9 +415,10 @@ private:
//actions for class browser
QAction * mClassBrowser_Sort_By_Type;
QAction * mClassBrowser_Sort_By_Name;
QAction * mClassBrowser_Show_Inheritance;
QAction * mClassBrowser_Show_Inherited;
QAction * mClassBrowser_goto_declaration;
QAction * mClassBrowser_goto_definition;
QWidget * mClassBrowserToolbar;
// QWidget interface
protected:

View File

@ -3959,6 +3959,36 @@ void Settings::UI::setLeftPanelIndex(int newLeftPanelIndex)
mLeftPanelIndex = newLeftPanelIndex;
}
bool Settings::UI::classBrowserShowInherited() const
{
return mClassBrowserShowInherited;
}
void Settings::UI::setClassBrowserShowInherited(bool newClassBrowserShowInherited)
{
mClassBrowserShowInherited = newClassBrowserShowInherited;
}
bool Settings::UI::classBrowserSortType() const
{
return mClassBrowserSortType;
}
void Settings::UI::setClassBrowserSortType(bool newClassBrowserSortType)
{
mClassBrowserSortType = newClassBrowserSortType;
}
bool Settings::UI::classBrowserSortAlpha() const
{
return mClassBrowserSortAlpha;
}
void Settings::UI::setClassBrowserSortAlpha(bool newClassBrowserSortAlpha)
{
mClassBrowserSortAlpha = newClassBrowserSortAlpha;
}
const QByteArray &Settings::UI::mainWindowState() const
{
return mMainWindowState;
@ -3979,6 +4009,9 @@ void Settings::UI::doSave()
saveValue("left_panel_openned",mLeftPanelOpenned);
saveValue("left_panel_width",mLeftPanelWidth);
saveValue("left_panel_index",mLeftPanelIndex);
saveValue("class_browser_sort_alphabetically",mClassBrowserSortAlpha);
saveValue("class_browser_sort_by_type",mClassBrowserSortType);
saveValue("class_browser_show_inherited",mClassBrowserShowInherited);
}
void Settings::UI::doLoad()
@ -3991,4 +4024,7 @@ void Settings::UI::doLoad()
mLeftPanelOpenned = boolValue("left_panel_openned",true);
mLeftPanelWidth = intValue("left_panel_width",250);
mLeftPanelIndex = intValue("left_panel_index",2);
mClassBrowserSortAlpha = boolValue("class_browser_sort_alphabetically",true);
mClassBrowserSortType = boolValue("class_browser_sort_by_type",true);
mClassBrowserShowInherited = boolValue("class_browser_show_inherited",true);
}

View File

@ -777,6 +777,15 @@ public:
int leftPanelIndex() const;
void setLeftPanelIndex(int newLeftPanelIndex);
bool classBrowserSortAlpha() const;
void setClassBrowserSortAlpha(bool newClassBrowserSortAlpha);
bool classBrowserSortType() const;
void setClassBrowserSortType(bool newClassBrowserSortType);
bool classBrowserShowInherited() const;
void setClassBrowserShowInherited(bool newClassBrowserShowInherited);
private:
QByteArray mMainWindowState;
QByteArray mMainWindowGeometry;
@ -786,6 +795,9 @@ public:
bool mLeftPanelOpenned;
int mLeftPanelWidth;
int mLeftPanelIndex;
bool mClassBrowserSortAlpha;
bool mClassBrowserSortType;
bool mClassBrowserShowInherited;
protected:
void doSave() override;

View File

@ -788,6 +788,10 @@ QToolBar::separator:vertical {
image: url(":/qss_icons/dark/rc/toolbar_separator_vertical.png");
}
QToolBar QToolButton {
background-color: #455364;
}
QToolButton#qt_toolbar_ext_button {
background: #455364;
border: 0px;
@ -1071,7 +1075,8 @@ https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtoolbutton
--------------------------------------------------------------------------- */
QToolButton {
background-color: #455364;
/* background-color: #455364; */
background-color: #19232D;
color: #E0E1E3;
border-radius: 4px;
padding: 2px;

View File

@ -131,6 +131,8 @@ bool fileExists(const QString &file)
bool fileExists(const QString &dir, const QString &fileName)
{
if (dir.isEmpty() || fileName.isEmpty())
return false;
QDir dirInfo(dir);
return dirInfo.exists(fileName);
}

View File

@ -4,6 +4,7 @@
#include <QColor>
#include <QPalette>
#include "../mainwindow.h"
#include "../settings.h"
ClassBrowserModel::ClassBrowserModel(QObject *parent):QAbstractItemModel(parent)
{
@ -13,7 +14,6 @@ ClassBrowserModel::ClassBrowserModel(QObject *parent):QAbstractItemModel(parent)
// mRoot->childrenFetched = true;
mUpdating = false;
mUpdateCount = 0;
mShowInheritedMembers = false;
}
ClassBrowserModel::~ClassBrowserModel()
@ -134,6 +134,10 @@ QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const
} else {
kind = statement->kind;
}
if (kind == StatementKind::skKeyword) {
if (statement->command.startsWith('#'))
kind = StatementKind::skPreprocessor;
}
return mColors->value(kind,pMainWindow->palette().color(QPalette::Text));
}
} else if (role == Qt::DecorationRole) {
@ -299,7 +303,7 @@ void ClassBrowserModel::filterChildren(ClassBrowserNode *node, const StatementMa
for (PStatement statement:statements) {
if (statement->kind == StatementKind::skBlock)
continue;
if (statement->isInherited && !mShowInheritedMembers)
if (statement->isInherited && !pSettings->ui().classBrowserShowInherited())
continue;
if (statement == node->statement) // prevent infinite recursion
@ -367,13 +371,18 @@ void ClassBrowserModel::filterChildren(ClassBrowserNode *node, const StatementMa
addChild(node,statement);
}
}
// if sortAlphabetically and sortByType then begin
// filtered.Sort(@CompareByAlphaAndType);
// end else if sortAlphabetically then begin
// filtered.Sort(@CompareByAlpha);
// end else if sortByType then begin
// filtered.Sort(@CompareByType);
// end;
if (pSettings->ui().classBrowserSortAlpha()) {
std::sort(node->children.begin(),node->children.end(),
[](ClassBrowserNode* node1,ClassBrowserNode* node2) {
return node1->statement->command < node2->statement->command;
});
}
if (pSettings->ui().classBrowserSortType()) {
std::sort(node->children.begin(),node->children.end(),
[](ClassBrowserNode* node1,ClassBrowserNode* node2) {
return node1->statement->kind < node2->statement->kind;
});
}
}
PStatement ClassBrowserModel::createDummy(PStatement statement)

View File

@ -57,7 +57,6 @@ private:
int mUpdateCount;
QRecursiveMutex mMutex;
QString mCurrentFile;
bool mShowInheritedMembers;
std::shared_ptr<QHash<StatementKind, QColor>> mColors;
};