swift
dbmodelworkbenchcomponent.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #include <QAction>
7 #include <QDir>
8 #include <QFileDialog>
9 #include <QIcon>
10 #include <QPointer>
11 #include <QtGlobal>
12 
13 #include "ui_dbmodelworkbenchcomponent.h"
14 
15 #include "core/db/databaseutils.h"
16 #include "core/webdataservices.h"
19 #include "gui/guiapplication.h"
20 #include "gui/menus/aircraftmodelmenus.h"
21 #include "gui/menus/menuaction.h"
24 #include "misc/icons.h"
25 #include "misc/logmessage.h"
26 #include "misc/statusmessage.h"
27 
28 using namespace swift::misc;
29 using namespace swift::misc::simulation;
30 using namespace swift::core::db;
31 using namespace swift::gui::menus;
32 using namespace swift::gui::views;
33 using namespace swift::gui::models;
34 
35 namespace swift::gui::components
36 {
37  CDbModelWorkbenchComponent::CDbModelWorkbenchComponent(QWidget *parent)
39  {
40  ui->setupUi(this);
41 
42  ui->tvp_Models->menuAddItems(CAircraftModelView::MenuStashing);
43  ui->tvp_Models->setAircraftModelMode(CAircraftModelListModel::OwnAircraftModelMappingTool);
44  ui->tvp_Models->addFilterDialog();
45  ui->tvp_Models->setDisplayAutomatically(true);
46  ui->tvp_Models->allowDragDrop(false, true, true);
47  ui->tvp_Models->setAcceptedMetaTypeIds();
48 
49  // menu
50  ui->tvp_Models->setCustomMenu(new CConsolidateWithDbDataMenu(ui->tvp_Models, this));
51  }
52 
54 
56  {
57  static const QStringList l({ CLogCategories::modelGui(), CLogCategories::guiComponent() });
58  return l;
59  }
60 
61  CAircraftModelView *CDbModelWorkbenchComponent::view() const { return ui->tvp_Models; }
62 
63  CAircraftModelListModel *CDbModelWorkbenchComponent::model() const { return ui->tvp_Models->derivedModel(); }
64 
66  {
67  return this->getModels().findFirstByModelStringOrDefault(modelString);
68  }
69 
71  {
72  return ui->tvp_Models->selectedObjects();
73  }
74 
75  CAircraftModelList CDbModelWorkbenchComponent::getModels() const { return ui->tvp_Models->container(); }
76 
77  int CDbModelWorkbenchComponent::getModelsCount() const { return ui->tvp_Models->rowCount(); }
78 
80  const CSimulatorInfo &simulator)
81  {
82  Q_UNUSED(simulator);
83  ui->tvp_Models->replaceOrAddModelsWithString(models);
84  }
85 
87  const CSimulatorInfo &simulator)
88  {
89  Q_UNUSED(simulator);
90  return ui->tvp_Models->replaceOrAddModelsWithString(models);
91  }
92 } // namespace swift::gui::components
Using this class provides a QFrame with the overlay functionality already integrated.
Handling of own models on disk (the models installed for the simulator)
swift::misc::simulation::CAircraftModelList getModels() const
Models.
swift::gui::views::CAircraftModelView * view() const
Models view.
swift::misc::simulation::CAircraftModelList getSelectedModels() const
Own models selected in view.
int updateModelsForSimulator(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator)
Set models.
swift::misc::simulation::CAircraftModel getOwnModelForModelString(const QString &modelString) const
Own (installed) model for given model string.
static const QStringList & getLogCategories()
Log categories.
models::CAircraftModelListModel * model() const
Access to aircraft model.
void setModelsForSimulator(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator)
Set models.
Aircraft model (used by another pilot, my models on disk)
Definition: aircraftmodel.h:71
Value object encapsulating a list of aircraft models.
CAircraftModel findFirstByModelStringOrDefault(const QString &modelString, Qt::CaseSensitivity sensitivity=Qt::CaseInsensitive) const
Find first by model string.
Simple hardcoded info about the corresponding simulator.
Definition: simulatorinfo.h:41
Classes interacting with the swift database (aka "datastore").
High level reusable GUI components.
Definition: aboutdialog.cpp:14
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.