[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/mobile/lib
From: Marc Mutz <mutz () kde ! org>
Date: 2010-11-02 16:05:20
Message-ID: 20101102160520.7EE55AC8AB () svn ! kde ! org
[Download RAW message or body]
SVN commit 1192323 by mutz:
DeclarativeWidgetBase: use DeclarativeWidgetBaseHelper
In this step, factor initialisation code out of the class template.
Adjust users of the class to the fact that m_widget is now private
(use the widget() accessor instead).
M +3 -3 calendar/declarativeeditors.cpp
M +7 -30 declarativewidgetbase.h
--- trunk/KDE/kdepim/mobile/lib/calendar/declarativeeditors.cpp #1192322:1192323
@@ -56,7 +56,7 @@
//
// Without this hack the widget gets a width that is too large for the app. It
// doesn't seem to matter which size you pass here.
- m_widget->resize( QSize() );
+ widget()->resize( QSize() );
}
MobileIncidenceMore::MobileIncidenceMore( QWidget *parent )
@@ -78,12 +78,12 @@
int DIEMore::currentIndex() const
{
- return m_widget->currentIndex();
+ return widget()->currentIndex();
}
void DIEMore::setCurrentIndex( int index )
{
- m_widget->setCurrentIndex( index );
+ widget()->setCurrentIndex( index );
}
#include "declarativeeditors.moc"
--- trunk/KDE/kdepim/mobile/lib/declarativewidgetbase.h #1192322:1192323
@@ -22,8 +22,6 @@
#include "mobileui_export.h"
-#include "stylesheetloader.h"
-
#include <QtGui/QGraphicsProxyWidget>
#include <QtGui/QGraphicsScene>
#include <QtDeclarative/QDeclarativeItem>
@@ -47,23 +45,15 @@
};
template <typename WidgetT, typename ViewT, void (ViewT::*registerFunc)( WidgetT* )>
-class DeclarativeWidgetBase : public QGraphicsProxyWidget
+class DeclarativeWidgetBase : public DeclarativeWidgetBaseHelper
{
public:
- explicit DeclarativeWidgetBase( QGraphicsItem *parent = 0 ) :
- QGraphicsProxyWidget( parent ),
- m_widget( new WidgetT )
- {
- init();
- }
+ explicit DeclarativeWidgetBase( QGraphicsItem *parent = 0 )
+ : DeclarativeWidgetBaseHelper( new WidgetT, parent ) {}
/** use this constructor if you inherit from this template to customize widget construction. */
- DeclarativeWidgetBase( WidgetT *widget, QGraphicsItem *parent ) :
- QGraphicsProxyWidget( parent ),
- m_widget( widget )
- {
- init();
- }
+ DeclarativeWidgetBase( WidgetT *widget, QGraphicsItem *parent )
+ : DeclarativeWidgetBaseHelper( widget, parent ) {}
protected:
QVariant itemChange ( GraphicsItemChange change, const QVariant& value )
@@ -72,26 +62,13 @@
if ( QGraphicsScene* scene = value.value<QGraphicsScene*>() )
Q_FOREACH( QGraphicsView * v, scene->views() )
if ( ViewT * view = qobject_cast<ViewT*>( v ) )
- (view->*registerFunc)( m_widget );
+ (view->*registerFunc)( widget() );
}
return QGraphicsProxyWidget::itemChange ( change, value );
}
protected:
- WidgetT* m_widget;
-
- private:
- void init()
- {
- Q_ASSERT( m_widget );
-
- QPalette pal = m_widget->palette();
- pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) );
- m_widget->setPalette( pal );
- StyleSheetLoader::applyStyle( m_widget );
- setWidget( m_widget );
- setFocusPolicy( Qt::StrongFocus );
- }
+ WidgetT * widget() const { return static_cast<WidgetT*>( DeclarativeWidgetBaseHelper::widget() ); }
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic