Allows to display callsign / user / statusmessage as icon in views. refs #122
* Icons * update of resource file * update in CValueObject classes callsign / user / statusmessage * update in list models, data method for returning Pixmap
@@ -13,6 +13,7 @@ namespace BlackGui
|
|||||||
CUserListModel::CUserListModel(QObject *parent) :
|
CUserListModel::CUserListModel(QObject *parent) :
|
||||||
CListModelBase<BlackMisc::Network::CUser, BlackMisc::Network::CUserList>("ViewUserList", parent)
|
CListModelBase<BlackMisc::Network::CUser, BlackMisc::Network::CUserList>("ViewUserList", parent)
|
||||||
{
|
{
|
||||||
|
this->m_columns.addColumn(CUser::IndexCallsignIcon, "");
|
||||||
this->m_columns.addColumn(CUser::IndexRealName, "realname");
|
this->m_columns.addColumn(CUser::IndexRealName, "realname");
|
||||||
this->m_columns.addColumn(CUser::IndexCallsign, "callsign");
|
this->m_columns.addColumn(CUser::IndexCallsign, "callsign");
|
||||||
this->m_columns.addColumn(CUser::IndexId, "userid");
|
this->m_columns.addColumn(CUser::IndexId, "userid");
|
||||||
@@ -24,4 +25,22 @@ namespace BlackGui
|
|||||||
(void)QT_TRANSLATE_NOOP("ViewUserList", "userid");
|
(void)QT_TRANSLATE_NOOP("ViewUserList", "userid");
|
||||||
(void)QT_TRANSLATE_NOOP("ViewUserList", "email");
|
(void)QT_TRANSLATE_NOOP("ViewUserList", "email");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display icons
|
||||||
|
*/
|
||||||
|
QVariant CUserListModel::data(const QModelIndex &modelIndex, int role) const
|
||||||
|
{
|
||||||
|
// shortcut, fast check
|
||||||
|
if (role != Qt::DecorationRole) return CListModelBase::data(modelIndex, role);
|
||||||
|
if (this->columnToPropertyIndex(modelIndex.column()) == CUser::IndexCallsignIcon)
|
||||||
|
{
|
||||||
|
if (role == Qt::DecorationRole)
|
||||||
|
{
|
||||||
|
CUser u = this->at(modelIndex);
|
||||||
|
return u.toIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CListModelBase::data(modelIndex, role);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ namespace BlackGui
|
|||||||
* \brief Destructor
|
* \brief Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~CUserListModel() {}
|
virtual ~CUserListModel() {}
|
||||||
|
|
||||||
|
//! \copydoc CListModelBase::data
|
||||||
|
QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -41,6 +41,38 @@ namespace BlackMisc
|
|||||||
return unified;
|
return unified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Iconify
|
||||||
|
*/
|
||||||
|
const QPixmap &CCallsign::convertToIcon(const CCallsign &callsign)
|
||||||
|
{
|
||||||
|
static const QPixmap app(QPixmap(":/blackmisc/icons/question.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
|
static const QPixmap gnd(QPixmap(":/blackmisc/icons/question.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
|
static const QPixmap del(QPixmap(":/blackmisc/icons/question.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
|
static const QPixmap twr(QPixmap(":/blackmisc/icons/question.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
|
static const QPixmap pilot(QPixmap(":/blackmisc/icons/aeropuerto.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
|
static const QPixmap sup(":/blackmisc/icons/SUP.png");
|
||||||
|
static const QPixmap unknown(QPixmap(":/blackmisc/icons/question.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
|
|
||||||
|
QString t = callsign.asString().toUpper();
|
||||||
|
if (t.length() < 3) return unknown;
|
||||||
|
t = t.right(3);
|
||||||
|
|
||||||
|
if (callsign.getStringAsSet().contains("_"))
|
||||||
|
{
|
||||||
|
if ("APP" == t) return app;
|
||||||
|
if ("GND" == t) return gnd;
|
||||||
|
if ("TWR" == t) return twr;
|
||||||
|
if ("DEL" == t) return del;
|
||||||
|
if ("SUP" == t) return sup;
|
||||||
|
return unknown;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return pilot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callsign as Observer
|
* Callsign as Observer
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ namespace BlackMisc
|
|||||||
return QVariant::fromValue(*this);
|
return QVariant::fromValue(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::toIcon()
|
||||||
|
virtual const QPixmap &toIcon() const override
|
||||||
|
{
|
||||||
|
return CCallsign::convertToIcon(*this);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Is empty?
|
* \brief Is empty?
|
||||||
* \return
|
* \return
|
||||||
@@ -168,6 +174,9 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
static QString unifyCallsign(const QString &callsign);
|
static QString unifyCallsign(const QString &callsign);
|
||||||
|
|
||||||
|
//! \representing icon
|
||||||
|
static const QPixmap &convertToIcon(const CCallsign &callsign);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_callsignAsSet;
|
QString m_callsignAsSet;
|
||||||
QString m_callsign;
|
QString m_callsign;
|
||||||
|
|||||||
@@ -9,5 +9,16 @@
|
|||||||
<file>icons/information.png</file>
|
<file>icons/information.png</file>
|
||||||
<file>icons/question.png</file>
|
<file>icons/question.png</file>
|
||||||
<file>icons/warning.png</file>
|
<file>icons/warning.png</file>
|
||||||
|
<file>icons/C1.png</file>
|
||||||
|
<file>icons/C3.png</file>
|
||||||
|
<file>icons/I1.png</file>
|
||||||
|
<file>icons/I3.png</file>
|
||||||
|
<file>icons/MNT.png</file>
|
||||||
|
<file>icons/OBS.png</file>
|
||||||
|
<file>icons/S1.png</file>
|
||||||
|
<file>icons/S2.png</file>
|
||||||
|
<file>icons/S3.png</file>
|
||||||
|
<file>icons/SUP.png</file>
|
||||||
|
<file>icons/aeropuerto.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
BIN
src/blackmisc/icons/C1.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/blackmisc/icons/C3.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/blackmisc/icons/I1.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/blackmisc/icons/I3.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/blackmisc/icons/MNT.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/blackmisc/icons/OBS.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/blackmisc/icons/S1.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/blackmisc/icons/S2.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/blackmisc/icons/S3.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/blackmisc/icons/SUP.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/blackmisc/icons/aeropuerto.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
@@ -168,6 +168,8 @@ namespace BlackMisc
|
|||||||
return QVariant(this->m_realname);
|
return QVariant(this->m_realname);
|
||||||
case IndexCallsign:
|
case IndexCallsign:
|
||||||
return this->m_callsign.toQVariant();
|
return this->m_callsign.toQVariant();
|
||||||
|
case IndexCallsignIcon:
|
||||||
|
return this->m_callsign.toIcon();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ namespace BlackMisc
|
|||||||
IndexId,
|
IndexId,
|
||||||
IndexPassword,
|
IndexPassword,
|
||||||
IndexRealName,
|
IndexRealName,
|
||||||
IndexCallsign
|
IndexCallsign,
|
||||||
|
IndexCallsignIcon
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -137,6 +138,12 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign) { m_callsign = callsign; }
|
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign) { m_callsign = callsign; }
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::toIcon()
|
||||||
|
virtual const QPixmap &toIcon() const override
|
||||||
|
{
|
||||||
|
return this->getCallsign().toIcon();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Equal operator ==
|
* \brief Equal operator ==
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -93,9 +93,9 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
const QPixmap &CStatusMessage::convertToIcon(const CStatusMessage &statusMessage)
|
const QPixmap &CStatusMessage::convertToIcon(const CStatusMessage &statusMessage)
|
||||||
{
|
{
|
||||||
static QPixmap w(QPixmap(":/blackmisc/icons/warning.png").scaledToWidth(16, Qt::SmoothTransformation));
|
static const QPixmap w(QPixmap(":/blackmisc/icons/warning.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
static QPixmap e(QPixmap(":/blackmisc/icons/critical.png").scaledToWidth(16, Qt::SmoothTransformation));
|
static const QPixmap e(QPixmap(":/blackmisc/icons/critical.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
static QPixmap i(QPixmap(":/blackmisc/icons/information.png").scaledToWidth(16, Qt::SmoothTransformation));
|
static const QPixmap i(QPixmap(":/blackmisc/icons/information.png").scaledToWidth(16, Qt::SmoothTransformation));
|
||||||
switch (statusMessage.getSeverity())
|
switch (statusMessage.getSeverity())
|
||||||
{
|
{
|
||||||
case SeverityInfo: return i;
|
case SeverityInfo: return i;
|
||||||
|
|||||||