QGIS API Documentation 3.41.0-Master (cea29feecf2)
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#ifndef SIP_RUN
41
47 template<class T>
48 static void deleteConnections( const QList<T *> &items, const std::function<void( const QString & )> &deleteConnection, QgsDataItemGuiContext context )
49 {
50 ( void ) context;
51 if ( items.empty() )
52 return;
53
54 QStringList connectionNames;
55 connectionNames.reserve( items.size() );
56 for ( T *item : items )
57 {
58 connectionNames << item->name();
59 }
60 QPointer<QgsDataItem> firstParent( items.at( 0 )->parent() );
61 deleteConnectionsPrivate( connectionNames, deleteConnection, firstParent );
62 }
63
72 static const QString uniqueName( const QString &name, const QStringList &connectionNames );
73
74#endif
75
76 private:
77 static void deleteConnectionsPrivate( const QStringList &connectionNames, const std::function<void( const QString & )> &deleteConnection, QPointer<QgsDataItem> firstParent );
78};
79
80#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