Human readable log category:

* fixed propertyIndex in CStatusMessage
* added method for human readable messages in CStatusMessage
* added typeid based category for classes
* listmodel for staus messages, added column and removed outdated data method
* columns, in class init
This commit is contained in:
Klaus Basan
2014-11-20 17:53:02 +01:00
committed by Roland Winklmeier
parent 6e5e28584f
commit 97e04f8360
8 changed files with 56 additions and 57 deletions

View File

@@ -21,11 +21,11 @@ namespace BlackGui
{}
CColumn::CColumn(const BlackMisc::CPropertyIndex &propertyIndex) :
m_formatter(new CPixmapFormatter()), m_propertyIndex(propertyIndex), m_editable(false)
m_formatter(new CPixmapFormatter()), m_propertyIndex(propertyIndex)
{}
CColumn::CColumn(const QString &toolTip, const BlackMisc::CPropertyIndex &propertyIndex) :
m_columnToolTip(toolTip), m_formatter(new CPixmapFormatter()), m_propertyIndex(propertyIndex), m_editable(false)
m_columnToolTip(toolTip), m_formatter(new CPixmapFormatter()), m_propertyIndex(propertyIndex)
{}
const char *CColumn::getTranslationContextChar() const

View File

@@ -88,7 +88,7 @@ namespace BlackGui
QString m_columnToolTip;
QSharedPointer<CDefaultFormatter> m_formatter;
BlackMisc::CPropertyIndex m_propertyIndex;
bool m_editable;
bool m_editable = false;
const char *getTranslationContextChar() const;
const char *getColumnNameChar() const;
const char *getColumnToolTipChar() const;

View File

@@ -27,9 +27,10 @@ namespace BlackGui
CListModelBase<BlackMisc::CStatusMessage, BlackMisc::CStatusMessageList>("ViewStatusMessageList", parent)
{
this->m_columns.addColumn(CColumn("time", CStatusMessage::IndexTimestamp, new CDateTimeFormatter(CDateTimeFormatter::formatHms())));
this->m_columns.addColumn(CColumn("severity", CStatusMessage::IndexSeverity));
this->m_columns.addColumn(CColumn::standardString("category", CStatusMessage::IndexCategoryHumanReadable));
this->m_columns.addColumn(CColumn("severity", CStatusMessage::IndexIcon));
this->m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage));
this->m_columns.addColumn(CColumn::standardString("category", CStatusMessage::IndexCategory));
this->m_columns.addColumn(CColumn::standardString("all categories", CStatusMessage::IndexCategories));
this->m_sortedColumn = CStatusMessage::IndexTimestamp;
this->m_sortOrder = Qt::DescendingOrder;
@@ -39,34 +40,8 @@ namespace BlackGui
(void)QT_TRANSLATE_NOOP("ViewStatusMessageList", "severity");
(void)QT_TRANSLATE_NOOP("ViewStatusMessageList", "type");
(void)QT_TRANSLATE_NOOP("ViewStatusMessageList", "message");
(void)QT_TRANSLATE_NOOP("ViewStatusMessageList", "all categories");
}
/*
* Display icons
*/
QVariant CStatusMessageListModel::data(const QModelIndex &modelIndex, int role) const
{
// shortcut, fast check
if (role != Qt::DisplayRole && role != Qt::DecorationRole) return CListModelBase::data(modelIndex, role);
if (this->columnToPropertyIndex(modelIndex.column()) == CStatusMessage::IndexSeverity)
{
if (role == Qt::DecorationRole)
{
CStatusMessage msg = this->at(modelIndex);
return QVariant(msg.toPixmap());
}
else if (role == Qt::DisplayRole)
{
// the text itself should be empty
return QVariant("");
}
else if (role == Qt::ToolTipRole)
{
CStatusMessage msg = this->at(modelIndex);
return QVariant(msg.getSeverityAsString());
}
}
return CListModelBase::data(modelIndex, role);
}
}
}
} // namespace
} // namespace

View File

@@ -34,9 +34,6 @@ namespace BlackGui
//! Destructor
virtual ~CStatusMessageListModel() {}
//! \copydoc CListModelBase::data
QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const override;
};
}
}