~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to mobile/lib/declarativewidgetbase.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2010 Volker Krause <vkrause@kde.org>
 
3
 
 
4
    This library is free software; you can redistribute it and/or modify it
 
5
    under the terms of the GNU Library General Public License as published by
 
6
    the Free Software Foundation; either version 2 of the License, or (at your
 
7
    option) any later version.
 
8
 
 
9
    This library is distributed in the hope that it will be useful, but WITHOUT
 
10
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
11
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
 
12
    License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Library General Public License
 
15
    along with this library; see the file COPYING.LIB.  If not, write to the
 
16
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
17
    02110-1301, USA.
 
18
*/
 
19
 
 
20
#include "declarativewidgetbase.h"
 
21
 
 
22
#include "stylesheetloader.h"
 
23
 
 
24
#include <QtGui/QGraphicsScene>
 
25
#include <QtGui/QWidget>
 
26
 
 
27
#ifdef _WIN32_WCE
 
28
bool DeclarativeWidgetBaseHelper::eventFilter( QObject *object, QEvent *event )
 
29
{
 
30
    if ( object == this && event->type() == QEvent::Hide ) {
 
31
        QWidget *widget = static_cast<QWidget*>( object );
 
32
        QMetaObject::invokeMethod( widget, "show", Qt::QueuedConnection );
 
33
        qDebug("Ate hide event");
 
34
    }
 
35
 
 
36
    return QGraphicsProxyWidget::eventFilter( object, event );
 
37
}
 
38
#endif
 
39
 
 
40
DeclarativeWidgetBaseHelper::DeclarativeWidgetBaseHelper( QWidget * widget, QGraphicsItem * parent, const RegisterFunction & registerFunc )
 
41
    : QGraphicsProxyWidget( parent ),
 
42
      m_registerFunc( registerFunc ),
 
43
      m_widget( widget )
 
44
{
 
45
    Q_ASSERT( m_widget );
 
46
 
 
47
    QPalette pal = m_widget->palette();
 
48
    pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) );
 
49
    m_widget->setPalette( pal );
 
50
    StyleSheetLoader::applyStyle( m_widget );
 
51
    setWidget( m_widget );
 
52
    setFocusPolicy( Qt::StrongFocus );
 
53
#ifdef _WIN32_WCE
 
54
    m_widget->installEventFilter( this );
 
55
#endif
 
56
}
 
57
 
 
58
DeclarativeWidgetBaseHelper::~DeclarativeWidgetBaseHelper()
 
59
{
 
60
#ifdef _WIN32_WCE
 
61
    m_widget->removeEventFilter( this );
 
62
#endif
 
63
}
 
64
 
 
65
QVariant DeclarativeWidgetBaseHelper::itemChange( GraphicsItemChange change, const QVariant & value )
 
66
{
 
67
    if ( !m_registerFunc.empty() )
 
68
        if ( change == ItemSceneHasChanged )
 
69
            if ( QGraphicsScene* scene = value.value<QGraphicsScene*>() )
 
70
                Q_FOREACH( QGraphicsView * v, scene->views() )
 
71
                    m_registerFunc( v, m_widget );
 
72
    return QGraphicsProxyWidget::itemChange ( change, value );
 
73
}