mkRPG
src/editor/GUI/Tabs/itemdelegates.h
Go to the documentation of this file.
00001 #ifndef ITEMDELEGATES_H
00002 #define ITEMDELEGATES_H
00003 
00004 #include <QtWidgets>
00005 //#include <QStyledItemDelegate>
00006 //#include <QItemEditorFactory>
00007 //#include <QSpinBox>
00008 //#include <QLineEdit>
00009 #include "Game/game.h"
00010 
00011 
00024 class ItemEditor : public QWidget
00025 {
00026     Q_OBJECT
00027 public:
00028     explicit ItemEditor(QWidget *edit, bool redef, QWidget* parent);
00029     void setEditorProperty(const char *name, const QVariant &value);
00030     QVariant editorProperty(const char *name) const;
00031     bool resetRequested() const;
00032     QWidget* editor() const;
00033 
00034 signals:
00035     void dataChanged(QWidget*);
00036     void dataReset(QWidget*);
00037 
00038 public slots:
00039     void dataReseted();
00040     void changeData();
00041     void setResetable(bool r);
00042 
00043 private slots:
00044     void resetData();
00045 
00046 private:
00047     QWidget *edit;
00048     bool resetRequest;
00049     QToolButton *tb;
00050 };
00051 
00052 
00059 class ParamItemDelegate : public QStyledItemDelegate
00060 {
00061     Q_OBJECT
00062 public:
00063     explicit ParamItemDelegate(QObject *parent = nullptr);
00064 
00065     QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00066     void setEditorData(QWidget *editor, const QModelIndex &index) const;
00067     void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00068     void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
00069     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00070     //void sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
00071 
00072 private:
00073     bool reseting;
00074 };
00075 
00076 
00077 
00084 class FlagItemDelegate : public QStyledItemDelegate
00085 {
00086     Q_OBJECT
00087 public:
00088     explicit FlagItemDelegate(QObject *parent = nullptr);
00089 
00090     QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00091     void setEditorData(QWidget *editor, const QModelIndex &index) const;
00092     void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00093     void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
00094     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00095     //void sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
00096 };
00097 
00098 
00099 
00104 class ObjectNameItemDelegate : public QStyledItemDelegate
00105 {
00106     Q_OBJECT
00107 public:
00108     explicit ObjectNameItemDelegate(QObject *parent = nullptr);
00109     QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00110     void setEditorData(QWidget *editor, const QModelIndex &index) const;
00111     void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00112     //void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;*/
00113     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00114 
00115 };
00116 
00117 
00122 class ActionReceiverEditor : public QWidget
00123 {
00124     Q_OBJECT
00125 
00126 public:
00127     explicit ActionReceiverEditor(const QModelIndex &index, QWidget *parent = nullptr);
00128 
00129 signals:
00130     void removeReceiver(QWidget *, const QPersistentModelIndex &);
00131     void editReceiver(QWidget *, const QPersistentModelIndex &);
00132 private slots:
00133     void removeReceiverRequest();
00134     void editReceiverRequest();
00135 
00136 private:
00137     QToolButton *edit;
00138     QToolButton *remove;
00139     QPersistentModelIndex index;
00140 };
00141 
00142 
00146 class ActionReceiverItemDelegate : public QStyledItemDelegate
00147 {
00148     Q_OBJECT
00149 
00150 public:
00151     explicit ActionReceiverItemDelegate(QObject *parent = nullptr);
00152     QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00153     void setEditorData(QWidget *editor, const QModelIndex &index) const;
00154     void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00155     void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
00156     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00157 
00158 signals:
00159     void removeRow(const QPersistentModelIndex &);
00160     void editRow(const QPersistentModelIndex &);
00161 
00162 private slots:
00163     void removeReceiver(QWidget *editor, const QPersistentModelIndex &index);
00164     void editReceiver(QWidget *editor, const QPersistentModelIndex &index);
00165 
00166 };
00167 
00168 
00169 
00170 #endif // ITEMDELEGATES_H
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Defines