mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
84d4a2dae0
commit
10ea572f5a
2 changed files with 27 additions and 42 deletions
|
|
@ -13,21 +13,27 @@ private:
|
|||
QWidget *parentWidget;
|
||||
};
|
||||
|
||||
class TankInfoDelegate : public QStyledItemDelegate{
|
||||
class ComboBoxDelegate : public QStyledItemDelegate{
|
||||
Q_OBJECT
|
||||
public:
|
||||
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 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;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue