forked from teamnwah/openmw-tes3coop
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);
|
||||
}
|
||||
|
||||
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;
|
||||
for (unsigned i = 0; i < data.size(); ++i)
|
||||
{
|
||||
|
@ -238,10 +245,17 @@ void CSVRender::PagedWorldspaceWidget::handleDrop (const std::vector< CSMWorld::
|
|||
|
||||
emit cellSelectionChanged(mSelection);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::DropType type) const
|
||||
{
|
||||
dropRequirments requirements = WorldspaceWidget::getDropRequirements (type);
|
||||
|
||||
if (requirements!=ignored)
|
||||
return requirements;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case Type_CellsExterior:
|
||||
|
|
|
@ -57,7 +57,9 @@ namespace CSVRender
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -89,13 +89,21 @@ void CSVRender::UnpagedWorldspaceWidget::cellRowsAboutToBeRemoved (const QModelI
|
|||
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();
|
||||
update();
|
||||
emit cellChanged(*data.begin());
|
||||
|
||||
/// \todo replace mCell
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
dropRequirments requirements = WorldspaceWidget::getDropRequirements (type);
|
||||
|
||||
if (requirements!=ignored)
|
||||
return requirements;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case Type_CellsInterior:
|
||||
|
|
|
@ -43,7 +43,9 @@ namespace CSVRender
|
|||
|
||||
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:
|
||||
|
||||
|
|
|
@ -187,6 +187,18 @@ CSVRender::WorldspaceWidget::DropType CSVRender::WorldspaceWidget::getDropType (
|
|||
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
|
||||
{
|
||||
return mSceneElements->getSelection();
|
||||
|
|
|
@ -70,12 +70,14 @@ namespace CSVRender
|
|||
|
||||
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);
|
||||
///< 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;
|
||||
|
||||
|
|
|
@ -198,10 +198,12 @@ void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalI
|
|||
CSVRender::UnpagedWorldspaceWidget* unPagedNewWidget = 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:
|
||||
mScene->handleDrop(data);
|
||||
mScene->handleDrop (data, type);
|
||||
break;
|
||||
|
||||
case CSVRender::WorldspaceWidget::needPaged:
|
||||
|
@ -209,7 +211,7 @@ void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalI
|
|||
toolbar = makeToolbar(pagedNewWidget, widget_Paged);
|
||||
makeConnections(pagedNewWidget);
|
||||
replaceToolbarAndWorldspace(pagedNewWidget, toolbar);
|
||||
mScene->handleDrop(data);
|
||||
mScene->handleDrop (data, type);
|
||||
break;
|
||||
|
||||
case CSVRender::WorldspaceWidget::needUnpaged:
|
||||
|
|
Loading…
Reference in a new issue