QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgsdataitemguiproviderutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsdataitemguiproviderutils.h
3 --------------------------------------
4 Date : June 2024
5 Copyright : (C) 2024 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSDATAITEMGUIPROVIDERUTILS_H
17#define QGSDATAITEMGUIPROVIDERUTILS_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21#include "qgis.h"
22#include "qgsdataitem.h"
24#include <QPointer>
25#include <functional>
26
27class QgsDataItem;
28
38{
39 public:
40
41#ifndef SIP_RUN
42
48 template<class T>
49 static void deleteConnections( const QList< T * > &items, const std::function< void( const QString & ) > &deleteConnection, QgsDataItemGuiContext context )
50 {
51 ( void )context;
52 if ( items.empty() )
53 return;
54
55 QStringList connectionNames;
56 connectionNames.reserve( items.size() );
57 for ( T *item : items )
58 {
59 connectionNames << item->name();
60 }
61 QPointer< QgsDataItem > firstParent( items.at( 0 )->parent() );
62 deleteConnectionsPrivate( connectionNames, deleteConnection, firstParent );
63 }
64
73 static const QString uniqueName( const QString &name, const QStringList &connectionNames );
74
75#endif
76
77 private:
78 static void deleteConnectionsPrivate( const QStringList &connectionNames, const std::function<void ( const QString & )> &deleteConnection, QPointer<QgsDataItem> firstParent );
79};
80
81#endif // QGSDATAITEMGUIPROVIDERUTILS_H
Encapsulates the context in which a QgsDataItem is shown within the application GUI.
Utility functions for QgsDataItemGuiProviders.
static void deleteConnections(const QList< T * > &items, const std::function< void(const QString &) > &deleteConnection, QgsDataItemGuiContext context)
Handles deletion of a list of connection items.
Base class for all items in the model.
Definition qgsdataitem.h:46