mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +00:00
partial dialogue subview implementation
This commit is contained in:
parent
92623921ad
commit
714b1924a5
4 changed files with 54 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
|||
#ifndef CSM_WOLRD_COLUMNS_H
|
||||
#define CSM_WOLRD_COLUMNS_H
|
||||
|
||||
#include "idcollection.hpp"
|
||||
#include "columnbase.hpp"
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
|
|
|
@ -10,6 +10,16 @@
|
|||
#include "idtable.hpp"
|
||||
#include "columns.hpp"
|
||||
|
||||
void CSMWorld::Data::addModel (QAbstractTableModel *model, UniversalId::Type type1,
|
||||
UniversalId::Type type2)
|
||||
{
|
||||
mModels.push_back (model);
|
||||
mModelIndex.insert (std::make_pair (type1, model));
|
||||
|
||||
if (type2!=UniversalId::Type_None)
|
||||
mModelIndex.insert (std::make_pair (type2, model));
|
||||
}
|
||||
|
||||
CSMWorld::Data::Data()
|
||||
{
|
||||
mGlobals.addColumn (new StringIdColumn<ESM::Global>);
|
||||
|
@ -17,16 +27,13 @@ CSMWorld::Data::Data()
|
|||
mGlobals.addColumn (new FixedRecordTypeColumn<ESM::Global> (UniversalId::Type_Global));
|
||||
mGlobals.addColumn (new FloatValueColumn<ESM::Global>);
|
||||
|
||||
mModels.insert (std::make_pair (
|
||||
UniversalId (UniversalId::Type_Globals),
|
||||
new IdTable (&mGlobals)
|
||||
));
|
||||
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
||||
}
|
||||
|
||||
CSMWorld::Data::~Data()
|
||||
{
|
||||
for (std::map<UniversalId, QAbstractTableModel *>::iterator iter (mModels.begin()); iter!=mModels.end(); ++iter)
|
||||
delete iter->second;
|
||||
for (std::vector<QAbstractTableModel *>::iterator iter (mModels.begin()); iter!=mModels.end(); ++iter)
|
||||
delete *iter;
|
||||
}
|
||||
|
||||
const CSMWorld::IdCollection<ESM::Global>& CSMWorld::Data::getGlobals() const
|
||||
|
@ -41,9 +48,9 @@ CSMWorld::IdCollection<ESM::Global>& CSMWorld::Data::getGlobals()
|
|||
|
||||
QAbstractTableModel *CSMWorld::Data::getTableModel (const UniversalId& id)
|
||||
{
|
||||
std::map<UniversalId, QAbstractTableModel *>::iterator iter = mModels.find (id);
|
||||
std::map<UniversalId::Type, QAbstractTableModel *>::iterator iter = mModelIndex.find (id.getType());
|
||||
|
||||
if (iter==mModels.end())
|
||||
if (iter==mModelIndex.end())
|
||||
throw std::logic_error ("No table model available for " + id.toString());
|
||||
|
||||
return iter->second;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#ifndef CSM_WOLRD_IDLIST_H
|
||||
#define CSM_WOLRD_IDLIST_H
|
||||
#ifndef CSM_WOLRD_DATA_H
|
||||
#define CSM_WOLRD_DATA_H
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <components/esm/loadglob.hpp>
|
||||
|
||||
|
@ -15,12 +16,16 @@ namespace CSMWorld
|
|||
class Data
|
||||
{
|
||||
IdCollection<ESM::Global> mGlobals;
|
||||
std::map<UniversalId, QAbstractTableModel *> mModels;
|
||||
std::vector<QAbstractTableModel *> mModels;
|
||||
std::map<UniversalId::Type, QAbstractTableModel *> mModelIndex;
|
||||
|
||||
// not implemented
|
||||
Data (const Data&);
|
||||
Data& operator= (const Data&);
|
||||
|
||||
void addModel (QAbstractTableModel *model, UniversalId::Type type1,
|
||||
UniversalId::Type type2 = UniversalId::Type_None);
|
||||
|
||||
public:
|
||||
|
||||
Data();
|
||||
|
@ -32,7 +37,10 @@ namespace CSMWorld
|
|||
IdCollection<ESM::Global>& getGlobals();
|
||||
|
||||
QAbstractTableModel *getTableModel (const UniversalId& id);
|
||||
///< If no table model is available for \æ id, an exception is thrown.
|
||||
///< If no table model is available for \a id, an exception is thrown.
|
||||
///
|
||||
/// \note The returned table may either be the model for the ID itself or the model that
|
||||
/// contains the record specified by the ID.
|
||||
|
||||
void merge();
|
||||
///< Merge modified into base.
|
||||
|
|
|
@ -1,11 +1,37 @@
|
|||
|
||||
#include "dialoguesubview.hpp"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
#include "../../model/world/columnbase.hpp"
|
||||
|
||||
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
||||
bool createAndDelete)
|
||||
: SubView (id)
|
||||
{
|
||||
QWidget *widget = new QWidget (this);
|
||||
|
||||
setWidget (widget);
|
||||
|
||||
QGridLayout *layout = new QGridLayout;
|
||||
|
||||
widget->setLayout (layout);
|
||||
|
||||
QAbstractTableModel *model = document.getData().getTableModel (id);
|
||||
|
||||
int columns = model->columnCount();
|
||||
|
||||
for (int i=0; i<columns; ++i)
|
||||
{
|
||||
int flags = model->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt();
|
||||
|
||||
if (flags & CSMWorld::ColumnBase::Flag_Dialogue)
|
||||
{
|
||||
layout->addWidget (new QLabel (model->headerData (i, Qt::Horizontal).toString()), i, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
||||
|
|
Loading…
Reference in a new issue