Removed old model/views for aircraft, now all with simulated aircraft

Updates of models in view now manually / automatic possible
Allow to reload models (in backend)
This commit is contained in:
Klaus Basan
2015-03-19 23:56:08 +01:00
parent afed33dbbf
commit 48dc360237
22 changed files with 143 additions and 182 deletions

View File

@@ -46,6 +46,7 @@ namespace BlackGui
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::requestUpdate, this, &CMappingComponent::ps_onModelsUpdateRequested);
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::rowCountChanged, this, &CMappingComponent::ps_onRowCountChanged);
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::clicked, this, &CMappingComponent::ps_onModelSelectedInView);
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::requestModelReload, this, &CMappingComponent::ps_onMenuRequestModelReload);
connect(this->ui->tvp_SimulatedAircraft, &CSimulatedAircraftView::rowCountChanged, this, &CMappingComponent::ps_onRowCountChanged);
connect(this->ui->tvp_SimulatedAircraft, &CSimulatedAircraftView::clicked, this, &CMappingComponent::ps_onAircraftSelectedInView);
@@ -106,7 +107,14 @@ namespace BlackGui
void CMappingComponent::ps_onAircraftModelsLoaded()
{
this->ps_onModelsUpdateRequested();
if (ui->tvp_AircraftModels->displayAutomatically())
{
this->ps_onModelsUpdateRequested();
}
else
{
CLogMessage(this).info("Models loaded, you can update the model view");
}
}
void CMappingComponent::ps_onModelMatchingCompleted(const BlackMisc::Simulation::CSimulatedAircraft &aircraft)
@@ -339,6 +347,15 @@ namespace BlackGui
}
}
void CMappingComponent::ps_onMenuRequestModelReload()
{
if (this->getIContextSimulator())
{
this->getIContextSimulator()->reloadInstalledModels();
CLogMessage(this).info("Requested to reload simulator aircraft models");
}
}
const QString &CMappingComponent::mappingtOriginator()
{
// string is generated once, the timestamp allows to use multiple

View File

@@ -109,6 +109,9 @@ namespace BlackGui
//! Enable / disable aircraft
void ps_onMenuEnableAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
//! Reload models
void ps_onMenuRequestModelReload();
private:
static const QString &mappingtOriginator();
void updateSimulatedAircraftView();

View File

@@ -1,55 +0,0 @@
/* Copyright (C) 2013
* 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 "aircraftlistmodel.h"
#include "blackmisc/nwuser.h"
#include "blackmisc/avaircraftsituation.h"
#include "blackmisc/blackmiscfreefunctions.h"
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Network;
namespace BlackGui
{
namespace Models
{
/*
* Constructor
*/
CAircraftListModel::CAircraftListModel(QObject *parent) : CListModelBase("ViewAircraftList", parent)
{
this->m_columns.addColumn(CColumn::standardValueObject("cs.", "callsign", { CAircraft::IndexCallsign, CCallsign::IndexCallsignString }));
this->m_columns.addColumn(CColumn::standardString("realname", "pilot's real name", { CAircraft::IndexPilot, CUser::IndexRealName }));
this->m_columns.addColumn(CColumn("dist.", "distance", CAircraft::IndexDistanceToOwnAircraft, new CAirspaceDistanceFormatter()));
this->m_columns.addColumn(CColumn("frequency", { CAircraft::IndexCom1System, CComSystem::IndexActiveFrequency }, new CComFrequencyFormatter()));
this->m_columns.addColumn(CColumn::standardString("icao", { CAircraft::IndexIcao, CAircraftIcao::IndexAsString}));
this->m_columns.addColumn(CColumn::standardString("transponder", { CAircraft::IndexTransponder, CTransponder::IndexTransponderCodeAndModeFormatted }));
this->m_columns.addColumn(CColumn("latitude", { CAircraft::IndexSituation, CAircraftSituation::IndexLatitude }, new CLatLonFormatter()));
this->m_columns.addColumn(CColumn("longitude", { CAircraft::IndexSituation, CAircraftSituation::IndexLongitude }, new CLatLonFormatter()));
this->m_columns.addColumn(CColumn::standardValueObject("altitude", { CAircraft::IndexSituation, CAircraftSituation::IndexAltitude }, CDefaultFormatter::alignRightVCenter()));
this->m_columns.addColumn(CColumn("gs", { CAircraft::IndexSituation, CAircraftSituation::IndexGroundspeed }, new CAircraftSpeedFormatter()));
// default sort order
this->setSortColumnByPropertyIndex(CAircraft::IndexDistanceToOwnAircraft);
this->m_sortOrder = Qt::AscendingOrder;
// force strings for translation in resource files
(void)QT_TRANSLATE_NOOP("ViewAircraftList", "callsign");
(void)QT_TRANSLATE_NOOP("ViewAircraftList", "pilotrealname");
(void)QT_TRANSLATE_NOOP("ViewAircraftList", "latitude");
(void)QT_TRANSLATE_NOOP("ViewAircraftList", "longitude");
(void)QT_TRANSLATE_NOOP("ViewAircraftList", "altitude");
(void)QT_TRANSLATE_NOOP("ViewAircraftList", "distance");
(void)QT_TRANSLATE_NOOP("ViewAircraftList", "height");
(void)QT_TRANSLATE_NOOP("ViewAircraftList", "transponder");
(void)QT_TRANSLATE_NOOP("ViewAircraftList", "groundspeed");
(void)QT_TRANSLATE_NOOP("ViewAircraftList", "icao");
}
} // namespace
} // namespace

View File

@@ -1,40 +0,0 @@
/* Copyright (C) 2013
* 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_AIRCRAFTLISTMODEL_H
#define BLACKGUI_AIRCRAFTLISTMODEL_H
#include "blackmisc/avaircraftlist.h"
#include "blackgui/models/listmodelbase.h"
#include <QAbstractItemModel>
#include <QDBusConnection>
namespace BlackGui
{
namespace Models
{
//! Aircraft list model
class CAircraftListModel : public CListModelBase<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>
{
public:
//! Constructor
explicit CAircraftListModel(QObject *parent = nullptr);
//! Destructor
virtual ~CAircraftListModel() {}
};
} // namespace
} // namespace
#endif // guard

View File

@@ -38,6 +38,11 @@ namespace BlackGui
this->m_model->setAircraftModelMode(mode);
}
bool CAircraftModelView::displayAutomatically() const
{
return m_displayAutomatically;
}
bool CAircraftModelView::ps_filterDialogFinished(int status)
{
if (CViewBase::ps_filterDialogFinished(status)) { return true; }
@@ -47,6 +52,24 @@ namespace BlackGui
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();
CViewBase::customMenu(menu);
}
void CAircraftModelView::ps_toggleAutoDisplay()
{
QAction *a = qobject_cast<QAction *>(QObject::sender());
if (!a) { return; }
Q_ASSERT(a->isCheckable());
this->m_displayAutomatically = a->isChecked();
}
CAircraftModelFilterForm *CAircraftModelView::getFilterForm() const
{
return static_cast<CAircraftModelFilterForm *>(this->m_filterDialog.data());

View File

@@ -23,6 +23,7 @@ namespace BlackGui
//! Aircrafts view
class CAircraftModelView : public CViewBase<Models::CAircraftModelListModel, BlackMisc::Simulation::CAircraftModelList, BlackMisc::Simulation::CAircraftModel>
{
Q_OBJECT
public:
@@ -32,14 +33,30 @@ namespace BlackGui
//! Set display mode
void setAircraftModelMode(Models::CAircraftModelListModel::AircraftModelMode mode);
//! Display automatically (when models are loaded)
bool displayAutomatically() const;
signals:
//! Request reloading of backend models
void requestModelReload();
protected slots:
//! \copydoc CViewBaseNonTemplate::ps_filterDialogFinished
virtual bool ps_filterDialogFinished(int status) override;
protected:
//! \copydoc CViewBase::customMenu
virtual void customMenu(QMenu &menu) const override;
private slots:
//! Toggle auto display
void ps_toggleAutoDisplay();
private:
//! Filter form
CAircraftModelFilterForm *getFilterForm() const;
bool m_displayAutomatically = false;
};
}
}
} // ns
} // ns
#endif // guard

View File

@@ -1,26 +0,0 @@
/* Copyright (C) 2013
* 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 "aircraftview.h"
#include <QHeaderView>
using namespace BlackMisc;
using namespace BlackGui::Models;
namespace BlackGui
{
namespace Views
{
CAircraftView::CAircraftView(QWidget *parent) : CViewBase(parent)
{
this->standardInit(new CAircraftListModel(this));
}
} // ns
} // ns

View File

@@ -1,34 +0,0 @@
/* Copyright (C) 2013
* 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_AIRCRAFTVIEW_H
#define BLACKGUI_AIRCRAFTVIEW_H
#include "viewbase.h"
#include "../models/aircraftlistmodel.h"
namespace BlackGui
{
namespace Views
{
//! Aircrafts view
//! \deprecated use simulated aircraft instead
class CAircraftView : public CViewBase<Models::CAircraftListModel, BlackMisc::Aviation::CAircraftList, BlackMisc::Aviation::CAircraft>
{
public:
//! Constructor
explicit CAircraftView(QWidget *parent = nullptr);
};
} // namespace
} // namespace
#endif // guard

View File

@@ -11,7 +11,6 @@
#include "../models/statusmessagelistmodel.h"
#include "../models/namevariantpairlistmodel.h"
#include "../models/atcstationlistmodel.h"
#include "../models/aircraftlistmodel.h"
#include "../models/aircraftmodellistmodel.h"
#include "../models/textmessagelistmodel.h"
#include "../models/airportlistmodel.h"
@@ -87,8 +86,14 @@ namespace BlackGui
}
if (!menu.isEmpty()) { menu.addSeparator(); }
menu.addAction(BlackMisc::CIcons::resize16(), "Full resize", this, SLOT(fullResizeToContents()));
menu.addAction(BlackMisc::CIcons::resizeVertical16(), "Resize rows to content", this, SLOT(rowsResizeModeToContent()));
menu.addAction(BlackMisc::CIcons::resizeVertical16(), "Resize rows interactive", this, SLOT(rowsResizeModeToInteractive()));
if (m_rowResizeMode == Interactive)
{
menu.addAction(BlackMisc::CIcons::resizeVertical16(), "Resize rows to content", this, SLOT(rowsResizeModeToContent()));
}
else
{
menu.addAction(BlackMisc::CIcons::resizeVertical16(), "Resize rows interactive", this, SLOT(rowsResizeModeToInteractive()));
}
// resize to content might decrease performance,
// so I only allow changing to "content resizing" if size matches
@@ -398,7 +403,6 @@ namespace BlackGui
template class CViewBase<BlackGui::Models::CStatusMessageListModel, BlackMisc::CStatusMessageList, BlackMisc::CStatusMessage>;
template class CViewBase<BlackGui::Models::CNameVariantPairModel, BlackMisc::CNameVariantPairList, BlackMisc::CNameVariantPair>;
template class CViewBase<BlackGui::Models::CAtcStationListModel, BlackMisc::Aviation::CAtcStationList, BlackMisc::Aviation::CAtcStation>;
template class CViewBase<BlackGui::Models::CAircraftListModel, BlackMisc::Aviation::CAircraftList, BlackMisc::Aviation::CAircraft>;
template class CViewBase<BlackGui::Models::CAirportListModel, BlackMisc::Aviation::CAirportList, BlackMisc::Aviation::CAirport>;
template class CViewBase<BlackGui::Models::CServerListModel, BlackMisc::Network::CServerList, BlackMisc::Network::CServer>;
template class CViewBase<BlackGui::Models::CUserListModel, BlackMisc::Network::CUserList, BlackMisc::Network::CUser>;