• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

treemodel.h

Go to the documentation of this file.
00001 #ifndef TREEMODEL_H
00002 #define TREEMODEL_H
00003 
00004 #include <QAbstractItemModel>
00005 
00006 #include "database.h"
00007 
00008 class TreeItem;
00009 class TreePath;
00010 class QSqlTableModel;
00011 
00028 class ProjectTreeModel : public QAbstractItemModel, public SqlHelper {
00029     Q_OBJECT
00030 public:
00031     enum TreeModelRoles {
00032         TreeItemPointer = Qt::UserRole + 1100,
00033         TreeId,
00034         TreeItemPath
00035     };
00036 
00037     ProjectTreeModel(QObject *parent = 0);
00038     ~ProjectTreeModel();
00039 
00040     QVariant data(const QModelIndex &index, int role) const;
00041     QVariant headerData(int section, Qt::Orientation orientation,
00042                         int role = Qt::DisplayRole) const;
00043     TreeItem *treeItemPointer(const QModelIndex &index) const;
00044     TreeItem *treeItemPointer(const int tree_id) const;
00045 
00046     QModelIndex index(int row, int column,
00047                       const QModelIndex &parent = QModelIndex()) const;
00048     QModelIndex index(const TreePath &path);
00049 
00050     QModelIndex parent(const QModelIndex &index) const;
00051     int rowCount(const QModelIndex &parent = QModelIndex()) const;
00052     int columnCount(const QModelIndex &parent = QModelIndex()) const;
00053 
00054     Qt::ItemFlags flags(const QModelIndex &index) const;
00055     bool setData(const QModelIndex &index, const QVariant &value,
00056                  int role = Qt::EditRole);
00057 
00058     QMimeData *mimeData(const QModelIndexList &indexes) const;
00059     QStringList mimeTypes() const;
00060     Qt::DropActions supportedDropActions() const;
00061 
00062     bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
00063     bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
00064 
00065     void reLoad();
00066 
00067     virtual QModelIndex match(const QModelIndex &start, const TreePath &path) const ;
00068 
00069 private slots:
00070     virtual void onTableChange(const QString &tableName);
00071 
00072 private:
00073     void setupModelData(TreeItem *parent);
00074 
00075     QString formName(int row, int column, QSqlTableModel &table, const QString &suffix = QString());
00076     bool columnIsPrimary(int column, QSqlTableModel &table);
00077     bool columnIsReserved(int column, QSqlTableModel &table);
00078 
00079 private:
00080     TreeItem *rootItem;
00081 };
00082 
00083 #endif // TREEMODEL_H

Generated on Tue Aug 24 2010 15:58:55 for Smartlet by  doxygen 1.7.1