mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T270, models/views for parts and situations
* added base class CListModelTimestampObjects * added model/view for CAircraftParts * added model/view for CAircraftSituation
This commit is contained in:
40
src/blackgui/models/aircraftpartslistmodel.cpp
Normal file
40
src/blackgui/models/aircraftpartslistmodel.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 "blackgui/models/aircraftpartslistmodel.h"
|
||||
#include "blackgui/models/columnformatters.h"
|
||||
#include "blackgui/models/columns.h"
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
CAircraftPartsListModel::CAircraftPartsListModel(QObject *parent) :
|
||||
CListModelTimestampObjects<CAircraftParts, CAircraftPartsList, true>("ViewAircraftPartsList", parent)
|
||||
{
|
||||
this->addTimestampOffsetColumns();
|
||||
|
||||
m_columns.addColumn(CColumn("gnd.", CAircraftParts::IndexOnGround, new CBoolIconFormatter("on gnd.", "not on gnd.")));
|
||||
m_columns.addColumn(CColumn("gear", CAircraftParts::IndexGearDown, new CBoolIconFormatter("gear down", "gear up")));
|
||||
m_columns.addColumn(CColumn("spoilers", CAircraftParts::IndexSpoilersOut, new CBoolIconFormatter("spoilers", "no spoilers")));
|
||||
m_columns.addColumn(CColumn("flaps", CAircraftParts::IndexFlapsPercentage, new CIntegerFormatter()));
|
||||
|
||||
m_columns.addColumn(CColumn::standardString("engines", { CAircraftParts::IndexEngines, CAircraftParts::IndexString }));
|
||||
m_columns.addColumn(CColumn::standardString("lights", { CAircraftParts::IndexLights, CAircraftParts::IndexString }));
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
40
src/blackgui/models/aircraftpartslistmodel.h
Normal file
40
src/blackgui/models/aircraftpartslistmodel.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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_MODELS_AIRCRAFTPARTSLISTMODEL_H
|
||||
#define BLACKGUI_MODELS_AIRCRAFTPARTSLISTMODEL_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/models/listmodeltimestampobjects.h"
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
class QModelIndex;
|
||||
class QObject;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
//! Client list model
|
||||
class BLACKGUI_EXPORT CAircraftPartsListModel : public CListModelTimestampObjects<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList, true>
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAircraftPartsListModel(QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CAircraftPartsListModel() {}
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
#endif // guard
|
||||
48
src/blackgui/models/aircraftsituationlistmodel.cpp
Normal file
48
src/blackgui/models/aircraftsituationlistmodel.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 "blackgui/models/aircraftsituationlistmodel.h"
|
||||
#include "blackgui/models/columnformatters.h"
|
||||
#include "blackgui/models/columns.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
CAircraftSituationListModel::CAircraftSituationListModel(QObject *parent) :
|
||||
CListModelTimestampObjects<CAircraftSituation, CAircraftSituationList, true>("ViewAircraftPartsList", parent)
|
||||
{
|
||||
this->addTimestampOffsetColumns();
|
||||
|
||||
m_columns.addColumn(CColumn("altitude", CAircraftSituation::IndexAltitude, new CAltitudeFormatter()));
|
||||
m_columns.addColumn(CColumn("CG", CAircraftSituation::IndexCG, new CPhysiqalQuantiyFormatter<CLengthUnit, CLength>(CLengthUnit::ft(), 1)));
|
||||
m_columns.addColumn(CColumn("latitude", CAircraftSituation::IndexLatitude, new CLatLonFormatter()));
|
||||
m_columns.addColumn(CColumn("longitude", CAircraftSituation::IndexLongitude, new CLatLonFormatter()));
|
||||
m_columns.addColumn(CColumn("gs.", CAircraftSituation::IndexGroundSpeed, new CSpeedKtsFormatter()));
|
||||
m_columns.addColumn(CColumn("on gnd.", "is on gnd.", CAircraftSituation::IndexIsOnGround, new CBoolIconFormatter("yes", "no"), true));
|
||||
m_columns.addColumn(CColumn::standardString("reliability", CAircraftSituation::IndexOnGroundReliabilityString));
|
||||
m_columns.addColumn(CColumn::standardString("gnd.elv.", { CAircraftSituation::IndexGroundElevationPlane, CElevationPlane::IndexGeodeticHeightAsString }));
|
||||
m_columns.addColumn(CColumn("elv.radius", { CAircraftSituation::IndexGroundElevationPlane, CElevationPlane::IndexRadius }, new CPhysiqalQuantiyFormatter<CLengthUnit, CLength>(CLengthUnit::m(), 1)));
|
||||
|
||||
// default sort order
|
||||
this->setSortColumnByPropertyIndex(CAircraftSituation::IndexAdjustedMsWithOffset);
|
||||
m_sortOrder = Qt::DescendingOrder;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
40
src/blackgui/models/aircraftsituationlistmodel.h
Normal file
40
src/blackgui/models/aircraftsituationlistmodel.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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_MODELS_AIRCRAFTSITUATIONLISTMODEL_H
|
||||
#define BLACKGUI_MODELS_AIRCRAFTSITUATIONLISTMODEL_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/models/listmodeltimestampobjects.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
class QModelIndex;
|
||||
class QObject;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
//! Client list model
|
||||
class BLACKGUI_EXPORT CAircraftSituationListModel : public CListModelTimestampObjects<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList, true>
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAircraftSituationListModel(QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CAircraftSituationListModel() {}
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
#endif // guard
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "blackmisc/aviation/airlineicaocodelist.h"
|
||||
#include "blackmisc/aviation/airportlist.h"
|
||||
#include "blackmisc/aviation/atcstationlist.h"
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/aviation/liverylist.h"
|
||||
#include "blackmisc/network/clientlist.h"
|
||||
#include "blackmisc/network/serverlist.h"
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
#include "blackgui/models/actionhotkeylistmodel.h"
|
||||
#include "blackgui/models/aircrafticaolistmodel.h"
|
||||
#include "blackgui/models/aircraftmodellistmodel.h"
|
||||
#include "blackgui/models/aircraftpartslistmodel.h"
|
||||
#include "blackgui/models/aircraftsituationlistmodel.h"
|
||||
#include "blackgui/models/airlineicaolistmodel.h"
|
||||
#include "blackgui/models/airportlistmodel.h"
|
||||
#include "blackgui/models/airportlistmodel.h"
|
||||
#include "blackgui/models/applicationinfolistmodel.h"
|
||||
#include "blackgui/models/atcstationlistmodel.h"
|
||||
#include "blackgui/models/clientlistmodel.h"
|
||||
|
||||
@@ -44,26 +44,17 @@ namespace BlackGui
|
||||
|
||||
QVariant CListModelBaseNonTemplate::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (orientation != Qt::Horizontal)
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
bool handled = (role == Qt::DisplayRole || role == Qt::ToolTipRole || role == Qt::InitialSortOrderRole);
|
||||
if (!handled)
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
if (section < 0 || section >= m_columns.size())
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
if (orientation != Qt::Horizontal) { return QVariant(); }
|
||||
const bool handled = (role == Qt::DisplayRole || role == Qt::ToolTipRole || role == Qt::InitialSortOrderRole);
|
||||
if (!handled) { return QVariant(); }
|
||||
if (section < 0 || section >= m_columns.size()) { return QVariant(); }
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
QString header = m_columns.at(section).getColumnName(false);
|
||||
return QVariant(header);
|
||||
}
|
||||
else if (role == Qt::ToolTipRole)
|
||||
if (role == Qt::ToolTipRole)
|
||||
{
|
||||
QString header = m_columns.at(section).getColumnToolTip(false);
|
||||
return header.isEmpty() ? QVariant() : QVariant(header);
|
||||
@@ -375,8 +366,8 @@ namespace BlackGui
|
||||
if (index.row() >= m_container.size()) { return; }
|
||||
m_container[index.row()] = object;
|
||||
|
||||
QModelIndex i1 = index.sibling(index.row(), 0);
|
||||
QModelIndex i2 = index.sibling(index.row(), this->columnCount(index) - 1);
|
||||
const QModelIndex i1 = index.sibling(index.row(), 0);
|
||||
const QModelIndex i2 = index.sibling(index.row(), this->columnCount(index) - 1);
|
||||
emit this->dataChanged(i1, i2); // which range has been changed
|
||||
}
|
||||
|
||||
@@ -777,6 +768,8 @@ namespace BlackGui
|
||||
template class CListModelBase<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList, true>;
|
||||
template class CListModelBase<BlackMisc::Aviation::CAircraftIcaoCode, BlackMisc::Aviation::CAircraftIcaoCodeList, true>;
|
||||
template class CListModelBase<BlackMisc::Aviation::CAirlineIcaoCode, BlackMisc::Aviation::CAirlineIcaoCodeList, true>;
|
||||
template class CListModelBase<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList, true>;
|
||||
template class CListModelBase<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList, true>;
|
||||
template class CListModelBase<BlackMisc::Network::CServer, BlackMisc::Network::CServerList, true>;
|
||||
template class CListModelBase<BlackMisc::Network::CUser, BlackMisc::Network::CUserList, true>;
|
||||
template class CListModelBase<BlackMisc::Network::CTextMessage, BlackMisc::Network::CTextMessageList, false>;
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
#ifndef BLACKGUI_LISTMODELBASE_H
|
||||
#define BLACKGUI_LISTMODELBASE_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/dropbase.h"
|
||||
#include "blackgui/models/columns.h"
|
||||
#include "blackgui/models/modelfilter.h"
|
||||
#include "blackgui/models/selectionmodel.h"
|
||||
#include "blackgui/dropbase.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/digestsignal.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
|
||||
51
src/blackgui/models/listmodeltimestampobjects.cpp
Normal file
51
src/blackgui/models/listmodeltimestampobjects.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 "listmodeltimestampobjects.h"
|
||||
#include "allmodelcontainers.h"
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
template <typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
CListModelTimestampObjects<ObjectType, ContainerType, UseCompare>::CListModelTimestampObjects(const QString &translationContext, QObject *parent) :
|
||||
CListModelBase<ObjectType, ContainerType, UseCompare>(translationContext, parent)
|
||||
{ }
|
||||
|
||||
template<typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
void CListModelTimestampObjects<ObjectType, ContainerType, UseCompare>::push_frontKeepLatestAdjustedFirst(const ObjectType &object, int max)
|
||||
{
|
||||
this->beginInsertRows(QModelIndex(), 0, 0);
|
||||
CListModelBase<ObjectType, ContainerType, UseCompare>::m_container.push_frontKeepLatestAdjustedFirst(object, max);
|
||||
this->endInsertRows();
|
||||
}
|
||||
|
||||
template<typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
void CListModelTimestampObjects<ObjectType, ContainerType, UseCompare>::addTimestampOffsetColumns()
|
||||
{
|
||||
CListModelBaseNonTemplate::m_columns.addColumn(CColumn::standardString("timestamp", ObjectType::IndexUtcTimestampFormattedMdhmsz));
|
||||
CListModelBaseNonTemplate::m_columns.addColumn(CColumn("ms", ObjectType::IndexMSecsSinceEpoch, new CIntegerFormatter()));
|
||||
CListModelBaseNonTemplate::m_columns.addColumn(CColumn("ms adj.", ObjectType::IndexAdjustedMsWithOffset, new CIntegerFormatter()));
|
||||
CListModelBaseNonTemplate::m_columns.addColumn(CColumn("offset", ObjectType::IndexOffsetMs, new CIntegerFormatter()));
|
||||
}
|
||||
|
||||
// see here for the reason of thess forward instantiations
|
||||
// https://isocpp.org/wiki/faq/templates#separate-template-fn-defn-from-decl
|
||||
template class CListModelTimestampObjects<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList, true>;
|
||||
template class CListModelTimestampObjects<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList, true>;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
48
src/blackgui/models/listmodeltimestampobjects.h
Normal file
48
src/blackgui/models/listmodeltimestampobjects.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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_MODELS_LISTMODELTIMESTAMPOBJECTS_H
|
||||
#define BLACKGUI_MODELS_LISTMODELTIMESTAMPOBJECTS_H
|
||||
|
||||
#include "blackgui/models/listmodelbase.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <Qt>
|
||||
|
||||
class QModelIndex;
|
||||
class QObject;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
//! List model for timestamp based objects
|
||||
template <typename ObjectType, typename ContainerType, bool UseCompare = false> class CListModelTimestampObjects :
|
||||
public CListModelBase<ObjectType, ContainerType, UseCompare>
|
||||
{
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~CListModelTimestampObjects() {}
|
||||
|
||||
//! Insert as first element by keeping maxElements and the latest first
|
||||
void push_frontKeepLatestAdjustedFirst(const ObjectType &object, int max);
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CListModelTimestampObjects(const QString &translationContext, QObject *parent = nullptr);
|
||||
|
||||
//! Standard timestamp offset columns
|
||||
void addTimestampOffsetColumns();
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
#endif // guard
|
||||
25
src/blackgui/views/aircraftpartsview.cpp
Normal file
25
src/blackgui/views/aircraftpartsview.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 "blackgui/views/aircraftpartsview.h"
|
||||
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CAircraftPartsView::CAircraftPartsView(QWidget *parent) :
|
||||
CViewWithTimestampObjects(parent)
|
||||
{
|
||||
this->standardInit(new CAircraftPartsListModel(this));
|
||||
this->setMenu(MenuDefault);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
35
src/blackgui/views/aircraftpartsview.h
Normal file
35
src/blackgui/views/aircraftpartsview.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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_VIEWS_AIRCRAFTPARTSVIEW_H
|
||||
#define BLACKGUI_VIEWS_AIRCRAFTPARTSVIEW_H
|
||||
|
||||
#include "blackgui/views/viewtimestampobjects.h"
|
||||
#include "blackgui/models/aircraftpartslistmodel.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Aircraft parts
|
||||
class BLACKGUI_EXPORT CAircraftPartsView : public CViewWithTimestampObjects<Models::CAircraftPartsListModel, BlackMisc::Aviation::CAircraftPartsList, BlackMisc::Aviation::CAircraftParts>
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAircraftPartsView(QWidget *parent = nullptr);
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
25
src/blackgui/views/aircraftsituationview.cpp
Normal file
25
src/blackgui/views/aircraftsituationview.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 "blackgui/views/aircraftsituationview.h"
|
||||
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CAircraftSituationView::CAircraftSituationView(QWidget *parent) :
|
||||
CViewWithTimestampObjects(parent)
|
||||
{
|
||||
this->standardInit(new CAircraftSituationListModel(this));
|
||||
this->setMenu(MenuDefault);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
35
src/blackgui/views/aircraftsituationview.h
Normal file
35
src/blackgui/views/aircraftsituationview.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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_VIEWS_AIRCRAFTSITUATIONVIEW_H
|
||||
#define BLACKGUI_VIEWS_AIRCRAFTSITUATIONVIEW_H
|
||||
|
||||
#include "blackgui/views/viewtimestampobjects.h"
|
||||
#include "blackgui/models/aircraftsituationlistmodel.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Aircraft situations view
|
||||
class BLACKGUI_EXPORT CAircraftSituationView : public CViewWithTimestampObjects<Models::CAircraftSituationListModel, BlackMisc::Aviation::CAircraftSituationList, BlackMisc::Aviation::CAircraftSituation>
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAircraftSituationView(QWidget *parent = nullptr);
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
@@ -1706,6 +1706,8 @@ namespace BlackGui
|
||||
// https://isocpp.org/wiki/faq/templates#separate-template-fn-defn-from-decl
|
||||
template class CViewBase<BlackGui::Models::CAircraftIcaoCodeListModel, BlackMisc::Aviation::CAircraftIcaoCodeList, BlackMisc::Aviation::CAircraftIcaoCode>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftModelListModel, BlackMisc::Simulation::CAircraftModelList, BlackMisc::Simulation::CAircraftModel>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftPartsListModel, BlackMisc::Aviation::CAircraftPartsList, BlackMisc::Aviation::CAircraftParts>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftSituationListModel, BlackMisc::Aviation::CAircraftSituationList, BlackMisc::Aviation::CAircraftSituation>;
|
||||
template class CViewBase<BlackGui::Models::CAirlineIcaoCodeListModel, BlackMisc::Aviation::CAirlineIcaoCodeList, BlackMisc::Aviation::CAirlineIcaoCode>;
|
||||
template class CViewBase<BlackGui::Models::CAirportListModel, BlackMisc::Aviation::CAirportList, BlackMisc::Aviation::CAirport>;
|
||||
template class CViewBase<BlackGui::Models::CApplicationInfoListModel, BlackMisc::CApplicationInfoList, BlackMisc::CApplicationInfo>;
|
||||
@@ -1726,5 +1728,6 @@ namespace BlackGui
|
||||
template class CViewBase<BlackGui::Models::CTextMessageListModel, BlackMisc::Network::CTextMessageList, BlackMisc::Network::CTextMessage>;
|
||||
template class CViewBase<BlackGui::Models::CUserListModel, BlackMisc::Network::CUserList, BlackMisc::Network::CUser>;
|
||||
template class CViewBase<BlackGui::Models::CWindLayerListModel, BlackMisc::Weather::CWindLayerList, BlackMisc::Weather::CWindLayer>;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
41
src/blackgui/views/viewtimestampobjects.cpp
Normal file
41
src/blackgui/views/viewtimestampobjects.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 "blackgui/views/viewtimestampobjects.h"
|
||||
#include "blackgui/models/aircraftpartslistmodel.h"
|
||||
#include "blackgui/models/aircraftsituationlistmodel.h"
|
||||
#include <QAction>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewWithTimestampObjects<ModelClass, ContainerType, ObjectType>::push_frontKeepLatestAdjustedFirst(const ObjectType &object, int max)
|
||||
{
|
||||
this->derivedModel()->push_frontKeepLatestAdjustedFirst(object, max);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
CViewWithTimestampObjects<ModelClass, ContainerType, ObjectType>::CViewWithTimestampObjects(QWidget *parent) :
|
||||
CViewBase<ModelClass, ContainerType, ObjectType>(parent)
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
template class CViewWithTimestampObjects<BlackGui::Models::CAircraftPartsListModel, BlackMisc::Aviation::CAircraftPartsList, BlackMisc::Aviation::CAircraftParts>;
|
||||
template class CViewWithTimestampObjects<BlackGui::Models::CAircraftSituationListModel, BlackMisc::Aviation::CAircraftSituationList, BlackMisc::Aviation::CAircraftSituation>;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
39
src/blackgui/views/viewtimestampobjects.h
Normal file
39
src/blackgui/views/viewtimestampobjects.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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_VIEWS_VIEWTIMESTAMPOBJECTS_H
|
||||
#define BLACKGUI_VIEWS_VIEWTIMESTAMPOBJECTS_H
|
||||
|
||||
#include "viewbase.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Menus { class CMenuActions; }
|
||||
namespace Views
|
||||
{
|
||||
//! Base class for views with DB objects
|
||||
template <class ModelClass, class ContainerType, class ObjectType> class CViewWithTimestampObjects :
|
||||
public CViewBase<ModelClass, ContainerType, ObjectType>
|
||||
{
|
||||
public:
|
||||
//! Insert as first element by keeping maxElements and the latest first
|
||||
void push_frontKeepLatestAdjustedFirst(const ObjectType &object, int max);
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
explicit CViewWithTimestampObjects(QWidget *parent = nullptr);
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user