mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:53:50 +00:00
generalising and cleaning up drop implementation of worldspace widget
This commit is contained in:
parent
5a9376450b
commit
0db288ce07
7 changed files with 56 additions and 9 deletions
|
@ -220,8 +220,15 @@ std::pair< int, int > CSVRender::PagedWorldspaceWidget::getCoordinatesFromId (co
|
||||||
return std::make_pair(x, y);
|
return std::make_pair(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::PagedWorldspaceWidget::handleDrop (const std::vector< CSMWorld::UniversalId >& data)
|
bool CSVRender::PagedWorldspaceWidget::handleDrop (
|
||||||
|
const std::vector< CSMWorld::UniversalId >& data, DropType type)
|
||||||
{
|
{
|
||||||
|
if (WorldspaceWidget::handleDrop (data, type))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (type!=Type_CellsExterior)
|
||||||
|
return false;
|
||||||
|
|
||||||
bool selectionChanged = false;
|
bool selectionChanged = false;
|
||||||
for (unsigned i = 0; i < data.size(); ++i)
|
for (unsigned i = 0; i < data.size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -238,10 +245,17 @@ void CSVRender::PagedWorldspaceWidget::handleDrop (const std::vector< CSMWorld::
|
||||||
|
|
||||||
emit cellSelectionChanged(mSelection);
|
emit cellSelectionChanged(mSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::DropType type) const
|
CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::DropType type) const
|
||||||
{
|
{
|
||||||
|
dropRequirments requirements = WorldspaceWidget::getDropRequirements (type);
|
||||||
|
|
||||||
|
if (requirements!=ignored)
|
||||||
|
return requirements;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case Type_CellsExterior:
|
case Type_CellsExterior:
|
||||||
|
|
|
@ -57,7 +57,9 @@ namespace CSVRender
|
||||||
|
|
||||||
void setCellSelection (const CSMWorld::CellSelection& selection);
|
void setCellSelection (const CSMWorld::CellSelection& selection);
|
||||||
|
|
||||||
virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data);
|
/// \return Drop handled?
|
||||||
|
virtual bool handleDrop (const std::vector<CSMWorld::UniversalId>& data,
|
||||||
|
DropType type);
|
||||||
|
|
||||||
virtual dropRequirments getDropRequirements(DropType type) const;
|
virtual dropRequirments getDropRequirements(DropType type) const;
|
||||||
|
|
||||||
|
|
|
@ -89,13 +89,21 @@ void CSVRender::UnpagedWorldspaceWidget::cellRowsAboutToBeRemoved (const QModelI
|
||||||
emit closeRequest();
|
emit closeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vector< CSMWorld::UniversalId >& data)
|
bool CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vector<CSMWorld::UniversalId>& data, DropType type)
|
||||||
{
|
{
|
||||||
|
if (WorldspaceWidget::handleDrop (data, type))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (type!=Type_CellsInterior)
|
||||||
|
return false;
|
||||||
|
|
||||||
mCellId = data.begin()->getId();
|
mCellId = data.begin()->getId();
|
||||||
update();
|
update();
|
||||||
emit cellChanged(*data.begin());
|
emit cellChanged(*data.begin());
|
||||||
|
|
||||||
/// \todo replace mCell
|
/// \todo replace mCell
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::UnpagedWorldspaceWidget::referenceableDataChanged (const QModelIndex& topLeft,
|
void CSVRender::UnpagedWorldspaceWidget::referenceableDataChanged (const QModelIndex& topLeft,
|
||||||
|
@ -168,6 +176,11 @@ std::string CSVRender::UnpagedWorldspaceWidget::getStartupInstruction()
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::DropType type) const
|
CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::DropType type) const
|
||||||
{
|
{
|
||||||
|
dropRequirments requirements = WorldspaceWidget::getDropRequirements (type);
|
||||||
|
|
||||||
|
if (requirements!=ignored)
|
||||||
|
return requirements;
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case Type_CellsInterior:
|
case Type_CellsInterior:
|
||||||
|
|
|
@ -43,7 +43,9 @@ namespace CSVRender
|
||||||
|
|
||||||
virtual dropRequirments getDropRequirements(DropType type) const;
|
virtual dropRequirments getDropRequirements(DropType type) const;
|
||||||
|
|
||||||
virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data);
|
/// \return Drop handled?
|
||||||
|
virtual bool handleDrop (const std::vector<CSMWorld::UniversalId>& data,
|
||||||
|
DropType type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,18 @@ CSVRender::WorldspaceWidget::DropType CSVRender::WorldspaceWidget::getDropType (
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSVRender::WorldspaceWidget::dropRequirments
|
||||||
|
CSVRender::WorldspaceWidget::getDropRequirements (DropType type) const
|
||||||
|
{
|
||||||
|
return ignored;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSVRender::WorldspaceWidget::handleDrop (const std::vector<CSMWorld::UniversalId>& data,
|
||||||
|
DropType type)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int CSVRender::WorldspaceWidget::getElementMask() const
|
unsigned int CSVRender::WorldspaceWidget::getElementMask() const
|
||||||
{
|
{
|
||||||
return mSceneElements->getSelection();
|
return mSceneElements->getSelection();
|
||||||
|
|
|
@ -70,12 +70,14 @@ namespace CSVRender
|
||||||
|
|
||||||
static DropType getDropType(const std::vector<CSMWorld::UniversalId>& data);
|
static DropType getDropType(const std::vector<CSMWorld::UniversalId>& data);
|
||||||
|
|
||||||
virtual dropRequirments getDropRequirements(DropType type) const = 0;
|
virtual dropRequirments getDropRequirements(DropType type) const;
|
||||||
|
|
||||||
virtual void useViewHint (const std::string& hint);
|
virtual void useViewHint (const std::string& hint);
|
||||||
///< Default-implementation: ignored.
|
///< Default-implementation: ignored.
|
||||||
|
|
||||||
virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data) = 0;
|
/// \return Drop handled?
|
||||||
|
virtual bool handleDrop (const std::vector<CSMWorld::UniversalId>& data,
|
||||||
|
DropType type);
|
||||||
|
|
||||||
virtual unsigned int getElementMask() const;
|
virtual unsigned int getElementMask() const;
|
||||||
|
|
||||||
|
|
|
@ -198,10 +198,12 @@ void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalI
|
||||||
CSVRender::UnpagedWorldspaceWidget* unPagedNewWidget = NULL;
|
CSVRender::UnpagedWorldspaceWidget* unPagedNewWidget = NULL;
|
||||||
CSVWidget::SceneToolbar* toolbar = NULL;
|
CSVWidget::SceneToolbar* toolbar = NULL;
|
||||||
|
|
||||||
switch (mScene->getDropRequirements(CSVRender::WorldspaceWidget::getDropType(data)))
|
CSVRender::WorldspaceWidget::DropType type = CSVRender::WorldspaceWidget::getDropType (data);
|
||||||
|
|
||||||
|
switch (mScene->getDropRequirements (type))
|
||||||
{
|
{
|
||||||
case CSVRender::WorldspaceWidget::canHandle:
|
case CSVRender::WorldspaceWidget::canHandle:
|
||||||
mScene->handleDrop(data);
|
mScene->handleDrop (data, type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CSVRender::WorldspaceWidget::needPaged:
|
case CSVRender::WorldspaceWidget::needPaged:
|
||||||
|
@ -209,7 +211,7 @@ void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalI
|
||||||
toolbar = makeToolbar(pagedNewWidget, widget_Paged);
|
toolbar = makeToolbar(pagedNewWidget, widget_Paged);
|
||||||
makeConnections(pagedNewWidget);
|
makeConnections(pagedNewWidget);
|
||||||
replaceToolbarAndWorldspace(pagedNewWidget, toolbar);
|
replaceToolbarAndWorldspace(pagedNewWidget, toolbar);
|
||||||
mScene->handleDrop(data);
|
mScene->handleDrop (data, type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CSVRender::WorldspaceWidget::needUnpaged:
|
case CSVRender::WorldspaceWidget::needUnpaged:
|
||||||
|
|
Loading…
Reference in a new issue