src/3rdparty/webkit/WebKit/qt/Api/qgraphicswebview.cpp
changeset 19 fcece45ef507
parent 3 41300fa6a67c
child 30 5dc02b23752f
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
    28 #include <QtGui/QGraphicsScene>
    28 #include <QtGui/QGraphicsScene>
    29 #include <QtGui/QGraphicsView>
    29 #include <QtGui/QGraphicsView>
    30 #include <QtGui/qapplication.h>
    30 #include <QtGui/qapplication.h>
    31 #include <QtGui/qgraphicssceneevent.h>
    31 #include <QtGui/qgraphicssceneevent.h>
    32 #include <QtGui/qstyleoption.h>
    32 #include <QtGui/qstyleoption.h>
       
    33 #include <QtGui/qinputcontext.h>
    33 #if defined(Q_WS_X11)
    34 #if defined(Q_WS_X11)
    34 #include <QX11Info>
    35 #include <QX11Info>
    35 #endif
    36 #endif
    36 
    37 
    37 class QGraphicsWebViewPrivate : public QWebPageClient {
    38 class QGraphicsWebViewPrivate : public QWebPageClient {
    61 
    62 
    62     virtual QObject* pluginParent() const;
    63     virtual QObject* pluginParent() const;
    63 
    64 
    64     void _q_doLoadFinished(bool success);
    65     void _q_doLoadFinished(bool success);
    65 
    66 
       
    67     void _q_updateMicroFocus();
       
    68     void _q_pageDestroyed();
       
    69 
    66     QGraphicsWebView* q;
    70     QGraphicsWebView* q;
    67     QWebPage* page;
    71     QWebPage* page;
    68 };
    72 };
    69 
    73 
    70 QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate()
    74 QGraphicsWebViewPrivate::~QGraphicsWebViewPrivate()
    76     // If the page had no title, still make sure it gets the signal
    80     // If the page had no title, still make sure it gets the signal
    77     if (q->title().isEmpty())
    81     if (q->title().isEmpty())
    78         emit q->urlChanged(q->url());
    82         emit q->urlChanged(q->url());
    79 
    83 
    80     emit q->loadFinished(success);
    84     emit q->loadFinished(success);
       
    85 }
       
    86 
       
    87 void QGraphicsWebViewPrivate::_q_updateMicroFocus()
       
    88 {
       
    89 #if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
       
    90     // Ideally, this should be handled by a common call to an updateMicroFocus function
       
    91     // in QGraphicsItem. See http://bugreports.qt.nokia.com/browse/QTBUG-7578.
       
    92     QList<QGraphicsView*> views = q->scene()->views();
       
    93     for (int c = 0; c < views.size(); ++c) {
       
    94         QInputContext* ic = views.at(c)->inputContext();
       
    95         if (ic)
       
    96             ic->update();
       
    97     }
       
    98 #endif
       
    99 }
       
   100 
       
   101 void QGraphicsWebViewPrivate::_q_pageDestroyed()
       
   102 {
       
   103     page = 0;
       
   104     q->setPage(0);
    81 }
   105 }
    82 
   106 
    83 void QGraphicsWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll)
   107 void QGraphicsWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll)
    84 {
   108 {
    85     q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll));
   109     q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll));
   433             this, SLOT(_q_doLoadFinished(bool)));
   457             this, SLOT(_q_doLoadFinished(bool)));
   434     connect(d->page, SIGNAL(statusBarMessage(QString)),
   458     connect(d->page, SIGNAL(statusBarMessage(QString)),
   435             this, SIGNAL(statusBarMessage(QString)));
   459             this, SIGNAL(statusBarMessage(QString)));
   436     connect(d->page, SIGNAL(linkClicked(QUrl)),
   460     connect(d->page, SIGNAL(linkClicked(QUrl)),
   437             this, SIGNAL(linkClicked(QUrl)));
   461             this, SIGNAL(linkClicked(QUrl)));
       
   462     connect(d->page, SIGNAL(microFocusChanged()),
       
   463             this, SLOT(_q_updateMicroFocus()));
       
   464     connect(d->page, SIGNAL(destroyed()),
       
   465             this, SLOT(_q_pageDestroyed()));
   438 }
   466 }
   439 
   467 
   440 /*!
   468 /*!
   441     \property QGraphicsWebView::url
   469     \property QGraphicsWebView::url
   442     \brief the url of the web page currently viewed
   470     \brief the url of the web page currently viewed