Skip to content
Snippets Groups Projects
Commit b6fda5be authored by dt's avatar dt
Browse files

Progress so far

parent 0f3d8b65
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,6 @@ using namespace Debugger::Internal; ...@@ -36,7 +36,6 @@ using namespace Debugger::Internal;
DebuggerUISwitcher *DebuggerUISwitcher::m_instance = 0; DebuggerUISwitcher *DebuggerUISwitcher::m_instance = 0;
DebuggerUISwitcher::DebuggerUISwitcher(Core::BaseMode *mode, QObject* parent) : QObject(parent), DebuggerUISwitcher::DebuggerUISwitcher(Core::BaseMode *mode, QObject* parent) : QObject(parent),
m_model(new QStandardItemModel(this)),
m_toolbarStack(new QStackedWidget), m_toolbarStack(new QStackedWidget),
m_languageActionGroup(new QActionGroup(this)), m_languageActionGroup(new QActionGroup(this)),
m_activeLanguage(-1), m_activeLanguage(-1),
...@@ -77,11 +76,7 @@ void DebuggerUISwitcher::addMenuAction(Core::Command *command, const QString &gr ...@@ -77,11 +76,7 @@ void DebuggerUISwitcher::addMenuAction(Core::Command *command, const QString &gr
void DebuggerUISwitcher::setActiveLanguage(const QString &langName) void DebuggerUISwitcher::setActiveLanguage(const QString &langName)
{ {
QModelIndex idx = modelIndexForLanguage(langName); changeDebuggerUI(langName);
if (!idx.isValid())
return;
changeDebuggerUI(idx.row());
} }
...@@ -163,9 +158,8 @@ DebuggerUISwitcher *DebuggerUISwitcher::instance() ...@@ -163,9 +158,8 @@ DebuggerUISwitcher *DebuggerUISwitcher::instance()
void DebuggerUISwitcher::addLanguage(const QString &langName) void DebuggerUISwitcher::addLanguage(const QString &langName)
{ {
QStandardItem* item = new QStandardItem(langName); m_toolBars.insert(langName, 0);
m_languages.append(langName);
m_model->appendRow(item);
Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionManager *am = Core::ICore::instance()->actionManager();
QAction *langChange = new QAction(langName, this); QAction *langChange = new QAction(langName, this);
...@@ -185,23 +179,21 @@ void DebuggerUISwitcher::langChangeTriggered() ...@@ -185,23 +179,21 @@ void DebuggerUISwitcher::langChangeTriggered()
{ {
QObject *sdr = sender(); QObject *sdr = sender();
QAction *act = qobject_cast<QAction*>(sdr); QAction *act = qobject_cast<QAction*>(sdr);
changeDebuggerUI(modelIndexForLanguage(act->text()).row()); changeDebuggerUI(act->text());
} }
void DebuggerUISwitcher::changeDebuggerUI(int langId) void DebuggerUISwitcher::changeDebuggerUI(const QString &langName)
{ {
if (m_changingUI) if (m_changingUI)
return; return;
m_changingUI = true; m_changingUI = true;
// id int langId = m_languages.indexOf(langName);
QModelIndex idx = m_model->index(langId, 0);
if (langId != m_activeLanguage) { if (langId != m_activeLanguage) {
m_languageActionGroup->actions()[langId]->setChecked(true); m_languageActionGroup->actions()[langId]->setChecked(true);
m_activeLanguage = langId; m_activeLanguage = langId;
m_toolbarStack->setCurrentIndex(m_model->data(idx, StackIndexRole).toInt()); m_toolbarStack->setCurrentWidget(m_toolBars.value(langName));
foreach (DebugToolWindow *window, m_dockWidgets) { foreach (DebugToolWindow *window, m_dockWidgets) {
if (window->m_languageId != langId) { if (window->m_languageId != langId) {
...@@ -224,31 +216,18 @@ void DebuggerUISwitcher::changeDebuggerUI(int langId) ...@@ -224,31 +216,18 @@ void DebuggerUISwitcher::changeDebuggerUI(int langId)
menuitem.second->setVisible(false); menuitem.second->setVisible(false);
} }
} }
m_languageMenu->menu()->setTitle(tr("Language") + " (" + idx.data().toString() + ")"); m_languageMenu->menu()->setTitle(tr("Language") + " (" + langName + ")");
emit languageChanged(idx.data().toString()); emit languageChanged(langName);
} }
m_changingUI = false; m_changingUI = false;
} }
QModelIndex DebuggerUISwitcher::modelIndexForLanguage(const QString& languageName)
{
QList<QStandardItem*> items = m_model->findItems(languageName);
if (items.length() != 1)
return QModelIndex();
return m_model->indexFromItem(items.at(0));
}
void DebuggerUISwitcher::setToolbar(const QString &langName, QWidget *widget) void DebuggerUISwitcher::setToolbar(const QString &langName, QWidget *widget)
{ {
QModelIndex modelIdx = modelIndexForLanguage(langName); Q_ASSERT(m_toolBars.contains(langName));
if (!modelIdx.isValid()) m_toolBars[langName] = widget;
return; m_toolbarStack->addWidget(widget);
int stackIdx = m_toolbarStack->addWidget(widget);
m_model->setData(modelIdx, stackIdx, StackIndexRole);
} }
DebuggerMainWindow *DebuggerUISwitcher::mainWindow() const DebuggerMainWindow *DebuggerUISwitcher::mainWindow() const
...@@ -311,13 +290,13 @@ QDockWidget *DebuggerUISwitcher::createDockWidget(const QString &langName, QWidg ...@@ -311,13 +290,13 @@ QDockWidget *DebuggerUISwitcher::createDockWidget(const QString &langName, QWidg
QDockWidget *dockWidget = m_mainWindow->addDockForWidget(widget); QDockWidget *dockWidget = m_mainWindow->addDockForWidget(widget);
m_mainWindow->addDockWidget(area, dockWidget); m_mainWindow->addDockWidget(area, dockWidget);
DebugToolWindow *window = new DebugToolWindow; DebugToolWindow *window = new DebugToolWindow;
window->m_languageId = modelIndexForLanguage(langName).row(); window->m_languageId = m_languages.indexOf(langName);
window->m_dockWidget = dockWidget; window->m_dockWidget = dockWidget;
window->m_visible = visibleByDefault; window->m_visible = visibleByDefault;
m_dockWidgets.append(window); m_dockWidgets.append(window);
if (modelIndexForLanguage(langName).row() != m_activeLanguage) if (m_languages.indexOf(langName) != m_activeLanguage)
dockWidget->hide(); dockWidget->hide();
Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionManager *am = Core::ICore::instance()->actionManager();
...@@ -325,7 +304,7 @@ QDockWidget *DebuggerUISwitcher::createDockWidget(const QString &langName, QWidg ...@@ -325,7 +304,7 @@ QDockWidget *DebuggerUISwitcher::createDockWidget(const QString &langName, QWidg
"Debugger." + dockWidget->objectName(), m_debuggercontext); "Debugger." + dockWidget->objectName(), m_debuggercontext);
m_viewsMenu->addAction(cmd); m_viewsMenu->addAction(cmd);
m_viewsMenuItems.append(qMakePair(modelIndexForLanguage(langName).row(), dockWidget->toggleViewAction())); m_viewsMenuItems.append(qMakePair(m_languages.indexOf(langName), dockWidget->toggleViewAction()));
return dockWidget; return dockWidget;
} }
...@@ -392,14 +371,14 @@ void DebuggerUISwitcher::initialize() ...@@ -392,14 +371,14 @@ void DebuggerUISwitcher::initialize()
readSettings(); readSettings();
if (m_activeLanguage == -1) { if (m_activeLanguage == -1) {
changeDebuggerUI(0); changeDebuggerUI(m_languages.first());
} }
hideInactiveWidgets(); hideInactiveWidgets();
} }
void DebuggerUISwitcher::resetDebuggerLayout() void DebuggerUISwitcher::resetDebuggerLayout()
{ {
emit dockArranged(m_model->index(m_activeLanguage, 0).data().toString()); emit dockArranged(m_languages.at(m_activeLanguage));
} }
} }
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#include <coreplugin/basemode.h> #include <coreplugin/basemode.h>
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtGui/QStandardItemModel>
#include <QtCore/QList> #include <QtCore/QList>
#include <QtCore/QMap>
namespace Core { namespace Core {
class ActionContainer; class ActionContainer;
...@@ -73,7 +73,7 @@ signals: ...@@ -73,7 +73,7 @@ signals:
private slots: private slots:
void modeChanged(Core::IMode *mode); void modeChanged(Core::IMode *mode);
void changeDebuggerUI(int langId); void changeDebuggerUI(const QString &langName);
void resetDebuggerLayout(); void resetDebuggerLayout();
void langChangeTriggered(); void langChangeTriggered();
...@@ -82,7 +82,6 @@ private: ...@@ -82,7 +82,6 @@ private:
void createViewsMenuItems(); void createViewsMenuItems();
void readSettings(); void readSettings();
void writeSettings() const; void writeSettings() const;
QModelIndex modelIndexForLanguage(const QString &langName);
QWidget *createContents(Core::BaseMode *mode); QWidget *createContents(Core::BaseMode *mode);
QWidget *createMainWindow(Core::BaseMode *mode); QWidget *createMainWindow(Core::BaseMode *mode);
...@@ -90,7 +89,10 @@ private: ...@@ -90,7 +89,10 @@ private:
typedef QPair<int, QAction* > ViewsMenuItems; typedef QPair<int, QAction* > ViewsMenuItems;
QList< ViewsMenuItems > m_viewsMenuItems; QList< ViewsMenuItems > m_viewsMenuItems;
QList< Internal::DebugToolWindow* > m_dockWidgets; QList< Internal::DebugToolWindow* > m_dockWidgets;
QStandardItemModel *m_model;
QMap<QString, QWidget *> m_toolBars;
QStringList m_languages;
QStackedWidget *m_toolbarStack; QStackedWidget *m_toolbarStack;
DebuggerMainWindow *m_mainWindow; DebuggerMainWindow *m_mainWindow;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment