swift
listmodelcallsignobjects.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_MODELS_LISTMODELCALLSIGNOBJECTS_H
7 #define SWIFT_GUI_MODELS_LISTMODELCALLSIGNOBJECTS_H
8 
9 #include <QColor>
10 #include <QString>
11 #include <QVariant>
12 #include <Qt>
13 
16 
17 class QModelIndex;
18 class QObject;
19 
20 namespace swift::gui::models
21 {
23  template <typename T, bool UseCompare = false>
24  class CListModelCallsignObjects : public CListModelBase<T, UseCompare>
25  {
26  public:
28  using ContainerType = T;
29 
31  using ObjectType = typename T::value_type;
32 
35 
38  {
39  m_highlightCallsigns = callsigns;
40  }
41 
43  void clearHighlightedCallsigns() { m_highlightCallsigns.clear(); }
44 
46  virtual void clearHighlighting() override
47  {
50  }
51 
53  void setHighlightColor(QColor color) { m_highlightColor = color; }
54 
56  virtual QVariant data(const QModelIndex &index, int role) const override;
57 
60 
62  bool isHighlightedIndex(const QModelIndex &index) const;
63 
64  protected:
66  CListModelCallsignObjects(const QString &translationContext, QObject *parent = nullptr);
67 
68  private:
69  swift::misc::aviation::CCallsignSet m_highlightCallsigns;
70  QColor m_highlightColor = Qt::green;
71  };
72 } // namespace swift::gui::models
73 #endif // SWIFT_GUI_MODELS_LISTMODELCALLSIGNOBJECTS_H
virtual void clearHighlighting()
Remove all highlighting.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const final
QModelIndex parent(const QModelIndex &child) const final
List model for callsign based objects (callsign is unique key)
void setHighlightColor(QColor color)
Set color for highlighting.
virtual QVariant data(const QModelIndex &index, int role) const
Get data for index and role.
bool isHighlightedIndex(const QModelIndex &index) const
Highlight index?
typename T::value_type ObjectType
Container element type.
void setHighlightedCallsigns(const swift::misc::aviation::CCallsignSet &callsigns)
Keys to be highlighted.
swift::misc::aviation::CCallsign callsignForIndex(const QModelIndex &index) const
Callsign for given index.
void clearHighlightedCallsigns()
Clear the highlighted callsign.
virtual void clearHighlighting()
Remove all highlighting.
CListModelCallsignObjects(const QString &translationContext, QObject *parent=nullptr)
Constructor.
void clear()
Removes all elements in the collection.
Definition: collection.h:194
Value object encapsulating information of a callsign.
Definition: callsign.h:30
Value object for a set of callsigns.
Definition: callsignset.h:26
Models to be used with views, mainly QTableView.