Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkPropertyItemDelegate.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef QmitkPropertyItemDelegate_h
18 #define QmitkPropertyItemDelegate_h
19 
20 #include <MitkQtWidgetsExports.h>
21 #include <QListView>
22 #include <QStyledItemDelegate>
23 #include <mitkPropertyList.h>
24 #include <mitkWeakPointer.h>
25 
26 class QComboBox;
27 class QLineEdit;
28 class QToolButton;
29 class QResizeEvent;
30 
31 class QmitkColorWidget : public QWidget
32 {
33  Q_OBJECT
34 
35 public:
36  explicit QmitkColorWidget(QWidget *parent = nullptr);
38 
39  QColor GetColor() const;
40  void SetColor(QColor color);
41 
42 signals:
43  void ColorPicked();
44 
45 private slots:
46  void OnButtonClicked();
47  void OnLineEditEditingFinished();
48 
49 private:
50  QColor m_Color;
51  QLineEdit *m_LineEdit;
52  QToolButton *m_Button;
53 };
54 
55 class QmitkComboBoxListView : public QListView
56 {
57  Q_OBJECT
58 
59 public:
60  explicit QmitkComboBoxListView(QComboBox *comboBox = NULL);
62 
63 protected:
64  void paintEvent(QPaintEvent *event) override;
65  void resizeEvent(QResizeEvent *event) override;
66  QStyleOptionViewItem viewOptions() const override;
67 
68 private:
69  QComboBox *m_ComboBox;
70 };
71 
72 class MITKQTWIDGETS_EXPORT QmitkPropertyItemDelegate : public QStyledItemDelegate
73 {
74  Q_OBJECT
75 
76 public:
77  explicit QmitkPropertyItemDelegate(QObject *parent = NULL);
79 
80  QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
81  void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
82  void setEditorData(QWidget *editor, const QModelIndex &index) const override;
83  void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
84  void SetPropertyList(mitk::PropertyList *propertyList);
85 
86 private slots:
87  void OnComboBoxCurrentIndexChanged(int index);
88  void OnSpinBoxEditingFinished();
89  void OnColorPicked();
90 
91 private:
92  std::string GetPropertyName(const QModelIndex &index) const;
93 
95 };
96 
97 #endif
void resizeEvent(QResizeEvent *event) override
QmitkComboBoxListView(QComboBox *comboBox=NULL)
#define MITKQTWIDGETS_EXPORT
Key-value list holding instances of BaseProperty.
QStyleOptionViewItem viewOptions() const override
void SetColor(QColor color)
QmitkColorWidget(QWidget *parent=nullptr)
void paintEvent(QPaintEvent *event) override