QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 bool mIsDir = false;
220 bool mIsSymLink = false;
221
222 friend class TestQgsDataItem;
223};
224
225// ---------
226
227// TODO: move to qgis_gui for QGIS 4
228
235class CORE_EXPORT QgsDirectoryParamWidget : public QTreeWidget
236{
237 Q_OBJECT
238
239 public:
240 QgsDirectoryParamWidget( const QString &path, QWidget *parent SIP_TRANSFERTHIS = nullptr );
241
242 protected:
243 void mousePressEvent( QMouseEvent *event ) override;
244
245 public slots:
246 void showHideColumn();
247};
248
249
250#ifndef SIP_RUN
251
257class CORE_EXPORT QgsProjectHomeItem : public QgsDirectoryItem
258{
259 Q_OBJECT
260
261 public:
262
266 QgsProjectHomeItem( QgsDataItem *parent, const QString &name, const QString &dirPath, const QString &path );
267
268 QIcon icon() override;
269 QVariant sortKey() const override;
270
271};
272
273#endif
274
275#endif // QGSDATAITEM_H
276
277
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
BrowserItemState
Browser item states.
Definition qgis.h:872
BrowserDirectoryMonitoring
Browser directory item monitoring switches.
Definition qgis.h:959
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 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