forked from mirror/openmw-tes3mp
refactored mapping from message severity enum to string
This commit is contained in:
parent
2d8a78726d
commit
9b12b4f1e2
4 changed files with 28 additions and 18 deletions
|
@ -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_)
|
||||
|
@ -18,7 +32,7 @@ void CSMDoc::Messages::add (const CSMWorld::UniversalId& id, const std::string&
|
|||
{
|
||||
if (severity==Message::Severity_Default)
|
||||
severity = mDefault;
|
||||
|
||||
|
||||
mMessages.push_back (Message (id, message, hint, severity));
|
||||
}
|
||||
|
||||
|
|
|
@ -21,18 +21,20 @@ namespace CSMDoc
|
|||
// reporting it correctly
|
||||
Severity_Default = 4
|
||||
};
|
||||
|
||||
|
||||
CSMWorld::UniversalId mId;
|
||||
std::string mMessage;
|
||||
std::string mHint;
|
||||
Severity mSeverity;
|
||||
|
||||
Message();
|
||||
|
||||
|
||||
Message (const CSMWorld::UniversalId& id, const std::string& message,
|
||||
const std::string& hint, Severity severity);
|
||||
|
||||
static std::string toString (Severity severity);
|
||||
};
|
||||
|
||||
|
||||
class Messages
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -13,7 +13,7 @@ CSMTools::ReportModel::ReportModel (bool fieldColumn, bool severityColumn)
|
|||
|
||||
if (severityColumn)
|
||||
mColumnSeverity = index++;
|
||||
|
||||
|
||||
if (fieldColumn)
|
||||
mColumnField = index++;
|
||||
|
||||
|
@ -46,7 +46,7 @@ QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
|
|||
case Column_Type:
|
||||
|
||||
return static_cast<int> (mRows.at (index.row()).mId.getType());
|
||||
|
||||
|
||||
case Column_Id:
|
||||
{
|
||||
CSMWorld::UniversalId id = mRows.at (index.row()).mId;
|
||||
|
@ -56,7 +56,7 @@ QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
|
|||
|
||||
return QString ("-");
|
||||
}
|
||||
|
||||
|
||||
case Column_Hint:
|
||||
|
||||
return QString::fromUtf8 (mRows.at (index.row()).mHint.c_str());
|
||||
|
@ -85,16 +85,10 @@ 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();
|
||||
}
|
||||
|
||||
|
@ -144,7 +138,7 @@ bool CSMTools::ReportModel::removeRows (int row, int count, const QModelIndex& p
|
|||
void CSMTools::ReportModel::add (const CSMDoc::Message& message)
|
||||
{
|
||||
beginInsertRows (QModelIndex(), mRows.size(), mRows.size());
|
||||
|
||||
|
||||
mRows.push_back (message);
|
||||
|
||||
endInsertRows();
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue