Ref T28, allow to set updater to really show if it is "on"

This commit is contained in:
Klaus Basan
2017-05-04 02:09:44 +02:00
committed by Mathew Sutcliffe
parent e7e984227b
commit 0fd3857b87
5 changed files with 31 additions and 5 deletions

View File

@@ -11,6 +11,7 @@
#include "ui_datasettingscomponent.h" #include "ui_datasettingscomponent.h"
using namespace BlackGui; using namespace BlackGui;
using namespace BlackCore::Db;
namespace BlackGui namespace BlackGui
{ {
@@ -27,5 +28,9 @@ namespace BlackGui
CDataSettingsComponent::~CDataSettingsComponent() CDataSettingsComponent::~CDataSettingsComponent()
{ } { }
void CDataSettingsComponent::setBackgroundUpdater(CBackgroundDataUpdater *updater)
{
ui->comp_ModelSettings->setBackgroundUpdater(updater);
}
} // ns } // ns
} // ns } // ns

View File

@@ -14,14 +14,13 @@
#include "blackgui/blackguiexport.h" #include "blackgui/blackguiexport.h"
#include "blackgui/overlaymessagesframe.h" #include "blackgui/overlaymessagesframe.h"
#include <QObject> #include <QObject>
#include <QScopedPointer> #include <QScopedPointer>
class QWidget; class QWidget;
namespace Ui { class CDataSettingsComponent; } namespace Ui { class CDataSettingsComponent; }
namespace BlackCore { namespace Db { class CBackgroundDataUpdater; }}
namespace BlackGui namespace BlackGui
{ {
namespace Components namespace Components
@@ -38,7 +37,10 @@ namespace BlackGui
explicit CDataSettingsComponent(QWidget *parent = nullptr); explicit CDataSettingsComponent(QWidget *parent = nullptr);
//! Destructor //! Destructor
~CDataSettingsComponent(); virtual ~CDataSettingsComponent();
//! Background updater
void setBackgroundUpdater(BlackCore::Db::CBackgroundDataUpdater *updater);
private: private:
QScopedPointer<Ui::CDataSettingsComponent> ui; QScopedPointer<Ui::CDataSettingsComponent> ui;

View File

@@ -9,7 +9,8 @@
#include "settingsmodelcomponent.h" #include "settingsmodelcomponent.h"
#include "ui_settingsmodelcomponent.h" #include "ui_settingsmodelcomponent.h"
#include "blackgui/guiapplication.h"
#include "blackcore/db/backgrounddataupdater.h"
#include "blackmisc/logmessage.h" #include "blackmisc/logmessage.h"
#include <QValidator> #include <QValidator>
@@ -45,6 +46,11 @@ namespace BlackGui
return ok ? secs : -1; return ok ? secs : -1;
} }
void CSettingsModelComponent::setBackgroundUpdater(BlackCore::Db::CBackgroundDataUpdater *updater)
{
m_updater = updater;
}
void CSettingsModelComponent::consolidationEntered() void CSettingsModelComponent::consolidationEntered()
{ {
int v = this->getBackgroundUpdaterIntervallSecs(); int v = this->getBackgroundUpdaterIntervallSecs();
@@ -61,7 +67,12 @@ namespace BlackGui
const bool on = v > 0; const bool on = v > 0;
const QString s = on ? QString::number(v) : ""; const QString s = on ? QString::number(v) : "";
ui->le_ConsolidateSecs->setText(s); ui->le_ConsolidateSecs->setText(s);
ui->comp_Led->setOn(on);
const bool updater =
on &&
sApp && !sApp->isShuttingDown() &&
this->m_updater && this->m_updater->isEnabled();
ui->comp_Led->setOn(updater);
} }
} // ns } // ns
} // ns } // ns

View File

@@ -16,6 +16,7 @@
#include <QFrame> #include <QFrame>
namespace Ui { class CSettingsModelComponent; } namespace Ui { class CSettingsModelComponent; }
namespace BlackCore { namespace Db { class CBackgroundDataUpdater; }}
namespace BlackGui namespace BlackGui
{ {
namespace Components namespace Components
@@ -37,9 +38,13 @@ namespace BlackGui
//! Interval, -1 for disabled //! Interval, -1 for disabled
int getBackgroundUpdaterIntervallSecs() const; int getBackgroundUpdaterIntervallSecs() const;
//! Updater (the updater this setting is for)
void setBackgroundUpdater(BlackCore::Db::CBackgroundDataUpdater *updater);
private: private:
QScopedPointer<Ui::CSettingsModelComponent> ui; QScopedPointer<Ui::CSettingsModelComponent> ui;
BlackMisc::CSetting<BlackGui::Settings::TBackgroundConsolidation> m_consolidationSetting { this, &CSettingsModelComponent::cacheChanged }; //!< consolidation time BlackMisc::CSetting<BlackGui::Settings::TBackgroundConsolidation> m_consolidationSetting { this, &CSettingsModelComponent::cacheChanged }; //!< consolidation time
BlackCore::Db::CBackgroundDataUpdater *m_updater = nullptr;
//! Consolidation time entered //! Consolidation time entered
void consolidationEntered(); void consolidationEntered();

View File

@@ -13,6 +13,7 @@
#include "blackgui/components/datamaininfoareacomponent.h" #include "blackgui/components/datamaininfoareacomponent.h"
#include "blackgui/components/dbmappingcomponent.h" #include "blackgui/components/dbmappingcomponent.h"
#include "blackgui/components/logcomponent.h" #include "blackgui/components/logcomponent.h"
#include "blackgui/components/datasettingscomponent.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackgui/stylesheetutility.h" #include "blackgui/stylesheetutility.h"
#include "blackmisc/loghandler.h" #include "blackmisc/loghandler.h"
@@ -160,6 +161,7 @@ void CSwiftData::consolidationSettingChanged()
{ {
if (m_updater) if (m_updater)
{ {
ui->comp_MainInfoArea->getDataSettingsComponent()->setBackgroundUpdater(nullptr);
m_updater->gracefulShutdown(); m_updater->gracefulShutdown();
m_updater.reset(nullptr); m_updater.reset(nullptr);
} }
@@ -170,6 +172,7 @@ void CSwiftData::consolidationSettingChanged()
{ {
m_updater.reset(new CBackgroundDataUpdater(this)); m_updater.reset(new CBackgroundDataUpdater(this));
m_updater->start(QThread::LowestPriority); m_updater->start(QThread::LowestPriority);
ui->comp_MainInfoArea->getDataSettingsComponent()->setBackgroundUpdater(m_updater.data());
} }
m_updater->startUpdating(consolidationSecs); m_updater->startUpdating(consolidationSecs);
} }