mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 12:36:42 +00:00
paged worldspace drop
This commit is contained in:
parent
19dac9dc86
commit
6aaa15b2e8
3 changed files with 31 additions and 17 deletions
|
@ -9,8 +9,9 @@
|
||||||
|
|
||||||
#include <apps/opencs/model/world/tablemimedata.hpp>
|
#include <apps/opencs/model/world/tablemimedata.hpp>
|
||||||
|
|
||||||
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget *parent)
|
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget *parent, const CSMDoc::Document& document)
|
||||||
: WorldspaceWidget (parent)
|
: WorldspaceWidget (parent),
|
||||||
|
mDocument(document)
|
||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
@ -66,24 +67,33 @@ void CSVRender::PagedWorldspaceWidget::dragMoveEvent (QDragMoveEvent* event)
|
||||||
|
|
||||||
void CSVRender::PagedWorldspaceWidget::dropEvent (QDropEvent* event)
|
void CSVRender::PagedWorldspaceWidget::dropEvent (QDropEvent* event)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
|
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
|
||||||
if (true)
|
if (mime->fromDocument(mDocument))
|
||||||
{
|
{
|
||||||
if (mime->holdsType(CSMWorld::UniversalId::Type_Cell))
|
std::vector<CSMWorld::UniversalId> data(mime->getData());
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < data.size(); ++i)
|
||||||
{
|
{
|
||||||
CSMWorld::UniversalId record(mime->returnMatching (CSMWorld::UniversalId::Type_Cell));
|
if (data[i].getType() == CSMWorld::UniversalId::Type_Cell ||
|
||||||
QString id(QString::fromUtf8(record.getId().c_str()));
|
data[i].getType() == CSMWorld::UniversalId::Type_Cell_Missing)
|
||||||
if (*id.begin() == '#')
|
|
||||||
{
|
{
|
||||||
id.remove(0,1);
|
if (*(data[i].getId().begin()) == '#')
|
||||||
QStringList splited(id.split(' '));
|
{
|
||||||
int x = splited.begin()->toInt();
|
std::pair<int, int> coordinate(getCoordinatesFromId(data[i].getId()));
|
||||||
int y = (splited.begin()+1)->toInt();
|
mSelection.add(CSMWorld::CellCoordinates(coordinate.first, coordinate.second));
|
||||||
mSelection.add(CSMWorld::CellCoordinates(x, y));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
//TODO!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::pair< int, int > CSVRender::PagedWorldspaceWidget::getCoordinatesFromId (const std::string& record) const
|
||||||
|
{
|
||||||
|
QString id(QString::fromUtf8(record.c_str()));
|
||||||
|
id.remove(0,1);
|
||||||
|
QStringList splited(id.split(' ')); //Well, this is the simplest approach
|
||||||
|
int x = splited.begin()->toInt();
|
||||||
|
int y = (splited.begin()+1)->toInt();
|
||||||
|
return std::make_pair(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define OPENCS_VIEW_PAGEDWORLDSPACEWIDGET_H
|
#define OPENCS_VIEW_PAGEDWORLDSPACEWIDGET_H
|
||||||
|
|
||||||
#include "../../model/world/cellselection.hpp"
|
#include "../../model/world/cellselection.hpp"
|
||||||
|
#include <apps/opencs/model/doc/document.hpp>
|
||||||
|
|
||||||
#include "worldspacewidget.hpp"
|
#include "worldspacewidget.hpp"
|
||||||
|
|
||||||
|
@ -12,6 +13,7 @@ namespace CSVRender
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
CSMWorld::CellSelection mSelection;
|
CSMWorld::CellSelection mSelection;
|
||||||
|
const CSMDoc::Document& mDocument; //for checking if drop comes from same document
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -21,9 +23,11 @@ namespace CSVRender
|
||||||
|
|
||||||
void dragMoveEvent(QDragMoveEvent *event);
|
void dragMoveEvent(QDragMoveEvent *event);
|
||||||
|
|
||||||
|
std::pair<int, int> getCoordinatesFromId(const std::string& record) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PagedWorldspaceWidget (QWidget *parent);
|
PagedWorldspaceWidget (QWidget *parent, const CSMDoc::Document& document);
|
||||||
///< \note Sets the cell area selection to an invalid value to indicate that currently
|
///< \note Sets the cell area selection to an invalid value to indicate that currently
|
||||||
/// no cells are displayed. The cells to be displayed will be specified later through
|
/// no cells are displayed. The cells to be displayed will be specified later through
|
||||||
/// hint system.
|
/// hint system.
|
||||||
|
|
|
@ -40,7 +40,7 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
|
|
||||||
if (id.getId()=="sys::default")
|
if (id.getId()=="sys::default")
|
||||||
{
|
{
|
||||||
CSVRender::PagedWorldspaceWidget *widget = new CSVRender::PagedWorldspaceWidget (this);
|
CSVRender::PagedWorldspaceWidget *widget = new CSVRender::PagedWorldspaceWidget (this, document);
|
||||||
mScene = widget;
|
mScene = widget;
|
||||||
connect (widget, SIGNAL (cellSelectionChanged (const CSMWorld::CellSelection&)),
|
connect (widget, SIGNAL (cellSelectionChanged (const CSMWorld::CellSelection&)),
|
||||||
this, SLOT (cellSelectionChanged (const CSMWorld::CellSelection&)));
|
this, SLOT (cellSelectionChanged (const CSMWorld::CellSelection&)));
|
||||||
|
|
Loading…
Reference in a new issue