mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 06:09:40 +00:00
refactored mapping from message severity enum to string
This commit is contained in:
parent
3ea445cc67
commit
092204bd82
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)
|
: 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_)
|
CSMDoc::Messages::Messages (Message::Severity default_)
|
||||||
: mDefault (default_)
|
: mDefault (default_)
|
||||||
|
@ -18,7 +32,7 @@ void CSMDoc::Messages::add (const CSMWorld::UniversalId& id, const std::string&
|
||||||
{
|
{
|
||||||
if (severity==Message::Severity_Default)
|
if (severity==Message::Severity_Default)
|
||||||
severity = mDefault;
|
severity = mDefault;
|
||||||
|
|
||||||
mMessages.push_back (Message (id, message, hint, severity));
|
mMessages.push_back (Message (id, message, hint, severity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,18 +21,20 @@ namespace CSMDoc
|
||||||
// reporting it correctly
|
// reporting it correctly
|
||||||
Severity_Default = 4
|
Severity_Default = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
CSMWorld::UniversalId mId;
|
CSMWorld::UniversalId mId;
|
||||||
std::string mMessage;
|
std::string mMessage;
|
||||||
std::string mHint;
|
std::string mHint;
|
||||||
Severity mSeverity;
|
Severity mSeverity;
|
||||||
|
|
||||||
Message();
|
Message();
|
||||||
|
|
||||||
Message (const CSMWorld::UniversalId& id, const std::string& message,
|
Message (const CSMWorld::UniversalId& id, const std::string& message,
|
||||||
const std::string& hint, Severity severity);
|
const std::string& hint, Severity severity);
|
||||||
|
|
||||||
|
static std::string toString (Severity severity);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Messages
|
class Messages
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -13,7 +13,7 @@ CSMTools::ReportModel::ReportModel (bool fieldColumn, bool severityColumn)
|
||||||
|
|
||||||
if (severityColumn)
|
if (severityColumn)
|
||||||
mColumnSeverity = index++;
|
mColumnSeverity = index++;
|
||||||
|
|
||||||
if (fieldColumn)
|
if (fieldColumn)
|
||||||
mColumnField = index++;
|
mColumnField = index++;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
|
||||||
case Column_Type:
|
case Column_Type:
|
||||||
|
|
||||||
return static_cast<int> (mRows.at (index.row()).mId.getType());
|
return static_cast<int> (mRows.at (index.row()).mId.getType());
|
||||||
|
|
||||||
case Column_Id:
|
case Column_Id:
|
||||||
{
|
{
|
||||||
CSMWorld::UniversalId id = mRows.at (index.row()).mId;
|
CSMWorld::UniversalId id = mRows.at (index.row()).mId;
|
||||||
|
@ -56,7 +56,7 @@ QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
|
||||||
|
|
||||||
return QString ("-");
|
return QString ("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
case Column_Hint:
|
case Column_Hint:
|
||||||
|
|
||||||
return QString::fromUtf8 (mRows.at (index.row()).mHint.c_str());
|
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)
|
if (index.column()==mColumnSeverity)
|
||||||
{
|
{
|
||||||
switch (mRows.at (index.row()).mSeverity)
|
return QString::fromUtf8 (
|
||||||
{
|
CSMDoc::Message::toString (mRows.at (index.row()).mSeverity).c_str());
|
||||||
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 QVariant();
|
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)
|
void CSMTools::ReportModel::add (const CSMDoc::Message& message)
|
||||||
{
|
{
|
||||||
beginInsertRows (QModelIndex(), mRows.size(), mRows.size());
|
beginInsertRows (QModelIndex(), mRows.size(), mRows.size());
|
||||||
|
|
||||||
mRows.push_back (message);
|
mRows.push_back (message);
|
||||||
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
|
@ -34,7 +34,7 @@ void CSVWorld::ScriptErrorTable::addMessage (const std::string& message,
|
||||||
|
|
||||||
setRowCount (row+1);
|
setRowCount (row+1);
|
||||||
|
|
||||||
setItem (row, 0, new QTableWidgetItem (""));
|
setItem (row, 0, new QTableWidgetItem (QString::fromUtf8 (CSMDoc::Message::toString (severity).c_str())));
|
||||||
|
|
||||||
if (line!=-1)
|
if (line!=-1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue