mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #745, allow to decide which descriptions are overridden in auto stashing
* adjusted CAircraftModel to ignore auto generated message * radio buttons in GUI to select all/non-empty descriptions * allow to use the temp. livery
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackGui::Views;
|
||||
@@ -53,12 +54,15 @@ namespace BlackGui
|
||||
ui(new Ui::CDbAutoStashingComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->ui->tvp_StatusMessages->setResizeMode(CAircraftModelView::ResizingAuto);
|
||||
this->ui->tvp_StatusMessages->menuAddItems(CAircraftModelView::MenuSave);
|
||||
this->ui->le_MaxModelsStashed->setValidator(new QIntValidator(10, CDbStashComponent::MaxModelPublished, this));
|
||||
ui->tvp_StatusMessages->setResizeMode(CAircraftModelView::ResizingAuto);
|
||||
ui->tvp_StatusMessages->menuAddItems(CAircraftModelView::MenuSave);
|
||||
ui->le_MaxModelsStashed->setValidator(new QIntValidator(10, CDbStashComponent::MaxModelPublished, this));
|
||||
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);
|
||||
|
||||
this->ps_resetDescription();
|
||||
}
|
||||
|
||||
CDbAutoStashingComponent::~CDbAutoStashingComponent()
|
||||
@@ -73,7 +77,7 @@ namespace BlackGui
|
||||
{
|
||||
// this removes previously stashed models
|
||||
this->getMappingComponent()->replaceStashedModelsUnvalidated(this->m_modelsToStash);
|
||||
if (this->ui->cb_RemovedChecked->isChecked())
|
||||
if (ui->cb_RemovedChecked->isChecked())
|
||||
{
|
||||
this->currentModelView()->removeModelsWithModelString(this->m_modelsToStash);
|
||||
}
|
||||
@@ -100,7 +104,7 @@ namespace BlackGui
|
||||
|
||||
void CDbAutoStashingComponent::showLastResults()
|
||||
{
|
||||
this->ui->bb_AutoStashing->setStandardButtons(QDialogButtonBox::Close);
|
||||
ui->bb_AutoStashing->setStandardButtons(QDialogButtonBox::Close);
|
||||
this->setVisible(true);
|
||||
}
|
||||
|
||||
@@ -111,11 +115,17 @@ namespace BlackGui
|
||||
Q_UNUSED(entity);
|
||||
}
|
||||
|
||||
void CDbAutoStashingComponent::ps_resetDescription()
|
||||
{
|
||||
ui->rb_DescriptionEmptyOnly->setChecked(true);
|
||||
ui->le_Description->setText(CAircraftModel::autoGenerated());
|
||||
}
|
||||
|
||||
void CDbAutoStashingComponent::initGui()
|
||||
{
|
||||
this->m_state = Idle;
|
||||
this->ui->bb_AutoStashing->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
this->ui->tvp_StatusMessages->clear();
|
||||
ui->bb_AutoStashing->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
ui->tvp_StatusMessages->clear();
|
||||
this->m_noData = 0;
|
||||
this->m_noValidationFailed = 0;
|
||||
this->m_noStashed = 0;
|
||||
@@ -130,26 +140,26 @@ namespace BlackGui
|
||||
{
|
||||
int selected = this->currentModelView()->selectedRowCount();
|
||||
int all = this->currentModelView()->rowCount();
|
||||
this->ui->le_Selected->setText(QString::number(selected));
|
||||
ui->le_Selected->setText(QString::number(selected));
|
||||
QString allStr(QString::number(all));
|
||||
if (all > CDbStashComponent::MaxModelPublished)
|
||||
{
|
||||
allStr += " (Max." + QString::number(CDbStashComponent::MaxModelPublished) + ")";
|
||||
}
|
||||
this->ui->le_All->setText(allStr);
|
||||
if (this->ui->le_MaxModelsStashed->text().isEmpty())
|
||||
ui->le_All->setText(allStr);
|
||||
if (ui->le_MaxModelsStashed->text().isEmpty())
|
||||
{
|
||||
this->ui->le_MaxModelsStashed->setText(all > 100 ? "100" : "");
|
||||
ui->le_MaxModelsStashed->setText(all > 100 ? "100" : "");
|
||||
}
|
||||
if (selected > 0)
|
||||
{
|
||||
this->ui->rb_Selected->setChecked(true);
|
||||
this->ui->rb_Selected->setEnabled(true);
|
||||
ui->rb_Selected->setChecked(true);
|
||||
ui->rb_Selected->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->rb_All->setChecked(true);
|
||||
this->ui->rb_Selected->setEnabled(false);
|
||||
ui->rb_All->setChecked(true);
|
||||
ui->rb_Selected->setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,16 +168,16 @@ namespace BlackGui
|
||||
{
|
||||
if (percent > 100) { percent = 100; }
|
||||
if (percent < 0) { percent = 0; }
|
||||
this->ui->pb_StashingProgress->setValue(percent);
|
||||
this->ui->le_Stashed->setText(QString::number(this->m_noStashed));
|
||||
this->ui->le_NoData->setText(QString::number(this->m_noData));
|
||||
this->ui->le_ValidationFailed->setText(QString::number(this->m_noValidationFailed));
|
||||
ui->pb_StashingProgress->setValue(percent);
|
||||
ui->le_Stashed->setText(QString::number(this->m_noStashed));
|
||||
ui->le_NoData->setText(QString::number(this->m_noData));
|
||||
ui->le_ValidationFailed->setText(QString::number(this->m_noValidationFailed));
|
||||
}
|
||||
|
||||
int CDbAutoStashingComponent::getSelectedOrAllCount() const
|
||||
{
|
||||
if (!this->currentModelView()) { return 0; }
|
||||
if (this->ui->rb_Selected->isChecked())
|
||||
if (ui->rb_Selected->isChecked())
|
||||
{
|
||||
return this->currentModelView()->selectedRowCount();
|
||||
}
|
||||
@@ -185,7 +195,7 @@ namespace BlackGui
|
||||
void CDbAutoStashingComponent::addStatusMessage(const CStatusMessage &msg)
|
||||
{
|
||||
if (msg.isEmpty()) { return; }
|
||||
this->ui->tvp_StatusMessages->insert(msg);
|
||||
ui->tvp_StatusMessages->insert(msg);
|
||||
}
|
||||
|
||||
void CDbAutoStashingComponent::addStatusMessage(const CStatusMessage &msg, const CAircraftModel &model)
|
||||
@@ -195,18 +205,18 @@ namespace BlackGui
|
||||
{
|
||||
CStatusMessage prefixMessage(msg);
|
||||
prefixMessage.prependMessage(QString(model.getModelString() + ", " + model.getMembersDbStatus() + ": "));
|
||||
this->ui->tvp_StatusMessages->insert(prefixMessage);
|
||||
ui->tvp_StatusMessages->insert(prefixMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->tvp_StatusMessages->insert(msg);
|
||||
ui->tvp_StatusMessages->insert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void CDbAutoStashingComponent::tryToStashModels()
|
||||
{
|
||||
Q_ASSERT_X(this->currentModelView(), Q_FUNC_INFO, "No view");
|
||||
const CAircraftModelList models(this->ui->rb_Selected->isChecked() ? this->currentModelView()->selectedObjects() : this->currentModelView()->containerOrFilteredContainer());
|
||||
const CAircraftModelList models(ui->rb_Selected->isChecked() ? this->currentModelView()->selectedObjects() : this->currentModelView()->containerOrFilteredContainer());
|
||||
if (models.isEmpty()) { return; }
|
||||
|
||||
// we have data and are good to go
|
||||
@@ -214,23 +224,29 @@ namespace BlackGui
|
||||
const int all = models.size();
|
||||
|
||||
// maximum
|
||||
const QString maxStr(this->ui->le_MaxModelsStashed->text());
|
||||
const QString maxStr(ui->le_MaxModelsStashed->text());
|
||||
bool okMaxStr = true;
|
||||
int max = maxStr.isEmpty() ? CDbStashComponent::MaxModelPublished : maxStr.toInt(&okMaxStr);
|
||||
if (!okMaxStr || max > all) { max = all; }
|
||||
|
||||
// override description
|
||||
const QString description(this->ui->le_Description->text().trimmed());
|
||||
const QString description(ui->le_Description->text().trimmed());
|
||||
|
||||
// temp livery if applicable
|
||||
const CLivery tempLivery(ui->cb_UseTempLivery->isChecked() ? getTempLivery() : CLivery());
|
||||
|
||||
int c = 0;
|
||||
CAircraftModelList autoStashed;
|
||||
for (const CAircraftModel &model : models)
|
||||
{
|
||||
CAircraftModel stashModel(model);
|
||||
bool stashed = this->tryToStashModel(stashModel);
|
||||
const bool stashed = this->tryToStashModel(stashModel, tempLivery);
|
||||
if (stashed)
|
||||
{
|
||||
if (!description.isEmpty()) { stashModel.setDescription(description); }
|
||||
if (!description.isEmpty())
|
||||
{
|
||||
this->setModelDescription(stashModel, description);
|
||||
}
|
||||
autoStashed.push_back(stashModel);
|
||||
}
|
||||
|
||||
@@ -260,10 +276,17 @@ namespace BlackGui
|
||||
this->m_state = Completed;
|
||||
}
|
||||
|
||||
bool CDbAutoStashingComponent::tryToStashModel(CAircraftModel &model)
|
||||
bool CDbAutoStashingComponent::tryToStashModel(CAircraftModel &model, const CLivery &tempLivery)
|
||||
{
|
||||
const bool useTempLivery = tempLivery.isLoadedFromDb();
|
||||
bool stashed = false;
|
||||
|
||||
// no airline and no livery, here replaced by temp livery
|
||||
if (useTempLivery && !model.hasAirlineDesignator() && !model.getLivery().hasValidDbKey())
|
||||
{
|
||||
model.setLivery(tempLivery);
|
||||
}
|
||||
|
||||
//! Some upfront tests
|
||||
if (!model.hasModelString())
|
||||
{
|
||||
@@ -304,6 +327,27 @@ namespace BlackGui
|
||||
return stashed;
|
||||
}
|
||||
|
||||
void CDbAutoStashingComponent::setModelDescription(CAircraftModel &model, const QString &description) const
|
||||
{
|
||||
if (description.isEmpty()) { return; }
|
||||
if (ui->rb_All->isChecked())
|
||||
{
|
||||
model.setDescription(description);
|
||||
}
|
||||
else
|
||||
{
|
||||
// only for "empty" ones
|
||||
if (model.hasDescription(true)) { return; }
|
||||
model.setDescription(description);
|
||||
}
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CLivery CDbAutoStashingComponent::getTempLivery()
|
||||
{
|
||||
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()}));
|
||||
|
||||
@@ -30,11 +30,9 @@ namespace BlackMisc
|
||||
namespace Simulation { class CAircraftModel; }
|
||||
}
|
||||
namespace Ui { class CDbAutoStashingComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views { class CAircraftModelView; }
|
||||
|
||||
namespace Components
|
||||
{
|
||||
/*!
|
||||
@@ -78,6 +76,9 @@ namespace BlackGui
|
||||
//! Data have been read
|
||||
void ps_entitiesRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
|
||||
|
||||
//! Reset the description settings
|
||||
void ps_resetDescription();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDbAutoStashingComponent> ui;
|
||||
|
||||
@@ -105,7 +106,13 @@ namespace BlackGui
|
||||
//! Try stashing a model
|
||||
//! \param model this model can be updated with consolidated data
|
||||
//! \return true means stashing is possible
|
||||
bool tryToStashModel(BlackMisc::Simulation::CAircraftModel &model);
|
||||
bool tryToStashModel(BlackMisc::Simulation::CAircraftModel &model, const BlackMisc::Aviation::CLivery &tempLivery);
|
||||
|
||||
//! Set the model description
|
||||
void setModelDescription(BlackMisc::Simulation::CAircraftModel &model, const QString &description) const;
|
||||
|
||||
//! Get the temp.livery if available
|
||||
static BlackMisc::Aviation::CLivery getTempLivery();
|
||||
|
||||
//! Categories
|
||||
const BlackMisc::CLogCategoryList &categgories();
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>357</height>
|
||||
<width>453</width>
|
||||
<height>413</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -16,48 +16,14 @@
|
||||
<layout class="QVBoxLayout" name="vl_AutoStashing">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gl_AutoStashing">
|
||||
<item row="6" column="0" colspan="4">
|
||||
<widget class="QProgressBar" name="pb_StashingProgress">
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLineEdit" name="le_All">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2" alignment="Qt::AlignLeft">
|
||||
<widget class="QCheckBox" name="cb_RemovedChecked">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_Description">
|
||||
<property name="text">
|
||||
<string>Remove stashed</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="lbl_Max">
|
||||
<property name="text">
|
||||
<string>Max stashed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLineEdit" name="le_MaxModelsStashed">
|
||||
<property name="placeholderText">
|
||||
<string>max.models stashed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="4">
|
||||
<item row="5" column="0" colspan="4">
|
||||
<widget class="BlackGui::Views::CStatusMessageView" name="tvp_StatusMessages">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
@@ -67,7 +33,14 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2" colspan="2">
|
||||
<item row="0" column="2">
|
||||
<widget class="QRadioButton" name="rb_All">
|
||||
<property name="text">
|
||||
<string>All:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="bb_AutoStashing">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@@ -77,10 +50,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QRadioButton" name="rb_All">
|
||||
<property name="text">
|
||||
<string>All:</string>
|
||||
<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>
|
||||
@@ -94,23 +70,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_Description">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="3">
|
||||
<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="0">
|
||||
<widget class="QRadioButton" name="rb_Selected">
|
||||
<property name="text">
|
||||
@@ -121,7 +80,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="4">
|
||||
<item row="6" column="0" colspan="4">
|
||||
<widget class="QFrame" name="fr_Statistics">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
@@ -199,6 +158,106 @@
|
||||
</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">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Max">
|
||||
<property name="text">
|
||||
<string>Max stashed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLineEdit" name="le_All">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2" alignment="Qt::AlignLeft">
|
||||
<widget class="QCheckBox" name="cb_RemovedChecked">
|
||||
<property name="text">
|
||||
<string>Remove stashed</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Livery">
|
||||
<property name="text">
|
||||
<string>Livery:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="cb_UseTempLivery">
|
||||
<property name="text">
|
||||
<string>use 'temp' livery if not resolved</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -210,6 +269,23 @@
|
||||
<header>blackgui/views/statusmessageview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>rb_Selected</tabstop>
|
||||
<tabstop>le_Selected</tabstop>
|
||||
<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>
|
||||
<tabstop>le_NoData</tabstop>
|
||||
<tabstop>le_ValidationFailed</tabstop>
|
||||
<tabstop>cb_RemovedChecked</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
|
||||
Reference in New Issue
Block a user