From 302e2f8e9a7ad6d7deab6a0f66bb230677221a41 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 7 Jun 2014 14:32:12 +0200 Subject: [PATCH] fixed some proxy model problems related to column numbers --- apps/opencs/view/world/table.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 7599c8341b..217d52ec14 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -36,8 +36,10 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end(); ++iter) { - records.push_back (mProxyModel->data ( - mProxyModel->index (iter->row(), columnIndex)).toString().toUtf8().constData()); + int row = mProxyModel->mapToSource (mProxyModel->index (iter->row(), 0)).row(); + + records.push_back (mModel->data ( + mModel->index (row, columnIndex)).toString().toUtf8().constData()); } mDispatcher->setSelection (records); @@ -71,8 +73,6 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) /// \todo allow reordering of multiple rows if (selectedRows.size()==1) { - int row =selectedRows.begin()->row(); - int column = mModel->searchColumnIndex (CSMWorld::Columns::ColumnId_Topic); if (column==-1) @@ -80,14 +80,17 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) if (column!=-1) { - if (row>0 && mProxyModel->data (mProxyModel->index (row, column))== - mProxyModel->data (mProxyModel->index (row-1, column))) + int row = mProxyModel->mapToSource ( + mProxyModel->index (selectedRows.begin()->row(), 0)).row(); + + if (row>0 && mModel->data (mModel->index (row, column))== + mModel->data (mModel->index (row-1, column))) { menu.addAction (mMoveUpAction); } - if (rowrowCount()-1 && mProxyModel->data (mProxyModel->index (row, column))== - mProxyModel->data (mProxyModel->index (row+1, column))) + if (rowrowCount()-1 && mModel->data (mModel->index (row, column))== + mModel->data (mModel->index (row+1, column))) { menu.addAction (mMoveDownAction); } @@ -225,9 +228,11 @@ void CSVWorld::Table::setEditLock (bool locked) CSMWorld::UniversalId CSVWorld::Table::getUniversalId (int row) const { + row = mProxyModel->mapToSource (mProxyModel->index (row, 0)).row(); + return CSMWorld::UniversalId ( - static_cast (mProxyModel->data (mProxyModel->index (row, 2)).toInt()), - mProxyModel->data (mProxyModel->index (row, 0)).toString().toUtf8().constData()); + static_cast (mModel->data (mModel->index (row, 2)).toInt()), + mModel->data (mModel->index (row, 0)).toString().toUtf8().constData()); } void CSVWorld::Table::editRecord()