refs #886, added wizard component for initial data load

* added buttons to CDbLoadOverviewComponent
* wizard component/page
* added to wizard
This commit is contained in:
Klaus Basan
2017-02-26 15:26:10 +01:00
committed by Mathew Sutcliffe
parent 9b4b2f70cc
commit b94eab581e
8 changed files with 1109 additions and 696 deletions

View File

@@ -19,15 +19,16 @@ namespace BlackGui
ui(new Ui::CConfigurationWizard)
{
ui->setupUi(this);
ui->wp_CopyCaches->setConfigComponent(ui->comp_CopyCaches);
ui->wp_CopySettings->setConfigComponent(ui->comp_CopySettings);
ui->wp_Simulator->setConfigComponent(ui->comp_Simulator);
ui->wp_DataLoad->setConfigComponent(ui->comp_DataLoad);
// no other versions, skip copy pages
if (!ui->comp_CopySettings->hasOtherVersionData())
{
this->setStartId(ConfigSimulator);
}
ui->wp_CopyCaches->setConfigComponent(ui->comp_CopyCaches);
ui->wp_CopySettings->setConfigComponent(ui->comp_CopySettings);
ui->wp_Simulator->setConfigComponent(ui->comp_Simulator);
connect(this, &QWizard::currentIdChanged, this, &CConfigurationWizard::wizardCurrentIdChanged);
}

View File

@@ -127,6 +127,32 @@
</item>
</layout>
</widget>
<widget class="BlackGui::Components::CInitialDataLoadWizardPage" name="wp_DataLoad">
<layout class="QVBoxLayout" name="vl_DataLoad">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="BlackGui::Components::CInitialDataLoadComponent" name="comp_DataLoad">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
@@ -153,6 +179,18 @@
<header>blackgui/components/copyconfigurationcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CInitialDataLoadWizardPage</class>
<extends>QWizardPage</extends>
<header>blackgui/components/initialdataloadcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CInitialDataLoadComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/initialdataloadcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -56,6 +56,9 @@ namespace BlackGui
connect(ui->tb_SharedReloadModels, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshSharedPressed);
connect(ui->tb_SharedReloadDistributors, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshSharedPressed);
connect(ui->pb_LoadAllFromDB, &QPushButton::pressed, this, &CDbLoadOverviewComponent::loadAllFromDb);
connect(ui->pb_LoadAllFromShared, &QPushButton::pressed, this, &CDbLoadOverviewComponent::loadAllFromShared);
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbLoadOverviewComponent::ps_dataLoaded);
connect(this, &CDbLoadOverviewComponent::ps_triggerDigestGuiUpdate, this, &CDbLoadOverviewComponent::ps_setValues);
}
@@ -107,6 +110,29 @@ namespace BlackGui
return m_loadIndicator && this->isVisible() && m_loadIndicator->isAnimated();
}
bool CDbLoadOverviewComponent::isLoadInProgress() const
{
return m_loadInProgress;
}
void CDbLoadOverviewComponent::showLoadAllButtons(bool shared, bool db)
{
const bool widget = shared || db;
ui->wi_LoadAllButtons->setVisible(widget);
ui->pb_LoadAllFromDB->setVisible(db);
ui->pb_LoadAllFromShared->setVisible(shared);
}
void CDbLoadOverviewComponent::loadAllFromDb()
{
this->triggerLoadingFromDb(CEntityFlags::AllDbEntitiesNoInfoObjects);
}
void CDbLoadOverviewComponent::loadAllFromShared()
{
this->triggerLoadingFromSharedFiles(CEntityFlags::AllDbEntitiesNoInfoObjects);
}
void CDbLoadOverviewComponent::centerLoadIndicator()
{
if (!m_loadIndicator) { return; }
@@ -247,31 +273,43 @@ namespace BlackGui
void CDbLoadOverviewComponent::ps_refreshDbPressed()
{
if (this->m_reloading) { return; }
if (this->m_loadInProgress) { return; }
const QObject *sender = QObject::sender();
const CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(sender->objectName());
this->triggerLoadingFromDb(entity);
}
void CDbLoadOverviewComponent::triggerLoadingFromDb(CEntityFlags::Entity entities)
{
if (this->m_loadInProgress) { return; }
// DB entities
const CEntityFlags::Entity triggeredEntity = sGui->getWebDataServices()->triggerLoadingDirectlyFromDb(entity);
if (triggeredEntity == CEntityFlags::NoEntity) { return; }
this->m_reloading = true;
const CEntityFlags::Entity triggeredEntities = sGui->getWebDataServices()->triggerLoadingDirectlyFromDb(entities);
if (triggeredEntities == CEntityFlags::NoEntity) { return; }
this->m_loadInProgress = true;
this->showLoading();
// shared files ts
sGui->getWebDataServices()->triggerLoadingOfSharedFilesHeaders(entity);
sGui->getWebDataServices()->triggerLoadingOfSharedFilesHeaders(entities);
sGui->getWebDataServices()->triggerReadOfInfoObjects();
}
void CDbLoadOverviewComponent::ps_refreshSharedPressed()
{
if (this->m_reloading) { return; }
if (this->m_loadInProgress) { return; }
const QObject *sender = QObject::sender();
const CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(sender->objectName());
this->triggerLoadingFromSharedFiles(entity);
}
void CDbLoadOverviewComponent::triggerLoadingFromSharedFiles(CEntityFlags::Entity entities)
{
if (this->m_loadInProgress) { return; }
// DB entities
const CEntityFlags::Entity triggeredEntity = sGui->getWebDataServices()->triggerLoadingDirectlyFromSharedFiles(entity, true);
if (triggeredEntity == CEntityFlags::NoEntity) { return; }
this->m_reloading = true;
const CEntityFlags::Entity triggeredEntities = sGui->getWebDataServices()->triggerLoadingDirectlyFromSharedFiles(entities, true);
if (triggeredEntities == CEntityFlags::NoEntity) { return; }
this->m_loadInProgress = true;
this->showLoading();
// shared files ts
@@ -284,7 +322,7 @@ namespace BlackGui
if (!entities.testFlag(CEntityFlags::InfoObjectEntity) && !CEntityFlags::anySwiftDbEntity(entities)) { return; }
if (state == CEntityFlags::ReadFinished || state == CEntityFlags::ReadFinishedRestricted)
{
this->m_reloading = false;
this->m_loadInProgress = false;
emit this->ps_triggerDigestGuiUpdate();
}
}

View File

@@ -50,6 +50,18 @@ namespace BlackGui
//! Showing load indicator?
bool isShowingLoadIndicator() const;
//! Loading in progress?
bool isLoadInProgress() const;
//! Show load all buttons
void showLoadAllButtons(bool shared, bool db);
//! Load all from DB
void loadAllFromDb();
//! Load all from shared
void loadAllFromShared();
signals:
//! Trigger GUI update
//! \private
@@ -65,8 +77,14 @@ namespace BlackGui
private:
QScopedPointer<Ui::CDbLoadOverviewComponent> ui;
BlackGui::CLoadIndicator *m_loadIndicator = nullptr; //!< load indicator if needed
bool m_reloading = false;
BlackMisc::CDigestSignal m_dsTriggerGuiUpdate { this, &CDbLoadOverviewComponent::ps_triggerDigestGuiUpdate, &CDbLoadOverviewComponent::ps_setValues, 750, 4 };
bool m_loadInProgress = false; //!< data loading in progress
//! Trigger loading from DB
void triggerLoadingFromDb(BlackMisc::Network::CEntityFlags::Entity entities);
//! Trigger loading from shared files
void triggerLoadingFromSharedFiles(BlackMisc::Network::CEntityFlags::Entity entities);
//! Show loading
void showLoading();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
/* Copyright (C) 2017
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "initialdataloadcomponent.h"
#include "ui_initialdataloadcomponent.h"
namespace BlackGui
{
namespace Components
{
CInitialDataLoadComponent::CInitialDataLoadComponent(QWidget *parent) :
QFrame(parent),
ui(new Ui::CInitialDataLoadComponent)
{
ui->setupUi(this);
ui->comp_DataUpdates->showLoadAllButtons(true, false);
}
CInitialDataLoadComponent::~CInitialDataLoadComponent()
{ }
void CInitialDataLoadComponent::loadAllFromShared()
{
ui->comp_DataUpdates->loadAllFromShared();
}
void CInitialDataLoadComponent::loadAllFromDb()
{
ui->comp_DataUpdates->loadAllFromDb();
}
bool CInitialDataLoadComponent::isLoadInProgress() const
{
return ui->comp_DataUpdates->isLoadInProgress();
}
void CInitialDataLoadWizardPage::initializePage()
{
Q_ASSERT_X(m_config, Q_FUNC_INFO, "Missing config");
QTimer::singleShot(500, m_config, [ = ] { m_config->loadAllFromShared(); });
}
bool CInitialDataLoadWizardPage::validatePage()
{
Q_ASSERT_X(m_config, Q_FUNC_INFO, "Missing config");
return !m_config->isLoadInProgress();
}
} // ns
} // ns

View File

@@ -0,0 +1,76 @@
/* Copyright (C) 2017
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_COMPONENTS_INITIALDATALOADCOMPONENT_H
#define BLACKGUI_COMPONENTS_INITIALDATALOADCOMPONENT_H
#include <QFrame>
#include <QScopedPointer>
#include <QWizardPage>
namespace Ui { class CInitialDataLoadComponent; }
namespace BlackGui
{
namespace Components
{
/**
* Initial data load to prefill caches
* \remark Normally used in wizard
*/
class CInitialDataLoadComponent : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit CInitialDataLoadComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~CInitialDataLoadComponent();
//! \copydoc BlackGui::Components::CDbLoadOverviewComponent::loadAllFromShared
void loadAllFromShared();
//! \copydoc BlackGui::Components::CDbLoadOverviewComponent::loadAllFromDb
void loadAllFromDb();
//! \copydoc BlackGui::Components::CDbLoadOverviewComponent::isLoadInProgress
bool isLoadInProgress() const;
private:
QScopedPointer<Ui::CInitialDataLoadComponent> ui;
};
/**
* Wizard page for CInitialDataLoadComponent
*/
class CInitialDataLoadWizardPage : public QWizardPage
{
public:
//! Constructors
using QWizardPage::QWizardPage;
//! Set config
void setConfigComponent(CInitialDataLoadComponent *config) { m_config = config; }
//! \copydoc QWizardPage::initializePage
virtual void initializePage() override;
//! \copydoc QWizardPage::validatePage
virtual bool validatePage() override;
private:
CInitialDataLoadComponent *m_config = nullptr;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CInitialDataLoadComponent</class>
<widget class="QFrame" name="CInitialDataLoadComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Initial data loading</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_DataLoadComponent">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QFrame" name="fr_Header">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="hl_HeaderText" stretch="1,6">
<item>
<widget class="QLabel" name="lbl_HeaderIcon">
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="pixmap">
<pixmap resource="../../blackmisc/blackmisc.qrc">:/own/icons/own/swift3D/sw3DGreen-32.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_HeaderText">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;We recommend to download an initial data set. This may some time, but then you can start to use all tool straight away with full functionality.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_DataLoading">
<property name="title">
<string>Data loading</string>
</property>
<layout class="QVBoxLayout" name="vl_DataLoading">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="BlackGui::Components::CInfoBarWebReadersStatusSmallComponent" name="comp_InfoBar">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="BlackGui::Components::CDbLoadOverviewComponent" name="comp_DataUpdates">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CDbLoadOverviewComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/dbloadoverviewcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CInfoBarWebReadersStatusSmallComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/infobarwebreadersstatussmallcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>
</resources>
<connections/>
</ui>