From a8cdd30124669136d360be0c869c9f1182ea8655 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 29 Mar 2015 13:55:31 +0200 Subject: [PATCH] added ID column to report table --- apps/opencs/model/tools/reportmodel.cpp | 44 ++++++++++++++++++------- apps/opencs/model/tools/reportmodel.hpp | 5 +++ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/apps/opencs/model/tools/reportmodel.cpp b/apps/opencs/model/tools/reportmodel.cpp index cc6c5a44c..218f391c9 100644 --- a/apps/opencs/model/tools/reportmodel.cpp +++ b/apps/opencs/model/tools/reportmodel.cpp @@ -22,7 +22,7 @@ int CSMTools::ReportModel::columnCount (const QModelIndex & parent) const if (parent.isValid()) return 0; - return 3; + return 4; } QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const @@ -30,13 +30,32 @@ QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const if (role!=Qt::DisplayRole) return QVariant(); - if (index.column()==0) - return static_cast (mRows.at (index.row()).mId.getType()); + switch (index.column()) + { + case Column_Type: + + return static_cast (mRows.at (index.row()).mId.getType()); + + case Column_Id: + { + CSMWorld::UniversalId id = mRows.at (index.row()).mId; + + if (id.getArgumentType()==CSMWorld::UniversalId::ArgumentType_Id) + return QString::fromUtf8 (id.getId().c_str()); - if (index.column()==1) - return QString::fromUtf8 (mRows.at (index.row()).mMessage.c_str()); + return QString ("-"); + } + + case Column_Description: - return QString::fromUtf8 (mRows.at (index.row()).mHint.c_str()); + return QString::fromUtf8 (mRows.at (index.row()).mMessage.c_str()); + + case Column_Hint: + + return QString::fromUtf8 (mRows.at (index.row()).mHint.c_str()); + } + + return QVariant(); } QVariant CSMTools::ReportModel::headerData (int section, Qt::Orientation orientation, int role) const @@ -47,13 +66,14 @@ QVariant CSMTools::ReportModel::headerData (int section, Qt::Orientation orienta if (orientation==Qt::Vertical) return QVariant(); - if (section==0) - return "Type"; - - if (section==1) - return "Description"; + switch (section) + { + case Column_Type: return "Type"; + case Column_Id: return "ID"; + case Column_Description: return "Description"; + } - return "Hint"; + return "-"; } bool CSMTools::ReportModel::removeRows (int row, int count, const QModelIndex& parent) diff --git a/apps/opencs/model/tools/reportmodel.hpp b/apps/opencs/model/tools/reportmodel.hpp index 64a477b6c..5f39316aa 100644 --- a/apps/opencs/model/tools/reportmodel.hpp +++ b/apps/opencs/model/tools/reportmodel.hpp @@ -26,6 +26,11 @@ namespace CSMTools std::vector mRows; + enum Columns + { + Column_Type = 0, Column_Id = 1, Column_Hint = 2, Column_Description = 3 + }; + public: virtual int rowCount (const QModelIndex & parent = QModelIndex()) const;