From e483d95e6b01bc5c6b97bb596409db0b35e213f7 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Thu, 22 Jan 2015 19:54:23 +0100 Subject: [PATCH] Properly implement plane selection Does no longer rely on proper indexes (corresponding index in the listWidget and in the stackedWidget) but actually remebers which plane belongs to which list entry --- src/gui/Mainwindow.cxx | 9 +++++++-- src/gui/Mainwindow.hxx | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/Mainwindow.cxx b/src/gui/Mainwindow.cxx index d929094..8a62ef8 100644 --- a/src/gui/Mainwindow.cxx +++ b/src/gui/Mainwindow.cxx @@ -51,7 +51,7 @@ Mainwindow::Mainwindow(InformationManager* mgr) setCentralWidget(stackedWidget); connect(listWidget, SIGNAL(currentRowChanged(int)), - stackedWidget, SLOT(setCurrentIndex(int))); + this, SLOT(switchMainPlane(int))); setWindowTitle(tr("FRIDA")); @@ -80,6 +80,10 @@ void Mainwindow::open() { manager->reset(fileName.toStdString()); } +void Mainwindow::switchMainPlane(int index) { + stackedWidget->setCurrentWidget(objects_list[listWidget->currentItem()]); +} + void Mainwindow::showListContextMenu(const QPoint& point) { QListWidgetItem * item = listWidget->itemAt(point); if (item) { @@ -137,8 +141,9 @@ void Mainwindow::addFunction(Function* fun) { w->addTab(t, "Listing"); - listWidget->addItem(fun->getName().c_str()); + QListWidgetItem * item = new QListWidgetItem(fun->getName().c_str(), listWidget); stackedWidget->addWidget(w); + objects_list.insert(std::make_pair(item, w)); } namespace { diff --git a/src/gui/Mainwindow.hxx b/src/gui/Mainwindow.hxx index 953b315..efc7d99 100644 --- a/src/gui/Mainwindow.hxx +++ b/src/gui/Mainwindow.hxx @@ -40,6 +40,7 @@ private: QAction *openAction; std::map blocks; + std::map objects_list; std::set functions; InformationManager* manager; @@ -47,6 +48,7 @@ private: private Q_SLOTS: void quit(); void open(); + void switchMainPlane(int); void showListContextMenu(const QPoint&); void requestNewFunction(); }; -- 2.39.2