QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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
52
54
75 void pushRecentSymbol( const QString &identifier, QgsSymbol *symbol SIP_TRANSFER );
76
85 QgsSymbol *recentSymbol( const QString &identifier ) const SIP_FACTORY;
86
94 template <class SymbolType> std::unique_ptr< SymbolType > recentSymbol( const QString &identifier ) const SIP_SKIP
95 {
96 std::unique_ptr< QgsSymbol > tmpSymbol( recentSymbol( identifier ) );
97 if ( SymbolType *symbolCastToType = dynamic_cast<SymbolType *>( tmpSymbol.get() ) )
98 {
99 return std::unique_ptr< SymbolType >( dynamic_cast<SymbolType *>( tmpSymbol.release() ) );
100 }
101 else
102 {
103 //could not cast
104 return nullptr;
105 }
106 }
107
108 private:
109
110#ifdef SIP_RUN
112#endif
113
114 std::unordered_map< QString, std::unique_ptr< QgsSymbol > > mRecentSymbols;
115
116};
117
118#endif // QGSRECENTSTYLEHANDLER_H
Handles and tracks style items recently used in the QGIS GUI.
QgsRecentStyleHandler(const QgsRecentStyleHandler &other)=delete
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
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76