2014-03-06 09:13:39 +00:00
|
|
|
|
|
|
|
#include "pagedworldspacewidget.hpp"
|
|
|
|
|
2014-04-01 08:04:14 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
2014-04-30 12:27:11 +00:00
|
|
|
#include <qt4/QtGui/qevent.h>
|
|
|
|
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
|
|
|
|
#include <apps/opencs/model/world/tablemimedata.hpp>
|
|
|
|
|
2014-03-06 09:13:39 +00:00
|
|
|
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget *parent)
|
2014-04-07 12:16:02 +00:00
|
|
|
: WorldspaceWidget (parent)
|
2014-04-30 12:27:11 +00:00
|
|
|
{
|
|
|
|
setAcceptDrops(true);
|
|
|
|
}
|
2014-04-01 08:04:14 +00:00
|
|
|
|
|
|
|
void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint)
|
|
|
|
{
|
|
|
|
if (!hint.empty())
|
|
|
|
{
|
2014-04-07 12:16:02 +00:00
|
|
|
CSMWorld::CellSelection selection;
|
|
|
|
|
2014-04-01 08:04:14 +00:00
|
|
|
if (hint[0]=='c')
|
|
|
|
{
|
2014-04-07 13:23:14 +00:00
|
|
|
// syntax: c:#x1 y1; #x2 y2 (number of coordinate pairs can be 0 or larger)
|
|
|
|
char ignore;
|
2014-04-01 08:04:14 +00:00
|
|
|
|
|
|
|
std::istringstream stream (hint.c_str());
|
2014-04-07 13:23:14 +00:00
|
|
|
if (stream >> ignore)
|
2014-04-01 08:04:14 +00:00
|
|
|
{
|
2014-04-07 13:23:14 +00:00
|
|
|
char ignore1; // : or ;
|
|
|
|
char ignore2; // #
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
while (stream >> ignore1 >> ignore2 >> x >> y)
|
|
|
|
selection.add (CSMWorld::CellCoordinates (x, y));
|
2014-04-01 08:04:14 +00:00
|
|
|
|
|
|
|
/// \todo adjust camera position
|
|
|
|
}
|
|
|
|
}
|
2014-04-07 13:23:14 +00:00
|
|
|
else if (hint[0]=='r')
|
|
|
|
{
|
|
|
|
/// \todo implement 'r' type hints
|
|
|
|
}
|
2014-04-07 12:16:02 +00:00
|
|
|
|
|
|
|
setCellSelection (selection);
|
2014-04-01 08:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-07 12:16:02 +00:00
|
|
|
void CSVRender::PagedWorldspaceWidget::setCellSelection (const CSMWorld::CellSelection& selection)
|
2014-04-01 08:04:14 +00:00
|
|
|
{
|
2014-04-07 12:16:02 +00:00
|
|
|
mSelection = selection;
|
|
|
|
emit cellSelectionChanged (mSelection);
|
2014-04-30 12:27:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSVRender::PagedWorldspaceWidget::dragEnterEvent (QDragEnterEvent* event)
|
|
|
|
{
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSVRender::PagedWorldspaceWidget::dragMoveEvent (QDragMoveEvent* event)
|
|
|
|
{
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSVRender::PagedWorldspaceWidget::dropEvent (QDropEvent* event)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
|
|
|
|
if (true)
|
|
|
|
{
|
|
|
|
if (mime->holdsType(CSMWorld::UniversalId::Type_Cell))
|
|
|
|
{
|
|
|
|
CSMWorld::UniversalId record(mime->returnMatching (CSMWorld::UniversalId::Type_Cell));
|
|
|
|
QString id(QString::fromUtf8(record.getId().c_str()));
|
|
|
|
if (*id.begin() == '#')
|
|
|
|
{
|
|
|
|
id.remove(0,1);
|
|
|
|
QStringList splited(id.split(' '));
|
|
|
|
int x = splited.begin()->toInt();
|
|
|
|
int y = (splited.begin()+1)->toInt();
|
|
|
|
mSelection.add(CSMWorld::CellCoordinates(x, y));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
//TODO!
|
|
|
|
}
|