Yes, you can drag. But not drop.

This commit is contained in:
Marek Kochanowicz 2014-02-04 11:40:48 +01:00
parent dc80bfff55
commit 423b2906be
6 changed files with 37 additions and 9 deletions

View file

@ -324,7 +324,7 @@ configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
configure_file(${OpenMW_SOURCE_DIR}/files/opencs.cfg configure_file(${OpenMW_SOURCE_DIR}/files/opencs.cfg
"${OpenMW_BINARY_DIR}/opencs.cfg") "${OpenMW_BINARY_DIR}/opencs.cfg")
configure_file(${OpenMW_SOURCE_DIR}/files/opencs/defaultfilters configure_file(${OpenMW_SOURCE_DIR}/files/opencs/defaultfilters
"${OpenMW_BINARY_DIR}/resources/defaultfilters" COPYONLY) "${OpenMW_BINARY_DIR}/resources/defaultfilters" COPYONLY)

View file

@ -24,7 +24,7 @@ opencs_units (model/world
opencs_units_noqt (model/world opencs_units_noqt (model/world
universalid record commands columnbase scriptcontext cell refidcollection universalid record commands columnbase scriptcontext cell refidcollection
refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata
) )
opencs_hdrs_noqt (model/world opencs_hdrs_noqt (model/world

View file

@ -1,10 +1,10 @@
#include "tablemimedata.hpp" #include "tablemimedata.hpp"
#include "universalid.hpp" #include "universalid.hpp"
CSMWorld::TableMimeData::TableMimeData (CSMWorld::UniversalId& UniversalId) : CSMWorld::TableMimeData::TableMimeData (UniversalId id) :
mUniversalId(UniversalId) mUniversalId(id)
{ {
mSupportedFormats << UniversalId.toString().c_str(); mSupportedFormats << QString::fromStdString("application/Type_" + id.getTypeName());
} }
QStringList CSMWorld::TableMimeData::formats() const QStringList CSMWorld::TableMimeData::formats() const
@ -19,4 +19,4 @@ CSMWorld::TableMimeData::~TableMimeData()
CSMWorld::UniversalId& CSMWorld::TableMimeData::getId() CSMWorld::UniversalId& CSMWorld::TableMimeData::getId()
{ {
return mUniversalId; return mUniversalId;
} }

View file

@ -5,7 +5,11 @@
#define TABLEMIMEDATA_H #define TABLEMIMEDATA_H
#include <qt4/QtCore/QMimeData> #include <qt4/QtCore/QMimeData>
#include <QVariant> #include <QStringList>
#include "universalid.hpp"
class QStringList;
namespace CSMWorld namespace CSMWorld
{ {
@ -13,14 +17,14 @@ namespace CSMWorld
class TableMimeData : public QMimeData class TableMimeData : public QMimeData
{ {
public: public:
TableMimeData(UniversalId& UniversalId); TableMimeData(UniversalId id);
~TableMimeData(); ~TableMimeData();
virtual QStringList formats() const; virtual QStringList formats() const;
UniversalId& getId(); UniversalId& getId();
private: private:
QStringList mSupportedFormats; QStringList mSupportedFormats;
UniversalId& mUniversalId; UniversalId mUniversalId;
}; };
} }
#endif // TABLEMIMEDATA_H #endif // TABLEMIMEDATA_H

View file

@ -412,3 +412,24 @@ void CSVWorld::Table::recordFilterChanged (boost::shared_ptr<CSMFilter::Node> fi
{ {
mProxyModel->setFilter (filter); mProxyModel->setFilter (filter);
} }
void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event)
{
if (event->buttons() & Qt::LeftButton)
{
QModelIndexList selectedRows = selectionModel()->selectedRows();
if (selectedRows.size() == 0)
{
return;
}
if (selectedRows.size() == 1) //tmp solution
{
CSMWorld::TableMimeData *mime = new CSMWorld::TableMimeData(getUniversalId(selectedRows.begin()->row()));
QDrag *drag = new QDrag(this);
drag->setMimeData(mime);
drag->start();
}
}
}

View file

@ -5,6 +5,7 @@
#include <string> #include <string>
#include <QTableView> #include <QTableView>
#include <qt4/QtGui/qevent.h>
#include "../../model/filter/node.hpp" #include "../../model/filter/node.hpp"
@ -49,6 +50,8 @@ namespace CSVWorld
std::vector<std::string> listDeletableSelectedIds() const; std::vector<std::string> listDeletableSelectedIds() const;
void mouseMoveEvent(QMouseEvent *event);
public: public:
Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete, bool sorting); Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete, bool sorting);