draganddrop: more porting, build some bits already

This commit is contained in:
Sebastian Kügler 2013-02-27 17:58:58 +01:00
parent 872839ecf9
commit 4fc1dbef00
7 changed files with 30 additions and 24 deletions

View File

@ -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)

View File

@ -4,7 +4,7 @@ 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

View File

@ -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();
} }

View File

@ -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

View File

@ -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();
} }

View File

@ -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)

View File

@ -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);