黑莓 10 扫描图库
Blackberry 10 scan gallery
我正在处理内容迁移应用程序。我必须将联系人、日历和媒体从 Blackberry 设备迁移到 Android 设备。我已经完成的联系人和日历。
我使用了下面的联系人代码片段
ContactService contactService;
ContactListFilters filters;
filters.setLimit(0);
QList<Contact> contactList = contactService.contacts(filters);
下面是日历
CalendarService calendarService;
EventSearchParameters searchParams;
searchParams.setStart(QDateTime(QDate(1918, 01, 01), QTime(00,00,00)));
searchParams.setEnd(QDateTime(QDate(2118, 12, 31), QTime(00,00,00)));
QList<CalendarEvent> eventList = calendarService.events(searchParams);
它工作正常。
Now, I have to lookup media in device i.e get media path based on type
say all Image, all Audio and all Video present in device.
Then with those path have to create a output stream and send it to
destination.
我听说您可以查询每台设备上可用的媒体 SQL 数据库,但我自己从未这样做过,所以在这方面我无能为力。对于存储在设备上的媒体文件,db 文件位于 /db/mmlibrary.db
,对于存储在 SD 卡上的媒体文件,db 文件位于 /db/mmlibrary_SD.db
。
否则,您可以递归地浏览设备并保留文件路径的全局列表。请注意,这样做可能会花费很长时间,对于我的个人设备,递归遍历所有文件夹并找到 186 个音频文件、5127 个图片文件和 28 个视频文件需要 25 秒。您可能希望在单独的线程中执行此代码以避免阻塞 UI.
#include "applicationui.hpp"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <QFileInfo>
#include <QDir>
using namespace bb::cascades;
const QStringList audioFileExtensions = QStringList() << "mp3" << "wav";
const QStringList pictureFileExtensions = QStringList() << "bmp" << "gif" << "ico" << "jpg" << "jpeg" << "png" << "tiff";
const QStringList videoFileExtensions = QStringList() << "avi" << "mkv" << "mp4" << "mpeg";
ApplicationUI::ApplicationUI() :
QObject()
{
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("_app", this);
AbstractPane *root = qml->createRootObject<AbstractPane>();
Application::instance()->setScene(root);
}
//Declared as public Q_INVOKABLE in hpp
void ApplicationUI::findMediaFiles(QString parentFolder) {
QDateTime start = QDateTime::currentDateTime();
qDebug() << "findMediaFiles() started in" << parentFolder;
//Those 3 QStringList are declared as private variables in hpp
audioFilePaths.clear();
pictureFilePaths.clear();
videoFilePaths.clear();
if (parentFolder.isEmpty()) {
parentFolder = QString(getenv("PERIMETER_HOME")) + "/shared";
}
findMediaFilesRecursively(parentFolder);
qDebug() << audioFilePaths.size() << audioFilePaths;
qDebug() << pictureFilePaths.size() << pictureFilePaths;
qDebug() << videoFilePaths.size() << videoFilePaths;
qDebug() << "Took" << start.secsTo(QDateTime::currentDateTime()) << "seconds";
}
//Declared as private in hpp
void ApplicationUI::findMediaFilesRecursively(QString parentFolder) {
QDir dir(parentFolder);
dir.setFilter(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot | QDir::NoSymLinks);
dir.setSorting(QDir::DirsFirst);
QFileInfoList fileInfoList = dir.entryInfoList();
foreach(QFileInfo fileInfo, fileInfoList) {
if (fileInfo.isDir()) {
findMediaFilesRecursively(fileInfo.absoluteFilePath());
continue;
}
QString extension = fileInfo.fileName().split(".").last();
if (audioFileExtensions.contains(extension, Qt::CaseInsensitive)) {
audioFilePaths.append(fileInfo.absoluteFilePath());
}
else if (pictureFileExtensions.contains(extension, Qt::CaseInsensitive)) {
pictureFilePaths.append(fileInfo.absoluteFilePath());
}
else if (videoFileExtensions.contains(extension, Qt::CaseInsensitive)) {
videoFilePaths.append(fileInfo.absoluteFilePath());
}
}
}
我正在处理内容迁移应用程序。我必须将联系人、日历和媒体从 Blackberry 设备迁移到 Android 设备。我已经完成的联系人和日历。
我使用了下面的联系人代码片段
ContactService contactService;
ContactListFilters filters;
filters.setLimit(0);
QList<Contact> contactList = contactService.contacts(filters);
下面是日历
CalendarService calendarService;
EventSearchParameters searchParams;
searchParams.setStart(QDateTime(QDate(1918, 01, 01), QTime(00,00,00)));
searchParams.setEnd(QDateTime(QDate(2118, 12, 31), QTime(00,00,00)));
QList<CalendarEvent> eventList = calendarService.events(searchParams);
它工作正常。
Now, I have to lookup media in device i.e get media path based on type say all Image, all Audio and all Video present in device.
Then with those path have to create a output stream and send it to destination.
我听说您可以查询每台设备上可用的媒体 SQL 数据库,但我自己从未这样做过,所以在这方面我无能为力。对于存储在设备上的媒体文件,db 文件位于 /db/mmlibrary.db
,对于存储在 SD 卡上的媒体文件,db 文件位于 /db/mmlibrary_SD.db
。
否则,您可以递归地浏览设备并保留文件路径的全局列表。请注意,这样做可能会花费很长时间,对于我的个人设备,递归遍历所有文件夹并找到 186 个音频文件、5127 个图片文件和 28 个视频文件需要 25 秒。您可能希望在单独的线程中执行此代码以避免阻塞 UI.
#include "applicationui.hpp"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <QFileInfo>
#include <QDir>
using namespace bb::cascades;
const QStringList audioFileExtensions = QStringList() << "mp3" << "wav";
const QStringList pictureFileExtensions = QStringList() << "bmp" << "gif" << "ico" << "jpg" << "jpeg" << "png" << "tiff";
const QStringList videoFileExtensions = QStringList() << "avi" << "mkv" << "mp4" << "mpeg";
ApplicationUI::ApplicationUI() :
QObject()
{
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("_app", this);
AbstractPane *root = qml->createRootObject<AbstractPane>();
Application::instance()->setScene(root);
}
//Declared as public Q_INVOKABLE in hpp
void ApplicationUI::findMediaFiles(QString parentFolder) {
QDateTime start = QDateTime::currentDateTime();
qDebug() << "findMediaFiles() started in" << parentFolder;
//Those 3 QStringList are declared as private variables in hpp
audioFilePaths.clear();
pictureFilePaths.clear();
videoFilePaths.clear();
if (parentFolder.isEmpty()) {
parentFolder = QString(getenv("PERIMETER_HOME")) + "/shared";
}
findMediaFilesRecursively(parentFolder);
qDebug() << audioFilePaths.size() << audioFilePaths;
qDebug() << pictureFilePaths.size() << pictureFilePaths;
qDebug() << videoFilePaths.size() << videoFilePaths;
qDebug() << "Took" << start.secsTo(QDateTime::currentDateTime()) << "seconds";
}
//Declared as private in hpp
void ApplicationUI::findMediaFilesRecursively(QString parentFolder) {
QDir dir(parentFolder);
dir.setFilter(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot | QDir::NoSymLinks);
dir.setSorting(QDir::DirsFirst);
QFileInfoList fileInfoList = dir.entryInfoList();
foreach(QFileInfo fileInfo, fileInfoList) {
if (fileInfo.isDir()) {
findMediaFilesRecursively(fileInfo.absoluteFilePath());
continue;
}
QString extension = fileInfo.fileName().split(".").last();
if (audioFileExtensions.contains(extension, Qt::CaseInsensitive)) {
audioFilePaths.append(fileInfo.absoluteFilePath());
}
else if (pictureFileExtensions.contains(extension, Qt::CaseInsensitive)) {
pictureFilePaths.append(fileInfo.absoluteFilePath());
}
else if (videoFileExtensions.contains(extension, Qt::CaseInsensitive)) {
videoFilePaths.append(fileInfo.absoluteFilePath());
}
}
}