QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
processing
qgsprocessingrecentalgorithmlog.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsprocessingrecentalgorithmlog.cpp
3
------------------------------------
4
Date : July 2018
5
Copyright : (C) 2018 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
#include "
qgsprocessingrecentalgorithmlog.h
"
17
18
#include "
qgssettings.h
"
19
20
#include <QString>
21
22
#include "moc_qgsprocessingrecentalgorithmlog.cpp"
23
24
using namespace
Qt::StringLiterals;
25
27
28
const
int
MAX_LOG_LENGTH = 5;
29
30
QgsProcessingRecentAlgorithmLog::QgsProcessingRecentAlgorithmLog( QObject *parent )
31
: QObject( parent )
32
{
33
const
QgsSettings
settings;
34
mRecentAlgorithmIds = settings.
value
( u
"processing/recentAlgorithms"
_s, QVariant(),
QgsSettings::Gui
).toStringList();
35
}
36
37
QStringList QgsProcessingRecentAlgorithmLog::recentAlgorithmIds()
const
38
{
39
return
mRecentAlgorithmIds;
40
}
41
42
void
QgsProcessingRecentAlgorithmLog::push(
const
QString &
id
)
43
{
44
const
QStringList previous = mRecentAlgorithmIds;
45
mRecentAlgorithmIds.removeAll(
id
);
46
mRecentAlgorithmIds.insert( 0,
id
);
47
if
( mRecentAlgorithmIds.length() > MAX_LOG_LENGTH )
48
mRecentAlgorithmIds = mRecentAlgorithmIds.mid( 0, MAX_LOG_LENGTH );
49
50
QgsSettings
settings;
51
settings.
setValue
( u
"processing/recentAlgorithms"
_s, mRecentAlgorithmIds,
QgsSettings::Gui
);
52
53
if
( previous != mRecentAlgorithmIds )
54
emit changed();
55
}
56
QgsSettings
Stores settings for use within QGIS.
Definition
qgssettings.h:68
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition
qgssettings.cpp:169
QgsSettings::Gui
@ Gui
Definition
qgssettings.h:76
QgsSettings::setValue
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Definition
qgssettings.cpp:300
qgsprocessingrecentalgorithmlog.h
qgssettings.h
Generated on
for QGIS API Documentation by
1.17.0