2013-04-27 15:27:27 +00:00
|
|
|
#ifndef MODELDELEGATES_H
|
|
|
|
#define MODELDELEGATES_H
|
|
|
|
|
2013-05-02 22:27:36 +00:00
|
|
|
#include <QStyledItemDelegate>
|
2013-07-16 18:31:44 +00:00
|
|
|
class QComboBox;
|
2013-04-27 15:27:27 +00:00
|
|
|
|
2013-05-02 22:27:36 +00:00
|
|
|
class StarWidgetsDelegate : public QStyledItemDelegate {
|
2013-04-27 15:27:27 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-05-23 04:25:05 +00:00
|
|
|
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;
|
2013-05-02 22:27:36 +00:00
|
|
|
private:
|
|
|
|
QWidget *parentWidget;
|
2013-04-27 15:27:27 +00:00
|
|
|
};
|
2013-05-22 17:11:49 +00:00
|
|
|
|
2013-06-16 13:15:19 +00:00
|
|
|
class ComboBoxDelegate : public QStyledItemDelegate{
|
2013-05-22 17:11:49 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-06-16 13:15:19 +00:00
|
|
|
explicit ComboBoxDelegate(QAbstractItemModel *model, QObject* parent = 0);
|
2013-05-23 04:25:05 +00:00
|
|
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
2013-05-23 18:33:20 +00:00
|
|
|
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
|
2013-06-16 15:33:27 +00:00
|
|
|
virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
2013-07-16 18:31:44 +00:00
|
|
|
virtual bool eventFilter(QObject* object, QEvent* event);
|
2013-07-16 22:13:58 +00:00
|
|
|
public slots:
|
|
|
|
void testActivation(const QString& s);
|
2013-07-18 14:53:47 +00:00
|
|
|
virtual void revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint) = 0;
|
2013-06-16 13:15:19 +00:00
|
|
|
protected:
|
|
|
|
QAbstractItemModel *model;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TankInfoDelegate : public ComboBoxDelegate{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit TankInfoDelegate(QObject* parent = 0);
|
2013-05-23 18:33:20 +00:00
|
|
|
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
|
2013-07-18 13:24:02 +00:00
|
|
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
|
|
public slots:
|
|
|
|
void revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint);
|
2013-05-22 17:11:49 +00:00
|
|
|
};
|
|
|
|
|
2013-06-16 13:15:19 +00:00
|
|
|
class WSInfoDelegate : public ComboBoxDelegate{
|
2013-05-24 01:40:16 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit WSInfoDelegate(QObject* parent = 0);
|
|
|
|
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
|
2013-07-18 13:24:02 +00:00
|
|
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
2013-07-18 14:53:47 +00:00
|
|
|
public slots:
|
|
|
|
void revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint);
|
2013-05-24 01:40:16 +00:00
|
|
|
};
|
|
|
|
|
2013-08-30 10:14:30 +00:00
|
|
|
class AirTypesDelegate : public ComboBoxDelegate{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit AirTypesDelegate(QObject* parent = 0);
|
|
|
|
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
|
|
|
|
public slots:
|
|
|
|
void revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint);
|
|
|
|
};
|
|
|
|
|
2013-04-27 15:27:27 +00:00
|
|
|
#endif
|