forked from mirror/openmw-tes3mp
changed data structure for report model
This commit is contained in:
parent
1ec0db231c
commit
4042b12013
2 changed files with 24 additions and 8 deletions
|
@ -3,6 +3,12 @@
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
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
|
int CSMTools::ReportModel::rowCount (const QModelIndex & parent) const
|
||||||
{
|
{
|
||||||
if (parent.isValid())
|
if (parent.isValid())
|
||||||
|
@ -25,12 +31,12 @@ QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if (index.column()==0)
|
if (index.column()==0)
|
||||||
return static_cast<int> (mRows.at (index.row()).first.getType());
|
return static_cast<int> (mRows.at (index.row()).mId.getType());
|
||||||
|
|
||||||
if (index.column()==1)
|
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
|
QVariant CSMTools::ReportModel::headerData (int section, Qt::Orientation orientation, int role) const
|
||||||
|
@ -65,19 +71,19 @@ void CSMTools::ReportModel::add (const CSMWorld::UniversalId& id, const std::str
|
||||||
{
|
{
|
||||||
beginInsertRows (QModelIndex(), mRows.size(), mRows.size());
|
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();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSMWorld::UniversalId& CSMTools::ReportModel::getUniversalId (int row) const
|
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
|
std::string CSMTools::ReportModel::getHint (int row) const
|
||||||
{
|
{
|
||||||
return mRows.at (row).second.second;
|
return mRows.at (row).mHint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMTools::ReportModel::clear()
|
void CSMTools::ReportModel::clear()
|
||||||
|
|
|
@ -14,7 +14,17 @@ namespace CSMTools
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
std::vector<std::pair<CSMWorld::UniversalId, std::pair<std::string, std::string> > > 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<Line> mRows;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue