swift
listmodeltimestampobjects.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #include <type_traits>
7 
8 #include <QModelIndex>
9 
10 #include "gui/models/allmodelcontainers.h"
11 
12 using namespace swift::misc;
13 using namespace swift::misc::aviation;
14 
15 namespace swift::gui::models
16 {
17  template <typename T, bool UseCompare>
19  QObject *parent)
20  : CListModelBase<ContainerType, UseCompare>(translationContext, parent)
21  {}
22 
23  template <typename T, bool UseCompare>
25  {
26  const CPropertyIndex pi = this->getSortProperty();
27  return ITimestampBased::canHandleIndex(pi);
28  }
29 
30  template <typename T, bool UseCompare>
32  {
34  CColumn::standardString("timestamp", ObjectType::IndexUtcTimestampFormattedMdhmsz));
36  "timestamp ms", "milliseconds since epoch", ObjectType::IndexMSecsSinceEpoch, new CIntegerFormatter()));
37  }
38 
44 
45  template <typename T, bool UseCompare>
47  const QString &translationContext, QObject *parent)
48  : CListModelTimestampObjects<ContainerType, UseCompare>(translationContext, parent)
49  {}
50 
51  template <typename T, bool UseCompare>
52  void
54  int max)
55  {
56  this->beginInsertRows(QModelIndex(), 0, 0);
57  CListModelBase<ContainerType, UseCompare>::m_container.push_frontKeepLatestAdjustedFirst(object, max);
58  this->endInsertRows();
59  }
60 
61  template <typename T, bool UseCompare>
63  {
66  "ms adj.", "milliseconds adjusted", ObjectType::IndexAdjustedMsWithOffset, new CIntegerFormatter()));
68  CColumn("t.os.", "time offset", ObjectType::IndexOffsetMs, new CIntegerFormatter()));
69  }
70 
74 } // namespace swift::gui::models
Single column.
Definition: columns.h:26
static CColumn standardString(const QString &headerName, const swift::misc::CPropertyIndex &propertyIndex, int alignment=CDefaultFormatter::alignDefault())
Get a standard string object formatted column.
Definition: columns.cpp:57
void addColumn(const CColumn &column)
Add a column.
Definition: columns.cpp:100
Formatter when column contains an integer.
typename T::value_type ObjectType
Container element type.
Definition: listmodelbase.h:41
List model for timestamp based objects with offset.
bool isSortedByTimestampProperty() const
Sorted by one of the timestamp columns?
void addTimestampOffsetColumns()
Standard timestamp offset columns.
void push_frontKeepLatestAdjustedFirst(const ObjectType &object, int max)
Insert as first element by keeping maxElements and the latest first.
CListModelTimestampWithOffsetObjects(const QString &translationContext, QObject *parent=nullptr)
Constructor.
Models to be used with views, mainly QTableView.
Free functions in swift::misc.