forked from teamnwah/openmw-tes3coop
Add some drag'n'drop utils to work with TableMimeData
This commit is contained in:
parent
dc37aea8eb
commit
2565452052
3 changed files with 57 additions and 1 deletions
|
@ -70,7 +70,7 @@ opencs_units (view/world
|
||||||
opencs_units_noqt (view/world
|
opencs_units_noqt (view/world
|
||||||
subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate
|
subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate
|
||||||
scripthighlighter idvalidator dialoguecreator physicssystem idcompletiondelegate
|
scripthighlighter idvalidator dialoguecreator physicssystem idcompletiondelegate
|
||||||
colordelegate
|
colordelegate dragdroputils
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units (view/widget
|
opencs_units (view/widget
|
||||||
|
|
26
apps/opencs/view/world/dragdroputils.cpp
Normal file
26
apps/opencs/view/world/dragdroputils.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include "dragdroputils.hpp"
|
||||||
|
|
||||||
|
#include <QDropEvent>
|
||||||
|
|
||||||
|
#include "../../model/world/tablemimedata.hpp"
|
||||||
|
|
||||||
|
const CSMWorld::TableMimeData *CSVWorld::DragDropUtils::getTableMimeData(const QDropEvent &event)
|
||||||
|
{
|
||||||
|
return dynamic_cast<const CSMWorld::TableMimeData *>(event.mimeData());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSVWorld::DragDropUtils::canAcceptData(const QDropEvent &event, CSMWorld::ColumnBase::Display type)
|
||||||
|
{
|
||||||
|
const CSMWorld::TableMimeData *data = getTableMimeData(event);
|
||||||
|
return data != NULL && data->holdsType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMWorld::UniversalId CSVWorld::DragDropUtils::getAcceptedData(const QDropEvent &event,
|
||||||
|
CSMWorld::ColumnBase::Display type)
|
||||||
|
{
|
||||||
|
if (canAcceptData(event, type))
|
||||||
|
{
|
||||||
|
return getTableMimeData(event)->returnMatching(type);
|
||||||
|
}
|
||||||
|
return CSMWorld::UniversalId::Type_None;
|
||||||
|
}
|
30
apps/opencs/view/world/dragdroputils.hpp
Normal file
30
apps/opencs/view/world/dragdroputils.hpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef CSV_WORLD_DRAGDROPUTILS_HPP
|
||||||
|
#define CSV_WORLD_DRAGDROPUTILS_HPP
|
||||||
|
|
||||||
|
#include "../../model/world/columnbase.hpp"
|
||||||
|
|
||||||
|
class QDropEvent;
|
||||||
|
|
||||||
|
namespace CSMWorld
|
||||||
|
{
|
||||||
|
class TableMimeData;
|
||||||
|
class UniversalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVWorld
|
||||||
|
{
|
||||||
|
class DragDropUtils
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const CSMWorld::TableMimeData *getTableMimeData(const QDropEvent &event);
|
||||||
|
|
||||||
|
static bool canAcceptData(const QDropEvent &event, CSMWorld::ColumnBase::Display type);
|
||||||
|
///< Checks whether the \a event contains a valid CSMWorld::TableMimeData that holds the \a type
|
||||||
|
|
||||||
|
static CSMWorld::UniversalId getAcceptedData(const QDropEvent &event, CSMWorld::ColumnBase::Display type);
|
||||||
|
///< Gets the accepted data from the \a event using the \a type
|
||||||
|
///< \return Type_None if the \a event data doesn't holds the \a type
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue