summaryrefslogtreecommitdiffstats
path: root/src/core/type_conversion.h
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2013-11-25 15:38:24 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-15 18:26:51 +0100
commitc34b72183e85e7c615ca65381d8591cdca23faf2 (patch)
treed5359c75cc8178e1f0e07c56aa52f88daba3fa23 /src/core/type_conversion.h
parent0b611c393e8208af717bd1c5e6c1aed1379d03ca (diff)
[Widgets] wire the file pickers
Introduce a new version of chooseFiles in QWebEnginePage. The existing API in WebKit1 seemed a bit dusty in any case (multiple only supported via extensions). Changes are: * oldFile becomes oldFiles, so that we could at a later stage expose the already selected files in the "multiple" case. * a type is introduced, for now limited to multiple selection, but over time, we might consider additions such as directory upload. Change-Id: I14cfea64ce95e892a0a1877c8cb914c5a421409f Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'src/core/type_conversion.h')
-rw-r--r--src/core/type_conversion.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h
index 659096b6e..a1c39581f 100644
--- a/src/core/type_conversion.h
+++ b/src/core/type_conversion.h
@@ -51,6 +51,7 @@
#include "third_party/skia/include/utils/SkMatrix44.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect.h"
+#include "ui/shell_dialogs/selected_file_info.h"
#include "url/gurl.h"
inline QString toQt(const base::string16 &string)
@@ -134,4 +135,31 @@ inline base::FilePath::StringType toFilePathString(const QString &str)
#endif
}
+template <typename T>
+inline T fileListingHelper(const QString &) {qFatal("Specialization missing for %s.", Q_FUNC_INFO);}
+
+template <>
+inline ui::SelectedFileInfo fileListingHelper<ui::SelectedFileInfo>(const QString &file)
+{
+ base::FilePath fp(toFilePathString(file));
+ return ui::SelectedFileInfo(fp, fp);
+}
+
+template <>
+inline base::FilePath fileListingHelper<base::FilePath>(const QString &file)
+{
+ return base::FilePath(toFilePathString(file));
+}
+
+
+template <typename T>
+inline std::vector<T> toVector(const QStringList &fileList)
+{
+ std::vector<T> selectedFiles;
+ selectedFiles.reserve(fileList.size());
+ Q_FOREACH (const QString &file, fileList)
+ selectedFiles.push_back(fileListingHelper<T>(file));
+ return selectedFiles;
+}
+
#endif // TYPE_CONVERSION_H