diff --git a/apps/opencs/model/world/nestedtablemodel.cpp b/apps/opencs/model/world/nestedtablemodel.cpp index 9a685557e..9ae4bdfd3 100644 --- a/apps/opencs/model/world/nestedtablemodel.cpp +++ b/apps/opencs/model/world/nestedtablemodel.cpp @@ -9,8 +9,12 @@ CSMWorld::NestedTableModel::NestedTableModel(const QModelIndex& parent, : mParentColumn(parent.column()) { const int parentRow = parent.row(); + mId = std::string(parentModel->index(parentRow, 0).data().toString().toUtf8()); + QAbstractProxyModel::setSourceModel(parentModel); + + setupHeaderVectors(columnId); } QModelIndex CSMWorld::NestedTableModel::mapFromSource(const QModelIndex& sourceIndex) const @@ -58,8 +62,8 @@ QModelIndex CSMWorld::NestedTableModel::index(int row, int column, const QModelI CSMWorld::IdTable* table = dynamic_cast(sourceModel()); - unsigned rows = table->rowCount(parent); - usigned columns = table->columnCount(parent); + int rows = table->rowCount(parent); + int columns = table->columnCount(parent); if (row < 0 || row >= rows || @@ -76,3 +80,39 @@ QModelIndex CSMWorld::NestedTableModel::parent(const QModelIndex& index) const { return QModelIndex(); } + +QVariant CSMWorld::NestedTableModel::headerData(int section, + Qt::Orientation orientation, + int role) const +{ + if (orientation==Qt::Vertical) + return QVariant(); + + if (role==Qt::DisplayRole) + return tr (mHeaderTitle[section].c_str()); + + if (role==ColumnBase::Role_Flags) + return QVariant(); //TODO + + if (role==ColumnBase::Role_Display) + return mHeaderDisplay[section]; + + return QVariant(); +} + +void CSMWorld::NestedTableModel::setupHeaderVectors(ColumnBase::Display columnId) +{ + switch(columnId) + { + case ColumnBase::Display_NestedItemList: + mHeaderTitle.push_back("test1"); + mHeaderTitle.push_back("test2"); + + mHeaderDisplay.push_back(ColumnBase::Display_String); + mHeaderDisplay.push_back(ColumnBase::Display_Integer); + break; + + default: + assert(false); + } +} diff --git a/apps/opencs/model/world/nestedtablemodel.hpp b/apps/opencs/model/world/nestedtablemodel.hpp index be29be2ca..80c7f5a8e 100644 --- a/apps/opencs/model/world/nestedtablemodel.hpp +++ b/apps/opencs/model/world/nestedtablemodel.hpp @@ -43,6 +43,11 @@ namespace CSMWorld virtual QModelIndex index(int row, int column, const QModelIndex& parent) const; virtual QModelIndex parent(const QModelIndex& index) const; + + virtual QVariant headerData ( int section, Qt::Orientation orientation, int role ) const; + + private: + void setupHeaderVectors(ColumnBase::Display columnId); }; } diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 7a0e2efec..109f0c3fa 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -393,7 +393,7 @@ void CSVWorld::EditWidget::remake(int row) int locked = 0; const int columns = mTable->columnCount(); - for (unsigned i=0; iheaderData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt();