Qx v0.5.8
Qt Extensions Library
Loading...
Searching...
No Matches
qx-progressgroup.h
1#ifndef QX_PROGRESSGROUP_H
2#define QX_PROGRESSGROUP_H
3
4// Shared Lib Support
5#include "qx/core/qx_core_export.h"
6
7// Qt Includes
8#include <QObject>
9#include <QString>
10#include <QProperty>
11
12namespace Qx
13{
14
15class QX_CORE_EXPORT ProgressGroup : public QObject
16{
17//-QObject Macro (Required for all QObject Derived Classes)-----------------------------------------------------------
18 Q_OBJECT
19
20//-Instance Properties-------------------------------------------------------------------------------------------------------
21private:
22 Q_PROPERTY(QString name READ name CONSTANT);
23 Q_PROPERTY(quint64 value READ value WRITE setValue NOTIFY valueChanged);
24 Q_PROPERTY(quint64 maximum READ maximum WRITE setMaximum NOTIFY maximumChanged);
25 Q_PROPERTY(quint64 weight READ weight WRITE setWeight NOTIFY weightChanged);
26 Q_PROPERTY(quint64 proportionComplete READ proportionComplete NOTIFY proportionCompleteChanged);
27
28//-Instance Members------------------------------------------------------------------------------------------
29private:
30 /* For mProportion, could just use an update function that is either called directly in settings, or connect the
31 * changed signals to the update function, but felt like trying out QProperty (Qt Bindable Properties) here. The
32 * reason it's not a QObjectBindableProperty is because in this case we only want the internal member variable to
33 * be bindable, and not the exposed Q_PROPERTY (yes the naming they chose is confusing). From the outside, it should
34 * still look like a normal variable.
35 */
36 QString mName;
37 QProperty<quint64> mValue;
38 QProperty<quint64> mMaximum;
39 quint64 mWeight;
40 QProperty<double> mProportion; // Pre-calculated and stored to save cycles in GroupedProgressManager
41 QPropertyNotifier mProportionNotifier; // Have to store this or else the assigned notify functor will be removed
42
43//-Constructor----------------------------------------------------------------------------------------------
44public:
45 explicit ProgressGroup(QString name, QObject* parent = nullptr);
46
47//-Instance Functions----------------------------------------------------------------------------------------------
48public:
49 QString name() const;
50 quint64 value() const;
51 quint64 maximum() const;
52 quint64 weight() const;
53 double proportionComplete() const;
54
55 void incrementValue();
56 void decrementValue();
57 void incrementMaximum();
58 void decrementMaximum();
59 void increaseValue(quint64 amount);
60 void decreaseValue(quint64 amount);
61 void increaseMaximum(quint64 amount);
62 void decreaseMaximum(quint64 amount);
63
64//-Slots------------------------------------------------------------------------------------------------------------
65public slots:
66 void reset();
67 void setValue(quint64 value);
68 void setMaximum(quint64 maximum);
69 void setWeight(quint64 weight);
70
71//-Signals------------------------------------------------------------------------------------------------------------
72signals:
73 void valueChanged(quint64 value);
74 void maximumChanged(quint64 maximum);
75 void weightChanged(quint64 weight);
76 void proportionCompleteChanged(double proportion);
77};
78
79}
80
81#endif // QX_PROGRESSGROUP_H
The ProgressGroup class represents a distinct portion of overall progress to be mediated by GroupedPr...
Definition qx-progressgroup.h:16
void valueChanged(quint64 value)
void proportionCompleteChanged(double proportion)
void maximumChanged(quint64 maximum)
void weightChanged(quint64 weight)
The Qx namespace is the main namespace through which all non-global functionality of the Qx library i...
Definition qx-processwaiter.cpp:5