mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 00:25:35 +08:00
refs #452 models and views created
* for new value objects (e.g. distributor, ...) * new modes are required (e.g. CStatusMessageListModel::Simplified) * model filter allowing to filter models
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f9048de1e6
commit
2c91b3ada0
26
src/blackgui/views/aircrafticaoview.cpp
Normal file
26
src/blackgui/views/aircrafticaoview.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "aircrafticaoview.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CAircraftIcaoCodeView::CAircraftIcaoCodeView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_withMenuItemBackend = true;
|
||||
this->standardInit(new CAircraftIcaoCodeListModel(this));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
33
src/blackgui/views/aircrafticaoview.h
Normal file
33
src/blackgui/views/aircrafticaoview.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_AIRCRAFTICAOVIEW_H
|
||||
#define BLACKGUI_AIRCRAFTICAOVIEW_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "viewbase.h"
|
||||
#include "../models/aircrafticaolistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Aircraft ICAO codes view
|
||||
class BLACKGUI_EXPORT CAircraftIcaoCodeView : public CViewBase<Models::CAircraftIcaoCodeListModel, BlackMisc::Aviation::CAircraftIcaoCodeList, BlackMisc::Aviation::CAircraftIcaoCode>
|
||||
{
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAircraftIcaoCodeView(QWidget *parent = nullptr);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "aircraftmodelview.h"
|
||||
#include "aircraftmodelfilterform.h"
|
||||
#include "blackgui/filters/aircraftmodelfilterdialog.h"
|
||||
#include <QHeaderView>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
@@ -16,6 +16,7 @@
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackGui::Models;
|
||||
using namespace BlackGui::Filters;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -23,18 +24,40 @@ namespace BlackGui
|
||||
{
|
||||
CAircraftModelView::CAircraftModelView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_withMenuItemClear = true;
|
||||
this->m_withMenuItemRefresh = true;
|
||||
this->standardInit(new CAircraftModelListModel(CAircraftModelListModel::ModelOnly, this));
|
||||
this->standardInit(new CAircraftModelListModel(CAircraftModelListModel::OwnSimulatorModel, this));
|
||||
|
||||
// filter
|
||||
QWidget *mainWindow = this->mainApplicationWindowWidget();
|
||||
Q_ASSERT_X(mainWindow, Q_FUNC_INFO, "no main window found");
|
||||
this->setFilterDialog(new CAircraftModelFilterForm(mainWindow));
|
||||
this->setFilterDialog(new CAircraftModelFilterDialog(mainWindow));
|
||||
}
|
||||
|
||||
void CAircraftModelView::setAircraftModelMode(CAircraftModelListModel::AircraftModelMode mode)
|
||||
{
|
||||
if (mode == CAircraftModelListModel::Database)
|
||||
{
|
||||
this->m_withMenuItemClear = false;
|
||||
this->m_withMenuItemRefresh = false;
|
||||
this->m_withMenuItemBackend = true;
|
||||
}
|
||||
else if (mode == CAircraftModelListModel::OwnSimulatorModel)
|
||||
{
|
||||
this->m_withMenuItemClear = false;
|
||||
this->m_withMenuItemRefresh = false;
|
||||
this->m_withMenuItemBackend = true;
|
||||
}
|
||||
else if (mode == CAircraftModelListModel::VPilotRuleModel)
|
||||
{
|
||||
this->m_withMenuItemClear = true;
|
||||
this->m_withMenuItemRefresh = false;
|
||||
this->m_withMenuItemBackend = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_withMenuItemClear = true;
|
||||
this->m_withMenuItemRefresh = true;
|
||||
this->m_withMenuItemBackend = true;
|
||||
}
|
||||
this->m_model->setAircraftModelMode(mode);
|
||||
}
|
||||
|
||||
@@ -43,22 +66,19 @@ namespace BlackGui
|
||||
return m_displayAutomatically;
|
||||
}
|
||||
|
||||
bool CAircraftModelView::ps_filterDialogFinished(int status)
|
||||
{
|
||||
if (CViewBase::ps_filterDialogFinished(status)) { return true; }
|
||||
if (!this->m_filterDialog) { this->derivedModel()->removeFilter(); return true; }
|
||||
std::unique_ptr<IModelFilter<CAircraftModelList>> filter(this->getFilterForm()->getFilter());
|
||||
this->derivedModel()->setFilter(filter);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CAircraftModelView::customMenu(QMenu &menu) const
|
||||
{
|
||||
QAction *a = menu.addAction(CIcons::appMappings16(), "Automatically display", this, SLOT(ps_toggleAutoDisplay()));
|
||||
a->setCheckable(true);
|
||||
a->setChecked(m_displayAutomatically);
|
||||
menu.addAction(CIcons::refresh16(), "Reload model data", this, SIGNAL(requestModelReload()));
|
||||
menu.addSeparator();
|
||||
CAircraftModelListModel::AircraftModelMode mode = this->m_model->getModelMode();
|
||||
if (mode == CAircraftModelListModel::VPilotRuleModel || mode == CAircraftModelListModel::OwnSimulatorModel)
|
||||
{
|
||||
QAction *a = menu.addAction(CIcons::appMappings16(), "Automatically display", this, SLOT(ps_toggleAutoDisplay()));
|
||||
a->setCheckable(true);
|
||||
a->setChecked(m_displayAutomatically);
|
||||
menu.addSeparator();
|
||||
a = menu.addAction(CIcons::database16(), "Highlight DB items", this, SLOT(ps_toggleHighlightDbModels()));
|
||||
a->setCheckable(true);
|
||||
a->setChecked(derivedModel()->highlightDbData());
|
||||
}
|
||||
CViewBase::customMenu(menu);
|
||||
}
|
||||
|
||||
@@ -66,13 +86,14 @@ namespace BlackGui
|
||||
{
|
||||
QAction *a = qobject_cast<QAction *>(QObject::sender());
|
||||
if (!a) { return; }
|
||||
Q_ASSERT(a->isCheckable());
|
||||
Q_ASSERT_X(a->isCheckable(), Q_FUNC_INFO, "object not checkable");
|
||||
this->m_displayAutomatically = a->isChecked();
|
||||
}
|
||||
|
||||
CAircraftModelFilterForm *CAircraftModelView::getFilterForm() const
|
||||
void CAircraftModelView::ps_toggleHighlightDbModels()
|
||||
{
|
||||
return static_cast<CAircraftModelFilterForm *>(this->m_filterDialog.data());
|
||||
bool h = derivedModel()->highlightDbData();
|
||||
derivedModel()->setHighlightDbData(!h);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -13,16 +13,17 @@
|
||||
#define BLACKGUI_AIRCRAFTMODELVIEW_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "aircraftmodelfilterform.h"
|
||||
#include "blackgui/filters/aircraftmodelfilterdialog.h"
|
||||
#include "blackgui/models/aircraftmodellistmodel.h"
|
||||
#include "viewbase.h"
|
||||
#include "../models/aircraftmodellistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Aircraft view
|
||||
class BLACKGUI_EXPORT CAircraftModelView : public CViewBase<Models::CAircraftModelListModel, BlackMisc::Simulation::CAircraftModelList, BlackMisc::Simulation::CAircraftModel>
|
||||
class BLACKGUI_EXPORT CAircraftModelView :
|
||||
public CViewBase<Models::CAircraftModelListModel, BlackMisc::Simulation::CAircraftModelList, BlackMisc::Simulation::CAircraftModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -36,13 +37,12 @@ namespace BlackGui
|
||||
//! Display automatically (when models are loaded)
|
||||
bool displayAutomatically() const;
|
||||
|
||||
signals:
|
||||
//! Request reloading of backend models
|
||||
void requestModelReload();
|
||||
//! Display automatically (when models are loaded)
|
||||
void setDisplayAutomatically(bool automatically) { m_displayAutomatically = automatically; }
|
||||
|
||||
protected slots:
|
||||
//! \copydoc CViewBaseNonTemplate::ps_filterDialogFinished
|
||||
virtual bool ps_filterDialogFinished(int status) override;
|
||||
signals:
|
||||
//! Request to load VPilot data
|
||||
void requestVPilotRules();
|
||||
|
||||
protected:
|
||||
//! \copydoc CViewBase::customMenu
|
||||
@@ -52,10 +52,11 @@ namespace BlackGui
|
||||
//! Toggle auto display
|
||||
void ps_toggleAutoDisplay();
|
||||
|
||||
//! Highlight DB models
|
||||
void ps_toggleHighlightDbModels();
|
||||
|
||||
private:
|
||||
//! Filter form
|
||||
CAircraftModelFilterForm *getFilterForm() const;
|
||||
bool m_displayAutomatically = false;
|
||||
bool m_displayAutomatically = false; //!< display automatically (when models are loaded)
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
26
src/blackgui/views/airlineicaoview.cpp
Normal file
26
src/blackgui/views/airlineicaoview.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "airlineicaoview.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CAirlineIcaoCodeView::CAirlineIcaoCodeView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_withMenuItemBackend = true;
|
||||
this->standardInit(new CAirlineIcaoCodeListModel(this));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
33
src/blackgui/views/airlineicaoview.h
Normal file
33
src/blackgui/views/airlineicaoview.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_AIRLINEICAOVIEW_H
|
||||
#define BLACKGUI_AIRLINEICAOVIEW_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "viewbase.h"
|
||||
#include "../models/airlineicaolistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Aircraft ICAO codes view
|
||||
class BLACKGUI_EXPORT CAirlineIcaoCodeView : public CViewBase<Models::CAirlineIcaoCodeListModel, BlackMisc::Aviation::CAirlineIcaoCodeList, BlackMisc::Aviation::CAirlineIcaoCode>
|
||||
{
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAirlineIcaoCodeView(QWidget *parent = nullptr);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
25
src/blackgui/views/countryview.cpp
Normal file
25
src/blackgui/views/countryview.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "countryview.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CCountryView::CCountryView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_withMenuItemBackend = true;
|
||||
this->standardInit(new CCountryListModel(this));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
32
src/blackgui/views/countryview.h
Normal file
32
src/blackgui/views/countryview.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COUNTRYVIEW_H
|
||||
#define BLACKGUI_COUNTRYVIEW_H
|
||||
|
||||
#include "viewbase.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/models/countrylistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Distributors
|
||||
class BLACKGUI_EXPORT CCountryView : public CViewBase<Models::CCountryListModel, BlackMisc::CCountryList, BlackMisc::CCountry>
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CCountryView(QWidget *parent = nullptr);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
@@ -18,6 +18,7 @@ namespace BlackGui
|
||||
{
|
||||
CDistributorView::CDistributorView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_withMenuItemBackend = true;
|
||||
this->standardInit(new CDistributorListModel(this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace BlackGui
|
||||
{
|
||||
CLiveryView::CLiveryView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_withMenuItemBackend = true;
|
||||
this->standardInit(new CLiveryListModel(this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#ifndef BLACKGUI_LIVERYVIEW_H
|
||||
#define BLACKGUI_LIVERYVIEW_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "viewbase.h"
|
||||
#include "../models/liverylistmodel.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/models/liverylistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
@@ -32,10 +32,10 @@ namespace BlackGui
|
||||
void setIconMode(bool withIcon);
|
||||
|
||||
//! Update or add value, QVariant version
|
||||
bool addOrUpdateByName(const QString &name, const BlackMisc::CVariant &value, const BlackMisc::CIcon &icon = BlackMisc::CIcon(), bool performResizing = true, bool skipEqualValues = true);
|
||||
bool addOrUpdateByName(const QString &name, const BlackMisc::CVariant &value, const BlackMisc::CIcon &icon = BlackMisc::CIcon(), bool isResizeConditionMet = true, bool skipEqualValues = true);
|
||||
|
||||
//! Remove by name
|
||||
void removeByName(const QString &name, bool performResizing = true);
|
||||
void removeByName(const QString &name, bool isResizeConditionMet = true);
|
||||
|
||||
//! Contains name
|
||||
bool containsName(const QString &name);
|
||||
|
||||
Reference in New Issue
Block a user