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
This commit is contained in:
Klaus Basan
2014-02-05 21:47:36 +00:00
committed by Mathew Sutcliffe
parent 431b347cfd
commit 7a63768c83
19 changed files with 87 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ namespace BlackGui
CUserListModel::CUserListModel(QObject *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::IndexCallsign, "callsign");
this->m_columns.addColumn(CUser::IndexId, "userid");
@@ -24,4 +25,22 @@ namespace BlackGui
(void)QT_TRANSLATE_NOOP("ViewUserList", "userid");
(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);
}
}

View File

@@ -26,6 +26,9 @@ namespace BlackGui
* \brief Destructor
*/
virtual ~CUserListModel() {}
//! \copydoc CListModelBase::data
QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const;
};
}
#endif // guard

View File

@@ -41,6 +41,38 @@ namespace BlackMisc
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
*/

View File

@@ -51,6 +51,12 @@ namespace BlackMisc
return QVariant::fromValue(*this);
}
//! \copydoc CValueObject::toIcon()
virtual const QPixmap &toIcon() const override
{
return CCallsign::convertToIcon(*this);
}
/*!
* \brief Is empty?
* \return
@@ -168,6 +174,9 @@ namespace BlackMisc
*/
static QString unifyCallsign(const QString &callsign);
//! \representing icon
static const QPixmap &convertToIcon(const CCallsign &callsign);
private:
QString m_callsignAsSet;
QString m_callsign;

View File

@@ -9,5 +9,16 @@
<file>icons/information.png</file>
<file>icons/question.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>
</RCC>

BIN
src/blackmisc/icons/C1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
src/blackmisc/icons/C3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
src/blackmisc/icons/I1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
src/blackmisc/icons/I3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
src/blackmisc/icons/MNT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
src/blackmisc/icons/OBS.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
src/blackmisc/icons/S1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
src/blackmisc/icons/S2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
src/blackmisc/icons/S3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
src/blackmisc/icons/SUP.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -168,6 +168,8 @@ namespace BlackMisc
return QVariant(this->m_realname);
case IndexCallsign:
return this->m_callsign.toQVariant();
case IndexCallsignIcon:
return this->m_callsign.toIcon();
default:
break;
}

View File

@@ -32,7 +32,8 @@ namespace BlackMisc
IndexId,
IndexPassword,
IndexRealName,
IndexCallsign
IndexCallsign,
IndexCallsignIcon
};
/*!
@@ -137,6 +138,12 @@ namespace BlackMisc
*/
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 ==
*/

View File

@@ -93,9 +93,9 @@ namespace BlackMisc
*/
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));
static const QPixmap w(QPixmap(":/blackmisc/icons/warning.png").scaledToWidth(16, Qt::SmoothTransformation));
static const QPixmap e(QPixmap(":/blackmisc/icons/critical.png").scaledToWidth(16, Qt::SmoothTransformation));
static const QPixmap i(QPixmap(":/blackmisc/icons/information.png").scaledToWidth(16, Qt::SmoothTransformation));
switch (statusMessage.getSeverity())
{
case SeverityInfo: return i;