Ref T442, moved tree model into own class

* columns can be used as with list model
* own class/file
This commit is contained in:
Klaus Basan
2018-12-04 19:38:18 +01:00
parent 4dae61c171
commit 45e34001a8
5 changed files with 179 additions and 60 deletions

View File

@@ -0,0 +1,58 @@
/* Copyright (C) 2018
* 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_ATCTREEMODEL_H
#define BLACKGUI_MODELS_ATCTREEMODEL_H
#include "columns.h"
#include "blackmisc/aviation/atcstationlist.h"
#include "blackgui/blackguiexport.h"
#include <QStandardItemModel>
#include <QHash>
namespace BlackGui
{
namespace Models
{
//! ATC list model
class BLACKGUI_EXPORT CAtcStationTreeModel : public QStandardItemModel
{
Q_OBJECT
public:
//! Constructor
explicit CAtcStationTreeModel(QObject *parent = nullptr);
//! Destructor
virtual ~CAtcStationTreeModel() override {}
//! Set station mode
void setColumns(const CColumns &columns) { m_columns.setColumns(columns); }
//! Update container
void updateContainer(const BlackMisc::Aviation::CAtcStationList &stations);
//! Get container
const BlackMisc::Aviation::CAtcStationList &container() const { return m_stations; }
//! Used to quickly update single station (better response for the user)
void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
private:
CColumns m_columns { "CAtcStationTreeModel" };
BlackMisc::Aviation::CAtcStationList m_stations;
QHash<QString, BlackMisc::Aviation::CAtcStationList> m_stationsBySuffix;
QStringList m_suffixes;
};
} // ns
} // ns
#endif // guard