mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #743, adjustments of auto stashing dialog
* using BlackCore::IProgressIndicator * log categories
This commit is contained in:
committed by
Mathew Sutcliffe
parent
260996b38c
commit
be94da0048
@@ -48,6 +48,12 @@ namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
const CLogCategoryList &CDbAutoStashingComponent::getLogCategories()
|
||||
{
|
||||
static const BlackMisc::CLogCategoryList cats { CLogCategory::mapping(), CLogCategory::guiComponent() };
|
||||
return cats;
|
||||
}
|
||||
|
||||
CDbAutoStashingComponent::CDbAutoStashingComponent(QWidget *parent) :
|
||||
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint),
|
||||
CDbMappingComponentAware(qobject_cast<CDbMappingComponent * >(parent)),
|
||||
@@ -60,7 +66,7 @@ namespace BlackGui
|
||||
Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "Expect mapping componet");
|
||||
|
||||
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbAutoStashingComponent::ps_entitiesRead);
|
||||
connect(ui->pb_ResetDescription, &QPushButton::clicked, this, &CDbAutoStashingComponent::ps_resetDescription);
|
||||
connect(ui->tb_ResetDescription, &QToolButton::clicked, this, &CDbAutoStashingComponent::ps_resetDescription);
|
||||
|
||||
this->ps_resetDescription();
|
||||
}
|
||||
@@ -70,30 +76,37 @@ namespace BlackGui
|
||||
|
||||
void CDbAutoStashingComponent::accept()
|
||||
{
|
||||
if (m_state == Running) { return; }
|
||||
if (m_state == Completed)
|
||||
switch (this->m_state)
|
||||
{
|
||||
if (!this->m_modelsToStash.isEmpty())
|
||||
case Running: return;
|
||||
case Completed:
|
||||
{
|
||||
// this removes previously stashed models
|
||||
this->getMappingComponent()->replaceStashedModelsUnvalidated(this->m_modelsToStash);
|
||||
if (ui->cb_RemovedChecked->isChecked())
|
||||
if (!this->m_modelsToStash.isEmpty())
|
||||
{
|
||||
this->currentModelView()->removeModelsWithModelString(this->m_modelsToStash);
|
||||
// this removes previously stashed models
|
||||
this->getMappingComponent()->replaceStashedModelsUnvalidated(this->m_modelsToStash);
|
||||
if (ui->cb_RemovedChecked->isChecked())
|
||||
{
|
||||
this->currentModelView()->removeModelsWithModelString(this->m_modelsToStash);
|
||||
}
|
||||
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QString("Auto stashed %1 models").arg(m_modelsToStash.size()));
|
||||
this->addStatusMessage(stashedMsg);
|
||||
this->m_modelsToStash.clear();
|
||||
}
|
||||
const CStatusMessage stashedMsg(categgories(), CStatusMessage::SeverityInfo, QString("Auto stashed %1 models").arg(m_modelsToStash.size()));
|
||||
this->addStatusMessage(stashedMsg);
|
||||
this->m_modelsToStash.clear();
|
||||
QDialog::accept();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (this->getSelectedOrAllCount() < 1)
|
||||
{
|
||||
const CStatusMessage m(this, CStatusMessage::SeverityError, "No data, nothing to do");
|
||||
this->addStatusMessage(m);
|
||||
QDialog::accept();
|
||||
}
|
||||
this->tryToStashModels();
|
||||
}
|
||||
QDialog::accept();
|
||||
}
|
||||
if (this->getSelectedOrAllCount() < 1)
|
||||
{
|
||||
const CStatusMessage m(categgories(), CStatusMessage::SeverityError, "No data, nothing to do");
|
||||
this->addStatusMessage(m);
|
||||
QDialog::accept();
|
||||
}
|
||||
this->tryToStashModels();
|
||||
}
|
||||
|
||||
int CDbAutoStashingComponent::exec()
|
||||
@@ -129,11 +142,11 @@ namespace BlackGui
|
||||
this->m_noData = 0;
|
||||
this->m_noValidationFailed = 0;
|
||||
this->m_noStashed = 0;
|
||||
this->updateGuiValues(0);
|
||||
this->updateProgressIndicator(0);
|
||||
|
||||
if (!this->currentModelView())
|
||||
{
|
||||
const CStatusMessage m(categgories(), CStatusMessage::SeverityError, "No data for auto stashing");
|
||||
const CStatusMessage m(this, CStatusMessage::SeverityError, "No data for auto stashing");
|
||||
this->addStatusMessage(m);
|
||||
}
|
||||
else
|
||||
@@ -164,7 +177,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDbAutoStashingComponent::updateGuiValues(int percent)
|
||||
void CDbAutoStashingComponent::updateProgressIndicator(int percent)
|
||||
{
|
||||
if (percent > 100) { percent = 100; }
|
||||
if (percent < 0) { percent = 0; }
|
||||
@@ -262,15 +275,15 @@ namespace BlackGui
|
||||
int maxPercent = autoStashed.size() * 100 / max;
|
||||
if (maxPercent > percent) { percent = maxPercent; }
|
||||
}
|
||||
this->updateGuiValues(percent);
|
||||
this->updateProgressIndicator(percent);
|
||||
}
|
||||
if (autoStashed.size() >= max) { break; }
|
||||
}
|
||||
|
||||
this->updateGuiValues(100);
|
||||
this->updateProgressIndicator(100);
|
||||
sGui->processEventsToRefreshGui();
|
||||
|
||||
const CStatusMessage stashedMsg(categgories(), CStatusMessage::SeverityInfo, QString("Ready to auto stashed %1 models").arg(autoStashed.size()));
|
||||
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QString("Ready to auto stashed %1 models").arg(autoStashed.size()));
|
||||
this->addStatusMessage(stashedMsg);
|
||||
this->m_modelsToStash = autoStashed;
|
||||
this->m_state = Completed;
|
||||
@@ -290,18 +303,18 @@ namespace BlackGui
|
||||
//! Some upfront tests
|
||||
if (!model.hasModelString())
|
||||
{
|
||||
this->addStatusMessage(CStatusMessage(this->categgories(), CStatusMessage::SeverityError, "No model string"));
|
||||
this->addStatusMessage(CStatusMessage(this, CStatusMessage::SeverityError, "No model string"));
|
||||
this->m_noData++;
|
||||
}
|
||||
else if (!model.hasAircraftDesignator())
|
||||
{
|
||||
this->addStatusMessage(CStatusMessage(this->categgories(), CStatusMessage::SeverityError, "No aircraft designator"), model);
|
||||
this->addStatusMessage(CStatusMessage(this, CStatusMessage::SeverityError, "No aircraft designator"), model);
|
||||
this->m_noData++;
|
||||
}
|
||||
else if (!model.hasAirlineDesignator() && !model.getLivery().hasValidDbKey())
|
||||
{
|
||||
// if there is no livery (normal) we need an airline
|
||||
this->addStatusMessage(CStatusMessage(this->categgories(), CStatusMessage::SeverityError, "No airline designator"), model);
|
||||
this->addStatusMessage(CStatusMessage(this, CStatusMessage::SeverityError, "No airline designator"), model);
|
||||
this->m_noData++;
|
||||
}
|
||||
else
|
||||
@@ -317,7 +330,7 @@ namespace BlackGui
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = CStatusMessage(categgories(), CStatusMessage::SeverityInfo, "Stashed succesfully");
|
||||
msg = CStatusMessage(this, CStatusMessage::SeverityInfo, "Stashed succesfully");
|
||||
stashed = true;
|
||||
this->m_noStashed++;
|
||||
model = stashModel;
|
||||
@@ -347,11 +360,5 @@ namespace BlackGui
|
||||
if (!sGui || !sGui->hasWebDataServices()) { return CLivery(); }
|
||||
return sGui->getWebDataServices()->getTempLiveryOrDefault();
|
||||
}
|
||||
|
||||
const CLogCategoryList &CDbAutoStashingComponent::categgories()
|
||||
{
|
||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::guiComponent() }).join({ CLogCategory::mapping()}));
|
||||
return cats;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/components/dbmappingcomponentaware.h"
|
||||
#include "blackcore/progress.h"
|
||||
#include "blackmisc/network/entityflags.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
@@ -40,7 +41,8 @@ namespace BlackGui
|
||||
*/
|
||||
class BLACKGUI_EXPORT CDbAutoStashingComponent :
|
||||
public QDialog,
|
||||
public BlackGui::Components::CDbMappingComponentAware
|
||||
public BlackGui::Components::CDbMappingComponentAware,
|
||||
public BlackCore::IProgressIndicator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -53,6 +55,9 @@ namespace BlackGui
|
||||
Completed
|
||||
};
|
||||
|
||||
//! Log categories
|
||||
static const BlackMisc::CLogCategoryList &getLogCategories();
|
||||
|
||||
//! Constructor
|
||||
explicit CDbAutoStashingComponent(QWidget *parent = nullptr);
|
||||
|
||||
@@ -62,6 +67,9 @@ namespace BlackGui
|
||||
//! At least run once and completed
|
||||
bool isCompleted() const { return m_state == Completed; }
|
||||
|
||||
//! \copydoc BlackCore::IProgressIndicator::updateProgressIndicator
|
||||
virtual void updateProgressIndicator(int percent) override;
|
||||
|
||||
public slots:
|
||||
//! \copydoc QDialog::accept
|
||||
virtual void accept() override;
|
||||
@@ -85,9 +93,6 @@ namespace BlackGui
|
||||
//! Init the component
|
||||
void initGui();
|
||||
|
||||
//! Update GUI values
|
||||
void updateGuiValues(int percent);
|
||||
|
||||
//! Number of all or selected models
|
||||
int getSelectedOrAllCount() const;
|
||||
|
||||
@@ -114,9 +119,6 @@ namespace BlackGui
|
||||
//! Get the temp.livery if available
|
||||
static BlackMisc::Aviation::CLivery getTempLivery();
|
||||
|
||||
//! Categories
|
||||
const BlackMisc::CLogCategoryList &categgories();
|
||||
|
||||
int m_noStashed = 0; //!< stashed models
|
||||
int m_noData = 0; //!< not stashed because no data
|
||||
int m_noValidationFailed = 0; //!< not stashed because validation failed
|
||||
|
||||
@@ -6,10 +6,16 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>453</width>
|
||||
<height>413</height>
|
||||
<width>600</width>
|
||||
<height>416</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Auto stashing</string>
|
||||
</property>
|
||||
@@ -36,7 +42,7 @@
|
||||
<item row="0" column="2">
|
||||
<widget class="QRadioButton" name="rb_All">
|
||||
<property name="text">
|
||||
<string>All:</string>
|
||||
<string>all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -50,16 +56,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="le_Description">
|
||||
<property name="maxLength">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Override description in model</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_Selected">
|
||||
<property name="readOnly">
|
||||
@@ -73,7 +69,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="rb_Selected">
|
||||
<property name="text">
|
||||
<string>Selected:</string>
|
||||
<string>selected</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
@@ -158,58 +154,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="le_MaxModelsStashed">
|
||||
<property name="placeholderText">
|
||||
<string>max.models to be stashed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QWidget" name="wi_DescriptionRadioButtons" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_DescriptionButtons">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_DescriptionAll">
|
||||
<property name="text">
|
||||
<string>all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_DescriptionEmptyOnly">
|
||||
<property name="toolTip">
|
||||
<string>apply only if description is empty</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>empty only</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="pb_ResetDescription">
|
||||
<property name="text">
|
||||
<string>reset description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="4">
|
||||
<widget class="QProgressBar" name="pb_StashingProgress">
|
||||
<property name="value">
|
||||
@@ -251,13 +195,92 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_MaxModelsStashed">
|
||||
<property name="placeholderText">
|
||||
<string>max.models to be stashed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="le_Description">
|
||||
<property name="maxLength">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Override description in model</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="3">
|
||||
<widget class="QCheckBox" name="cb_UseTempLivery">
|
||||
<property name="text">
|
||||
<string>use 'temp' livery if not resolved</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" colspan="2" alignment="Qt::AlignLeft">
|
||||
<widget class="QWidget" name="wi_DescriptionRadioButtons" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_DescriptionButtons">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_DescriptionAll">
|
||||
<property name="text">
|
||||
<string>all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="QRadioButton" name="rb_DescriptionEmptyOnly">
|
||||
<property name="toolTip">
|
||||
<string>apply only if description is empty</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>empty only</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_ResetDescription">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QToolButton" name="tb_ResetDescription">
|
||||
<property name="toolTip">
|
||||
<string>reset description</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../blackmisc/blackmisc.qrc">
|
||||
<normaloff>:/diagona/icons/diagona/icons/cross-white.png</normaloff>:/diagona/icons/diagona/icons/cross-white.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -275,10 +298,7 @@
|
||||
<tabstop>rb_All</tabstop>
|
||||
<tabstop>le_All</tabstop>
|
||||
<tabstop>le_MaxModelsStashed</tabstop>
|
||||
<tabstop>pb_ResetDescription</tabstop>
|
||||
<tabstop>le_Description</tabstop>
|
||||
<tabstop>rb_DescriptionAll</tabstop>
|
||||
<tabstop>rb_DescriptionEmptyOnly</tabstop>
|
||||
<tabstop>cb_UseTempLivery</tabstop>
|
||||
<tabstop>tvp_StatusMessages</tabstop>
|
||||
<tabstop>le_Stashed</tabstop>
|
||||
@@ -286,7 +306,9 @@
|
||||
<tabstop>le_ValidationFailed</tabstop>
|
||||
<tabstop>cb_RemovedChecked</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../blackmisc/blackmisc.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bb_AutoStashing</sender>
|
||||
|
||||
Reference in New Issue
Block a user