Quantum GIS API Documentation  master-ce49b66
src/core/qgsbrowsermodel.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     qgsbrowsermodel.h
00003     ---------------------
00004     begin                : July 2011
00005     copyright            : (C) 2011 by Martin Dobias
00006     email                : wonder dot sk at gmail dot 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     // Refresh item specified by path
00079     void refresh( QString path );
00080 
00081     // Refresh item childs
00082     void refresh( const QModelIndex &index = QModelIndex() );
00083 
00085     QModelIndex findPath( QString path );
00086 
00087     void connectItem( QgsDataItem *item );
00088 
00089     bool canFetchMore( const QModelIndex & parent ) const;
00090     void fetchMore( const QModelIndex & parent );
00091 
00092   public slots:
00093     // Reload the whole model
00094     void reload();
00095     void beginInsertItems( QgsDataItem *parent, int first, int last );
00096     void endInsertItems();
00097     void beginRemoveItems( QgsDataItem *parent, int first, int last );
00098     void endRemoveItems();
00099 
00100     void addFavouriteDirectory( QString favDir );
00101     void removeFavourite( const QModelIndex &index );
00102 
00103     void updateProjectHome();
00104 
00105   protected:
00106     // populates the model
00107     void addRootItems();
00108     void removeRootItems();
00109 
00110     QVector<QgsDataItem*> mRootItems;
00111     QgsFavouritesItem *mFavourites;
00112     QgsDirectoryItem *mProjectHome;
00113 };
00114 
00115 #endif // QGSBROWSERMODEL_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines