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:
Klaus Basan
2018-05-25 21:29:13 +02:00
parent 117862e756
commit c16f5575f4
17 changed files with 485 additions and 19 deletions

View 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

View 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

View 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

View 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

View File

@@ -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

View 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

View 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