refs #358, GUI for installed / matched models

* model / view / component classes
This commit is contained in:
Klaus Basan
2014-12-15 17:44:23 +01:00
parent 819c4cb0db
commit 4a94a125f2
12 changed files with 477 additions and 3 deletions

View File

@@ -0,0 +1,77 @@
/* Copyright (C) 2013
* 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.
*/
#include "aircraftmodellistmodel.h"
#include "blackmisc/avaircrafticao.h"
#include "blackmisc/icons.h"
#include "blackmisc/blackmiscfreefunctions.h"
using namespace BlackMisc;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Network;
namespace BlackGui
{
namespace Models
{
/*
* Constructor
*/
CAircraftModelListModel::CAircraftModelListModel(AircraftModelMode mode, QObject *parent) : CListModelBase("CAircraftModelListModel", parent)
{
this->setAircraftModelMode(mode);
// force strings for translation in resource files
(void)QT_TRANSLATE_NOOP("CAircraftModelListModel", "callsign");
(void)QT_TRANSLATE_NOOP("CAircraftModelListModel", "combined type");
(void)QT_TRANSLATE_NOOP("CAircraftModelListModel", "model");
}
void CAircraftModelListModel::setAircraftModelMode(CAircraftModelListModel::AircraftModelMode mode)
{
if (this->m_mode == mode) return;
this->m_mode = mode;
this->m_columns.clear();
switch (mode)
{
case NotSet:
case ModelOnly:
this->m_columns.addColumn(CColumn::standardString("model", { CAircraftModel::IndexModelString}));
this->m_columns.addColumn(CColumn::standardString("description", { CAircraftModel::IndexDescription}));
this->m_columns.addColumn(CColumn::standardString("filename", { CAircraftModel::IndexFileName}));
// default sort order
this->setSortColumnByPropertyIndex(CAircraftModel::IndexModelString);
this->m_sortOrder = Qt::AscendingOrder;
break;
case MappedModel:
this->m_columns.addColumn(CColumn::standardValueObject("call", "callsign", CAircraftModel::IndexCallsign));
this->m_columns.addColumn(CColumn::standardString("model", { CAircraftModel::IndexModelString}));
this->m_columns.addColumn(CColumn::standardString("ac", "aircraft ICAO", { CAircraftModel::IndexIcao, CAircraftIcao::IndexAircraftDesignator}));
this->m_columns.addColumn(CColumn::standardString("al", "airline ICAO", { CAircraftModel::IndexIcao, CAircraftIcao::IndexAirlineDesignator}));
// this->m_columns.addColumn(CColumn::standardString("ct", "combined type", { CAircraftModel::IndexIcao, CAircraftIcao::IndexCombinedAircraftType}));
this->m_columns.addColumn(CColumn("q.?", "queried", CAircraftModel::IndexHasQueriedModelString,
new CBoolIconFormatter(CIcons::StandardIconTick16, CIcons::StandardIconCross16, "queried", "not queried")));
this->m_columns.addColumn(CColumn::standardString("description", { CAircraftModel::IndexDescription}));
this->m_columns.addColumn(CColumn::standardString("filename", { CAircraftModel::IndexFileName}));
// default sort order
this->setSortColumnByPropertyIndex(CAircraftModel::IndexModelString);
this->m_sortOrder = Qt::AscendingOrder;
break;
default:
qFatal("Wrong mode");
break;
}
}
} // namespace
} // namespace

View File

@@ -0,0 +1,52 @@
/* Copyright (C) 2013
* 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_AIRCRAFTMODELLISTMODEL_H
#define BLACKGUI_AIRCRAFTMODELLISTMODEL_H
#include "blackmisc/nwaircraftmodellist.h"
#include "blackgui/models/listmodelbase.h"
#include <QAbstractItemModel>
#include <QDBusConnection>
namespace BlackGui
{
namespace Models
{
//! Aircraft model list model
class CAircraftModelListModel : public CListModelBase<BlackMisc::Network::CAircraftModel, BlackMisc::Network::CAircraftModelList>
{
public:
//! How to display
enum AircraftModelMode {
NotSet,
ModelOnly,
MappedModel
};
//! Constructor
explicit CAircraftModelListModel(AircraftModelMode mode, QObject *parent = nullptr);
//! Destructor
virtual ~CAircraftModelListModel() {}
//! Mode
void setAircraftModelMode(CAircraftModelListModel::AircraftModelMode stationMode);
private:
AircraftModelMode m_mode = NotSet; //!< current mode
};
}
}
#endif // guard

View File

@@ -32,7 +32,7 @@ namespace BlackGui
this->m_columns.addColumn(CColumn("capabilities", CClient::IndexVoiceCapabilitiesIcon));
this->m_columns.addColumn(CColumn::standardString("capabilities", CClient::IndexCapabilitiesString));
this->m_columns.addColumn(CColumn::standardString("model", {CClient::IndexModel, CAircraftModel::IndexModelString}));
this->m_columns.addColumn(CColumn("q.?", "queried", {CClient::IndexModel, CAircraftModel::IndexIsQueriedModelString},
this->m_columns.addColumn(CColumn("q.?", "queried", {CClient::IndexModel, CAircraftModel::IndexHasQueriedModelString},
new CBoolIconFormatter(CIcons::StandardIconTick16, CIcons::StandardIconCross16, "queried", "not queried")));
this->m_columns.addColumn(CColumn::standardString("server", CClient::IndexServer));

View File

@@ -16,6 +16,8 @@
#include "blackmisc/nwserverlist.h"
#include "blackmisc/nwuserlist.h"
#include "blackmisc/nwclientlist.h"
#include "blackmisc/nwaircraftmodellist.h"
#include "blackmisc/nwaircraftmappinglist.h"
#include "blackmisc/setkeyboardhotkeylist.h"
#include "blackmisc/blackmiscfreefunctions.h"
@@ -202,7 +204,7 @@ namespace BlackGui
{
if (index.row() < 0 || index.row() >= this->m_container.size())
{
static const ObjectType def{}; // default object
static const ObjectType def {}; // default object
return def;
}
else
@@ -326,6 +328,8 @@ namespace BlackGui
template class CListModelBase<BlackMisc::Network::CServer, BlackMisc::Network::CServerList>;
template class CListModelBase<BlackMisc::Network::CUser, BlackMisc::Network::CUserList>;
template class CListModelBase<BlackMisc::Network::CClient, BlackMisc::Network::CClientList>;
template class CListModelBase<BlackMisc::Network::CAircraftModel, BlackMisc::Network::CAircraftModelList>;
template class CListModelBase<BlackMisc::Network::CAircraftMapping, BlackMisc::Network::CAircraftMappingList>;
template class CListModelBase<BlackMisc::Settings::CSettingKeyboardHotkey, BlackMisc::Settings::CSettingKeyboardHotkeyList>;
} // namespace