// $Id$ // BoilerTreeView.hpp // // CLASSES: // class BoilerTreeView : public QTreeView // class BoilerTreeView::ItemModel : public QAbstractItemModel // class BoilerTreeView::ItemDelegate : public QStyledItemDelegate // // SEE COMMENTS in BoilerTreeView.cpp. // //-- #ifndef BoilerTreeViewINCLUDED #define BoilerTreeViewINCLUDED #include #include #include // ****************************************** // *** class BoilerTreeView : QTreeView *** // ****************************************** class BoilerTreeView : public QTreeView { Q_OBJECT private: class ItemModel; // declared below, a QAbstractItemModel class ItemDelegate; // declared below, a QStyledItemDelegate private: ItemModel* _itemModel; ItemDelegate* _itemDelegate; public: BoilerTreeView (QWidget* parentWid); virtual ~BoilerTreeView(); }; // ************************************************************** // *** class BoilerTreeView::ItemModel : QAbstractItemModel *** // ************************************************************** class BoilerTreeView::ItemModel : public QAbstractItemModel { Q_OBJECT private: BoilerTreeView* _parentTreeView; public: ItemModel (BoilerTreeView* parentTreeView); virtual ~ItemModel(); // ************************************************* // *** Virtual methods from QAbstractItemModel *** // ************************************************* public: Qt::ItemFlags flags (const QModelIndex&) const; QModelIndex index (int row, int col, const QModelIndex& parent=QModelIndex()) const; QModelIndex parent (const QModelIndex&) const { return QModelIndex(); } int rowCount (const QModelIndex& parent=QModelIndex()) const; int columnCount (const QModelIndex& parent=QModelIndex()) const; QVariant data (const QModelIndex&, int role=Qt::DisplayRole) const; QVariant headerData (int section, Qt::Orientation, int role=Qt::DisplayRole) const; bool setData (const QModelIndex&, const QVariant&, int role=Qt::EditRole); // ------------------------------------------------- }; // ****************************************************************** // *** class BoilerTreeView::ItemDelegate : QStyledItemDelegate *** // ****************************************************************** class BoilerTreeView::ItemDelegate : public QStyledItemDelegate { Q_OBJECT private: BoilerTreeView* _parentTreeView; public: ItemDelegate (BoilerTreeView* parentTreeView); virtual ~ItemDelegate(); // **************************************************** // *** Virtual methods from QAbstractItemDelegate *** // **************************************************** // Note: when defering to the base class implementation, make sure // to call the direct base class method, i.e. of QStyledItemDelegate. QWidget* createEditor (QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const; void setEditorData (QWidget* editor, const QModelIndex&) const; void setModelData (QWidget* editor, QAbstractItemModel* itemModel, const QModelIndex&) const; }; #endif // BoilerTreeViewINCLUDED //--- (end BoilerTreeView.hpp) ---