mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
CValueObject virtual method toIcon, reprsenting the object as icon where applicable.
Currently used for status messages (severity), will be used for CAtcStation and others as well.
This commit is contained in:
committed by
Mathew Sutcliffe
parent
4ec1db4b38
commit
fda587994d
@@ -21,10 +21,10 @@ int main(int argc, char *argv[])
|
|||||||
BlackMisc::registerMetadata();
|
BlackMisc::registerMetadata();
|
||||||
// BlackMisc::displayAllUserMetatypesTypes();
|
// BlackMisc::displayAllUserMetatypesTypes();
|
||||||
|
|
||||||
QFile file(":/translations/blackmisc_i18n_de.qm");
|
QFile file(":blackmisc/translations/blackmisc_i18n_de.qm");
|
||||||
qDebug() << (file.exists() ? "Found translations in resources" : "No translations in resources");
|
qDebug() << (file.exists() ? "Found translations in resources" : "No translations in resources");
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
translator.load("blackmisc_i18n_de", ":/translations/");
|
translator.load("blackmisc_i18n_de", ":blackmisc/translations/");
|
||||||
|
|
||||||
// app
|
// app
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|||||||
@@ -36,22 +36,12 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
// shortcut, fast check
|
// shortcut, fast check
|
||||||
if (role != Qt::DisplayRole && role != Qt::DecorationRole) return CListModelBase::data(modelIndex, role);
|
if (role != Qt::DisplayRole && role != Qt::DecorationRole) return CListModelBase::data(modelIndex, role);
|
||||||
|
|
||||||
static QPixmap w(QPixmap(":/blackgui/iconsQt/warning.png").scaledToWidth(16, Qt::SmoothTransformation));
|
|
||||||
static QPixmap e(QPixmap(":/blackgui/iconsQt/critical.png").scaledToWidth(16, Qt::SmoothTransformation));
|
|
||||||
static QPixmap i(QPixmap(":/blackgui/iconsQt/information.png").scaledToWidth(16, Qt::SmoothTransformation));
|
|
||||||
|
|
||||||
if (this->columnToPropertyIndex(modelIndex.column()) == CStatusMessage::IndexSeverity)
|
if (this->columnToPropertyIndex(modelIndex.column()) == CStatusMessage::IndexSeverity)
|
||||||
{
|
{
|
||||||
if (role == Qt::DecorationRole)
|
if (role == Qt::DecorationRole)
|
||||||
{
|
{
|
||||||
CStatusMessage msg = this->at(modelIndex);
|
CStatusMessage msg = this->at(modelIndex);
|
||||||
switch (msg.getSeverity())
|
return msg.toIcon();
|
||||||
{
|
|
||||||
case CStatusMessage::SeverityError: return e;
|
|
||||||
case CStatusMessage::SeverityWarning: return w;
|
|
||||||
default: return i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (role == Qt::DisplayRole)
|
else if (role == Qt::DisplayRole)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,6 +88,23 @@ namespace BlackMisc
|
|||||||
return CStatusMessage(CStatusMessage::TypeUnspecific, CStatusMessage::SeverityInfo, message);
|
return CStatusMessage(CStatusMessage::TypeUnspecific, CStatusMessage::SeverityInfo, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pixmap
|
||||||
|
*/
|
||||||
|
const QPixmap &CStatusMessage::convertToIcon(const CStatusMessage &statusMessage)
|
||||||
|
{
|
||||||
|
static QPixmap w(QPixmap(":/blackmisc/icons/warning.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
|
static QPixmap e(QPixmap(":/blackmisc/icons/critical.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
|
static QPixmap i(QPixmap(":/blackmisc/icons/information.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
|
switch (statusMessage.getSeverity())
|
||||||
|
{
|
||||||
|
case SeverityInfo: return i;
|
||||||
|
case SeverityWarning: return w;
|
||||||
|
case SeverityError: return e;
|
||||||
|
default: return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hash
|
* Hash
|
||||||
*/
|
*/
|
||||||
@@ -260,7 +277,7 @@ namespace BlackMisc
|
|||||||
/*
|
/*
|
||||||
* Set property as index
|
* Set property as index
|
||||||
*/
|
*/
|
||||||
void CStatusMessage::propertyByIndex(const QVariant &variant, int index)
|
void CStatusMessage::setPropertyByIndex(const QVariant &variant, int index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -114,6 +114,9 @@ namespace BlackMisc
|
|||||||
//! \brief Type as string
|
//! \brief Type as string
|
||||||
const QString &getTypeAsString() const;
|
const QString &getTypeAsString() const;
|
||||||
|
|
||||||
|
//! \brief representing icon
|
||||||
|
virtual const QPixmap &toIcon() const override { return CStatusMessage::convertToIcon(*this); }
|
||||||
|
|
||||||
//! \brief Type as string
|
//! \brief Type as string
|
||||||
const QString &getSeverityAsString() const;
|
const QString &getSeverityAsString() const;
|
||||||
|
|
||||||
@@ -159,6 +162,9 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
static CStatusMessage getInfoMessage(const QString &message);
|
static CStatusMessage getInfoMessage(const QString &message);
|
||||||
|
|
||||||
|
//! \representing icon
|
||||||
|
static const QPixmap &convertToIcon(const CStatusMessage &statusMessage);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*!
|
/*!
|
||||||
* \brief Marshall to DBus
|
* \brief Marshall to DBus
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QPixmap>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -173,6 +174,12 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
virtual QVariant toQVariant() const = 0;
|
virtual QVariant toQVariant() const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief As icon, not implement by all classes
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
virtual const QPixmap &toIcon() const { static const QPixmap p; return p; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set property by index
|
* \brief Set property by index
|
||||||
* \remarks Intentionally not abstract, avoiding all classes need to implement this method
|
* \remarks Intentionally not abstract, avoiding all classes need to implement this method
|
||||||
|
|||||||
Reference in New Issue
Block a user