mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
CListModelBase and CViewBase: reduce the number of template parameters
by relying on what can easily be deduced from the first parameter(s).
This commit is contained in:
@@ -33,7 +33,7 @@ namespace BlackGui
|
||||
{
|
||||
//! Aircraft ICAO codes view
|
||||
class BLACKGUI_EXPORT CAircraftIcaoCodeView :
|
||||
public CViewWithDbObjects<Models::CAircraftIcaoCodeListModel, BlackMisc::Aviation::CAircraftIcaoCodeList, BlackMisc::Aviation::CAircraftIcaoCode, int>
|
||||
public CViewWithDbObjects<Models::CAircraftIcaoCodeListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace BlackGui
|
||||
|
||||
//! Aircraft view
|
||||
class BLACKGUI_EXPORT CAircraftModelView :
|
||||
public COrderableViewWithDbObjects<Models::CAircraftModelListModel, BlackMisc::Simulation::CAircraftModelList, BlackMisc::Simulation::CAircraftModel, int>
|
||||
public COrderableViewWithDbObjects<Models::CAircraftModelListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Aircraft parts
|
||||
class BLACKGUI_EXPORT CAircraftPartsView : public CViewWithTimestampWithOffsetObjects<Models::CAircraftPartsListModel, BlackMisc::Aviation::CAircraftPartsList, BlackMisc::Aviation::CAircraftParts>
|
||||
class BLACKGUI_EXPORT CAircraftPartsView : public CViewWithTimestampWithOffsetObjects<Models::CAircraftPartsListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Aircraft situation change view
|
||||
class BLACKGUI_EXPORT CAircraftSituationChangeView : public CViewWithTimestampWithOffsetObjects<Models::CAircraftSituationChangeListModel, BlackMisc::Aviation::CAircraftSituationChangeList, BlackMisc::Aviation::CAircraftSituationChange>
|
||||
class BLACKGUI_EXPORT CAircraftSituationChangeView : public CViewWithTimestampWithOffsetObjects<Models::CAircraftSituationChangeListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Aircraft situations view
|
||||
class BLACKGUI_EXPORT CAircraftSituationView : public CViewWithTimestampWithOffsetObjects<Models::CAircraftSituationListModel, BlackMisc::Aviation::CAircraftSituationList, BlackMisc::Aviation::CAircraftSituation>
|
||||
class BLACKGUI_EXPORT CAircraftSituationView : public CViewWithTimestampWithOffsetObjects<Models::CAircraftSituationListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace BlackGui
|
||||
{
|
||||
//! Aircraft ICAO codes view
|
||||
class BLACKGUI_EXPORT CAirlineIcaoCodeView :
|
||||
public CViewWithDbObjects<Models::CAirlineIcaoCodeListModel, BlackMisc::Aviation::CAirlineIcaoCodeList, BlackMisc::Aviation::CAirlineIcaoCode, int>
|
||||
public CViewWithDbObjects<Models::CAirlineIcaoCodeListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Airports view
|
||||
class BLACKGUI_EXPORT CAirportView : public CViewBase<Models::CAirportListModel, BlackMisc::Aviation::CAirportList, BlackMisc::Aviation::CAirport>
|
||||
class BLACKGUI_EXPORT CAirportView : public CViewBase<Models::CAirportListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Network servers
|
||||
class BLACKGUI_EXPORT CApplicationInfoView : public CViewBase<Models::CApplicationInfoListModel, BlackMisc::CApplicationInfoList, BlackMisc::CApplicationInfo>
|
||||
class BLACKGUI_EXPORT CApplicationInfoView : public CViewBase<Models::CApplicationInfoListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! ATC stations view
|
||||
class BLACKGUI_EXPORT CAtcStationView : public CViewWithCallsignObjects<BlackGui::Models::CAtcStationListModel, BlackMisc::Aviation::CAtcStationList, BlackMisc::Aviation::CAtcStation>
|
||||
class BLACKGUI_EXPORT CAtcStationView : public CViewWithCallsignObjects<BlackGui::Models::CAtcStationListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Client view
|
||||
class BLACKGUI_EXPORT CClientView : public CViewBase<Models::CClientListModel, BlackMisc::Network::CClientList, BlackMisc::Network::CClient>
|
||||
class BLACKGUI_EXPORT CClientView : public CViewBase<Models::CClientListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Airports view
|
||||
class BLACKGUI_EXPORT CCloudLayerView : public CViewBase<Models::CCloudLayerListModel, BlackMisc::Weather::CCloudLayerList, BlackMisc::Weather::CCloudLayer>
|
||||
class BLACKGUI_EXPORT CCloudLayerView : public CViewBase<Models::CCloudLayerListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Countries
|
||||
class BLACKGUI_EXPORT CCountryView : public CViewBase<Models::CCountryListModel, BlackMisc::CCountryList, BlackMisc::CCountry>
|
||||
class BLACKGUI_EXPORT CCountryView : public CViewBase<Models::CCountryListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace BlackGui
|
||||
{
|
||||
//! Distributors
|
||||
class BLACKGUI_EXPORT CDistributorView :
|
||||
public COrderableViewWithDbObjects<BlackGui::Models::CDistributorListModel, BlackMisc::Simulation::CDistributorList, BlackMisc::Simulation::CDistributor, QString>
|
||||
public COrderableViewWithDbObjects<BlackGui::Models::CDistributorListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Originator servers
|
||||
class BLACKGUI_EXPORT CIdentifierView : public CViewBase<Models::CIdentifierListModel, BlackMisc::CIdentifierList, BlackMisc::CIdentifier>
|
||||
class BLACKGUI_EXPORT CIdentifierView : public CViewBase<Models::CIdentifierListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Distributors
|
||||
class BLACKGUI_EXPORT CInterpolationSetupView : public CViewWithCallsignObjects<Models::CInterpolationSetupListModel, BlackMisc::Simulation::CInterpolationSetupList, BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign>
|
||||
class BLACKGUI_EXPORT CInterpolationSetupView : public CViewWithCallsignObjects<Models::CInterpolationSetupListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace BlackGui
|
||||
{
|
||||
//! Distributors
|
||||
class BLACKGUI_EXPORT CLiveryView :
|
||||
public CViewWithDbObjects<Models::CLiveryListModel, BlackMisc::Aviation::CLiveryList, BlackMisc::Aviation::CLivery, int>
|
||||
public CViewWithDbObjects<Models::CLiveryListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Matching statistics
|
||||
class BLACKGUI_EXPORT CMatchingStatisticsView : public CViewBase<Models::CMatchingStatisticsModel, BlackMisc::Simulation::CMatchingStatistics, BlackMisc::Simulation::CMatchingStatisticsEntry>
|
||||
class BLACKGUI_EXPORT CMatchingStatisticsView : public CViewBase<Models::CMatchingStatisticsModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! User view
|
||||
class BLACKGUI_EXPORT CNameVariantPairView : public CViewBase<Models::CNameVariantPairModel, BlackMisc::CNameVariantPairList, BlackMisc::CNameVariantPair>
|
||||
class BLACKGUI_EXPORT CNameVariantPairView : public CViewBase<Models::CNameVariantPairModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Network servers
|
||||
class BLACKGUI_EXPORT CServerView : public CViewBase<Models::CServerListModel, BlackMisc::Network::CServerList, BlackMisc::Network::CServer>
|
||||
class BLACKGUI_EXPORT CServerView : public CViewBase<Models::CServerListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace BlackGui
|
||||
{
|
||||
//! Aircraft view
|
||||
class BLACKGUI_EXPORT CSimulatedAircraftView :
|
||||
public CViewWithCallsignObjects<Models::CSimulatedAircraftListModel, BlackMisc::Simulation::CSimulatedAircraftList, BlackMisc::Simulation::CSimulatedAircraft>
|
||||
public CViewWithCallsignObjects<Models::CSimulatedAircraftListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Status message view
|
||||
class BLACKGUI_EXPORT CStatusMessageView : public CViewBase<Models::CStatusMessageListModel, BlackMisc::CStatusMessageList, BlackMisc::CStatusMessage>
|
||||
class BLACKGUI_EXPORT CStatusMessageView : public CViewBase<Models::CStatusMessageListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Airports view
|
||||
class BLACKGUI_EXPORT CTemperatureLayerView : public CViewBase<Models::CTemperatureLayerListModel, BlackMisc::Weather::CTemperatureLayerList, BlackMisc::Weather::CTemperatureLayer>
|
||||
class BLACKGUI_EXPORT CTemperatureLayerView : public CViewBase<Models::CTemperatureLayerListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Airports view
|
||||
class BLACKGUI_EXPORT CTextMessageView : public CViewBase<Models::CTextMessageListModel, BlackMisc::Network::CTextMessageList, BlackMisc::Network::CTextMessage>
|
||||
class BLACKGUI_EXPORT CTextMessageView : public CViewBase<Models::CTextMessageListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! User view
|
||||
class BLACKGUI_EXPORT CUserView : public CViewBase<Models::CUserListModel, BlackMisc::Network::CUserList, BlackMisc::Network::CUser>
|
||||
class BLACKGUI_EXPORT CUserView : public CViewBase<Models::CUserListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
CViewBase<ModelClass, ContainerType, ObjectType>::CViewBase(QWidget *parent, ModelClass *model) : CViewBaseNonTemplate(parent), m_model(model)
|
||||
template <class T>
|
||||
CViewBase<T>::CViewBase(QWidget *parent, ModelClass *model) : CViewBaseNonTemplate(parent), m_model(model)
|
||||
{
|
||||
this->setSortingEnabled(true);
|
||||
if (model)
|
||||
@@ -43,8 +43,8 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewBase<ModelClass, ContainerType, ObjectType>::updateContainer(const ContainerType &container, bool sort, bool resize)
|
||||
template <class T>
|
||||
int CViewBase<T>::updateContainer(const ContainerType &container, bool sort, bool resize)
|
||||
{
|
||||
Q_ASSERT_X(m_model, Q_FUNC_INFO, "Missing model");
|
||||
if (container.isEmpty())
|
||||
@@ -95,8 +95,8 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
CWorker *CViewBase<ModelClass, ContainerType, ObjectType>::updateContainerAsync(const ContainerType &container, bool sort, bool resize)
|
||||
template <class T>
|
||||
CWorker *CViewBase<T>::updateContainerAsync(const ContainerType &container, bool sort, bool resize)
|
||||
{
|
||||
// avoid unnecessary effort when empty
|
||||
if (container.isEmpty())
|
||||
@@ -122,8 +122,8 @@ namespace BlackGui
|
||||
return worker;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::updateContainerMaybeAsync(const ContainerType &container, bool sort, bool resize)
|
||||
template <class T>
|
||||
void CViewBase<T>::updateContainerMaybeAsync(const ContainerType &container, bool sort, bool resize)
|
||||
{
|
||||
if (container.isEmpty())
|
||||
{
|
||||
@@ -140,8 +140,8 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::insert(const ObjectType &value, bool resize)
|
||||
template <class T>
|
||||
void CViewBase<T>::insert(const ObjectType &value, bool resize)
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
if (this->rowCount() < 1)
|
||||
@@ -156,8 +156,8 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::insert(const ContainerType &container, bool resize)
|
||||
template <class T>
|
||||
void CViewBase<T>::insert(const ContainerType &container, bool resize)
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
if (this->rowCount() < 1)
|
||||
@@ -172,8 +172,8 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::push_back(const ObjectType &value, bool resize)
|
||||
template <class T>
|
||||
void CViewBase<T>::push_back(const ObjectType &value, bool resize)
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
if (this->rowCount() < 1)
|
||||
@@ -188,8 +188,8 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::push_back(const ContainerType &container, bool resize)
|
||||
template <class T>
|
||||
void CViewBase<T>::push_back(const ContainerType &container, bool resize)
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
if (this->rowCount() < 1)
|
||||
@@ -204,29 +204,29 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
const ObjectType &CViewBase<ModelClass, ContainerType, ObjectType>::at(const QModelIndex &index) const
|
||||
template <class T>
|
||||
const typename CViewBase<T>::ObjectType &CViewBase<T>::at(const QModelIndex &index) const
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->at(index);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
const ContainerType &CViewBase<ModelClass, ContainerType, ObjectType>::container() const
|
||||
template <class T>
|
||||
const typename CViewBase<T>::ContainerType &CViewBase<T>::container() const
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->container();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
const ContainerType &CViewBase<ModelClass, ContainerType, ObjectType>::containerOrFilteredContainer(bool *filtered) const
|
||||
template <class T>
|
||||
const typename CViewBase<T>::ContainerType &CViewBase<T>::containerOrFilteredContainer(bool *filtered) const
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->containerOrFilteredContainer(filtered);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
ContainerType CViewBase<ModelClass, ContainerType, ObjectType>::selectedObjects() const
|
||||
template <class T>
|
||||
typename CViewBase<T>::ContainerType CViewBase<T>::selectedObjects() const
|
||||
{
|
||||
if (!this->hasSelection()) { return ContainerType(); }
|
||||
ContainerType c;
|
||||
@@ -238,8 +238,8 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
ContainerType CViewBase<ModelClass, ContainerType, ObjectType>::unselectedObjects() const
|
||||
template <class T>
|
||||
typename CViewBase<T>::ContainerType CViewBase<T>::unselectedObjects() const
|
||||
{
|
||||
if (!this->hasSelection()) { return this->containerOrFilteredContainer(); }
|
||||
ContainerType c;
|
||||
@@ -251,8 +251,8 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
ObjectType CViewBase<ModelClass, ContainerType, ObjectType>::firstSelectedOrDefaultObject() const
|
||||
template <class T>
|
||||
typename CViewBase<T>::ObjectType CViewBase<T>::firstSelectedOrDefaultObject() const
|
||||
{
|
||||
if (this->hasSelection())
|
||||
{
|
||||
@@ -267,8 +267,8 @@ namespace BlackGui
|
||||
return ObjectType();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewBase<ModelClass, ContainerType, ObjectType>::updateSelected(const CPropertyIndexVariantMap &vm)
|
||||
template <class T>
|
||||
int CViewBase<T>::updateSelected(const CPropertyIndexVariantMap &vm)
|
||||
{
|
||||
if (vm.isEmpty()) { return 0; }
|
||||
if (!hasSelection()) { return 0; }
|
||||
@@ -306,22 +306,22 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewBase<ModelClass, ContainerType, ObjectType>::updateSelected(const CVariant &variant, const CPropertyIndex &index)
|
||||
template <class T>
|
||||
int CViewBase<T>::updateSelected(const CVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
const CPropertyIndexVariantMap vm(index, variant);
|
||||
return this->updateSelected(vm);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
ObjectType CViewBase<ModelClass, ContainerType, ObjectType>::selectedObject() const
|
||||
template <class T>
|
||||
typename CViewBase<T>::ObjectType CViewBase<T>::selectedObject() const
|
||||
{
|
||||
const ContainerType c = this->selectedObjects();
|
||||
return c.frontOrDefault();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewBase<ModelClass, ContainerType, ObjectType>::removeSelectedRows()
|
||||
template <class T>
|
||||
int CViewBase<T>::removeSelectedRows()
|
||||
{
|
||||
if (!this->hasSelection()) { return 0; }
|
||||
if (this->isEmpty()) { return 0; }
|
||||
@@ -348,8 +348,8 @@ namespace BlackGui
|
||||
return delta;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::presizeOrFullResizeToContents()
|
||||
template <class T>
|
||||
void CViewBase<T>::presizeOrFullResizeToContents()
|
||||
{
|
||||
const int rc = this->rowCount();
|
||||
if (rc > ResizeSubsetThreshold)
|
||||
@@ -369,15 +369,15 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::clearHighlighting()
|
||||
template <class T>
|
||||
void CViewBase<T>::clearHighlighting()
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->clearHighlighting();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::materializeFilter()
|
||||
template <class T>
|
||||
void CViewBase<T>::materializeFilter()
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
if (!m_model->hasFilter()) { return; }
|
||||
@@ -387,44 +387,44 @@ namespace BlackGui
|
||||
this->updateContainerMaybeAsync(filtered);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::clear()
|
||||
template <class T>
|
||||
void CViewBase<T>::clear()
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
m_model->clear();
|
||||
this->hideLoadIndicator();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewBase<ModelClass, ContainerType, ObjectType>::rowCount() const
|
||||
template <class T>
|
||||
int CViewBase<T>::rowCount() const
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->rowCount();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewBase<ModelClass, ContainerType, ObjectType>::columnCount() const
|
||||
template <class T>
|
||||
int CViewBase<T>::columnCount() const
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->columnCount(QModelIndex());
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
bool CViewBase<ModelClass, ContainerType, ObjectType>::isEmpty() const
|
||||
template <class T>
|
||||
bool CViewBase<T>::isEmpty() const
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->rowCount() < 1;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
bool CViewBase<ModelClass, ContainerType, ObjectType>::isOrderable() const
|
||||
template <class T>
|
||||
bool CViewBase<T>::isOrderable() const
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->isOrderable();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::allowDragDrop(bool allowDrag, bool allowDrop, bool allowDropJsonFile)
|
||||
template <class T>
|
||||
void CViewBase<T>::allowDragDrop(bool allowDrag, bool allowDrop, bool allowDropJsonFile)
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
|
||||
@@ -436,15 +436,15 @@ namespace BlackGui
|
||||
m_model->allowFileDrop(allowDropJsonFile);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
bool CViewBase<ModelClass, ContainerType, ObjectType>::isDropAllowed() const
|
||||
template <class T>
|
||||
bool CViewBase<T>::isDropAllowed() const
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->isDropAllowed();
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::dropEvent(QDropEvent *event)
|
||||
template<class T>
|
||||
void CViewBase<T>::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (m_model && m_model->isJsonFileDropAllowed() && CGuiUtility::isMimeRepresentingReadableJsonFile(event->mimeData()))
|
||||
{
|
||||
@@ -456,43 +456,43 @@ namespace BlackGui
|
||||
CViewBaseNonTemplate::dropEvent(event);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
bool CViewBase<ModelClass, ContainerType, ObjectType>::acceptDrop(const QMimeData *mimeData) const
|
||||
template <class T>
|
||||
bool CViewBase<T>::acceptDrop(const QMimeData *mimeData) const
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
const bool a = m_model->acceptDrop(mimeData);
|
||||
return a;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
bool CViewBase<ModelClass, ContainerType, ObjectType>::setSorting(const CPropertyIndex &propertyIndex, Qt::SortOrder order)
|
||||
template <class T>
|
||||
bool CViewBase<T>::setSorting(const CPropertyIndex &propertyIndex, Qt::SortOrder order)
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->setSorting(propertyIndex, order);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::sortByPropertyIndex(const CPropertyIndex &propertyIndex, Qt::SortOrder order)
|
||||
template <class T>
|
||||
void CViewBase<T>::sortByPropertyIndex(const CPropertyIndex &propertyIndex, Qt::SortOrder order)
|
||||
{
|
||||
m_model->sortByPropertyIndex(propertyIndex, order);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
QJsonObject CViewBase<ModelClass, ContainerType, ObjectType>::toJson(bool selectedOnly) const
|
||||
template <class T>
|
||||
QJsonObject CViewBase<T>::toJson(bool selectedOnly) const
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->toJson(selectedOnly);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
QString CViewBase<ModelClass, ContainerType, ObjectType>::toJsonString(QJsonDocument::JsonFormat format, bool selectedOnly) const
|
||||
template <class T>
|
||||
QString CViewBase<T>::toJsonString(QJsonDocument::JsonFormat format, bool selectedOnly) const
|
||||
{
|
||||
Q_ASSERT(m_model);
|
||||
return m_model->toJsonString(format, selectedOnly);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::setObjectName(const QString &name)
|
||||
template <class T>
|
||||
void CViewBase<T>::setObjectName(const QString &name)
|
||||
{
|
||||
// then name here is mainly set for debugging purposes so each model can be identified
|
||||
Q_ASSERT(m_model);
|
||||
@@ -501,33 +501,33 @@ namespace BlackGui
|
||||
m_model->setObjectName(modelName);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::takeFilterOwnership(std::unique_ptr<BlackGui::Models::IModelFilter<ContainerType> > &filter)
|
||||
template <class T>
|
||||
void CViewBase<T>::takeFilterOwnership(std::unique_ptr<BlackGui::Models::IModelFilter<ContainerType> > &filter)
|
||||
{
|
||||
this->derivedModel()->takeFilterOwnership(filter);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::removeFilter()
|
||||
template <class T>
|
||||
void CViewBase<T>::removeFilter()
|
||||
{
|
||||
this->derivedModel()->removeFilter();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
bool CViewBase<ModelClass, ContainerType, ObjectType>::hasFilter() const
|
||||
template <class T>
|
||||
bool CViewBase<T>::hasFilter() const
|
||||
{
|
||||
return derivedModel()->hasFilter();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::addContainerTypesAsDropTypes(bool objectType, bool containerType)
|
||||
template <class T>
|
||||
void CViewBase<T>::addContainerTypesAsDropTypes(bool objectType, bool containerType)
|
||||
{
|
||||
if (objectType) { m_model->addAcceptedMetaTypeId(qMetaTypeId<ObjectType>()); }
|
||||
if (containerType) { m_model->addAcceptedMetaTypeId(qMetaTypeId<ContainerType>()); }
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::initAsOrderable()
|
||||
template <class T>
|
||||
void CViewBase<T>::initAsOrderable()
|
||||
{
|
||||
Q_ASSERT_X(isOrderable(), Q_FUNC_INFO, "Model not orderable");
|
||||
this->allowDragDrop(true, true);
|
||||
@@ -536,8 +536,8 @@ namespace BlackGui
|
||||
this->addContainerTypesAsDropTypes(true, true);
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::setTabWidgetViewText(QTabWidget *tw, int index)
|
||||
template<class T>
|
||||
void CViewBase<T>::setTabWidgetViewText(QTabWidget *tw, int index)
|
||||
{
|
||||
if (!tw) { return; }
|
||||
QString o = tw->tabText(index);
|
||||
@@ -546,8 +546,8 @@ namespace BlackGui
|
||||
tw->setTabText(index, o);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::setSortIndicator()
|
||||
template <class T>
|
||||
void CViewBase<T>::setSortIndicator()
|
||||
{
|
||||
if (m_model->hasValidSortColumn())
|
||||
{
|
||||
@@ -558,8 +558,8 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::standardInit(ModelClass *model)
|
||||
template <class T>
|
||||
void CViewBase<T>::standardInit(ModelClass *model)
|
||||
{
|
||||
Q_ASSERT_X(model || m_model, Q_FUNC_INFO, "Missing model");
|
||||
if (model)
|
||||
@@ -590,15 +590,15 @@ namespace BlackGui
|
||||
this->setSortIndicator();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
bool CViewBase<ModelClass, ContainerType, ObjectType>::reachedResizeThreshold(int containerSize) const
|
||||
template <class T>
|
||||
bool CViewBase<T>::reachedResizeThreshold(int containerSize) const
|
||||
{
|
||||
if (containerSize < 0) { return this->rowCount() > m_skipResizeThreshold; }
|
||||
return containerSize > m_skipResizeThreshold;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::performModeBasedResizeToContent()
|
||||
template <class T>
|
||||
void CViewBase<T>::performModeBasedResizeToContent()
|
||||
{
|
||||
// small set or large set? This only performs real resizing, no presizing
|
||||
// remark, see also presizeOrFullResizeToContents
|
||||
@@ -612,15 +612,15 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewBase<ModelClass, ContainerType, ObjectType>::performUpdateContainer(const BlackMisc::CVariant &variant, bool sort, bool resize)
|
||||
template <class T>
|
||||
int CViewBase<T>::performUpdateContainer(const BlackMisc::CVariant &variant, bool sort, bool resize)
|
||||
{
|
||||
ContainerType c(variant.to<ContainerType>());
|
||||
return this->updateContainer(c, sort, resize);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::updateSortIndicator()
|
||||
template <class T>
|
||||
void CViewBase<T>::updateSortIndicator()
|
||||
{
|
||||
if (this->derivedModel()->hasValidSortColumn())
|
||||
{
|
||||
@@ -630,50 +630,50 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::mouseOverCallback(const QModelIndex &index, bool mouseOver)
|
||||
template <class T>
|
||||
void CViewBase<T>::mouseOverCallback(const QModelIndex &index, bool mouseOver)
|
||||
{
|
||||
// void
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(mouseOver);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::drawDropIndicator(bool indicator)
|
||||
template <class T>
|
||||
void CViewBase<T>::drawDropIndicator(bool indicator)
|
||||
{
|
||||
m_dropIndicator = indicator;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::selectObjects(const ContainerType &selectedObjects)
|
||||
template <class T>
|
||||
void CViewBase<T>::selectObjects(const ContainerType &selectedObjects)
|
||||
{
|
||||
Q_UNUSED(selectedObjects);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
CStatusMessage CViewBase<ModelClass, ContainerType, ObjectType>::modifyLoadedJsonData(ContainerType &data) const
|
||||
template <class T>
|
||||
CStatusMessage CViewBase<T>::modifyLoadedJsonData(ContainerType &data) const
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
static const CStatusMessage e(this, CStatusMessage::SeverityInfo, "no modification", true);
|
||||
return e;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
CStatusMessage CViewBase<ModelClass, ContainerType, ObjectType>::validateLoadedJsonData(const ContainerType &data) const
|
||||
template <class T>
|
||||
CStatusMessage CViewBase<T>::validateLoadedJsonData(const ContainerType &data) const
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
static const CStatusMessage e(this, CStatusMessage::SeverityInfo, "validation passed", true);
|
||||
return e;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::jsonLoadedAndModelUpdated(const ContainerType &data)
|
||||
template <class T>
|
||||
void CViewBase<T>::jsonLoadedAndModelUpdated(const ContainerType &data)
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::customMenu(CMenuActions &menuActions)
|
||||
template<class T>
|
||||
void CViewBase<T>::customMenu(CMenuActions &menuActions)
|
||||
{
|
||||
CViewBaseNonTemplate::customMenu(menuActions);
|
||||
|
||||
@@ -684,8 +684,8 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
CStatusMessage CViewBase<ModelClass, ContainerType, ObjectType>::loadJsonFile(const QString &fileName)
|
||||
template<class T>
|
||||
CStatusMessage CViewBase<T>::loadJsonFile(const QString &fileName)
|
||||
{
|
||||
CStatusMessage m;
|
||||
do
|
||||
@@ -761,8 +761,8 @@ namespace BlackGui
|
||||
return m;
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::displayContainerAsJsonPopup(bool selectedOnly)
|
||||
template<class T>
|
||||
void CViewBase<T>::displayContainerAsJsonPopup(bool selectedOnly)
|
||||
{
|
||||
const ContainerType container = selectedOnly ? this->selectedObjects() : this->container();
|
||||
const QString json = container.toJsonString();
|
||||
@@ -772,8 +772,8 @@ namespace BlackGui
|
||||
this->textEditDialog()->show();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
CStatusMessage CViewBase<ModelClass, ContainerType, ObjectType>::ps_loadJson(const QString &directory)
|
||||
template <class T>
|
||||
CStatusMessage CViewBase<T>::ps_loadJson(const QString &directory)
|
||||
{
|
||||
const QString fileName = QFileDialog::getOpenFileName(nullptr,
|
||||
tr("Load data file"),
|
||||
@@ -782,8 +782,8 @@ namespace BlackGui
|
||||
return this->loadJsonFile(fileName);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
CStatusMessage CViewBase<ModelClass, ContainerType, ObjectType>::ps_saveJson(bool selectedOnly, const QString &directory)
|
||||
template <class T>
|
||||
CStatusMessage CViewBase<T>::ps_saveJson(bool selectedOnly, const QString &directory)
|
||||
{
|
||||
const QString fileName = QFileDialog::getSaveFileName(nullptr,
|
||||
tr("Save data file"),
|
||||
@@ -800,8 +800,8 @@ namespace BlackGui
|
||||
CStatusMessage(this, CStatusMessage::SeverityError, "Writing " + fileName + " failed", true);
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::copy()
|
||||
template<class T>
|
||||
void CViewBase<T>::copy()
|
||||
{
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
if (!clipboard) { return; }
|
||||
@@ -813,16 +813,16 @@ namespace BlackGui
|
||||
clipboard->setText(json);
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::cut()
|
||||
template<class T>
|
||||
void CViewBase<T>::cut()
|
||||
{
|
||||
if (!QApplication::clipboard()) { return; }
|
||||
this->copy();
|
||||
this->removeSelectedRows();
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::paste()
|
||||
template<class T>
|
||||
void CViewBase<T>::paste()
|
||||
{
|
||||
const QClipboard *clipboard = QApplication::clipboard();
|
||||
if (!clipboard) { return; }
|
||||
@@ -844,15 +844,15 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
bool CViewBase<ModelClass, ContainerType, ObjectType>::ps_filterDialogFinished(int status)
|
||||
template <class T>
|
||||
bool CViewBase<T>::ps_filterDialogFinished(int status)
|
||||
{
|
||||
QDialog::DialogCode statusCode = static_cast<QDialog::DialogCode>(status);
|
||||
return ps_filterWidgetChangedFilter(statusCode == QDialog::Accepted);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
bool CViewBase<ModelClass, ContainerType, ObjectType>::ps_filterWidgetChangedFilter(bool enabled)
|
||||
template <class T>
|
||||
bool CViewBase<T>::ps_filterWidgetChangedFilter(bool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
@@ -885,30 +885,30 @@ namespace BlackGui
|
||||
return true; // handled
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::ps_removeFilter()
|
||||
template <class T>
|
||||
void CViewBase<T>::ps_removeFilter()
|
||||
{
|
||||
this->derivedModel()->removeFilter();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::ps_clicked(const QModelIndex &index)
|
||||
template <class T>
|
||||
void CViewBase<T>::ps_clicked(const QModelIndex &index)
|
||||
{
|
||||
if (!m_acceptClickSelection) { return; }
|
||||
if (!index.isValid()) { return; }
|
||||
emit objectClicked(CVariant::fromValue(at(index)));
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::ps_doubleClicked(const QModelIndex &index)
|
||||
template <class T>
|
||||
void CViewBase<T>::ps_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!m_acceptDoubleClickSelection) { return; }
|
||||
if (!index.isValid()) { return; }
|
||||
emit objectDoubleClicked(CVariant::fromValue(at(index)));
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::ps_rowSelected(const QModelIndex &index)
|
||||
template <class T>
|
||||
void CViewBase<T>::ps_rowSelected(const QModelIndex &index)
|
||||
{
|
||||
if (!m_acceptRowSelection) { return; }
|
||||
if (!index.isValid()) { return; }
|
||||
|
||||
@@ -591,14 +591,23 @@ namespace BlackGui
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackGui::Views::CViewBaseNonTemplate::Menu)
|
||||
|
||||
//! Base class for views
|
||||
template <class ModelClass, class ContainerType, class ObjectType> class CViewBase :
|
||||
template <class T> class CViewBase :
|
||||
public CViewBaseNonTemplate,
|
||||
public Models::ISelectionModel<ContainerType>
|
||||
public Models::ISelectionModel<typename T::ContainerType>
|
||||
{
|
||||
// I cannot use Q_OBJECT here, because: Template classes are not supported by Q_OBJECT
|
||||
// and I cannot declare slots as SLOT because I have no Q_OBJECT macro
|
||||
|
||||
public:
|
||||
//! Model type
|
||||
using ModelClass = T;
|
||||
|
||||
//! Model container type
|
||||
using ContainerType = typename T::ContainerType;
|
||||
|
||||
//! Model container element type
|
||||
using ObjectType = typename T::ObjectType;
|
||||
|
||||
//! Destructor
|
||||
virtual ~CViewBase() { if (m_model) { m_model->markDestroyed(); }}
|
||||
|
||||
|
||||
@@ -13,14 +13,14 @@ namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
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::CAircraftSituationChangeListModel, BlackMisc::Aviation::CAircraftSituationChangeList, BlackMisc::Aviation::CAircraftSituationChange>;
|
||||
template class CViewBase<BlackGui::Models::CAirlineIcaoCodeListModel, BlackMisc::Aviation::CAirlineIcaoCodeList, BlackMisc::Aviation::CAirlineIcaoCode>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftIcaoCodeListModel, BlackMisc::Aviation::CAircraftIcaoCodeList, BlackMisc::Aviation::CAircraftIcaoCode>;
|
||||
template class CViewBase<BlackGui::Models::CAirportListModel, BlackMisc::Aviation::CAirportList, BlackMisc::Aviation::CAirport>;
|
||||
template class CViewBase<BlackGui::Models::CAtcStationListModel, BlackMisc::Aviation::CAtcStationList, BlackMisc::Aviation::CAtcStation>;
|
||||
template class CViewBase<BlackGui::Models::CLiveryListModel, BlackMisc::Aviation::CLiveryList, BlackMisc::Aviation::CLivery>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftModelListModel>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftPartsListModel>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftSituationListModel>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftSituationChangeListModel>;
|
||||
template class CViewBase<BlackGui::Models::CAirlineIcaoCodeListModel>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftIcaoCodeListModel>;
|
||||
template class CViewBase<BlackGui::Models::CAirportListModel>;
|
||||
template class CViewBase<BlackGui::Models::CAtcStationListModel>;
|
||||
template class CViewBase<BlackGui::Models::CLiveryListModel>;
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -13,10 +13,10 @@ namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
template class CViewBase<BlackGui::Models::CApplicationInfoListModel, BlackMisc::CApplicationInfoList, BlackMisc::CApplicationInfo>;
|
||||
template class CViewBase<BlackGui::Models::CCountryListModel, BlackMisc::CCountryList, BlackMisc::CCountry>;
|
||||
template class CViewBase<BlackGui::Models::CStatusMessageListModel, BlackMisc::CStatusMessageList, BlackMisc::CStatusMessage>;
|
||||
template class CViewBase<BlackGui::Models::CIdentifierListModel, BlackMisc::CIdentifierList, BlackMisc::CIdentifier>;
|
||||
template class CViewBase<BlackGui::Models::CNameVariantPairModel, BlackMisc::CNameVariantPairList, BlackMisc::CNameVariantPair>;
|
||||
template class CViewBase<BlackGui::Models::CApplicationInfoListModel>;
|
||||
template class CViewBase<BlackGui::Models::CCountryListModel>;
|
||||
template class CViewBase<BlackGui::Models::CStatusMessageListModel>;
|
||||
template class CViewBase<BlackGui::Models::CIdentifierListModel>;
|
||||
template class CViewBase<BlackGui::Models::CNameVariantPairModel>;
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
template class CViewBase<BlackGui::Models::CClientListModel, BlackMisc::Network::CClientList, BlackMisc::Network::CClient>;
|
||||
template class CViewBase<BlackGui::Models::CServerListModel, BlackMisc::Network::CServerList, BlackMisc::Network::CServer>;
|
||||
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::CClientListModel>;
|
||||
template class CViewBase<BlackGui::Models::CServerListModel>;
|
||||
template class CViewBase<BlackGui::Models::CTextMessageListModel>;
|
||||
template class CViewBase<BlackGui::Models::CUserListModel>;
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
template class CViewBase<BlackGui::Models::CDistributorListModel, BlackMisc::Simulation::CDistributorList, BlackMisc::Simulation::CDistributor>;
|
||||
template class CViewBase<BlackGui::Models::CInterpolationSetupListModel, BlackMisc::Simulation::CInterpolationSetupList, BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign>;
|
||||
template class CViewBase<BlackGui::Models::CMatchingStatisticsModel, BlackMisc::Simulation::CMatchingStatistics, BlackMisc::Simulation::CMatchingStatisticsEntry>;
|
||||
template class CViewBase<BlackGui::Models::CSimulatedAircraftListModel, BlackMisc::Simulation::CSimulatedAircraftList, BlackMisc::Simulation::CSimulatedAircraft>;
|
||||
template class CViewBase<BlackGui::Models::CDistributorListModel>;
|
||||
template class CViewBase<BlackGui::Models::CInterpolationSetupListModel>;
|
||||
template class CViewBase<BlackGui::Models::CMatchingStatisticsModel>;
|
||||
template class CViewBase<BlackGui::Models::CSimulatedAircraftListModel>;
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
template class CViewBase<BlackGui::Models::CCloudLayerListModel, BlackMisc::Weather::CCloudLayerList, BlackMisc::Weather::CCloudLayer>;
|
||||
template class CViewBase<BlackGui::Models::CTemperatureLayerListModel, BlackMisc::Weather::CTemperatureLayerList, BlackMisc::Weather::CTemperatureLayer>;
|
||||
template class CViewBase<BlackGui::Models::CWindLayerListModel, BlackMisc::Weather::CWindLayerList, BlackMisc::Weather::CWindLayer>;
|
||||
template class CViewBase<BlackGui::Models::CCloudLayerListModel>;
|
||||
template class CViewBase<BlackGui::Models::CTemperatureLayerListModel>;
|
||||
template class CViewBase<BlackGui::Models::CWindLayerListModel>;
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -29,28 +29,28 @@ namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
CViewWithCallsignObjects<ModelClass, ContainerType, ObjectType>::CViewWithCallsignObjects(QWidget *parent) :
|
||||
CViewBase<ModelClass, ContainerType, ObjectType>(parent)
|
||||
template <class T>
|
||||
CViewWithCallsignObjects<T>::CViewWithCallsignObjects(QWidget *parent) :
|
||||
CViewBase<T>(parent)
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewWithCallsignObjects<ModelClass, ContainerType, ObjectType>::selectCallsign(const CCallsign &callsign)
|
||||
template <class T>
|
||||
void CViewWithCallsignObjects<T>::selectCallsign(const CCallsign &callsign)
|
||||
{
|
||||
const CCallsignSet cs({callsign});
|
||||
this->selectCallsigns(cs);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewWithCallsignObjects<ModelClass, ContainerType, ObjectType>::selectCallsigns(const CCallsignSet &callsigns)
|
||||
template <class T>
|
||||
void CViewWithCallsignObjects<T>::selectCallsigns(const CCallsignSet &callsigns)
|
||||
{
|
||||
if (callsigns.isEmpty()) { return; }
|
||||
this->clearSelection();
|
||||
int r = -1;
|
||||
QSet<int> rows;
|
||||
for (const ObjectType &obj : CViewBase<ModelClass, ContainerType, ObjectType>::containerOrFilteredContainer())
|
||||
for (const ObjectType &obj : CViewBase<T>::containerOrFilteredContainer())
|
||||
{
|
||||
r++;
|
||||
if (callsigns.contains(obj.getCallsign()))
|
||||
@@ -61,24 +61,24 @@ namespace BlackGui
|
||||
this->selectRows(rows);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
CCallsignSet CViewWithCallsignObjects<ModelClass, ContainerType, ObjectType>::selectedCallsigns() const
|
||||
template <class T>
|
||||
CCallsignSet CViewWithCallsignObjects<T>::selectedCallsigns() const
|
||||
{
|
||||
if (!this->hasSelection()) { return CCallsignSet(); }
|
||||
const ContainerType selected(this->selectedObjects());
|
||||
return selected.getCallsigns();
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewWithCallsignObjects<ModelClass, ContainerType, ObjectType>::removeCallsign(const CCallsign &callsign)
|
||||
template<class T>
|
||||
int CViewWithCallsignObjects<T>::removeCallsign(const CCallsign &callsign)
|
||||
{
|
||||
if (callsign.isEmpty()) { return 0; }
|
||||
const CCallsignSet set({ callsign });
|
||||
return this->removeCallsigns(set);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewWithCallsignObjects<ModelClass, ContainerType, ObjectType>::removeCallsigns(const CCallsignSet &callsigns)
|
||||
template <class T>
|
||||
int CViewWithCallsignObjects<T>::removeCallsigns(const CCallsignSet &callsigns)
|
||||
{
|
||||
if (callsigns.isEmpty()) { return 0; }
|
||||
if (this->isEmpty()) { return 0; }
|
||||
@@ -92,8 +92,8 @@ namespace BlackGui
|
||||
return delta;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewWithCallsignObjects<ModelClass, ContainerType, ObjectType>::replaceOrAddObjectsByCallsign(const ContainerType &container)
|
||||
template <class T>
|
||||
int CViewWithCallsignObjects<T>::replaceOrAddObjectsByCallsign(const ContainerType &container)
|
||||
{
|
||||
if (container.isEmpty()) { return 0; }
|
||||
ContainerType copy(this->container());
|
||||
@@ -103,8 +103,8 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewWithCallsignObjects<ModelClass, ContainerType, ObjectType>::replaceOrAddObjectByCallsign(const ObjectType &object)
|
||||
template<class T>
|
||||
int CViewWithCallsignObjects<T>::replaceOrAddObjectByCallsign(const ObjectType &object)
|
||||
{
|
||||
ContainerType copy(this->container());
|
||||
const int c = copy.replaceOrAddObjectByCallsign(object);
|
||||
@@ -113,8 +113,8 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewWithCallsignObjects<ModelClass, ContainerType, ObjectType>::selectObjects(const ContainerType &selectedObjects)
|
||||
template<class T>
|
||||
void CViewWithCallsignObjects<T>::selectObjects(const ContainerType &selectedObjects)
|
||||
{
|
||||
if (!selectedObjects.isEmpty())
|
||||
{
|
||||
@@ -122,9 +122,9 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template class CViewWithCallsignObjects<BlackGui::Models::CAtcStationListModel, BlackMisc::Aviation::CAtcStationList, BlackMisc::Aviation::CAtcStation>;
|
||||
template class CViewWithCallsignObjects<BlackGui::Models::CInterpolationSetupListModel, BlackMisc::Simulation::CInterpolationSetupList, BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign>;
|
||||
template class CViewWithCallsignObjects<BlackGui::Models::CSimulatedAircraftListModel, BlackMisc::Simulation::CSimulatedAircraftList, BlackMisc::Simulation::CSimulatedAircraft>;
|
||||
template class CViewWithCallsignObjects<BlackGui::Models::CAtcStationListModel>;
|
||||
template class CViewWithCallsignObjects<BlackGui::Models::CInterpolationSetupListModel>;
|
||||
template class CViewWithCallsignObjects<BlackGui::Models::CSimulatedAircraftListModel>;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -29,10 +29,19 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Base class for views with DB objects
|
||||
template <class ModelClass, class ContainerType, class ObjectType> class CViewWithCallsignObjects :
|
||||
public CViewBase<ModelClass, ContainerType, ObjectType>
|
||||
template <class T> class CViewWithCallsignObjects :
|
||||
public CViewBase<T>
|
||||
{
|
||||
public:
|
||||
//! Model type
|
||||
using ModelClass = T;
|
||||
|
||||
//! Model container type
|
||||
using ContainerType = typename T::ContainerType;
|
||||
|
||||
//! Model container element type
|
||||
using ObjectType = typename T::ObjectType;
|
||||
|
||||
//! Select callsign
|
||||
void selectCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
|
||||
@@ -40,40 +40,40 @@ namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::CViewWithDbObjects(QWidget *parent) :
|
||||
CViewBase<ModelClass, ContainerType, ObjectType>(parent)
|
||||
template <class T>
|
||||
CViewWithDbObjects<T>::CViewWithDbObjects(QWidget *parent) :
|
||||
CViewBase<ModelClass>(parent)
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
ObjectType CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::latestObject() const
|
||||
template <class T>
|
||||
typename CViewWithDbObjects<T>::ObjectType CViewWithDbObjects<T>::latestObject() const
|
||||
{
|
||||
return this->container().latestObject();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
ObjectType CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::oldestObject() const
|
||||
template <class T>
|
||||
typename CViewWithDbObjects<T>::ObjectType CViewWithDbObjects<T>::oldestObject() const
|
||||
{
|
||||
return this->container().oldestObject();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
void CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::selectDbKey(const KeyType &key)
|
||||
template <class T>
|
||||
void CViewWithDbObjects<T>::selectDbKey(const KeyType &key)
|
||||
{
|
||||
const QSet<KeyType> set({key});
|
||||
this->selectDbKeys(set);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
void CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::selectDbKeys(const QSet<KeyType> &keys)
|
||||
template <class T>
|
||||
void CViewWithDbObjects<T>::selectDbKeys(const QSet<KeyType> &keys)
|
||||
{
|
||||
if (keys.isEmpty()) { return; }
|
||||
this->clearSelection();
|
||||
int r = -1;
|
||||
QSet<int> rows;
|
||||
for (const ObjectType &obj : CViewBase<ModelClass, ContainerType, ObjectType>::containerOrFilteredContainer())
|
||||
for (const ObjectType &obj : CViewBase<ModelClass>::containerOrFilteredContainer())
|
||||
{
|
||||
r++;
|
||||
if (!obj.hasValidDbKey()) { continue; }
|
||||
@@ -85,16 +85,16 @@ namespace BlackGui
|
||||
this->selectRows(rows);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
QSet<KeyType> CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::selectedDbKeys() const
|
||||
template <class T>
|
||||
QSet<typename CViewWithDbObjects<T>::KeyType> CViewWithDbObjects<T>::selectedDbKeys() const
|
||||
{
|
||||
if (!this->hasSelection()) { return QSet<KeyType>(); }
|
||||
const ContainerType selected(this->selectedObjects());
|
||||
return selected.toDbKeySet();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
int CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::removeDbKeys(const QSet<KeyType> &keys)
|
||||
template <class T>
|
||||
int CViewWithDbObjects<T>::removeDbKeys(const QSet<KeyType> &keys)
|
||||
{
|
||||
if (keys.isEmpty()) { return 0; }
|
||||
if (this->isEmpty()) { return 0; }
|
||||
@@ -108,8 +108,8 @@ namespace BlackGui
|
||||
return delta;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
int CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::replaceOrAddObjectsByKey(const ContainerType &container)
|
||||
template <class T>
|
||||
int CViewWithDbObjects<T>::replaceOrAddObjectsByKey(const ContainerType &container)
|
||||
{
|
||||
if (container.isEmpty()) { return 0; }
|
||||
ContainerType copy(this->container());
|
||||
@@ -119,21 +119,21 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
void CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::customMenu(Menus::CMenuActions &menuActions)
|
||||
template <class T>
|
||||
void CViewWithDbObjects<T>::customMenu(Menus::CMenuActions &menuActions)
|
||||
{
|
||||
CViewBase<ModelClass, ContainerType, ObjectType>::customMenu(menuActions);
|
||||
CViewBase<ModelClass>::customMenu(menuActions);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::COrderableViewWithDbObjects(QWidget *parent) :
|
||||
CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::CViewWithDbObjects(parent)
|
||||
template <class T>
|
||||
COrderableViewWithDbObjects<T>::COrderableViewWithDbObjects(QWidget *parent) :
|
||||
CViewWithDbObjects<T>::CViewWithDbObjects(parent)
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
void COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::customMenu(CMenuActions &menuActions)
|
||||
template <class T>
|
||||
void COrderableViewWithDbObjects<T>::customMenu(CMenuActions &menuActions)
|
||||
{
|
||||
if (this->m_menus.testFlag(CViewBaseNonTemplate::MenuOrderable) && this->hasSelection())
|
||||
{
|
||||
@@ -162,7 +162,7 @@ namespace BlackGui
|
||||
m_leOrder->setValidator(m_validator);
|
||||
QWidgetAction *orderAction = new QWidgetAction(this);
|
||||
orderAction->setDefaultWidget(m_frame);
|
||||
QObject::connect(m_leOrder, &QLineEdit::returnPressed, this, &COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::orderToLineEdit);
|
||||
QObject::connect(m_leOrder, &QLineEdit::returnPressed, this, &COrderableViewWithDbObjects<T>::orderToLineEdit);
|
||||
m_menuActions[0] = orderAction;
|
||||
}
|
||||
}
|
||||
@@ -171,15 +171,15 @@ namespace BlackGui
|
||||
m_leOrder->setPlaceholderText("New order 0-" + QString::number(maxOrder));
|
||||
|
||||
menuActions.addAction(m_menuActions[0], CMenuAction::pathViewOrder());
|
||||
m_menuActions[1] = menuActions.addAction(CIcons::arrowMediumNorth16(), "To top", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::orderToTop });
|
||||
m_menuActions[2] = menuActions.addAction(CIcons::arrowMediumSouth16(), "To bottom", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::orderToBottom });
|
||||
m_menuActions[3] = menuActions.addAction(CIcons::arrowMediumWest16(), "Freeze current order", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::freezeCurrentOrder });
|
||||
m_menuActions[1] = menuActions.addAction(CIcons::arrowMediumNorth16(), "To top", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects<T>::orderToTop });
|
||||
m_menuActions[2] = menuActions.addAction(CIcons::arrowMediumSouth16(), "To bottom", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects<T>::orderToBottom });
|
||||
m_menuActions[3] = menuActions.addAction(CIcons::arrowMediumWest16(), "Freeze current order", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects<T>::freezeCurrentOrder });
|
||||
}
|
||||
CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::customMenu(menuActions);
|
||||
CViewWithDbObjects<T>::customMenu(menuActions);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
void COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::selectObjects(const ContainerType &selectedObjects)
|
||||
template <class T>
|
||||
void COrderableViewWithDbObjects<T>::selectObjects(const ContainerType &selectedObjects)
|
||||
{
|
||||
if (!selectedObjects.isEmpty())
|
||||
{
|
||||
@@ -187,8 +187,8 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
void COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::moveSelectedItems(int order)
|
||||
template <class T>
|
||||
void COrderableViewWithDbObjects<T>::moveSelectedItems(int order)
|
||||
{
|
||||
if (this->isEmpty()) { return; }
|
||||
const ContainerType objs(this->selectedObjects());
|
||||
@@ -196,14 +196,14 @@ namespace BlackGui
|
||||
this->m_model->moveItems(objs, order);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
void COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::orderToTop()
|
||||
template <class T>
|
||||
void COrderableViewWithDbObjects<T>::orderToTop()
|
||||
{
|
||||
this->moveSelectedItems(0);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
void COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::orderToBottom()
|
||||
template <class T>
|
||||
void COrderableViewWithDbObjects<T>::orderToBottom()
|
||||
{
|
||||
int c = this->model()->rowCount() - 1;
|
||||
if (c >= 0)
|
||||
@@ -212,8 +212,8 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
void COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::orderToLineEdit()
|
||||
template <class T>
|
||||
void COrderableViewWithDbObjects<T>::orderToLineEdit()
|
||||
{
|
||||
if (this->isEmpty()) { return; }
|
||||
QLineEdit *le = qobject_cast<QLineEdit *>(QObject::sender());
|
||||
@@ -222,8 +222,8 @@ namespace BlackGui
|
||||
this->moveSelectedItems(order);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType>
|
||||
void COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::freezeCurrentOrder()
|
||||
template <class T>
|
||||
void COrderableViewWithDbObjects<T>::freezeCurrentOrder()
|
||||
{
|
||||
ContainerType objects = this->container();
|
||||
objects.freezeOrder();
|
||||
@@ -232,14 +232,14 @@ namespace BlackGui
|
||||
|
||||
// see here for the reason of thess forward instantiations
|
||||
// https://isocpp.org/wiki/faq/templates#separate-template-fn-defn-from-decl
|
||||
template class CViewWithDbObjects<BlackGui::Models::CAircraftIcaoCodeListModel, BlackMisc::Aviation::CAircraftIcaoCodeList, BlackMisc::Aviation::CAircraftIcaoCode, int>;
|
||||
template class CViewWithDbObjects<BlackGui::Models::CAirlineIcaoCodeListModel, BlackMisc::Aviation::CAirlineIcaoCodeList, BlackMisc::Aviation::CAirlineIcaoCode, int>;
|
||||
template class CViewWithDbObjects<BlackGui::Models::CCountryListModel, BlackMisc::CCountryList, BlackMisc::CCountry, QString>;
|
||||
template class CViewWithDbObjects<BlackGui::Models::CLiveryListModel, BlackMisc::Aviation::CLiveryList, BlackMisc::Aviation::CLivery, int>;
|
||||
template class CViewWithDbObjects<BlackGui::Models::CDistributorListModel, BlackMisc::Simulation::CDistributorList, BlackMisc::Simulation::CDistributor, QString>;
|
||||
template class CViewWithDbObjects<BlackGui::Models::CAircraftModelListModel, BlackMisc::Simulation::CAircraftModelList, BlackMisc::Simulation::CAircraftModel, int>;
|
||||
template class COrderableViewWithDbObjects<BlackGui::Models::CDistributorListModel, BlackMisc::Simulation::CDistributorList, BlackMisc::Simulation::CDistributor, QString>;
|
||||
template class COrderableViewWithDbObjects<BlackGui::Models::CAircraftModelListModel, BlackMisc::Simulation::CAircraftModelList, BlackMisc::Simulation::CAircraftModel, int>;
|
||||
template class CViewWithDbObjects<BlackGui::Models::CAircraftIcaoCodeListModel>;
|
||||
template class CViewWithDbObjects<BlackGui::Models::CAirlineIcaoCodeListModel>;
|
||||
template class CViewWithDbObjects<BlackGui::Models::CCountryListModel>;
|
||||
template class CViewWithDbObjects<BlackGui::Models::CLiveryListModel>;
|
||||
template class CViewWithDbObjects<BlackGui::Models::CDistributorListModel>;
|
||||
template class CViewWithDbObjects<BlackGui::Models::CAircraftModelListModel>;
|
||||
template class COrderableViewWithDbObjects<BlackGui::Models::CDistributorListModel>;
|
||||
template class COrderableViewWithDbObjects<BlackGui::Models::CAircraftModelListModel>;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -30,10 +30,22 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Base class for views with DB objects
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType> class CViewWithDbObjects :
|
||||
public CViewBase<ModelClass, ContainerType, ObjectType>
|
||||
template <class T> class CViewWithDbObjects :
|
||||
public CViewBase<T>
|
||||
{
|
||||
public:
|
||||
//! Model type
|
||||
using ModelClass = T;
|
||||
|
||||
//! Model container type
|
||||
using ContainerType = typename T::ContainerType;
|
||||
|
||||
//! Model container element type
|
||||
using ObjectType = typename T::ObjectType;
|
||||
|
||||
//! Model DB key type
|
||||
using KeyType = typename T::KeyType;
|
||||
|
||||
//! Get latest object
|
||||
ObjectType latestObject() const;
|
||||
|
||||
@@ -64,9 +76,22 @@ namespace BlackGui
|
||||
};
|
||||
|
||||
//! Base class for views with DB objects also orderable (based on BlackMisc::IOrderableList )
|
||||
template <class ModelClass, class ContainerType, class ObjectType, class KeyType> class COrderableViewWithDbObjects :
|
||||
public CViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>
|
||||
template <class T> class COrderableViewWithDbObjects :
|
||||
public CViewWithDbObjects<T>
|
||||
{
|
||||
public:
|
||||
//! Model type
|
||||
using ModelClass = T;
|
||||
|
||||
//! Model container type
|
||||
using ContainerType = typename T::ContainerType;
|
||||
|
||||
//! Model container element type
|
||||
using ObjectType = typename T::ObjectType;
|
||||
|
||||
//! Model DB key type
|
||||
using KeyType = typename T::KeyType;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
explicit COrderableViewWithDbObjects(QWidget *parent = nullptr);
|
||||
|
||||
@@ -22,22 +22,22 @@ namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewWithTimestampWithOffsetObjects<ModelClass, ContainerType, ObjectType>::push_frontKeepLatestAdjustedFirst(const ObjectType &object, int max)
|
||||
template<class T>
|
||||
void CViewWithTimestampWithOffsetObjects<T>::push_frontKeepLatestAdjustedFirst(const ObjectType &object, int max)
|
||||
{
|
||||
this->derivedModel()->push_frontKeepLatestAdjustedFirst(object, max);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
CViewWithTimestampWithOffsetObjects<ModelClass, ContainerType, ObjectType>::CViewWithTimestampWithOffsetObjects(QWidget *parent) :
|
||||
CViewBase<ModelClass, ContainerType, ObjectType>(parent)
|
||||
template <class T>
|
||||
CViewWithTimestampWithOffsetObjects<T>::CViewWithTimestampWithOffsetObjects(QWidget *parent) :
|
||||
CViewBase<ModelClass>(parent)
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
template class CViewWithTimestampWithOffsetObjects<BlackGui::Models::CAircraftPartsListModel, BlackMisc::Aviation::CAircraftPartsList, BlackMisc::Aviation::CAircraftParts>;
|
||||
template class CViewWithTimestampWithOffsetObjects<BlackGui::Models::CAircraftSituationListModel, BlackMisc::Aviation::CAircraftSituationList, BlackMisc::Aviation::CAircraftSituation>;
|
||||
template class CViewWithTimestampWithOffsetObjects<BlackGui::Models::CAircraftSituationChangeListModel, BlackMisc::Aviation::CAircraftSituationChangeList, BlackMisc::Aviation::CAircraftSituationChange>;
|
||||
template class CViewWithTimestampWithOffsetObjects<BlackGui::Models::CAircraftPartsListModel>;
|
||||
template class CViewWithTimestampWithOffsetObjects<BlackGui::Models::CAircraftSituationListModel>;
|
||||
template class CViewWithTimestampWithOffsetObjects<BlackGui::Models::CAircraftSituationChangeListModel>;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -23,10 +23,19 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Base class for views timestamp offset objects
|
||||
template <class ModelClass, class ContainerType, class ObjectType> class CViewWithTimestampWithOffsetObjects :
|
||||
public CViewBase<ModelClass, ContainerType, ObjectType>
|
||||
template <class T> class CViewWithTimestampWithOffsetObjects :
|
||||
public CViewBase<T>
|
||||
{
|
||||
public:
|
||||
//! Model type
|
||||
using ModelClass = T;
|
||||
|
||||
//! Model container type
|
||||
using ContainerType = typename T::ContainerType;
|
||||
|
||||
//! Model container element type
|
||||
using ObjectType = typename T::ObjectType;
|
||||
|
||||
//! Insert as first element by keeping maxElements and the latest first
|
||||
void push_frontKeepLatestAdjustedFirst(const ObjectType &object, int max);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Wind layer view
|
||||
class BLACKGUI_EXPORT CWindLayerView : public CViewBase<Models::CWindLayerListModel, BlackMisc::Weather::CWindLayerList, BlackMisc::Weather::CWindLayer>
|
||||
class BLACKGUI_EXPORT CWindLayerView : public CViewBase<Models::CWindLayerListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user