update paged scene view according to changes made to cell records

This commit is contained in:
Marc Zinnschlag 2014-06-30 17:57:38 +02:00
parent 5fb2e1a877
commit a25321f07e
2 changed files with 43 additions and 3 deletions

View file

@ -129,11 +129,19 @@ void CSVRender::PagedWorldspaceWidget::referenceAdded (const QModelIndex& parent
flagAsModified(); flagAsModified();
} }
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document) CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document)
: WorldspaceWidget (document, parent), mDocument (document), mWorldspace ("std::default") : 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() CSVRender::PagedWorldspaceWidget::~PagedWorldspaceWidget()
{ {
@ -227,4 +235,27 @@ CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::g
default: default:
return ignored; 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();
} }

View file

@ -61,6 +61,15 @@ namespace CSVRender
signals: signals:
void cellSelectionChanged (const CSMWorld::CellSelection& selection); 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);
}; };
} }