mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #475, allow to load DB data from disk.
* Will allow to load data if DB is not accessible / available * Also allows to save, so a special set can be saved for testing/forensic. * fixed status bar, as received data no longer means DB is alive
This commit is contained in:
committed by
Mathew Sutcliffe
parent
326a465b54
commit
aa653e0d85
@@ -7,11 +7,12 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "ui_datainfoareacomponent.h"
|
||||
#include "blackgui/components/logcomponent.h"
|
||||
#include "blackgui/components/datainfoareacomponent.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "ui_datainfoareacomponent.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui;
|
||||
@@ -73,6 +74,37 @@ namespace BlackGui
|
||||
this->ui->comp_DbLiveries->setProvider(provider);
|
||||
this->ui->comp_DbModels->setProvider(provider);
|
||||
this->ui->comp_Countries->setProvider(provider);
|
||||
CWebDataServicesAware::setProvider(provider);
|
||||
}
|
||||
|
||||
bool CDataInfoAreaComponent::writeDbDataToResourceDir() const
|
||||
{
|
||||
bool s = hasProvider() &&
|
||||
this->writeDbDataToDisk(CProject::getSwiftStaticDbFilesDir());
|
||||
if (s)
|
||||
{
|
||||
CLogMessage(this).info("Written DB data");
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).error("Cannot write DB data");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
bool CDataInfoAreaComponent::readDbDataFromResourceDir()
|
||||
{
|
||||
bool s = hasProvider() &&
|
||||
this->readDbDataFromDisk(CProject::getSwiftStaticDbFilesDir());
|
||||
if (s)
|
||||
{
|
||||
CLogMessage(this).info("Read DB data");
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).error("Failed to load DB data");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
QSize CDataInfoAreaComponent::getPreferredSizeWhenFloating(int areaIndex) const
|
||||
|
||||
@@ -82,6 +82,13 @@ namespace BlackGui
|
||||
//! Set data reader
|
||||
virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReader) override;
|
||||
|
||||
public slots:
|
||||
//! Write to resource dir
|
||||
bool writeDbDataToResourceDir() const;
|
||||
|
||||
//! Load from resource dir
|
||||
bool readDbDataFromResourceDir();
|
||||
|
||||
protected:
|
||||
//! \copydoc CInfoArea::getPreferredSizeWhenFloating
|
||||
virtual QSize getPreferredSizeWhenFloating(int areaIndex) const override;
|
||||
|
||||
@@ -62,17 +62,7 @@ namespace BlackGui
|
||||
|
||||
void CInfoBarWebReadersStatusComponent::ps_dataRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||
{
|
||||
if (readState == CEntityFlags::ReadFinished)
|
||||
{
|
||||
bool swift = CWebReaderFlags::isFromSwiftDb(entity);
|
||||
if (swift && count > 0)
|
||||
{
|
||||
// avoids unnecessary checks
|
||||
this->ui->led_SwiftDb->setOn(true);
|
||||
this->m_timer.start(); // restart
|
||||
}
|
||||
}
|
||||
|
||||
Q_UNUSED(count);
|
||||
QList<CLedWidget *> leds = this->entityToLeds(entity);
|
||||
if (!leds.isEmpty()) { this->setLedReadStates(leds, readState); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user