cut 3.3.0
Loading...
Searching...
No Matches
QeStateDetailed.hpp
1#ifndef QESTATEDETAILED_HPP
2#define QESTATEDETAILED_HPP
3
4#include <QWidget>
5#include <QColor>
6#include <QSize>
7#include <QString>
8#include <QStringList>
9
22class QeStateDetailed : public QWidget
23{
24 Q_OBJECT
25
30 Q_PROPERTY(QString stateString READ getStateString WRITE setStateString NOTIFY stateStringChanged)
31
32
36 Q_PROPERTY(QString state READ getState NOTIFY stateChanged)
37
43
48 Q_PROPERTY(QStringList subStates READ getSubStates NOTIFY subStatesChanged)
49
55
60 Q_PROPERTY(QString substateSep READ getSubstateSep WRITE setSubstateSep NOTIFY substateSepChanged)
61
66 Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
67
73
79
85
91
97
102 Q_PROPERTY(QString offWords READ getOffWords WRITE setOffWords NOTIFY offWordsChanged)
103
108 Q_PROPERTY(bool popupMode READ getPopupMode WRITE setPopupMode NOTIFY popupModeChanged)
109
110
111public:
116 explicit QeStateDetailed(QWidget *parent = nullptr);
117
123 QString getStateString(){ return m_stateString; };
124
130 QString getState(){ return m_state; };
131
137 QStringList getOrthogonalStates(){ return m_orthogonalStates; };
138
144 QString getOrthogonalSep(){ return m_orthogonalSep; };
145
151 QString getSubstateSep(){ return m_substateSep; };
152
158 QStringList getSubStates() const{ return m_subStates; }
159
165 int spacing() const { return m_spacing; }
166
172 QString getPositiveWords() const {return m_positiveWords; }
173
179 QString getWarningWords() const { return m_warningWords; }
180
186 QString getNegativeWords() const { return m_negativeWords; }
187
193 QString getNeutralWords() const { return m_neutralWords; }
194
200 QString getOffWords() const { return m_offWords;}
201
207 QString getInitialisingWords() const { return m_initialisingWords; }
208
213 bool getPopupMode() const { return m_popupMode; }
214
215signals:
219 void stateStringChanged(QString newValue);
220
224 void stateChanged(QString newValue);
225
229 void orthogonalStatesChanged(QStringList newValue);
230
234 void orthogonalSepChanged(QString newValue);
235
239 void substateSepChanged(QString newValue);
240
244 void subStatesChanged(QStringList subStates);
245
250
255
260
265
270
275
281
282public slots:
290 void setStateString(QString newValue);
291
297 void setOrthogonalSep(QString newValue){ this->m_orthogonalSep = newValue; emit orthogonalSepChanged(newValue); processStateString(); this->update(); };
298
304 void setSubstateSep (QString newValue){ this->m_substateSep = newValue; emit substateSepChanged(newValue); processStateString(); this->update(); };
305
312 {
313 if (m_spacing == spacing)
314 return;
315
316 m_spacing = spacing;
317 update();
318 }
319
326 {
327 if (m_positiveWords == positiveWords)
328 return;
329
330 m_positiveWords = positiveWords;
331 update();
332 emit positiveWordsChanged(m_positiveWords);
333 }
334
341 {
342 if (m_warningWords == warningWords)
343 return;
344
345 m_warningWords = warningWords;
346 update();
347 emit warningWordsChanged(m_warningWords);
348 }
349
356 {
357 if (m_negativeWords == negativeWords)
358 return;
359
360 m_negativeWords = negativeWords;
361 update();
362 emit negativeWordsChanged(m_negativeWords);
363 }
364
371 {
372 if (m_neutralWords == neutralWords)
373 return;
374
375 m_neutralWords = neutralWords;
376 update();
377 emit neutralWordsChanged(m_neutralWords);
378 }
379
385 void setOffWords(QString offWords)
386 {
387 if (m_offWords == offWords)
388 return;
389
390 m_offWords = offWords;
391 update();
392 emit offWordsChanged(m_offWords);
393 }
394
401 {
402 if (m_initialisingWords == initialisingWords)
403 return;
404
405 m_initialisingWords = initialisingWords;
406 update();
407 emit initialisingWordsChanged(m_initialisingWords);
408 }
409
416 {
417 if (m_popupMode == popupMode)
418 return;
419
420 m_popupMode = popupMode;
421 emit popupModeChanged(m_popupMode);
422 }
423
424protected:
425 void paintEvent(QPaintEvent *event) override;
426 void mousePressEvent(QMouseEvent *event) override;
427 void focusOutEvent(QFocusEvent * 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 QString m_stateString = {};
437 QString m_state ={};
438 QStringList m_orthogonalStates = {};
439 QString m_orthogonalSep = ";";
440 QString m_substateSep = ":";
441
442 QColor positive = QColor("#3C7A0C");
443 QColor neutral = QColor("#095AD3");
444 QColor negative = QColor("#FF3317");
445 QColor viewBackgroundAlternate = QColor("#F2F2F2");
446 QColor warning = QColor("#FF8E26");
447
448 QStringList m_subStates;
449 bool m_showAll = true;
450 bool m_autoCompact = false;
451 int m_spacing = 6;
452 QString m_positiveWords = "idle goingrunning goingidle updateidle";
453 QString m_warningWords = "recovering";
454 QString m_negativeWords = "error";
455 QString m_neutralWords = "running updating";
456 QString m_offWords = "off";
457 QString m_initialisingWords = "initialising starting notready ready enabling disabling";
458 bool m_popupMode = false;
459};
460
461#endif // QESTATEDETAILED_HPP
QString stateString
Communicates the widget of the string that contains the state information.
Definition QeStateDetailed.hpp:30
QString getWarningWords() const
Gets the list of warning words.
Definition QeStateDetailed.hpp:179
void setSubstateSep(QString newValue)
Defines which separator is to be used between Substates.
Definition QeStateDetailed.hpp:304
int spacing
Separation in pixels between one state and the next.
Definition QeStateDetailed.hpp:66
QString getOffWords() const
Gets the list of off words.
Definition QeStateDetailed.hpp:200
void popupModeChanged(bool popupMode)
Indicates when the popupMode has changed.
void initialisingWordsChanged(QString initialisingWords)
Indicates a change in the initialisingWords property.
bool popupMode
Identifies this widget as a popup to a particular QeState.
Definition QeStateDetailed.hpp:108
QString neutralWords
Words considered for Neutral color (normally blue), space separated.
Definition QeStateDetailed.hpp:96
QString getNegativeWords() const
Gets the list of negative words.
Definition QeStateDetailed.hpp:186
QString getNeutralWords() const
Gets the list of neutral words.
Definition QeStateDetailed.hpp:193
QString state
Read-only property that contains the state of the component/application after interpretation of the s...
Definition QeStateDetailed.hpp:36
void orthogonalSepChanged(QString newValue)
Indicates a change in the orthogonal separator property.
void setNegativeWords(QString negativeWords)
Sets the negative words property.
Definition QeStateDetailed.hpp:355
QString initialisingWords
Words considered for Initialising color (normally yellow), space separated.
Definition QeStateDetailed.hpp:72
void subStatesChanged(QStringList subStates)
Indicates a change in the substates property.
void setStateString(QString newValue)
Main setter of the QeState widget.
Definition QeStateDetailed.cpp:15
void setPopupMode(bool popupMode)
Sets the operation mode for the widget.
Definition QeStateDetailed.hpp:415
void warningWordsChanged(QString warningWords)
Indicates a change in the warningWords property.
QString getState()
Returns the parsed state.
Definition QeStateDetailed.hpp:130
void neutralWordsChanged(QString neutralWords)
Indicates a change in the neutralWords property.
void substateSepChanged(QString newValue)
Indicates a change in the substate separator property.
void setNeutralWords(QString neutralWords)
Sets the neutral words property.
Definition QeStateDetailed.hpp:370
QString negativeWords
Words considered for Negative color (normally red), space separated.
Definition QeStateDetailed.hpp:90
void orthogonalStatesChanged(QStringList newValue)
Indicates a change in the orthogonalStates property.
void setPositiveWords(QString positiveWords)
Sets the positve words property.
Definition QeStateDetailed.hpp:325
QString getPositiveWords() const
Gets the list of positive words.
Definition QeStateDetailed.hpp:172
void setOrthogonalSep(QString newValue)
Defines which separator is to be used between Orthogonal regions.
Definition QeStateDetailed.hpp:297
void positiveWordsChanged(QString positiveWords)
Indicates a change in the positiveWords property.
QString offWords
Words considered for Off color (normally grey), space separated.
Definition QeStateDetailed.hpp:102
void offWordsChanged(QString offWords)
Indicates a change in the offWords property.
void setInitialisingWords(QString initialisingWords)
Sets the initialising words property.
Definition QeStateDetailed.hpp:400
void stateChanged(QString newValue)
Indicates a change in the state property.
QStringList getSubStates() const
Returns list of parsed sub states.
Definition QeStateDetailed.hpp:158
QStringList orthogonalStates
Orthogonal regions states, in a list.
Definition QeStateDetailed.hpp:42
void setOffWords(QString offWords)
Sets the off words property.
Definition QeStateDetailed.hpp:385
QString warningWords
Words considered for Warning color (normally orange), space separated.
Definition QeStateDetailed.hpp:84
QStringList getOrthogonalStates()
Returns a list of strings that contains the separated orthogonal state.
Definition QeStateDetailed.hpp:137
QStringList subStates
Substates in a list.
Definition QeStateDetailed.hpp:48
QString positiveWords
Words considered for Positive color (normally green), space separated.
Definition QeStateDetailed.hpp:78
QString getInitialisingWords() const
Gets the list of initialiasing words.
Definition QeStateDetailed.hpp:207
void setSpacing(int spacing)
Sets the spacing property.
Definition QeStateDetailed.hpp:311
bool getPopupMode() const
Returns if this instance of the widget is acting as a popup.
Definition QeStateDetailed.hpp:213
void negativeWordsChanged(QString negativeWords)
Indicates a change in the negativeWords property.
void setWarningWords(QString warningWords)
Sets the warning words property.
Definition QeStateDetailed.hpp:340
int spacing() const
Returns the ammount of pixels left as spacing between states.
Definition QeStateDetailed.hpp:165
QString orthogonalSep
Orthogonal Regions separator.
Definition QeStateDetailed.hpp:54
QString getSubstateSep()
Returns the separator used to parse between States whithin an orthogonal region.
Definition QeStateDetailed.hpp:151
QString getStateString()
Gets the stateString property.
Definition QeStateDetailed.hpp:123
QeStateDetailed(QWidget *parent=nullptr)
Constructor for the QeStateDetailed class.
Definition QeStateDetailed.cpp:11
QString substateSep
Substates separator.
Definition QeStateDetailed.hpp:60
QString getOrthogonalSep()
Returns the separator used to parse between Orthogonal regions.
Definition QeStateDetailed.hpp:144
void stateStringChanged(QString newValue)
Indicates a change in the stateString property.