refactored mapping from message severity enum to string

This commit is contained in:
Marc Zinnschlag 2015-07-16 14:46:02 +02:00
parent 2d8a78726d
commit 9b12b4f1e2
4 changed files with 28 additions and 18 deletions

View file

@ -8,6 +8,20 @@ CSMDoc::Message::Message (const CSMWorld::UniversalId& id, const std::string& me
: mId (id), mMessage (message), mHint (hint), mSeverity (severity)
{}
std::string CSMDoc::Message::toString (Severity severity)
{
switch (severity)
{
case CSMDoc::Message::Severity_Info: return "Information";
case CSMDoc::Message::Severity_Warning: return "Warning";
case CSMDoc::Message::Severity_Error: return "Error";
case CSMDoc::Message::Severity_SeriousError: return "Serious Error";
case CSMDoc::Message::Severity_Default: break;
}
return "";
}
CSMDoc::Messages::Messages (Message::Severity default_)
: mDefault (default_)

View file

@ -31,6 +31,8 @@ namespace CSMDoc
Message (const CSMWorld::UniversalId& id, const std::string& message,
const std::string& hint, Severity severity);
static std::string toString (Severity severity);
};
class Messages

View file

@ -85,14 +85,8 @@ QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
if (index.column()==mColumnSeverity)
{
switch (mRows.at (index.row()).mSeverity)
{
case CSMDoc::Message::Severity_Info: return "Information";
case CSMDoc::Message::Severity_Warning: return "Warning";
case CSMDoc::Message::Severity_Error: return "Error";
case CSMDoc::Message::Severity_SeriousError: return "Serious Error";
case CSMDoc::Message::Severity_Default: break;
}
return QString::fromUtf8 (
CSMDoc::Message::toString (mRows.at (index.row()).mSeverity).c_str());
}
return QVariant();

View file

@ -34,7 +34,7 @@ void CSVWorld::ScriptErrorTable::addMessage (const std::string& message,
setRowCount (row+1);
setItem (row, 0, new QTableWidgetItem (""));
setItem (row, 0, new QTableWidgetItem (QString::fromUtf8 (CSMDoc::Message::toString (severity).c_str())));
if (line!=-1)
{