15 #ifndef QGSBROWSERMODEL_H
16 #define QGSBROWSERMODEL_H
18 #include "qgis_core.h"
21 #include <QAbstractItemModel>
71 PathRole = Qt::UserRole,
72 CommentRole = Qt::UserRole + 1,
78 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
79 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
80 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
81 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole )
const override;
82 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
83 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
84 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
85 QModelIndex parent(
const QModelIndex &index )
const override;
86 QStringList mimeTypes()
const override;
87 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
88 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
override;
89 bool hasChildren(
const QModelIndex &parent = QModelIndex() )
const override;
90 bool canFetchMore(
const QModelIndex &parent )
const override;
91 void fetchMore(
const QModelIndex &parent )
override;
107 QgsDataItem *dataItem(
const QModelIndex &idx )
const;
110 void refresh(
const QString &path );
113 void refresh(
const QModelIndex &index = QModelIndex() );
123 QModelIndex findPath(
const QString &path, Qt::MatchFlag matchFlag = Qt::MatchExactly );
126 static QModelIndex findPath( QAbstractItemModel *model,
const QString &path, Qt::MatchFlag matchFlag = Qt::MatchExactly )
SIP_SKIP;
137 QModelIndex findUri(
const QString &uri, QModelIndex index = QModelIndex() );
159 QMap<QString, QgsDirectoryItem *> driveItems()
const;
182 void refreshDrives();
184 void beginInsertItems(
QgsDataItem *parent,
int first,
int last );
185 void endInsertItems();
186 void beginRemoveItems(
QgsDataItem *parent,
int first,
int last );
187 void endRemoveItems();
204 void addFavoriteDirectory(
const QString &directory,
const QString &name = QString() );
211 void removeFavorite(
const QModelIndex &index );
221 void updateProjectHome();
235 void removeRootItems();
244 void onConnectionsChanged(
const QString &providerKey );
247 bool mInitialized =
false;
248 QMap< QString, QgsDirectoryItem * > mDriveItems;
256 friend class TestQgsBrowserModel;
257 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()
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.