Kross
model.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KROSS_MODEL_H
00021 #define KROSS_MODEL_H
00022
00023 #include <kross/core/krossconfig.h>
00024
00025 #include <QtCore/QModelIndex>
00026 #include <QtGui/QSortFilterProxyModel>
00027
00028 namespace Kross {
00029
00030
00031 class Action;
00032 class ActionCollection;
00033
00039 class KROSSUI_EXPORT ActionCollectionModel : public QAbstractItemModel
00040 {
00041 Q_OBJECT
00042 public:
00043 enum Mode {
00044 None = 0,
00045 Icons = 1,
00046 ToolTips = 2,
00047 UserCheckable = 4
00048
00049 };
00050
00051 explicit ActionCollectionModel(QObject* parent, ActionCollection* collection = 0, Mode mode = Mode(Icons|ToolTips));
00052 virtual ~ActionCollectionModel();
00053
00054 virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
00055 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
00056 virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
00057 virtual QModelIndex parent(const QModelIndex& index) const;
00058 virtual Qt::ItemFlags flags(const QModelIndex &index) const;
00059 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
00060 virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
00061
00062 virtual bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());
00063 virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
00064 virtual bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex());
00065 virtual bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex());
00066
00067
00068 virtual QStringList mimeTypes() const;
00069 virtual QMimeData* mimeData(const QModelIndexList& indexes) const;
00070 virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
00071
00072 virtual Qt::DropActions supportedDropActions() const;
00073
00078 static Action* action(const QModelIndex& index);
00079
00084 static ActionCollection* collection(const QModelIndex& index);
00085
00086 private Q_SLOTS:
00087 void slotUpdated();
00088
00089 private:
00091 class Private;
00093 Private* const d;
00094 };
00095
00100 class KROSSUI_EXPORT ActionCollectionProxyModel : public QSortFilterProxyModel
00101 {
00102 public:
00103 explicit ActionCollectionProxyModel(QObject* parent, ActionCollectionModel* model = 0);
00104 virtual ~ActionCollectionProxyModel();
00105
00106 private:
00108 virtual void setSourceModel(QAbstractItemModel* sourceModel);
00110 virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
00111 };
00112
00113 }
00114
00115 #endif
00116