mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
babbfa9204
I had to immprove the TankInfoModel with two new methods, insertRows and setData, because the delegate used this model to show what kind of Tanks we are offering. Since the user can enter a new type of Tank, it's important to add this tank to all lists using the delegates. I Also added two new methods on the delegate itself, to correctly shows the data, and set the data on the model. This also will help dirk with a working example on how to edit things while using a delegate. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
25 lines
878 B
C++
25 lines
878 B
C++
#ifndef MODELDELEGATES_H
|
|
#define MODELDELEGATES_H
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
class StarWidgetsDelegate : public QStyledItemDelegate {
|
|
Q_OBJECT
|
|
public:
|
|
explicit StarWidgetsDelegate(QWidget* parent = 0);
|
|
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
private:
|
|
QWidget *parentWidget;
|
|
};
|
|
|
|
class TankInfoDelegate : public QStyledItemDelegate{
|
|
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;
|
|
};
|
|
|
|
#endif
|