-
Notifications
You must be signed in to change notification settings - Fork 105
/
symbol_widget.h
136 lines (112 loc) · 3.47 KB
/
symbol_widget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* Copyright 2012, 2013 Thomas Schöps
* Copyright 2014 Kai Pastor
*
* This file is part of OpenOrienteering.
*
* OpenOrienteering is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenOrienteering is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenOrienteering. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPENORIENTEERING_SYMBOL_WIDGET_H
#define OPENORIENTEERING_SYMBOL_WIDGET_H
#include <QObject>
#include <QScrollArea>
class QContextMenuEvent;
class QWidget;
namespace OpenOrienteering {
class Map;
class Symbol;
class SymbolRenderWidget;
/**
* @brief Shows all symbols from a map in a scrollable widget.
*
* SymbolWidget shows all symbols from a map's symbol set.
* It lets the user select symbols and perform actions on symbols.
*
* The implementation is based on SymbolRenderWidget and QScrollArea.
* Normally it is used inside a dock widget.
*/
class SymbolWidget : public QScrollArea
{
Q_OBJECT
public:
/**
* @brief Constructs a new SymbolWidget.
* @param map The map which provides the symbols. Must not be nullptr.
* @param mobile_mode If true, enables a special mode for mobile devices.
* @param parent The parent QWidget.
*/
SymbolWidget(Map* map, bool mobile_mode, QWidget* parent = nullptr);
/**
* @brief Destroys the SymbolWidget.
*/
~SymbolWidget() override;
/**
* @brief If exactly one symbol is selected, returns this symbol.
*
* Otherwise returns nullptr.
*/
const Symbol* getSingleSelectedSymbol() const;
/**
* @brief If exactly one symbol is selected, returns this symbol.
*
* Otherwise returns nullptr.
*/
Symbol* getSingleSelectedSymbol();
/**
* @brief Returns the number of selected symbols.
*/
int selectedSymbolsCount() const;
/**
* @brief Checks if the symbol is selected.
*/
bool isSymbolSelected(const Symbol* symbol) const;
/**
* @brief Selects the symbol exclusively, deselecting all other symbols.
*/
void selectSingleSymbol(const Symbol* symbol);
signals:
/**
* @brief The collection of selected symbols changed.
*/
void selectedSymbolsChanged();
/**
* @brief The user triggered "Switch symbol".
* @todo Merge with/Reuse corresponding action in MapEditorController.
*/
void switchSymbolClicked();
/**
* @brief The user triggered "Fill/Create border".
* @todo Merge with/Reuse corresponding action in MapEditorController.
*/
void fillBorderClicked();
/**
* @brief The user triggered selecting objects with the active symbol.
* @param select_exclusively If true, an existing selection is replaced,
* otherwise it is extend.
*/
void selectObjectsClicked(bool select_exclusively);
/**
* @brief The user triggered deselecting objects with the active symbol.
*/
void deselectObjectsClicked();
protected:
/**
* @brief Receives context menu events and opens the context menu.
*/
void contextMenuEvent(QContextMenuEvent* event) override;
private:
SymbolRenderWidget* render_widget;
};
} // namespace OpenOrienteering
#endif