able to drag existing cells from the regionmap

openmw-30
Marek Kochanowicz 11 years ago
parent 853abb65c3
commit 18fc8acc71

@ -16,6 +16,7 @@ void CSVWorld::DragRecordTable::startDrag (const CSVWorld::DragRecordTable& tabl
}
}
CSVWorld::DragRecordTable::DragRecordTable (CSMDoc::Document& document) :
mDocument(document)
CSVWorld::DragRecordTable::DragRecordTable (CSMDoc::Document& document, QWidget* parent) :
mDocument(document),
QTableView(parent)
{}

@ -1,8 +1,9 @@
#ifndef CSV_WORLD_REGIONMAP_H
#define CSV_WORLD_REGIONMAP_H
#ifndef CSV_WORLD_DRAGRECORDTABLE_H
#define CSV_WORLD_DRAGRECORDTABLE_H
#include <QTableView>
class QWidget;
class QAction;
namespace CSMDoc
@ -23,7 +24,7 @@ namespace CSVWorld
CSMDoc::Document& mDocument;
public:
DragRecordTable(CSMDoc::Document& document);
DragRecordTable(CSMDoc::Document& document, QWidget* parent = NULL);
virtual std::vector<CSMWorld::UniversalId> getDragedRecords() const = 0;
@ -33,4 +34,4 @@ namespace CSVWorld
}
#endif

@ -181,7 +181,7 @@ void CSVWorld::RegionMap::setRegion (const std::string& regionId)
CSVWorld::RegionMap::RegionMap (const CSMWorld::UniversalId& universalId,
CSMDoc::Document& document, QWidget *parent)
: QTableView (parent), mEditLock (false), mDocument (document)
: mEditLock (false), DragRecordTable(document, parent)
{
verticalHeader()->hide();
horizontalHeader()->hide();
@ -348,4 +348,19 @@ void CSVWorld::RegionMap::viewInTable()
void CSVWorld::RegionMap::mouseMoveEvent (QMouseEvent* event)
{
startDrag(*this);
}
std::vector< CSMWorld::UniversalId > CSVWorld::RegionMap::getDragedRecords() const
{
QModelIndexList selected = getSelectedCells();
std::vector<CSMWorld::UniversalId> ids;
foreach (QModelIndex it, selected)
{
ids.push_back(
CSMWorld::UniversalId
(CSMWorld::UniversalId::Type_Cell,
model()->data(it, CSMWorld::RegionMap::Role_CellId).toString().toUtf8().constData()));
}
return ids;
}

@ -1,8 +1,14 @@
#ifndef CSV_WORLD_REGIONMAP_H
#define CSV_WORLD_REGIONMAP_H
#include <cstddef>
#include <vector>
#include <QObject>
#include <QTableView>
#include "./dragrecordtable.hpp"
class QAction;
namespace CSMDoc
@ -17,7 +23,7 @@ namespace CSMWorld
namespace CSVWorld
{
class RegionMap : public QTableView
class RegionMap : public DragRecordTable
{
Q_OBJECT
@ -30,7 +36,6 @@ namespace CSVWorld
QAction *mViewAction;
QAction *mViewInTableAction;
bool mEditLock;
CSMDoc::Document& mDocument;
std::string mRegionId;
private:
@ -59,6 +64,8 @@ namespace CSVWorld
void setEditLock (bool locked);
virtual std::vector<CSMWorld::UniversalId> getDragedRecords() const;
signals:
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);

@ -4,7 +4,6 @@
#include <vector>
#include <string>
#include <QTableView>
#include <QtGui/qevent.h>
#include "../../model/filter/node.hpp"
@ -25,7 +24,6 @@ namespace CSMWorld
class UniversalId;
class IdTableProxyModel;
class IdTable;
class TableMimeData;
}
namespace CSVWorld

Loading…
Cancel
Save