Medical Imaging Interaction Toolkit  2025.12.02
Medical Imaging Interaction Toolkit
QmitkDataStorageComboBoxWithSelectNone.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef QmitkDataStorageComboBoxWithSelectNone_h
14 #define QmitkDataStorageComboBoxWithSelectNone_h
15 
16 #include <MitkQtWidgetsExports.h>
17 
19 #include "QmitkCustomVariants.h"
20 #include "mitkDataNode.h"
21 
22 
33 {
34 
35  Q_OBJECT
36  Q_PROPERTY(mitkDataNodePtr SelectedNode READ GetSelectedNode WRITE SetSelectedNode)
37  Q_PROPERTY(QString currentValue READ currentValue WRITE setCurrentValue)
38 
39  public:
44  QmitkDataStorageComboBoxWithSelectNone(QWidget* parent = nullptr, bool autoSelectNewNodes=false);
45 
51  const mitk::NodePredicateBase* predicate,
52  QWidget* parent = nullptr,
53  bool autoSelectNewNodes = false);
54 
60 
64  static const QString ZERO_ENTRY_STRING;
65 
71  int Find(const mitk::DataNode* dataNode) const override;
72 
78  mitk::DataNode::Pointer GetNode(int index) const override;
79 
83  mitk::DataNode::Pointer GetSelectedNode() const override;
84 
88  virtual void SetSelectedNode(const mitk::DataNode::Pointer& node);
89 
95  void RemoveNode(int index) override;
96 
102  void SetNode(int index, const mitk::DataNode* dataNode) override;
103 
107  virtual QString currentValue() const;
108 
112  virtual void setCurrentValue(const QString& path);
113 
117  void SetZeroEntryText(const QString& zeroEntryString);
118 
119  protected:
120 
124  bool HasIndex(unsigned int index) const;
125 
129  void InsertNode(int index, const mitk::DataNode* dataNode) override;
130 
134  void Reset() override;
135 
136  private:
137 
144  QString m_CurrentPath;
145 };
146 
147 #endif
#define MITKQTWIDGETS_EXPORT
mitk::DataNode::Pointer mitkDataNodePtr
Displays all or a subset (defined by a predicate) of nodes of the Data Storage, and additionally,...
void Reset() override
Reset function whenever datastorage or predicate changes.
QmitkDataStorageComboBoxWithSelectNone(QWidget *parent=nullptr, bool autoSelectNewNodes=false)
Calls base class constructor.
int Find(const mitk::DataNode *dataNode) const override
Searches for a given node, returning the index if found.
mitk::DataNode::Pointer GetNode(int index) const override
Retrieves the node at a given index, where if index is zero, will always return nullptr.
virtual QString currentValue() const
Get the current file path.
~QmitkDataStorageComboBoxWithSelectNone() override
Nothing to do.
mitk::DataNode::Pointer GetSelectedNode() const override
Returns the selected DataNode or nullptr if there is none, or the current index is zero.
void SetNode(int index, const mitk::DataNode *dataNode) override
Set a DataNode in the ComboBox at the specified index (if the index exists). Internally the method ju...
static const QString ZERO_ENTRY_STRING
Stores the string that will be present on index 0, currently equal to "please select".
void SetZeroEntryText(const QString &zeroEntryString)
Set the string that will be present on index 0.
virtual void SetSelectedNode(const mitk::DataNode::Pointer &node)
Sets the combo box to the index that contains the specified node, or 0 if the node cannot be found.
virtual void setCurrentValue(const QString &path)
Set the current file path.
bool HasIndex(unsigned int index) const
Checks if the given index is within range.
void InsertNode(int index, const mitk::DataNode *dataNode) override
Inserts a new node at the given index, unless index is 0, which is silently ignored.
QmitkDataStorageComboBoxWithSelectNone(mitk::DataStorage *dataStorage, const mitk::NodePredicateBase *predicate, QWidget *parent=nullptr, bool autoSelectNewNodes=false)
Calls base class constructor.
void RemoveNode(int index) override
Removes a node from the ComboBox at a specified index (if the index exists). Gets called when a DataS...
Displays all or a subset (defined by a predicate) of nodes of the Data Storage.
virtual void SetNode(int index, const mitk::DataNode *dataNode)
virtual void RemoveNode(int index)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
Data management class that handles 'was created by' relations.
Interface for evaluation conditions used in the DataStorage class GetSubset() method.