From a25321f07ec3d005c4292976390c18ee2dda2cd3 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 30 Jun 2014 17:57:38 +0200 Subject: [PATCH] update paged scene view according to changes made to cell records --- .../view/render/pagedworldspacewidget.cpp | 37 +++++++++++++++++-- .../view/render/pagedworldspacewidget.hpp | 9 +++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index ca47621c6..1ee32fa97 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -129,11 +129,19 @@ void CSVRender::PagedWorldspaceWidget::referenceAdded (const QModelIndex& parent flagAsModified(); } - - CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document) : WorldspaceWidget (document, parent), mDocument (document), mWorldspace ("std::default") -{} +{ + QAbstractItemModel *cells = + document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells); + + connect (cells, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), + this, SLOT (cellDataChanged (const QModelIndex&, const QModelIndex&))); + connect (cells, SIGNAL (rowsRemoved (const QModelIndex&, int, int)), + this, SLOT (cellRemoved (const QModelIndex&, int, int))); + connect (cells, SIGNAL (rowsInserted (const QModelIndex&, int, int)), + this, SLOT (cellAdded (const QModelIndex&, int, int))); +} CSVRender::PagedWorldspaceWidget::~PagedWorldspaceWidget() { @@ -227,4 +235,27 @@ CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::g default: return ignored; } +} + +void CSVRender::PagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft, + const QModelIndex& bottomRight) +{ + /// \todo check if no selected cell is affected and do not update, if that is the case + if (adjustCells()) + flagAsModified(); +} + +void CSVRender::PagedWorldspaceWidget::cellRemoved (const QModelIndex& parent, int start, + int end) +{ + if (adjustCells()) + flagAsModified(); +} + +void CSVRender::PagedWorldspaceWidget::cellAdded (const QModelIndex& index, int start, + int end) +{ + /// \todo check if no selected cell is affected and do not update, if that is the case + if (adjustCells()) + flagAsModified(); } \ No newline at end of file diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index bf6d480ca..c4fb789ee 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -61,6 +61,15 @@ namespace CSVRender signals: void cellSelectionChanged (const CSMWorld::CellSelection& selection); + + private slots: + + virtual void cellDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight); + + virtual void cellRemoved (const QModelIndex& parent, int start, int end); + + virtual void cellAdded (const QModelIndex& index, int start, int end); + }; }