From 1f597a6d5a03787f1fa41e8c7f8d4912f5eb306a Mon Sep 17 00:00:00 2001 From: Sergey BELASH Date: Mon, 18 Aug 2014 17:31:40 +0400 Subject: [PATCH] Bugfix: application after adding python console into main menu --- src/XGUI/XGUI_MainMenu.cpp | 9 +++++---- src/XGUI/XGUI_MainMenu.h | 1 + src/XGUI/XGUI_MainWindow.cpp | 11 ++++++----- src/XGUI/XGUI_Workbench.cpp | 6 +++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/XGUI/XGUI_MainMenu.cpp b/src/XGUI/XGUI_MainMenu.cpp index e35b94a56..1bd8d8eb0 100644 --- a/src/XGUI/XGUI_MainMenu.cpp +++ b/src/XGUI/XGUI_MainMenu.cpp @@ -48,6 +48,7 @@ XGUI_Workbench* XGUI_MainMenu::addWorkbench(const QString& theId, const QString& XGUI_Workbench* aPage = new XGUI_Workbench(myMenuTabs); aPage->setObjectName(theId); myMenuTabs->addTab(aPage, aTitle); + myWorkbenches.append(aPage); return aPage; } @@ -99,8 +100,8 @@ XGUI_Command* XGUI_MainMenu::feature(const QString& theId) const XGUI_Command* result; result = myGeneralPage->feature(theId); if (!result) { - for (int aTabIdx = 0; aTabIdx < myMenuTabs->count(); ++aTabIdx) { - XGUI_Workbench* aWbn = static_cast(myMenuTabs->widget(aTabIdx)); + XGUI_Workbench* aWbn; + foreach (aWbn, myWorkbenches) { result = aWbn->feature(theId); if (result) break; } @@ -111,8 +112,8 @@ XGUI_Command* XGUI_MainMenu::feature(const QString& theId) const QList XGUI_MainMenu::features() const { QList aList = myGeneralPage->features(); - for (int aTabIdx = 0; aTabIdx < myMenuTabs->count(); ++aTabIdx) { - XGUI_Workbench* aWbn = static_cast(myMenuTabs->widget(aTabIdx)); + XGUI_Workbench* aWbn; + foreach (aWbn, myWorkbenches) { aList.append(aWbn->features()); } return aList; diff --git a/src/XGUI/XGUI_MainMenu.h b/src/XGUI/XGUI_MainMenu.h index 29b87063f..4f3168548 100644 --- a/src/XGUI/XGUI_MainMenu.h +++ b/src/XGUI/XGUI_MainMenu.h @@ -78,6 +78,7 @@ private: XGUI_MainWindow* myDesktop; QTabWidget* myMenuTabs; XGUI_MenuGroupPanel* myGeneralPage; + QList myWorkbenches; QMap myCommandState; }; diff --git a/src/XGUI/XGUI_MainWindow.cpp b/src/XGUI/XGUI_MainWindow.cpp index 3aa696045..189f1cd35 100644 --- a/src/XGUI/XGUI_MainWindow.cpp +++ b/src/XGUI/XGUI_MainWindow.cpp @@ -66,11 +66,12 @@ QMdiArea* XGUI_MainWindow::mdiArea() const void XGUI_MainWindow::showPythonConsole() { // TODO: Check why PyConsole can not be created - //if (!myPythonConsole) { - // myPythonConsole = new PyConsole_EnhConsole(this, new PyConsole_EnhInterp()); - // undockPythonConsole(); - //} - //myPythonConsole->parentWidget()->show(); + if (!myPythonConsole) { + myPythonConsole = new PyConsole_EnhConsole(this, new PyConsole_EnhInterp()); + myPythonConsole->setObjectName("PythonConsole"); + undockPythonConsole(); + } + myPythonConsole->parentWidget()->show(); } //****************************************************** diff --git a/src/XGUI/XGUI_Workbench.cpp b/src/XGUI/XGUI_Workbench.cpp index f92380374..36efadf9f 100644 --- a/src/XGUI/XGUI_Workbench.cpp +++ b/src/XGUI/XGUI_Workbench.cpp @@ -188,8 +188,8 @@ XGUI_Command* XGUI_Workbench::feature(const QString& theId) const QList XGUI_Workbench::features() const { QList aList; - QList::const_iterator aIt; - for (aIt = myGroups.constBegin(); aIt != myGroups.constEnd(); ++aIt) - aList.append((*aIt)->features()); + foreach (XGUI_MenuGroupPanel* aGroup, myGroups) { + aList.append(aGroup->features()); + } return aList; } -- 2.39.2