00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef QGSBROWSERMODEL_H
00016 #define QGSBROWSERMODEL_H
00017
00018 #include <QAbstractItemModel>
00019 #include <QIcon>
00020 #include <QMimeData>
00021
00022 #include "qgsdataitem.h"
00023
00024 class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
00025 {
00026 Q_OBJECT
00027
00028 public:
00029 explicit QgsBrowserModel( QObject *parent = 0 );
00030 ~QgsBrowserModel();
00031
00032
00033
00036 virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
00037
00042 virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
00043
00046 virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00047
00049 virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
00050
00053 virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
00054
00056 virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
00057
00058 QModelIndex findItem( QgsDataItem *item, QgsDataItem *parent = 0 ) const;
00059
00063 virtual QModelIndex parent( const QModelIndex &index ) const;
00064
00066 virtual QStringList mimeTypes() const;
00067
00069 virtual QMimeData * mimeData( const QModelIndexList &indexes ) const;
00070
00072 virtual bool dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent );
00073
00074 QgsDataItem *dataItem( const QModelIndex &idx ) const;
00075
00076 bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;
00077
00078
00079 void reload();
00080
00081
00082 void refresh( QString path );
00083
00084
00085 void refresh( const QModelIndex &index = QModelIndex() );
00086
00088 QModelIndex findPath( QString path );
00089
00090 void connectItem( QgsDataItem *item );
00091
00092 signals:
00093
00094 public slots:
00095
00096
00097
00098
00099 void beginInsertItems( QgsDataItem *parent, int first, int last );
00100 void endInsertItems();
00101 void beginRemoveItems( QgsDataItem *parent, int first, int last );
00102 void endRemoveItems();
00103
00104 protected:
00105
00106
00107 void addRootItems();
00108 void removeRootItems();
00109
00110 QVector<QgsDataItem*> mRootItems;
00111 };
00112
00113 #endif // QGSBROWSERMODEL_H