11#include <QStringBuilder>
18#include "gui/menus/menuaction.h"
37using namespace swift::misc::simulation;
38using namespace swift::misc::aviation;
41using namespace swift::gui::menus;
73 m_menus = MenuDefaultNoClear | MenuStashing | MenuLoadAndSave;
128 m_model->setAcceptedMetaTypeIds({
129 qMetaTypeId<CAirlineIcaoCode>(),
130 qMetaTypeId<CAirlineIcaoCodeList>(),
131 qMetaTypeId<CAircraftIcaoCode>(),
132 qMetaTypeId<CAircraftIcaoCodeList>(),
133 qMetaTypeId<CLivery>(),
134 qMetaTypeId<CLiveryList>(),
135 qMetaTypeId<CDistributor>(),
136 qMetaTypeId<CDistributorList>(),
137 qMetaTypeId<CAircraftModel>(),
138 qMetaTypeId<CAircraftModelList>(),
157 const int delta =
copy.removeModelsWithString(modelStrings, sensitivity);
179 int c =
copy.replaceOrAddModelsWithString(
models, sensitivity);
204 const int r = this->
rowOf(invaliddModels.
front());
223 m_correspondingSimulator = simulator;
224 m_correspondingSimulatorDir = simDir;
245 const QMimeData *mime =
event->mimeData();
259 if (!
model.hasModelString())
286 if (icao.validate().hasErrorMessages())
295 if (icaos.size() != 1)
309 if (livery.validate().hasErrorMessages())
318 if (liveries.size() != 1)
322 const CLivery livery = liveries.front();
332 if (distributor.validate().hasErrorMessages())
341 if (distributors.size() != 1)
355 if (airline.validate().hasErrorMessages())
365 if (airlines.size() != 1)
391 {
this, &CAircraftModelView::displayModelStatisticsDialog });
392 if (m_withValidationContextMenu)
398 {
this, &CAircraftModelView::displayModelValidationDialog });
410 bool addStashMenu =
false;
417 {
this, &CAircraftModelView::requestedStash });
427 const bool tooMany = selected > 500;
428 const bool canStash = selected > 0 && !tooMany;
443 {
this, &CAircraftModelView::toggleHighlightStashedModels });
459 {
this, &CAircraftModelView::requestTempDisable });
476 if (m_correspondingSimulator.isNoSimulator())
486 const int removed =
models.removeIfNotMatchingSimulator(m_correspondingSimulator);
493 << removed << m_correspondingSimulator.
toQString(
true);
502 if (m_correspondingSimulator.isNoSimulator())
506 if (
models.containsNotMatchingSimulator(m_correspondingSimulator))
527 void CAircraftModelView::toggleHighlightStashedModels()
534 void CAircraftModelView::toggleHighlightInvalidModels()
540 void CAircraftModelView::stashingClearsSelection() { m_stashingClearsSelection = !m_stashingClearsSelection; }
542 void CAircraftModelView::requestedStash()
554 if (m_stashingClearsSelection)
562 void CAircraftModelView::requestTempDisable()
579 u
"Temp.disabled " % selectedModels.getModelStringList(
true).join(
" ")));
583 void CAircraftModelView::displayModelStatisticsDialog()
585 if (!m_statisticsDialog)
587 m_statisticsDialog =
new CAircraftModelStatisticsDialog(
this);
589 m_statisticsDialog->analyzeModels(this->
container());
590 m_statisticsDialog->exec();
593 void CAircraftModelView::displayModelValidationDialog()
595 if (!m_fileValidationDialog)
597 m_fileValidationDialog =
new CAircraftModelValidationDialog(
this);
599 m_fileValidationDialog->setModels(this->
selectedObjects(), m_correspondingSimulator,
600 m_correspondingSimulatorDir);
601 m_fileValidationDialog->triggerValidation(1000);
602 m_fileValidationDialog->exec();
bool isShuttingDown() const
Is application shutting down?
bool displayInStatusBar(const swift::misc::CStatusMessage &message)
direct access to main application window
static QDialog * findParentDialog(QWidget *widget)
Find parent dialog if there is any, otherwise null.
static swift::misc::CVariant fromSwiftDragAndDropData(const QMimeData *mime)
From text dropped.
static bool hasSwiftVariantMimeType(const QMimeData *mime)
Mime data with swift type.
static const QKeySequence & keyStash()
For stashing models.
Form for a aircraft model filter.
Aircraft model list model.
void setAircraftModelMode(CAircraftModelListModel::AircraftModelMode stationMode)
Mode.
void setHighlight(bool highlightModels)
Highlight models.
AircraftModelMode getModelMode() const
Mode.
bool highlightModels() const
Highlight models.
void setHighlightColor(const QBrush &brush)
The highlight color.
AircraftModelMode
How to display.
@ OwnAircraftModelMappingTool
models of my simulator, but in mapping mode
@ VPilotRuleModel
vPilot rule turned into model
@ OwnAircraftModelClient
models existing for my simulator
@ StashModel
stashed models
@ Database
Database entry.
void setHighlightModels(const swift::misc::simulation::CAircraftModelList &highlightModels)
Highlight models.
void replaceOrAddByModelString(const swift::misc::simulation::CAircraftModelList &models)
Replace models with same model string, or just add.
void setHighlightModelStrings(const QStringList &modelStrings=QStringList())
Highlight models.
void customMenu(menus::CMenuActions &menuActions)
Method creating the menu.
bool highlightModels() const
Highlight models.
void setHighlightColor(const QBrush &brush)
The highlight color.
int removeModelsWithModelString(const QStringList &modelStrings, Qt::CaseSensitivity sensitivity=Qt::CaseInsensitive)
Remove models with model strings.
void setAircraftModelMode(models::CAircraftModelListModel::AircraftModelMode mode)
Set display mode.
swift::gui::filters::CAircraftModelFilterDialog * getFilterDialog() const
Filter dialog if any.
void jsonLoadedAndModelUpdated(const swift::misc::simulation::CAircraftModelList &models)
In swift::gui::views::CViewBaseNonTemplate::loadJson the view has been updated because of loaded JSON...
swift::misc::CStatusMessage modifyLoadedJsonData(swift::misc::simulation::CAircraftModelList &models) const
Modify JSON data loaded in swift::gui::views::CViewBaseNonTemplate::loadJson.
swift::misc::CStatusMessage validateLoadedJsonData(const swift::misc::simulation::CAircraftModelList &models) const
Verify JSON data loaded in swift::gui::views::CViewBaseNonTemplate::loadJson.
void setHighlightModelsForInvalidModels()
Set the highlight models based on the saved file.
void requestTempDisableModelsForMatching(const swift::misc::simulation::CAircraftModelList &models)
Temp.disable model.
void dropEvent(QDropEvent *event)
int replaceOrAddModelsWithString(const swift::misc::simulation::CAircraftModelList &models, Qt::CaseSensitivity sensitivity=Qt::CaseInsensitive)
Replace models with sme model string, otherwise add.
void setHighlight(bool highlight)
Highlight models.
void setHighlightModels(const swift::misc::simulation::CAircraftModelList &highlightModelsList)
Highlight models.
void setCorrespondingSimulator(const swift::misc::simulation::CSimulatorInfo &simulator, const QString &simDir)
Corresponding simulator.
void jsonModelsForSimulatorLoaded(const swift::misc::simulation::CSimulatorInfo &simulator)
Models for simulator loaded (JSON).
void toggledHighlightStashedModels()
Highlight stashed models has been toggled.
void requestHandlingOfStashDrop(const swift::misc::aviation::CAirlineIcaoCode &airlineIcao)
Request further handling of drops I cannot handle on my own.
void setHighlightModelStrings(const QStringList &highlightModelsStrings)
Highlight models.
bool hasSelectedModelsToStash() const
Has any models to stash and it is allowed to stash.
int applyToSelected(const swift::misc::aviation::CLivery &livery)
Apply to selected objects.
CAircraftModelView(QWidget *parent=nullptr)
Constructor.
void addFilterDialog()
Add my own filter dialog.
void setAcceptedMetaTypeIds()
Add the technically supported metatypes allowed for drag and drop.
void requestStash(const swift::misc::simulation::CAircraftModelList &models)
Request to stash if applicable.
void customMenu(swift::gui::menus::CMenuActions &menuActions)
Method creating the menu.
COrderableViewWithDbObjects(QWidget *parent=nullptr)
int rowOf(const ObjectType &obj) const
void standardInit(ModelClass *model=nullptr)
void updateContainerMaybeAsync(const ContainerType &container, bool sort=true, bool resize=true)
ContainerType selectedObjects() const
virtual swift::misc::CStatusMessage validateLoadedJsonData(const ContainerType &data) const
Verify JSON data loaded in swift::gui::views::CViewBaseNonTemplate::loadJson.
bool isDropAllowed() const
const ContainerType & container() const
ModelClass * derivedModel()
int updateSelected(const swift::misc::CVariant &variant, const swift::misc::CPropertyIndex &index)
void dropEvent(QDropEvent *event)
menus::IMenuDelegate * setCustomMenu(menus::IMenuDelegate *menu, bool nestPreviousMenu=true)
Set custom menu if applicable.
Menu m_menus
Default menu settings.
int selectedRowCount() const
Number of selected rows.
void setSettingsDirectoryIndex(swift::misc::CDirectories::ColumnIndex directoryIndex)
Index of the directory we "remember".
QMap< MenuFlag, menus::CMenuActions > m_menuFlagActions
initialized actions for menu flag (enum)
QWidget * getFilterWidget() const
Filter widget if any.
menus::CMenuActions initMenuActions(MenuFlag menu)
Init menu actions.
void setFilterDialog(filters::CFilterDialog *filterDialog)
Filter dialog.
@ MenuCanStashModels
stash models
@ MenuHighlightStashed
highlight stashed models
@ MenuBackend
allow to request data from backend
@ MenuDisableModelsTemp
temp.
bool hasSelection() const
Selection (selected rows).
static const QPixmap & appAircraft16()
Application aircrafts.
static const QPixmap & appDbStash16()
Stash.
static const QPixmap & disk16()
Disk.
static const QPixmap & delete16()
Delete.
Specialized value object compliant map for variants, based on indexes.
reference front()
Access the first element.
bool isEmpty() const
Synonym for empty.
Streamable status message, e.g.
static constexpr auto SeverityInfo
Status severities.
static constexpr auto SeverityError
Status severities.
static constexpr auto SeverityDebug
Status severities.
static constexpr auto SeverityWarning
Status severities.
bool hasErrorMessages() const
Error messages.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
static CVariant fromValue(T &&value)
Construct a variant from a value.
T value() const
Return the value converted to the type T.
bool isValid() const
True if this variant is valid.
bool canConvert(int typeId) const
True if this variant can be converted to the type with the given metatype ID.
Value object for ICAO classification.
CStatusMessageList validate() const
Validate data.
Value object encapsulating a list of ICAO codes.
Value object for ICAO classification.
CStatusMessageList validate() const
Validate data.
Value object encapsulating a list of ICAO codes.
Value object encapsulating information about an airpot.
CStatusMessageList validate() const
Validate data.
Value object for a list of airports.
QString toQString(bool i18n=false) const
Cast as QString.
Aircraft model (used by another pilot, my models on disk).
Value object encapsulating a list of aircraft models.
QStringList getModelStringList(bool sort=true) const
Model strings.
static bool hasInvalidModelFile()
Save/load invalid models.
CStatusMessage loadInvalidModels()
Save/load invalid models.
CSimulatorInfo simulatorsWithMaxEntries() const
Which simulator(s) have the most entries?
Value object encapsulating information of software distributor.
swift::misc::CStatusMessageList validate() const
Validate data.
Value object encapsulating a list of distributors.
Simple hardcoded info about the corresponding simulator.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Filter to search data sets.
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.
virtual bool event(QEvent *event) override
QAbstractItemModel * model() const const
bool isEmpty() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
T qobject_cast(QObject *object)