##// END OF EJS Templates
r162:723bff6bece1 merge
Show More
VariableController.cpp
59 lines | 1.7 KiB | text/x-c | CppLexer
/ core / src / Variable / VariableController.cpp
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 #include <Variable/VariableController.h>
Alexandre Leroux
Adds Variable model in the Variable controller
r113 #include <Variable/VariableModel.h>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111
#include <QMutex>
#include <QThread>
Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
struct VariableController::VariableControllerPrivate {
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r159 explicit VariableControllerPrivate(VariableController *parent)
: m_WorkingMutex{}, m_VariableModel{new VariableModel{parent}}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 {
}
QMutex m_WorkingMutex;
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r159 /// Variable model. The VariableController has the ownership
VariableModel *m_VariableModel;
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 };
VariableController::VariableController(QObject *parent)
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r159 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 {
Add the TimeWidget
r134 qCDebug(LOG_VariableController()) << tr("VariableController construction")
<< QThread::currentThread();
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 }
VariableController::~VariableController()
{
Add the TimeWidget
r134 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
<< QThread::currentThread();
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 this->waitForFinish();
}
Alexandre Leroux
Adds Variable model in the Variable controller
r113 Variable *VariableController::createVariable(const QString &name) noexcept
{
return impl->m_VariableModel->createVariable(name);
}
Alexandre Leroux
Affects model to the Variable Widget
r152 VariableModel *VariableController::variableModel() noexcept
{
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r159 return impl->m_VariableModel;
Alexandre Leroux
Affects model to the Variable Widget
r152 }
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 void VariableController::initialize()
{
qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
impl->m_WorkingMutex.lock();
qCDebug(LOG_VariableController()) << tr("VariableController init END");
}
void VariableController::finalize()
{
impl->m_WorkingMutex.unlock();
}
void VariableController::waitForFinish()
{
QMutexLocker locker{&impl->m_WorkingMutex};
}