diff --git a/src/blackgui/models/allmodelcontainers.h b/src/blackgui/models/allmodelcontainers.h index 4f2ce843e..bc36ed02f 100644 --- a/src/blackgui/models/allmodelcontainers.h +++ b/src/blackgui/models/allmodelcontainers.h @@ -10,19 +10,25 @@ #ifndef BLACKGUI_MODELS_ALLMODELCONTAINERS_H #define BLACKGUI_MODELS_ALLMODELCONTAINERS_H +#include "blackmisc/simulation/aircraftmodellist.h" +#include "blackmisc/simulation/distributorlist.h" +#include "blackmisc/simulation/interpolationsetuplist.h" +#include "blackmisc/simulation/simulatedaircraftlist.h" +#include "blackmisc/simulation/matchingstatistics.h" #include "blackmisc/aviation/aircrafticaocodelist.h" #include "blackmisc/aviation/airlineicaocodelist.h" #include "blackmisc/aviation/airportlist.h" #include "blackmisc/aviation/atcstationlist.h" #include "blackmisc/aviation/liverylist.h" -#include "blackmisc/input/actionhotkeylist.h" #include "blackmisc/network/clientlist.h" #include "blackmisc/network/serverlist.h" #include "blackmisc/network/textmessagelist.h" #include "blackmisc/network/userlist.h" -#include "blackmisc/simulation/aircraftmodellist.h" -#include "blackmisc/simulation/distributorlist.h" -#include "blackmisc/simulation/simulatedaircraftlist.h" +#include "blackmisc/weather/cloudlayerlist.h" +#include "blackmisc/weather/presentweatherlist.h" +#include "blackmisc/weather/temperaturelayerlist.h" +#include "blackmisc/weather/windlayerlist.h" +#include "blackmisc/input/actionhotkeylist.h" #include "blackmisc/countrylist.h" #include "blackmisc/namevariantpairlist.h" #include "blackmisc/statusmessagelist.h" diff --git a/src/blackgui/models/allmodels.h b/src/blackgui/models/allmodels.h index 5be60935c..1890bf6c5 100644 --- a/src/blackgui/models/allmodels.h +++ b/src/blackgui/models/allmodels.h @@ -22,6 +22,7 @@ #include "blackgui/models/countrylistmodel.h" #include "blackgui/models/distributorlistmodel.h" #include "blackgui/models/identifierlistmodel.h" +#include "blackgui/models/interpolationsetupmodel.h" #include "blackgui/models/liverylistmodel.h" #include "blackgui/models/matchingstatisticsmodel.h" #include "blackgui/models/namevariantpairlistmodel.h" diff --git a/src/blackgui/models/interpolationsetupmodel.cpp b/src/blackgui/models/interpolationsetupmodel.cpp new file mode 100644 index 000000000..202611383 --- /dev/null +++ b/src/blackgui/models/interpolationsetupmodel.cpp @@ -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/columns.h" +#include "blackgui/models/interpolationsetupmodel.h" + +#include +#include + +using namespace BlackMisc; +using namespace BlackMisc::Aviation; +using namespace BlackMisc::Simulation; + +namespace BlackGui +{ + namespace Models + { + CInterpolationSetupListModel::CInterpolationSetupListModel(QObject *parent) : + CListModelCallsignObjects("CInterpolationSetupListModel", parent) + { + m_columns.addColumn(CColumn::standardValueObject("cs.", "callsign", CInterpolationAndRenderingSetupPerCallsign::IndexCallsign, CCallsign::IndexCallsignString)); + m_columns.addColumn(CColumn("sim.dbg.", "simulator debug", CInterpolationAndRenderingSetupPerCallsign::IndexSimulatorDebugMessages, new CBoolIconFormatter("sim.dbg.", "simulator debug"))); + m_columns.addColumn(CColumn("log.int.", "log.interpolation", CInterpolationAndRenderingSetupPerCallsign::IndexLogInterpolation, new CBoolIconFormatter("log.int.", "log.interpolation"))); + m_columns.addColumn(CColumn("parts", "aircraft parts", CInterpolationAndRenderingSetupPerCallsign::IndexEnabledAircraftParts, new CBoolIconFormatter("parts", "aircraft parts"))); + m_columns.addColumn(CColumn("log.int.", "log.interpolation", CInterpolationAndRenderingSetupPerCallsign::IndexEnableGndFlag, new CBoolIconFormatter("log.int.", "log.interpolation"))); + m_columns.addColumn(CColumn("send gnd.", "send gnd.", CInterpolationAndRenderingSetupPerCallsign::IndexSendGndFlagToSimulator, new CBoolIconFormatter("send gnd.", "send gnd."))); + m_columns.addColumn(CColumn("full", "full int.", CInterpolationAndRenderingSetupPerCallsign::IndexForceFullInterpolation, new CBoolIconFormatter("full", "full int."))); + + // default sort order + this->setSortColumnByPropertyIndex(CCountry::IndexIsoCode); + m_sortOrder = Qt::AscendingOrder; + } + } // ns +} // ns diff --git a/src/blackgui/models/interpolationsetupmodel.h b/src/blackgui/models/interpolationsetupmodel.h new file mode 100644 index 000000000..1b9834dff --- /dev/null +++ b/src/blackgui/models/interpolationsetupmodel.h @@ -0,0 +1,37 @@ +/* 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_INTERPOLATIONSETUPMODEL_H +#define BLACKGUI_MODELS_INTERPOLATIONSETUPMODEL_H + +#include "blackmisc/simulation/interpolationsetuplist.h" +#include "blackgui/models/listmodelcallsignobjects.h" +#include "blackgui/blackguiexport.h" +#include + +namespace BlackGui +{ + namespace Models + { + //! Country list model + class BLACKGUI_EXPORT CInterpolationSetupListModel : + public CListModelCallsignObjects + { + public: + //! Constructor + explicit CInterpolationSetupListModel(QObject *parent = nullptr); + + //! Destructor + virtual ~CInterpolationSetupListModel() {} + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/models/listmodelbase.cpp b/src/blackgui/models/listmodelbase.cpp index 083e6c56b..8acefdda7 100644 --- a/src/blackgui/models/listmodelbase.cpp +++ b/src/blackgui/models/listmodelbase.cpp @@ -13,49 +13,13 @@ #include "blackgui/guiutility.h" #include "blackgui/models/columnformatters.h" #include "blackgui/models/listmodelbase.h" -#include "blackmisc/aviation/aircrafticaocode.h" -#include "blackmisc/aviation/aircrafticaocodelist.h" -#include "blackmisc/aviation/airlineicaocode.h" -#include "blackmisc/aviation/airlineicaocodelist.h" -#include "blackmisc/aviation/airport.h" -#include "blackmisc/aviation/airportlist.h" -#include "blackmisc/aviation/atcstation.h" -#include "blackmisc/aviation/atcstationlist.h" -#include "blackmisc/aviation/livery.h" -#include "blackmisc/aviation/liverylist.h" +#include "blackgui/models/allmodelcontainers.h" #include "blackmisc/compare.h" -#include "blackmisc/country.h" -#include "blackmisc/countrylist.h" -#include "blackmisc/identifier.h" -#include "blackmisc/identifierlist.h" -#include "blackmisc/namevariantpair.h" -#include "blackmisc/namevariantpairlist.h" -#include "blackmisc/network/client.h" -#include "blackmisc/network/clientlist.h" -#include "blackmisc/network/server.h" -#include "blackmisc/network/serverlist.h" -#include "blackmisc/network/textmessage.h" -#include "blackmisc/network/textmessagelist.h" -#include "blackmisc/network/user.h" -#include "blackmisc/network/userlist.h" #include "blackmisc/predicates.h" #include "blackmisc/propertyindex.h" #include "blackmisc/sequence.h" -#include "blackmisc/simulation/aircraftmodel.h" -#include "blackmisc/simulation/aircraftmodellist.h" -#include "blackmisc/simulation/distributor.h" -#include "blackmisc/simulation/distributorlist.h" -#include "blackmisc/simulation/simulatedaircraft.h" -#include "blackmisc/simulation/simulatedaircraftlist.h" -#include "blackmisc/simulation/matchingstatisticsentry.h" -#include "blackmisc/simulation/matchingstatistics.h" -#include "blackmisc/statusmessage.h" -#include "blackmisc/statusmessagelist.h" #include "blackmisc/variant.h" #include "blackmisc/verify.h" -#include "blackmisc/weather/cloudlayerlist.h" -#include "blackmisc/weather/temperaturelayerlist.h" -#include "blackmisc/weather/windlayerlist.h" #include "blackmisc/worker.h" #include @@ -793,6 +757,7 @@ namespace BlackGui template class CListModelBase; template class CListModelBase; template class CListModelBase; + template class CListModelBase; template class CListModelBase; template class CListModelBase; template class CListModelBase; diff --git a/src/blackgui/models/listmodelcallsignobjects.cpp b/src/blackgui/models/listmodelcallsignobjects.cpp index 446378e45..03b6c7618 100644 --- a/src/blackgui/models/listmodelcallsignobjects.cpp +++ b/src/blackgui/models/listmodelcallsignobjects.cpp @@ -55,5 +55,6 @@ namespace BlackGui // https://isocpp.org/wiki/faq/templates#separate-template-fn-defn-from-decl template class CListModelCallsignObjects; template class CListModelCallsignObjects; + template class CListModelCallsignObjects; } // namespace } // namespace diff --git a/src/blackgui/views/interpolationsetupview.cpp b/src/blackgui/views/interpolationsetupview.cpp new file mode 100644 index 000000000..d4a6b686d --- /dev/null +++ b/src/blackgui/views/interpolationsetupview.cpp @@ -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 "interpolationsetupview.h" + +using namespace BlackGui::Models; + +namespace BlackGui +{ + namespace Views + { + CInterpolationSetupView::CInterpolationSetupView(QWidget *parent) : + CViewWithCallsignObjects(parent) + { + this->standardInit(new CInterpolationSetupListModel(this)); + // this->setMenu(MenuDefaultDbViews); + } + } // ns +} // ns diff --git a/src/blackgui/views/interpolationsetupview.h b/src/blackgui/views/interpolationsetupview.h new file mode 100644 index 000000000..d3f2375b2 --- /dev/null +++ b/src/blackgui/views/interpolationsetupview.h @@ -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_INTERPOLATIONSETUPVIEW_H +#define BLACKGUI_VIEWS_INTERPOLATIONSETUPVIEW_H + +#include "blackgui/blackguiexport.h" +#include "blackgui/models/interpolationsetupmodel.h" +#include "blackgui/views/viewcallsignobjects.h" +#include "blackmisc/countrylist.h" + +class QWidget; + +namespace BlackGui +{ + namespace Views + { + //! Distributors + class BLACKGUI_EXPORT CInterpolationSetupView : public CViewWithCallsignObjects + { + public: + //! Constructor + explicit CInterpolationSetupView(QWidget *parent = nullptr); + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/views/viewbase.cpp b/src/blackgui/views/viewbase.cpp index 3aee49528..69771d49e 100644 --- a/src/blackgui/views/viewbase.cpp +++ b/src/blackgui/views/viewbase.cpp @@ -15,6 +15,7 @@ #include "blackgui/guiutility.h" #include "blackgui/loadindicator.h" #include "blackgui/models/allmodels.h" +#include "blackgui/models/allmodelcontainers.h" #include "blackgui/menus/menuaction.h" #include "blackgui/menus/menudelegate.h" #include "blackgui/menus/fontmenus.h" @@ -22,47 +23,12 @@ #include "blackgui/views/viewbase.h" #include "blackgui/views/viewbaseproxystyle.h" #include "blackgui/views/viewbaseitemdelegate.h" -#include "blackmisc/aviation/aircrafticaocode.h" -#include "blackmisc/aviation/aircrafticaocodelist.h" -#include "blackmisc/aviation/airlineicaocode.h" -#include "blackmisc/aviation/airlineicaocodelist.h" -#include "blackmisc/aviation/airport.h" -#include "blackmisc/aviation/airportlist.h" -#include "blackmisc/aviation/atcstation.h" -#include "blackmisc/aviation/atcstationlist.h" -#include "blackmisc/aviation/livery.h" -#include "blackmisc/aviation/liverylist.h" -#include "blackmisc/country.h" -#include "blackmisc/countrylist.h" #include "blackmisc/fileutils.h" #include "blackmisc/icons.h" -#include "blackmisc/identifier.h" -#include "blackmisc/identifierlist.h" #include "blackmisc/logmessage.h" #include "blackmisc/namevariantpair.h" #include "blackmisc/namevariantpairlist.h" -#include "blackmisc/network/client.h" -#include "blackmisc/network/clientlist.h" -#include "blackmisc/network/server.h" -#include "blackmisc/network/serverlist.h" -#include "blackmisc/network/textmessage.h" -#include "blackmisc/network/textmessagelist.h" -#include "blackmisc/network/user.h" -#include "blackmisc/network/userlist.h" #include "blackmisc/propertyindexvariantmap.h" -#include "blackmisc/propertyindexlist.h" -#include "blackmisc/simulation/aircraftmodel.h" -#include "blackmisc/simulation/aircraftmodellist.h" -#include "blackmisc/simulation/distributor.h" -#include "blackmisc/simulation/distributorlist.h" -#include "blackmisc/simulation/matchingstatisticsentry.h" -#include "blackmisc/simulation/matchingstatistics.h" -#include "blackmisc/simulation/simulatedaircraft.h" -#include "blackmisc/simulation/simulatedaircraftlist.h" -#include "blackmisc/statusmessagelist.h" -#include "blackmisc/weather/cloudlayerlist.h" -#include "blackmisc/weather/temperaturelayerlist.h" -#include "blackmisc/weather/windlayerlist.h" #include "blackmisc/worker.h" #include @@ -1430,7 +1396,7 @@ namespace BlackGui // Clear highlighting if (this->derivedModel()->hasHighlightedRows()) { - menuActions.addAction(CIcons::refresh16(), "Clear highlighting", CMenuAction::pathViewClearHighlighting(), nullptr , { this, &CViewBaseNonTemplate::clearHighlighting }); + menuActions.addAction(CIcons::refresh16(), "Clear highlighting", CMenuAction::pathViewClearHighlighting(), nullptr, { this, &CViewBaseNonTemplate::clearHighlighting }); } } @@ -1644,6 +1610,7 @@ namespace BlackGui template class CViewBase; template class CViewBase; template class CViewBase; + template class CViewBase; template class CViewBase; template class CViewBase; template class CViewBase; diff --git a/src/blackgui/views/viewcallsignobjects.cpp b/src/blackgui/views/viewcallsignobjects.cpp index 8c219832e..1c220b3ce 100644 --- a/src/blackgui/views/viewcallsignobjects.cpp +++ b/src/blackgui/views/viewcallsignobjects.cpp @@ -9,6 +9,7 @@ #include "blackgui/views/viewcallsignobjects.h" #include "blackgui/models/atcstationlistmodel.h" +#include "blackgui/models/interpolationsetupmodel.h" #include "blackgui/models/simulatedaircraftlistmodel.h" #include "blackmisc/icons.h" @@ -68,6 +69,14 @@ namespace BlackGui return selected.getCallsigns(); } + template + int CViewWithCallsignObjects::removeCallsign(const CCallsign &callsign) + { + if (callsign.isEmpty()) { return 0; } + const CCallsignSet set({ callsign }); + return this->removeCallsigns(set); + } + template int CViewWithCallsignObjects::removeCallsigns(const CCallsignSet &callsigns) { @@ -88,7 +97,17 @@ namespace BlackGui { if (container.isEmpty()) { return 0; } ContainerType copy(this->container()); - int c = copy.replaceOrAddObjectsByCallsign(container); + const int c = copy.replaceOrAddObjectsByCallsign(container); + if (c == 0) { return 0; } + this->updateContainerMaybeAsync(copy); + return c; + } + + template + int CViewWithCallsignObjects::replaceOrAddObjectByCallsign(const ObjectType &object) + { + ContainerType copy(this->container()); + const int c = copy.replaceOrAddObjectByCallsign(object); if (c == 0) { return 0; } this->updateContainerMaybeAsync(copy); return c; @@ -104,6 +123,7 @@ namespace BlackGui } template class CViewWithCallsignObjects; + template class CViewWithCallsignObjects; template class CViewWithCallsignObjects; } // namespace diff --git a/src/blackgui/views/viewcallsignobjects.h b/src/blackgui/views/viewcallsignobjects.h index f5d299269..f77272d3b 100644 --- a/src/blackgui/views/viewcallsignobjects.h +++ b/src/blackgui/views/viewcallsignobjects.h @@ -45,9 +45,15 @@ namespace BlackGui //! Remove callsigns int removeCallsigns(const BlackMisc::Aviation::CCallsignSet &callsigns); + //! Remove callsign + int removeCallsign(const BlackMisc::Aviation::CCallsign &callsign); + //! Update or insert data (based on callsign) int replaceOrAddObjectsByCallsign(const ContainerType &container); + //! Update or insert data (based on callsign) + int replaceOrAddObjectByCallsign(const ObjectType &object); + //! Reselect by callsigns virtual void selectObjects(const ContainerType &selectedObjects) override; diff --git a/src/blackmisc/aviation/callsignobjectlist.cpp b/src/blackmisc/aviation/callsignobjectlist.cpp index 249512daa..5dadfaaee 100644 --- a/src/blackmisc/aviation/callsignobjectlist.cpp +++ b/src/blackmisc/aviation/callsignobjectlist.cpp @@ -7,14 +7,15 @@ * contained in the LICENSE file. */ +#include "blackmisc/simulation/simulatedaircraftlist.h" +#include "blackmisc/simulation/interpolationsetuplist.h" #include "blackmisc/aviation/callsignobjectlist.h" #include "blackmisc/aviation/callsign.h" -#include "blackmisc/predicates.h" #include "blackmisc/aviation/atcstationlist.h" #include "blackmisc/aviation/aircraftsituationlist.h" #include "blackmisc/aviation/flightplanlist.h" -#include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/network/clientlist.h" +#include "blackmisc/predicates.h" #include @@ -179,6 +180,17 @@ namespace BlackMisc return result; } + template + int ICallsignObjectList::replaceOrAddObjectByCallsign(const OBJ &otherObject) + { + const CCallsign cs(otherObject.getCallsign()); + if (cs.isEmpty()) { return 0; } + CONTAINER ©(this->container()); + copy.removeByCallsign(cs); + copy.push_back(otherObject); + return 1; + } + template int ICallsignObjectList::replaceOrAddObjectsByCallsign(const CONTAINER &others) { @@ -188,7 +200,7 @@ namespace BlackMisc for (const OBJ &obj : others) { const CCallsign cs(obj.getCallsign()); - if (cs.isEmpty()) continue; + if (cs.isEmpty()) { continue; } copy.removeByCallsign(cs); copy.push_back(obj); c++; @@ -237,6 +249,7 @@ namespace BlackMisc template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ICallsignObjectList; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ICallsignObjectList; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ICallsignObjectList; + template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ICallsignObjectList; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ICallsignObjectList; //! \endcond diff --git a/src/blackmisc/aviation/callsignobjectlist.h b/src/blackmisc/aviation/callsignobjectlist.h index f0a6b9eaf..2636fabf5 100644 --- a/src/blackmisc/aviation/callsignobjectlist.h +++ b/src/blackmisc/aviation/callsignobjectlist.h @@ -33,6 +33,8 @@ namespace BlackMisc { class CSimulatedAircraft; class CSimulatedAircraftList; + class CInterpolationAndRenderingSetupPerCallsign; + class CInterpolationSetupList; } namespace Network @@ -90,11 +92,14 @@ namespace BlackMisc //! Split into 0..n containers as per callsign QHash splitPerCallsign() const; + //! Replace or add objects by callsign + int replaceOrAddObjectByCallsign(const OBJ &otherObject); + //! Replace or add objects by callsign int replaceOrAddObjectsByCallsign(const CONTAINER &others); //! Incremental update or add object - int incrementalUpdateOrAdd(const OBJ &objectBeforeChanged, const BlackMisc::CPropertyIndexVariantMap &changedValues); + int incrementalUpdateOrAdd(const OBJ &objectBeforeChanged, const CPropertyIndexVariantMap &changedValues); //! Sort by callsign void sortByCallsign(); @@ -115,6 +120,7 @@ namespace BlackMisc extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ICallsignObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ICallsignObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ICallsignObjectList; + extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ICallsignObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ICallsignObjectList; //! \endcond