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(draganddrop)
add_subdirectory(draganddrop)
add_subdirectory(krunnermodel)
add_subdirectory(qtextracomponents)
add_subdirectory(plasmacomponents)

View File

@ -4,10 +4,10 @@ include(KDE4Defaults)
set(declarativedragdrop_SRCS
draganddropplugin.cpp
DeclarativeDragArea.cpp
DeclarativeDragDropEvent.cpp
DeclarativeDropArea.cpp
DeclarativeMimeData.cpp
# DeclarativeDragArea.cpp
DeclarativeDragDropEvent.cpp
DeclarativeDropArea.cpp
DeclarativeMimeData.cpp
)
INCLUDE_DIRECTORIES(

View File

@ -25,15 +25,23 @@
DeclarativeDragDropEvent::DeclarativeDragDropEvent(QEvent* e, DeclarativeDropArea* parent) :
QObject(parent),
m_x(e->pos().x()),
m_y(e->pos().y()),
m_buttons(e->buttons()),
m_modifiers(e->modifiers()),
m_data(e->mimeData()),
m_event(e)
// m_x(e->pos().x()),
// m_y(e->pos().y()),
// m_buttons(e->buttons()),
// m_modifiers(e->modifiers()),
// m_data(e->mimeData()),
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) {
QPointF pos = parent->mapFromScene(e->scenePos());
//pos = parent->mapFromScene(e->scenePos());
m_x = pos.x();
m_y = pos.y();
}

View File

@ -114,7 +114,7 @@ private:
Qt::MouseButtons m_buttons;
Qt::KeyboardModifiers m_modifiers;
DeclarativeMimeData m_data;
QGraphicsSceneDragDropEvent* m_event;
QDropEvent* m_event;
};
#endif // DECLARATIVEDRAGDROPEVENT_H

View File

@ -31,10 +31,7 @@ DeclarativeDropArea::DeclarativeDropArea(QQuickItem *parent)
: QQuickItem(parent),
m_enabled(true)
{
// setAcceptDrops(m_enabled);
if (m_enabled) {
setFlag(ItemAcceptsDrops);
}
setFlag(ItemAcceptsDrops, m_enabled);
}
void DeclarativeDropArea::dragEnterEvent(QDragEnterEvent *event) {
@ -72,6 +69,6 @@ void DeclarativeDropArea::setEnabled(bool enabled)
}
m_enabled = enabled;
setAcceptDrops(m_enabled);
setFlag(ItemAcceptsDrops, m_enabled);
emit enabledChanged();
}

View File

@ -24,20 +24,20 @@
#include <QtQml>
#include "DeclarativeDragArea.h"
#include "DeclarativeDragDropEvent.h"
#include "DeclarativeDropArea.h"
#include "DeclarativeMimeData.h"
// #include "DeclarativeDragArea.h"
// #include "DeclarativeDragDropEvent.h"
// #include "DeclarativeDropArea.h"
// #include "DeclarativeMimeData.h"
void DragAndDropPlugin::registerTypes(const char *uri)
{
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");
// qmlRegisterUncreatableType<DeclarativeMimeData>(uri, 1, 0, "MimeData", "MimeData 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
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void registerTypes(const char *uri);