tabs to spaces. fewer kittens are now being killed.
This commit is contained in:
parent
4c79f05a60
commit
a4e83dde8e
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DeclarativeDragArea.h"
|
#include "DeclarativeDragArea.h"
|
||||||
@ -32,29 +32,29 @@
|
|||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
A DragArea is used to make an item draggable.
|
A DragArea is used to make an item draggable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DeclarativeDragArea::DeclarativeDragArea(QDeclarativeItem *parent)
|
DeclarativeDragArea::DeclarativeDragArea(QDeclarativeItem *parent)
|
||||||
: QDeclarativeItem(parent),
|
: QDeclarativeItem(parent),
|
||||||
m_delegate(0),
|
m_delegate(0),
|
||||||
m_source(0),
|
m_source(0),
|
||||||
m_target(0),
|
m_target(0),
|
||||||
m_enabled(true),
|
m_enabled(true),
|
||||||
m_supportedActions(Qt::MoveAction),
|
m_supportedActions(Qt::MoveAction),
|
||||||
m_defaultAction(Qt::MoveAction),
|
m_defaultAction(Qt::MoveAction),
|
||||||
m_data(new DeclarativeMimeData()) // m_data is owned by us, and we shouldn't pass it to Qt directly as it will automatically delete it after the drag and drop.
|
m_data(new DeclarativeMimeData()) // m_data is owned by us, and we shouldn't pass it to Qt directly as it will automatically delete it after the drag and drop.
|
||||||
{
|
{
|
||||||
m_startDragDistance = QApplication::startDragDistance();
|
m_startDragDistance = QApplication::startDragDistance();
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
setFiltersChildEvents(true);
|
setFiltersChildEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeclarativeDragArea::~DeclarativeDragArea()
|
DeclarativeDragArea::~DeclarativeDragArea()
|
||||||
{
|
{
|
||||||
if (m_data) {
|
if (m_data) {
|
||||||
delete m_data;
|
delete m_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -63,18 +63,18 @@ DeclarativeDragArea::~DeclarativeDragArea()
|
|||||||
*/
|
*/
|
||||||
QDeclarativeComponent* DeclarativeDragArea::delegate() const
|
QDeclarativeComponent* DeclarativeDragArea::delegate() const
|
||||||
{
|
{
|
||||||
return m_delegate;
|
return m_delegate;
|
||||||
}
|
}
|
||||||
void DeclarativeDragArea::setDelegate(QDeclarativeComponent *delegate)
|
void DeclarativeDragArea::setDelegate(QDeclarativeComponent *delegate)
|
||||||
{
|
{
|
||||||
if (m_delegate != delegate) {
|
if (m_delegate != delegate) {
|
||||||
m_delegate = delegate;
|
m_delegate = delegate;
|
||||||
emit delegateChanged();
|
emit delegateChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void DeclarativeDragArea::resetDelegate()
|
void DeclarativeDragArea::resetDelegate()
|
||||||
{
|
{
|
||||||
setDelegate(0);
|
setDelegate(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -83,31 +83,31 @@ void DeclarativeDragArea::resetDelegate()
|
|||||||
*/
|
*/
|
||||||
QDeclarativeItem* DeclarativeDragArea::source() const
|
QDeclarativeItem* DeclarativeDragArea::source() const
|
||||||
{
|
{
|
||||||
return m_source;
|
return m_source;
|
||||||
}
|
}
|
||||||
void DeclarativeDragArea::setSource(QDeclarativeItem* source)
|
void DeclarativeDragArea::setSource(QDeclarativeItem* source)
|
||||||
{
|
{
|
||||||
if (m_source != source) {
|
if (m_source != source) {
|
||||||
m_source = source;
|
m_source = source;
|
||||||
emit sourceChanged();
|
emit sourceChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void DeclarativeDragArea::resetSource()
|
void DeclarativeDragArea::resetSource()
|
||||||
{
|
{
|
||||||
setSource(0);
|
setSource(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// target
|
// target
|
||||||
QDeclarativeItem* DeclarativeDragArea::target() const
|
QDeclarativeItem* DeclarativeDragArea::target() const
|
||||||
{
|
{
|
||||||
//TODO: implement me
|
//TODO: implement me
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// data
|
// data
|
||||||
DeclarativeMimeData* DeclarativeDragArea::mimeData() const
|
DeclarativeMimeData* DeclarativeDragArea::mimeData() const
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// startDragDistance
|
// startDragDistance
|
||||||
@ -150,82 +150,82 @@ void DeclarativeDragArea::setDelegateImage(const QVariant &image)
|
|||||||
// enabled
|
// enabled
|
||||||
bool DeclarativeDragArea::isEnabled() const
|
bool DeclarativeDragArea::isEnabled() const
|
||||||
{
|
{
|
||||||
return m_enabled;
|
return m_enabled;
|
||||||
}
|
}
|
||||||
void DeclarativeDragArea::setEnabled(bool enabled)
|
void DeclarativeDragArea::setEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled != m_enabled) {
|
if (enabled != m_enabled) {
|
||||||
m_enabled = enabled;
|
m_enabled = enabled;
|
||||||
emit enabledChanged();
|
emit enabledChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// supported actions
|
// supported actions
|
||||||
Qt::DropActions DeclarativeDragArea::supportedActions() const
|
Qt::DropActions DeclarativeDragArea::supportedActions() const
|
||||||
{
|
{
|
||||||
return m_supportedActions;
|
return m_supportedActions;
|
||||||
}
|
}
|
||||||
void DeclarativeDragArea::setSupportedActions(Qt::DropActions actions)
|
void DeclarativeDragArea::setSupportedActions(Qt::DropActions actions)
|
||||||
{
|
{
|
||||||
if (actions != m_supportedActions) {
|
if (actions != m_supportedActions) {
|
||||||
m_supportedActions = actions;
|
m_supportedActions = actions;
|
||||||
emit supportedActionsChanged();
|
emit supportedActionsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// default action
|
// default action
|
||||||
Qt::DropAction DeclarativeDragArea::defaultAction() const
|
Qt::DropAction DeclarativeDragArea::defaultAction() const
|
||||||
{
|
{
|
||||||
return m_defaultAction;
|
return m_defaultAction;
|
||||||
}
|
}
|
||||||
void DeclarativeDragArea::setDefaultAction(Qt::DropAction action)
|
void DeclarativeDragArea::setDefaultAction(Qt::DropAction action)
|
||||||
{
|
{
|
||||||
if (action != m_defaultAction) {
|
if (action != m_defaultAction) {
|
||||||
m_defaultAction = action;
|
m_defaultAction = action;
|
||||||
emit defaultActionChanged();
|
emit defaultActionChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if ( !m_enabled
|
if ( !m_enabled
|
||||||
|| QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton)).length()
|
|| QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton)).length()
|
||||||
< m_startDragDistance) {
|
< m_startDragDistance) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDrag *drag = new QDrag(event->widget());
|
QDrag *drag = new QDrag(event->widget());
|
||||||
DeclarativeMimeData* dataCopy = new DeclarativeMimeData(m_data); //Qt will take ownership of this copy and delete it.
|
DeclarativeMimeData* dataCopy = new DeclarativeMimeData(m_data); //Qt will take ownership of this copy and delete it.
|
||||||
drag->setMimeData(dataCopy);
|
drag->setMimeData(dataCopy);
|
||||||
|
|
||||||
if (!m_delegateImage.isNull()) {
|
if (!m_delegateImage.isNull()) {
|
||||||
drag->setPixmap(QPixmap::fromImage(m_delegateImage));
|
drag->setPixmap(QPixmap::fromImage(m_delegateImage));
|
||||||
} else if (m_delegate) {
|
} else if (m_delegate) {
|
||||||
|
|
||||||
// Render the delegate to a Pixmap
|
// Render the delegate to a Pixmap
|
||||||
|
|
||||||
QDeclarativeItem* item = qobject_cast<QDeclarativeItem *>(m_delegate->create());
|
QDeclarativeItem* item = qobject_cast<QDeclarativeItem *>(m_delegate->create());
|
||||||
|
|
||||||
QGraphicsScene scene;
|
QGraphicsScene scene;
|
||||||
scene.addItem(item);
|
scene.addItem(item);
|
||||||
|
|
||||||
QPixmap pixmap(scene.sceneRect().width(), scene.sceneRect().height());
|
QPixmap pixmap(scene.sceneRect().width(), scene.sceneRect().height());
|
||||||
pixmap.fill(Qt::transparent);
|
pixmap.fill(Qt::transparent);
|
||||||
|
|
||||||
QPainter painter(&pixmap);
|
QPainter painter(&pixmap);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
scene.render(&painter);
|
scene.render(&painter);
|
||||||
painter.end();
|
painter.end();
|
||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
drag->setPixmap(pixmap);
|
drag->setPixmap(pixmap);
|
||||||
drag->setHotSpot(QPoint(0, 0)); // TODO: Make a property for that
|
drag->setHotSpot(QPoint(0, 0)); // TODO: Make a property for that
|
||||||
}
|
}
|
||||||
|
|
||||||
//setCursor(Qt::OpenHandCursor); //TODO? Make a property for the cursor
|
//setCursor(Qt::OpenHandCursor); //TODO? Make a property for the cursor
|
||||||
|
|
||||||
Qt::DropAction action = drag->exec(m_supportedActions, m_defaultAction);
|
Qt::DropAction action = drag->exec(m_supportedActions, m_defaultAction);
|
||||||
emit drop(action);
|
emit drop(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeclarativeDragArea::sceneEventFilter(QGraphicsItem *item, QEvent *event)
|
bool DeclarativeDragArea::sceneEventFilter(QGraphicsItem *item, QEvent *event)
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DECLARATIVEDRAGAREA_H
|
#ifndef DECLARATIVEDRAGAREA_H
|
||||||
@ -86,62 +86,62 @@ class DeclarativeDragArea : public QDeclarativeItem
|
|||||||
Q_PROPERTY(QVariant delegateImage READ delegateImage WRITE setDelegateImage NOTIFY delegateImageChanged)
|
Q_PROPERTY(QVariant delegateImage READ delegateImage WRITE setDelegateImage NOTIFY delegateImageChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeclarativeDragArea(QDeclarativeItem *parent=0);
|
DeclarativeDragArea(QDeclarativeItem *parent=0);
|
||||||
~DeclarativeDragArea();
|
~DeclarativeDragArea();
|
||||||
|
|
||||||
QDeclarativeComponent *delegate() const;
|
QDeclarativeComponent *delegate() const;
|
||||||
void setDelegate(QDeclarativeComponent* delegate);
|
void setDelegate(QDeclarativeComponent* delegate);
|
||||||
void resetDelegate();
|
void resetDelegate();
|
||||||
|
|
||||||
QVariant delegateImage() const;
|
QVariant delegateImage() const;
|
||||||
void setDelegateImage(const QVariant &image);
|
void setDelegateImage(const QVariant &image);
|
||||||
QDeclarativeItem* target() const;
|
QDeclarativeItem* target() const;
|
||||||
QDeclarativeItem* source() const;
|
QDeclarativeItem* source() const;
|
||||||
void setSource(QDeclarativeItem* source);
|
void setSource(QDeclarativeItem* source);
|
||||||
void resetSource();
|
void resetSource();
|
||||||
|
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
void setEnabled(bool enabled);
|
void setEnabled(bool enabled);
|
||||||
|
|
||||||
int startDragDistance() const;
|
int startDragDistance() const;
|
||||||
void setStartDragDistance(int distance);
|
void setStartDragDistance(int distance);
|
||||||
|
|
||||||
//supported actions
|
//supported actions
|
||||||
Qt::DropActions supportedActions() const;
|
Qt::DropActions supportedActions() const;
|
||||||
void setSupportedActions(Qt::DropActions actions);
|
void setSupportedActions(Qt::DropActions actions);
|
||||||
|
|
||||||
//default action
|
//default action
|
||||||
Qt::DropAction defaultAction() const;
|
Qt::DropAction defaultAction() const;
|
||||||
void setDefaultAction(Qt::DropAction action);
|
void setDefaultAction(Qt::DropAction action);
|
||||||
|
|
||||||
DeclarativeMimeData* mimeData() const;
|
DeclarativeMimeData* mimeData() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void delegateChanged();
|
void delegateChanged();
|
||||||
void sourceChanged();
|
void sourceChanged();
|
||||||
void targetChanged();
|
void targetChanged();
|
||||||
void dataChanged();
|
void dataChanged();
|
||||||
void enabledChanged();
|
void enabledChanged();
|
||||||
void drop(int action);
|
void drop(int action);
|
||||||
void supportedActionsChanged();
|
void supportedActionsChanged();
|
||||||
void defaultActionChanged();
|
void defaultActionChanged();
|
||||||
void startDragDistanceChanged();
|
void startDragDistanceChanged();
|
||||||
void delegateImageChanged();
|
void delegateImageChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *) {}
|
void mousePressEvent(QGraphicsSceneMouseEvent *) {}
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) {}
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) {}
|
||||||
bool sceneEventFilter(QGraphicsItem *item, QEvent *event);
|
bool sceneEventFilter(QGraphicsItem *item, QEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDeclarativeComponent* m_delegate;
|
QDeclarativeComponent* m_delegate;
|
||||||
QDeclarativeItem* m_source;
|
QDeclarativeItem* m_source;
|
||||||
QDeclarativeItem* m_target;
|
QDeclarativeItem* m_target;
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
Qt::DropActions m_supportedActions;
|
Qt::DropActions m_supportedActions;
|
||||||
Qt::DropAction m_defaultAction;
|
Qt::DropAction m_defaultAction;
|
||||||
DeclarativeMimeData* const m_data;
|
DeclarativeMimeData* const m_data;
|
||||||
QImage m_delegateImage;
|
QImage m_delegateImage;
|
||||||
int m_startDragDistance;
|
int m_startDragDistance;
|
||||||
};
|
};
|
||||||
|
@ -1,42 +1,42 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DeclarativeDragDropEvent.h"
|
#include "DeclarativeDragDropEvent.h"
|
||||||
|
|
||||||
DeclarativeDragDropEvent::DeclarativeDragDropEvent(QGraphicsSceneDragDropEvent* e, QObject* parent) :
|
DeclarativeDragDropEvent::DeclarativeDragDropEvent(QGraphicsSceneDragDropEvent* e, QObject* 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(e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarativeDragDropEvent::accept(int action)
|
void DeclarativeDragDropEvent::accept(int action)
|
||||||
{
|
{
|
||||||
m_event->setDropAction( (Qt::DropAction) action );
|
m_event->setDropAction( (Qt::DropAction) action );
|
||||||
m_event->accept();
|
m_event->accept();
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DECLARATIVEDRAGDROPEVENT_H
|
#ifndef DECLARATIVEDRAGDROPEVENT_H
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DeclarativeDropArea.h"
|
#include "DeclarativeDropArea.h"
|
||||||
@ -28,41 +28,41 @@
|
|||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
DeclarativeDropArea::DeclarativeDropArea(QDeclarativeItem *parent)
|
DeclarativeDropArea::DeclarativeDropArea(QDeclarativeItem *parent)
|
||||||
: QDeclarativeItem(parent),
|
: QDeclarativeItem(parent),
|
||||||
m_enabled(true)
|
m_enabled(true)
|
||||||
{
|
{
|
||||||
setAcceptDrops(m_enabled);
|
setAcceptDrops(m_enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarativeDropArea::dragEnterEvent(QGraphicsSceneDragDropEvent *event) {
|
void DeclarativeDropArea::dragEnterEvent(QGraphicsSceneDragDropEvent *event) {
|
||||||
DeclarativeDragDropEvent dde(event, this);
|
DeclarativeDragDropEvent dde(event, this);
|
||||||
emit dragEnter(&dde);
|
emit dragEnter(&dde);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarativeDropArea::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
|
void DeclarativeDropArea::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
|
||||||
{
|
{
|
||||||
DeclarativeDragDropEvent dde(event, this);
|
DeclarativeDragDropEvent dde(event, this);
|
||||||
emit dragLeave(&dde);
|
emit dragLeave(&dde);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarativeDropArea::dropEvent(QGraphicsSceneDragDropEvent *event)
|
void DeclarativeDropArea::dropEvent(QGraphicsSceneDragDropEvent *event)
|
||||||
{
|
{
|
||||||
DeclarativeDragDropEvent dde(event, this);
|
DeclarativeDragDropEvent dde(event, this);
|
||||||
emit drop(&dde);
|
emit drop(&dde);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeclarativeDropArea::isEnabled() const
|
bool DeclarativeDropArea::isEnabled() const
|
||||||
{
|
{
|
||||||
return m_enabled;
|
return m_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarativeDropArea::setEnabled(bool enabled)
|
void DeclarativeDropArea::setEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled == m_enabled) {
|
if (enabled == m_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_enabled = enabled;
|
m_enabled = enabled;
|
||||||
setAcceptDrops(m_enabled);
|
setAcceptDrops(m_enabled);
|
||||||
emit enabledChanged();
|
emit enabledChanged();
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DECLARATIVEDROPAREA_H
|
#ifndef DECLARATIVEDROPAREA_H
|
||||||
|
@ -1,86 +1,86 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DeclarativeMimeData.h"
|
#include "DeclarativeMimeData.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\qmlclass MimeData DeclarativeMimeData
|
\qmlclass MimeData DeclarativeMimeData
|
||||||
|
|
||||||
This is a wrapper class around QMimeData, with a few extensions to provide better support for in-qml drag & drops.
|
This is a wrapper class around QMimeData, with a few extensions to provide better support for in-qml drag & drops.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
\class DeclarativeMimeData
|
\class DeclarativeMimeData
|
||||||
|
|
||||||
Creates a new DeclarativeMimeData by cloning the QMimeData passed as parameter.
|
Creates a new DeclarativeMimeData by cloning the QMimeData passed as parameter.
|
||||||
This is useful for two reasons :
|
This is useful for two reasons :
|
||||||
- In DragArea, we want to clone our "working copy" of the DeclarativeMimeData instance, as Qt will automatically
|
- In DragArea, we want to clone our "working copy" of the DeclarativeMimeData instance, as Qt will automatically
|
||||||
delete it after the drag and drop operation.
|
delete it after the drag and drop operation.
|
||||||
- In the drop events, the QMimeData is const, and we have troubles passing const to QML. So we clone it to
|
- In the drop events, the QMimeData is const, and we have troubles passing const to QML. So we clone it to
|
||||||
remove the "constness"
|
remove the "constness"
|
||||||
|
|
||||||
This method will try to cast the QMimeData to DeclarativeMimeData, and will clone our extensions to QMimeData as well
|
This method will try to cast the QMimeData to DeclarativeMimeData, and will clone our extensions to QMimeData as well
|
||||||
*/
|
*/
|
||||||
DeclarativeMimeData::DeclarativeMimeData(const QMimeData* copy)
|
DeclarativeMimeData::DeclarativeMimeData(const QMimeData* copy)
|
||||||
: QMimeData(),
|
: QMimeData(),
|
||||||
m_source(0)
|
m_source(0)
|
||||||
{
|
{
|
||||||
// Copy the standard MIME data
|
// Copy the standard MIME data
|
||||||
foreach(QString format, copy->formats()) {
|
foreach(QString format, copy->formats()) {
|
||||||
this->setData(format, copy->data(format));
|
this->setData(format, copy->data(format));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the object we are copying actually is a DeclarativeMimeData, copy our extended properties as well
|
// If the object we are copying actually is a DeclarativeMimeData, copy our extended properties as well
|
||||||
const DeclarativeMimeData* declarativeMimeData = qobject_cast<const DeclarativeMimeData*>(copy);
|
const DeclarativeMimeData* declarativeMimeData = qobject_cast<const DeclarativeMimeData*>(copy);
|
||||||
if (declarativeMimeData) {
|
if (declarativeMimeData) {
|
||||||
this->setSource(declarativeMimeData->source());
|
this->setSource(declarativeMimeData->source());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\qmlproperty url MimeData::url
|
\qmlproperty url MimeData::url
|
||||||
|
|
||||||
Returns the first URL from the urls property of QMimeData
|
Returns the first URL from the urls property of QMimeData
|
||||||
TODO: We should use QDeclarativeListProperty<QUrls> to return the whole list instead of only the first element.
|
TODO: We should use QDeclarativeListProperty<QUrls> to return the whole list instead of only the first element.
|
||||||
*/
|
*/
|
||||||
QUrl DeclarativeMimeData::url() const
|
QUrl DeclarativeMimeData::url() const
|
||||||
{
|
{
|
||||||
if ( this->hasUrls() && !this->urls().isEmpty()) {
|
if ( this->hasUrls() && !this->urls().isEmpty()) {
|
||||||
return QMimeData::urls().first();
|
return QMimeData::urls().first();
|
||||||
}
|
}
|
||||||
return QUrl();
|
return QUrl();
|
||||||
}
|
}
|
||||||
void DeclarativeMimeData::setUrl(const QUrl &url)
|
void DeclarativeMimeData::setUrl(const QUrl &url)
|
||||||
{
|
{
|
||||||
if (this->url() == url)
|
if (this->url() == url)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QList<QUrl> urlList;
|
QList<QUrl> urlList;
|
||||||
urlList.append(url);
|
urlList.append(url);
|
||||||
QMimeData::setUrls(urlList);
|
QMimeData::setUrls(urlList);
|
||||||
emit urlChanged();
|
emit urlChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList DeclarativeMimeData::urls() const
|
QVariantList DeclarativeMimeData::urls() const
|
||||||
@ -105,17 +105,17 @@ void DeclarativeMimeData::setUrls(const QVariantList &urls)
|
|||||||
// color
|
// color
|
||||||
QColor DeclarativeMimeData::color() const
|
QColor DeclarativeMimeData::color() const
|
||||||
{
|
{
|
||||||
if ( this->hasColor()) {
|
if ( this->hasColor()) {
|
||||||
return qvariant_cast<QColor>(this->colorData());
|
return qvariant_cast<QColor>(this->colorData());
|
||||||
}
|
}
|
||||||
return QColor();
|
return QColor();
|
||||||
}
|
}
|
||||||
void DeclarativeMimeData::setColor(const QColor &color)
|
void DeclarativeMimeData::setColor(const QColor &color)
|
||||||
{
|
{
|
||||||
if (this->color() != color) {
|
if (this->color() != color) {
|
||||||
this->setColorData(color);
|
this->setColorData(color);
|
||||||
emit colorChanged();
|
emit colorChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarativeMimeData::setData(const QString &mimeType, const QString &data)
|
void DeclarativeMimeData::setData(const QString &mimeType, const QString &data)
|
||||||
@ -134,12 +134,12 @@ void DeclarativeMimeData::setData(const QString &mimeType, const QString &data)
|
|||||||
*/
|
*/
|
||||||
QDeclarativeItem* DeclarativeMimeData::source() const
|
QDeclarativeItem* DeclarativeMimeData::source() const
|
||||||
{
|
{
|
||||||
return m_source;
|
return m_source;
|
||||||
}
|
}
|
||||||
void DeclarativeMimeData::setSource(QDeclarativeItem* source)
|
void DeclarativeMimeData::setSource(QDeclarativeItem* source)
|
||||||
{
|
{
|
||||||
if (m_source != source) {
|
if (m_source != source) {
|
||||||
m_source = source;
|
m_source = source;
|
||||||
emit sourceChanged();
|
emit sourceChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
|
||||||
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
Original author: Gregory Schlomoff <greg@betterinbox.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DECLARATIVEMIMEDATA_H
|
#ifndef DECLARATIVEMIMEDATA_H
|
||||||
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
class DeclarativeMimeData : public QMimeData
|
class DeclarativeMimeData : public QMimeData
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A plain text (MIME type text/plain) representation of the data.
|
* A plain text (MIME type text/plain) representation of the data.
|
||||||
@ -63,41 +63,41 @@ class DeclarativeMimeData : public QMimeData
|
|||||||
* The graphical item on the scene that started the drag event. It may be null.
|
* The graphical item on the scene that started the drag event. It may be null.
|
||||||
*/
|
*/
|
||||||
Q_PROPERTY(QDeclarativeItem* source READ source WRITE setSource NOTIFY sourceChanged)
|
Q_PROPERTY(QDeclarativeItem* source READ source WRITE setSource NOTIFY sourceChanged)
|
||||||
//TODO: Image property
|
//TODO: Image property
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeclarativeMimeData() : QMimeData() {}
|
DeclarativeMimeData() : QMimeData() {}
|
||||||
DeclarativeMimeData(const QMimeData* copy);
|
DeclarativeMimeData(const QMimeData* copy);
|
||||||
|
|
||||||
QUrl url() const;
|
QUrl url() const;
|
||||||
void setUrl(const QUrl &url);
|
void setUrl(const QUrl &url);
|
||||||
|
|
||||||
QVariantList urls() const;
|
QVariantList urls() const;
|
||||||
void setUrls(const QVariantList &urls);
|
void setUrls(const QVariantList &urls);
|
||||||
|
|
||||||
QColor color() const;
|
QColor color() const;
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
|
|
||||||
Q_INVOKABLE void setData(const QString &mimeType, const QString &data);
|
Q_INVOKABLE void setData(const QString &mimeType, const QString &data);
|
||||||
|
|
||||||
QDeclarativeItem* source() const;
|
QDeclarativeItem* source() const;
|
||||||
void setSource(QDeclarativeItem* source);
|
void setSource(QDeclarativeItem* source);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QString text() const; //TODO: Reimplement this to issue the onChanged signals
|
QString text() const; //TODO: Reimplement this to issue the onChanged signals
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
QString html() const;
|
QString html() const;
|
||||||
void setHtml(const QString &html);
|
void setHtml(const QString &html);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void textChanged(); //FIXME not being used
|
void textChanged(); //FIXME not being used
|
||||||
void htmlChanged(); //FIXME not being used
|
void htmlChanged(); //FIXME not being used
|
||||||
void urlChanged();
|
void urlChanged();
|
||||||
void urlsChanged();
|
void urlsChanged();
|
||||||
void colorChanged();
|
void colorChanged();
|
||||||
void sourceChanged();
|
void sourceChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDeclarativeItem* m_source;
|
QDeclarativeItem* m_source;
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2011 by Marco Martin <mart@kde.org>
|
Copyright 2011 by Marco Martin <mart@kde.org>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "draganddropplugin.h"
|
#include "draganddropplugin.h"
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2011 by Marco Martin <mart@kde.org>
|
Copyright 2011 by Marco Martin <mart@kde.org>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DRAGANDDROPPLUGIN_H
|
#ifndef DRAGANDDROPPLUGIN_H
|
||||||
@ -27,10 +27,10 @@
|
|||||||
|
|
||||||
class DragAndDropPlugin : public QDeclarativeExtensionPlugin
|
class DragAndDropPlugin : public QDeclarativeExtensionPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void registerTypes(const char *uri);
|
void registerTypes(const char *uri);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user