Changeset 52151 in webkit


Ignore:
Timestamp:
Dec 15, 2009 8:13:51 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-15 Luiz Agostini <luiz.agostini@openbossa.org>

Reviewed by Kenneth Rohde Christiansen.

Moving list populate methods from PopupMenuQt to QWebPopup.

In preparation to future implementation of a delegation API for the combobox.

  • platform/PopupMenu.h:
  • platform/qt/PopupMenuQt.cpp: (WebCore::PopupMenu::show): (WebCore::PopupMenu::hide):
  • platform/qt/QWebPopup.cpp: (WebCore::QWebPopup::show): (WebCore::QWebPopup::populate):
  • platform/qt/QWebPopup.h: (WebCore::QWebPopup::hide):
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52149 r52151  
     12009-12-15  Luiz Agostini  <luiz.agostini@openbossa.org>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        Moving list populate methods from PopupMenuQt to QWebPopup.
     6       
     7        In preparation to future implementation of a delegation API for the combobox.
     8
     9        * platform/PopupMenu.h:
     10        * platform/qt/PopupMenuQt.cpp:
     11        (WebCore::PopupMenu::show):
     12        (WebCore::PopupMenu::hide):
     13        * platform/qt/QWebPopup.cpp:
     14        (WebCore::QWebPopup::show):
     15        (WebCore::QWebPopup::populate):
     16        * platform/qt/QWebPopup.h:
     17        (WebCore::QWebPopup::hide):
     18
    1192009-12-15  Alexander Pavlov  <apavlov@chromium.org>
    220
  • trunk/WebCore/platform/PopupMenu.h

    r48446 r52151  
    145145    RetainPtr<NSPopUpButtonCell> m_popup;
    146146#elif PLATFORM(QT)
    147     void clear();
    148     void populate(const IntRect&);
    149147    QWebPopup* m_popup;
    150148#elif PLATFORM(WIN)
  • trunk/WebCore/platform/qt/PopupMenuQt.cpp

    r49502 r52151  
    2727#include "PopupMenu.h"
    2828
    29 #include "Frame.h"
    3029#include "FrameView.h"
    31 #include "HostWindow.h"
    3230#include "PopupMenuClient.h"
    33 #include "QWebPageClient.h"
    3431#include "QWebPopup.h"
    35 
    36 #include <QAction>
    37 #include <QDebug>
    38 #include <QListWidget>
    39 #include <QListWidgetItem>
    40 #include <QMenu>
    41 #include <QPoint>
    42 #include <QStandardItemModel>
    43 #include <QWidgetAction>
    4432
    4533namespace WebCore {
     
    5644}
    5745
    58 void PopupMenu::clear()
    59 {
    60     m_popup->clear();
    61 }
    62 
    63 void PopupMenu::populate(const IntRect&)
    64 {
    65     clear();
    66     Q_ASSERT(client());
    67 
    68     QStandardItemModel* model = qobject_cast<QStandardItemModel*>(m_popup->model());
    69     Q_ASSERT(model);
    70 
    71     int size = client()->listSize();
    72     for (int i = 0; i < size; i++) {
    73         if (client()->itemIsSeparator(i))
    74             m_popup->insertSeparator(i);
    75         else {
    76             m_popup->insertItem(i, client()->itemText(i));
    77 
    78             if (model && !client()->itemIsEnabled(i))
    79                 model->item(i)->setEnabled(false);
    80 
    81             if (client()->itemIsSelected(i))
    82                 m_popup->setCurrentIndex(i);
    83         }
    84     }
    85 }
    86 
    8746void PopupMenu::show(const IntRect& r, FrameView* v, int index)
    8847{
    89     QWebPageClient* client = v->hostWindow()->platformPageClient();
    90     populate(r);
    9148    QRect rect = r;
    9249    rect.moveTopLeft(v->contentsToWindow(r.topLeft()));
    93     rect.setHeight(m_popup->sizeHint().height());
    94 
    95     m_popup->setParent(client->ownerWidget());
    96     m_popup->setGeometry(rect);
    97     m_popup->setCurrentIndex(index);
    98     m_popup->exec();
     50    m_popup->show(rect, index);
    9951}
    10052
    10153void PopupMenu::hide()
    10254{
    103     m_popup->hidePopup();
     55    m_popup->hide();
    10456}
    10557
  • trunk/WebCore/platform/qt/QWebPopup.cpp

    r48372 r52151  
    2121#include "config.h"
    2222#include "QWebPopup.h"
     23#include "HostWindow.h"
    2324#include "PopupMenuStyle.h"
     25#include "QWebPageClient.h"
    2426
    2527#include <QAbstractItemView>
     
    2729#include <QInputContext>
    2830#include <QMouseEvent>
     31#include <QStandardItemModel>
    2932
    3033namespace WebCore {
     
    4245
    4346
    44 void QWebPopup::exec()
     47void QWebPopup::show(const QRect& geometry, int selectedIndex)
    4548{
     49    populate();
     50    setCurrentIndex(selectedIndex);
     51
     52    QWidget* parent = 0;
     53    if (m_client->hostWindow() && m_client->hostWindow()->platformPageClient())
     54       parent = m_client->hostWindow()->platformPageClient()->ownerWidget();
     55
     56    setParent(parent);
     57    setGeometry(QRect(geometry.left(), geometry.top(), geometry.width(), sizeHint().height()));
     58
    4659    QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton,
    4760                      Qt::LeftButton, Qt::NoModifier);
    4861    QCoreApplication::sendEvent(this, &event);
     62}
     63
     64void QWebPopup::populate()
     65{
     66    clear();
     67    Q_ASSERT(m_client);
     68
     69    QStandardItemModel* model = qobject_cast<QStandardItemModel*>(QComboBox::model());
     70    Q_ASSERT(model);
     71
     72    int size = m_client->listSize();
     73    for (int i = 0; i < size; i++) {
     74        if (m_client->itemIsSeparator(i))
     75            insertSeparator(i);
     76        else {
     77            insertItem(i, m_client->itemText(i));
     78
     79            if (model && !m_client->itemIsEnabled(i))
     80                model->item(i)->setEnabled(false);
     81        }
     82    }
    4983}
    5084
  • trunk/WebCore/platform/qt/QWebPopup.h

    r37061 r52151  
    2828namespace WebCore {
    2929
    30 class QWebPopup : public QComboBox {
     30class QWebPopup : private QComboBox {
    3131    Q_OBJECT
    3232public:
    3333    QWebPopup(PopupMenuClient* client);
    3434
    35     void exec();
     35    void show(const QRect& geometry, int selectedIndex);
     36    void hide() { hidePopup(); }
     37
     38private slots:
     39    void activeChanged(int);
     40
     41private:
     42    PopupMenuClient* m_client;
     43    bool m_popupVisible;
     44
     45    void populate();
    3646
    3747    virtual void showPopup();
    3848    virtual void hidePopup();
    39 
    40 private slots:
    41     void activeChanged(int);
    42 private:
    43     PopupMenuClient* m_client;
    44     bool m_popupVisible;
    4549};
    4650
Note: See TracChangeset for help on using the changeset viewer.