mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 15:45:42 +08:00
refs #899, list model for callsign based models
(callsign is unique key)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
297fef7c3c
commit
949407c1a7
74
src/blackgui/models/listmodelcallsignobjects.h
Normal file
74
src/blackgui/models/listmodelcallsignobjects.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* Copyright (C) 2017
|
||||
* 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_LISTMODELCALLSIGNOBJECTS_H
|
||||
#define BLACKGUI_MODELS_LISTMODELCALLSIGNOBJECTS_H
|
||||
|
||||
#include "blackgui/models/listmodelbase.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <Qt>
|
||||
|
||||
class QModelIndex;
|
||||
class QObject;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
//! List model for callsign based objects (callsign is unique key)
|
||||
template <typename ObjectType, typename ContainerType, bool UseCompare = false> class CListModelCallsignObjects :
|
||||
public CListModelBase<ObjectType, ContainerType, UseCompare>
|
||||
{
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~CListModelCallsignObjects() {}
|
||||
|
||||
//! Keys to be highlighted
|
||||
void setHighlightedCallsigns(const BlackMisc::Aviation::CCallsignSet &callsigns) { m_highlightCallsigns = callsigns; }
|
||||
|
||||
//! Clear the highlighted callsign
|
||||
void clearHighlightedCallsigns() { m_highlightCallsigns.clear(); }
|
||||
|
||||
//! \copydoc BlackGui::Models::CListModelBaseNonTemplate::clearHighlighting
|
||||
virtual void clearHighlighting() override
|
||||
{
|
||||
this->clearHighlightedCallsigns();
|
||||
CListModelBase<ObjectType, ContainerType, UseCompare>::clearHighlighting();
|
||||
}
|
||||
|
||||
//! Set color for highlighting
|
||||
void setHighlightColor(QColor color) { m_highlightColor = color; }
|
||||
|
||||
//! Get data for index and role
|
||||
virtual QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
//! Callsign for given index
|
||||
BlackMisc::Aviation::CCallsign callsignForIndex(const QModelIndex &index) const;
|
||||
|
||||
//! Highlight index?
|
||||
bool isHighlightedIndex(const QModelIndex &index) const;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CListModelCallsignObjects(const QString &translationContext, QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
BlackMisc::Aviation::CCallsignSet m_highlightCallsigns; //!< callsigns to be highlighted
|
||||
QColor m_highlightColor = Qt::green;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user