##// END OF EJS Templates
Adapts VariableModel to be a QabstractTableModel...
Adapts VariableModel to be a QabstractTableModel The mechanism proposed by Qt makes it easy to display the model in a QTableView

File last commit:

r126:5404c5d53512
r140:5bdc904b0565
Show More
VariableController.cpp
53 lines | 1.5 KiB | text/x-c | CppLexer
/ core / src / Variable / VariableController.cpp
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 #include <Variable/VariableController.h>
Alexandre Leroux
Adds Variable model in the Variable controller
r108 #include <Variable/VariableModel.h>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106
#include <QMutex>
#include <QThread>
Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
struct VariableController::VariableControllerPrivate {
explicit VariableControllerPrivate()
Alexandre Leroux
Adds Variable model in the Variable controller
r108 : m_WorkingMutex{}, m_VariableModel{std::make_unique<VariableModel>()}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 {
}
QMutex m_WorkingMutex;
Alexandre Leroux
Adds Variable model in the Variable controller
r108 std::unique_ptr<VariableModel> m_VariableModel;
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 };
VariableController::VariableController(QObject *parent)
: QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>()}
{
Add the TimeWidget
r126 qCDebug(LOG_VariableController()) << tr("VariableController construction")
<< QThread::currentThread();
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 }
VariableController::~VariableController()
{
Add the TimeWidget
r126 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
<< QThread::currentThread();
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 this->waitForFinish();
}
Alexandre Leroux
Adds Variable model in the Variable controller
r108 Variable *VariableController::createVariable(const QString &name) noexcept
{
return impl->m_VariableModel->createVariable(name);
}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 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};
}