diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index f58d77c90..5abf4ea8b 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -1,7 +1,7 @@ #ifndef CSM_WOLRD_COLUMNS_H #define CSM_WOLRD_COLUMNS_H -#include "idcollection.hpp" +#include "columnbase.hpp" namespace CSMWorld { diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 0da0cba83..a3522503e 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -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); @@ -17,16 +27,13 @@ CSMWorld::Data::Data() mGlobals.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Global)); mGlobals.addColumn (new FloatValueColumn); - 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::iterator iter (mModels.begin()); iter!=mModels.end(); ++iter) - delete iter->second; + for (std::vector::iterator iter (mModels.begin()); iter!=mModels.end(); ++iter) + delete *iter; } const CSMWorld::IdCollection& CSMWorld::Data::getGlobals() const @@ -41,9 +48,9 @@ CSMWorld::IdCollection& CSMWorld::Data::getGlobals() QAbstractTableModel *CSMWorld::Data::getTableModel (const UniversalId& id) { - std::map::iterator iter = mModels.find (id); + std::map::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; diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index a8a21e205..f7748cb5d 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -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 +#include #include @@ -15,12 +16,16 @@ namespace CSMWorld class Data { IdCollection mGlobals; - std::map mModels; + std::vector mModels; + std::map 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& 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. diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index e2d16f1e3..354223757 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -1,11 +1,37 @@ #include "dialoguesubview.hpp" +#include +#include +#include + +#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; iheaderData (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)