/
qgsaggregatetoolbutton.h
98 lines (80 loc) · 2.73 KB
/
qgsaggregatetoolbutton.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
/***************************************************************************
qgsaggregatetoolbutton.h
--------------------------------------
Date : Nov 2017
Copyright : (C) 2017 Matthias Kuhn
Email : matthias@opengis.ch
***************************************************************************
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSAGGREGATETOOLBUTTON_H
#define QGSAGGREGATETOOLBUTTON_H
#include <QToolButton>
#include <QVariant>
#include "qgsaggregatecalculator.h"
#include "qgis_gui.h"
/**
* \ingroup gui
*
* Offers a toolbutton to choose between different aggregate functions.
* Functions are filtered based on the type.
*
* \since QGIS 3.0
*/
class GUI_EXPORT QgsAggregateToolButton : public QToolButton
{
Q_OBJECT
public:
/**
* Constructor
*/
QgsAggregateToolButton();
/**
* Based on the \a type of underlying data, some aggregates will be available or not.
*/
void setType( QVariant::Type type );
/**
* Based on the \a type of underlying data, some aggregates will be available or not.
*/
QVariant::Type type() const;
/**
* When this flag is false, the aggregate will be deactivated. I.e. no aggregate is chosen.
*/
void setActive( bool active );
/**
* When this flag is false, the aggregate will be deactivated. I.e. no aggregate is chosen.
*/
bool active() const;
/**
* The function name of the selected aggregate or a Null String if none is chosen.
*/
QString aggregate() const;
/**
* The function name of the selected aggregate or a Null String if none is chosen.
*/
void setAggregate( const QString &aggregate );
signals:
/**
* The function name of the selected aggregate has changed.
*/
void aggregateChanged();
/**
* A function has been selected or deselected.
*/
void activeChanged();
private slots:
void aboutToShowMenu();
private:
void updateAvailableAggregates();
QMenu *mMenu = nullptr;
QVariant::Type mType = QVariant::Invalid;
bool mActive = false;
QString mAggregate;
QList<QgsAggregateCalculator::AggregateInfo> mAvailableAggregates;
};
#endif // QGSAGGREGATETOOLBUTTON_H