draganddrop: more porting, build some bits already
This commit is contained in:
parent
872839ecf9
commit
4fc1dbef00
@ -1,5 +1,5 @@
|
|||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
#add_subdirectory(draganddrop)
|
add_subdirectory(draganddrop)
|
||||||
add_subdirectory(krunnermodel)
|
add_subdirectory(krunnermodel)
|
||||||
add_subdirectory(qtextracomponents)
|
add_subdirectory(qtextracomponents)
|
||||||
add_subdirectory(plasmacomponents)
|
add_subdirectory(plasmacomponents)
|
||||||
|
@ -4,10 +4,10 @@ include(KDE4Defaults)
|
|||||||
|
|
||||||
set(declarativedragdrop_SRCS
|
set(declarativedragdrop_SRCS
|
||||||
draganddropplugin.cpp
|
draganddropplugin.cpp
|
||||||
DeclarativeDragArea.cpp
|
# DeclarativeDragArea.cpp
|
||||||
DeclarativeDragDropEvent.cpp
|
DeclarativeDragDropEvent.cpp
|
||||||
DeclarativeDropArea.cpp
|
DeclarativeDropArea.cpp
|
||||||
DeclarativeMimeData.cpp
|
DeclarativeMimeData.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
|
@ -25,15 +25,23 @@
|
|||||||
|
|
||||||
DeclarativeDragDropEvent::DeclarativeDragDropEvent(QEvent* e, DeclarativeDropArea* parent) :
|
DeclarativeDragDropEvent::DeclarativeDragDropEvent(QEvent* e, DeclarativeDropArea* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_x(e->pos().x()),
|
// m_x(e->pos().x()),
|
||||||
m_y(e->pos().y()),
|
// m_y(e->pos().y()),
|
||||||
m_buttons(e->buttons()),
|
// m_buttons(e->buttons()),
|
||||||
m_modifiers(e->modifiers()),
|
// m_modifiers(e->modifiers()),
|
||||||
m_data(e->mimeData()),
|
// m_data(e->mimeData()),
|
||||||
m_event(e)
|
m_event(0)
|
||||||
{
|
{
|
||||||
|
QPointF pos;
|
||||||
|
m_event = dynamic_cast<QDropEvent*>(e); // also covers enter
|
||||||
|
|
||||||
|
if (m_event) {
|
||||||
|
// m_x = m_event->pos.x();
|
||||||
|
// m_y = m_event->pos.y();
|
||||||
|
m_buttons = m_event->mouseButtons();
|
||||||
|
}
|
||||||
if (parent) {
|
if (parent) {
|
||||||
QPointF pos = parent->mapFromScene(e->scenePos());
|
//pos = parent->mapFromScene(e->scenePos());
|
||||||
m_x = pos.x();
|
m_x = pos.x();
|
||||||
m_y = pos.y();
|
m_y = pos.y();
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ private:
|
|||||||
Qt::MouseButtons m_buttons;
|
Qt::MouseButtons m_buttons;
|
||||||
Qt::KeyboardModifiers m_modifiers;
|
Qt::KeyboardModifiers m_modifiers;
|
||||||
DeclarativeMimeData m_data;
|
DeclarativeMimeData m_data;
|
||||||
QGraphicsSceneDragDropEvent* m_event;
|
QDropEvent* m_event;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DECLARATIVEDRAGDROPEVENT_H
|
#endif // DECLARATIVEDRAGDROPEVENT_H
|
||||||
|
@ -31,10 +31,7 @@ DeclarativeDropArea::DeclarativeDropArea(QQuickItem *parent)
|
|||||||
: QQuickItem(parent),
|
: QQuickItem(parent),
|
||||||
m_enabled(true)
|
m_enabled(true)
|
||||||
{
|
{
|
||||||
// setAcceptDrops(m_enabled);
|
setFlag(ItemAcceptsDrops, m_enabled);
|
||||||
if (m_enabled) {
|
|
||||||
setFlag(ItemAcceptsDrops);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarativeDropArea::dragEnterEvent(QDragEnterEvent *event) {
|
void DeclarativeDropArea::dragEnterEvent(QDragEnterEvent *event) {
|
||||||
@ -72,6 +69,6 @@ void DeclarativeDropArea::setEnabled(bool enabled)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_enabled = enabled;
|
m_enabled = enabled;
|
||||||
setAcceptDrops(m_enabled);
|
setFlag(ItemAcceptsDrops, m_enabled);
|
||||||
emit enabledChanged();
|
emit enabledChanged();
|
||||||
}
|
}
|
||||||
|
@ -24,20 +24,20 @@
|
|||||||
|
|
||||||
#include <QtQml>
|
#include <QtQml>
|
||||||
|
|
||||||
#include "DeclarativeDragArea.h"
|
// #include "DeclarativeDragArea.h"
|
||||||
#include "DeclarativeDragDropEvent.h"
|
// #include "DeclarativeDragDropEvent.h"
|
||||||
#include "DeclarativeDropArea.h"
|
// #include "DeclarativeDropArea.h"
|
||||||
#include "DeclarativeMimeData.h"
|
// #include "DeclarativeMimeData.h"
|
||||||
|
|
||||||
void DragAndDropPlugin::registerTypes(const char *uri)
|
void DragAndDropPlugin::registerTypes(const char *uri)
|
||||||
{
|
{
|
||||||
Q_ASSERT(uri == QLatin1String("org.kde.draganddrop"));
|
Q_ASSERT(uri == QLatin1String("org.kde.draganddrop"));
|
||||||
|
|
||||||
qmlRegisterType<DeclarativeDropArea>(uri, 1, 0, "DropArea");
|
// qmlRegisterType<DeclarativeDropArea>(uri, 1, 0, "DropArea");
|
||||||
// qmlRegisterType<DeclarativeDragArea>(uri, 1, 0, "DragArea");
|
// qmlRegisterType<DeclarativeDragArea>(uri, 1, 0, "DragArea");
|
||||||
// qmlRegisterUncreatableType<DeclarativeMimeData>(uri, 1, 0, "MimeData", "MimeData cannot be created from QML.");
|
// qmlRegisterUncreatableType<DeclarativeMimeData>(uri, 1, 0, "MimeData", "MimeData cannot be created from QML.");
|
||||||
// qmlRegisterUncreatableType<DeclarativeDragDropEvent>(uri, 1, 0, "DragDropEvent", "DragDropEvent cannot be created from QML.");
|
// qmlRegisterUncreatableType<DeclarativeDragDropEvent>(uri, 1, 0, "DragDropEvent", "DragDropEvent cannot be created from QML.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN2(draganddropplugin, DragAndDropPlugin)
|
//Q_EXPORT_PLUGIN2(draganddropplugin, DragAndDropPlugin)
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
class DragAndDropPlugin : public QQmlExtensionPlugin
|
class DragAndDropPlugin : public QQmlExtensionPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void registerTypes(const char *uri);
|
void registerTypes(const char *uri);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user