QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgsfeedback.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsfeedback.h
3
--------------------------------------
4
Date : July 2016
5
Copyright : (C) 2016 by Martin Dobias
6
Email : wonder dot sk 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 QGSFEEDBACK_H
17
#define QGSFEEDBACK_H
18
19
#include "qgis_core.h"
20
#include "
qgis_sip.h
"
21
22
#include <QObject>
23
43
class
CORE_EXPORT
QgsFeedback
:
public
QObject
44
{
45
Q_OBJECT
46
public
:
48
QgsFeedback
( QObject *parent
SIP_TRANSFERTHIS
=
nullptr
)
49
: QObject( parent )
50
{}
51
52
~QgsFeedback
()
override
;
53
54
// clang-format off
56
bool
isCanceled
() const
SIP_HOLDGIL
{
return
mCanceled; }
57
// clang-format on
58
65
void
setProgress
(
double
progress
)
66
{
67
// avoid flooding with too many events
68
if
(
static_cast<
int
>
( mProgress * 10 ) !=
static_cast<
int
>
(
progress
* 10 ) )
69
emit
progressChanged
(
progress
);
70
71
mProgress =
progress
;
72
}
73
81
double
progress
() const
SIP_HOLDGIL
{
return
mProgress; }
82
91
unsigned
long
long
processedCount
() const
SIP_HOLDGIL
{
return
mProcessedCount; }
92
100
void
setProcessedCount
(
unsigned
long
long
processedCount
)
101
{
102
mProcessedCount =
processedCount
;
103
emit
processedCountChanged
(
processedCount
);
104
}
105
117
static
std::unique_ptr<QgsFeedback> createScaledFeedback(
118
QgsFeedback
*parentFeedback,
double
startPercentage,
double
endPercentage );
119
120
public
slots:
121
123
void
cancel
()
124
{
125
if
( mCanceled )
126
return
;
// only emit the signal once
127
mCanceled =
true
;
128
emit
canceled
();
129
}
130
131
signals:
133
void
canceled
();
134
142
void
progressChanged
(
double
progress
);
143
152
void
processedCountChanged
(
unsigned
long
long
processedCount
);
153
154
private
:
156
bool
mCanceled =
false
;
157
158
double
mProgress = 0.0;
159
unsigned
long
long
mProcessedCount = 0;
160
};
161
162
163
#endif
// QGSFEEDBACK_H
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition
qgsfeedback.h:44
QgsFeedback::isCanceled
bool isCanceled() const
Tells whether the operation has been canceled already.
Definition
qgsfeedback.h:56
QgsFeedback::setProcessedCount
void setProcessedCount(unsigned long long processedCount)
Sets the current processed objects count for the feedback object.
Definition
qgsfeedback.h:100
QgsFeedback::progressChanged
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
QgsFeedback::canceled
void canceled()
Internal routines can connect to this signal if they use event loop.
QgsFeedback::QgsFeedback
QgsFeedback(QObject *parent=nullptr)
Construct a feedback object.
Definition
qgsfeedback.h:48
QgsFeedback::processedCount
unsigned long long processedCount() const
Returns the current processed objects count reported by the feedback object.
Definition
qgsfeedback.h:91
QgsFeedback::processedCountChanged
void processedCountChanged(unsigned long long processedCount)
Emitted when the feedback object reports a change in the number of processed objects.
QgsFeedback::cancel
void cancel()
Tells the internal routines that the current operation should be canceled. This should be run by the ...
Definition
qgsfeedback.h:123
QgsFeedback::setProgress
void setProgress(double progress)
Sets the current progress for the feedback object.
Definition
qgsfeedback.h:65
QgsFeedback::progress
double progress() const
Returns the current progress reported by the feedback object.
Definition
qgsfeedback.h:81
QgsFeedback::~QgsFeedback
~QgsFeedback() override
qgis_sip.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
SIP_HOLDGIL
#define SIP_HOLDGIL
Definition
qgis_sip.h:183
Generated on
for QGIS API Documentation by
1.17.0