QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgsscopedconnection.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsscopedconnection.h
3
----------------------
4
begin : May 2026
5
copyright : (C) 2026 by Nyall Dawson
6
email : nyall dot dawson 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
18
#ifndef QGSSCOPEDCONNECTION_H
19
#define QGSSCOPEDCONNECTION_H
20
21
#include <QMetaObject>
22
#include <QObject>
23
24
#define SIP_NO_FILE
25
32
class
QgsScopedConnection
33
{
34
public
:
38
QgsScopedConnection
() =
default
;
39
43
explicit
QgsScopedConnection
( QMetaObject::Connection connection )
44
: mConnection( std::move( connection ) )
45
{}
46
52
~QgsScopedConnection
() {
disconnect
(); }
53
54
// No copies permitted
55
QgsScopedConnection
(
const
QgsScopedConnection
& ) =
delete
;
56
QgsScopedConnection
&
operator=
(
const
QgsScopedConnection
& ) =
delete
;
57
59
QgsScopedConnection
(
QgsScopedConnection
&&other ) noexcept
60
: mConnection( std::move( other.mConnection ) )
61
{
62
other.mConnection = QMetaObject::Connection();
63
}
64
65
QgsScopedConnection
&
operator=
(
QgsScopedConnection
&&other )
noexcept
66
{
67
if
(
this
!= &other )
68
{
69
disconnect
();
70
mConnection = std::move( other.mConnection );
71
other.mConnection = QMetaObject::Connection();
72
}
73
return
*
this
;
74
}
75
76
QgsScopedConnection
&
operator=
( QMetaObject::Connection connection )
77
{
78
disconnect
();
79
mConnection = std::move( connection );
80
return
*
this
;
81
}
82
86
void
disconnect
()
87
{
88
if
( mConnection )
89
{
90
QObject::disconnect( mConnection );
91
mConnection = QMetaObject::Connection();
92
}
93
}
94
95
private
:
96
QMetaObject::Connection mConnection;
97
};
98
99
#endif
// QGSSCOPEDCONNECTION_H
QgsScopedConnection::disconnect
void disconnect()
Manually disconnects the managed connection.
Definition
qgsscopedconnection.h:86
QgsScopedConnection::QgsScopedConnection
QgsScopedConnection()=default
Default constructor (holds an invalid connection).
QgsScopedConnection::operator=
QgsScopedConnection & operator=(QgsScopedConnection &&other) noexcept
Definition
qgsscopedconnection.h:65
QgsScopedConnection::operator=
QgsScopedConnection & operator=(const QgsScopedConnection &)=delete
QgsScopedConnection::operator=
QgsScopedConnection & operator=(QMetaObject::Connection connection)
Definition
qgsscopedconnection.h:76
QgsScopedConnection::QgsScopedConnection
QgsScopedConnection(QgsScopedConnection &&other) noexcept
Move constructor.
Definition
qgsscopedconnection.h:59
QgsScopedConnection::QgsScopedConnection
QgsScopedConnection(const QgsScopedConnection &)=delete
QgsScopedConnection::QgsScopedConnection
QgsScopedConnection(QMetaObject::Connection connection)
Constructor for QgsScopedConnection, managing the specified connection.
Definition
qgsscopedconnection.h:43
QgsScopedConnection::~QgsScopedConnection
~QgsScopedConnection()
Destructor for QgsScopedConnection.
Definition
qgsscopedconnection.h:52
Generated on
for QGIS API Documentation by
1.17.0