swift
Loading...
Searching...
No Matches
dbstashcomponent.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <iterator>
7
8#include <QCheckBox>
9#include <QMessageBox>
10#include <QPushButton>
11#include <QStringBuilder>
12#include <QWidget>
13#include <Qt>
14#include <QtGlobal>
15
16#include "ui_dbstashcomponent.h"
17
18#include "core/application.h"
23#include "gui/guiapplication.h"
26#include "gui/views/viewbase.h"
29#include "misc/logcategories.h"
30#include "misc/sequence.h"
33#include "misc/verify.h"
34
35using namespace swift::core;
36using namespace swift::core::db;
37using namespace swift::misc;
38using namespace swift::misc::simulation;
39using namespace swift::misc::aviation;
40using namespace swift::misc::network;
41using namespace swift::gui;
42using namespace swift::gui::models;
43using namespace swift::gui::views;
44
46{
49 {
50 ui->setupUi(this);
51
52 connect(ui->pb_Unstash, &QPushButton::pressed, this, &CDbStashComponent::onUnstashPressed);
53 connect(ui->pb_Validate, &QPushButton::pressed, this, &CDbStashComponent::onValidatePressed);
54 connect(ui->pb_RemoveInvalid, &QPushButton::pressed, this, &CDbStashComponent::onRemoveInvalidPressed);
55 connect(ui->pb_Publish, &QPushButton::pressed, this, &CDbStashComponent::onPublishPressed);
56 connect(ui->tvp_StashAircraftModels, &CAircraftModelView::modelChanged, this,
58 connect(ui->tvp_StashAircraftModels, &CAircraftModelView::modelDataChanged, this,
59 &CDbStashComponent::onRowCountChanged);
60
61 // copy over buttons
62 connect(ui->pb_AircraftIcao, &QPushButton::pressed, this, &CDbStashComponent::copyOverValuesToSelectedModels);
63 connect(ui->pb_AirlineIcao, &QPushButton::pressed, this, &CDbStashComponent::copyOverValuesToSelectedModels);
64 connect(ui->pb_Livery, &QPushButton::pressed, this, &CDbStashComponent::copyOverValuesToSelectedModels);
65 connect(ui->pb_Distributor, &QPushButton::pressed, this, &CDbStashComponent::copyOverValuesToSelectedModels);
66 connect(ui->pb_Model, &QPushButton::pressed, this, &CDbStashComponent::modifyModelDialog);
67
68 ui->tvp_StashAircraftModels->setAircraftModelMode(CAircraftModelListModel::StashModel);
69 ui->tvp_StashAircraftModels->allowDragDrop(false, true, true);
70 ui->tvp_StashAircraftModels->setAcceptedMetaTypeIds();
71 ui->tvp_StashAircraftModels->menuAddItems(CAircraftModelView::MenuLoadAndSave);
72 ui->tvp_StashAircraftModels->menuAddItems(CAircraftModelView::MenuRemoveSelectedRows);
73 ui->tvp_StashAircraftModels->setHighlight(true);
74 ui->tvp_StashAircraftModels->setHighlightColor(Qt::red);
75 ui->tvp_StashAircraftModels->setSettingsDirectoryIndex(CDirectories::IndexDirLastModelStashJsonOrDefault);
76 this->enableButtonRow();
77
78 connect(sApp->getWebDataServices()->getDatabaseWriter(), &CDatabaseWriter::publishedModels, this,
79 &CDbStashComponent::onPublishedModelsResponse, Qt::QueuedConnection);
80 this->onUserChanged();
81 }
82
84
86 {
87 if (!allowReplace && ui->tvp_StashAircraftModels->container().containsModelStringOrDbKey(model))
88 {
89 const QString msg("Model '%1' already stashed");
90 return { validationCategories(), CStatusMessage::SeverityError, msg.arg(model.getModelString()) };
91 }
92 return {};
93 }
94
95 CStatusMessage CDbStashComponent::stashModel(const CAircraftModel &model, bool replace, bool consolidateWithDbData,
96 bool clearHighlighting)
97 {
98 const CAircraftModel stashModel(consolidateWithDbData ? this->consolidateModel(model) : model);
99 const CStatusMessage m(this->validateStashModel(stashModel, replace));
100 if (!m.isWarningOrAbove())
101 {
102 if (clearHighlighting)
103 {
105 }
106 if (replace)
107 {
108 ui->tvp_StashAircraftModels->replaceOrAdd(&CAircraftModel::getModelString, stashModel.getModelString(),
109 stashModel);
110 }
111 else
112 {
113 ui->tvp_StashAircraftModels->insert(stashModel);
114 }
115 }
116 return m;
117 }
118
120 bool consolidateWithDbData, bool clearHighlighting)
121 {
122 if (models.isEmpty())
123 {
124 return {};
125 }
127 int successfullyAdded = 0;
128 for (const CAircraftModel &model : models)
129 {
130 const CStatusMessage m(this->stashModel(model, replace, consolidateWithDbData, false));
131 if (m.isWarningOrAbove())
132 {
133 msgs.push_back(m);
134 }
135 else
136 {
137 successfullyAdded++;
138 }
139 }
140 if (successfullyAdded > 0 && clearHighlighting)
141 {
143 }
144 return msgs;
145 }
146
148 {
149 ui->tvp_StashAircraftModels->updateContainerMaybeAsync(models);
150 }
151
153 {
154 if (keys.isEmpty())
155 {
156 return 0;
157 }
158 return ui->tvp_StashAircraftModels->removeDbKeys(keys);
159 }
160
162 {
163 if (modelStrings.isEmpty())
164 {
165 return 0;
166 }
167 return ui->tvp_StashAircraftModels->removeModelsWithModelString(modelStrings);
168 }
169
171 {
172 if (models.isEmpty())
173 {
174 return 0;
175 }
176 return ui->tvp_StashAircraftModels->removeModelsWithModelString(models);
177 }
178
179 CAircraftModelView *CDbStashComponent::view() const { return ui->tvp_StashAircraftModels; }
180
181 bool CDbStashComponent::hasStashedModels() const { return !ui->tvp_StashAircraftModels->isEmpty(); }
182
183 int CDbStashComponent::getStashedModelsCount() const { return ui->tvp_StashAircraftModels->rowCount(); }
184
186 {
187 return ui->tvp_StashAircraftModels->derivedModel()->getModelStrings(false);
188 }
189
191 {
192 return ui->tvp_StashAircraftModels->derivedModel()->container();
193 }
194
196 {
197 if (modelString.isEmpty() || ui->tvp_StashAircraftModels->isEmpty())
198 {
199 return {};
200 }
201 return ui->tvp_StashAircraftModels->container().findFirstByModelStringOrDefault(modelString);
202 }
203
204 void CDbStashComponent::applyToSelected(const CLivery &livery, bool acceptWarnings)
205 {
206 if (!ui->tvp_StashAircraftModels->hasSelection())
207 {
208 return;
209 }
210 CStatusMessageList msgs(livery.validate());
211 if (this->showOverlayMessages(msgs, acceptWarnings))
212 {
213 return;
214 }
215 ui->tvp_StashAircraftModels->applyToSelected(livery);
216 }
217
218 void CDbStashComponent::applyToSelected(const CAircraftIcaoCode &icao, bool acceptWarnings)
219 {
220 if (!ui->tvp_StashAircraftModels->hasSelection())
221 {
222 return;
223 }
224 CStatusMessageList msgs(icao.validate());
225 if (this->showOverlayMessages(msgs, acceptWarnings))
226 {
227 return;
228 }
229 ui->tvp_StashAircraftModels->applyToSelected(icao);
230 }
231
232 void CDbStashComponent::applyToSelected(const CAirlineIcaoCode &icao, bool acceptWarnings)
233 {
234 if (!icao.hasValidDesignator())
235 {
236 static const CStatusMessage msg(CStatusMessage::SeverityError, u"No valid designator");
237 this->showOverlayMessage(msg);
238 return;
239 }
240
241 // retrieve the std livery
242 const CLivery stdLivery(sApp->getWebDataServices()->getStdLiveryForAirlineCode(icao));
243 if (!stdLivery.hasValidDbKey())
244 {
246 u"No valid standard livery for " % icao.getDesignator());
247 this->showOverlayMessage(msg);
248 return;
249 }
250
251 applyToSelected(stdLivery, acceptWarnings);
252 }
253
254 void CDbStashComponent::applyToSelected(const CDistributor &distributor, bool acceptWarnings)
255 {
256 if (!ui->tvp_StashAircraftModels->hasSelection())
257 {
258 return;
259 }
260 CStatusMessageList msgs(distributor.validate());
261 if (this->showOverlayMessages(msgs, acceptWarnings))
262 {
263 return;
264 }
265 ui->tvp_StashAircraftModels->applyToSelected(distributor);
266 }
267
269 {
270 if (vm.isEmpty())
271 {
272 return;
273 }
274 if (!ui->tvp_StashAircraftModels->hasSelection())
275 {
276 return;
277 }
278 ui->tvp_StashAircraftModels->applyToSelected(vm);
279 }
280
281 void CDbStashComponent::onUnstashPressed() { ui->tvp_StashAircraftModels->removeSelectedRows(); }
282
283 void CDbStashComponent::onValidatePressed()
284 {
285 if (ui->tvp_StashAircraftModels->isEmpty())
286 {
287 return;
288 }
289 CAircraftModelList validModels;
290 CAircraftModelList invalidModels;
291 this->validateAndDisplay(validModels, invalidModels, true);
292 }
293
294 void CDbStashComponent::onRemoveInvalidPressed()
295 {
296 if (ui->tvp_StashAircraftModels->isEmpty())
297 {
298 return;
299 }
300 CAircraftModelList validModels;
301 CAircraftModelList invalidModels;
302 this->validate(validModels, invalidModels);
303 this->unstashModels(invalidModels);
304 }
305
306 void CDbStashComponent::onPublishPressed()
307 {
309 {
310 return;
311 }
312 if (ui->tvp_StashAircraftModels->isEmpty())
313 {
314 return;
315 }
317 {
318 return;
319 }
320
321 // get models right here, because later steps might affect selection
322 const CAircraftModelList models(getSelectedOrAllModels());
323 if (models.isEmpty())
324 {
325 return;
326 }
327
328 // validate
329 CAircraftModelList validModels;
330 CAircraftModelList invalidModels;
331 if (!this->validateAndDisplay(validModels, invalidModels))
332 {
333 return;
334 }
335 CStatusMessageList msgs;
336 if (validModels.size() > MaxModelPublished)
337 {
338 validModels.truncate(MaxModelPublished);
339 msgs.push_back(CStatusMessage(validationCategories(), CStatusMessage::SeverityWarning,
340 u"More than %1 values, values skipped")
342 }
343
345 if (msgs.hasWarningOrErrorMessages())
346 {
347 this->showOverlayMessages(msgs);
348 }
349 else
350 {
351 ui->tvp_StashAircraftModels->showLoadIndicator();
352 }
353 }
354
355 void CDbStashComponent::onPublishedModelsResponse(const CAircraftModelList &publishedModels,
356 const CAircraftModelList &skippedModels,
357 const CStatusMessageList &msgs, bool sendingSuccesful,
358 bool directWrite)
359 {
360 Q_UNUSED(skippedModels);
361 ui->tvp_StashAircraftModels->hideLoadIndicator();
362 if (!publishedModels.isEmpty() && sendingSuccesful)
363 {
364 emit this->modelsSuccessfullyPublished(publishedModels, directWrite);
365 }
366
367 if (!msgs.isEmpty())
368 {
369 if (publishedModels.isEmpty())
370 {
371 this->showOverlayMessages(msgs, false, false);
372 }
373 else
374 {
375 QPointer<CDbStashComponent> myself(this);
376 const QString confirm("Remove %1 published models from stash?");
377 auto lambda = [=]() {
378 if (!myself)
379 {
380 return;
381 }
382 myself->unstashModels(publishedModels.getModelStringList(false));
383 };
384 this->showOverlayMessagesWithConfirmation(msgs, false, confirm.arg(publishedModels.size()), lambda,
386 }
387 }
388 }
389
390 CStatusMessageList CDbStashComponent::validate(CAircraftModelList &validModels,
391 CAircraftModelList &invalidModels) const
392 {
393 if (ui->tvp_StashAircraftModels->isEmpty())
394 {
395 return {};
396 }
397 Q_ASSERT_X(sGui->getWebDataServices(), Q_FUNC_INFO, "No web services");
398 const CAircraftModelList models(getSelectedOrAllModels());
399 if (models.isEmpty())
400 {
401 return {};
402 }
403 const bool ignoreEqual = ui->cb_ChangedOnly->isChecked();
404 const CStatusMessageList msgs(
405 sGui->getWebDataServices()->validateForPublishing(models, ignoreEqual, validModels, invalidModels));
406
407 // OK?
408 if (msgs.isEmpty())
409 {
410 return CStatusMessageList(
411 { CStatusMessage(validationCategories(), CStatusMessage::SeverityInfo, u"No errors in %1 model(s)")
412 << models.size() });
413 }
414 else
415 {
416 return msgs;
417 }
418 }
419
420 bool CDbStashComponent::validateAndDisplay(CAircraftModelList &validModels, CAircraftModelList &invalidModels,
421 bool displayInfo)
422 {
423 const CStatusMessageList msgs(this->validate(validModels, invalidModels));
424 if (msgs.hasWarningOrErrorMessages())
425 {
426 this->showOverlayMessages(msgs);
427 ui->tvp_StashAircraftModels->setHighlightModelStrings(invalidModels.getModelStringList(false));
428 }
429 else
430 {
431 // delete highlighting because no errors
432 ui->tvp_StashAircraftModels->clearHighlighting();
433 if (displayInfo)
434 {
435 const QString no = QString::number(this->getStashedModelsCount());
436 const CStatusMessage msg(validationCategories(), CStatusMessage::SeverityInfo,
437 "Validation passed for " + no + " models");
438 this->showOverlayMessage(msg);
439 }
440 }
441 return !validModels.isEmpty(); // at least some valid objects
442 }
443
444 void CDbStashComponent::enableButtonRow()
445 {
446 const bool e = !ui->tvp_StashAircraftModels->isEmpty();
447 ui->pb_AircraftIcao->setEnabled(e);
448 ui->pb_AirlineIcao->setEnabled(e);
449 ui->pb_Distributor->setEnabled(e);
450 ui->pb_Livery->setEnabled(e);
451 ui->pb_Unstash->setEnabled(e);
452 ui->pb_Validate->setEnabled(e);
453 ui->pb_RemoveInvalid->setEnabled(e);
454 ui->pb_Model->setEnabled(e);
455 ui->pb_Publish->setEnabled(e);
456 this->onUserChanged();
457 }
458
459 const CLogCategoryList &CDbStashComponent::validationCategories() const
460 {
461 static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
462 return cats;
463 }
464
465 CAircraftModelList CDbStashComponent::getSelectedOrAllModels() const
466 {
467 const bool selectedOnly = ui->cb_SelectedOnly->isChecked();
468 const CAircraftModelList models(selectedOnly ? ui->tvp_StashAircraftModels->selectedObjects() :
469 ui->tvp_StashAircraftModels->containerOrFilteredContainer());
470 return models;
471 }
472
473 CAircraftModel CDbStashComponent::consolidateWithDbData(const CAircraftModel &model, bool forced) const
474 {
475 const CAircraftModel consolidatedModel = CDatabaseUtils::consolidateModelWithDbData(model, forced);
476 return consolidatedModel;
477 }
478
479 CAircraftModel CDbStashComponent::consolidateWithOwnModels(const CAircraftModel &model) const
480 {
481 if (!model.hasModelString())
482 {
483 return model;
484 }
486 {
487 return model;
488 }
489 CAircraftModel ownModel(this->getMappingComponent()->getOwnModelForModelString(model.getModelString()));
490 if (!ownModel.hasModelString())
491 {
492 return model;
493 }
494 ownModel.updateMissingParts(model);
495 return ownModel;
496 }
497
498 CAuthenticatedUser CDbStashComponent::getSwiftDbUser() const { return m_swiftDbUser.get(); }
499
501 {
503 const bool ownModel = stashModel.getModelType() == CAircraftModel::TypeOwnSimulatorModel;
504
505 // merge/update with DB data if any
506 // this is a forced update with DB data, as DB data can change
507 stashModel = this->consolidateWithDbData(stashModel, true);
508
509 // merge with own models if any
510 if (!ownModel)
511 {
512 stashModel = this->consolidateWithOwnModels(stashModel);
513 }
514
515 return stashModel;
516 }
517
519 {
520 if (!sGui || !sGui->hasWebDataServices())
521 {
522 return;
523 }
524 if (sGui->isShuttingDown())
525 {
526 return;
527 }
528 const CAircraftModelList models = ui->tvp_StashAircraftModels->selectedObjects();
529 if (models.isEmpty())
530 {
531 return;
532 }
533
535 for (const CAircraftModel &model : models)
536 {
537 CStatusMessageList modelMsgs;
538 const bool equal = sGui->getWebDataServices()->isDbModelEqualForPublishing(model, &modelMsgs);
539 if (equal)
540 {
541 msgs.push_back(CStatusMessage(this).info(u"Model '%1' has no change values")
542 << model.getModelStringAndDbKey());
543 }
544 else
545 {
546 msgs.push_back(modelMsgs);
547 }
548 }
549 this->showOverlayMessages(msgs);
550 }
551
552 void CDbStashComponent::clearValidationHighlighting() { ui->tvp_StashAircraftModels->clearHighlighting(); }
553
554 void CDbStashComponent::copyOverValuesToSelectedModels()
555 {
556 const QObject *sender = QObject::sender();
557 SWIFT_VERIFY_X(this->getMappingComponent(), Q_FUNC_INFO, "Missing mapping component");
558 if (!this->getMappingComponent())
559 {
560 return;
561 }
562 if (!ui->tvp_StashAircraftModels->hasSelection())
563 {
564 return;
565 }
566
567 const CAircraftModel model(this->getMappingComponent()->getEditorAircraftModel());
568 if (sender == ui->pb_AircraftIcao)
569 {
571 }
572 else if (sender == ui->pb_AirlineIcao)
573 {
574 this->applyToSelected(model.getAirlineIcaoCode());
575 }
576 else if (sender == ui->pb_Distributor)
577 {
578 this->applyToSelected(model.getDistributor());
579 }
580 else if (sender == ui->pb_Livery)
581 {
582 this->applyToSelected(model.getLivery());
583 }
584 }
585
586 void CDbStashComponent::modifyModelDialog()
587 {
588 if (this->getMappingComponent())
589 {
591 }
592 }
593
594 void CDbStashComponent::onRowCountChanged(int number, bool filter)
595 {
596 Q_UNUSED(number);
597 Q_UNUSED(filter);
598 this->enableButtonRow();
599 }
600
601 void CDbStashComponent::onUserChanged()
602 {
603 const CAuthenticatedUser user(this->getSwiftDbUser());
604 if (!user.isAuthenticated())
605 {
606 ui->pb_Publish->setText(" Publish (login) ");
607 ui->pb_Publish->setToolTip("Login first");
608 ui->pb_Publish->setEnabled(false);
609 }
610 else if (user.canDirectlyWriteModels())
611 {
612 ui->pb_Publish->setText(" Publish (dir.) ");
613 ui->pb_Publish->setToolTip("Models directly released");
614 ui->pb_Publish->setEnabled(true);
615 }
616 else
617 {
618 ui->pb_Publish->setText(" Publish (CR) ");
619 ui->pb_Publish->setToolTip("Models published as change request");
620 ui->pb_Publish->setEnabled(true);
621 }
622 }
623
624 bool CDbStashComponent::showOverlayMessages(const CStatusMessageList &msgs, bool onlyErrors, bool appendOldMessages,
625 std::chrono::milliseconds timeout)
626 {
627 if (msgs.isEmpty())
628 {
629 return false;
630 }
631 if (!msgs.hasErrorMessages() && onlyErrors)
632 {
633 return false;
634 }
635 SWIFT_VERIFY_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
636 if (!this->getMappingComponent())
637 {
638 return false;
639 }
640
641 this->getMappingComponent()->showOverlayMessages(msgs, appendOldMessages, timeout);
642 return true;
643 }
644
645 bool CDbStashComponent::showOverlayMessagesWithConfirmation(const CStatusMessageList &msgs, bool appendOldMessages,
646 const QString &confirmation,
647 std::function<void()> okLambda,
648 QMessageBox::StandardButton defaultButton,
649 bool onlyErrors, std::chrono::milliseconds timeout)
650 {
651 if (msgs.isEmpty())
652 {
653 return false;
654 }
655 if (!msgs.hasErrorMessages() && onlyErrors)
656 {
657 return false;
658 }
659 SWIFT_VERIFY_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
660 if (!this->getMappingComponent())
661 {
662 return false;
663 }
664 this->getMappingComponent()->showOverlayMessagesWithConfirmation(msgs, appendOldMessages, confirmation,
665 okLambda, defaultButton, timeout);
666 return true;
667 }
668
669 bool CDbStashComponent::showOverlayMessage(const CStatusMessage &msg, std::chrono::milliseconds timeout)
670 {
671 if (msg.isEmpty())
672 {
673 return false;
674 }
675 SWIFT_VERIFY_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
676 if (!this->getMappingComponent())
677 {
678 return false;
679 }
680 this->getMappingComponent()->showOverlayMessage(msg, timeout);
681 return true;
682 }
683
684 void CDbStashComponent::clearOverlayMessages()
685 {
686 SWIFT_VERIFY_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
687 if (!this->getMappingComponent())
688 {
689 return;
690 }
692 }
693} // namespace swift::gui::components
bool hasWebDataServices() const
Web data services available?
bool isShuttingDown() const
Is application shutting down?
CWebDataServices * getWebDataServices() const
Get the web data services.
swift::misc::CStatusMessageList asyncPublishModels(const swift::misc::simulation::CAircraftModelList &modelsToBePublished) const
Publish models to database.
swift::misc::CStatusMessageList validateForPublishing(const swift::misc::simulation::CAircraftModelList &modelsToBePublished, bool ignoreEqual, swift::misc::simulation::CAircraftModelList &validModels, swift::misc::simulation::CAircraftModelList &invalidModels) const
Validate for publishing.
static swift::misc::simulation::CAircraftModel consolidateModelWithDbData(const swift::misc::simulation::CAircraftModel &model, bool force, bool *modified=nullptr)
Consolidate model data with DB data.
void publishedModels(const swift::misc::simulation::CAircraftModelList &modelsPublished, const swift::misc::simulation::CAircraftModelList &modelsSkipped, const swift::misc::CStatusMessageList &messages, bool sendingSuccessful, bool directWrite)
Published models, the response to.
bool hasMinimumMappingVersion() const
Minimum mapping version check.
void clearOverlayMessages()
Clear the overlay messages.
bool showOverlayMessage(const swift::misc::CStatusMessage &message, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show single message.
void showOverlayMessages(const swift::misc::CStatusMessageList &messages, bool appendOldMessages=false, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages.
void showOverlayMessagesWithConfirmation(const swift::misc::CStatusMessageList &messages, bool appendOldMessages, const QString &confirmationMessage, std::function< void()> okLambda, QMessageBox::StandardButton defaultButton=QMessageBox::Cancel, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages with confirmation bar.
CDbMappingComponent * getMappingComponent() const
Get the mapping component.
void modifyModelDialog()
Open model modify dialog.
static constexpr int MaxModelPublished
Number of models which can be published at once.
void stashedModelsChanged()
Stashed models have been changed.
void showChangedAttributes()
Show changed attributes of selected models.
int unstashModels(const QSet< int > &keys)
Unstash given models with keys.
int getStashedModelsCount() const
Number of models.
swift::misc::simulation::CAircraftModel getStashedModel(const QString &modelString) const
Model for model string.
swift::gui::views::CAircraftModelView * view() const
The embedded view.
void applyToSelected(const swift::misc::aviation::CLivery &livery, bool acceptWarnings=true)
Apply livery to selected objects.
bool hasStashedModels() const
Has stashed models.
swift::misc::CStatusMessage stashModel(const swift::misc::simulation::CAircraftModel &model, bool replace=false, bool consolidateWithDbData=true, bool clearHighlighting=true)
Stash given model (includes validation and consolidation with DB data).
swift::misc::CStatusMessage validateStashModel(const swift::misc::simulation::CAircraftModel &model, bool allowReplace) const
Test the given model if it can be stashed.
swift::misc::simulation::CAircraftModel consolidateModel(const swift::misc::simulation::CAircraftModel &model) const
Consolidate with other available data.
const swift::misc::simulation::CAircraftModelList & getStashedModels() const
The stashed models.
void modelsSuccessfullyPublished(const swift::misc::simulation::CAircraftModelList &publishedModels, bool directWrite)
Models succesfully published.
swift::misc::CStatusMessageList stashModels(const swift::misc::simulation::CAircraftModelList &models, bool replace=false, bool consolidateWithDbData=true, bool clearHighlighting=true)
Stash given models (includes validation and consolidation with DB data).
void clearValidationHighlighting()
Clear highlighting set by validations.
void replaceModelsUnvalidated(const swift::misc::simulation::CAircraftModelList &models)
Replace models, no validation.
CDbStashComponent(QWidget *parent=nullptr)
Constructor.
QStringList getStashedModelStrings() const
Stashed model strings.
bool isEmpty() const
Empty?
Definition viewbase.cpp:481
void modelChanged()
Model bas been changed (means data in view have been changed).
void modelDataChanged(int count, bool withFilter)
Model data changed.
@ MenuRemoveSelectedRows
allow to remove selected rows
Definition viewbase.h:121
bool isEmpty() const
Message empty.
Specialized value object compliant map for variants, based on indexes.
size_type size() const
Returns number of elements in the sequence.
Definition sequence.h:273
void truncate(size_type maxSize)
Changes the size of the sequence, if it is bigger than the given size.
Definition sequence.h:291
void push_back(const T &value)
Appends an element at the end of the sequence.
Definition sequence.h:308
bool isEmpty() const
Synonym for empty.
Definition sequence.h:285
Streamable status message, e.g.
bool isWarningOrAbove() const
Warning or above.
static constexpr auto SeverityInfo
Status severities.
static constexpr auto SeverityError
Status severities.
static constexpr auto SeverityWarning
Status severities.
Status messages, e.g. from Core -> GUI.
bool hasWarningOrErrorMessages() const
Warning or error messages.
bool hasErrorMessages() const
Error messages.
const CONTAINER & container() const
Container.
Value object for ICAO classification.
CStatusMessageList validate() const
Validate data.
Value object for ICAO classification.
bool hasValidDesignator() const
Airline designator available?
const QString & getDesignator() const
Get airline, e.g. "DLH".
Value object encapsulating information about an airpot.
Definition livery.h:29
CStatusMessageList validate() const
Validate data.
Definition livery.cpp:132
bool hasValidDbKey() const
Has valid DB key.
Definition datastore.h:102
Aircraft model (used by another pilot, my models on disk).
@ TypeOwnSimulatorModel
represents own simulator model (AI model, model on disk)
const CDistributor & getDistributor() const
Get distributor.
const aviation::CLivery & getLivery() const
Get livery.
const QString & getModelString() const
Model key, either queried or loaded from simulator model.
ModelType getModelType() const
Model type.
QString getModelStringAndDbKey() const
Model string and DB key (if available).
const aviation::CAirlineIcaoCode & getAirlineIcaoCode() const
Airline ICAO code.
bool hasModelString() const
Non empty model string?
const aviation::CAircraftIcaoCode & getAircraftIcaoCode() const
Aircraft ICAO code.
Value object encapsulating a list of aircraft models.
QStringList getModelStringList(bool sort=true) const
Model strings.
Value object encapsulating information of software distributor.
Definition distributor.h:33
swift::misc::CStatusMessageList validate() const
Validate data.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Classes interacting with the swift database (aka "datastore").
Backend services of the swift project, like dealing with the network or the simulators.
Definition actionbind.cpp:7
High level reusable GUI components.
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
GUI related classes.
Free functions in swift::misc.
QFrame(QWidget *parent, Qt::WindowFlags f)
bool isEmpty() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
QObject * sender() const const
bool isEmpty() const const
QString arg(Args &&... args) const const
bool isEmpty() const const
QString number(double n, char format, int precision)
QueuedConnection
QWidget(QWidget *parent, Qt::WindowFlags f)
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.
Definition verify.h:26