BlackBerry: Choose the appropriate file dialog type
This chooses the appropriate file dialog type based on the nameFilters that were set. Change-Id: I0c674eacbaebf862ce4359e744271c0d6382c216 Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
This commit is contained in:
parent
7591abbe04
commit
43af92be45
@ -48,6 +48,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonParseError>
|
||||
#include <QMimeDatabase>
|
||||
#include <QUrl>
|
||||
#include <private/qppsobject_p.h>
|
||||
|
||||
@ -119,7 +120,7 @@ void QQnxFilePicker::open()
|
||||
}
|
||||
|
||||
QVariantMap map;
|
||||
map[QStringLiteral("Type")] = QStringLiteral("Other");
|
||||
map[QStringLiteral("Type")] = filePickerType();
|
||||
map[QStringLiteral("Mode")] = modeToString(m_mode);
|
||||
map[QStringLiteral("Title")] = m_title;
|
||||
map[QStringLiteral("ViewMode")] = QStringLiteral("Default");
|
||||
@ -281,6 +282,39 @@ void QQnxFilePicker::handleFilePickerResponse(const char *data)
|
||||
cleanup();
|
||||
}
|
||||
|
||||
QString QQnxFilePicker::filePickerType() const
|
||||
{
|
||||
bool images = false;
|
||||
bool video = false;
|
||||
bool music = false;
|
||||
QMimeDatabase mimeDb;
|
||||
for (int i = 0; i < filters().count(); i++) {
|
||||
QList<QMimeType> mimeTypes = mimeDb.mimeTypesForFileName(filters().at(i));
|
||||
if (mimeTypes.isEmpty())
|
||||
return QStringLiteral("Other");
|
||||
|
||||
if (mimeTypes.first().name().startsWith(QLatin1String("image")))
|
||||
images = true;
|
||||
else if (mimeTypes.first().name().startsWith(QLatin1String("audio")))
|
||||
music = true;
|
||||
else if (mimeTypes.first().name().startsWith(QLatin1String("video")))
|
||||
video = true;
|
||||
else
|
||||
return QStringLiteral("Other");
|
||||
}
|
||||
|
||||
if (!video && !music)
|
||||
return QStringLiteral("Picture");
|
||||
|
||||
if (!images && !music)
|
||||
return QStringLiteral("Video");
|
||||
|
||||
if (!images && !video)
|
||||
return QStringLiteral("Music");
|
||||
|
||||
return QStringLiteral("Other");
|
||||
}
|
||||
|
||||
QString QQnxFilePicker::modeToString(QQnxFilePicker::Mode mode) const
|
||||
{
|
||||
switch (mode) {
|
||||
|
@ -92,6 +92,7 @@ public Q_SLOTS:
|
||||
private:
|
||||
void cleanup();
|
||||
void handleFilePickerResponse(const char *data);
|
||||
QString filePickerType() const;
|
||||
|
||||
QString modeToString(Mode mode) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user