QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsdirectoryitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsddirectoryitem.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 QGSDIRECTORYITEM_H
18#define QGSDIRECTORYITEM_H
19
20#include "qgis_sip.h"
21#include "qgis_core.h"
23#include <QDateTime>
24#include <QTreeWidget>
25
26class QFileSystemWatcher;
27class QMouseEvent;
28
33class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem
34{
35 Q_OBJECT
36 public:
37
48 QgsDirectoryItem( QgsDataItem *parent SIP_TRANSFERTHIS, const QString &name, const QString &path );
49
50
51 // TODO QGIS 4.0 -- rename "name" to "title" or "text" or something more descriptive, and "path" to something
52 // else to clarify the role of dirPath vs path
53
70 QgsDirectoryItem( QgsDataItem *parent SIP_TRANSFERTHIS, const QString &name, const QString &dirPath, const QString &path, const QString &providerKey = QString() );
71
72#ifdef SIP_RUN
73 SIP_PYOBJECT __repr__();
74 % MethodCode
75 QString str = QStringLiteral( "<QgsDirectoryItem: %1 - %2>" ).arg( sipCpp->dirPath(), sipCpp->path() );
76 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
77 % End
78#endif
79 void setState( Qgis::BrowserItemState state ) override;
80
81 QVector<QgsDataItem *> createChildren() override;
82
86 QString dirPath() const { return mDirPath; }
87
88 bool equal( const QgsDataItem *other ) override;
89 QIcon icon() override;
90
99 QColor iconColor() const;
100
112 void setIconColor( const QColor &color );
113
121 static void setCustomColor( const QString &directory, const QColor &color );
122
123 Q_DECL_DEPRECATED QWidget *paramWidget() override SIP_FACTORY SIP_DEPRECATED;
124 bool hasDragEnabled() const override { return true; }
125 QgsMimeDataUtils::UriList mimeUris() const override;
126
128 static bool hiddenPath( const QString &path );
129
140 static Qgis::BrowserDirectoryMonitoring monitoringForPath( const QString &path );
141
161 static bool pathShouldByMonitoredByDefault( const QString &path );
162
169 bool isMonitored() const { return mMonitored; }
170
177 Qgis::BrowserDirectoryMonitoring monitoring() const;
178
187 void setMonitoring( Qgis::BrowserDirectoryMonitoring monitoring );
188
196 void reevaluateMonitoring() SIP_SKIP;
197
198 public slots:
199 void childrenCreated() override;
200 void directoryChanged();
201
202 protected:
203
204 QString mDirPath;
205
206 private:
207
208 void init( const QString &dirName );
209
210 void createOrDestroyFileSystemWatcher();
211
212 Qgis::BrowserDirectoryMonitoring mMonitoring = Qgis::BrowserDirectoryMonitoring::Default;
213 bool mMonitored = true;
214 QFileSystemWatcher *mFileSystemWatcher = nullptr;
215 bool mRefreshLater = false;
216 QDateTime mLastScan;
217 QColor mIconColor;
218
219 friend class TestQgsDataItem;
220};
221
222// ---------
223
224// TODO: move to qgis_gui for QGIS 4
225
232class CORE_EXPORT QgsDirectoryParamWidget : public QTreeWidget
233{
234 Q_OBJECT
235
236 public:
237 QgsDirectoryParamWidget( const QString &path, QWidget *parent SIP_TRANSFERTHIS = nullptr );
238
239 protected:
240 void mousePressEvent( QMouseEvent *event ) override;
241
242 public slots:
243 void showHideColumn();
244};
245
246
247#ifndef SIP_RUN
248
255class CORE_EXPORT QgsProjectHomeItem : public QgsDirectoryItem
256{
257 Q_OBJECT
258
259 public:
260
264 QgsProjectHomeItem( QgsDataItem *parent, const QString &name, const QString &dirPath, const QString &path );
265
266 QIcon icon() override;
267 QVariant sortKey() const override;
268
269};
270
271#endif
272
273#endif // QGSDATAITEM_H
274
275
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
BrowserItemState
Browser item states.
Definition qgis.h:625
BrowserDirectoryMonitoring
Browser directory item monitoring switches.
Definition qgis.h:684
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 QIcon icon()
virtual void setState(Qgis::BrowserItemState state)
Set item state.
virtual Q_DECL_DEPRECATED QWidget * paramWidget()
Returns source widget from data item for QgsBrowserPropertiesWidget.
virtual QgsMimeDataUtils::UriList mimeUris() const
Returns mime URIs for the data item, most data providers will only return a single URI but some data ...
virtual bool equal(const QgsDataItem *other)
Returns true if this item is equal to another item (by testing item type and path).
A directory: contains subdirectories and layers.
bool isMonitored() const
Returns true if the directory is currently being monitored for changes and the item auto-refreshed wh...
QString dirPath() const
Returns the full path to the directory the item represents.
Browser parameter widget implementation for directory items.
QList< QgsMimeDataUtils::Uri > UriList
A directory item showing the current project directory.
#define str(x)
Definition qgis.cpp:38
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_FACTORY
Definition qgis_sip.h:76