-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#47: Created header and cpp file which contain qproperties of critica…
…l faults, non-critical faults, and microphone
- Loading branch information
1 parent
e9d5892
commit 4090d59
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "headercontroller.h" | ||
|
||
HeaderController::HeaderController(Model *model, QObject *parent) | ||
: QObject{parent}, m_numCriticalWarnings(0), m_numNonCriticalWarnings(0), | ||
m_isTalking(false) { | ||
this->m_model = model; | ||
connect(m_model, &Model::onCurrentDataChange, this, | ||
&HeaderController::currentDataDidChange); | ||
} | ||
|
||
int HeaderController::numCriticalWarnings() const { | ||
return m_numCriticalWarnings; | ||
} | ||
|
||
void HeaderController::setNumCriticalWarnings(int numCriticalWarnings) { | ||
if (m_numCriticalWarnings != numCriticalWarnings) { | ||
m_numCriticalWarnings = numCriticalWarnings; | ||
emit numCriticalWarningsChanged(numCriticalWarnings); | ||
} | ||
} | ||
|
||
int HeaderController::numNonCriticalWarnings() const { | ||
return m_numNonCriticalWarnings; | ||
} | ||
|
||
void HeaderController::setNumNonCriticalWarnings(int numNonCriticalWarnings) { | ||
if (m_numNonCriticalWarnings != numNonCriticalWarnings) { | ||
m_numNonCriticalWarnings = numNonCriticalWarnings; | ||
emit numCriticalWarningsChanged(numNonCriticalWarnings); | ||
} | ||
} | ||
|
||
bool HeaderController::isTalking() const { return m_isTalking; } | ||
|
||
void HeaderController::setIsTalking(bool isTalking) { | ||
if (m_isTalking != isTalking) { | ||
m_isTalking = isTalking; | ||
emit isTalkingChanged(isTalking); | ||
} | ||
} | ||
|
||
void HeaderController::currentDataDidChange() { | ||
setNumCriticalWarnings(*m_model->getNumCriticalWarnings()); | ||
setNumNonCriticalWarnings(*m_model->getNumNonCriticalWarnings()); | ||
setIsTalking(*m_model->getIsTalking()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef HEADERCONTROLLER_H | ||
#define HEADERCONTROLLER_H | ||
|
||
#include "../models/model.h" | ||
#include <QObject> | ||
|
||
/** | ||
* @brief The HeaderController class | ||
* Controller for the views. | ||
*/ | ||
class HeaderController : public QObject { | ||
Q_OBJECT | ||
Q_PROPERTY(int numCriticalWarnings READ numCriticalWarnings WRITE | ||
setNumCriticalWarnings NOTIFY numCriticalWarningsChanged FINAL) | ||
Q_PROPERTY( | ||
int numNonCriticalWarnings READ numNonCriticalWarnings WRITE | ||
setNumNonCriticalWarnings NOTIFY numNonCriticalWarningsChanged FINAL) | ||
Q_PROPERTY(bool isTalking READ isTalking WRITE setIsTalking NOTIFY | ||
isTalkingChanged FINAL) | ||
|
||
public: | ||
explicit HeaderController(Model *model, QObject *parent = nullptr); | ||
int numCriticalWarnings() const; | ||
int numNonCriticalWarnings() const; | ||
bool isTalking() const; | ||
|
||
signals: | ||
void numCriticalWarningsChanged(int); | ||
void numNonCriticalWarningsChanged(int); | ||
void isTalkingChanged(bool); | ||
|
||
public slots: | ||
void setNumCriticalWarnings(int); | ||
void setNumNonCriticalWarnings(int); | ||
void setIsTalking(bool); | ||
void currentDataDidChange(); | ||
|
||
private: | ||
Model *m_model; | ||
int m_numCriticalWarnings; | ||
int m_numNonCriticalWarnings; | ||
bool m_isTalking; | ||
}; | ||
|
||
#endif // HEADERCONTROLLER_H |