[Marble-commits] KDE/kdeedu/marble/src
Bastian Holst
bastianholst at gmx.de
Tue Aug 18 13:55:16 CEST 2009
SVN commit 1012921 by bholst:
Work on Marbles GraphicsItems and PhotoPluginItem:
* PhotoPluginItem now uses LabelGraphicsItem.
* LabelGraphicsItem now paints on the correct position.
M +0 -3 lib/AbstractDataPluginItem.h
M +1 -1 lib/graphicsview/FrameGraphicsItem.cpp
M +0 -6 lib/graphicsview/GeoGraphicsItem.h
M +5 -3 lib/graphicsview/LabelGraphicsItem.cpp
M +9 -0 lib/graphicsview/MarbleGraphicsItem.cpp
M +4 -4 lib/graphicsview/MarbleGraphicsItem.h
M +0 -6 lib/graphicsview/ScreenGraphicsItem.h
M +13 -12 plugins/render/photo/PhotoPluginItem.cpp
M +5 -6 plugins/render/photo/PhotoPluginItem.h
M +0 -9 plugins/render/weather/WeatherItem.cpp
M +0 -3 plugins/render/weather/WeatherItem.h
--- trunk/KDE/kdeedu/marble/src/lib/AbstractDataPluginItem.h #1012920:1012921
@@ -74,9 +74,6 @@
virtual bool initialized() = 0;
virtual void addDownloadedFile( const QString& url, const QString& type );
-
- virtual void paint( GeoPainter *painter, ViewportParams *viewport,
- const QString& renderPos, GeoSceneLayer * layer = 0 ) = 0;
virtual bool isGeoProjected();
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/FrameGraphicsItem.cpp #1012920:1012921
@@ -260,7 +260,7 @@
painter->save();
painter->translate( paintedRect( QPointF( 0.0, 0.0 ) ).topLeft() );
paintBackground( painter );
- painter->translate( padding(), padding() );
+ painter->translate( d->m_padding, d->m_padding );
paintContent( painter, viewport, renderPos, layer );
painter->restore();
}
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/GeoGraphicsItem.h #1012920:1012921
@@ -144,12 +144,6 @@
*/
QList<QPointF> positions() const;
- /**
- * Paints the item in item coordinates
- */
- virtual void paint( GeoPainter *painter, ViewportParams *viewport,
- const QString& renderPos, GeoSceneLayer * layer = 0 ) = 0;
-
protected:
explicit GeoGraphicsItem( GeoGraphicsItemPrivate *d_ptr );
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/LabelGraphicsItem.cpp #1012920:1012921
@@ -149,16 +149,18 @@
if ( !d->m_text.isNull() ) {
painter->setFont( d->font() );
painter->setPen( QColor( Qt::black ) );
- painter->drawText( contentRect().toRect(),
+ painter->drawText( QRect( QPoint( 0, 0 ), contentSize().toSize() ),
Qt::AlignVCenter | Qt::AlignLeft,
d->m_text );
}
else if ( !d->m_image.isNull() ) {
- painter->drawImage( contentRect(),
+ painter->drawImage( QRectF( QPointF( 0, 0 ), contentSize() ),
d->m_image );
}
else if ( !d->m_icon.isNull() ) {
- d->m_icon.paint( painter, contentRect().toRect(), Qt::AlignCenter );
+ d->m_icon.paint( painter,
+ QRect( QPoint( 0, 0 ), contentSize().toSize() ),
+ Qt::AlignCenter );
}
painter->restore();
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/MarbleGraphicsItem.cpp #1012920:1012921
@@ -251,6 +251,15 @@
p()->m_toolTip = toolTip;
}
+void MarbleGraphicsItem::paint( GeoPainter *painter, ViewportParams *viewport,
+ const QString& renderPos, GeoSceneLayer * layer )
+{
+ Q_UNUSED( viewport );
+ Q_UNUSED( renderPos );
+ Q_UNUSED( layer );
+ Q_UNUSED( painter );
+}
+
bool MarbleGraphicsItem::eventFilter( QObject *object, QEvent *e )
{
Q_UNUSED( object );
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/MarbleGraphicsItem.h #1012920:1012921
@@ -154,15 +154,15 @@
*/
virtual QRectF contentRect() const;
- protected:
- explicit MarbleGraphicsItem( MarbleGraphicsItemPrivate *d_ptr );
-
/**
* Paints the item in item coordinates. This has to be reimplemented by the subclass
* This function will be called by paintEvent().
*/
virtual void paint( GeoPainter *painter, ViewportParams *viewport,
- const QString& renderPos, GeoSceneLayer * layer = 0 ) = 0;
+ const QString& renderPos, GeoSceneLayer * layer = 0 );
+
+ protected:
+ explicit MarbleGraphicsItem( MarbleGraphicsItemPrivate *d_ptr );
virtual bool eventFilter( QObject *object, QEvent *e );
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/ScreenGraphicsItem.h #1012920:1012921
@@ -89,12 +89,6 @@
* be disabled. By default all flags are disabled.
*/
void setFlags( GraphicsItemFlags flags );
-
- /**
- * Paints the item in item coordinates
- */
- virtual void paint( GeoPainter *painter, ViewportParams *viewport,
- const QString& renderPos, GeoSceneLayer * layer = 0 ) = 0;
protected:
explicit ScreenGraphicsItem( ScreenGraphicsItemPrivate *d_ptr );
--- trunk/KDE/kdeedu/marble/src/plugins/render/photo/PhotoPluginItem.cpp #1012920:1012921
@@ -20,6 +20,8 @@
#include "AbstractDataPluginItem.h"
#include "GeoDataCoordinates.h"
#include "GeoPainter.h"
+#include "LabelGraphicsItem.h"
+#include "MarbleGraphicsGridLayout.h"
#include "TinyWebBrowser.h"
#include "ViewportParams.h"
@@ -31,11 +33,13 @@
#include <QtCore/QHash>
#include <QtCore/QUrl>
#include <QtGui/QMouseEvent>
+#include <QtGui/QPixmap>
using namespace Marble;
PhotoPluginItem::PhotoPluginItem( QObject *parent )
: AbstractDataPluginItem( parent ),
+ m_image( 0 ),
m_hasCoordinates( false ),
m_browser( 0 )
{
@@ -66,8 +70,15 @@
void PhotoPluginItem::addDownloadedFile( const QString& url, const QString& type )
{
if( type == "thumbnail" ) {
+ if ( !m_image ) {
+ m_image = new LabelGraphicsItem( this );
+ m_image->setFrame( FrameGraphicsItem::RectFrame );
+ MarbleGraphicsGridLayout *layout = new MarbleGraphicsGridLayout( 1, 1 );
+ layout->addItem( m_image, 0, 0 );
+ setLayout( layout );
+ }
m_smallImage.load( url );
- setSize( m_smallImage.size() );
+ m_image->setImage( m_smallImage );
}
else if ( type == "info" ) {
QFile file( url );
@@ -88,16 +99,6 @@
emit updated();
}
}
-
-void PhotoPluginItem::paint( GeoPainter *painter, ViewportParams *viewport,
- const QString& renderPos, GeoSceneLayer * layer )
-{
- Q_UNUSED( renderPos )
- Q_UNUSED( layer )
- Q_UNUSED( viewport )
-
- painter->drawPixmap( 0, 0, m_smallImage );
-}
bool PhotoPluginItem::operator<( const AbstractDataPluginItem *other ) const
{
@@ -174,7 +175,7 @@
QAction *PhotoPluginItem::action()
{
if( m_action->icon().isNull() ) {
- m_action->setIcon( QIcon( m_smallImage ) );
+ m_action->setIcon( QIcon( QPixmap::fromImage( m_smallImage ) ) );
}
return m_action;
}
--- trunk/KDE/kdeedu/marble/src/plugins/render/photo/PhotoPluginItem.h #1012920:1012921
@@ -13,7 +13,7 @@
#include "AbstractDataPluginItem.h"
-#include <QtGui/QPixmap>
+#include <QtGui/QImage>
class QAction;
class QUrl;
@@ -21,6 +21,7 @@
namespace Marble
{
+class LabelGraphicsItem;
class TinyWebBrowser;
class PhotoPluginItem : public AbstractDataPluginItem
@@ -37,9 +38,6 @@
bool initialized();
void addDownloadedFile( const QString& url, const QString& type );
-
- void paint( GeoPainter *painter, ViewportParams *viewport,
- const QString& renderPos, GeoSceneLayer * layer = 0 );
bool operator<( const AbstractDataPluginItem *other ) const;
@@ -73,9 +71,10 @@
void openBrowser();
private:
+ LabelGraphicsItem *m_image;
bool m_hasCoordinates;
- QPixmap m_smallImage;
- QPixmap m_microImage;
+ QImage m_smallImage;
+ QImage m_microImage;
TinyWebBrowser *m_browser;
QAction *m_action;
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/WeatherItem.cpp #1012920:1012921
@@ -311,15 +311,6 @@
|| d->isWindSpeedShown();
}
-void WeatherItem::paint( GeoPainter *painter, ViewportParams *viewport,
- const QString& renderPos, GeoSceneLayer * layer )
-{
- Q_UNUSED( viewport );
- Q_UNUSED( renderPos );
- Q_UNUSED( layer );
- Q_UNUSED( painter );
-}
-
bool WeatherItem::operator<( const AbstractDataPluginItem *other ) const
{
const WeatherItem *weatherItem = qobject_cast<const WeatherItem *>(other);
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/WeatherItem.h #1012920:1012921
@@ -59,9 +59,6 @@
bool initialized();
virtual void addDownloadedFile( const QString& url, const QString& type ) = 0;
-
- void paint( GeoPainter *painter, ViewportParams *viewport,
- const QString& renderPos, GeoSceneLayer * layer = 0 );
bool operator<( const AbstractDataPluginItem *other ) const;
More information about the Marble-commits
mailing list