swift
Loading...
Searching...
No Matches
dbownmodelsetcomponent.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_GUI_COMPONENTS_CDBOWNMODELSETCOMPONENT_H
7#define SWIFT_GUI_COMPONENTS_CDBOWNMODELSETCOMPONENT_H
8
9#include <QFrame>
10#include <QList>
11#include <QObject>
12#include <QScopedPointer>
13
16#include "gui/menus/menudelegate.h"
23#include "misc/statusmessage.h"
24
25class QAction;
26
27namespace Ui
28{
29 class CDbOwnModelSetComponent;
30}
31namespace swift::misc::simulation
32{
33 class CAircraftModel;
34}
35namespace swift::gui
36{
37 namespace menus
38 {
39 class CMenuActions;
40 }
41 namespace views
42 {
45 } // namespace views
46 namespace components
47 {
53
58 public QFrame,
64 {
72
73 public:
75 explicit CDbOwnModelSetComponent(QWidget *parent = nullptr);
76
79
82
86
90
94
97 int getModelSetCountFromView() const;
98
101 {
102 return this->getCachedModels(m_simulator);
103 }
104
106 int getModelSetCount() const { return this->getCachedModelsCount(m_simulator); }
107
110
113
116
119
121 void setMappingComponent(CDbMappingComponent *component) override;
122
125
129 {
130 this->setModelSet(models, this->getModelSetSimulator());
131 }
133 {
134 return this->replaceOrAddModelSet(models, this->getModelSetSimulator());
135 }
140
141
143 void enableButtons(bool firstSet, bool newSet);
144
148
152
153 private:
155 void tabIndexChanged(int index);
156
158 void buttonClicked();
159
161 void onRowCountChanged(int count, bool withFilter);
162
164 void onJsonDataLoaded(const swift::misc::simulation::CSimulatorInfo &simulator);
165
167 void viewModelChanged();
168
170 void distributorPreferencesChanged();
171
173 void reduceModels();
174
176 void removeExcludedModels();
177
179 void removeNonDBModels();
180
182 void setSaveFileName(const swift::misc::simulation::CSimulatorInfo &simulator);
183
185 void updateViewToCurrentModels();
186
188 void createNewSet();
189
191 void firstSet();
192
194 void copyFromAnotherSwift();
195
197 void showModelStatistics();
198
200 void updateDistributorOrder(const swift::misc::simulation::CSimulatorInfo &simulator);
201
203 bool runsInDialog();
204
206 QScopedPointer<CDbOwnModelSetFormDialog> m_modelSetFormDialog;
207 QScopedPointer<CFirstModelSetDialog> m_firstModelSetDialog;
208 QScopedPointer<CDbReduceModelDuplicates> m_reduceModelsDialog;
211
214 m_distributorPreferences {
215 this, &CDbOwnModelSetComponent::distributorPreferencesChanged
216 };
218 this
219 };
221 this
222 };
223
224 // -------------------------- custom menus -----------------------------------
225
229 class CLoadModelSetMenu : public menus::IMenuDelegate
230 {
231 public:
233 CLoadModelSetMenu(CDbOwnModelSetComponent *ownModelSetComponent)
234 : menus::IMenuDelegate(ownModelSetComponent)
235 {}
236
238 void customMenu(swift::gui::menus::CMenuActions &menuActions) override;
239
240 private:
241 QList<QAction *> m_setActions;
242 QList<QAction *> m_setNewActions;
243 };
244 };
245 } // namespace components
246} // namespace swift::gui
247
248#endif // SWIFT_GUI_COMPONENTS_CDBOWNMODELSETCOMPONENT_H
Allows subcomponents to gain access to model component.
const swift::misc::simulation::CAircraftModelList & getModelSetFromView() const
Current model set for simulator CDbOwnModelSetComponent::getModelSetSimulator.
swift::misc::simulation::CAircraftModelList getModelSet() const
Cached models for current simulator.
int getModelSetCountFromView() const
Current sount of model set for simulator CDbOwnModelSetComponent::getModelSetSimulator.
int replaceOrAddModelSet(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator)
Replace or add models provided for a given simulator.
swift::misc::simulation::CSimulatorInfo getSelectedSimulator() const
Simulator.
void setSimulator(const swift::misc::simulation::CSimulatorInfo &simulator)
Simulator.
swift::misc::CStatusMessage addToModelSet(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator)
Add to model set.
views::CAircraftModelView * view() const
Corresponding view.
void setSimulatorSelectorMode(CSimulatorSelector::Mode mode)
How to display.
void setModels(const swift::misc::simulation::CAircraftModelList &models)
Set models.
swift::misc::simulation::CSimulatorInfo getModelSetSimulator() const
Model set is for simulator.
void setMappingComponent(CDbMappingComponent *component)
Set the corresponding component.
void triggerSetSimulatorDeferred(const swift::misc::simulation::CSimulatorInfo &simulator)
Deferred init of simulator.
CDbOwnModelSetComponent(QWidget *parent=nullptr)
Constructor.
void setModelSet(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator)
Set the model set for a given simulator.
int updateModels(const swift::misc::simulation::CAircraftModelList &models)
Update models.
QString getModelCacheCountAndTimestamp() const
Count and cache timestamp.
int getModelSetCount() const
Cached models count for current simulator.
void enableButtons(bool firstSet, bool newSet)
Enable buttons.
Bunch of CMenuAction objects.
Definition menuaction.h:384
IMenuDelegate(QWidget *parent=nullptr)
Constructor.
Class template for accessing a specific value in the CSettingsCache.
Streamable status message, e.g.
Aircraft model (used by another pilot, my models on disk).
Value object encapsulating a list of aircraft models.
Simple hardcoded info about the corresponding simulator.
Interface to "something" backing models, which can be set.
Interface to "something" backing models, which can be modified (updated).
Interface to "something" backing models, which can be set.
Interface to "something" backing models, which can be modified (updated).
Interface to "something" allowing a simulator selection.
Basically a QObject free (delegate based) version of CCentralMultiSimulatorModelSetCachesProvider.
CAircraftModelList getCachedModels(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
int getCachedModelsCount(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
High level reusable GUI components.
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
GUI related classes.
QFrame(QWidget *parent, Qt::WindowFlags f)
Q_INTERFACES(...)
Q_OBJECTQ_OBJECT
QObject * parent() const const
QString number(double n, char format, int precision)
QWidget(QWidget *parent, Qt::WindowFlags f)