mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 12:35:46 +00:00
Nested tables accept drops
This commit is contained in:
parent
b9882eb59a
commit
d606b62688
@ -12,7 +12,13 @@
|
|||||||
|
|
||||||
void CSVWorld::DragRecordTable::startDragFromTable (const CSVWorld::DragRecordTable& table)
|
void CSVWorld::DragRecordTable::startDragFromTable (const CSVWorld::DragRecordTable& table)
|
||||||
{
|
{
|
||||||
CSMWorld::TableMimeData* mime = new CSMWorld::TableMimeData (table.getDraggedRecords(), mDocument);
|
std::vector<CSMWorld::UniversalId> records = table.getDraggedRecords();
|
||||||
|
if (records.empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMWorld::TableMimeData* mime = new CSMWorld::TableMimeData (records, mDocument);
|
||||||
|
|
||||||
if (mime)
|
if (mime)
|
||||||
{
|
{
|
||||||
@ -27,7 +33,9 @@ CSVWorld::DragRecordTable::DragRecordTable (CSMDoc::Document& document, QWidget*
|
|||||||
QTableView(parent),
|
QTableView(parent),
|
||||||
mDocument(document),
|
mDocument(document),
|
||||||
mEditLock(false)
|
mEditLock(false)
|
||||||
{}
|
{
|
||||||
|
setAcceptDrops(true);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::DragRecordTable::setEditLock (bool locked)
|
void CSVWorld::DragRecordTable::setEditLock (bool locked)
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,7 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document,
|
|||||||
CSMWorld::UniversalId id,
|
CSMWorld::UniversalId id,
|
||||||
CSMWorld::NestedTableProxyModel* model,
|
CSMWorld::NestedTableProxyModel* model,
|
||||||
QWidget* parent)
|
QWidget* parent)
|
||||||
: QTableView(parent),
|
: DragRecordTable(document, parent),
|
||||||
mUndoStack(document.getUndoStack()),
|
|
||||||
mModel(model)
|
mModel(model)
|
||||||
{
|
{
|
||||||
mDispatcher = new CSMWorld::CommandDispatcher (document, id, this);
|
mDispatcher = new CSMWorld::CommandDispatcher (document, id, this);
|
||||||
@ -47,8 +46,6 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document,
|
|||||||
|
|
||||||
setModel(model);
|
setModel(model);
|
||||||
|
|
||||||
setAcceptDrops(true);
|
|
||||||
|
|
||||||
mAddNewRowAction = new QAction (tr ("Add new row"), this);
|
mAddNewRowAction = new QAction (tr ("Add new row"), this);
|
||||||
|
|
||||||
connect(mAddNewRowAction, SIGNAL(triggered()),
|
connect(mAddNewRowAction, SIGNAL(triggered()),
|
||||||
@ -60,12 +57,10 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document,
|
|||||||
this, SLOT(removeRowActionTriggered()));
|
this, SLOT(removeRowActionTriggered()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::NestedTable::dragEnterEvent(QDragEnterEvent *event)
|
std::vector<CSMWorld::UniversalId> CSVWorld::NestedTable::getDraggedRecords() const
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVWorld::NestedTable::dragMoveEvent(QDragMoveEvent *event)
|
|
||||||
{
|
{
|
||||||
|
// No drag support for nested tables
|
||||||
|
return std::vector<CSMWorld::UniversalId>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::NestedTable::contextMenuEvent (QContextMenuEvent *event)
|
void CSVWorld::NestedTable::contextMenuEvent (QContextMenuEvent *event)
|
||||||
@ -84,16 +79,16 @@ void CSVWorld::NestedTable::contextMenuEvent (QContextMenuEvent *event)
|
|||||||
|
|
||||||
void CSVWorld::NestedTable::removeRowActionTriggered()
|
void CSVWorld::NestedTable::removeRowActionTriggered()
|
||||||
{
|
{
|
||||||
mUndoStack.push(new CSMWorld::DeleteNestedCommand(*(mModel->model()),
|
mDocument.getUndoStack().push(new CSMWorld::DeleteNestedCommand(*(mModel->model()),
|
||||||
mModel->getParentId(),
|
mModel->getParentId(),
|
||||||
selectionModel()->selectedRows().begin()->row(),
|
selectionModel()->selectedRows().begin()->row(),
|
||||||
mModel->getParentColumn()));
|
mModel->getParentColumn()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::NestedTable::addNewRowActionTriggered()
|
void CSVWorld::NestedTable::addNewRowActionTriggered()
|
||||||
{
|
{
|
||||||
mUndoStack.push(new CSMWorld::AddNestedCommand(*(mModel->model()),
|
mDocument.getUndoStack().push(new CSMWorld::AddNestedCommand(*(mModel->model()),
|
||||||
mModel->getParentId(),
|
mModel->getParentId(),
|
||||||
selectionModel()->selectedRows().size(),
|
selectionModel()->selectedRows().size(),
|
||||||
mModel->getParentColumn()));
|
mModel->getParentColumn()));
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#ifndef CSV_WORLD_NESTEDTABLE_H
|
#ifndef CSV_WORLD_NESTEDTABLE_H
|
||||||
#define CSV_WORLD_NESTEDTABLE_H
|
#define CSV_WORLD_NESTEDTABLE_H
|
||||||
|
|
||||||
#include <QTableView>
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
|
||||||
class QUndoStack;
|
#include "dragrecordtable.hpp"
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
class QContextMenuEvent;
|
class QContextMenuEvent;
|
||||||
|
|
||||||
@ -22,13 +22,12 @@ namespace CSMDoc
|
|||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
class NestedTable : public QTableView
|
class NestedTable : public DragRecordTable
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QAction *mAddNewRowAction;
|
QAction *mAddNewRowAction;
|
||||||
QAction *mRemoveRowAction;
|
QAction *mRemoveRowAction;
|
||||||
QUndoStack& mUndoStack;
|
|
||||||
CSMWorld::NestedTableProxyModel* mModel;
|
CSMWorld::NestedTableProxyModel* mModel;
|
||||||
CSMWorld::CommandDispatcher *mDispatcher;
|
CSMWorld::CommandDispatcher *mDispatcher;
|
||||||
|
|
||||||
@ -38,10 +37,7 @@ namespace CSVWorld
|
|||||||
CSMWorld::NestedTableProxyModel* model,
|
CSMWorld::NestedTableProxyModel* model,
|
||||||
QWidget* parent = NULL);
|
QWidget* parent = NULL);
|
||||||
|
|
||||||
protected:
|
virtual std::vector<CSMWorld::UniversalId> getDraggedRecords() const;
|
||||||
void dragEnterEvent(QDragEnterEvent *event);
|
|
||||||
|
|
||||||
void dragMoveEvent(QDragMoveEvent *event);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void contextMenuEvent (QContextMenuEvent *event);
|
void contextMenuEvent (QContextMenuEvent *event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user