6 #include <QIntValidator>
8 #include "ui_dbautosimulatorstashingcomponent.h"
16 using namespace swift::misc::simulation;
20 CDbAutoSimulatorStashingComponent::CDbAutoSimulatorStashingComponent(
QWidget *parent)
21 :
QDialog(parent,
Qt::WindowSystemMenuHint |
Qt::WindowTitleHint),
26 ui->le_MaxModelsStashed->setValidator(
new QIntValidator(
this));
27 ui->tvp_StatusMessages->setMode(swift::gui::models::CStatusMessageListModel::Simplified);
28 ui->le_MaxModelsStashed->setText(
"100");
48 const CStatusMessage stashedMsg(
this, CStatusMessage::SeverityInfo,
49 QStringLiteral(
"Stashed %1 models").arg(m_modelsToStash.
size()));
50 this->addStatusMessage(stashedMsg);
51 m_modelsToStash.
clear();
68 percent = std::clamp(percent, 0, 100);
69 ui->pb_StashingProgress->setValue(percent);
77 void CDbAutoSimulatorStashingComponent::initGui()
80 ui->tvp_StatusMessages->clear();
85 ui->le_AllSets->setText(infoAll);
87 if (!this->currentModelView())
89 const CStatusMessage m(
this, CStatusMessage::SeverityError, u
"No data for simulator updating");
90 this->addStatusMessage(m);
99 void CDbAutoSimulatorStashingComponent::addStatusMessage(
const CStatusMessage &msg)
102 ui->tvp_StatusMessages->insert(msg);
105 void CDbAutoSimulatorStashingComponent::addStatusMessages(
const CStatusMessageList &msgs)
107 if (msgs.
isEmpty()) {
return; }
108 for (
const CStatusMessage &msg : msgs) { this->addStatusMessage(msg); }
118 ui->tvp_StatusMessages->insert(prefixMessage);
120 else { ui->tvp_StatusMessages->insert(msg); }
123 void CDbAutoSimulatorStashingComponent::tryToStash()
127 if (!this->currentModelView()) {
return; }
129 int maxObjectsStashed = -1;
130 if (!ui->le_MaxModelsStashed->text().isEmpty())
133 ui->le_MaxModelsStashed->text().toInt(&ok);
134 if (!ok) { maxObjectsStashed = 100; }
137 const bool selected = ui->rb_SelectedOnly->isChecked();
138 int ownModelsCount = 0;
142 static const QString intro(
"Checking %1 selected models");
144 ownModelsCount = selectedModels.size();
145 this->addStatusMessage(
CStatusMessage(
this, CStatusMessage::SeverityInfo, intro.arg(ownModelsCount)));
147 CDatabaseUtils::updateSimulatorForFsFamily(selectedModels, &info, maxObjectsStashed,
this,
true);
152 const QSet<CSimulatorInfo> fsFamilySims(CSimulatorInfo::allFsFamilySimulators().asSingleSimulatorSet());
153 static const QString intro(
"Checking %1 models for %2");
159 const QString sim = simulator.toQString();
160 ownModelsCount += ownModels.
size();
161 this->addStatusMessage(
162 CStatusMessage(
this, CStatusMessage::SeverityInfo, intro.arg(ownModels.
size()).arg(sim)));
164 CDatabaseUtils::updateSimulatorForFsFamily(ownModels, &info, maxObjectsStashed,
this,
true));
168 const QString result(
"Tested %1 own models, %2 models should be updated in DB");
169 this->addStatusMessages(info);
170 this->addStatusMessage(
Allows to automatically update models if found in own model set, but already existing for a sibling s...
~CDbAutoSimulatorStashingComponent()
Destructor.
void updateProgressIndicator(int percent)
Update the progress indicator 0..100.
Allows subcomponents to gain access to model component.
CDbMappingComponent * getMappingComponent() const
Get the mapping component.
void replaceStashedModelsUnvalidated(const swift::misc::simulation::CAircraftModelList &models) const
Replace models, no validation.
views::CAircraftModelView * currentModelView() const
Current model view.
QString getOwnModelsInfoStringFsFamily() const
Info string without XPlane (FSX,P3D, FS9)
int selectedRowCount() const
Number of selected rows.
bool isEmpty() const
Message empty.
size_type size() const
Returns number of elements in the sequence.
void push_back(const T &value)
Appends an element at the end of the sequence.
void clear()
Removes all elements in the sequence.
bool isEmpty() const
Synonym for empty.
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
Aircraft model (used by another pilot, my models on disk)
QString getMembersDbStatus() const
Info, which members (Livery, Aircraft ICAO, ...) are already based on DB data.
const QString & getModelString() const
Model key, either queried or loaded from simulator model.
bool hasModelString() const
Non empty model string?
Value object encapsulating a list of aircraft models.
Simple hardcoded info about the corresponding simulator.
Classes interacting with the swift database (aka "datastore").
High level reusable GUI components.
Free functions in swift::misc.
QString number(double n, char format, int precision)