From 4042b120130a971e234b08a6a9826d4c15b56d0b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 29 Mar 2015 13:43:11 +0200 Subject: [PATCH] changed data structure for report model --- apps/opencs/model/tools/reportmodel.cpp | 20 +++++++++++++------- apps/opencs/model/tools/reportmodel.hpp | 12 +++++++++++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/apps/opencs/model/tools/reportmodel.cpp b/apps/opencs/model/tools/reportmodel.cpp index acd4728c6..cc6c5a44c 100644 --- a/apps/opencs/model/tools/reportmodel.cpp +++ b/apps/opencs/model/tools/reportmodel.cpp @@ -3,6 +3,12 @@ #include +CSMTools::ReportModel::Line::Line (const CSMWorld::UniversalId& id, const std::string& message, + const std::string& hint) +: mId (id), mMessage (message), mHint (hint) +{} + + int CSMTools::ReportModel::rowCount (const QModelIndex & parent) const { if (parent.isValid()) @@ -25,12 +31,12 @@ QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const return QVariant(); if (index.column()==0) - return static_cast (mRows.at (index.row()).first.getType()); + return static_cast (mRows.at (index.row()).mId.getType()); if (index.column()==1) - return QString::fromUtf8 (mRows.at (index.row()).second.first.c_str()); + return QString::fromUtf8 (mRows.at (index.row()).mMessage.c_str()); - return QString::fromUtf8 (mRows.at (index.row()).second.second.c_str()); + return QString::fromUtf8 (mRows.at (index.row()).mHint.c_str()); } QVariant CSMTools::ReportModel::headerData (int section, Qt::Orientation orientation, int role) const @@ -64,20 +70,20 @@ void CSMTools::ReportModel::add (const CSMWorld::UniversalId& id, const std::str const std::string& hint) { beginInsertRows (QModelIndex(), mRows.size(), mRows.size()); - - mRows.push_back (std::make_pair (id, std::make_pair (message, hint))); + + mRows.push_back (Line (id, message, hint)); endInsertRows(); } const CSMWorld::UniversalId& CSMTools::ReportModel::getUniversalId (int row) const { - return mRows.at (row).first; + return mRows.at (row).mId; } std::string CSMTools::ReportModel::getHint (int row) const { - return mRows.at (row).second.second; + return mRows.at (row).mHint; } void CSMTools::ReportModel::clear() diff --git a/apps/opencs/model/tools/reportmodel.hpp b/apps/opencs/model/tools/reportmodel.hpp index 71f5bdf73..64a477b6c 100644 --- a/apps/opencs/model/tools/reportmodel.hpp +++ b/apps/opencs/model/tools/reportmodel.hpp @@ -14,7 +14,17 @@ namespace CSMTools { Q_OBJECT - std::vector > > mRows; + 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; public: