QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsrecentstylehandler.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrecentstylehandler.h
3 ------------------------
4 begin : September 2021
5 copyright : (C) 2021 by 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#ifndef QGSRECENTSTYLEHANDLER_H
17#define QGSRECENTSTYLEHANDLER_H
18
19#include "qgis_sip.h"
20#include "qgis_core.h"
21#include "qgis.h"
22#include "qgssymbol.h"
23#include <unordered_map>
24#include <memory>
25
26class QgsSymbol;
27
38class CORE_EXPORT QgsRecentStyleHandler
39{
40 public:
41
49
54
56
77 void pushRecentSymbol( const QString &identifier, QgsSymbol *symbol SIP_TRANSFER );
78
87 QgsSymbol *recentSymbol( const QString &identifier ) const SIP_FACTORY;
88
96 template <class SymbolType> std::unique_ptr< SymbolType > recentSymbol( const QString &identifier ) const SIP_SKIP
97 {
98 std::unique_ptr< QgsSymbol > tmpSymbol( recentSymbol( identifier ) );
99 if ( SymbolType *symbolCastToType = dynamic_cast<SymbolType *>( tmpSymbol.get() ) )
100 {
101 return std::unique_ptr< SymbolType >( dynamic_cast<SymbolType *>( tmpSymbol.release() ) );
102 }
103 else
104 {
105 //could not cast
106 return nullptr;
107 }
108 }
109
110 private:
111
112#ifdef SIP_RUN
114#endif
115
116 std::unordered_map< QString, std::unique_ptr< QgsSymbol > > mRecentSymbols;
117
118};
119
120#endif // QGSRECENTSTYLEHANDLER_H
Handles and tracks style items recently used in the QGIS GUI.
QgsRecentStyleHandler(const QgsRecentStyleHandler &other)=delete
QgsRecentStyleHandler cannot be copied.
QgsRecentStyleHandler()
Creates a new recent style handler.
std::unique_ptr< SymbolType > recentSymbol(const QString &identifier) const
Returns a copy of the recently used symbol with the specified identifier, or nullptr if no symbol wit...
QgsRecentStyleHandler & operator=(const QgsRecentStyleHandler &other)=delete
QgsRecentStyleHandler cannot be copied.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:94
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76