QGIS API Documentation 3.41.0-Master (3440c17df1d)
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_sip.h"
21#include "qgis_core.h"
22
23#include "qgis.h"
25#include "qgsdirectoryitem.h"
26
31class CORE_EXPORT QgsFavoritesItem : public QgsDataCollectionItem
32{
33 Q_OBJECT
34 public:
35
40 QgsFavoritesItem( QgsDataItem *parent, const QString &name, const QString &path = QString() );
41
42#ifdef SIP_RUN
43 SIP_PYOBJECT __repr__();
44 % MethodCode
45 QString str = QStringLiteral( "<QgsFavoritesItem: \"%1\">" ).arg( sipCpp->name() );
46 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
47 % End
48#endif
49
50 QVector<QgsDataItem *> createChildren() override;
51
60 void addDirectory( const QString &directory, const QString &name = QString() );
61
66 void removeDirectory( QgsDirectoryItem *item );
67
71 void renameFavorite( const QString &path, const QString &name );
72
74 static QIcon iconFavorites();
75
76 QVariant sortKey() const override;
77
78 private:
79 QVector<QgsDataItem *> createChildren( const QString &directory, const QString &name );
80};
81
82#ifndef SIP_RUN
83
89Q_NOWARN_DEPRECATED_PUSH // rename is deprecated
90class CORE_EXPORT QgsFavoriteItem : public QgsDirectoryItem
91{
92 Q_OBJECT
93
94 public:
95
104 QgsFavoriteItem( QgsFavoritesItem *parent, const QString &name, const QString &dirPath, const QString &path );
105
106 // TODO QGIS 4.0 - don't remove this method when the deprecated base class virtual method is removed, but instead
107 // remove the override!
108
112 bool rename( const QString &name ) override;
113
114 private:
115
116 QgsFavoritesItem *mFavorites = nullptr;
117
118};
120
121#endif
122
123#endif // QGSFAVORITESITEM_H
124
125
A Collection: logical collection of layers or subcollections, e.g.
Base class for all items in the model.
Definition qgsdataitem.h:46
virtual QVariant sortKey() const
Returns the sorting key for the 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.
A directory: contains subdirectories and layers.
A directory item showing the a single favorite directory.
Contains various Favorites directories.
#define str(x)
Definition qgis.cpp:39
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:6535
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:6534