QGIS API Documentation 3.99.0-Master (e9821da5c6b)
Loading...
Searching...
No Matches
qgsfavoritesitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsfavoritesitem.h
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#ifndef QGSFAVORITESITEM_H
18#define QGSFAVORITESITEM_H
19
20#include "qgis.h"
21#include "qgis_core.h"
22#include "qgis_sip.h"
24#include "qgsdirectoryitem.h"
25
26#include <QString>
27
28using namespace Qt::StringLiterals;
29
34class CORE_EXPORT QgsFavoritesItem : public QgsDataCollectionItem
35{
36 Q_OBJECT
37 public:
38
43 QgsFavoritesItem( QgsDataItem *parent, const QString &name, const QString &path = QString() );
44
45#ifdef SIP_RUN
46 SIP_PYOBJECT __repr__();
47 % MethodCode
48 QString str = u"<QgsFavoritesItem: \"%1\">"_s.arg( sipCpp->name() );
49 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
50 % End
51#endif
52
53 QVector<QgsDataItem *> createChildren() override;
54
63 void addDirectory( const QString &directory, const QString &name = QString() );
64
70
74 void renameFavorite( const QString &path, const QString &name );
75
77 static QIcon iconFavorites();
78
79 QVariant sortKey() const override;
80
81 private:
82 QVector<QgsDataItem *> createChildren( const QString &directory, const QString &name );
83};
84
85#ifndef SIP_RUN
86
92Q_NOWARN_DEPRECATED_PUSH // rename is deprecated
93class CORE_EXPORT QgsFavoriteItem : public QgsDirectoryItem
94{
95 Q_OBJECT
96
97 public:
98
107 QgsFavoriteItem( QgsFavoritesItem *parent, const QString &name, const QString &dirPath, const QString &path );
108
109 // TODO QGIS 5.0 - don't remove this method when the deprecated base class virtual method is removed, but instead
110 // remove the override!
111
115 bool rename( const QString &name ) override;
116
117 private:
118
119 QgsFavoritesItem *mFavorites = nullptr;
120
121};
123
124#endif
125
126#endif // QGSFAVORITESITEM_H
127
128
QgsDataCollectionItem(QgsDataItem *parent, const QString &name, const QString &path=QString(), const QString &providerKey=QString())
Constructor for QgsDataCollectionItem, with the specified parent item.
virtual QVariant sortKey() const
Returns the sorting key for the item.
QgsDataItem(Qgis::BrowserItemType type, QgsDataItem *parent, const QString &name, const QString &path, const QString &providerKey=QString())
Constructor for QgsDataItem, with the specified parent item.
virtual QVector< QgsDataItem * > createChildren()
Create children.
virtual Q_DECL_DEPRECATED bool rename(const QString &name)
Sets a new name for the item, and returns true if the item was successfully renamed.
QString name() const
Returns the name of the item (the displayed text for the item).
QString path() const
QgsDataItem * parent() const
Gets item parent.
A browser item for directories: contains subdirectories and layers.
QString dirPath() const
Returns the full path to the directory the item represents.
QgsDirectoryItem(QgsDataItem *parent, const QString &name, const QString &path)
Constructor for QgsDirectoryItem, with the specified parent item.
QgsFavoriteItem(QgsFavoritesItem *parent, const QString &name, const QString &dirPath, const QString &path)
Constructor for QgsFavoriteItem.
A browser item which contains various Favorites directories.
void addDirectory(const QString &directory, const QString &name=QString())
Adds a new directory to the favorites group.
void removeDirectory(QgsDirectoryItem *item)
Removes an existing directory from the favorites group.
static QIcon iconFavorites()
Icon for favorites group.
QgsFavoritesItem(QgsDataItem *parent, const QString &name, const QString &path=QString())
Constructor for QgsFavoritesItem.
void renameFavorite(const QString &path, const QString &name)
Renames the stored favorite with corresponding path a new name.
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:7475
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:7474