Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgsbrowsermodel.h 00003 --------------------- 00004 begin : July 2011 00005 copyright : (C) 2011 by Martin Dobias 00006 email : wonder.sk at gmail.com 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 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 // implemented methods from QAbstractItemModel for read-only access 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 // Reload the whole model 00079 void reload(); 00080 00081 // Refresh item specified by path 00082 void refresh( QString path ); 00083 00084 // Refresh item childs 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 //void removeItems( QgsDataItem * parent, QVector<QgsDataItem *>items ); 00096 //void addItems( QgsDataItem * parent, QVector<QgsDataItem *>items ); 00097 //void refreshItems( QgsDataItem * parent, QVector<QgsDataItem *>items ); 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 // populates the model 00107 void addRootItems(); 00108 void removeRootItems(); 00109 00110 QVector<QgsDataItem*> mRootItems; 00111 }; 00112 00113 #endif // QGSBROWSERMODEL_H