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:
Klaus Basan
2014-02-05 21:33:40 +00:00
committed by Mathew Sutcliffe
parent 4ec1db4b38
commit fda587994d
5 changed files with 34 additions and 14 deletions

View File

@@ -36,22 +36,12 @@ namespace BlackGui
{
// shortcut, fast check
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 (role == Qt::DecorationRole)
{
CStatusMessage msg = this->at(modelIndex);
switch (msg.getSeverity())
{
case CStatusMessage::SeverityError: return e;
case CStatusMessage::SeverityWarning: return w;
default: return i;
}
return msg.toIcon();
}
else if (role == Qt::DisplayRole)
{