mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 18:19:40 +00:00
added field column to report table
This commit is contained in:
parent
416b8165cd
commit
e8091c4e7e
4 changed files with 59 additions and 9 deletions
|
@ -2,12 +2,29 @@
|
||||||
#include "reportmodel.hpp"
|
#include "reportmodel.hpp"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "../world/columns.hpp"
|
||||||
|
|
||||||
CSMTools::ReportModel::Line::Line (const CSMWorld::UniversalId& id, const std::string& message,
|
CSMTools::ReportModel::Line::Line (const CSMWorld::UniversalId& id, const std::string& message,
|
||||||
const std::string& hint)
|
const std::string& hint)
|
||||||
: mId (id), mMessage (message), mHint (hint)
|
: mId (id), mMessage (message), mHint (hint)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
CSMTools::ReportModel::ReportModel (bool fieldColumn)
|
||||||
|
{
|
||||||
|
if (fieldColumn)
|
||||||
|
{
|
||||||
|
mColumnField = 3;
|
||||||
|
mColumnDescription = 4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mColumnDescription = 3;
|
||||||
|
|
||||||
|
mColumnField = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int CSMTools::ReportModel::rowCount (const QModelIndex & parent) const
|
int CSMTools::ReportModel::rowCount (const QModelIndex & parent) const
|
||||||
{
|
{
|
||||||
|
@ -22,7 +39,7 @@ int CSMTools::ReportModel::columnCount (const QModelIndex & parent) const
|
||||||
if (parent.isValid())
|
if (parent.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 4;
|
return mColumnDescription+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
|
QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
|
||||||
|
@ -46,15 +63,32 @@ QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
|
||||||
return QString ("-");
|
return QString ("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
case Column_Description:
|
|
||||||
|
|
||||||
return QString::fromUtf8 (mRows.at (index.row()).mMessage.c_str());
|
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (index.column()==mColumnDescription)
|
||||||
|
return QString::fromUtf8 (mRows.at (index.row()).mMessage.c_str());
|
||||||
|
|
||||||
|
if (index.column()==mColumnField)
|
||||||
|
{
|
||||||
|
std::string field;
|
||||||
|
|
||||||
|
std::istringstream stream (mRows.at (index.row()).mHint);
|
||||||
|
|
||||||
|
char type, ignore;
|
||||||
|
int fieldIndex;
|
||||||
|
|
||||||
|
if ((stream >> type >> ignore >> fieldIndex) && type=='r')
|
||||||
|
{
|
||||||
|
field = CSMWorld::Columns::getName (
|
||||||
|
static_cast<CSMWorld::Columns::ColumnId> (fieldIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString::fromUtf8 (field.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,9 +104,14 @@ QVariant CSMTools::ReportModel::headerData (int section, Qt::Orientation orienta
|
||||||
{
|
{
|
||||||
case Column_Type: return "Type";
|
case Column_Type: return "Type";
|
||||||
case Column_Id: return "ID";
|
case Column_Id: return "ID";
|
||||||
case Column_Description: return "Description";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (section==mColumnDescription)
|
||||||
|
return "Description";
|
||||||
|
|
||||||
|
if (section==mColumnField)
|
||||||
|
return "Field";
|
||||||
|
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,20 @@ namespace CSMTools
|
||||||
|
|
||||||
std::vector<Line> mRows;
|
std::vector<Line> mRows;
|
||||||
|
|
||||||
|
// Fixed columns
|
||||||
enum Columns
|
enum Columns
|
||||||
{
|
{
|
||||||
Column_Type = 0, Column_Id = 1, Column_Hint = 2, Column_Description = 3
|
Column_Type = 0, Column_Id = 1, Column_Hint = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Configurable columns
|
||||||
|
int mColumnDescription;
|
||||||
|
int mColumnField;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
ReportModel (bool fieldColumn = false);
|
||||||
|
|
||||||
virtual int rowCount (const QModelIndex & parent = QModelIndex()) const;
|
virtual int rowCount (const QModelIndex & parent = QModelIndex()) const;
|
||||||
|
|
||||||
virtual int columnCount (const QModelIndex & parent = QModelIndex()) const;
|
virtual int columnCount (const QModelIndex & parent = QModelIndex()) const;
|
||||||
|
|
|
@ -27,7 +27,11 @@ void CSMTools::Search::searchTextCell (const CSMWorld::IdTableBase *model,
|
||||||
message << getLocation (model, index, id) << text.mid (pos).toUtf8().data();
|
message << getLocation (model, index, id) << text.mid (pos).toUtf8().data();
|
||||||
|
|
||||||
std::ostringstream hint;
|
std::ostringstream hint;
|
||||||
hint << "r: " << index.column() << " " << pos << " " << search.length();
|
hint
|
||||||
|
<< "r: "
|
||||||
|
<< model->getColumnId (index.column())
|
||||||
|
<< " " << pos
|
||||||
|
<< " " << search.length();
|
||||||
|
|
||||||
messages.add (id, message.str(), hint.str());
|
messages.add (id, message.str(), hint.str());
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ CSMWorld::UniversalId CSMTools::Tools::runVerifier()
|
||||||
|
|
||||||
CSMWorld::UniversalId CSMTools::Tools::newSearch()
|
CSMWorld::UniversalId CSMTools::Tools::newSearch()
|
||||||
{
|
{
|
||||||
mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel));
|
mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel (true)));
|
||||||
|
|
||||||
return CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Search, mNextReportNumber-1);
|
return CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Search, mNextReportNumber-1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue