- enhancement: Tooltip support for '->' operator on std iterators.

- enhancement: Close other editors.
This commit is contained in:
Roy Qu 2023-06-13 17:16:09 +08:00
parent 4746d1b63c
commit dfed4accf6
10 changed files with 424 additions and 337 deletions

View File

@ -2,6 +2,8 @@ Red Panda C++ Version 2.23
- fix: When selection is availalbe, Ctrl+Click shouldn't jump to declaration/definition. - fix: When selection is availalbe, Ctrl+Click shouldn't jump to declaration/definition.
- enhancement: Code completion for '->' operator on std iterators. - enhancement: Code completion for '->' operator on std iterators.
- enhancement: Tooltip support for '->' operator on std iterators.
- enhancement: Close other editors.
Red Panda C++ Version 2.22 Red Panda C++ Version 2.22

View File

@ -387,6 +387,25 @@ bool EditorList::closeAll(bool force) {
return true; return true;
} }
bool EditorList::closeOthers(Editor *editor)
{
QList<Editor*> editors;
for (int i=0;i<mLeftPageWidget->count();i++) {
editors.append(static_cast<Editor*>(mLeftPageWidget->widget(i)));
}
for (int i=0;i<mRightPageWidget->count();i++) {
editors.append(static_cast<Editor*>(mRightPageWidget->widget(i)));
}
for (Editor* e: editors ) {
if (e!=editor) {
if (!closeEditor(e,false,false)) {
return false;
}
}
}
return true;
}
void EditorList::forceCloseEditor(Editor *editor) void EditorList::forceCloseEditor(Editor *editor)
{ {
beginUpdate(); beginUpdate();

View File

@ -56,6 +56,7 @@ public:
void clearProjectEditorsModified(); void clearProjectEditorsModified();
bool closeAll(bool force = false); bool closeAll(bool force = false);
bool closeOthers(Editor* editor);
void forceCloseEditor(Editor* editor); void forceCloseEditor(Editor* editor);

View File

@ -589,6 +589,7 @@ void MainWindow::updateEditorActions(const Editor *e)
ui->actionClose->setEnabled(false); ui->actionClose->setEnabled(false);
ui->actionClose_All->setEnabled(false); ui->actionClose_All->setEnabled(false);
ui->actionClose_Others->setEnabled(false);
ui->actionAdd_bookmark->setEnabled(false); ui->actionAdd_bookmark->setEnabled(false);
ui->actionRemove_Bookmark->setEnabled(false); ui->actionRemove_Bookmark->setEnabled(false);
@ -650,6 +651,7 @@ void MainWindow::updateEditorActions(const Editor *e)
ui->actionClose->setEnabled(true); ui->actionClose->setEnabled(true);
ui->actionClose_All->setEnabled(true); ui->actionClose_All->setEnabled(true);
ui->actionClose_Others->setEnabled(mEditorList->pageCount()>1);
int line = e->caretY(); int line = e->caretY();
ui->actionAdd_bookmark->setEnabled(e->document()->count()>0 && !e->hasBookmark(line)); ui->actionAdd_bookmark->setEnabled(e->document()->count()>0 && !e->hasBookmark(line));
@ -1725,6 +1727,7 @@ void MainWindow::updateActionIcons()
ui->actionClose->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_CLOSE)); ui->actionClose->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_CLOSE));
ui->actionClose_Project->setIcon(pIconsManager->getIcon(IconsManager::ACTION_PROJECT_CLOSE)); ui->actionClose_Project->setIcon(pIconsManager->getIcon(IconsManager::ACTION_PROJECT_CLOSE));
ui->actionClose_All->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_CLOSE_ALL)); ui->actionClose_All->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_CLOSE_ALL));
ui->actionClose_Others->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_CLOSE_ALL));
ui->actionPrint->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_PRINT)); ui->actionPrint->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_PRINT));
ui->actionUndo->setIcon(pIconsManager->getIcon(IconsManager::ACTION_EDIT_UNDO)); ui->actionUndo->setIcon(pIconsManager->getIcon(IconsManager::ACTION_EDIT_UNDO));
@ -4989,6 +4992,7 @@ void MainWindow::onEditorTabContextMenu(QTabWidget* tabWidget, const QPoint &pos
} }
menu.addAction(ui->actionClose); menu.addAction(ui->actionClose);
menu.addAction(ui->actionClose_All); menu.addAction(ui->actionClose_All);
menu.addAction(ui->actionClose_Others);
menu.addSeparator(); menu.addSeparator();
menu.addAction(ui->actionToggle_Readonly); menu.addAction(ui->actionToggle_Readonly);
menu.addSeparator(); menu.addSeparator();
@ -9920,3 +9924,14 @@ void MainWindow::on_actionGoto_File_End_and_Select_triggered()
} }
} }
void MainWindow::on_actionClose_Others_triggered()
{
mClosing = true;
Editor* e = mEditorList->getEditor();
if (e) {
mEditorList->closeOthers(e);
}
mClosing = false;
}

View File

@ -841,6 +841,8 @@ private slots:
void on_actionGoto_File_End_and_Select_triggered(); void on_actionGoto_File_End_and_Select_triggered();
void on_actionClose_Others_triggered();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
bool mFullInitialized; bool mFullInitialized;

View File

@ -3510,6 +3510,14 @@
<enum>QAction::NoRole</enum> <enum>QAction::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionClose_Others">
<property name="text">
<string>Close Others</string>
</property>
<property name="menuRole">
<enum>QAction::NoRole</enum>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

View File

@ -531,6 +531,29 @@ PStatement CppParser::doFindStatementOf(const QString &fileName, const QStringLi
return statement; return statement;
} }
return PStatement(); return PStatement();
} else if (ownerEvalStatement->typeStatement
&& STLIterators.contains(ownerEvalStatement->typeStatement->command)
&& memberOperator=="->"
) {
PStatement parentScope = ownerEvalStatement->typeStatement->parentScope.lock();
if (STLContainers.contains(parentScope->fullName)) {
QString typeName=doFindFirstTemplateParamOf(fileName,ownerEvalStatement->templateParams, parentScope);
PStatement typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
if (typeStatement) {
return findMemberOfStatement(phrase, typeStatement);
} else {
return PStatement();
}
} else if (STLMaps.contains(parentScope->fullName)) {
QString typeName=doFindTemplateParamOf(fileName,ownerEvalStatement->templateParams,1,parentScope);
// qDebug()<<"typeName"<<typeName<<lastResult->baseStatement->type<<lastResult->baseStatement->command;
PStatement typeStatement=doFindTypeDefinitionOf(fileName, typeName,parentScope);
if (typeStatement) {
return findMemberOfStatement(phrase, typeStatement);
} else {
return PStatement();
}
}
} }
return findMemberOfStatement(phrase, ownerEvalStatement->effectiveTypeStatement); return findMemberOfStatement(phrase, ownerEvalStatement->effectiveTypeStatement);
} }

View File

@ -5267,6 +5267,10 @@
<source>Goto File End and Select</source> <source>Goto File End and Select</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Close Others</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>MemoryModel</name> <name>MemoryModel</name>

File diff suppressed because it is too large Load Diff

View File

@ -4992,6 +4992,10 @@
<source>Goto File End and Select</source> <source>Goto File End and Select</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Close Others</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>MemoryModel</name> <name>MemoryModel</name>