refs #335, Minor tweaks:

* Formatting
* renaming
* fixed some issues of cppcheck
* new icons
* smooth scrolling in views, stretching for few columns
* fixed start timer in updatetimer
* background colors of some LEDs
This commit is contained in:
Klaus Basan
2014-10-24 23:55:36 +02:00
committed by Roland Winklmeier
parent a9768566e6
commit 43ecc238ed
36 changed files with 186 additions and 124 deletions

View File

@@ -24,5 +24,4 @@ namespace BlackCore
return nullptr; return nullptr;
} }
} }
} // namespace
}

View File

@@ -59,7 +59,7 @@ namespace BlackCore
virtual ~IContextOwnAircraft() {} virtual ~IContextOwnAircraft() {}
signals: signals:
//! \brief Aircraft changed //! Aircraft changed
//! \remarks local only //! \remarks local only
void changedAircraft(const BlackMisc::Aviation::CAircraft &aircraft, const QString &originator); void changedAircraft(const BlackMisc::Aviation::CAircraft &aircraft, const QString &originator);

View File

@@ -24,7 +24,7 @@ namespace BlackCore
* Init this context * Init this context
*/ */
CContextOwnAircraft::CContextOwnAircraft(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContextOwnAircraft::CContextOwnAircraft(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
IContextOwnAircraft(mode, runtime), m_automaticVoiceRoomResolution(true) IContextOwnAircraft(mode, runtime)
{ {
Q_ASSERT(this->getRuntime()); Q_ASSERT(this->getRuntime());
Q_ASSERT(this->getRuntime()->getIContextSettings()); Q_ASSERT(this->getRuntime()->getIContextSettings());
@@ -123,7 +123,7 @@ namespace BlackCore
{ {
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << position << altitude << originator; CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << position << altitude << originator;
bool changed = (this->m_ownAircraft.getPosition() != position); bool changed = (this->m_ownAircraft.getPosition() != position);
if (changed) this->m_ownAircraft.setPosition(position); if (changed) { this->m_ownAircraft.setPosition(position); }
if (this->m_ownAircraft.getAltitude() != altitude) if (this->m_ownAircraft.getAltitude() != altitude)
{ {

View File

@@ -80,7 +80,7 @@ namespace BlackCore
private: private:
BlackMisc::Aviation::CAircraft m_ownAircraft; //!< my aircraft BlackMisc::Aviation::CAircraft m_ownAircraft; //!< my aircraft
bool m_automaticVoiceRoomResolution; //!< voice room override bool m_automaticVoiceRoomResolution = true; //!< automatic voice room resolution, or disable for override
QString m_voiceRoom1UrlOverride; //!< overridden voice room url QString m_voiceRoom1UrlOverride; //!< overridden voice room url
QString m_voiceRoom2UrlOverride; //!< overridden voice room url QString m_voiceRoom2UrlOverride; //!< overridden voice room url

View File

@@ -24,9 +24,7 @@ namespace BlackGui
CAircraftComponent::CAircraftComponent(QWidget *parent) : CAircraftComponent::CAircraftComponent(QWidget *parent) :
QTabWidget(parent), QTabWidget(parent),
CEnableForDockWidgetInfoArea(), ui(new Ui::CAircraftComponent)
CEnableForRuntime(nullptr, false),
ui(new Ui::CAircraftComponent), m_updateTimer(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
this->tabBar()->setExpanding(false); this->tabBar()->setExpanding(false);

View File

@@ -75,7 +75,7 @@ namespace BlackGui
private: private:
QScopedPointer<Ui::CAircraftComponent> ui; QScopedPointer<Ui::CAircraftComponent> ui;
CUpdateTimer *m_updateTimer; CUpdateTimer *m_updateTimer = nullptr;
}; };
} }
} }

View File

@@ -64,7 +64,7 @@ namespace BlackGui
this->connect(this->ui->pb_CockpitToggleCom2, &QPushButton::clicked, this, &CCockpitV1Component::cockpitValuesChanged); this->connect(this->ui->pb_CockpitToggleCom2, &QPushButton::clicked, this, &CCockpitV1Component::cockpitValuesChanged);
this->connect(this->ui->pb_CockpitSelcalTest, &QPushButton::clicked, this, &CCockpitV1Component::testSelcal); this->connect(this->ui->pb_CockpitSelcalTest, &QPushButton::clicked, this, &CCockpitV1Component::testSelcal);
this->connect(this->ui->cbp_CockpitTransponderMode, &CTransponderModeSelector::valueChanged, this, &CCockpitV1Component::cockpitValuesChanged); this->connect(this->ui->cbp_CockpitTransponderMode, &CTransponderModeSelector::transponderModeChanged, this, &CCockpitV1Component::cockpitValuesChanged);
this->connect(this->ui->di_CockpitCom1Volume, &QDial::valueChanged, this, &CCockpitV1Component::setCom1Volume); this->connect(this->ui->di_CockpitCom1Volume, &QDial::valueChanged, this, &CCockpitV1Component::setCom1Volume);
this->connect(this->ui->di_CockpitCom2Volume, &QDial::valueChanged, this, &CCockpitV1Component::setCom2Volume); this->connect(this->ui->di_CockpitCom2Volume, &QDial::valueChanged, this, &CCockpitV1Component::setCom2Volume);

View File

@@ -49,8 +49,8 @@ namespace BlackGui
this->ui->led_Simulator->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Simulator connected", "Simulator disconnected", 14); this->ui->led_Simulator->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Simulator connected", "Simulator disconnected", 14);
shape = CLedWidget::Rounded; shape = CLedWidget::Rounded;
this->ui->led_Ptt->setValues(CLedWidget::Yellow, CLedWidget::Red, shape, "Ptt", "Silence", 18); this->ui->led_Ptt->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Ptt", "Silence", 18);
this->ui->led_Audio->setValues(CLedWidget::Yellow, CLedWidget::Red, shape, "On", "Muted", 18); this->ui->led_Audio->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "On", "Muted", 18);
} }
void CInfoBarStatusComponent::setDBusStatus(bool dbus) void CInfoBarStatusComponent::setDBusStatus(bool dbus)

View File

@@ -20,8 +20,12 @@ namespace BlackGui
this->m_timer = new QTimer(this); this->m_timer = new QTimer(this);
this->m_timerSingleShot = new QTimer(this); this->m_timerSingleShot = new QTimer(this);
this->m_timerSingleShot->setSingleShot(true); this->m_timerSingleShot->setSingleShot(true);
this->connect(this->m_timer, SIGNAL(timeout()), parent, slot);
this->connect(this->m_timerSingleShot, SIGNAL(timeout()), parent, slot); bool c = this->connect(this->m_timer, SIGNAL(timeout()), parent, slot);
Q_ASSERT(c);
c = this->connect(this->m_timerSingleShot, SIGNAL(timeout()), parent, slot);
Q_ASSERT(c);
Q_UNUSED(c);
} }
CUpdateTimer::~CUpdateTimer() CUpdateTimer::~CUpdateTimer()

View File

@@ -48,6 +48,9 @@ namespace BlackGui
//! Stop timer //! Stop timer
void stopTimer() { this->setUpdateInterval(-1); this->m_timerSingleShot->stop(); } void stopTimer() { this->setUpdateInterval(-1); this->m_timerSingleShot->stop(); }
//! Start timer
void startTimer(int milliSeconds) { this->setUpdateInterval(milliSeconds);}
//! Fire the timer straight away //! Fire the timer straight away
void fireTimer(); void fireTimer();

View File

@@ -48,7 +48,7 @@ namespace BlackGui
//! Return pressed //! Return pressed
void ps_voiceRoomUrlsReturnPressed(); void ps_voiceRoomUrlsReturnPressed();
//! set the voice room url fields (checkboxes, line edits) //! Set the voice room url fields (checkboxes, line edits)
void ps_updateAudioVoiceRoomsFromContext(const BlackMisc::Audio::CVoiceRoomList &selectedVoiceRooms, bool connected); void ps_updateAudioVoiceRoomsFromContext(const BlackMisc::Audio::CVoiceRoomList &selectedVoiceRooms, bool connected);
private: private:
@@ -58,7 +58,6 @@ namespace BlackGui
//! Update voice room views //! Update voice room views
void updateVoiceRoomMembers(); void updateVoiceRoomMembers();
QScopedPointer<Ui::CVoiceRoomsComponent> ui; QScopedPointer<Ui::CVoiceRoomsComponent> ui;
}; };

View File

@@ -169,14 +169,7 @@ namespace BlackGui
void CLedWidget::toggleValue() void CLedWidget::toggleValue()
{ {
if (m_value == Temporary || m_value == On) m_value = (m_value == Off) ? m_value = On : m_value = Off;
{
m_value = Off;
}
else
{
m_value = Off;
}
setLed(); setLed();
} }

View File

@@ -277,7 +277,7 @@ namespace BlackGui
{ } { }
CBoolIconFormatter::CBoolIconFormatter(CIcons::IconIndex onIcon, CIcons::IconIndex offIcon, const QString &onName, const QString &offName, int alignment) : CBoolIconFormatter::CBoolIconFormatter(CIcons::IconIndex onIcon, CIcons::IconIndex offIcon, const QString &onName, const QString &offName, int alignment) :
CBoolIconFormatter(CIconList::iconForIndex(onIcon), CIconList::iconForIndex(offIcon), onName, offName, alignment) CBoolIconFormatter(CIconList::iconByIndex(onIcon), CIconList::iconByIndex(offIcon), onName, offName, alignment)
{ } { }
CBoolIconFormatter::CBoolIconFormatter(const CIcon &onIcon, const CIcon &offIcon, const QString &onName, const QString &offName, int alignment) : CBoolIconFormatter::CBoolIconFormatter(const CIcon &onIcon, const CIcon &offIcon, const QString &onName, const QString &offName, int alignment) :

View File

@@ -18,7 +18,7 @@ namespace Ui { class CShowHideBar; }
namespace BlackGui namespace BlackGui
{ {
//! Show or hide another section //! Show or hide (expand / collapse) another section
class CShowHideBar : public QFrame class CShowHideBar : public QFrame
{ {
Q_OBJECT Q_OBJECT

View File

@@ -1,12 +1,19 @@
/* 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 "transpondermodeselector.h" #include "transpondermodeselector.h"
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
namespace BlackGui namespace BlackGui
{ {
CTransponderModeSelector::CTransponderModeSelector(QWidget *parent) : QComboBox(parent)
CTransponderModeSelector::CTransponderModeSelector(QWidget *parent) : QComboBox(parent),
m_currentMode(CTransponder::StateStandby), m_resetMode(CTransponder::StateStandby)
{ {
QComboBox::insertItems(0, CTransponderModeSelector::modes()); QComboBox::insertItems(0, CTransponderModeSelector::modes());
connect(&this->m_resetTimer, &QTimer::timeout, this, &CTransponderModeSelector::resetTransponderMode); connect(&this->m_resetTimer, &QTimer::timeout, this, &CTransponderModeSelector::resetTransponderMode);
@@ -51,9 +58,9 @@ namespace BlackGui
void CTransponderModeSelector::setSelectedTransponderMode(CTransponder::TransponderMode mode) void CTransponderModeSelector::setSelectedTransponderMode(CTransponder::TransponderMode mode)
{ {
if (mode != CTransponder::StateIdent) this->m_resetMode = mode; if (mode != CTransponder::StateIdent) { this->m_resetMode = mode; }
if (this->m_currentMode == mode) return; if (this->m_currentMode == mode) { return; }
if (this->m_currentMode == CTransponder::StateIdent) emit this->identEnded(); if (this->m_currentMode == CTransponder::StateIdent) { emit this->transponderStateIdentEnded(); }
this->m_currentMode = mode; this->m_currentMode = mode;
QString m = CTransponder::modeAsString(mode); QString m = CTransponder::modeAsString(mode);
QComboBox::setCurrentText(m); QComboBox::setCurrentText(m);
@@ -65,7 +72,12 @@ namespace BlackGui
{ {
this->m_resetTimer.stop(); this->m_resetTimer.stop();
} }
emit this->valueChanged(); emit this->transponderModeChanged(this->m_currentMode);
}
void CTransponderModeSelector::setSelectedTransponderModeStateIdent()
{
this->setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::StateIdent);
} }
void CTransponderModeSelector::setSelectedTransponderModeAsString(const QString &mode) void CTransponderModeSelector::setSelectedTransponderModeAsString(const QString &mode)

View File

@@ -1,3 +1,14 @@
/* 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_TRANSPONDERMODESELECTOR_H #ifndef BLACKGUI_TRANSPONDERMODESELECTOR_H
#define BLACKGUI_TRANSPONDERMODESELECTOR_H #define BLACKGUI_TRANSPONDERMODESELECTOR_H
@@ -11,65 +22,62 @@
namespace BlackGui namespace BlackGui
{ {
/*! //! Selector for the transponder mode
* \brief Selector for the transponder mode //! \remarks features ident reset
*/
class CTransponderModeSelector : public QComboBox class CTransponderModeSelector : public QComboBox
{ {
Q_OBJECT Q_OBJECT
private:
BlackMisc::Aviation::CTransponder::TransponderMode m_currentMode;
BlackMisc::Aviation::CTransponder::TransponderMode m_resetMode;
QTimer m_resetTimer;
public: public:
//! \brief Constructor //! Constructor
explicit CTransponderModeSelector(QWidget *parent = nullptr); explicit CTransponderModeSelector(QWidget *parent = nullptr);
//! \brief Standby string //! Standby string
static const QString &transponderStateStandby(); static const QString &transponderStateStandby();
//! \brief Ident string //! Ident string
static const QString &transponderStateIdent(); static const QString &transponderStateIdent();
//! \brief Mode C string //! Mode C string
static const QString &transponderModeC(); static const QString &transponderModeC();
//! \brief All relevant modes for GUI //! All relevant modes for GUI
static const QStringList &modes(); static const QStringList &modes();
//! \brief Selected transponder mode //! Selected transponder mode
BlackMisc::Aviation::CTransponder::TransponderMode getSelectedTransponderMode() const; BlackMisc::Aviation::CTransponder::TransponderMode getSelectedTransponderMode() const;
//! \brief Selected transponder mode //! Ident selected
void setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::TransponderMode mode);
//!\ brief Set to ident
void setSelectedTransponderModeStateIdent()
{
this->setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::StateIdent);
}
//! \brief Ident selected
bool isIdentSelected() const bool isIdentSelected() const
{ {
return this->getSelectedTransponderMode() == BlackMisc::Aviation::CTransponder::StateIdent; return this->getSelectedTransponderMode() == BlackMisc::Aviation::CTransponder::StateIdent;
} }
public slots: public slots:
//! \brief reset to last mode (unequal ident) //! reset to last mode (unequal ident)
void resetTransponderMode(); void resetTransponderMode();
//! \brief Selected transponder mode //! Selected transponder mode
void setSelectedTransponderModeAsString(const QString &mode); void setSelectedTransponderModeAsString(const QString &mode);
signals: //! Selected transponder mode
//! Singal, which makes sure the value is already updated internally void setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::TransponderMode mode);
void valueChanged();
//! \brief Ident ended //! Set to ident (transponder state)
void identEnded(); void setSelectedTransponderModeStateIdent();
signals:
//! Mode / state has been changed
void transponderModeChanged(BlackMisc::Aviation::CTransponder::TransponderMode newMode);
//! Ident phase ended
void transponderStateIdentEnded();
private:
BlackMisc::Aviation::CTransponder::TransponderMode m_currentMode = BlackMisc::Aviation::CTransponder::StateStandby;
BlackMisc::Aviation::CTransponder::TransponderMode m_resetMode = BlackMisc::Aviation::CTransponder::StateStandby;
QTimer m_resetTimer;
}; };
} // namespace } // namespace

View File

@@ -19,6 +19,7 @@ namespace BlackGui
{ {
CNameVariantPairView::CNameVariantPairView(QWidget *parent) : CViewBase(parent) CNameVariantPairView::CNameVariantPairView(QWidget *parent) : CViewBase(parent)
{ {
m_forceStretchLastColumnWhenResized = true;
this->standardInit(new CNameVariantPairModel(true, this)); this->standardInit(new CNameVariantPairModel(true, this));
} }
@@ -47,4 +48,4 @@ namespace BlackGui
return this->m_model->containsName(name); return this->m_model->containsName(name);
} }
} }
} } // namespace

View File

@@ -31,10 +31,10 @@ namespace BlackGui
void setIconMode(bool withIcon); void setIconMode(bool withIcon);
//! Update or add value, QVariant version //! Update or add value, QVariant version
bool addOrUpdateByName(const QString &name, const QVariant &value, const BlackMisc::CIcon &icon = BlackMisc::CIcon(), bool resize = true, bool skipEqualValues = true); bool addOrUpdateByName(const QString &name, const QVariant &value, const BlackMisc::CIcon &icon = BlackMisc::CIcon(), bool performResizing = true, bool skipEqualValues = true);
//! Remove by name //! Remove by name
void removeByName(const QString &name, bool resize = true); void removeByName(const QString &name, bool performResizing = true);
//! Contains name //! Contains name
bool containsName(const QString &name); bool containsName(const QString &name);

View File

@@ -40,6 +40,11 @@ namespace BlackGui
{ {
this->setContextMenuPolicy(Qt::CustomContextMenu); this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &QWidget::customContextMenuRequested, this, &CViewBaseNonTemplate::ps_customMenuRequested); connect(this, &QWidget::customContextMenuRequested, this, &CViewBaseNonTemplate::ps_customMenuRequested);
// scroll modes
this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
} }
void CViewBaseNonTemplate::customMenu(QMenu &menu) const void CViewBaseNonTemplate::customMenu(QMenu &menu) const
@@ -82,8 +87,8 @@ namespace BlackGui
void CViewBaseNonTemplate::initRowsResizeModeToInteractive() void CViewBaseNonTemplate::initRowsResizeModeToInteractive()
{ {
const int h = this->verticalHeader()->minimumSectionSize(); const int height = this->verticalHeader()->minimumSectionSize();
this->setRowsResizeModeToInteractive(h); this->setRowsResizeModeToInteractive(height);
} }
void CViewBaseNonTemplate::setRowsResizeModeToInteractive(int height) void CViewBaseNonTemplate::setRowsResizeModeToInteractive(int height)
@@ -94,8 +99,9 @@ namespace BlackGui
verticalHeader->setDefaultSectionSize(height); verticalHeader->setDefaultSectionSize(height);
} }
bool CViewBaseNonTemplate::resize() const bool CViewBaseNonTemplate::performResizing() const
{ {
if (m_resizeMode == ResizingOff) { return false; }
if (m_resizeMode == ResizingOnce) { return m_resizeCount < 1; } if (m_resizeMode == ResizingOnce) { return m_resizeCount < 1; }
if (m_resizeMode == ResizingAuto) if (m_resizeMode == ResizingAuto)
{ {
@@ -103,7 +109,7 @@ namespace BlackGui
if (m_resizeAutoNthTime < 2) return true; if (m_resizeAutoNthTime < 2) return true;
return (m_resizeCount % m_resizeAutoNthTime) == 0; return (m_resizeCount % m_resizeAutoNthTime) == 0;
} }
return m_resizeMode == ResizingOff; return false;
} }
void CViewBaseNonTemplate::fullResizeToContents() void CViewBaseNonTemplate::fullResizeToContents()
@@ -115,7 +121,11 @@ namespace BlackGui
m_resizeCount++; m_resizeCount++;
this->resizeColumnsToContents(); this->resizeColumnsToContents();
this->resizeRowsToContents(); this->resizeRowsToContents();
if (m_forceStretchLastColumnWhenResized)
{
// re-stretch
this->horizontalHeader()->setStretchLastSection(true);
}
qDebug() << this->objectName() << "resize ms:" << t.elapsed() << QThread::currentThreadId(); qDebug() << this->objectName() << "resize ms:" << t.elapsed() << QThread::currentThreadId();
} }
@@ -166,7 +176,7 @@ namespace BlackGui
template <class ModelClass, class ContainerType> void CViewBase<ModelClass, ContainerType>::updateContainerMaybeAsync(const ContainerType &container, bool sort, bool resize) template <class ModelClass, class ContainerType> void CViewBase<ModelClass, ContainerType>::updateContainerMaybeAsync(const ContainerType &container, bool sort, bool resize)
{ {
if (container.size() > asyncThreshold && sort) if (container.size() > asyncRowsCountThreshold && sort)
{ {
// larger container with sorting // larger container with sorting
updateContainerAsync(container, sort, resize); updateContainerAsync(container, sort, resize);
@@ -231,7 +241,7 @@ namespace BlackGui
template <class ModelClass, class ContainerType> void CViewBase<ModelClass, ContainerType>::performResizeToContents() template <class ModelClass, class ContainerType> void CViewBase<ModelClass, ContainerType>::performResizeToContents()
{ {
// small set or large set? // small set or large set?
if (this->resize()) if (this->performResizing())
{ {
this->fullResizeToContents(); this->fullResizeToContents();
} }

View File

@@ -38,11 +38,11 @@ namespace BlackGui
{ {
ResizingAuto, //!< always resizing, \sa m_resizeAutoNthTime ResizingAuto, //!< always resizing, \sa m_resizeAutoNthTime
ResizingOnce, //!< only one time ResizingOnce, //!< only one time
ResizingOff ResizingOff //!< never
}; };
//! When to use asynchronous updates //! When (rows count) to use asynchronous updates
static const int asyncThreshold = 50; static const int asyncRowsCountThreshold = 50;
//! Clear data //! Clear data
virtual void clear() = 0; virtual void clear() = 0;
@@ -101,21 +101,22 @@ namespace BlackGui
//! \param variant contains the container //! \param variant contains the container
//! \param sort //! \param sort
//! \param resize //! \param resize
virtual int performUpdateContainer(const QVariant &variant, bool sort, bool resize) = 0; virtual int performUpdateContainer(const QVariant &variant, bool sort, bool performResizing) = 0;
//! Skip resizing because of size? //! Skip resizing because of size?
virtual bool reachedResizeThreshold() const = 0; virtual bool reachedResizeThreshold() const = 0;
//! Resize or skip resize? //! Resize or skip resize?
virtual bool resize() const; virtual bool performResizing() const;
//! Init default values //! Init default values
virtual void standardInit(); virtual void standardInit();
ResizeMode m_resizeMode = ResizingAuto; //!< mode ResizeMode m_resizeMode = ResizingAuto; //!< mode
int m_resizeCount = 0; //!< flag / counter,how many resize activities int m_resizeCount = 0; //!< flag / counter, how many resize activities
int m_skipResizeThreshold = 40; //!< when to skip resize int m_skipResizeThreshold = 40; //!< when to skip resize (rows count)
int m_resizeAutoNthTime = 1; //!< with ResizeAuto, resize every n-th time int m_resizeAutoNthTime = 1; //!< with ResizeAuto, resize every n-th time
bool m_forceStretchLastColumnWhenResized = false; //! a small table might (few columns) might to fail stretching, force again
protected slots: protected slots:
//! Helper method with template free signature serving as callback from threaded worker //! Helper method with template free signature serving as callback from threaded worker
@@ -153,13 +154,13 @@ namespace BlackGui
virtual void clear() override { Q_ASSERT(this->m_model); this->m_model->clear(); } virtual void clear() override { Q_ASSERT(this->m_model); this->m_model->clear(); }
//! Update whole container //! Update whole container
int updateContainer(const ContainerType &container, bool sort = true, bool resize = true); int updateContainer(const ContainerType &container, bool sort = true, bool performResizing = true);
//! Update whole container in background //! Update whole container in background
BlackMisc::CWorker *updateContainerAsync(const ContainerType &container, bool sort = true, bool resize = true); BlackMisc::CWorker *updateContainerAsync(const ContainerType &container, bool sort = true, bool performResizing = true);
//! Based on size call sync / async update //! Based on size call sync / async update
void updateContainerMaybeAsync(const ContainerType &container, bool sort = true, bool resize = true); void updateContainerMaybeAsync(const ContainerType &container, bool sort = true, bool performResizing = true);
//! Insert //! Insert
template<class ObjectType> void insert(const ObjectType &value, bool resize = true) template<class ObjectType> void insert(const ObjectType &value, bool resize = true)
@@ -211,7 +212,7 @@ namespace BlackGui
virtual void performResizeToContents() override; virtual void performResizeToContents() override;
//! \copydoc CViewBaseNonTemplate::performUpdateContainer //! \copydoc CViewBaseNonTemplate::performUpdateContainer
virtual int performUpdateContainer(const QVariant &variant, bool sort, bool resize) override; virtual int performUpdateContainer(const QVariant &variant, bool sort, bool performResizing) override;
}; };
} // namespace } // namespace

View File

@@ -115,7 +115,7 @@ namespace BlackMisc
*/ */
CIcon CAltitude::toIcon() const CIcon CAltitude::toIcon() const
{ {
return BlackMisc::CIconList::iconForIndex(CIcons::GeoPosition); return BlackMisc::CIconList::iconByIndex(CIcons::GeoPosition);
} }
} // namespace } // namespace

View File

@@ -38,23 +38,23 @@ namespace BlackMisc
const CIcon &CCallsign::convertToIcon(const CCallsign &callsign) const CIcon &CCallsign::convertToIcon(const CCallsign &callsign)
{ {
QString t = callsign.asString().toUpper(); QString t = callsign.asString().toUpper();
if (t.length() < 3) return CIconList::iconForIndex(CIcons::NetworkRoleUnknown); if (t.length() < 3) return CIconList::iconByIndex(CIcons::NetworkRoleUnknown);
t = t.right(3); t = t.right(3);
if (callsign.getStringAsSet().contains("_")) if (callsign.getStringAsSet().contains("_"))
{ {
if ("APP" == t) return CIconList::iconForIndex(CIcons::NetworkRoleApproach); if ("APP" == t) return CIconList::iconByIndex(CIcons::NetworkRoleApproach);
if ("GND" == t) return CIconList::iconForIndex(CIcons::NetworkRoleGround); if ("GND" == t) return CIconList::iconByIndex(CIcons::NetworkRoleGround);
if ("TWR" == t) return CIconList::iconForIndex(CIcons::NetworkRoleTower); if ("TWR" == t) return CIconList::iconByIndex(CIcons::NetworkRoleTower);
if ("DEL" == t) return CIconList::iconForIndex(CIcons::NetworkRoleDelivery); if ("DEL" == t) return CIconList::iconByIndex(CIcons::NetworkRoleDelivery);
if ("CTR" == t) return CIconList::iconForIndex(CIcons::NetworkRoleCenter); if ("CTR" == t) return CIconList::iconByIndex(CIcons::NetworkRoleCenter);
if ("SUP" == t) return CIconList::iconForIndex(CIcons::NetworkRoleSup); if ("SUP" == t) return CIconList::iconByIndex(CIcons::NetworkRoleSup);
if ("OBS" == t) return CIconList::iconForIndex(CIcons::NetworkRoleApproach); if ("OBS" == t) return CIconList::iconByIndex(CIcons::NetworkRoleApproach);
return CIconList::iconForIndex(CIcons::NetworkRoleUnknown); return CIconList::iconByIndex(CIcons::NetworkRoleUnknown);
} }
else else
{ {
return CIconList::iconForIndex(CIcons::NetworkRolePilot); return CIconList::iconByIndex(CIcons::NetworkRolePilot);
} }
} }

View File

@@ -67,7 +67,7 @@ namespace BlackMisc
bool equalsString(const QString &callsignString) const; bool equalsString(const QString &callsignString) const;
//! \copydoc CValueObject::toIcon() //! \copydoc CValueObject::toIcon()
virtual BlackMisc::CIcon toIcon() const override { return CCallsign::convertToIcon(*this); } virtual BlackMisc::CIcon toIcon() const override { return convertToIcon(*this); }
//! \copydoc CValueObject::propertyByIndex //! \copydoc CValueObject::propertyByIndex
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override; virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;

View File

@@ -42,7 +42,7 @@ namespace BlackMisc
BlackMisc::CIcon CFlightPlan::toIcon() const BlackMisc::CIcon CFlightPlan::toIcon() const
{ {
return BlackMisc::CIconList::iconForIndex(CIcons::StandardIconAppFlightPlan16); return BlackMisc::CIconList::iconByIndex(CIcons::StandardIconAppFlightPlan16);
} }
} // namespace } // namespace

View File

@@ -40,7 +40,7 @@ namespace BlackMisc
CSelcal(const char *code) : m_code(code) {} CSelcal(const char *code) : m_code(code) {}
//! Is valid? //! Is valid?
bool isValid() const { return CSelcal::isValidCode(this->m_code); } bool isValid() const { return isValidCode(this->m_code); }
//! Get SELCAL code //! Get SELCAL code
const QString &getCode() const { return this->m_code; } const QString &getCode() const { return this->m_code; }

View File

@@ -73,7 +73,7 @@ namespace BlackMisc
*/ */
template <class LATorLON> CIcon CEarthAngle<LATorLON>::toIcon() const template <class LATorLON> CIcon CEarthAngle<LATorLON>::toIcon() const
{ {
return BlackMisc::CIconList::iconForIndex(CIcons::GeoPosition); return BlackMisc::CIconList::iconByIndex(CIcons::GeoPosition);
} }
// see here for the reason of thess forward instantiations // see here for the reason of thess forward instantiations

View File

@@ -35,6 +35,17 @@ namespace BlackMisc
static const CIconList icons( static const CIconList icons(
{ {
// keep indexes alphabetically sorted and in sync with CIcons // keep indexes alphabetically sorted and in sync with CIcons
CIcon(CIcons::ApplicationIconAircrafts, "aircrafts"),
CIcon(CIcons::ApplicationIconAtc, "ATC"),
CIcon(CIcons::ApplicationIconAudio, "audio"),
CIcon(CIcons::ApplicationIconCockpit, "cockpit"),
CIcon(CIcons::ApplicationIconFlightPlan, "flightplan"),
CIcon(CIcons::ApplicationIconLog, "log"),
CIcon(CIcons::ApplicationIconMappings, "mappings"),
CIcon(CIcons::ApplicationIconSettings, "settings"),
CIcon(CIcons::ApplicationIconSimulator, "simulator"),
CIcon(CIcons::ApplicationIconTextMessages, "text messages"),
CIcon(CIcons::ApplicationIconWeather, "weather"),
CIcon(CIcons::AviationAtis, "ATIS"), CIcon(CIcons::AviationAtis, "ATIS"),
CIcon(CIcons::AviationAttitudeIndicator, "attitude indicator"), CIcon(CIcons::AviationAttitudeIndicator, "attitude indicator"),
CIcon(CIcons::AviationMetar, "METAR"), CIcon(CIcons::AviationMetar, "METAR"),
@@ -133,12 +144,12 @@ namespace BlackMisc
return icons; return icons;
} }
const CIcon &CIconList::iconForIndex(CIcons::IconIndex index) const CIcon &CIconList::iconByIndex(CIcons::IconIndex index)
{ {
return iconForIndex(static_cast<int>(index)); return iconByIndex(static_cast<int>(index));
} }
const CIcon &CIconList::iconForIndex(int index) const CIcon &CIconList::iconByIndex(int index)
{ {
// changed to index / at based approach during #322 (after Sleepy profiling) // changed to index / at based approach during #322 (after Sleepy profiling)
// this seems to be faster as the findBy approach previously used, but required synced indexes // this seems to be faster as the findBy approach previously used, but required synced indexes

View File

@@ -46,10 +46,10 @@ namespace BlackMisc
static const CIconList &allIcons(); static const CIconList &allIcons();
//! Icon for given index //! Icon for given index
static const CIcon &iconForIndex(CIcons::IconIndex index); static const CIcon &iconByIndex(CIcons::IconIndex index);
//! Icon for given index //! Icon for given index
static const CIcon &iconForIndex(int index); static const CIcon &iconByIndex(int index);
}; };
} }

View File

@@ -30,6 +30,17 @@ namespace BlackMisc
{ {
switch (index) switch (index)
{ {
case ApplicationIconAircrafts: return appAircrafts16();
case ApplicationIconAtc: return appAtc16();
case ApplicationIconAudio: return appAudio16();
case ApplicationIconCockpit: return appCockpit16();
case ApplicationIconFlightPlan: return appFlightPlan16();
case ApplicationIconLog: return appLog16();
case ApplicationIconMappings: return appMappings16();
case ApplicationIconSettings: return appSettings16();
case ApplicationIconSimulator: return appSimulator16();
case ApplicationIconTextMessages: return appTextMessages16();
case ApplicationIconWeather: return appWeather16();
case AviationAtis: return atis(); case AviationAtis: return atis();
case AviationAttitudeIndicator: return attitudeIndicator16(); case AviationAttitudeIndicator: return attitudeIndicator16();
case AviationMetar: return metar(); case AviationMetar: return metar();
@@ -93,6 +104,7 @@ namespace BlackMisc
case StandardIconPaperPlane16: return paperPlane16(); case StandardIconPaperPlane16: return paperPlane16();
case StandardIconPlugin16: return plugin16(); case StandardIconPlugin16: return plugin16();
case StandardIconRadar16: return radar16(); case StandardIconRadar16: return radar16();
case StandardIconRadio16: return radio16();
case StandardIconRefresh16: return refresh16(); case StandardIconRefresh16: return refresh16();
case StandardIconResize16: return resize16(); case StandardIconResize16: return resize16();
case StandardIconResizeHorizontal16: return resizeHorizontal16(); case StandardIconResizeHorizontal16: return resizeHorizontal16();

View File

@@ -28,6 +28,17 @@ namespace BlackMisc
enum IconIndex enum IconIndex
{ {
// !! keep indexes alphabetically sorted and in sync with CIconList // !! keep indexes alphabetically sorted and in sync with CIconList
ApplicationIconAircrafts,
ApplicationIconAtc,
ApplicationIconAudio,
ApplicationIconCockpit,
ApplicationIconFlightPlan,
ApplicationIconLog,
ApplicationIconMappings,
ApplicationIconSettings,
ApplicationIconSimulator,
ApplicationIconTextMessages,
ApplicationIconWeather,
AviationAttitudeIndicator, AviationAttitudeIndicator,
AviationAtis, AviationAtis,
AviationMetar, AviationMetar,
@@ -751,13 +762,13 @@ namespace BlackMisc
//! Text only //! Text only
static const QPixmap &capabilityTextOnly() static const QPixmap &capabilityTextOnly()
{ {
return CIcons::appTextMessages16(); return appTextMessages16();
} }
//! Text only //! Text only
static const QPixmap &capabilityUnknown() static const QPixmap &capabilityUnknown()
{ {
return CIcons::unknown16(); return unknown16();
} }
//! Attitude indicator //! Attitude indicator

View File

@@ -92,7 +92,7 @@ namespace BlackMisc
if (static_cast<QMetaType::Type>(variant.type()) == QMetaType::Int) if (static_cast<QMetaType::Type>(variant.type()) == QMetaType::Int)
{ {
CIcons::IconIndex index = static_cast<CIcons::IconIndex>(variant.toInt()); CIcons::IconIndex index = static_cast<CIcons::IconIndex>(variant.toInt());
this->m_icon = CIconList::iconForIndex(index); this->m_icon = CIconList::iconByIndex(index);
} }
else else
{ {

View File

@@ -100,18 +100,18 @@ namespace BlackMisc
switch (this->m_voiceCapabilities) switch (this->m_voiceCapabilities)
{ {
case Voice: case Voice:
return CIconList::iconForIndex(CIcons::NetworkCapabilityVoiceBackground); return CIconList::iconByIndex(CIcons::NetworkCapabilityVoiceBackground);
case TextOnly: case TextOnly:
return CIconList::iconForIndex(CIcons::NetworkCapabilityTextOnly); return CIconList::iconByIndex(CIcons::NetworkCapabilityTextOnly);
case Unknown: case Unknown:
return CIconList::iconForIndex(CIcons::NetworkCapabilityUnknown); return CIconList::iconByIndex(CIcons::NetworkCapabilityUnknown);
case VoiceReceivingOnly: case VoiceReceivingOnly:
return CIconList::iconForIndex(CIcons::NetworkCapabilityVoiceReceiveOnlyBackground); return CIconList::iconByIndex(CIcons::NetworkCapabilityVoiceReceiveOnlyBackground);
default: default:
break; break;
} }
Q_ASSERT(false); Q_ASSERT(false);
return CIconList::iconForIndex(CIcons::NetworkCapabilityUnknown); // never reached return CIconList::iconByIndex(CIcons::NetworkCapabilityUnknown); // never reached
} }
/* /*

View File

@@ -17,7 +17,7 @@ namespace BlackMisc
{ {
BlackMisc::CIcon CAngle::toIcon() const BlackMisc::CIcon CAngle::toIcon() const
{ {
BlackMisc::CIcon i = CIconList::iconForIndex(CIcons::StandardIconArrowMediumNorth16); BlackMisc::CIcon i = CIconList::iconByIndex(CIcons::StandardIconArrowMediumNorth16);
i.setRotation(*this); i.setRotation(*this);
return i; return i;
} }

View File

@@ -132,11 +132,11 @@ namespace BlackMisc
{ {
switch (statusMessage.getSeverity()) switch (statusMessage.getSeverity())
{ {
case SeverityDebug: return CIconList::iconForIndex(CIcons::StandardIconUnknown16); // TODO case SeverityDebug: return CIconList::iconByIndex(CIcons::StandardIconUnknown16); // TODO
case SeverityInfo: return CIconList::iconForIndex(CIcons::StandardIconInfo16); case SeverityInfo: return CIconList::iconByIndex(CIcons::StandardIconInfo16);
case SeverityWarning: return CIconList::iconForIndex(CIcons::StandardIconWarning16); case SeverityWarning: return CIconList::iconByIndex(CIcons::StandardIconWarning16);
case SeverityError: return CIconList::iconForIndex(CIcons::StandardIconError16); case SeverityError: return CIconList::iconByIndex(CIcons::StandardIconError16);
default: return CIconList::iconForIndex(CIcons::StandardIconInfo16); default: return CIconList::iconByIndex(CIcons::StandardIconInfo16);
} }
} }

View File

@@ -91,7 +91,7 @@ namespace BlackMisc
void setSeverity(StatusSeverity severity) { this->m_severity = severity; } void setSeverity(StatusSeverity severity) { this->m_severity = severity; }
//! Representing icon //! Representing icon
virtual CIcon toIcon() const override { return CStatusMessage::convertToIcon(*this); } virtual CIcon toIcon() const override { return convertToIcon(*this); }
//! Severity as string //! Severity as string
const QString &getSeverityAsString() const; const QString &getSeverityAsString() const;

View File

@@ -185,7 +185,7 @@ namespace BlackMisc
*/ */
CIcon CValueObject::toIcon() const CIcon CValueObject::toIcon() const
{ {
return CIconList::iconForIndex(CIcons::StandardIconUnknown16); return CIconList::iconByIndex(CIcons::StandardIconUnknown16);
} }
/* /*