cut 3.3.0
Loading...
Searching...
No Matches
QeState.hpp
1#ifndef QESTATE_HPP
2#define QESTATE_HPP
3
4#include "QeStateDetailed.hpp"
5#include <QWidget>
6#include <QColor>
7#include <QSize>
8#include <QString>
9#include <QStringList>
10
23class QeState : public QWidget
24{
25 Q_OBJECT
26
31 Q_PROPERTY(QString stateString READ getStateString WRITE setStateString NOTIFY stateStringChanged)
32
33
37 Q_PROPERTY(QString state READ getState NOTIFY stateChanged)
38
44
49 Q_PROPERTY(QStringList subStates READ getSubStates NOTIFY subStatesChanged)
50
56
61 Q_PROPERTY(QString substateSep READ getSubstateSep WRITE setSubstateSep NOTIFY substateSepChanged)
62
67 Q_PROPERTY(bool showAll READ showsAll WRITE setShowAll NOTIFY showAllChanged)
68
74
79 Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
80
86
92
98
104
110
115 Q_PROPERTY(QString offWords READ getOffWords WRITE setOffWords NOTIFY offWordsChanged)
116
122
123
124public:
129 explicit QeState(QWidget *parent = nullptr);
130
136 QString getStateString(){ return m_stateString; };
137
143 QString getState(){ return m_state; };
144
150 QStringList getOrthogonalStates(){ return m_orthogonalStates; };
151
157 QString getOrthogonalSep(){ return m_orthogonalSep; };
158
164 QString getSubstateSep(){ return m_substateSep; };
165
171 QStringList getSubStates() const{ return m_subStates; }
172
178 bool showsAll() const { return m_showAll; }
179
186 bool isAutoCompacting() const { return m_autoCompact; }
187
193 int spacing() const { return m_spacing; }
194
200 QString getPositiveWords() const {return m_positiveWords; }
201
207 QString getWarningWords() const { return m_warningWords; }
208
214 QString getNegativeWords() const { return m_negativeWords; }
215
221 QString getNeutralWords() const { return m_neutralWords; }
222
228 QString getOffWords() const { return m_offWords;}
229
235 QString getInitialisingWords() const { return m_initialisingWords; }
236
242 int getShowOnlyIndex() const { return m_showOnlyIndex; }
243
244signals:
248 void stateStringChanged(QString newValue);
249
253 void stateChanged(QString newValue);
254
258 void orthogonalStatesChanged(QStringList newValue);
259
263 void orthogonalSepChanged(QString newValue);
264
268 void substateSepChanged(QString newValue);
269
273 void subStatesChanged(QStringList subStates);
274
279
284
289
294
299
304
309
314
318 void clicked();
319
325
326public slots:
334 void setStateString(QString newValue);
335
341 void setOrthogonalSep(QString newValue);
342
348 void setSubstateSep (QString newValue);
349
356 void setShowAll(bool showAll);
357
363 void setAutoCompact(bool autoCompact);
364
370 void setSpacing(int spacing);
371
377 void setPositiveWords(QString positiveWords);
378
384 void setWarningWords(QString warningWords);
385
391 void setNegativeWords(QString negativeWords);
392
398 void setNeutralWords(QString neutralWords);
399
405 void setOffWords(QString offWords);
406
413
420
421protected:
422 void paintEvent(QPaintEvent *event) override;
423 void resizeEvent(QResizeEvent *event) override;
424 void moveEvent(QMoveEvent *event) override;
425 void mousePressEvent(QMouseEvent *event) override;
426 QSize sizeHint() const override;
427
428private:
429 void processStateString();
430 const QColor fillColorForState(const QString& state);
431 QString lastSubState(QString compositeState);
432 QString compactString(QString oldState);
433 QColor foregroundFromBackgroundColor(QColor fgColor);
434 void adjustPopup();
435 QString m_stateString = {""};
436 QString m_state ={""};
437 QStringList m_orthogonalStates = {};
438 QString m_orthogonalSep = {";"};
439 QString m_substateSep = {":"};
440
441 QColor positive = QColor("#3C7A0C");
442 QColor neutral = QColor("#095AD3");
443 QColor negative = QColor("#FF3317");
444 QColor viewBackgroundAlternate = QColor("#F2F2F2");
445 QColor warning = QColor("#FF8E26");
446
447 QStringList m_subStates = {};
448 bool m_showAll = false;
449 bool m_autoCompact = false;
450 int m_spacing = 6;
451 QString m_positiveWords = "idle goingrunning goingidle updateidle";
452 QString m_warningWords = "recovering";
453 QString m_negativeWords = "error";
454 QString m_neutralWords = "running updating";
455 QString m_offWords = "off";
456 QString m_initialisingWords = "initialising starting notready ready enabling disabling";
457 QeStateDetailed* m_popup;
458 int m_showOnlyIndex = -1;
459};
460
461#endif // QESTATE_HPP
void substateSepChanged(QString newValue)
Indicates a change in the substate separator property.
QString positiveWords
Words considered for Positive color (normally green), space separated.
Definition QeState.hpp:91
int spacing() const
Returns the ammount of pixels left as spacing between states.
Definition QeState.hpp:193
QString substateSep
Substates separator.
Definition QeState.hpp:61
void stateStringChanged(QString newValue)
Indicates a change in the stateString property.
void positiveWordsChanged(QString positiveWords)
Indicates a change in the positiveWords property.
QString getInitialisingWords() const
Gets the list of initialiasing words.
Definition QeState.hpp:235
bool showsAll() const
Indicates when the widget shows all orthogonal regions instead of just one.
Definition QeState.hpp:178
void initialisingWordsChanged(QString initialisingWords)
Indicates a change in the initialisingWords property.
QString orthogonalSep
Orthogonal Regions separator.
Definition QeState.hpp:55
QString getNegativeWords() const
Gets the list of negative words.
Definition QeState.hpp:214
QString getState()
Returns the parsed state.
Definition QeState.hpp:143
void offWordsChanged(QString offWords)
Indicates a change in the offWords property.
void setShowOnlyIndex(int showOnlyIndex)
Sets the showOnlyIndex property.
Definition QeState.cpp:138
QString getSubstateSep()
Returns the separator used to parse between States whithin an orthogonal region.
Definition QeState.hpp:164
QString offWords
Words considered for Off color (normally grey), space separated.
Definition QeState.hpp:115
void neutralWordsChanged(QString neutralWords)
Indicates a change in the neutralWords property.
QString getOrthogonalSep()
Returns the separator used to parse between Orthogonal regions.
Definition QeState.hpp:157
void setInitialisingWords(QString initialisingWords)
Sets the initialising words property.
Definition QeState.cpp:128
void orthogonalSepChanged(QString newValue)
Indicates a change in the orthogonal separator property.
void warningWordsChanged(QString warningWords)
Indicates a change in the warningWords property.
void subStatesChanged(QStringList subStates)
Indicates a change in the substates property.
void setShowAll(bool showAll)
When true configures the widget to show the complete Substates string.
Definition QeState.cpp:50
void setOrthogonalSep(QString newValue)
Defines which separator is to be used between Orthogonal regions.
Definition QeState.cpp:34
void orthogonalStatesChanged(QStringList newValue)
Indicates a change in the orthogonalStates property.
QStringList orthogonalStates
Orthogonal regions states, in a list.
Definition QeState.hpp:43
bool isAutoCompacting() const
Indicates if the widget is set to automatically summarize states is horizontal space is not enough.
Definition QeState.hpp:186
QStringList subStates
Substates in a list.
Definition QeState.hpp:49
int spacing
Separation in pixels between one state and the next.
Definition QeState.hpp:79
void setAutoCompact(bool autoCompact)
Sets the autoCompact property.
Definition QeState.cpp:59
QString neutralWords
Words considered for Neutral color (normally blue), space separated.
Definition QeState.hpp:109
QString getStateString()
Gets the stateString property.
Definition QeState.hpp:136
bool showAll
Shows states and substates for first region.
Definition QeState.hpp:67
QString negativeWords
Words considered for Negative color (normally red), space separated.
Definition QeState.hpp:103
QString getPositiveWords() const
Gets the list of positive words.
Definition QeState.hpp:200
void setOffWords(QString offWords)
Sets the off words property.
Definition QeState.cpp:118
QString getWarningWords() const
Gets the list of warning words.
Definition QeState.hpp:207
int showOnlyIndex
Shows only the state for the orthogonal region in the index N.
Definition QeState.hpp:121
QString state
Read-only property that contains the state of the component/application after interpretation of the s...
Definition QeState.hpp:37
void clicked()
Emitted when a mouse click is done in the widget.
QString initialisingWords
Words considered for Initialising color (normally yellow), space separated.
Definition QeState.hpp:85
QString getNeutralWords() const
Gets the list of neutral words.
Definition QeState.hpp:221
void setWarningWords(QString warningWords)
Sets the warning words property.
Definition QeState.cpp:88
QString getOffWords() const
Gets the list of off words.
Definition QeState.hpp:228
void setStateString(QString newValue)
Main setter of the QeState widget.
Definition QeState.cpp:21
void negativeWordsChanged(QString negativeWords)
Indicates a change in the negativeWords property.
void setSpacing(int spacing)
Sets the spacing property.
Definition QeState.cpp:68
void setPositiveWords(QString positiveWords)
Sets the positve words property.
Definition QeState.cpp:77
void setNeutralWords(QString neutralWords)
Sets the neutral words property.
Definition QeState.cpp:108
void autoCompactChanged(bool autoCompact)
Indicates a change in the autoCompact property.
QString warningWords
Words considered for Warning color (normally orange), space separated.
Definition QeState.hpp:97
QeState(QWidget *parent=nullptr)
Constructor for the QeState class.
Definition QeState.cpp:13
void showOnlyIndexChanged(int showOnlyIndex)
Signal emitted when the showOnlyIndex property changes.
void showAllChanged(bool showAll)
Indicates a change in the showAll property.
void setNegativeWords(QString negativeWords)
Sets the negative words property.
Definition QeState.cpp:98
void stateChanged(QString newValue)
Indicates a change in the state property.
QStringList getOrthogonalStates()
Returns a list of strings that contains the separated orthogonal state.
Definition QeState.hpp:150
int getShowOnlyIndex() const
Gets the currently shown orthogonal region index.
Definition QeState.hpp:242
QString stateString
Communicates the widget of the string that contains the state information.
Definition QeState.hpp:31
QStringList getSubStates() const
Returns list of parsed sub states.
Definition QeState.hpp:171
bool autoCompact
Automatically compact representation to Initials when no space is available.
Definition QeState.hpp:73
void setSubstateSep(QString newValue)
Defines which separator is to be used between Substates.
Definition QeState.cpp:42