QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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 "moc_qgsprocessingfavoritealgorithmmanager.cpp"
18#include "qgssettingstree.h"
20
22
23const QgsSettingsEntryStringList *QgsProcessingFavoriteAlgorithmManager::settingsFavoriteAlgorithms = new QgsSettingsEntryStringList( QStringLiteral( "favorite-algorithms" ), QgsSettingsTree::sTreeProcessing, QStringList(), QObject::tr( "Favorite Processing algorithms" ) );
24
25QgsProcessingFavoriteAlgorithmManager::QgsProcessingFavoriteAlgorithmManager( QObject *parent )
26 : QObject( parent )
27{
28 mFavoriteAlgorithmIds = QgsProcessingFavoriteAlgorithmManager::settingsFavoriteAlgorithms->value();
29}
30
31QStringList QgsProcessingFavoriteAlgorithmManager::favoriteAlgorithmIds() const
32{
33 return mFavoriteAlgorithmIds;
34}
35
36void QgsProcessingFavoriteAlgorithmManager::add( const QString &id )
37{
38 if ( mFavoriteAlgorithmIds.contains( id ) )
39 {
40 return;
41 }
42
43 mFavoriteAlgorithmIds << id;
44 QgsProcessingFavoriteAlgorithmManager::settingsFavoriteAlgorithms->setValue( mFavoriteAlgorithmIds );
45 emit changed();
46}
47
48void QgsProcessingFavoriteAlgorithmManager::remove( const QString &id )
49{
50 if ( !mFavoriteAlgorithmIds.contains( id ) )
51 {
52 return;
53 }
54
55 mFavoriteAlgorithmIds.removeAll( id );
56 QgsProcessingFavoriteAlgorithmManager::settingsFavoriteAlgorithms->setValue( mFavoriteAlgorithmIds );
57 emit changed();
58}
59
60void QgsProcessingFavoriteAlgorithmManager::clear()
61{
62 mFavoriteAlgorithmIds.clear();
63 QgsProcessingFavoriteAlgorithmManager::settingsFavoriteAlgorithms->setValue( mFavoriteAlgorithmIds );
64 emit changed();
65}
66
67bool QgsProcessingFavoriteAlgorithmManager::isFavorite( const QString &id )
68{
69 return mFavoriteAlgorithmIds.contains( id );
70}
71
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