some cleanup of the scene view drop code

deque
Marc Zinnschlag 10 years ago
parent 3f24593dba
commit 5a9376450b

@ -240,14 +240,14 @@ void CSVRender::PagedWorldspaceWidget::handleDrop (const std::vector< CSMWorld::
}
}
CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::dropType type) const
CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::DropType type) const
{
switch (type)
{
case cellsExterior:
case Type_CellsExterior:
return canHandle;
case cellsInterior:
case Type_CellsInterior:
return needUnpaged;
default:

@ -59,7 +59,7 @@ namespace CSVRender
virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data);
virtual dropRequirments getDropRequirements(dropType type) const;
virtual dropRequirments getDropRequirements(DropType type) const;
/// \attention The created tool is not added to the toolbar (via addTool). Doing
/// that is the responsibility of the calling function.

@ -166,14 +166,14 @@ std::string CSVRender::UnpagedWorldspaceWidget::getStartupInstruction()
return stream.str();
}
CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::dropType type) const
CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::DropType type) const
{
switch(type)
{
case cellsInterior:
case Type_CellsInterior:
return canHandle;
case cellsExterior:
case Type_CellsExterior:
return needPaged;
default:

@ -41,7 +41,7 @@ namespace CSVRender
UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document,
QWidget *parent);
virtual dropRequirments getDropRequirements(dropType type) const;
virtual dropRequirments getDropRequirements(DropType type) const;
virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data);

@ -162,54 +162,26 @@ CSVWidget::SceneToolRun *CSVRender::WorldspaceWidget::makeRunTool (
return mRun;
}
CSVRender::WorldspaceWidget::dropType CSVRender::WorldspaceWidget::getDropType (
CSVRender::WorldspaceWidget::DropType CSVRender::WorldspaceWidget::getDropType (
const std::vector< CSMWorld::UniversalId >& data)
{
dropType output = notCells;
bool firstIteration = true;
DropType output = Type_Other;
for (unsigned i = 0; i < data.size(); ++i)
for (std::vector<CSMWorld::UniversalId>::const_iterator iter (data.begin());
iter!=data.end(); ++iter)
{
if (data[i].getType() == CSMWorld::UniversalId::Type_Cell ||
data[i].getType() == CSMWorld::UniversalId::Type_Cell_Missing)
DropType type = Type_Other;
if (iter->getType()==CSMWorld::UniversalId::Type_Cell ||
iter->getType()==CSMWorld::UniversalId::Type_Cell_Missing)
{
if (*(data[i].getId().begin()) == '#') //exterior
{
if (firstIteration)
{
output = cellsExterior;
firstIteration = false;
continue;
}
if (output == cellsInterior)
{
output = cellsMixed;
break;
} else {
output = cellsInterior;
}
} else //interior
{
if (firstIteration)
{
output = cellsInterior;
firstIteration = false;
continue;
}
if (output == cellsExterior)
{
output = cellsMixed;
break;
} else {
output = cellsInterior;
}
}
} else {
output = notCells;
break;
type = iter->getId().substr (0, 1)=="#" ? Type_CellsExterior : Type_CellsInterior;
}
if (iter==data.begin())
output = type;
else if (output!=type) // mixed types -> ignore
return Type_Other;
}
return output;

@ -36,12 +36,11 @@ namespace CSVRender
public:
enum dropType
enum DropType
{
cellsMixed,
cellsInterior,
cellsExterior,
notCells
Type_CellsInterior,
Type_CellsExterior,
Type_Other
};
enum dropRequirments
@ -69,9 +68,9 @@ namespace CSVRender
void selectDefaultNavigationMode();
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 = 0;
virtual void useViewHint (const std::string& hint);
///< Default-implementation: ignored.

Loading…
Cancel
Save