15 #ifndef QGSBROWSERMODEL_H 
   16 #define QGSBROWSERMODEL_H 
   18 #include "qgis_core.h" 
   20 #include <QAbstractItemModel> 
   25 #include <QFutureWatcher> 
   95       PathRole = Qt::UserRole, 
 
   96       CommentRole = Qt::UserRole + 1, 
 
  102     Qt::ItemFlags flags( 
const QModelIndex &index ) 
const override;
 
  103     QVariant data( 
const QModelIndex &index, 
int role = Qt::DisplayRole ) 
const override;
 
  104     bool setData( 
const QModelIndex &index, 
const QVariant &value, 
int role = Qt::EditRole ) 
override;
 
  105     QVariant headerData( 
int section, Qt::Orientation orientation, 
int role = Qt::DisplayRole ) 
const override;
 
  106     int rowCount( 
const QModelIndex &parent = QModelIndex() ) 
const override;
 
  107     int columnCount( 
const QModelIndex &parent = QModelIndex() ) 
const override;
 
  108     QModelIndex index( 
int row, 
int column, 
const QModelIndex &parent = QModelIndex() ) 
const override;
 
  109     QModelIndex parent( 
const QModelIndex &index ) 
const override;
 
  110     QStringList mimeTypes() 
const override;
 
  111     QMimeData *mimeData( 
const QModelIndexList &indexes ) 
const override;
 
  112     bool dropMimeData( 
const QMimeData *data, Qt::DropAction action, 
int row, 
int column, 
const QModelIndex &parent ) 
override;
 
  113     bool hasChildren( 
const QModelIndex &parent = QModelIndex() ) 
const override;
 
  114     bool canFetchMore( 
const QModelIndex &parent ) 
const override;
 
  115     void fetchMore( 
const QModelIndex &parent ) 
override;
 
  131     QgsDataItem *dataItem( 
const QModelIndex &idx ) 
const;
 
  134     void refresh( 
const QString &path );
 
  137     void refresh( 
const QModelIndex &index = QModelIndex() );
 
  147     QModelIndex findPath( 
const QString &path, Qt::MatchFlag matchFlag = Qt::MatchExactly );
 
  150     static QModelIndex findPath( QAbstractItemModel *model, 
const QString &path, Qt::MatchFlag matchFlag = Qt::MatchExactly ) 
SIP_SKIP;
 
  161     QModelIndex findUri( 
const QString &uri, QModelIndex index = QModelIndex() );
 
  183     QMap<QString, QgsDirectoryItem *> driveItems() 
const;
 
  206     void refreshDrives();
 
  208     void beginInsertItems( 
QgsDataItem *parent, 
int first, 
int last );
 
  209     void endInsertItems();
 
  210     void beginRemoveItems( 
QgsDataItem *parent, 
int first, 
int last );
 
  211     void endRemoveItems();
 
  228     void addFavoriteDirectory( 
const QString &directory, 
const QString &name = QString() );
 
  235     void removeFavorite( 
const QModelIndex &index );
 
  245     void updateProjectHome();
 
  259     void removeRootItems();
 
  268     void onConnectionsChanged( 
const QString &providerKey );
 
  271     bool mInitialized = 
false;
 
  272     QMap< QString, QgsDirectoryItem * > mDriveItems;
 
  280     friend class TestQgsBrowserModel;
 
  281     friend class TestQgsBrowserProxyModel;
 
BrowserItemState
Browser item states.
A model for showing available data sources and other items in a structured tree.
void connectionsChanged(const QString &providerKey)
Emitted when connections for the specified providerKey have changed in the browser.
QVector< QgsDataItem * > mRootItems
void stateChanged(const QModelIndex &index, Qgis::BrowserItemState oldState)
Emitted when item children fetch was finished.
bool initialized() const
Returns true if the model has been initialized.
@ ProviderKeyRole
Data item provider key that created the item, see QgsDataItem::providerKey()
@ SortRole
Custom sort role, see QgsDataItem::sortKey()
QgsDataItem * item() const
void finished(QgsDataItem *item, const QVector< QgsDataItem * > &items)
This is the interface for those who want to add custom data items to the browser tree.
Base class for all items in the model.
A directory: contains subdirectories and layers.
A directory item showing the a single favorite directory.
Contains various Favorites directories.