1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-25 03:40:40 +00:00

Add pathgrid modified signals.

This commit is contained in:
Aesylwinn 2016-05-02 22:08:49 -04:00
parent 933504dbd0
commit 7fbcc47b15
8 changed files with 255 additions and 1 deletions

View File

@ -254,6 +254,26 @@ bool CSVRender::Cell::referenceAdded (const QModelIndex& parent, int start, int
return addObjects (start, end); return addObjects (start, end);
} }
void CSVRender::Cell::pathgridAdded(const CSMWorld::Pathgrid& pathgrid)
{
}
void CSVRender::Cell::pathgridRemoved()
{
}
void CSVRender::Cell::pathgridDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
{
}
void CSVRender::Cell::pathgridRowRemoved(const QModelIndex& parent, int start, int end)
{
}
void CSVRender::Cell::pathgridRowAdded(const QModelIndex& parent, int start, int end)
{
}
void CSVRender::Cell::setSelection (int elementMask, Selection mode) void CSVRender::Cell::setSelection (int elementMask, Selection mode)
{ {
if (elementMask & Mask_Reference) if (elementMask & Mask_Reference)

View File

@ -29,6 +29,7 @@ namespace CSMWorld
{ {
class Data; class Data;
class CellCoordinates; class CellCoordinates;
class Pathgrid;
} }
namespace CSVRender namespace CSVRender
@ -103,6 +104,16 @@ namespace CSVRender
/// this cell? /// this cell?
bool referenceAdded (const QModelIndex& parent, int start, int end); bool referenceAdded (const QModelIndex& parent, int start, int end);
void pathgridAdded(const CSMWorld::Pathgrid& pathgrid);
void pathgridRemoved();
void pathgridDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
void pathgridRowRemoved(const QModelIndex& parent, int start, int end);
void pathgridRowAdded(const QModelIndex& parent, int start, int end);
void setSelection (int elementMask, Selection mode); void setSelection (int elementMask, Selection mode);
// Select everything that references the same ID as at least one of the elements // Select everything that references the same ID as at least one of the elements

View File

@ -275,6 +275,107 @@ void CSVRender::PagedWorldspaceWidget::referenceAdded (const QModelIndex& parent
flagAsModified(); flagAsModified();
} }
void CSVRender::PagedWorldspaceWidget::pathgridDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
{
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mDocument.getData().getPathgrids();
if (topLeft.parent().isValid())
{
int row = topLeft.parent().row();
const CSMWorld::Pathgrid& pathgrid = pathgrids.getRecord(row).get();
CSMWorld::CellCoordinates coords = CSMWorld::CellCoordinates(pathgrid.mData.mX, pathgrid.mData.mY);
std::map<CSMWorld::CellCoordinates, Cell*>::iterator searchResult = mCells.find(coords);
if (searchResult != mCells.end())
{
searchResult->second->pathgridDataChanged(topLeft, bottomRight);
flagAsModified();
}
}
}
void CSVRender::PagedWorldspaceWidget::pathgridRemoved (const QModelIndex& parent, int start, int end)
{
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mDocument.getData().getPathgrids();
if (parent.isValid())
{
// Pathgrid data was modified
int row = parent.row();
const CSMWorld::Pathgrid& pathgrid = pathgrids.getRecord(row).get();
CSMWorld::CellCoordinates coords = CSMWorld::CellCoordinates(pathgrid.mData.mX, pathgrid.mData.mY);
std::map<CSMWorld::CellCoordinates, Cell*>::iterator searchResult = mCells.find(coords);
if (searchResult != mCells.end())
{
searchResult->second->pathgridRowRemoved(parent, start, end);
flagAsModified();
}
}
}
void CSVRender::PagedWorldspaceWidget::pathgridAboutToBeRemoved (const QModelIndex& parent, int start, int end)
{
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mDocument.getData().getPathgrids();
if (!parent.isValid())
{
// Pathgrid going to be deleted
for (int row = start; row <= end; ++row)
{
const CSMWorld::Pathgrid& pathgrid = pathgrids.getRecord(row).get();
CSMWorld::CellCoordinates coords = CSMWorld::CellCoordinates(pathgrid.mData.mX, pathgrid.mData.mY);
std::map<CSMWorld::CellCoordinates, Cell*>::iterator searchResult = mCells.find(coords);
if (searchResult != mCells.end())
{
searchResult->second->pathgridRemoved();
flagAsModified();
}
}
}
}
void CSVRender::PagedWorldspaceWidget::pathgridAdded(const QModelIndex& parent, int start, int end)
{
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mDocument.getData().getPathgrids();
if (!parent.isValid())
{
// Pathgrid added theoretically, unable to test until it is possible to add pathgrids
for (int row = start; row <= end; ++row)
{
const CSMWorld::Pathgrid& pathgrid = pathgrids.getRecord(row).get();
CSMWorld::CellCoordinates coords = CSMWorld::CellCoordinates(pathgrid.mData.mX, pathgrid.mData.mY);
std::map<CSMWorld::CellCoordinates, Cell*>::iterator searchResult = mCells.find(coords);
if (searchResult != mCells.end())
{
searchResult->second->pathgridAdded(pathgrid);
flagAsModified();
}
}
}
else
{
// Pathgrid data was modified
int row = parent.row();
const CSMWorld::Pathgrid& pathgrid = pathgrids.getRecord(row).get();
CSMWorld::CellCoordinates coords = CSMWorld::CellCoordinates(pathgrid.mData.mX, pathgrid.mData.mY);
std::map<CSMWorld::CellCoordinates, Cell*>::iterator searchResult = mCells.find(coords);
if (searchResult != mCells.end())
{
searchResult->second->pathgridRowAdded(parent, start, end);
flagAsModified();
}
}
}
std::string CSVRender::PagedWorldspaceWidget::getStartupInstruction() std::string CSVRender::PagedWorldspaceWidget::getStartupInstruction()
{ {
osg::Vec3d eye, center, up; osg::Vec3d eye, center, up;

View File

@ -52,6 +52,14 @@ namespace CSVRender
virtual void referenceAdded (const QModelIndex& index, int start, int end); virtual void referenceAdded (const QModelIndex& index, int start, int end);
virtual void pathgridDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
virtual void pathgridRemoved (const QModelIndex& parent, int start, int end);
virtual void pathgridAboutToBeRemoved (const QModelIndex& parent, int start, int end);
virtual void pathgridAdded (const QModelIndex& parent, int start, int end);
virtual std::string getStartupInstruction(); virtual std::string getStartupInstruction();
/// \note Does not update the view or any cell marker /// \note Does not update the view or any cell marker

View File

@ -32,7 +32,7 @@ void CSVRender::UnpagedWorldspaceWidget::update()
} }
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, QWidget* parent) CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, QWidget* parent)
: WorldspaceWidget (document, parent), mCellId (cellId) : WorldspaceWidget (document, parent), mDocument(document), mCellId (cellId)
{ {
mCellsModel = &dynamic_cast<CSMWorld::IdTable&> ( mCellsModel = &dynamic_cast<CSMWorld::IdTable&> (
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells)); *document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells));
@ -197,6 +197,90 @@ void CSVRender::UnpagedWorldspaceWidget::referenceAdded (const QModelIndex& pare
flagAsModified(); flagAsModified();
} }
void CSVRender::UnpagedWorldspaceWidget::pathgridDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
{
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mDocument.getData().getPathgrids();
if (topLeft.parent().isValid())
{
int row = topLeft.parent().row();
const CSMWorld::Pathgrid& pathgrid = pathgrids.getRecord(row).get();
if (mCellId == pathgrid.mId)
{
mCell->pathgridDataChanged(topLeft, bottomRight);
flagAsModified();
}
}
}
void CSVRender::UnpagedWorldspaceWidget::pathgridRemoved (const QModelIndex& parent, int start, int end)
{
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mDocument.getData().getPathgrids();
if (parent.isValid()){
// Pathgrid data was modified
int row = parent.row();
const CSMWorld::Pathgrid& pathgrid = pathgrids.getRecord(row).get();
if (mCellId == pathgrid.mId)
{
mCell->pathgridRowRemoved(parent, start, end);
flagAsModified();
}
}
}
void CSVRender::UnpagedWorldspaceWidget::pathgridAboutToBeRemoved (const QModelIndex& parent, int start, int end)
{
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mDocument.getData().getPathgrids();
if (!parent.isValid())
{
// Pathgrid going to be deleted
for (int row = start; row <= end; ++row)
{
const CSMWorld::Pathgrid& pathgrid = pathgrids.getRecord(row).get();
if (mCellId == pathgrid.mId)
{
mCell->pathgridRemoved();
flagAsModified();
}
}
}
}
void CSVRender::UnpagedWorldspaceWidget::pathgridAdded (const QModelIndex& parent, int start, int end)
{
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mDocument.getData().getPathgrids();
if (!parent.isValid())
{
// Pathgrid added theoretically, unable to test until it is possible to add pathgrids
for (int row = start; row <= end; ++row)
{
const CSMWorld::Pathgrid& pathgrid = pathgrids.getRecord(row).get();
if (mCellId == pathgrid.mId)
{
mCell->pathgridAdded(pathgrid);
flagAsModified();
}
}
}
else
{
// Pathgrid data was modified
int row = parent.row();
const CSMWorld::Pathgrid& pathgrid = pathgrids.getRecord(row).get();
if (mCellId == pathgrid.mId)
{
mCell->pathgridRowAdded(parent, start, end);
flagAsModified();
}
}
}
void CSVRender::UnpagedWorldspaceWidget::addVisibilitySelectorButtons ( void CSVRender::UnpagedWorldspaceWidget::addVisibilitySelectorButtons (
CSVWidget::SceneToolToggle2 *tool) CSVWidget::SceneToolToggle2 *tool)
{ {

View File

@ -25,6 +25,7 @@ namespace CSVRender
{ {
Q_OBJECT Q_OBJECT
CSMDoc::Document& mDocument;
std::string mCellId; std::string mCellId;
CSMWorld::IdTable *mCellsModel; CSMWorld::IdTable *mCellsModel;
CSMWorld::IdTable *mReferenceablesModel; CSMWorld::IdTable *mReferenceablesModel;
@ -83,6 +84,15 @@ namespace CSVRender
virtual void referenceAdded (const QModelIndex& index, int start, int end); virtual void referenceAdded (const QModelIndex& index, int start, int end);
virtual void pathgridDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
virtual void pathgridRemoved (const QModelIndex& parent, int start, int end);
virtual void pathgridAboutToBeRemoved (const QModelIndex& parent, int start, int end);
virtual void pathgridAdded (const QModelIndex& parent, int start, int end);
virtual std::string getStartupInstruction(); virtual std::string getStartupInstruction();
protected: protected:

View File

@ -59,6 +59,17 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg
connect (references, SIGNAL (rowsInserted (const QModelIndex&, int, int)), connect (references, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
this, SLOT (referenceAdded (const QModelIndex&, int, int))); this, SLOT (referenceAdded (const QModelIndex&, int, int)));
QAbstractItemModel *pathgrids = document.getData().getTableModel (CSMWorld::UniversalId::Type_Pathgrids);
connect (pathgrids, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
this, SLOT (pathgridDataChanged (const QModelIndex&, const QModelIndex&)));
connect (pathgrids, SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
this, SLOT (pathgridRemoved (const QModelIndex&, int, int)));
connect (pathgrids, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
this, SLOT (pathgridAboutToBeRemoved (const QModelIndex&, int, int)));
connect (pathgrids, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
this, SLOT (pathgridAdded (const QModelIndex&, int, int)));
QAbstractItemModel *debugProfiles = QAbstractItemModel *debugProfiles =
document.getData().getTableModel (CSMWorld::UniversalId::Type_DebugProfiles); document.getData().getTableModel (CSMWorld::UniversalId::Type_DebugProfiles);

View File

@ -228,6 +228,15 @@ namespace CSVRender
virtual void referenceAdded (const QModelIndex& index, int start, int end) = 0; virtual void referenceAdded (const QModelIndex& index, int start, int end) = 0;
virtual void pathgridDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) = 0;
virtual void pathgridRemoved (const QModelIndex& parent, int start, int end) = 0;
virtual void pathgridAboutToBeRemoved (const QModelIndex& parent, int start, int end) = 0;
virtual void pathgridAdded (const QModelIndex& parent, int start, int end) = 0;
virtual void runRequest (const std::string& profile); virtual void runRequest (const std::string& profile);
void debugProfileDataChanged (const QModelIndex& topLeft, void debugProfileDataChanged (const QModelIndex& topLeft,