summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-09-08 16:35:08 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-09-08 20:05:12 (GMT)
commit567b7c1002e4525c6a843f568ce996ca36b7c85c (patch)
tree2adb4efcff4d2edb3c33f32713c063005ef77aa5
parent6f21c01ffb7d5bd05d9dd94844c855fd4894d7a5 (diff)
Remove outdated AbstractDataPlugin::setDelegate(QtQuick stuff)
Summary: * subclass DeclarativeDataPlugin replaced that need * allows to drop dep of libmarblewidget to Qt5::Quick again Follow-up for c9bf0b7712e127b5339b962c28aa469312320cf5 Reviewers: sanjibanb, nienhueser, #marble Reviewed By: nienhueser, #marble Differential Revision: https://phabricator.kde.org/D2714
-rw-r--r--src/lib/marble/AbstractDataPlugin.cpp136
-rw-r--r--src/lib/marble/AbstractDataPlugin.h8
-rw-r--r--src/lib/marble/CMakeLists.txt1
-rw-r--r--src/lib/marble/MarbleConfig.cmake.in2
-rw-r--r--src/lib/marble/declarative/DeclarativeDataPlugin.h3
5 files changed, 10 insertions, 140 deletions
diff --git a/src/lib/marble/AbstractDataPlugin.cpp b/src/lib/marble/AbstractDataPlugin.cpp
index 14f7894..b770119 100644
--- a/src/lib/marble/AbstractDataPlugin.cpp
+++ b/src/lib/marble/AbstractDataPlugin.cpp
@@ -23,9 +23,6 @@
// Qt
#include <QTimer>
#include <QRegion>
-#include <QQmlComponent>
-#include <QQmlContext>
-#include <QQuickItem>
namespace Marble
{
@@ -35,9 +32,7 @@ class AbstractDataPluginPrivate
public:
AbstractDataPluginPrivate()
: m_model( 0 ),
- m_numberOfItems( 10 ),
- m_delegate( 0 ),
- m_delegateParent( 0 )
+ m_numberOfItems( 10 )
{
m_updateTimer.setSingleShot( true );
}
@@ -48,9 +43,6 @@ class AbstractDataPluginPrivate
AbstractDataPluginModel *m_model;
quint32 m_numberOfItems;
- QQmlComponent* m_delegate;
- QQuickItem* m_delegateParent;
- QMap<AbstractDataPluginItem*,QQuickItem*> m_delegateInstances;
QTimer m_updateTimer;
};
@@ -92,20 +84,16 @@ bool AbstractDataPlugin::render( GeoPainter *painter, ViewportParams *viewport,
Q_UNUSED( renderPos );
Q_UNUSED( layer );
- if ( d->m_delegate ) {
- handleViewportChange( viewport );
- } else {
- QList<AbstractDataPluginItem*> items = d->m_model->items( viewport, numberOfItems() );
- painter->save();
+ QList<AbstractDataPluginItem*> items = d->m_model->items( viewport, numberOfItems() );
+ painter->save();
- // Paint the most important item at last
- for( int i = items.size() - 1; i >= 0; --i ) {
- items.at( i )->paintEvent( painter, viewport );
- }
-
- painter->restore();
+ // Paint the most important item at last
+ for( int i = items.size() - 1; i >= 0; --i ) {
+ items.at( i )->paintEvent( painter, viewport );
}
-
+
+ painter->restore();
+
return true;
}
@@ -165,15 +153,6 @@ RenderPlugin::RenderType AbstractDataPlugin::renderType() const
return OnlineRenderType;
}
-void AbstractDataPlugin::setDelegate( QQmlComponent *delegate, QQuickItem* parent )
-{
- qDeleteAll( d->m_delegateInstances.values() );
- d->m_delegateInstances.clear();
-
- d->m_delegate = delegate;
- d->m_delegateParent = parent;
-}
-
void AbstractDataPlugin::setFavoriteItemsOnly( bool favoriteOnly )
{
if ( d->m_model && d->m_model->isFavoriteItemsOnly() != favoriteOnly ) {
@@ -191,103 +170,6 @@ QObject *AbstractDataPlugin::favoritesModel()
return d->m_model ? d->m_model->favoritesModel() : 0;
}
-void AbstractDataPlugin::handleViewportChange( const ViewportParams *viewport )
-{
- QList<AbstractDataPluginItem*> orphane = d->m_delegateInstances.keys();
- QList<AbstractDataPluginItem*> const items = d->m_model->items( viewport, numberOfItems() );
- foreach( AbstractDataPluginItem* item, items ) {
- qreal x, y;
- Marble::GeoDataCoordinates const coordinates = item->coordinate();
- bool const visible = viewport->screenCoordinates( coordinates.longitude(), coordinates.latitude(), x, y );
-
- if ( !d->m_delegateInstances.contains( item ) ) {
- if ( !visible ) {
- // We don't have, but don't need it either. Shouldn't happen though as the model checks for it already.
- continue;
- }
-
- // Create a new QML object instance using the delegate as the factory. The original
- // data plugin item is set as the context object, i.e. all its properties are available
- // to QML directly with their names
- QQmlContext *context = new QQmlContext( qmlContext( d->m_delegate ) );
- context->setContextObject( item );
- QList<QByteArray> const dynamicProperties = item->dynamicPropertyNames();
- foreach( const QByteArray &property, dynamicProperties ) {
- context->setContextProperty(property, item->property(property.constData()));
- }
-
- QObject* component = d->m_delegate->create( context );
- QQuickItem* newItem = qobject_cast<QQuickItem*>( component );
-
- if ( newItem ) {
- newItem->setParentItem( d->m_delegateParent );
- d->m_delegateInstances[item] = newItem;
- } else {
- mDebug() << "Failed to create delegate";
- continue;
- }
- } else if ( !visible ) {
- // Previously visible but not anymore => needs to be deleted. Orphane list takes care of it later.
- // Shouldn't happen though as the model checks for it already.
- continue;
- }
-
- Q_ASSERT( visible );
- QQuickItem* declarativeItem = d->m_delegateInstances[item];
- Q_ASSERT( declarativeItem );
-
- // Make sure we have a valid bounding rect for collision detection
- item->setProjection( viewport );
- item->setSize(QSizeF(declarativeItem->width(), declarativeItem->height()));
-
- int shiftX( 0 ), shiftY( 0 );
- switch( declarativeItem->transformOrigin() ) {
- case QQuickItem::TopLeft:
- case QQuickItem::Top:
- case QQuickItem::TopRight:
- break;
- case QQuickItem::Left:
- case QQuickItem::Center:
- case QQuickItem::Right:
- shiftY = declarativeItem->height() / 2;
- break;
- case QQuickItem::BottomLeft:
- case QQuickItem::Bottom:
- case QQuickItem::BottomRight:
- shiftY = declarativeItem->height();
- break;
- }
-
- switch( declarativeItem->transformOrigin() ) {
- case QQuickItem::TopLeft:
- case QQuickItem::Left:
- case QQuickItem::BottomLeft:
- break;
- case QQuickItem::Top:
- case QQuickItem::Center:
- case QQuickItem::Bottom:
- shiftX = declarativeItem->width() / 2;
- break;
- case QQuickItem::TopRight:
- case QQuickItem::Right:
- case QQuickItem::BottomRight:
- shiftX = declarativeItem->width();
- break;
- }
-
- declarativeItem->setX( x - shiftX );
- declarativeItem->setY( y - shiftY );
- orphane.removeOne( item );
- }
-
- // Cleanup
- foreach( AbstractDataPluginItem* item, orphane ) {
- Q_ASSERT( d->m_delegateInstances.contains( item ) );
- delete d->m_delegateInstances[item];
- d->m_delegateInstances.remove( item );
- }
-}
-
void AbstractDataPlugin::favoriteItemsChanged( const QStringList& favoriteItems )
{
Q_UNUSED( favoriteItems )
diff --git a/src/lib/marble/AbstractDataPlugin.h b/src/lib/marble/AbstractDataPlugin.h
index d32b7c7..8d84975 100644
--- a/src/lib/marble/AbstractDataPlugin.h
+++ b/src/lib/marble/AbstractDataPlugin.h
@@ -15,9 +15,6 @@
#include "marble_export.h"
#include "RenderPlugin.h"
-class QQmlComponent;
-class QQuickItem;
-
namespace Marble
{
@@ -113,17 +110,12 @@ class MARBLE_EXPORT AbstractDataPlugin : public RenderPlugin
*/
virtual RenderType renderType() const;
- void setDelegate(QQmlComponent* delegate, QQuickItem *parent );
-
/** Convenience method to set the favorite item state on the current model */
void setFavoriteItemsOnly( bool favoriteOnly );
bool isFavoriteItemsOnly() const;
QObject* favoritesModel();
-
-public Q_SLOTS:
- void handleViewportChange( const ViewportParams *viewport );
private Q_SLOTS:
virtual void favoriteItemsChanged( const QStringList& favoriteItems );
diff --git a/src/lib/marble/CMakeLists.txt b/src/lib/marble/CMakeLists.txt
index 475513b..8984dbe 100644
--- a/src/lib/marble/CMakeLists.txt
+++ b/src/lib/marble/CMakeLists.txt
@@ -379,7 +379,6 @@ target_link_libraries(marblewidget
Qt5::Xml
Qt5::Gui
Qt5::Widgets
- Qt5::Quick
LINK_PRIVATE
Qt5::Svg
Qt5::Script
diff --git a/src/lib/marble/MarbleConfig.cmake.in b/src/lib/marble/MarbleConfig.cmake.in
index 6e56a74..0f562d1 100644
--- a/src/lib/marble/MarbleConfig.cmake.in
+++ b/src/lib/marble/MarbleConfig.cmake.in
@@ -3,14 +3,12 @@
set(MARBLE_NO_WEBKITWIDGETS @MARBLE_NO_WEBKITWIDGETS@)
if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.13)
- find_dependency(Qt5Quick @REQUIRED_QT_VERSION@)
find_dependency(Qt5Xml @REQUIRED_QT_VERSION@)
find_dependency(Qt5Widgets @REQUIRED_QT_VERSION@)
if (NOT MARBLE_NO_WEBKITWIDGETS)
find_dependency(Qt5WebKitWidgets @REQUIRED_QT_VERSION@)
endif()
else()
- find_package(Qt5Quick REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5Widgets REQUIRED)
if (NOT MARBLE_NO_WEBKITWIDGETS)
diff --git a/src/lib/marble/declarative/DeclarativeDataPlugin.h b/src/lib/marble/declarative/DeclarativeDataPlugin.h
index 8a9082d..4c8fb59 100644
--- a/src/lib/marble/declarative/DeclarativeDataPlugin.h
+++ b/src/lib/marble/declarative/DeclarativeDataPlugin.h
@@ -14,9 +14,8 @@
#define DECLARATIVEDATAPLUGIN_H
#include "AbstractDataPlugin.h"
-#include "RenderPlugin.h"
-#include "RenderPluginInterface.h"
+#include <QQmlComponent>
#include <QStringList>
class DeclarativeDataPluginPrivate;