defuze.me  Client
editabletreemodel.hpp
00001 /**************************************************************************
00002 ** defuze.me Epitech Innovative Project
00003 **
00004 ** Copyright 2010-2012
00005 **   Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard
00006 **   Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier
00007 **
00008 ** All rights reserved.
00009 **************************************************************************/
00010 
00011 #ifndef EDITABLETREEMODEL_HPP
00012 #define EDITABLETREEMODEL_HPP
00013 
00014 #include <QAbstractItemModel>
00015 #include <QModelIndex>
00016 #include <QVariant>
00017 
00018 class EditableTreeItem;
00019 
00020 class EditableTreeModel : public QAbstractItemModel
00021 {
00022     Q_OBJECT
00023 
00024 public:
00025     EditableTreeModel(QObject *parent = 0);
00026     ~EditableTreeModel();
00027 
00028     QVariant data(const QModelIndex &index, int role) const;
00029     QVariant headerData(int section, Qt::Orientation orientation,
00030                         int role = Qt::DisplayRole) const;
00031 
00032     QModelIndex index(int row, int column,
00033                       const QModelIndex &parent = QModelIndex()) const;
00034     QModelIndex parent(const QModelIndex &index) const;
00035 
00036     int rowCount(const QModelIndex &parent = QModelIndex()) const;
00037     int columnCount(const QModelIndex &parent = QModelIndex()) const;
00038 
00039     Qt::ItemFlags flags(const QModelIndex &index) const;
00040     bool setData(const QModelIndex &index, const QVariant &value,
00041                  int role = Qt::EditRole);
00042     bool setHeaderData(int section, Qt::Orientation orientation,
00043                        const QVariant &value, int role = Qt::EditRole);
00044 
00045     bool insertColumns(int position, int columns,
00046                        const QModelIndex &parent = QModelIndex());
00047     bool removeColumns(int position, int columns,
00048                        const QModelIndex &parent = QModelIndex());
00049     bool insertRows(int position, int rows,
00050                     const QModelIndex &parent = QModelIndex());
00051     bool removeRows(int position, int rows,
00052                     const QModelIndex &parent = QModelIndex());
00053 
00054 protected:
00055     void setupModelData(const QStringList &lines, EditableTreeItem *parent);
00056     EditableTreeItem *getItem(const QModelIndex &index) const;
00057 
00058     EditableTreeItem *rootItem;
00059 };
00060 
00061 #endif // EDITABLETREEMODEL_HPP