summaryrefslogtreecommitdiffstats
path: root/qt-ui/modeldelegates.h
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-16 10:15:19 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-16 10:15:19 -0300
commit10ea572f5af471e959e34441e9a23fac58f4b928 (patch)
tree2226206a0963fa6a74c3f53b98856d5dd4d8943d /qt-ui/modeldelegates.h
parent84d4a2dae069a2e728cea8d7a4506921b558603f (diff)
downloadsubsurface-10ea572f5af471e959e34441e9a23fac58f4b928.tar.gz
Create a 'ComboBoxDelegate' to concentrate the comboboxness of delegates.
This patch creates a ComboBoxDelegate where the other specific delegates should inherit from. this adds a little code cleanup for the current version, and will help as soon as more delegates got added to the code. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/modeldelegates.h')
-rw-r--r--qt-ui/modeldelegates.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/qt-ui/modeldelegates.h b/qt-ui/modeldelegates.h
index 79fbe297b..00436d874 100644
--- a/qt-ui/modeldelegates.h
+++ b/qt-ui/modeldelegates.h
@@ -13,21 +13,27 @@ private:
QWidget *parentWidget;
};
-class TankInfoDelegate : public QStyledItemDelegate{
+class ComboBoxDelegate : public QStyledItemDelegate{
Q_OBJECT
public:
- explicit TankInfoDelegate(QObject* parent = 0);
+ explicit ComboBoxDelegate(QAbstractItemModel *model, QObject* parent = 0);
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
+protected:
+ QAbstractItemModel *model;
+};
+
+class TankInfoDelegate : public ComboBoxDelegate{
+ Q_OBJECT
+public:
+ explicit TankInfoDelegate(QObject* parent = 0);
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
};
-class WSInfoDelegate : public QStyledItemDelegate{
+class WSInfoDelegate : public ComboBoxDelegate{
Q_OBJECT
public:
explicit WSInfoDelegate(QObject* parent = 0);
- virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
- virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
};