16 #include <QApplication> 18 #include <QtConcurrentMap> 52 , mFavourites( nullptr )
53 , mProjectHome( nullptr )
54 , mInitialized( false )
155 Q_FOREACH (
int key, providerMap.
uniqueKeys() )
158 if ( providerGroup.
size() > 1 )
191 flags |= Qt::ItemIsDragEnabled;
194 flags |= Qt::ItemIsDropEnabled;
208 else if ( role == Qt::DisplayRole )
212 else if ( role == Qt::ToolTipRole )
216 else if ( role == Qt::DecorationRole && index.
column() == 0 )
243 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
286 return findPath(
this, path, matchFlag );
295 bool foundChild =
true;
301 for (
int i = 0; i < model->
rowCount( theIndex ); i++ )
306 if ( itemPath == path )
322 if ( matchFlag == Qt::MatchStartsWith )
340 if ( column < 0 || column >=
columnCount() || row < 0 )
362 for (
int i = 0; i < items.
size(); i++ )
364 if ( items[i] == item )
379 if ( !idx.isValid() )
394 if ( !idx.isValid() )
442 types <<
"application/x-vnd.qgis.qgis.uri";
561 hiddenItems << item->
path();
563 settings.
setValue(
"/browser/hiddenPaths", hiddenItems );
580 if ( ! mInitialized )
virtual void refresh(QVector< QgsDataItem *> children)
Contains various Favourites directories.
virtual int rowCount(const QModelIndex &parent) const=0
void removeDirectory(QgsDirectoryItem *item)
static bool cmpByDataItemName_(QgsDataItem *a, QgsDataItem *b)
static QgsDataItemProviderRegistry * instance()
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const=0
bool canFetchMore(const QModelIndex &parent) const override
int localeAwareCompare(const QString &other) const
void hidePath(QgsDataItem *item)
Hide the given path in the browser model.
QList< T > values() const
virtual QgsDataItem * createDataItem(const QString &path, QgsDataItem *parentItem)=0
Create a new instance of QgsDataItem (or null) for given path and parent item.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Provides the number of rows of data exposed by the model.
void fetchMore(const QModelIndex &parent) override
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Used to supply item data to views and delegates.
QVector< QgsDataItem * > children() const
int indexOf(const T &value, int from) const
void removeFavourite(const QModelIndex &index)
virtual bool handleDrop(const QMimeData *, Qt::DropAction)
Attempts to process the mime data dropped on this item.
QgsFavouritesItem * mFavourites
QModelIndex findPath(const QString &path, Qt::MatchFlag matchFlag=Qt::MatchExactly)
Return index of item with given path.
void beginRemoveItems(QgsDataItem *parent, int first, int last)
void connectItem(QgsDataItem *item)
void insert(int i, const T &value)
void init()
Delayed initialization.
static QMimeData * encodeUriList(const UriList &layers)
void setIcon(const QIcon &icon)
void itemStateChanged(QgsDataItem *item, QgsDataItem::State oldState)
virtual QStringList mimeTypes() const override
Returns a list of mime that can describe model indexes.
QgsBrowserModel(QObject *parent=nullptr, bool initialize=true)
QgsBrowserModel.
QString tr(const char *sourceText, const char *disambiguation, int n)
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
void setValue(const QString &key, const QVariant &value)
QgsDirectoryItem * mProjectHome
static void deleteLater(QVector< QgsDataItem *> &items)
void append(const T &value)
iterator insertMulti(const Key &key, const T &value)
QgsDataItem * parent() const
Get item parent.
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
#define QgsDebugMsgLevel(str, level)
void beginRemoveRows(const QModelIndex &parent, int first, int last)
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
Children not yet created.
Creating children in separate thread (populating or refreshing)
QgsDataItem * dataItem(const QModelIndex &idx) const
void * internalPointer() const
virtual int capabilities()=0
Return combination of flags from QgsDataProvider::DataCapabilities.
virtual QVariant data(const QModelIndex &index, int role) const=0
QgsBrowserWatcher(QgsDataItem *item)
void reload()
Reload the whole model.
A directory: contains subdirectories and layers.
QModelIndex createIndex(int row, int column, void *ptr) const
Base class for all items in the model.
void addDirectory(const QString &favIcon)
void beginInsertRows(const QModelIndex &parent, int first, int last)
QModelIndex findItem(QgsDataItem *item, QgsDataItem *parent=nullptr) const
QVariant value(const QString &key, const QVariant &defaultValue) const
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Provides views with information to show in their headers.
static bool hiddenPath(QString path)
Check if the given path is hidden from the browser model.
void addFavouriteDirectory(const QString &favDir)
QStringList toStringList() const
void beginInsertItems(QgsDataItem *parent, int first, int last)
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the index of the item in the model specified by the given row, column and parent index...
static QgsProject * instance()
Returns the QgsProject singleton instance.
int count(const T &value) const
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const override
Provides the number of columns of data exposed by the model.
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Handles the data supplied by a drag and drop operation that ended with the given action.
void stateChanged(const QModelIndex &index, QgsDataItem::State oldState)
Emitted when item children fetch was finished.
void refresh(const QString &path)
Refresh item specified by path.
virtual QMimeData * mimeData(const QModelIndexList &indexes) const override
Returns an object that contains serialized items of data corresponding to the list of indexes specifi...
Represents a QGIS project.
Item that represents a layer that can be opened with one of the providers.
int indexOf(const QRegExp &rx, int from) const
virtual void deleteChildItem(QgsDataItem *child)
Removes and deletes a child item, emitting relevant signals to the model.
virtual QString name()=0
Human-readable name of the provider name.
void itemDataChanged(QgsDataItem *item)
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
Used by other components to obtain information about each item provided by the model.
virtual void populate(const QVector< QgsDataItem *> &children)
QString absolutePath() const
virtual bool acceptDrop()
Returns whether the item accepts drag and dropped layers - e.g.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, const QWidget *widget) const=0
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
virtual QString comments() const
Returns comments of the layer.
void addRootItems()
Populates the model.
This is the interface for those who want to add custom data items to the browser tree.
void setUrls(const QList< QUrl > &urls)
QUrl fromLocalFile(const QString &localFile)
QList< Key > uniqueKeys() const
QVector< QgsDataItem * > mRootItems