diff --git a/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestControls.ui b/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestControls.ui index 04d4c4ad16..df889be58d 100644 --- a/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestControls.ui +++ b/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestControls.ui @@ -1,79 +1,93 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>QmitkDataStorageViewerTestControls</class> <widget class="QWidget" name="QmitkDataStorageViewerTestControls"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>451</width> <height>572</height> </rect> </property> <property name="minimumSize"> <size> <width>0</width> <height>0</height> </size> </property> <property name="windowTitle"> <string>Data storage viewer test</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="1" column="1"> - <widget class="QCheckBox" name="selectionProviderCheckBox2"> + <item row="1" column="0"> + <widget class="QCheckBox" name="selectionProviderCheckBox"> <property name="text"> <string>Set as selection provider</string> </property> </widget> </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="selectionProviderCheckBox"> + <item row="2" column="1"> + <widget class="QCheckBox" name="selectionListenerCheckBox2"> <property name="text"> - <string>Set as selection provider</string> + <string>Set as selection listener</string> </property> </widget> </item> - <item row="0" column="0"> - <widget class="QListView" name="selectionListView"/> + <item row="2" column="0"> + <widget class="QCheckBox" name="selectionListenerCheckBox"> + <property name="text"> + <string>Set as selection listener</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="selectionProviderCheckBox2"> + <property name="text"> + <string>Set as selection provider</string> + </property> + </widget> </item> <item row="0" column="1"> <widget class="QListView" name="selectionListView2"/> </item> + <item row="0" column="0"> + <widget class="QListView" name="selectionListView"/> + </item> <item row="4" column="0"> - <widget class="QCheckBox" name="checkBox"> + <widget class="QCheckBox" name="selectionProviderCheckBox3"> + <property name="text"> + <string>Set as selection provider</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QCheckBox" name="selectionListenerCheckBox3"> <property name="text"> <string>Set as selection listner</string> </property> </widget> </item> - <item row="2" column="0"> - <widget class="QmitkSingleNodeSelectionWidget" name="singelSlot" native="true"> + <item row="3" column="0"> + <widget class="QmitkSingleNodeSelectionWidget" name="singleSlot" native="true"> <property name="minimumSize"> <size> <width>0</width> <height>40</height> </size> </property> </widget> </item> - <item row="3" column="0"> - <widget class="QCheckBox" name="checkBox_2"> - <property name="text"> - <string>Set as selection provider</string> - </property> - </widget> - </item> </layout> </widget> <customwidgets> <customwidget> <class>QmitkSingleNodeSelectionWidget</class> <extends>QWidget</extends> - <header>QmitkSingleNodeSelectionWidget.h</header> + <header location="global">QmitkSingleNodeSelectionWidget.h</header> <container>1</container> </customwidget> </customwidgets> <resources/> <connections/> </ui> diff --git a/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.cpp b/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.cpp index 006d1d35c3..a08f599516 100644 --- a/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.cpp +++ b/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.cpp @@ -1,110 +1,170 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // data storage viewer test plugin #include "QmitkDataStorageViewerTestView.h" // berry #include <berryIWorkbenchWindow.h> // qt #include <QHBoxLayout> const std::string QmitkDataStorageViewerTestView::VIEW_ID = "org.mitk.views.datastorageviewertest"; void QmitkDataStorageViewerTestView::SetFocus() { // nothing here } void QmitkDataStorageViewerTestView::CreateQtPartControl(QWidget* parent) { // create GUI widgets m_Controls.setupUi(parent); m_DataStorageDefaultListModel = new QmitkDataStorageDefaultListModel(this); m_DataStorageDefaultListModel->SetDataStorage(GetDataStorage()); m_Controls.selectionListView->setSelectionMode(QAbstractItemView::ExtendedSelection); m_Controls.selectionListView->setSelectionBehavior(QAbstractItemView::SelectRows); m_Controls.selectionListView->setAlternatingRowColors(true); m_Controls.selectionListView->setModel(m_DataStorageDefaultListModel); m_DataStorageDefaultListModel2 = new QmitkDataStorageDefaultListModel(this); m_DataStorageDefaultListModel2->SetDataStorage(GetDataStorage()); m_Controls.selectionListView2->setSelectionMode(QAbstractItemView::ExtendedSelection); m_Controls.selectionListView2->setSelectionBehavior(QAbstractItemView::SelectRows); m_Controls.selectionListView2->setAlternatingRowColors(true); m_Controls.selectionListView2->setModel(m_DataStorageDefaultListModel2); m_ModelViewSelectionConnector = std::make_unique<QmitkModelViewSelectionConnector>(); try { m_ModelViewSelectionConnector->SetView(m_Controls.selectionListView); } catch (mitk::Exception& e) { mitkReThrow(e) << "Cannot connect the model-view pair signals and slots."; } - m_SelectionServiceConnector = std::make_unique<QmitkSelectionServiceConnector>(); - m_SelectionServiceConnector->AddPostSelectionListener(GetSite()->GetWorkbenchWindow()->GetSelectionService()); - connect(m_SelectionServiceConnector.get(), SIGNAL(ServiceSelectionChanged(QList<mitk::DataNode::Pointer>)), m_ModelViewSelectionConnector.get(), SLOT(SetCurrentSelection(QList<mitk::DataNode::Pointer>))); m_ModelViewSelectionConnector2 = std::make_unique<QmitkModelViewSelectionConnector>(); try { m_ModelViewSelectionConnector2->SetView(m_Controls.selectionListView2); } catch (mitk::Exception& e) { mitkReThrow(e) << "Cannot connect the model-view pair signals and slots."; } - m_SelectionServiceConnector2 = std::make_unique<QmitkSelectionServiceConnector>(); - m_SelectionServiceConnector2->AddPostSelectionListener(GetSite()->GetWorkbenchWindow()->GetSelectionService()); - connect(m_SelectionServiceConnector2.get(), SIGNAL(ServiceSelectionChanged(QList<mitk::DataNode::Pointer>)), m_ModelViewSelectionConnector2.get(), SLOT(SetCurrentSelection(QList<mitk::DataNode::Pointer>))); + + m_SelectionServiceConnector3 = std::make_unique<QmitkSelectionServiceConnector>(); connect(m_Controls.selectionProviderCheckBox, SIGNAL(toggled(bool)), this, SLOT(SetAsSelectionProvider1(bool))); connect(m_Controls.selectionProviderCheckBox2, SIGNAL(toggled(bool)), this, SLOT(SetAsSelectionProvider2(bool))); + + connect(m_Controls.selectionListenerCheckBox, SIGNAL(toggled(bool)), this, SLOT(SetAsSelectionListener1(bool))); + connect(m_Controls.selectionListenerCheckBox2, SIGNAL(toggled(bool)), this, SLOT(SetAsSelectionListener2(bool))); + + connect(m_Controls.selectionProviderCheckBox3, SIGNAL(toggled(bool)), this, SLOT(SetAsSelectionProvider3(bool))); + connect(m_Controls.selectionListenerCheckBox3, SIGNAL(toggled(bool)), this, SLOT(SetAsSelectionListener3(bool))); + } void QmitkDataStorageViewerTestView::SetAsSelectionProvider1(bool checked) { if (checked) { m_SelectionServiceConnector->SetAsSelectionProvider(GetSite()->GetSelectionProvider().Cast<QmitkDataNodeSelectionProvider>().GetPointer()); connect(m_ModelViewSelectionConnector.get(), SIGNAL(CurrentSelectionChanged(QList<mitk::DataNode::Pointer>)), m_SelectionServiceConnector.get(), SLOT(ChangeServiceSelection(QList<mitk::DataNode::Pointer>))); } else { m_SelectionServiceConnector->RemoveAsSelectionProvider(); disconnect(m_ModelViewSelectionConnector.get(), SIGNAL(CurrentSelectionChanged(QList<mitk::DataNode::Pointer>)), m_SelectionServiceConnector.get(), SLOT(ChangeServiceSelection(QList<mitk::DataNode::Pointer>))); } } +void QmitkDataStorageViewerTestView::SetAsSelectionListener1(bool checked) +{ + if (checked) + { + m_SelectionServiceConnector->AddPostSelectionListener(GetSite()->GetWorkbenchWindow()->GetSelectionService()); + connect(m_SelectionServiceConnector.get(), SIGNAL(ServiceSelectionChanged(QList<mitk::DataNode::Pointer>)), m_ModelViewSelectionConnector.get(), SLOT(SetCurrentSelection(QList<mitk::DataNode::Pointer>))); + } + else + { + m_SelectionServiceConnector->RemovePostSelectionListener(); + disconnect(m_SelectionServiceConnector.get(), SIGNAL(ServiceSelectionChanged(QList<mitk::DataNode::Pointer>)), m_ModelViewSelectionConnector.get(), SLOT(SetCurrentSelection(QList<mitk::DataNode::Pointer>))); + + } +} + void QmitkDataStorageViewerTestView::SetAsSelectionProvider2(bool checked) { if (checked) { m_SelectionServiceConnector2->SetAsSelectionProvider(GetSite()->GetSelectionProvider().Cast<QmitkDataNodeSelectionProvider>().GetPointer()); connect(m_ModelViewSelectionConnector2.get(), SIGNAL(CurrentSelectionChanged(QList<mitk::DataNode::Pointer>)), m_SelectionServiceConnector2.get(), SLOT(ChangeServiceSelection(QList<mitk::DataNode::Pointer>))); } else { m_SelectionServiceConnector2->RemoveAsSelectionProvider(); disconnect(m_ModelViewSelectionConnector2.get(), SIGNAL(CurrentSelectionChanged(QList<mitk::DataNode::Pointer>)), m_SelectionServiceConnector2.get(), SLOT(ChangeServiceSelection(QList<mitk::DataNode::Pointer>))); } } + +void QmitkDataStorageViewerTestView::SetAsSelectionListener2(bool checked) +{ + if (checked) + { + m_SelectionServiceConnector2->AddPostSelectionListener(GetSite()->GetWorkbenchWindow()->GetSelectionService()); + connect(m_SelectionServiceConnector2.get(), SIGNAL(ServiceSelectionChanged(QList<mitk::DataNode::Pointer>)), m_ModelViewSelectionConnector2.get(), SLOT(SetCurrentSelection(QList<mitk::DataNode::Pointer>))); + } + else + { + m_SelectionServiceConnector2->RemovePostSelectionListener(); + disconnect(m_SelectionServiceConnector2.get(), SIGNAL(ServiceSelectionChanged(QList<mitk::DataNode::Pointer>)), m_ModelViewSelectionConnector2.get(), SLOT(SetCurrentSelection(QList<mitk::DataNode::Pointer>))); + } +} + +void QmitkDataStorageViewerTestView::SetAsSelectionProvider3(bool checked) +{ + if (checked) + { + m_SelectionServiceConnector3->SetAsSelectionProvider(GetSite()->GetSelectionProvider().Cast<QmitkDataNodeSelectionProvider>().GetPointer()); + connect(m_Controls.singleSlot, SIGNAL(CurrentSelectionChanged(QList<mitk::DataNode::Pointer>)), m_SelectionServiceConnector.get(), SLOT(ChangeServiceSelection(QList<mitk::DataNode::Pointer>))); + } + else + { + m_SelectionServiceConnector3->RemoveAsSelectionProvider(); + disconnect(m_Controls.singleSlot, SIGNAL(CurrentSelectionChanged(QList<mitk::DataNode::Pointer>)), m_SelectionServiceConnector.get(), SLOT(ChangeServiceSelection(QList<mitk::DataNode::Pointer>))); + } +} + +void QmitkDataStorageViewerTestView::SetAsSelectionListener3(bool checked) +{ + if (checked) + { + m_SelectionServiceConnector3->AddPostSelectionListener(GetSite()->GetWorkbenchWindow()->GetSelectionService()); + connect(m_SelectionServiceConnector3.get(), SIGNAL(ServiceSelectionChanged(QList<mitk::DataNode::Pointer>)), m_Controls.singleSlot, SLOT(SetCurrentSelection(QList<mitk::DataNode::Pointer>))); + } + else + { + m_SelectionServiceConnector3->RemovePostSelectionListener(); + disconnect(m_SelectionServiceConnector3.get(), SIGNAL(ServiceSelectionChanged(QList<mitk::DataNode::Pointer>)), m_Controls.singleSlot, SLOT(SetCurrentSelection(QList<mitk::DataNode::Pointer>))); + } +} \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.h b/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.h index 3e2f86faef..24ba825f22 100644 --- a/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.h +++ b/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.h @@ -1,65 +1,71 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKDATASTORAGEVIEWERTESTVIEW_H #define QMITKDATASTORAGEVIEWERTESTVIEW_H // mitk gui qt common plugin #include <QmitkAbstractView.h> #include "QmitkModelViewSelectionConnector.h" #include "QmitkSelectionServiceConnector.h" // data storage viewer test plugin #include "ui_QmitkDataStorageViewerTestControls.h" // qt widgets module #include "QmitkDataStorageDefaultListModel.h" /** * @brief DataStorageViewerTestView */ class QmitkDataStorageViewerTestView : public QmitkAbstractView { Q_OBJECT public: static const std::string VIEW_ID; protected: virtual void SetFocus() override; virtual void CreateQtPartControl(QWidget* parent) override; private Q_SLOTS: void SetAsSelectionProvider1(bool checked); void SetAsSelectionProvider2(bool checked); + void SetAsSelectionProvider3(bool checked); + void SetAsSelectionListener1(bool checked); + void SetAsSelectionListener2(bool checked); + void SetAsSelectionListener3(bool checked); private: Ui::QmitkDataStorageViewerTestControls m_Controls; QmitkDataStorageDefaultListModel* m_DataStorageDefaultListModel; QmitkDataStorageDefaultListModel* m_DataStorageDefaultListModel2; std::unique_ptr<QmitkModelViewSelectionConnector> m_ModelViewSelectionConnector; std::unique_ptr<QmitkSelectionServiceConnector> m_SelectionServiceConnector; std::unique_ptr<QmitkModelViewSelectionConnector> m_ModelViewSelectionConnector2; std::unique_ptr<QmitkSelectionServiceConnector> m_SelectionServiceConnector2; + + std::unique_ptr<QmitkSelectionServiceConnector> m_SelectionServiceConnector3; }; #endif // QMITKDATASTORAGEVIEWERTESTVIEW_H