diff --git a/Modules/QtWidgets/include/QmitkMultiNodeSelectionWidget.h b/Modules/QtWidgets/include/QmitkMultiNodeSelectionWidget.h index a82e42d432..0705e7dac8 100644 --- a/Modules/QtWidgets/include/QmitkMultiNodeSelectionWidget.h +++ b/Modules/QtWidgets/include/QmitkMultiNodeSelectionWidget.h @@ -1,79 +1,79 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QMITK_MULTI_NODE_SELECTION_WIDGET_H #define QMITK_MULTI_NODE_SELECTION_WIDGET_H #include -#include "ui_QmitkMultiNodeSelectionWidget.h" +#include #include #include #include #include #include class QmitkAbstractDataStorageModel; /** * @class QmitkMultiNodeSelectionWidget * @brief Widget that allows to perform and represents a multiple node selection. */ class MITKQTWIDGETS_EXPORT QmitkMultiNodeSelectionWidget : public QmitkAbstractNodeSelectionWidget { Q_OBJECT public: explicit QmitkMultiNodeSelectionWidget(QWidget* parent = nullptr); using NodeList = QmitkAbstractNodeSelectionWidget::NodeList; /** * @brief Helper function that is used to check the given selection for consistency. * Returning an empty string assumes that everything is alright and the selection * is valid. If the string is not empty, the content of the string will be used * as error message in the overlay to indicate the problem. */ using SelectionCheckFunctionType = std::function; /** * @brief A selection check function can be set. If set the widget uses this function to * check the made/set selection. If the selection is valid, everything is fine. * If selection is indicated as invalid, it will not be communicated by the widget * (no signal emission). */ void SetSelectionCheckFunction(const SelectionCheckFunctionType &checkFunction); public Q_SLOTS: void OnEditSelection(); protected Q_SLOTS: void OnClearSelection(const mitk::DataNode* node); protected: void changeEvent(QEvent *event) override; void UpdateInfo() override; void OnInternalSelectionChanged() override; bool AllowEmissionOfSelection(const NodeList& emissionCandidates) const override; QmitkSimpleTextOverlayWidget* m_Overlay; SelectionCheckFunctionType m_CheckFunction; mutable std::string m_CheckResponse; Ui_QmitkMultiNodeSelectionWidget m_Controls; }; #endif // QMITK_MULTI_NODE_SELECTION_WIDGET_H diff --git a/Modules/QtWidgets/include/QmitkNodeSelectionDialog.h b/Modules/QtWidgets/include/QmitkNodeSelectionDialog.h index 21155b9e49..a91eb7a97e 100644 --- a/Modules/QtWidgets/include/QmitkNodeSelectionDialog.h +++ b/Modules/QtWidgets/include/QmitkNodeSelectionDialog.h @@ -1,146 +1,146 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QMITK_NODE_SELECTION_DIALOG_H #define QMITK_NODE_SELECTION_DIALOG_H #include -#include "ui_QmitkNodeSelectionDialog.h" +#include #include #include #include #include "mitkIDataStorageInspectorProvider.h" #include #include #include /** * @class QmitkNodeSelectionDialog * @brief A customized QDialog that displays different data storage inspectors and allows to * set and get a current selection by selecting data nodes in the data storage inspectors. */ class MITKQTWIDGETS_EXPORT QmitkNodeSelectionDialog : public QDialog { Q_OBJECT public: explicit QmitkNodeSelectionDialog(QWidget* parent = nullptr, QString caption = "", QString hint = ""); /** * @brief Set the data storage that will be used. * The function iterates over the dialog's panels and sets the data storage of each panel accordingly. * Each panel is a specific data storage inspector. * * @param dataStorage A pointer to the data storage to set. */ void SetDataStorage(mitk::DataStorage* dataStorage); /** * @brief Set the node predicate that will be used. * The function iterates over the dialog's panels and sets the node predicate of each panel accordingly. * Each panel is a specific data storage inspector. * * @param nodePredicate A pointer to node predicate. */ virtual void SetNodePredicate(const mitk::NodePredicateBase* nodePredicate); const mitk::NodePredicateBase* GetNodePredicate() const; using NodeList = QList; NodeList GetSelectedNodes() const; /** * @brief Helper function that is used to check the given selection for consistency. * Returning an empty string assumes that everything is alright and the selection is valid. * If the string is not empty, the content of the string will be used as error message. */ using SelectionCheckFunctionType = std::function; /** * @brief A selection check function can be set. If set the dialog uses this function to check the made/set selection. * If the selection is valid, everything is fine. * If the selection is indicated as invalid, the dialog will display the selection check function error message. */ void SetSelectionCheckFunction(const SelectionCheckFunctionType &checkFunction); bool GetSelectOnlyVisibleNodes() const; using SelectionMode = QAbstractItemView::SelectionMode; /** * @brief Set the Qt selection mode (e.g. Single selection, multi selection). * The function iterates over the dialog's panels and sets the Qt selection mode of each panel accordingly. * Each panel is a concrete data storage inspector. * * @param mode The QAbstractItemView::SelectionMode to define the selection mode. */ void SetSelectionMode(SelectionMode mode); SelectionMode GetSelectionMode() const; Q_SIGNALS: /** * @brief A signal that will be emitted if the selected node has changed. * * @param nodes A list of data nodes that are newly selected. */ void CurrentSelectionChanged(NodeList nodes); public Q_SLOTS: /** * @brief Set the selection modus to (not) include invisible nodes in the selection. * The function iterates over the dialog's panels and sets the selection modus of each panel accordingly. * Each panel is a concrete data storage inspector. * * @param selectOnlyVisibleNodes The bool value to define the selection modus. */ void SetSelectOnlyVisibleNodes(bool selectOnlyVisibleNodes); /** * @brief Set the currently selected nodes given a list of data nodes. * The function iterates over the dialog's panels and sets the current selection of each panel accordingly. * Each panel is a concrete data storage inspector. * * @param selectedNodes A list of data nodes that should be newly selected. */ void SetCurrentSelection(NodeList selectedNodes); protected Q_SLOTS: void OnSelectionChanged(NodeList selectedNodes); void OnFavoriteNodesButtonClicked(); void OnOK(); void OnCancel(); void OnDoubleClicked(const QModelIndex& index); protected: void SetErrorText(const std::string& checkResponse); void AddPanel(const mitk::IDataStorageInspectorProvider* provider, const mitk::IDataStorageInspectorProvider::InspectorIDType &preferredID, bool &preferredFound, int &preferredIndex); mitk::WeakPointer m_DataStorage; mitk::NodePredicateBase::ConstPointer m_NodePredicate; bool m_SelectOnlyVisibleNodes; NodeList m_SelectedNodes; SelectionCheckFunctionType m_CheckFunction; SelectionMode m_SelectionMode; using PanelVectorType = std::vector; PanelVectorType m_Panels; QPushButton* m_FavoriteNodesButton; Ui_QmitkNodeSelectionDialog m_Controls; }; #endif // QMITK_NODE_SELECTION_DIALOG_H diff --git a/Modules/QtWidgets/include/QmitkNodeSelectionListItemWidget.h b/Modules/QtWidgets/include/QmitkNodeSelectionListItemWidget.h index cab0a0c91e..b1448a3024 100644 --- a/Modules/QtWidgets/include/QmitkNodeSelectionListItemWidget.h +++ b/Modules/QtWidgets/include/QmitkNodeSelectionListItemWidget.h @@ -1,52 +1,52 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QMITK_NODE_SELECTION_LIST_ITEM_WIDGET_H #define QMITK_NODE_SELECTION_LIST_ITEM_WIDGET_H #include -#include "ui_QmitkNodeSelectionListItemWidget.h" +#include #include #include class MITKQTWIDGETS_EXPORT QmitkNodeSelectionListItemWidget : public QWidget { Q_OBJECT public: explicit QmitkNodeSelectionListItemWidget(QWidget* parent = nullptr); ~QmitkNodeSelectionListItemWidget() override; const mitk::DataNode* GetSelectedNode() const; public Q_SLOTS : virtual void SetSelectedNode(const mitk::DataNode* node); virtual void SetClearAllowed(bool allowed); signals: void ClearSelection(const mitk::DataNode* node); protected Q_SLOTS: void OnClearSelection(); protected: bool eventFilter(QObject *obj, QEvent *ev) override; Ui_QmitkNodeSelectionListItemWidget m_Controls; }; #endif // QMITK_NODE_SELECTION_LIST_ITEM_WIDGET_H diff --git a/Modules/QtWidgets/include/QmitkSingleNodeSelectionWidget.h b/Modules/QtWidgets/include/QmitkSingleNodeSelectionWidget.h index af818d8e8b..10f776d00c 100644 --- a/Modules/QtWidgets/include/QmitkSingleNodeSelectionWidget.h +++ b/Modules/QtWidgets/include/QmitkSingleNodeSelectionWidget.h @@ -1,97 +1,97 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QMITK_SINGLE_NODE_SELECTION_WIDGET_H #define QMITK_SINGLE_NODE_SELECTION_WIDGET_H #include -#include "ui_QmitkSingleNodeSelectionWidget.h" +#include #include #include #include #include #include class QmitkAbstractDataStorageModel; /** * @class QmitkSingleNodeSelectionWidget * @brief Widget that represents a node selection of (max) one node. It acts like a button. Clicking on it * allows to change the selection. * * @remark This class provides a public function 'SetAutoSelectNewNodes' that can be used to enable * the auto selection mode (default is false). * The user of this class calling this function has to make sure that the base-class Q_SIGNAL * 'CurrentSelectionChanged', which will be emitted by this function, is already * connected to a receiving slot, if the initial valid auto selection should not get lost. */ class MITKQTWIDGETS_EXPORT QmitkSingleNodeSelectionWidget : public QmitkAbstractNodeSelectionWidget { Q_OBJECT public: explicit QmitkSingleNodeSelectionWidget(QWidget* parent = nullptr); mitk::DataNode::Pointer GetSelectedNode() const; bool GetAutoSelectNewNodes() const; using NodeList = QmitkAbstractNodeSelectionWidget::NodeList; public Q_SLOTS: void SetCurrentSelectedNode(mitk::DataNode* selectedNode); /** * Sets the auto selection mode (default is false). * If auto select is true and the following conditions are fullfilled, the widget will * select a node automatically from the data storage: * - a data storage is set * - data storage contains at least one node that matches the given predicate * - no selection is set * * @remark Enabling the auto selection mode by calling 'SetAutoSelectNewNodes(true)' * will directly emit a 'QmitkSingleNodeSelectionWidget::CurrentSelectionChanged' Q_SIGNAL * if a valid auto selection was made. * If this initial emission should not get lost, auto selection mode needs to be enabled after this * selection widget has been connected via the 'QmitkSingleNodeSelectionWidget::CurrentSelectionChanged' * Q_SIGNAL to a receiving function. */ void SetAutoSelectNewNodes(bool autoSelect); protected Q_SLOTS: virtual void OnClearSelection(); protected: void ReviseSelectionChanged(const NodeList& oldInternalSelection, NodeList& newInternalSelection) override; bool eventFilter(QObject *obj, QEvent *ev) override; void EditSelection(); void UpdateInfo() override; void OnDataStorageChanged() override; void OnNodeAddedToStorage(const mitk::DataNode* node) override; void AutoSelectNodes(); /** Helper function that gets a suitable auto selected node from the datastorage that fits to the predicate settings. @param ignoreNodes You may pass a list of nodes that must not be choosen as auto selected node. */ mitk::DataNode::Pointer DetermineAutoSelectNode(const NodeList& ignoreNodes = {}); /** See documentation of SetAutoSelectNewNodes for details*/ bool m_AutoSelectNodes; Ui_QmitkSingleNodeSelectionWidget m_Controls; }; #endif // QMITK_SINGLE_NODE_SELECTION_WIDGET_H