Changeset 39132 in webkit
- Timestamp:
- Dec 9, 2008, 2:13:49 AM (16 years ago)
- Location:
- trunk/WebKit/qt
- Files:
-
- 4 edited
-
Api/qwebpage.cpp (modified) (4 diffs)
-
Api/qwebpage.h (modified) (2 diffs)
-
ChangeLog (modified) (1 diff)
-
WebCoreSupport/ChromeClientQt.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/qt/Api/qwebpage.cpp
r39069 r39132 1981 1981 should verify that the extension is supported by calling supportsExtension(). 1982 1982 1983 Currently there are no extensions. 1983 \value ChooseMultipleFilesExtension Whether the web page supports multiple file selection. 1984 This extension is invoked when the web content requests one or more file names, for example 1985 as a result of the user clicking on a "file upload" button in a HTML form where multiple 1986 file selection is allowed. 1987 1984 1988 */ 1985 1989 … … 1993 1997 1994 1998 /*! 1995 \class QWebPage::Extension Return1999 \class QWebPage::ExtensionOption 1996 2000 \since 4.4 1997 \brief The ExtensionOption class provides an extended output argument to QWebPage's extension support.2001 \brief The ExtensionOption class provides an extended input argument to QWebPage's extension support. 1998 2002 1999 2003 \sa QWebPage::extension() 2004 */ 2005 2006 /*! 2007 \class QWebPage::ChooseMultipleFilesExtensionOption 2008 \since 4.5 2009 \brief The ChooseMultipleFilesExtensionOption class describes the option 2010 for the multiple files selection extension. 2011 2012 The ChooseMultipleFilesExtensionOption class holds the frame originating the request 2013 and the suggested filenames which might be provided. 2014 2015 \sa QWebPage::chooseFile(), QWebPage::ChooseMultipleFilesExtensionReturn 2016 */ 2017 2018 /*! 2019 \class QWebPage::ChooseMultipleFilesExtensionReturn 2020 \since 4.5 2021 \brief The ChooseMultipleFilesExtensionReturn describes the return value 2022 for the multiple files selection extension. 2023 2024 The ChooseMultipleFilesExtensionReturn class holds the filenames selected by the user 2025 when the extension is invoked. 2026 2027 \sa QWebPage::ChooseMultipleFilesExtensionOption 2000 2028 */ 2001 2029 … … 2008 2036 You can call supportsExtension() to check if an extension is supported by the page. 2009 2037 2010 By default, no extensions are supported, and this function returns false.2011 2012 2038 \sa supportsExtension(), Extension 2013 2039 */ 2014 2040 bool QWebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) 2015 2041 { 2016 Q_UNUSED(extension) 2017 Q_UNUSED(option) 2018 Q_UNUSED(output) 2042 #ifndef QT_NO_FILEDIALOG 2043 if (extension == ChooseMultipleFilesExtension) { 2044 // FIXME: do not ignore suggestedFiles 2045 QStringList suggestedFiles = reinterpret_cast<const ChooseMultipleFilesExtensionOption*>(option)->suggestedFiles; 2046 QStringList names = QFileDialog::getOpenFileNames(d->view, QString::null); 2047 reinterpret_cast<ChooseMultipleFilesExtensionReturn*>(output)->files = names; 2048 return true; 2049 } 2050 #endif 2051 2019 2052 return false; 2020 2053 } … … 2027 2060 bool QWebPage::supportsExtension(Extension extension) const 2028 2061 { 2029 Q_UNUSED(extension) 2062 #ifndef QT_NO_FILEDIALOG 2063 return extension == ChooseMultipleFilesExtension; 2064 #else 2065 Q_UNUSED(extension); 2030 2066 return false; 2067 #endif 2031 2068 } 2032 2069 -
trunk/WebKit/qt/Api/qwebpage.h
r38396 r39132 240 240 241 241 enum Extension { 242 ChooseMultipleFilesExtension 242 243 }; 243 244 class ExtensionOption … … 245 246 class ExtensionReturn 246 247 {}; 248 249 class ChooseMultipleFilesExtensionOption : public ExtensionOption { 250 public: 251 QWebFrame *parentFrame; 252 QStringList suggestedFiles; 253 }; 254 255 class ChooseMultipleFilesExtensionReturn : public ExtensionReturn { 256 public: 257 QStringList files; 258 }; 259 247 260 virtual bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0); 248 261 virtual bool supportsExtension(Extension extension) const; -
trunk/WebKit/qt/ChangeLog
r39069 r39132 1 2008-12-08 Ariya Hidayat <ariya.hidayat@trolltech.com> 2 3 Reviewed by Simon Hausmann. 4 5 Multiple files support for the file chooser. 6 7 * Api/qwebpage.cpp: 8 (QWebPage::chooseFiles): 9 * Api/qwebpage.h: 10 * WebCoreSupport/ChromeClientQt.cpp: 11 (WebCore::ChromeClientQt::runOpenPanel): 12 1 13 2008-12-06 Simon Fraser <simon.fraser@apple.com> 2 14 -
trunk/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
r38555 r39132 394 394 void ChromeClientQt::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> prpFileChooser) 395 395 { 396 // FIXME: Support multiple files.397 398 396 RefPtr<FileChooser> fileChooser = prpFileChooser; 399 QString suggestedFile; 400 if (!fileChooser->filenames().isEmpty()) 401 suggestedFile = fileChooser->filenames()[0]; 402 QString file = m_webPage->chooseFile(QWebFramePrivate::kit(frame), suggestedFile); 403 if (!file.isEmpty()) 404 fileChooser->chooseFile(file); 405 } 406 407 } 397 bool supportMulti = m_webPage->supportsExtension(QWebPage::ChooseMultipleFilesExtension); 398 399 if (fileChooser->allowsMultipleFiles() && supportMulti) { 400 QWebPage::ChooseMultipleFilesExtensionOption option; 401 option.parentFrame = QWebFramePrivate::kit(frame); 402 403 if (!fileChooser->filenames().isEmpty()) 404 for (int i = 0; i < fileChooser->filenames().size(); ++i) 405 option.suggestedFiles += fileChooser->filenames()[i]; 406 407 QWebPage::ChooseMultipleFilesExtensionReturn output; 408 m_webPage->extension(QWebPage::ChooseMultipleFilesExtension, &option, &output); 409 410 if (!output.files.isEmpty()) { 411 Vector<String> names; 412 for (int i = 0; i < output.files.count(); ++i) 413 names.append(output.files[i]); 414 fileChooser->chooseFiles(names); 415 } 416 } else { 417 QString suggestedFile; 418 if (!fileChooser->filenames().isEmpty()) 419 suggestedFile = fileChooser->filenames()[0]; 420 QString file = m_webPage->chooseFile(QWebFramePrivate::kit(frame), suggestedFile); 421 if (!file.isEmpty()) 422 fileChooser->chooseFile(file); 423 } 424 } 425 426 }
Note:
See TracChangeset
for help on using the changeset viewer.