mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
* new constructor in column class * removed overridden data method, no longer needed * added icons for ATC station views * QPixmap comparison for such columns (free functions)
96 lines
4.2 KiB
C++
96 lines
4.2 KiB
C++
/* Copyright (C) 2013 VATSIM Community / contributors
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "atcstationlistmodel.h"
|
|
#include "blackmisc/blackmiscfreefunctions.h"
|
|
|
|
using namespace BlackMisc::Aviation;
|
|
|
|
namespace BlackGui
|
|
{
|
|
/*
|
|
* Constructor
|
|
*/
|
|
CAtcStationListModel::CAtcStationListModel(AtcStationMode stationMode, QObject *parent) :
|
|
CListModelBase("ViewAtcList", parent), m_stationMode(NotSet)
|
|
{
|
|
this->setStationMode(stationMode);
|
|
// force strings for translation in resource files
|
|
(void)QT_TRANSLATE_NOOP("ViewAtcList", "callsign");
|
|
(void)QT_TRANSLATE_NOOP("ViewAtcList", "distance");
|
|
(void)QT_TRANSLATE_NOOP("ViewAtcList", "frequency");
|
|
(void)QT_TRANSLATE_NOOP("ViewAtcList", "controllername");
|
|
(void)QT_TRANSLATE_NOOP("ViewAtcList", "online");
|
|
(void)QT_TRANSLATE_NOOP("ViewAtcList", "bookedfrom");
|
|
(void)QT_TRANSLATE_NOOP("ViewAtcList", "bookeduntil");
|
|
(void)QT_TRANSLATE_NOOP("ViewAtcList", "voiceroomurl");
|
|
}
|
|
|
|
void CAtcStationListModel::setStationMode(CAtcStationListModel::AtcStationMode stationMode)
|
|
{
|
|
if (this->m_stationMode == stationMode) return;
|
|
this->m_stationMode = stationMode;
|
|
this->m_columns.clear();
|
|
switch (stationMode)
|
|
{
|
|
case NotSet:
|
|
case StationsOnline:
|
|
this->m_columns.addColumn(CColumn("callsign", CAtcStation::IndexCallsignAsStringAsSet));
|
|
this->m_columns.addColumn(CColumn(CAtcStation::IndexCallsignIcon, true));
|
|
this->m_columns.addColumn(CColumn("distance", CAtcStation::IndexDistance, Qt::AlignRight | Qt::AlignVCenter));
|
|
this->m_columns.addColumn(CColumn("frequency", CAtcStation::IndexFrequency, Qt::AlignRight | Qt::AlignVCenter));
|
|
this->m_columns.addColumn(CColumn("controllername", CAtcStation::IndexControllerRealName));
|
|
this->m_columns.addColumn(CColumn("bookedfrom", CAtcStation::IndexBookedFrom));
|
|
this->m_columns.addColumn(CColumn("bookeduntil", CAtcStation::IndexBookedUntil));
|
|
this->m_columns.addColumn(CColumn("voiceroomurl", CAtcStation::IndexVoiceRoomUrl));
|
|
|
|
// default sort order
|
|
this->setSortColumnByPropertyIndex(CAtcStation::IndexDistance);
|
|
this->m_sortOrder = Qt::AscendingOrder;
|
|
break;
|
|
|
|
case StationsBooked:
|
|
this->m_columns.addColumn(CColumn("callsign", CAtcStation::IndexCallsignAsStringAsSet));
|
|
this->m_columns.addColumn(CColumn(CAtcStation::IndexCallsignIcon, true));
|
|
this->m_columns.addColumn(CColumn("controllername", CAtcStation::IndexControllerRealName));
|
|
this->m_columns.addColumn(CColumn("bookedfrom", CAtcStation::IndexBookedFrom));
|
|
this->m_columns.addColumn(CColumn("bookeduntil", CAtcStation::IndexBookedUntil));
|
|
this->m_columns.addColumn(CColumn("frequency", CAtcStation::IndexFrequency, Qt::AlignRight | Qt::AlignVCenter));
|
|
this->m_columns.addColumn(CColumn("online", CAtcStation::IndexIsOnline));
|
|
|
|
// default sort order
|
|
this->setSortColumnByPropertyIndex(CAtcStation::IndexBookedFrom);
|
|
this->m_sortOrder = Qt::AscendingOrder;
|
|
break;
|
|
|
|
default:
|
|
qFatal("Wrong mode");
|
|
break;
|
|
}
|
|
}
|
|
|
|
void CAtcStationListModel::changedAtcStationConnectionStatus(const CAtcStation &station, bool added)
|
|
{
|
|
if (station.getCallsign().isEmpty()) return;
|
|
if (added)
|
|
{
|
|
if (this->m_container.contains(&CAtcStation::getCallsign, station.getCallsign()))
|
|
{
|
|
this->m_container.replaceIf(&CAtcStation::getCallsign, station.getCallsign(), station);
|
|
}
|
|
else
|
|
{
|
|
this->insert(station);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
beginRemoveRows(QModelIndex(), 0, 0);
|
|
this->m_container.removeIf(&CAtcStation::getCallsign, station.getCallsign());
|
|
endRemoveRows();
|
|
}
|
|
}
|
|
}
|