forked from mirror/openmw-tes3mp
small test with statics and two columns
This commit is contained in:
parent
02ace69511
commit
9426eda47a
8 changed files with 94 additions and 2 deletions
|
@ -23,7 +23,7 @@ opencs_units (model/world
|
|||
|
||||
opencs_units_noqt (model/world
|
||||
universalid data record idcollection commands columnbase scriptcontext cell refidcollection
|
||||
refidadapter refiddata
|
||||
refidadapter refiddata refidadapterimp
|
||||
)
|
||||
|
||||
opencs_hdrs_noqt (model/world
|
||||
|
|
|
@ -327,6 +327,8 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
|
|||
case ESM::REC_SPEL: mSpells.load (reader, base); break;
|
||||
case ESM::REC_CELL: mCells.load (reader, base); break;
|
||||
|
||||
case ESM::REC_STAT: mReferenceables.load (reader, base, UniversalId::Type_Static); break;
|
||||
|
||||
default:
|
||||
|
||||
/// \todo throw an exception instead, once all records are implemented
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef CSM_WOLRD_REDIDADAPTER_H
|
||||
#ifndef CSM_WOLRD_REFIDADAPTER_H
|
||||
#define CSM_WOLRD_REFIDADAPTER_H
|
||||
|
||||
#include <string>
|
||||
|
|
49
apps/opencs/model/world/refidadapterimp.cpp
Normal file
49
apps/opencs/model/world/refidadapterimp.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
#include "refidadapterimp.hpp"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include <components/esm/loadstat.hpp>
|
||||
|
||||
#include "record.hpp"
|
||||
#include "refiddata.hpp"
|
||||
#include "universalid.hpp"
|
||||
|
||||
CSMWorld::StaticRefIdAdapter::StaticRefIdAdapter (const RefIdColumn *id, const RefIdColumn *modified)
|
||||
: mId (id), mModified (modified)
|
||||
{}
|
||||
|
||||
QVariant CSMWorld::StaticRefIdAdapter::getData (const RefIdColumn *column, const RefIdData& data,
|
||||
int index) const
|
||||
{
|
||||
const Record<ESM::Static>& record = static_cast<const Record<ESM::Static>&> (
|
||||
data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Static)));
|
||||
|
||||
if (column==mId)
|
||||
return QString::fromUtf8 (record.get().mId.c_str());
|
||||
|
||||
if (column==mModified)
|
||||
{
|
||||
if (record.mState==Record<ESM::Static>::State_Erased)
|
||||
return static_cast<int> (Record<ESM::Static>::State_Deleted);
|
||||
|
||||
return static_cast<int> (record.mState);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void CSMWorld::StaticRefIdAdapter::setData (const RefIdColumn *column, RefIdData& data, int index,
|
||||
const QVariant& value) const
|
||||
{
|
||||
Record<ESM::Static>& record = static_cast<Record<ESM::Static>&> (
|
||||
data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Static)));
|
||||
|
||||
if (column==mModified)
|
||||
record.mState = static_cast<RecordBase::State> (value.toInt());
|
||||
}
|
||||
|
||||
std::string CSMWorld::StaticRefIdAdapter::getId (const RecordBase& record) const
|
||||
{
|
||||
return dynamic_cast<const Record<ESM::Static>&> (record).get().mId;
|
||||
}
|
28
apps/opencs/model/world/refidadapterimp.hpp
Normal file
28
apps/opencs/model/world/refidadapterimp.hpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef CSM_WOLRD_REFIDADAPTERIMP_H
|
||||
#define CSM_WOLRD_REFIDADAPTERIMP_H
|
||||
|
||||
#include "refidadapter.hpp"
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
class StaticRefIdAdapter : public RefIdAdapter
|
||||
{
|
||||
const RefIdColumn *mId;
|
||||
const RefIdColumn *mModified;
|
||||
|
||||
public:
|
||||
|
||||
StaticRefIdAdapter (const RefIdColumn *id, const RefIdColumn *modified);
|
||||
|
||||
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int idnex)
|
||||
const;
|
||||
|
||||
virtual void setData (const RefIdColumn *column, RefIdData& data, int index,
|
||||
const QVariant& value) const;
|
||||
///< If the data type does not match an exception is thrown.
|
||||
|
||||
virtual std::string getId (const RecordBase& record) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -129,6 +129,11 @@ void CSVDoc::View::setupWorldMenu()
|
|||
QAction *cells = new QAction (tr ("Cells"), this);
|
||||
connect (cells, SIGNAL (triggered()), this, SLOT (addCellsSubView()));
|
||||
world->addAction (cells);
|
||||
|
||||
QAction *referenceables = new QAction (tr ("Referenceables"), this);
|
||||
connect (referenceables, SIGNAL (triggered()), this, SLOT (addReferenceablesSubView()));
|
||||
world->addAction (referenceables);
|
||||
|
||||
}
|
||||
|
||||
void CSVDoc::View::setupUi()
|
||||
|
@ -334,6 +339,11 @@ void CSVDoc::View::addCellsSubView()
|
|||
addSubView (CSMWorld::UniversalId::Type_Cells);
|
||||
}
|
||||
|
||||
void CSVDoc::View::addReferenceablesSubView()
|
||||
{
|
||||
addSubView (CSMWorld::UniversalId::Type_Referenceables);
|
||||
}
|
||||
|
||||
void CSVDoc::View::abortOperation (int type)
|
||||
{
|
||||
mDocument->abortOperation (type);
|
||||
|
|
|
@ -135,6 +135,8 @@ namespace CSVDoc
|
|||
void addSpellsSubView();
|
||||
|
||||
void addCellsSubView();
|
||||
|
||||
void addReferenceablesSubView();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
|
|||
CSMWorld::UniversalId::Type_Birthsigns,
|
||||
CSMWorld::UniversalId::Type_Spells,
|
||||
CSMWorld::UniversalId::Type_Cells,
|
||||
CSMWorld::UniversalId::Type_Referenceables,
|
||||
|
||||
CSMWorld::UniversalId::Type_None // end marker
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue