forked from teamnwah/openmw-tes3coop
Add pathgrid modified signals.
This commit is contained in:
parent
933504dbd0
commit
7fbcc47b15
8 changed files with 255 additions and 1 deletions
|
@ -254,6 +254,26 @@ bool CSVRender::Cell::referenceAdded (const QModelIndex& parent, int start, int
|
|||
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)
|
||||
{
|
||||
if (elementMask & Mask_Reference)
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace CSMWorld
|
|||
{
|
||||
class Data;
|
||||
class CellCoordinates;
|
||||
class Pathgrid;
|
||||
}
|
||||
|
||||
namespace CSVRender
|
||||
|
@ -103,6 +104,16 @@ namespace CSVRender
|
|||
/// this cell?
|
||||
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);
|
||||
|
||||
// Select everything that references the same ID as at least one of the elements
|
||||
|
|
|
@ -275,6 +275,107 @@ void CSVRender::PagedWorldspaceWidget::referenceAdded (const QModelIndex& parent
|
|||
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()
|
||||
{
|
||||
osg::Vec3d eye, center, up;
|
||||
|
|
|
@ -52,6 +52,14 @@ namespace CSVRender
|
|||
|
||||
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();
|
||||
|
||||
/// \note Does not update the view or any cell marker
|
||||
|
|
|
@ -32,7 +32,7 @@ void CSVRender::UnpagedWorldspaceWidget::update()
|
|||
}
|
||||
|
||||
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&> (
|
||||
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells));
|
||||
|
@ -197,6 +197,90 @@ void CSVRender::UnpagedWorldspaceWidget::referenceAdded (const QModelIndex& pare
|
|||
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 (
|
||||
CSVWidget::SceneToolToggle2 *tool)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace CSVRender
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
CSMDoc::Document& mDocument;
|
||||
std::string mCellId;
|
||||
CSMWorld::IdTable *mCellsModel;
|
||||
CSMWorld::IdTable *mReferenceablesModel;
|
||||
|
@ -83,6 +84,15 @@ namespace CSVRender
|
|||
|
||||
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();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -59,6 +59,17 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg
|
|||
connect (references, SIGNAL (rowsInserted (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 =
|
||||
document.getData().getTableModel (CSMWorld::UniversalId::Type_DebugProfiles);
|
||||
|
||||
|
|
|
@ -228,6 +228,15 @@ namespace CSVRender
|
|||
|
||||
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);
|
||||
|
||||
void debugProfileDataChanged (const QModelIndex& topLeft,
|
||||
|
|
Loading…
Reference in a new issue