Changeset 52151 in webkit
- Timestamp:
- Dec 15, 2009 8:13:51 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r52149 r52151 1 2009-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 1 19 2009-12-15 Alexander Pavlov <apavlov@chromium.org> 2 20 -
trunk/WebCore/platform/PopupMenu.h
r48446 r52151 145 145 RetainPtr<NSPopUpButtonCell> m_popup; 146 146 #elif PLATFORM(QT) 147 void clear();148 void populate(const IntRect&);149 147 QWebPopup* m_popup; 150 148 #elif PLATFORM(WIN) -
trunk/WebCore/platform/qt/PopupMenuQt.cpp
r49502 r52151 27 27 #include "PopupMenu.h" 28 28 29 #include "Frame.h"30 29 #include "FrameView.h" 31 #include "HostWindow.h"32 30 #include "PopupMenuClient.h" 33 #include "QWebPageClient.h"34 31 #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>44 32 45 33 namespace WebCore { … … 56 44 } 57 45 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 87 46 void PopupMenu::show(const IntRect& r, FrameView* v, int index) 88 47 { 89 QWebPageClient* client = v->hostWindow()->platformPageClient();90 populate(r);91 48 QRect rect = r; 92 49 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); 99 51 } 100 52 101 53 void PopupMenu::hide() 102 54 { 103 m_popup->hide Popup();55 m_popup->hide(); 104 56 } 105 57 -
trunk/WebCore/platform/qt/QWebPopup.cpp
r48372 r52151 21 21 #include "config.h" 22 22 #include "QWebPopup.h" 23 #include "HostWindow.h" 23 24 #include "PopupMenuStyle.h" 25 #include "QWebPageClient.h" 24 26 25 27 #include <QAbstractItemView> … … 27 29 #include <QInputContext> 28 30 #include <QMouseEvent> 31 #include <QStandardItemModel> 29 32 30 33 namespace WebCore { … … 42 45 43 46 44 void QWebPopup:: exec()47 void QWebPopup::show(const QRect& geometry, int selectedIndex) 45 48 { 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 46 59 QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton, 47 60 Qt::LeftButton, Qt::NoModifier); 48 61 QCoreApplication::sendEvent(this, &event); 62 } 63 64 void 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 } 49 83 } 50 84 -
trunk/WebCore/platform/qt/QWebPopup.h
r37061 r52151 28 28 namespace WebCore { 29 29 30 class QWebPopup : p ublicQComboBox {30 class QWebPopup : private QComboBox { 31 31 Q_OBJECT 32 32 public: 33 33 QWebPopup(PopupMenuClient* client); 34 34 35 void exec(); 35 void show(const QRect& geometry, int selectedIndex); 36 void hide() { hidePopup(); } 37 38 private slots: 39 void activeChanged(int); 40 41 private: 42 PopupMenuClient* m_client; 43 bool m_popupVisible; 44 45 void populate(); 36 46 37 47 virtual void showPopup(); 38 48 virtual void hidePopup(); 39 40 private slots:41 void activeChanged(int);42 private:43 PopupMenuClient* m_client;44 bool m_popupVisible;45 49 }; 46 50
Note: See TracChangeset
for help on using the changeset viewer.