QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsprojectitem.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprojectitem.cpp
3 -------------------
4 begin : 2011-04-01
5 copyright : (C) 2011 Radim Blazek
6 email : radim dot blazek at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "qgsprojectitem.h"
19#include <QDir>
20
21QgsProjectItem::QgsProjectItem( QgsDataItem *parent, const QString &name,
22 const QString &path, const QString &providerKey )
23 : QgsDataItem( Qgis::BrowserItemType::Project, parent, name, path, providerKey )
24{
25 mIconName = QStringLiteral( ":/images/icons/qgis_icon.svg" );
26 setToolTip( QDir::toNativeSeparators( path ) );
27 setState( Qgis::BrowserItemState::Populated ); // no more children
28}
29
31{
33 u.layerType = QStringLiteral( "project" );
34 u.name = mName;
35 u.uri = mPath;
36
38 {
39 u.filePath = path();
40 }
41
42 return { u };
43}
44
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:54
@ Populated
Children created.
@ ItemRepresentsFile
Item's path() directly represents a file on disk (since QGIS 3.22)
Base class for all items in the model.
Definition: qgsdataitem.h:46
QString mName
Definition: qgsdataitem.h:441
void setToolTip(const QString &msg)
Definition: qgsdataitem.h:398
QString mPath
Definition: qgsdataitem.h:447
QString mIconName
Definition: qgsdataitem.h:449
QString path() const
Definition: qgsdataitem.h:348
virtual void setState(Qgis::BrowserItemState state)
Set item state.
virtual Qgis::BrowserItemCapabilities capabilities2() const
Returns the capabilities for the data item.
Definition: qgsdataitem.h:297
QList< QgsMimeDataUtils::Uri > UriList
QgsMimeDataUtils::UriList mimeUris() const override
Returns mime URIs for the data item, most data providers will only return a single URI but some data ...
QgsProjectItem(QgsDataItem *parent, const QString &name, const QString &path, const QString &providerKey=QString())
A data item holding a reference to a QGIS project file.
QString filePath
Path to file, if uri is associated with a file.
QString uri
Identifier of the data source recognized by its providerKey.
QString name
Human readable name to be used e.g. in layer tree.
QString layerType
Type of URI.