QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgsprocessingfavoritealgorithmmanager.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingfavoritealgorithmmanager.cpp
3 ------------------------------------
4 Date : February 2024
5 Copyright : (C) 2024 Alexander Bruy
6 Email : alexander dot bruy 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
17#include "qgssettingstree.h"
19
21
22const QgsSettingsEntryStringList *QgsProcessingFavoriteAlgorithmManager::settingsFavoriteAlgorithms = new QgsSettingsEntryStringList( QStringLiteral( "favorite-algorithms" ), QgsSettingsTree::sTreeProcessing, QStringList(), QObject::tr( "Favorite Processing algorithms" ) );
23
24QgsProcessingFavoriteAlgorithmManager::QgsProcessingFavoriteAlgorithmManager( QObject *parent )
25 : QObject( parent )
26{
27 mFavoriteAlgorithmIds = QgsProcessingFavoriteAlgorithmManager::settingsFavoriteAlgorithms->value();
28}
29
30QStringList QgsProcessingFavoriteAlgorithmManager::favoriteAlgorithmIds() const
31{
32 return mFavoriteAlgorithmIds;
33}
34
35void QgsProcessingFavoriteAlgorithmManager::add( const QString &id )
36{
37 if ( mFavoriteAlgorithmIds.contains( id ) )
38 {
39 return;
40 }
41
42 mFavoriteAlgorithmIds << id;
43 QgsProcessingFavoriteAlgorithmManager::settingsFavoriteAlgorithms->setValue( mFavoriteAlgorithmIds );
44 emit changed();
45}
46
47void QgsProcessingFavoriteAlgorithmManager::remove( const QString &id )
48{
49 if ( !mFavoriteAlgorithmIds.contains( id ) )
50 {
51 return;
52 }
53
54 mFavoriteAlgorithmIds.removeAll( id );
55 QgsProcessingFavoriteAlgorithmManager::settingsFavoriteAlgorithms->setValue( mFavoriteAlgorithmIds );
56 emit changed();
57}
58
59void QgsProcessingFavoriteAlgorithmManager::clear()
60{
61 mFavoriteAlgorithmIds.clear();
62 QgsProcessingFavoriteAlgorithmManager::settingsFavoriteAlgorithms->setValue( mFavoriteAlgorithmIds );
63 emit changed();
64}
65
66bool QgsProcessingFavoriteAlgorithmManager::isFavorite( const QString &id )
67{
68 return mFavoriteAlgorithmIds.contains( id );
69}
70
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
A string list settings entry.
static QgsSettingsTreeNode * sTreeProcessing