forked from mirror/openmw-tes3mp
added new, later common, base for the regionmap and the table
This commit is contained in:
parent
6929e541dd
commit
853abb65c3
9 changed files with 90 additions and 38 deletions
|
@ -60,7 +60,7 @@ opencs_hdrs_noqt (view/doc
|
|||
opencs_units (view/world
|
||||
table tablesubview scriptsubview util regionmapsubview tablebottombox creator genericcreator
|
||||
cellcreator referenceablecreator referencecreator scenesubview scenetoolbar scenetool
|
||||
scenetoolmode infocreator scriptedit dialoguesubview previewsubview regionmap
|
||||
scenetoolmode infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable
|
||||
)
|
||||
|
||||
opencs_units (view/render
|
||||
|
|
|
@ -11,7 +11,7 @@ mDocument(document)
|
|||
mObjectsFormats << QString::fromUtf8 (("tabledata/" + id.getTypeName()).c_str());
|
||||
}
|
||||
|
||||
CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id, const CSMDoc::Document& document) :
|
||||
CSMWorld::TableMimeData::TableMimeData (const std::vector< CSMWorld::UniversalId >& id, const CSMDoc::Document& document) :
|
||||
mUniversalId (id), mDocument(document)
|
||||
{
|
||||
for (std::vector<UniversalId>::iterator it (mUniversalId.begin()); it != mUniversalId.end(); ++it)
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace CSMWorld
|
|||
public:
|
||||
TableMimeData(UniversalId id, const CSMDoc::Document& document);
|
||||
|
||||
TableMimeData(std::vector<UniversalId>& id, const CSMDoc::Document& document);
|
||||
TableMimeData(const std::vector<UniversalId>& id, const CSMDoc::Document& document);
|
||||
|
||||
~TableMimeData();
|
||||
|
||||
|
|
21
apps/opencs/view/world/dragrecordtable.cpp
Normal file
21
apps/opencs/view/world/dragrecordtable.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include <QDrag>
|
||||
|
||||
#include "../../model/world/tablemimedata.hpp"
|
||||
#include "dragrecordtable.hpp"
|
||||
|
||||
void CSVWorld::DragRecordTable::startDrag (const CSVWorld::DragRecordTable& table)
|
||||
{
|
||||
CSMWorld::TableMimeData* mime = new CSMWorld::TableMimeData (table.getDragedRecords(), mDocument);
|
||||
|
||||
if (mime)
|
||||
{
|
||||
QDrag* drag = new QDrag (this);
|
||||
drag->setMimeData (mime);
|
||||
drag->setPixmap (QString::fromUtf8 (mime->getIcon().c_str()));
|
||||
drag->exec (Qt::CopyAction);
|
||||
}
|
||||
}
|
||||
|
||||
CSVWorld::DragRecordTable::DragRecordTable (CSMDoc::Document& document) :
|
||||
mDocument(document)
|
||||
{}
|
36
apps/opencs/view/world/dragrecordtable.hpp
Normal file
36
apps/opencs/view/world/dragrecordtable.hpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef CSV_WORLD_REGIONMAP_H
|
||||
#define CSV_WORLD_REGIONMAP_H
|
||||
|
||||
#include <QTableView>
|
||||
|
||||
class QAction;
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Document;
|
||||
}
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
class UniversalId;
|
||||
}
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class DragRecordTable : public QTableView
|
||||
{
|
||||
protected:
|
||||
CSMDoc::Document& mDocument;
|
||||
|
||||
public:
|
||||
DragRecordTable(CSMDoc::Document& document);
|
||||
|
||||
virtual std::vector<CSMWorld::UniversalId> getDragedRecords() const = 0;
|
||||
|
||||
protected:
|
||||
void startDrag(const DragRecordTable& table);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
#include "../../model/world/idtable.hpp"
|
||||
#include "../../model/world/commands.hpp"
|
||||
#include "../../model/world/columns.hpp"
|
||||
#include "../../model/world/tablemimedata.hpp"
|
||||
|
||||
void CSVWorld::RegionMap::contextMenuEvent (QContextMenuEvent *event)
|
||||
{
|
||||
|
@ -343,4 +344,8 @@ void CSVWorld::RegionMap::viewInTable()
|
|||
hint << ")";
|
||||
|
||||
emit editRequest (CSMWorld::UniversalId::Type_Cells, hint.str());
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::RegionMap::mouseMoveEvent (QMouseEvent* event)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ namespace CSVWorld
|
|||
void setRegion (const std::string& regionId);
|
||||
///< Set region Id of selected cells.
|
||||
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
public:
|
||||
|
||||
RegionMap (const CSMWorld::UniversalId& universalId, CSMDoc::Document& document,
|
||||
|
|
|
@ -189,7 +189,7 @@ std::vector<std::string> CSVWorld::Table::listDeletableSelectedIds() const
|
|||
CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
|
||||
bool createAndDelete, bool sorting, CSMDoc::Document& document)
|
||||
: mCreateAction (0), mCloneAction(0), mEditLock (false), mRecordStatusDisplay (0),
|
||||
mDocument (document)
|
||||
DragRecordTable(document)
|
||||
{
|
||||
mModel = &dynamic_cast<CSMWorld::IdTable&> (*mDocument.getData().getTableModel (id));
|
||||
|
||||
|
@ -512,37 +512,8 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event)
|
|||
{
|
||||
if (event->buttons() & Qt::LeftButton)
|
||||
{
|
||||
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||
|
||||
if (selectedRows.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QDrag* drag = new QDrag (this);
|
||||
CSMWorld::TableMimeData* mime = NULL;
|
||||
|
||||
if (selectedRows.size() == 1)
|
||||
{
|
||||
mime = new CSMWorld::TableMimeData (getUniversalId (selectedRows.begin()->row()), mDocument);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<CSMWorld::UniversalId> idToDrag;
|
||||
|
||||
foreach (QModelIndex it, selectedRows) //I had a dream. Dream where you could use C++11 in OpenMW.
|
||||
{
|
||||
idToDrag.push_back (getUniversalId (it.row()));
|
||||
}
|
||||
|
||||
mime = new CSMWorld::TableMimeData (idToDrag, mDocument);
|
||||
}
|
||||
|
||||
drag->setMimeData (mime);
|
||||
drag->setPixmap (QString::fromUtf8 (mime->getIcon().c_str()));
|
||||
drag->exec(Qt::CopyAction);
|
||||
startDrag(*this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event)
|
||||
|
@ -598,4 +569,18 @@ std::vector<std::string> CSVWorld::Table::getColumnsWithDisplay(CSMWorld::Column
|
|||
}
|
||||
}
|
||||
return titles;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector< CSMWorld::UniversalId > CSVWorld::Table::getDragedRecords() const
|
||||
{
|
||||
|
||||
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||
std::vector<CSMWorld::UniversalId> idToDrag;
|
||||
|
||||
foreach (QModelIndex it, selectedRows) //I had a dream. Dream where you could use C++11 in OpenMW.
|
||||
{
|
||||
idToDrag.push_back (getUniversalId (it.row()));
|
||||
}
|
||||
|
||||
return idToDrag;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "../../model/filter/node.hpp"
|
||||
#include "../../model/world/columnbase.hpp"
|
||||
#include "dragrecordtable.hpp"
|
||||
|
||||
class QUndoStack;
|
||||
class QAction;
|
||||
|
@ -24,6 +25,7 @@ namespace CSMWorld
|
|||
class UniversalId;
|
||||
class IdTableProxyModel;
|
||||
class IdTable;
|
||||
class TableMimeData;
|
||||
}
|
||||
|
||||
namespace CSVWorld
|
||||
|
@ -31,7 +33,7 @@ namespace CSVWorld
|
|||
class CommandDelegate;
|
||||
|
||||
///< Table widget
|
||||
class Table : public QTableView
|
||||
class Table : public DragRecordTable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -49,7 +51,6 @@ namespace CSVWorld
|
|||
CSMWorld::IdTable *mModel;
|
||||
bool mEditLock;
|
||||
int mRecordStatusDisplay;
|
||||
CSMDoc::Document& mDocument;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -82,6 +83,8 @@ namespace CSVWorld
|
|||
|
||||
std::vector<std::string> getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const;
|
||||
|
||||
virtual std::vector<CSMWorld::UniversalId> getDragedRecords() const;
|
||||
|
||||
signals:
|
||||
|
||||
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);
|
||||
|
|
Loading…
Reference in a new issue