Files
pilotclient/src/blackgui/models/statusmessagelistmodel.cpp
Klaus Basan b09dbd4828 refs #568, improved display / sorting for status message categories
* display technical categories when no hr categories are available
* compare function for status message
2016-01-28 16:32:01 +01:00

71 lines
3.1 KiB
C++

/* Copyright (C) 2013
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "statusmessagelistmodel.h"
#include "blackmisc/icon.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include <QMetaProperty>
#include <QBrush>
#include <QIcon>
using namespace BlackMisc;
namespace BlackGui
{
namespace Models
{
CStatusMessageListModel::CStatusMessageListModel(QObject *parent) :
CListModelBase<CStatusMessage, CStatusMessageList, true>("ViewStatusMessageList", parent)
{
setMode(Detailed);
// force strings for translation in resource files
(void)QT_TRANSLATE_NOOP("ViewStatusMessageList", "time");
(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");
}
void CStatusMessageListModel::setMode(CStatusMessageListModel::Mode mode)
{
this->m_columns.clear();
switch (mode)
{
case Detailed:
{
this->m_columns.addColumn(CColumn("time", CStatusMessage::IndexUtcTimestamp, new CDateTimeFormatter(CDateTimeFormatter::formatHms())));
this->m_columns.addColumn(CColumn::standardString("category", CStatusMessage::IndexCategoryHumanReadableOrTechnicalAsString));
CColumn col = CColumn("severity", CStatusMessage::IndexIcon);
col.setSortPropertyIndex(CStatusMessage::IndexSeverityAsString);
this->m_columns.addColumn(col);
this->m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage));
this->m_sortedColumn = CStatusMessage::IndexUtcTimestamp;
this->m_sortOrder = Qt::DescendingOrder;
}
break;
case Simplified:
{
this->m_columns.addColumn(CColumn("time", CStatusMessage::IndexUtcTimestamp, new CDateTimeFormatter(CDateTimeFormatter::formatHms())));
CColumn col = CColumn("severity", CStatusMessage::IndexIcon);
col.setSortPropertyIndex(CStatusMessage::IndexSeverityAsString);
this->m_columns.addColumn(col);
this->m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage));
this->m_sortedColumn = CStatusMessage::IndexUtcTimestamp;
this->m_sortOrder = Qt::DescendingOrder;
}
break;
}
}
} // namespace
} // namespace