15#ifndef QGSBROWSERMODEL_H
16#define QGSBROWSERMODEL_H
21#include <QAbstractItemModel>
71 PathRole = Qt::UserRole,
72 CommentRole = Qt::UserRole + 1,
79 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
80 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
81 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
82 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole )
const override;
83 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
84 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
85 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
86 QModelIndex parent(
const QModelIndex &index )
const override;
87 QStringList mimeTypes()
const override;
88 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
89 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
override;
90 bool hasChildren(
const QModelIndex &parent = QModelIndex() )
const override;
91 bool canFetchMore(
const QModelIndex &parent )
const override;
92 void fetchMore(
const QModelIndex &parent )
override;
108 QgsDataItem *dataItem(
const QModelIndex &idx )
const;
111 void refresh(
const QString &path );
114 void refresh(
const QModelIndex &index = QModelIndex() );
124 QModelIndex findPath(
const QString &path, Qt::MatchFlag matchFlag = Qt::MatchExactly );
127 static QModelIndex findPath( QAbstractItemModel *model,
const QString &path, Qt::MatchFlag matchFlag = Qt::MatchExactly )
SIP_SKIP;
138 QModelIndex findUri(
const QString &uri, QModelIndex index = QModelIndex() );
160 QMap<QString, QgsDirectoryItem *> driveItems()
const;
167 QVector<QgsDataItem *>
rootItems()
const {
return mRootItems; }
191 void refreshDrives();
193 void beginInsertItems(
QgsDataItem *parent,
int first,
int last );
194 void endInsertItems();
195 void beginRemoveItems(
QgsDataItem *parent,
int first,
int last );
196 void endRemoveItems();
213 void addFavoriteDirectory(
const QString &directory,
const QString &name = QString() );
220 void removeFavorite(
const QModelIndex &index );
230 void updateProjectHome();
244 void removeRootItems();
253 void onConnectionsChanged(
const QString &providerKey );
256 bool mInitialized =
false;
257 QMap< QString, QgsDirectoryItem * > mDriveItems;
265 friend class TestQgsBrowserModel;
266 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()
QVector< QgsDataItem * > rootItems() const
Returns the root items for the model.
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.