00001 #ifndef FOLDERTREEMODEL_H
00002 #define FOLDERTREEMODEL_H
00003
00004 #include <QtCore/QAbstractItemModel>
00005 #include <QtCore/QModelIndex>
00006 #include <QtCore/QVariant>
00007 #include <QtCore/QSet>
00008
00009 #include "ACE/accesstocool.h"
00010
00011 #include <vector>
00012 #include <string>
00013
00014 class FolderTreeItem;
00015
00016
00017 class FolderTreeModel : public QAbstractItemModel
00018 {
00019 Q_OBJECT
00020
00021 public:
00022
00023 FolderTreeModel( cool::IDatabasePtr dbPtr, const QString connectionString, QObject* parent = 0 );
00024 ~FolderTreeModel();
00025
00026 QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
00027 QVariant headerData( int section = 0, Qt::Orientation orientation = Qt::Horizontal, int role = Qt::DisplayRole ) const;
00028 QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const;
00029 QModelIndex index( const QString& fullFolderName) const;
00030 QModelIndex parent( const QModelIndex& index ) const;
00031 int rowCount( const QModelIndex& parent = QModelIndex() ) const;
00032 int columnCount( const QModelIndex& parent = QModelIndex() ) const;
00033 Qt::ItemFlags flags( const QModelIndex& index ) const;
00034 bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole );
00035 void emitDataChanged( const QModelIndex& index, const bool changed );
00036 bool setHeaderData( int section, Qt::Orientation orientation, const QVariant& value, int role = Qt::EditRole );
00037 bool removeRows( int row, int count = 1, const QModelIndex& parent = QModelIndex() );
00038 bool insertRows( int row, int count = 1, const QModelIndex& parent = QModelIndex() );
00039 QString folderName( const QModelIndex& index ) const;
00040 cool::IDatabasePtr getCoolDBPtr() const;
00041 bool isModified() const;
00042 QSet< QModelIndex > getModifiedFolders() const;
00043
00044 QString coolConnectionString;
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 private:
00067 FolderTreeItem* rootTreeItem;
00068 cool::IDatabasePtr coolDBPtr;
00069 Qt::GlobalColor modifiedColour;
00070 QSet< QModelIndex > modifiedFolders;
00071
00072 void setupFolderTreeModelData( std::vector< std::string >& nodeList );
00073 void setModifiedFolders( const QModelIndex& index, const bool modified );
00074
00075 };
00076
00077 #endif