From 0e21c61297d8775740386634e28f60f51ee7dbe2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 20 Jun 2015 16:55:34 +0200 Subject: [PATCH] replaced redundant CSMTools::ReportModel::Line struct with CSMDoc::Message struct --- apps/opencs/model/doc/messages.cpp | 13 +++++++------ apps/opencs/model/doc/messages.hpp | 18 ++++++++++++------ apps/opencs/model/tools/reportmodel.cpp | 9 ++------- apps/opencs/model/tools/reportmodel.hpp | 14 +++----------- 4 files changed, 24 insertions(+), 30 deletions(-) diff --git a/apps/opencs/model/doc/messages.cpp b/apps/opencs/model/doc/messages.cpp index 9b295fb28..3c709683e 100644 --- a/apps/opencs/model/doc/messages.cpp +++ b/apps/opencs/model/doc/messages.cpp @@ -1,15 +1,16 @@ #include "messages.hpp" +CSMDoc::Message::Message (const CSMWorld::UniversalId& id, const std::string& message, + const std::string& hint) +: mId (id), mMessage (message), mHint (hint) +{} + + void CSMDoc::Messages::add (const CSMWorld::UniversalId& id, const std::string& message, const std::string& hint) { - Message data; - data.mId = id; - data.mMessage = message; - data.mHint = hint; - - mMessages.push_back (data); + mMessages.push_back (Message (id, message, hint)); } void CSMDoc::Messages::push_back (const std::pair& data) diff --git a/apps/opencs/model/doc/messages.hpp b/apps/opencs/model/doc/messages.hpp index 0f36c73a7..4e143d869 100644 --- a/apps/opencs/model/doc/messages.hpp +++ b/apps/opencs/model/doc/messages.hpp @@ -8,16 +8,22 @@ namespace CSMDoc { + struct Message + { + CSMWorld::UniversalId mId; + std::string mMessage; + std::string mHint; + + Message (const CSMWorld::UniversalId& id, const std::string& message, + const std::string& hint); + }; + class Messages { public: - struct Message - { - CSMWorld::UniversalId mId; - std::string mMessage; - std::string mHint; - }; + // \deprecated Use CSMDoc::Message directly instead. + typedef CSMDoc::Message Message; typedef std::vector Collection; diff --git a/apps/opencs/model/tools/reportmodel.cpp b/apps/opencs/model/tools/reportmodel.cpp index 1248e202b..e661e9eac 100644 --- a/apps/opencs/model/tools/reportmodel.cpp +++ b/apps/opencs/model/tools/reportmodel.cpp @@ -6,11 +6,6 @@ #include "../world/columns.hpp" -CSMTools::ReportModel::Line::Line (const CSMWorld::UniversalId& id, const std::string& message, - const std::string& hint) -: mId (id), mMessage (message), mHint (hint) -{} - CSMTools::ReportModel::ReportModel (bool fieldColumn) { if (fieldColumn) @@ -137,14 +132,14 @@ void CSMTools::ReportModel::add (const CSMWorld::UniversalId& id, const std::str { beginInsertRows (QModelIndex(), mRows.size(), mRows.size()); - mRows.push_back (Line (id, message, hint)); + mRows.push_back (CSMDoc::Message (id, message, hint)); endInsertRows(); } void CSMTools::ReportModel::flagAsReplaced (int index) { - Line& line = mRows.at (index); + CSMDoc::Message& line = mRows.at (index); std::string hint = line.mHint; if (hint.empty() || hint[0]!='R') diff --git a/apps/opencs/model/tools/reportmodel.hpp b/apps/opencs/model/tools/reportmodel.hpp index 4d2d0542f..ff20f74a5 100644 --- a/apps/opencs/model/tools/reportmodel.hpp +++ b/apps/opencs/model/tools/reportmodel.hpp @@ -6,6 +6,8 @@ #include +#include "../doc/messages.hpp" + #include "../world/universalid.hpp" namespace CSMTools @@ -14,17 +16,7 @@ namespace CSMTools { Q_OBJECT - struct Line - { - Line (const CSMWorld::UniversalId& id, const std::string& message, - const std::string& hint); - - CSMWorld::UniversalId mId; - std::string mMessage; - std::string mHint; - }; - - std::vector mRows; + std::vector mRows; // Fixed columns enum Columns