diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkSelectionServiceConnector.h b/Plugins/org.mitk.gui.qt.common/src/QmitkSelectionServiceConnector.h index a0d014eac1..6dc2989f1a 100644 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkSelectionServiceConnector.h +++ b/Plugins/org.mitk.gui.qt.common/src/QmitkSelectionServiceConnector.h @@ -1,140 +1,137 @@ /*=================================================================== 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 QMITKSELECTIONSERVICECONNECTOR_H #define QMITKSELECTIONSERVICECONNECTOR_H #include -// qt widgets module -#include - // mitk gui qt common plugin #include "QmitkDataNodeSelectionProvider.h" #include "internal/QmitkDataNodeItemModel.h" // blueberry ui qt plugin #include /* * @brief The 'QmitkSelectionServiceConnector' is used to handle the selections of the global selection bus (selection service). * * The selection service connector can listen to a selection service. This should be done by using 'AddPostSelectionListener' * with the existing selection service of the surrounding 'QmitkAbstractView'. * The selection service connector can provide selections. This should be done by using 'SetAsSelectionProvider' * with the existing selection provider of the surrounding 'QmitkAbstractView'. * * The 'QmitkSelectionServiceConnector' offers a public slot and signal that can be used to propagate the selected * nodes from or to the global selection bus: * The 'ChangeServiceSelection'-slot transforms the given list of selected nodes into a QItemSelection of a temporary * data node selection model. This data node selection model is set as the item selection model of the member selection provider. * So by temporary adding a new data node selection model and changing its selection the selection provider sends a new selection * that can be received at any place in the workbench. * * The 'ServiceSelectionChanged'-signal sends a list of selected nodes to it's local environment (e.g. containing widget). * The 'ServiceSelectionChanged'-signal is emitted by the 'ServiceSelectionChanged'-function, which transforms the * berry selection of the selection into a data node list. The 'ServiceSelectionChanged'-function is called whenever * the selection service sends a selection changed event. * * In order to connect the 'QmitkSelectionServiceConnector' with a model-view pair, a 'QmitkModelViewSelectionConnector' needs to be used: * The 'QmitkModelViewSelectionConnector' offers a 'SetCurrentSelection'-slot that can be connected with the * 'ServiceSelectionChanged'-signal of this class. * The 'QmitkModelViewSelectionConnector' offers a 'CurrentSelectionChanged'-signal that can be connected with the * 'ChangeServiceSelection'-slot of this class. */ class MITK_QT_COMMON QmitkSelectionServiceConnector : public QObject { Q_OBJECT public: QmitkSelectionServiceConnector(); ~QmitkSelectionServiceConnector(); /* * @brief Create a selection listener and add it to the list of selection listener of the given selection service. * * The selection listener is connected to the 'ServiceSelectionChanged' member function, which is * called if a berry selection is changed in the workbench. */ void AddPostSelectionListener(berry::ISelectionService* selectionService); /* * @brief Remove a selection listener from the list of selection listener of the selection service member. */ void RemovePostSelectionListener(); /* * @brief Store the given selection provider as a private member. * In order to use the public slot 'ChangeServiceSelection'-function, the selection provider member had to be * previously set. */ void SetAsSelectionProvider(QmitkDataNodeSelectionProvider* selectionProvider); /* * @brief Set the selection provider member to a nullptr. This will prevent the public slot * 'ChangeServiceSelection'-function from working. */ void RemoveAsSelectionProvider(); Q_SIGNALS: /* * @brief A signal that will be emitted by the private 'ServiceSelectionChanged'-function. This happens if a selection is changed * via the selection service. * * @par nodes A list of data nodes that are newly selected. */ void ServiceSelectionChanged(QList nodes); /* * @brief A signal that will be emitted by the private 'ServiceSelectionChanged'-function. If sourcePart has send an invalid selection * (selection pointer was Null). * @par sourcePart Part that sent the null selection. */ void ServiceNullSelection(const berry::IWorkbenchPart::Pointer& sourcePart); public Q_SLOTS: /* * @brief Send new selections to the selection service via the private selection provider member. * * This slot-function is called whenever a local selection is changed in the surrounding widget and a selection provider was set. * The newly selected data nodes are added temporary to a 'QmitkDataNodeItemModel', which is then used to define * the indices to select. * The 'QItemSelectionModel' is set as the item selection model of the selection provider member and its items are * selected by the indices previously defined by the 'QmitkDataNodeItemModel'. */ void ChangeServiceSelection(QList nodes); private: std::unique_ptr m_BerrySelectionListener; berry::ISelectionService* m_SelectionService; QmitkDataNodeSelectionProvider* m_SelectionProvider; std::shared_ptr m_DataNodeItemModel; std::shared_ptr m_DataNodeSelectionModel; /* * @brief Handle a selection received from the selection service. * * This function is called whenever a berry selection of the selection service is changed in the workbench. * The new selection is transformed into a data node selection and the contained data nodes are propagated * as the new current selection of the item view member. * * @par sourcePart The workbench part containing the selection. * @par selection The current selection. */ void OnServiceSelectionChanged(const berry::IWorkbenchPart::Pointer& sourcePart, const berry::ISelection::ConstPointer& selection); }; #endif // QMITKSELECTIONSERVICECONNECTOR_H 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 77f8edc873..c904bc5eb6 100644 --- a/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestControls.ui +++ b/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestControls.ui @@ -1,173 +1,183 @@ QmitkDataStorageViewerTestControls 0 0 945 456 0 0 Data storage viewer test + + + + + + Set as selection provider - - - Set as selection provider - - - - - + + - Allow only images + Set as selection listener - - + + - Is Optional + Set as selection listener - - - - Set as selection provider + + + + + 0 + 0 + + + + + 0 + 40 + - - + + + + + - Only valid nodes + Set as selection provider - - + + - Allow only images -(using NodePredicate feature and general invalid message) + Set as selection provider - - + + - Set as selection listener + Set as selection listner - - + + - Set as selection listener + Set as selection listner - + Only valid nodes - - + + - Set as selection listner + Only valid nodes - - + + - Set as selection listner + Allow only images - - + + - Set as selection provider + Allow only images (using NodePredicate feature and general invalid message) - - + + - Is Optional + Allow only uneven selection count (using check funcktion feature) - - - - - 0 - 0 - - - - - 0 - 40 - + + + + Is Optional - - - - - + + - Allow only uneven selection count -(using check funcktion feature) + Is Optional + + QmitkDataStorageListInspector + QWidget +
QmitkDataStorageListInspector.h
+ 1 +
+ + QmitkDataStorageTreeInspector + QWidget +
QmitkDataStorageTreeInspector.h
+ 1 +
QmitkSingleNodeSelectionWidget QWidget
QmitkSingleNodeSelectionWidget.h
1
QmitkMultiNodeSelectionWidget QWidget
QmitkMultiNodeSelectionWidget.h
1
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 75b1e89291..c402a0e2e6 100644 --- a/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.cpp +++ b/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.cpp @@ -1,278 +1,264 @@ /*=================================================================== 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" #include "mitkNodePredicateDataType.h" // berry #include -// qt -#include - 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_Controls.listInspector->SetDataStorage(GetDataStorage()); + m_Controls.treeInspector->SetDataStorage(GetDataStorage()); m_Controls.singleSlot->SetDataStorage(GetDataStorage()); m_Controls.singleSlot->SetEmptyInfo(QString("EmptyInfo: Set this to display info in empty state")); m_Controls.singleSlot->SetInvalidInfo(QString("InvalidInfo: is displayed for invalid states")); m_Controls.singleSlot->SetPopUpTitel(QString("This is the definable caption. Choose your data now!")); m_Controls.singleSlot->SetPopUpHint(QString("I am an optional hint, that can be set by the developer

If not set the widget is invisible.")); m_Controls.multiSlot->SetDataStorage(GetDataStorage()); m_Controls.multiSlot->SetEmptyInfo(QString("EmptyInfo: Set this to display info in empty state")); m_Controls.multiSlot->SetInvalidInfo(QString("InvalidInfo: is displayed for invalid states")); m_Controls.multiSlot->SetPopUpTitel(QString("This is the definable caption. Choose your data now!")); m_Controls.multiSlot->SetPopUpHint(QString("I am an optional hint, that can be set by the developer

If not set the widget is invisible.")); - m_ModelViewSelectionConnector = std::make_unique(); + m_ModelViewSelectionConnector1 = std::make_unique(); try { - m_ModelViewSelectionConnector->SetView(m_Controls.selectionListView); + m_ModelViewSelectionConnector1->SetView(m_Controls.listInspector->GetView()); } catch (mitk::Exception& e) { mitkReThrow(e) << "Cannot connect the model-view pair signals and slots."; } - m_SelectionServiceConnector = std::make_unique(); + m_SelectionServiceConnector1 = std::make_unique(); m_ModelViewSelectionConnector2 = std::make_unique(); try { - m_ModelViewSelectionConnector2->SetView(m_Controls.selectionListView2); + m_ModelViewSelectionConnector2->SetView(m_Controls.treeInspector->GetView()); } catch (mitk::Exception& e) { mitkReThrow(e) << "Cannot connect the model-view pair signals and slots."; } m_SelectionServiceConnector2 = std::make_unique(); m_SelectionServiceConnector3 = std::make_unique(); m_SelectionServiceConnector4 = std::make_unique(); - 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.selectionProviderCheckBox, &QCheckBox::toggled, this, &QmitkDataStorageViewerTestView::SetAsSelectionProvider1); + connect(m_Controls.selectionProviderCheckBox2, &QCheckBox::toggled, this, &QmitkDataStorageViewerTestView::SetAsSelectionProvider2); - 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.selectionListenerCheckBox, &QCheckBox::toggled, this, &QmitkDataStorageViewerTestView::SetAsSelectionListener1); + connect(m_Controls.selectionListenerCheckBox2, &QCheckBox::toggled, this, &QmitkDataStorageViewerTestView::SetAsSelectionListener2); - connect(m_Controls.selectionProviderCheckBox3, SIGNAL(toggled(bool)), this, SLOT(SetAsSelectionProvider3(bool))); - connect(m_Controls.selectionListenerCheckBox3, SIGNAL(toggled(bool)), this, SLOT(SetAsSelectionListener3(bool))); + connect(m_Controls.selectionProviderCheckBox3, &QCheckBox::toggled, this, &QmitkDataStorageViewerTestView::SetAsSelectionProvider3); + connect(m_Controls.selectionListenerCheckBox3, &QCheckBox::toggled, this, &QmitkDataStorageViewerTestView::SetAsSelectionListener3); - connect(m_Controls.checkOnlyVisible, SIGNAL(toggled(bool)), m_Controls.singleSlot, SLOT(SetSelectOnlyVisibleNodes(bool))); - connect(m_Controls.checkOptional, SIGNAL(toggled(bool)), m_Controls.singleSlot, SLOT(SetSelectionIsOptional(bool))); - connect(m_Controls.checkOnlyImages, SIGNAL(toggled(bool)), this, SLOT(OnOnlyImages(bool))); + connect(m_Controls.checkOnlyVisible1, &QCheckBox::toggled, m_Controls.singleSlot, &QmitkSingleNodeSelectionWidget::SetSelectOnlyVisibleNodes); + connect(m_Controls.checkOptional1, &QCheckBox::toggled, m_Controls.singleSlot, &QmitkSingleNodeSelectionWidget::SetSelectionIsOptional); + connect(m_Controls.checkOnlyImages1, &QCheckBox::toggled, this, &QmitkDataStorageViewerTestView::OnOnlyImages1); - connect(m_Controls.selectionProviderCheckBox4, SIGNAL(toggled(bool)), this, SLOT(SetAsSelectionProvider4(bool))); - connect(m_Controls.selectionListenerCheckBox4, SIGNAL(toggled(bool)), this, SLOT(SetAsSelectionListener4(bool))); + connect(m_Controls.selectionProviderCheckBox4, &QCheckBox::toggled, this, &QmitkDataStorageViewerTestView::SetAsSelectionProvider4); + connect(m_Controls.selectionListenerCheckBox4, &QCheckBox::toggled, this, &QmitkDataStorageViewerTestView::SetAsSelectionListener4); - connect(m_Controls.checkOnlyVisible_2, SIGNAL(toggled(bool)), m_Controls.multiSlot, SLOT(SetSelectOnlyVisibleNodes(bool))); - connect(m_Controls.checkOptional_2, SIGNAL(toggled(bool)), m_Controls.multiSlot, SLOT(SetSelectionIsOptional(bool))); - connect(m_Controls.checkOnlyImages_2, SIGNAL(toggled(bool)), this, SLOT(OnOnlyImages2(bool))); - connect(m_Controls.checkOnlyUneven, SIGNAL(toggled(bool)), this, SLOT(OnOnlyUneven(bool))); + connect(m_Controls.checkOnlyVisible2, &QCheckBox::toggled, m_Controls.multiSlot, &QmitkMultiNodeSelectionWidget::SetSelectOnlyVisibleNodes); + connect(m_Controls.checkOptional2, &QCheckBox::toggled, m_Controls.multiSlot, &QmitkMultiNodeSelectionWidget::SetSelectionIsOptional); + connect(m_Controls.checkOnlyImages2, &QCheckBox::toggled, this, &QmitkDataStorageViewerTestView::OnOnlyImages2); + connect(m_Controls.checkOnlyUneven, &QCheckBox::toggled, this, &QmitkDataStorageViewerTestView::OnOnlyUneven); } void QmitkDataStorageViewerTestView::SetAsSelectionProvider1(bool checked) { if (checked) { - m_SelectionServiceConnector->SetAsSelectionProvider(GetSite()->GetSelectionProvider().Cast().GetPointer()); - connect(m_ModelViewSelectionConnector.get(), SIGNAL(CurrentSelectionChanged(QList)), m_SelectionServiceConnector.get(), SLOT(ChangeServiceSelection(QList))); + m_SelectionServiceConnector1->SetAsSelectionProvider(GetSite()->GetSelectionProvider().Cast().GetPointer()); + connect(m_ModelViewSelectionConnector1.get(), &QmitkModelViewSelectionConnector::CurrentSelectionChanged, m_SelectionServiceConnector1.get(), &QmitkSelectionServiceConnector::ChangeServiceSelection); } else { - m_SelectionServiceConnector->RemoveAsSelectionProvider(); - disconnect(m_ModelViewSelectionConnector.get(), SIGNAL(CurrentSelectionChanged(QList)), m_SelectionServiceConnector.get(), SLOT(ChangeServiceSelection(QList))); + m_SelectionServiceConnector1->RemoveAsSelectionProvider(); + disconnect(m_ModelViewSelectionConnector1.get(), &QmitkModelViewSelectionConnector::CurrentSelectionChanged, m_SelectionServiceConnector1.get(), &QmitkSelectionServiceConnector::ChangeServiceSelection); } } void QmitkDataStorageViewerTestView::SetAsSelectionListener1(bool checked) { if (checked) { - m_SelectionServiceConnector->AddPostSelectionListener(GetSite()->GetWorkbenchWindow()->GetSelectionService()); - connect(m_SelectionServiceConnector.get(), SIGNAL(ServiceSelectionChanged(QList)), m_ModelViewSelectionConnector.get(), SLOT(SetCurrentSelection(QList))); + m_SelectionServiceConnector1->AddPostSelectionListener(GetSite()->GetWorkbenchWindow()->GetSelectionService()); + connect(m_SelectionServiceConnector1.get(), &QmitkSelectionServiceConnector::ServiceSelectionChanged, m_ModelViewSelectionConnector1.get(), &QmitkModelViewSelectionConnector::SetCurrentSelection); } else { - m_SelectionServiceConnector->RemovePostSelectionListener(); - disconnect(m_SelectionServiceConnector.get(), SIGNAL(ServiceSelectionChanged(QList)), m_ModelViewSelectionConnector.get(), SLOT(SetCurrentSelection(QList))); + m_SelectionServiceConnector1->RemovePostSelectionListener(); + disconnect(m_SelectionServiceConnector1.get(), &QmitkSelectionServiceConnector::ServiceSelectionChanged, m_ModelViewSelectionConnector1.get(), &QmitkModelViewSelectionConnector::SetCurrentSelection); } } void QmitkDataStorageViewerTestView::SetAsSelectionProvider2(bool checked) { if (checked) { m_SelectionServiceConnector2->SetAsSelectionProvider(GetSite()->GetSelectionProvider().Cast().GetPointer()); - connect(m_ModelViewSelectionConnector2.get(), SIGNAL(CurrentSelectionChanged(QList)), m_SelectionServiceConnector2.get(), SLOT(ChangeServiceSelection(QList))); + connect(m_ModelViewSelectionConnector2.get(), &QmitkModelViewSelectionConnector::CurrentSelectionChanged, m_SelectionServiceConnector2.get(), &QmitkSelectionServiceConnector::ChangeServiceSelection); } else { m_SelectionServiceConnector2->RemoveAsSelectionProvider(); - disconnect(m_ModelViewSelectionConnector2.get(), SIGNAL(CurrentSelectionChanged(QList)), m_SelectionServiceConnector2.get(), SLOT(ChangeServiceSelection(QList))); + disconnect(m_ModelViewSelectionConnector2.get(), &QmitkModelViewSelectionConnector::CurrentSelectionChanged, m_SelectionServiceConnector2.get(), &QmitkSelectionServiceConnector::ChangeServiceSelection); } } void QmitkDataStorageViewerTestView::SetAsSelectionListener2(bool checked) { if (checked) { m_SelectionServiceConnector2->AddPostSelectionListener(GetSite()->GetWorkbenchWindow()->GetSelectionService()); - connect(m_SelectionServiceConnector2.get(), SIGNAL(ServiceSelectionChanged(QList)), m_ModelViewSelectionConnector2.get(), SLOT(SetCurrentSelection(QList))); + connect(m_SelectionServiceConnector2.get(), &QmitkSelectionServiceConnector::ServiceSelectionChanged, m_ModelViewSelectionConnector2.get(), &QmitkModelViewSelectionConnector::SetCurrentSelection); } else { m_SelectionServiceConnector2->RemovePostSelectionListener(); - disconnect(m_SelectionServiceConnector2.get(), SIGNAL(ServiceSelectionChanged(QList)), m_ModelViewSelectionConnector2.get(), SLOT(SetCurrentSelection(QList))); + disconnect(m_SelectionServiceConnector2.get(), &QmitkSelectionServiceConnector::ServiceSelectionChanged, m_ModelViewSelectionConnector2.get(), &QmitkModelViewSelectionConnector::SetCurrentSelection); } } void QmitkDataStorageViewerTestView::SetAsSelectionProvider3(bool checked) { if (checked) { m_SelectionServiceConnector3->SetAsSelectionProvider(GetSite()->GetSelectionProvider().Cast().GetPointer()); - connect(m_Controls.singleSlot, SIGNAL(CurrentSelectionChanged(QList)), m_SelectionServiceConnector3.get(), SLOT(ChangeServiceSelection(QList))); + connect(m_Controls.singleSlot, &QmitkSingleNodeSelectionWidget::CurrentSelectionChanged, m_SelectionServiceConnector3.get(), &QmitkSelectionServiceConnector::ChangeServiceSelection); } else { m_SelectionServiceConnector3->RemoveAsSelectionProvider(); - disconnect(m_Controls.singleSlot, SIGNAL(CurrentSelectionChanged(QList)), m_SelectionServiceConnector3.get(), SLOT(ChangeServiceSelection(QList))); + disconnect(m_Controls.singleSlot, &QmitkSingleNodeSelectionWidget::CurrentSelectionChanged, m_SelectionServiceConnector3.get(), &QmitkSelectionServiceConnector::ChangeServiceSelection); } } void QmitkDataStorageViewerTestView::SetAsSelectionListener3(bool checked) { if (checked) { m_SelectionServiceConnector3->AddPostSelectionListener(GetSite()->GetWorkbenchWindow()->GetSelectionService()); connect(m_SelectionServiceConnector3.get(), &QmitkSelectionServiceConnector::ServiceSelectionChanged, m_Controls.singleSlot, &QmitkSingleNodeSelectionWidget::SetCurrentSelection); } else { m_SelectionServiceConnector3->RemovePostSelectionListener(); disconnect(m_SelectionServiceConnector3.get(), &QmitkSelectionServiceConnector::ServiceSelectionChanged, m_Controls.singleSlot, &QmitkSingleNodeSelectionWidget::SetCurrentSelection); } } void QmitkDataStorageViewerTestView::SetAsSelectionProvider4(bool checked) { if (checked) { m_SelectionServiceConnector4->SetAsSelectionProvider(GetSite()->GetSelectionProvider().Cast().GetPointer()); - connect(m_Controls.multiSlot, SIGNAL(CurrentSelectionChanged(QList)), m_SelectionServiceConnector4.get(), SLOT(ChangeServiceSelection(QList))); + connect(m_Controls.multiSlot, &QmitkMultiNodeSelectionWidget::CurrentSelectionChanged, m_SelectionServiceConnector4.get(), &QmitkSelectionServiceConnector::ChangeServiceSelection); } else { m_SelectionServiceConnector4->RemoveAsSelectionProvider(); - disconnect(m_Controls.multiSlot, SIGNAL(CurrentSelectionChanged(QList)), m_SelectionServiceConnector4.get(), SLOT(ChangeServiceSelection(QList))); + disconnect(m_Controls.multiSlot, &QmitkMultiNodeSelectionWidget::CurrentSelectionChanged, m_SelectionServiceConnector4.get(), &QmitkSelectionServiceConnector::ChangeServiceSelection); } } void QmitkDataStorageViewerTestView::SetAsSelectionListener4(bool checked) { if (checked) { m_SelectionServiceConnector4->AddPostSelectionListener(GetSite()->GetWorkbenchWindow()->GetSelectionService()); connect(m_SelectionServiceConnector4.get(), &QmitkSelectionServiceConnector::ServiceSelectionChanged, m_Controls.multiSlot, &QmitkMultiNodeSelectionWidget::SetCurrentSelection); } else { m_SelectionServiceConnector4->RemovePostSelectionListener(); disconnect(m_SelectionServiceConnector4.get(), &QmitkSelectionServiceConnector::ServiceSelectionChanged, m_Controls.multiSlot, &QmitkMultiNodeSelectionWidget::SetCurrentSelection); } } -void QmitkDataStorageViewerTestView::OnOnlyImages(bool checked) +void QmitkDataStorageViewerTestView::OnOnlyImages1(bool checked) { if (checked) { m_Controls.singleSlot->SetNodePredicate(mitk::NodePredicateDataType::New("Image")); } else { m_Controls.singleSlot->SetNodePredicate(nullptr); } } void QmitkDataStorageViewerTestView::OnOnlyImages2(bool checked) { if (checked) { m_Controls.multiSlot->SetNodePredicate(mitk::NodePredicateDataType::New("Image")); m_Controls.multiSlot->SetInvalidInfo(QString("InvalidInfo: is displayed for invalid states. Only images allowed!")); } else { m_Controls.multiSlot->SetNodePredicate(nullptr); m_Controls.multiSlot->SetInvalidInfo(QString("InvalidInfo: is displayed for invalid states")); } }; void QmitkDataStorageViewerTestView::OnOnlyUneven(bool checked) { if (checked) { auto checkFunction = [](const QmitkMultiNodeSelectionWidget::NodeList & nodes) { if (!(nodes.size() % 2)) { std::stringstream ss; ss << "

Invalid selection.

The number of selected nodes must be even! the current number is " << nodes.size() << ".

"; return ss.str(); } return std::string(); }; m_Controls.multiSlot->SetSelectionCheckFunction(checkFunction); } else { auto checkFunction = [](const QmitkMultiNodeSelectionWidget::NodeList & /*nodes*/) { return std::string(); }; m_Controls.multiSlot->SetSelectionCheckFunction(checkFunction); } } 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 157775f528..116effbe7f 100644 --- a/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.h +++ b/Plugins/org.mitk.gui.qt.datastorageviewertest/src/internal/QmitkDataStorageViewerTestView.h @@ -1,78 +1,73 @@ /*=================================================================== 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 #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 SetAsSelectionProvider4(bool checked); void SetAsSelectionListener1(bool checked); void SetAsSelectionListener2(bool checked); void SetAsSelectionListener3(bool checked); void SetAsSelectionListener4(bool checked); - void OnOnlyImages(bool checked); + void OnOnlyImages1(bool checked); void OnOnlyImages2(bool checked); void OnOnlyUneven(bool checked); private: Ui::QmitkDataStorageViewerTestControls m_Controls; - QmitkDataStorageDefaultListModel* m_DataStorageDefaultListModel; - QmitkDataStorageDefaultListModel* m_DataStorageDefaultListModel2; - std::unique_ptr m_ModelViewSelectionConnector; - std::unique_ptr m_SelectionServiceConnector; + std::unique_ptr m_ModelViewSelectionConnector1; + std::unique_ptr m_SelectionServiceConnector1; std::unique_ptr m_ModelViewSelectionConnector2; std::unique_ptr m_SelectionServiceConnector2; std::unique_ptr m_SelectionServiceConnector3; std::unique_ptr m_SelectionServiceConnector4; }; #endif // QMITKDATASTORAGEVIEWERTESTVIEW_H