cut 3.4.6
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 <QPointer>
8#include <QSize>
9#include <QString>
10#include <QStringList>
11
24class QeState : public QWidget
25{
26 Q_OBJECT
27
32 Q_PROPERTY(QString stateString READ getStateString WRITE setStateString NOTIFY stateStringChanged)
33
34
38 Q_PROPERTY(QString state READ getState NOTIFY stateChanged)
39
45
50 Q_PROPERTY(QStringList subStates READ getSubStates NOTIFY subStatesChanged)
51
57
62 Q_PROPERTY(QString substateSep READ getSubstateSep WRITE setSubstateSep NOTIFY substateSepChanged)
63
68 Q_PROPERTY(bool showAll READ showsAll WRITE setShowAll NOTIFY showAllChanged)
69
75
80 Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
81
87
93
99
105
111
116 Q_PROPERTY(QString offWords READ getOffWords WRITE setOffWords NOTIFY offWordsChanged)
117
123
124
125public:
130 explicit QeState(QWidget *parent = nullptr);
131 ~QeState() override;
132
138 QString getStateString(){ return m_stateString; };
139
145 QString getState(){ return m_state; };
146
152 QStringList getOrthogonalStates(){ return m_orthogonalStates; };
153
159 QString getOrthogonalSep(){ return m_orthogonalSep; };
160
166 QString getSubstateSep(){ return m_substateSep; };
167
173 QStringList getSubStates() const{ return m_subStates; }
174
180 bool showsAll() const { return m_showAll; }
181
188 bool isAutoCompacting() const { return m_autoCompact; }
189
195 int spacing() const { return m_spacing; }
196
202 QString getPositiveWords() const {return m_positiveWords; }
203
209 QString getWarningWords() const { return m_warningWords; }
210
216 QString getNegativeWords() const { return m_negativeWords; }
217
223 QString getNeutralWords() const { return m_neutralWords; }
224
230 QString getOffWords() const { return m_offWords;}
231
237 QString getInitialisingWords() const { return m_initialisingWords; }
238
244 int getShowOnlyIndex() const { return m_showOnlyIndex; }
245
246signals:
250 void stateStringChanged(QString newValue);
251
255 void stateChanged(QString newValue);
256
260 void orthogonalStatesChanged(QStringList newValue);
261
265 void orthogonalSepChanged(QString newValue);
266
270 void substateSepChanged(QString newValue);
271
275 void subStatesChanged(QStringList subStates);
276
281
286
291
296
301
306
311
316
320 void clicked();
321
327
328public slots:
336 void setStateString(QString newValue);
337
343 void setOrthogonalSep(QString newValue);
344
350 void setSubstateSep (QString newValue);
351
358 void setShowAll(bool showAll);
359
365 void setAutoCompact(bool autoCompact);
366
372 void setSpacing(int spacing);
373
379 void setPositiveWords(QString positiveWords);
380
386 void setWarningWords(QString warningWords);
387
393 void setNegativeWords(QString negativeWords);
394
400 void setNeutralWords(QString neutralWords);
401
407 void setOffWords(QString offWords);
408
415
422
423protected:
424 void paintEvent(QPaintEvent *event) override;
425 void resizeEvent(QResizeEvent *event) override;
426 void moveEvent(QMoveEvent *event) override;
427 void mousePressEvent(QMouseEvent *event) override;
428 QSize sizeHint() const override;
429
430private:
431 void processStateString();
432 const QColor fillColorForState(const QString& state);
433 QString lastSubState(QString compositeState);
434 QString compactString(QString oldState);
435 QColor foregroundFromBackgroundColor(QColor fgColor);
436 void adjustPopup();
437 QString m_stateString = {""};
438 QString m_state ={""};
439 QStringList m_orthogonalStates = {};
440 QString m_orthogonalSep = {";"};
441 QString m_substateSep = {":"};
442
443 QColor positive = QColor("#3C7A0C");
444 QColor neutral = QColor("#095AD3");
445 QColor negative = QColor("#FF3317");
446 QColor viewBackgroundAlternate = QColor("#F2F2F2");
447 QColor warning = QColor("#FF8E26");
448
449 QStringList m_subStates = {};
450 bool m_showAll = false;
451 bool m_autoCompact = false;
452 int m_spacing = 6;
453 QString m_positiveWords = "idle goingrunning goingidle updateidle";
454 QString m_warningWords = "recovering";
455 QString m_negativeWords = "error";
456 QString m_neutralWords = "running updating";
457 QString m_offWords = "off";
458 QString m_initialisingWords = "initialising starting notready ready enabling disabling";
459 QPointer<QeStateDetailed> m_popup;
460 int m_showOnlyIndex = -1;
461};
462
463#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:92
int spacing() const
Returns the ammount of pixels left as spacing between states.
Definition QeState.hpp:195
QString substateSep
Substates separator.
Definition QeState.hpp:62
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:237
bool showsAll() const
Indicates when the widget shows all orthogonal regions instead of just one.
Definition QeState.hpp:180
void initialisingWordsChanged(QString initialisingWords)
Indicates a change in the initialisingWords property.
QString orthogonalSep
Orthogonal Regions separator.
Definition QeState.hpp:56
QString getNegativeWords() const
Gets the list of negative words.
Definition QeState.hpp:216
QString getState()
Returns the parsed state.
Definition QeState.hpp:145
void offWordsChanged(QString offWords)
Indicates a change in the offWords property.
void setShowOnlyIndex(int showOnlyIndex)
Sets the showOnlyIndex property.
Definition QeState.cpp:142
QString getSubstateSep()
Returns the separator used to parse between States whithin an orthogonal region.
Definition QeState.hpp:166
QString offWords
Words considered for Off color (normally grey), space separated.
Definition QeState.hpp:116
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:159
void setInitialisingWords(QString initialisingWords)
Sets the initialising words property.
Definition QeState.cpp:132
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:54
void setOrthogonalSep(QString newValue)
Defines which separator is to be used between Orthogonal regions.
Definition QeState.cpp:38
void orthogonalStatesChanged(QStringList newValue)
Indicates a change in the orthogonalStates property.
QStringList orthogonalStates
Orthogonal regions states, in a list.
Definition QeState.hpp:44
bool isAutoCompacting() const
Indicates if the widget is set to automatically summarize states is horizontal space is not enough.
Definition QeState.hpp:188
QStringList subStates
Substates in a list.
Definition QeState.hpp:50
int spacing
Separation in pixels between one state and the next.
Definition QeState.hpp:80
void setAutoCompact(bool autoCompact)
Sets the autoCompact property.
Definition QeState.cpp:63
QString neutralWords
Words considered for Neutral color (normally blue), space separated.
Definition QeState.hpp:110
QString getStateString()
Gets the stateString property.
Definition QeState.hpp:138
bool showAll
Shows states and substates for first region.
Definition QeState.hpp:68
QString negativeWords
Words considered for Negative color (normally red), space separated.
Definition QeState.hpp:104
QString getPositiveWords() const
Gets the list of positive words.
Definition QeState.hpp:202
void setOffWords(QString offWords)
Sets the off words property.
Definition QeState.cpp:122
QString getWarningWords() const
Gets the list of warning words.
Definition QeState.hpp:209
int showOnlyIndex
Shows only the state for the orthogonal region in the index N.
Definition QeState.hpp:122
QString state
Read-only property that contains the state of the component/application after interpretation of the s...
Definition QeState.hpp:38
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:86
QString getNeutralWords() const
Gets the list of neutral words.
Definition QeState.hpp:223
void setWarningWords(QString warningWords)
Sets the warning words property.
Definition QeState.cpp:92
QString getOffWords() const
Gets the list of off words.
Definition QeState.hpp:230
void setStateString(QString newValue)
Main setter of the QeState widget.
Definition QeState.cpp:25
void negativeWordsChanged(QString negativeWords)
Indicates a change in the negativeWords property.
void setSpacing(int spacing)
Sets the spacing property.
Definition QeState.cpp:72
void setPositiveWords(QString positiveWords)
Sets the positve words property.
Definition QeState.cpp:81
void setNeutralWords(QString neutralWords)
Sets the neutral words property.
Definition QeState.cpp:112
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:98
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:102
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:152
int getShowOnlyIndex() const
Gets the currently shown orthogonal region index.
Definition QeState.hpp:244
QString stateString
Communicates the widget of the string that contains the state information.
Definition QeState.hpp:32
QStringList getSubStates() const
Returns list of parsed sub states.
Definition QeState.hpp:173
bool autoCompact
Automatically compact representation to Initials when no space is available.
Definition QeState.hpp:74
void setSubstateSep(QString newValue)
Defines which separator is to be used between Substates.
Definition QeState.cpp:46