mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 13:55:36 +08:00
Some fixes of status message view
* push_front as default (in most cases we have "latest first" * as follow up of t270 use CListModelTimestampObjects
This commit is contained in:
@@ -26,7 +26,23 @@ namespace BlackGui
|
||||
{ }
|
||||
|
||||
template<typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
void CListModelTimestampObjects<ObjectType, ContainerType, UseCompare>::push_frontKeepLatestAdjustedFirst(const ObjectType &object, int max)
|
||||
void CListModelTimestampObjects<ObjectType, ContainerType, UseCompare>::addTimestampColumns()
|
||||
{
|
||||
CListModelBaseNonTemplate::m_columns.addColumn(CColumn::standardString("timestamp", ObjectType::IndexUtcTimestampFormattedMdhmsz));
|
||||
CListModelBaseNonTemplate::m_columns.addColumn(CColumn("ms", ObjectType::IndexMSecsSinceEpoch, new CIntegerFormatter()));
|
||||
}
|
||||
|
||||
template class CListModelTimestampObjects<BlackMisc::CStatusMessage, BlackMisc::CStatusMessageList, true>;
|
||||
template class CListModelTimestampObjects<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList, true>;
|
||||
template class CListModelTimestampObjects<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList, true>;
|
||||
|
||||
template <typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
CListModelTimestampWithOffsetObjects<ObjectType, ContainerType, UseCompare>::CListModelTimestampWithOffsetObjects(const QString &translationContext, QObject *parent) :
|
||||
CListModelTimestampObjects<ObjectType, ContainerType, UseCompare>(translationContext, parent)
|
||||
{ }
|
||||
|
||||
template<typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
void CListModelTimestampWithOffsetObjects<ObjectType, ContainerType, UseCompare>::push_frontKeepLatestAdjustedFirst(const ObjectType &object, int max)
|
||||
{
|
||||
this->beginInsertRows(QModelIndex(), 0, 0);
|
||||
CListModelBase<ObjectType, ContainerType, UseCompare>::m_container.push_frontKeepLatestAdjustedFirst(object, max);
|
||||
@@ -34,18 +50,14 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
template<typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
void CListModelTimestampObjects<ObjectType, ContainerType, UseCompare>::addTimestampOffsetColumns()
|
||||
void CListModelTimestampWithOffsetObjects<ObjectType, ContainerType, UseCompare>::addTimestampOffsetColumns()
|
||||
{
|
||||
CListModelBaseNonTemplate::m_columns.addColumn(CColumn::standardString("timestamp", ObjectType::IndexUtcTimestampFormattedMdhmsz));
|
||||
CListModelBaseNonTemplate::m_columns.addColumn(CColumn("ms", ObjectType::IndexMSecsSinceEpoch, new CIntegerFormatter()));
|
||||
CListModelTimestampObjects<ObjectType, ContainerType, UseCompare>::addTimestampColumns();
|
||||
CListModelBaseNonTemplate::m_columns.addColumn(CColumn("ms adj.", ObjectType::IndexAdjustedMsWithOffset, new CIntegerFormatter()));
|
||||
CListModelBaseNonTemplate::m_columns.addColumn(CColumn("offset", ObjectType::IndexOffsetMs, new CIntegerFormatter()));
|
||||
}
|
||||
|
||||
// see here for the reason of thess forward instantiations
|
||||
// https://isocpp.org/wiki/faq/templates#separate-template-fn-defn-from-decl
|
||||
template class CListModelTimestampObjects<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList, true>;
|
||||
template class CListModelTimestampObjects<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList, true>;
|
||||
|
||||
template class CListModelTimestampWithOffsetObjects<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList, true>;
|
||||
template class CListModelTimestampWithOffsetObjects<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList, true>;
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -25,20 +25,32 @@ namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
//! List model for timestamp based objects
|
||||
//! List model for timestamp based objects with offset
|
||||
template <typename ObjectType, typename ContainerType, bool UseCompare = false> class CListModelTimestampObjects :
|
||||
public CListModelBase<ObjectType, ContainerType, UseCompare>
|
||||
{
|
||||
protected:
|
||||
//! Constructor
|
||||
CListModelTimestampObjects(const QString &translationContext, QObject *parent = nullptr);
|
||||
|
||||
//! Standard timestamp columns
|
||||
void addTimestampColumns();
|
||||
};
|
||||
|
||||
//! List model for timestamp based objects with offset
|
||||
template <typename ObjectType, typename ContainerType, bool UseCompare = false> class CListModelTimestampWithOffsetObjects :
|
||||
public CListModelTimestampObjects<ObjectType, ContainerType, UseCompare>
|
||||
{
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~CListModelTimestampObjects() {}
|
||||
virtual ~CListModelTimestampWithOffsetObjects() {}
|
||||
|
||||
//! Insert as first element by keeping maxElements and the latest first
|
||||
void push_frontKeepLatestAdjustedFirst(const ObjectType &object, int max);
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CListModelTimestampObjects(const QString &translationContext, QObject *parent = nullptr);
|
||||
CListModelTimestampWithOffsetObjects(const QString &translationContext, QObject *parent = nullptr);
|
||||
|
||||
//! Standard timestamp offset columns
|
||||
void addTimestampOffsetColumns();
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace BlackGui
|
||||
namespace Models
|
||||
{
|
||||
CStatusMessageListModel::CStatusMessageListModel(QObject *parent) :
|
||||
CListModelBase<CStatusMessage, CStatusMessageList, true>("ViewStatusMessageList", parent)
|
||||
CListModelTimestampObjects<CStatusMessage, CStatusMessageList, true>("ViewStatusMessageList", parent)
|
||||
{
|
||||
this->setMode(Detailed);
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
#define BLACKGUI_STATUSMESSAGELISTMODEL_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/models/listmodelbase.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackgui/models/listmodeltimestampobjects.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
|
||||
class QObject;
|
||||
@@ -24,9 +23,10 @@ namespace BlackGui
|
||||
namespace Models
|
||||
{
|
||||
/*!
|
||||
* Server list model
|
||||
* Status message list model
|
||||
*/
|
||||
class BLACKGUI_EXPORT CStatusMessageListModel : public CListModelBase<BlackMisc::CStatusMessage, BlackMisc::CStatusMessageList, true>
|
||||
class BLACKGUI_EXPORT CStatusMessageListModel :
|
||||
public CListModelTimestampObjects<BlackMisc::CStatusMessage, BlackMisc::CStatusMessageList, true>
|
||||
{
|
||||
public:
|
||||
//! Mode
|
||||
|
||||
Reference in New Issue
Block a user