QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
21 QgsProjectItem::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 
QgsProjectItem::mimeUris
QgsMimeDataUtils::UriList mimeUris() const override
Returns mime URIs for the data item, most data providers will only return a single URI but some data ...
Definition: qgsprojectitem.cpp:30
QgsMimeDataUtils::Uri::name
QString name
Human readable name to be used e.g. in layer tree.
Definition: qgsmimedatautils.h:123
QgsMimeDataUtils::Uri::uri
QString uri
Identifier of the data source recognized by its providerKey.
Definition: qgsmimedatautils.h:125
QgsDataItem::path
QString path() const
Definition: qgsdataitem.h:354
QgsMimeDataUtils::Uri::layerType
QString layerType
Type of URI.
Definition: qgsmimedatautils.h:112
QgsDataItem::setToolTip
void setToolTip(const QString &msg)
Definition: qgsdataitem.h:406
QgsMimeDataUtils::UriList
QList< QgsMimeDataUtils::Uri > UriList
Definition: qgsmimedatautils.h:164
QgsDataItem::mIconName
QString mIconName
Definition: qgsdataitem.h:457
Qgis::BrowserItemCapability::ItemRepresentsFile
@ ItemRepresentsFile
Item's path() directly represents a file on disk (since QGIS 3.22)
Qgis::BrowserItemState::Populated
@ Populated
Children created.
QgsDataItem::setState
virtual void setState(Qgis::BrowserItemState state)
Set item state.
Definition: qgsdataitem.cpp:557
QgsMimeDataUtils::Uri::filePath
QString filePath
Path to file, if uri is associated with a file.
Definition: qgsmimedatautils.h:154
QgsDataItem::mName
QString mName
Definition: qgsdataitem.h:449
QgsMimeDataUtils::Uri
Definition: qgsmimedatautils.h:40
QgsDataItem::mPath
QString mPath
Definition: qgsdataitem.h:455
QgsProjectItem::QgsProjectItem
QgsProjectItem(QgsDataItem *parent, const QString &name, const QString &path, const QString &providerKey=QString())
A data item holding a reference to a QGIS project file.
Definition: qgsprojectitem.cpp:21
qgsprojectitem.h
Qgis
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:71
QgsDataItem::capabilities2
virtual Qgis::BrowserItemCapabilities capabilities2() const
Returns the capabilities for the data item.
Definition: qgsdataitem.h:303
QgsDataItem
Base class for all items in the model.
Definition: qgsdataitem.h:45