[Marble-commits] KDE/kdeedu/marble/src/lib
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Mon Feb 28 20:05:18 CET 2011
SVN commit 1223153 by beschow:
cleanup: merge MarbleWidget*InputHandler::init() into respective constructors
M +2 -3 MarbleWidget.cpp
M +48 -59 MarbleWidgetInputHandler.cpp
M +2 -6 MarbleWidgetInputHandler.h
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #1223152:1223153
@@ -238,7 +238,7 @@
m_widget->connect( m_model->sunLocator(), SIGNAL( centerSun() ),
m_widget, SLOT( centerSun() ) );
- m_widget->setInputHandler( new MarbleWidgetDefaultInputHandler );
+ m_widget->setInputHandler( new MarbleWidgetDefaultInputHandler( m_widget ) );
m_widget->setMouseTracking( m_widget );
m_routingLayer = new RoutingLayer( m_widget, m_widget );
@@ -302,7 +302,6 @@
d->m_inputhandler = handler;
if ( d->m_inputhandler ) {
- d->m_inputhandler->init( this );
installEventFilter( d->m_inputhandler );
connect( d->m_inputhandler, SIGNAL( mouseClickScreenPosition( int, int ) ),
@@ -1214,7 +1213,7 @@
if ( enabled )
{
if ( !d->m_inputhandler ) {
- setInputHandler( new MarbleWidgetDefaultInputHandler );
+ setInputHandler( new MarbleWidgetDefaultInputHandler( this ) );
}
else {
installEventFilter( d->m_inputhandler );
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidgetInputHandler.cpp #1223152:1223153
@@ -50,19 +50,19 @@
class MarbleWidgetInputHandler::Protected
{
public:
- Protected();
+ Protected( MarbleWidget *widget );
- MarbleWidget *m_widget;
- MarbleModel *m_model;
+ MarbleWidget *const m_widget;
+ MarbleModel *const m_model;
bool m_positionSignalConnected;
QTimer *m_mouseWheelTimer;
Qt::MouseButtons m_disabledMouseButtons;
qreal m_wheelZoomTargetDistance;
};
-MarbleWidgetInputHandler::Protected::Protected()
- : m_widget( 0 ),
- m_model( 0 ),
+MarbleWidgetInputHandler::Protected::Protected( MarbleWidget *widget )
+ : m_widget( widget ),
+ m_model( widget->model() ),
m_positionSignalConnected( false ),
m_mouseWheelTimer( 0 ),
m_disabledMouseButtons( Qt::NoButton ),
@@ -71,13 +71,21 @@
}
-MarbleWidgetInputHandler::MarbleWidgetInputHandler()
- : d( new Protected )
+MarbleWidgetInputHandler::MarbleWidgetInputHandler( MarbleWidget *widget )
+ : d( new Protected( widget ) )
{
d->m_mouseWheelTimer = new QTimer( this );
connect( d->m_mouseWheelTimer, SIGNAL( timeout() ),
this, SLOT( restoreViewContext() ) );
+
+ connect( d->m_widget, SIGNAL( renderPluginInitialized( RenderPlugin * ) ),
+ this, SLOT( installPluginEventFilter( RenderPlugin * ) ) );
+
+ foreach( RenderPlugin *renderPlugin, d->m_widget->renderPlugins() ) {
+ if( renderPlugin->isInitialized() )
+ d->m_widget->installEventFilter( renderPlugin );
}
+}
MarbleWidgetInputHandler::~MarbleWidgetInputHandler()
{
@@ -95,20 +103,6 @@
return d->m_positionSignalConnected;
}
-void MarbleWidgetInputHandler::init( MarbleWidget *w )
-{
- d->m_widget = w;
- d->m_model = w->model();
-
- connect( d->m_widget, SIGNAL( renderPluginInitialized( RenderPlugin * ) ),
- this, SLOT( installPluginEventFilter( RenderPlugin * ) ) );
-
- foreach( RenderPlugin *renderPlugin, d->m_widget->renderPlugins() ) {
- if( renderPlugin->isInitialized() )
- d->m_widget->installEventFilter( renderPlugin );
- }
-}
-
void MarbleWidgetInputHandler::setMouseButtonPopupEnabled( Qt::MouseButton mouseButton, bool enabled )
{
if ( enabled ) {
@@ -291,8 +285,8 @@
marbleWidget->flyTo( lookAt );
}
-MarbleWidgetDefaultInputHandler::MarbleWidgetDefaultInputHandler()
- : MarbleWidgetInputHandler(), d( new Private )
+MarbleWidgetDefaultInputHandler::MarbleWidgetDefaultInputHandler( MarbleWidget *widget )
+ : MarbleWidgetInputHandler( widget ), d( new Private )
{
d->m_selectionRubber = new QRubberBand( QRubberBand::Rectangle,
MarbleWidgetInputHandler::d->m_widget );
@@ -303,42 +297,7 @@
connect( &d->m_toolTipTimer, SIGNAL( timeout() ), this, SLOT( openItemToolTip() ) );
d->m_lmbTimer.setSingleShot(true);
connect( &d->m_lmbTimer, SIGNAL(timeout()), this, SLOT(lmbTimeout()));
-}
-MarbleWidgetDefaultInputHandler::~MarbleWidgetDefaultInputHandler()
-{
- // FIXME: move to Private
- delete d->m_selectionRubber;
- delete d;
-}
-
-void MarbleWidgetDefaultInputHandler::lmbTimeout()
-{
- if (!d->m_selectionRubber->isVisible()) {
- emit lmbRequest( d->m_leftPressedX, d->m_leftPressedY );
- }
-}
-
-void MarbleWidgetInputHandler::restoreViewContext()
-{
- // Needs to stop the timer since it repeats otherwise.
- d->m_mouseWheelTimer->stop();
-
- // Redraw the map with the quality set for Still (if necessary).
- d->m_widget->setViewContext( Still );
- d->m_widget->viewport()->resetFocusPoint();
- d->m_wheelZoomTargetDistance = 0.0;
-}
-
-void MarbleWidgetInputHandler::installPluginEventFilter( RenderPlugin *renderPlugin )
-{
- d->m_widget->installEventFilter( renderPlugin );
-}
-
-void MarbleWidgetDefaultInputHandler::init( MarbleWidget *w )
-{
- MarbleWidgetInputHandler::init( w );
-
// The interface to the measure tool consists of a RMB popup menu
// and some signals.
MeasureTool *measureTool = MarbleWidgetInputHandler::d->m_widget->measureTool();
@@ -375,6 +334,36 @@
this, SLOT( showLmbMenu( int, int ) ) );
}
+MarbleWidgetDefaultInputHandler::~MarbleWidgetDefaultInputHandler()
+{
+ // FIXME: move to Private
+ delete d->m_selectionRubber;
+ delete d;
+}
+
+void MarbleWidgetDefaultInputHandler::lmbTimeout()
+{
+ if (!d->m_selectionRubber->isVisible()) {
+ emit lmbRequest( d->m_leftPressedX, d->m_leftPressedY );
+ }
+}
+
+void MarbleWidgetInputHandler::restoreViewContext()
+{
+ // Needs to stop the timer since it repeats otherwise.
+ d->m_mouseWheelTimer->stop();
+
+ // Redraw the map with the quality set for Still (if necessary).
+ d->m_widget->setViewContext( Still );
+ d->m_widget->viewport()->resetFocusPoint();
+ d->m_wheelZoomTargetDistance = 0.0;
+}
+
+void MarbleWidgetInputHandler::installPluginEventFilter( RenderPlugin *renderPlugin )
+{
+ d->m_widget->installEventFilter( renderPlugin );
+}
+
void MarbleWidgetDefaultInputHandler::showLmbMenu( int x, int y )
{
if ( isMouseButtonPopupEnabled( Qt::LeftButton ) ) {
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidgetInputHandler.h #1223152:1223153
@@ -40,14 +40,12 @@
Q_OBJECT
public:
- MarbleWidgetInputHandler();
+ MarbleWidgetInputHandler( MarbleWidget* );
virtual ~MarbleWidgetInputHandler();
void setPositionSignalConnected( bool connected );
bool isPositionSignalConnected() const;
- virtual void init( MarbleWidget* );
-
/**
* @brief Set whether a popup menu appears on a click (not drag) with the left mouse button
* @param enabled True to enable the popup menu (default), false to disable it
@@ -88,13 +86,11 @@
Q_OBJECT
public:
- MarbleWidgetDefaultInputHandler();
+ MarbleWidgetDefaultInputHandler( MarbleWidget* );
~MarbleWidgetDefaultInputHandler();
static bool keyEvent( MarbleWidget * widget, QEvent* e );
- virtual void init( MarbleWidget* );
-
protected:
bool eventFilter( QObject *, QEvent * );
More information about the Marble-commits
mailing list