QGIS API Documentation 4.1.0-Master (8da4c00a38b)
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#include "qgssettingstree.h"
26
27#include <QString>
28
30
31using namespace Qt::StringLiterals;
32
37class CORE_EXPORT QgsFavoritesItem : public QgsDataCollectionItem
38{
39 Q_OBJECT
40 public:
41#ifndef SIP_RUN
46#endif
47
52 QgsFavoritesItem( QgsDataItem *parent, const QString &name, const QString &path = QString() );
53
54#ifdef SIP_RUN
55 // clang-format off
56 SIP_PYOBJECT __repr__();
57 % MethodCode
58 QString str = u"<QgsFavoritesItem: \"%1\">"_s.arg( sipCpp->name() );
59 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
60 % End
61// clang-format on
62#endif
63
64 QVector<QgsDataItem *> createChildren() override;
65
74 void addDirectory( const QString &directory, const QString &name = QString() );
75
81
85 void renameFavorite( const QString &path, const QString &name );
86
88 static QIcon iconFavorites();
89
90 QVariant sortKey() const override;
91
92 private:
93 QVector<QgsDataItem *> createChildren( const QString &directory, const QString &name );
94};
95
96#ifndef SIP_RUN
97
103Q_NOWARN_DEPRECATED_PUSH // rename is deprecated
104 class CORE_EXPORT QgsFavoriteItem : public QgsDirectoryItem
105{
106 Q_OBJECT
107
108 public:
117 QgsFavoriteItem( QgsFavoritesItem *parent, const QString &name, const QString &dirPath, const QString &path );
118
119 // TODO QGIS 5.0 - don't remove this method when the deprecated base class virtual method is removed, but instead
120 // remove the override!
121
125 bool rename( const QString &name ) override;
126
127 private:
128 QgsFavoritesItem *mFavorites = nullptr;
129};
131
132#endif
133
134#endif // QGSFAVORITESITEM_H
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.
static QgsSettingsTreeNode * sTreeBrowser
Settings tree node for browser settings.
static const QgsSettingsEntryStringList * settingsFavoriteDirs
Settings entry for favorite directories.
A string list settings entry.
A tree node for the settings tree to help organizing and introspecting the tree.
QgsSettingsTreeNode * createChildNode(const QString &key)
Creates a normal tree node It will return the existing child node if it exists at the given key.
static QgsSettingsTreeNode * treeRoot()
Returns the tree root node for the settings tree.
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:7652
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:7651