黑莓10扫描库 [英] Blackberry 10 scan gallery

查看:65
本文介绍了黑莓10扫描库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发内容迁移应用程序.我必须将联系人,日历,媒体从Blackberry设备迁移到Android设备.我已经完成的联系人和日历.

I am working on content migration application. I have to migrate contacts, calendars, media from Blackberry device to Android device. Contacts and Calendars I have done.

我在下面的联系人代码段中使用了

I used below snip of code for Contacts

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.

I've heard you can query the media SQL database available on every device, but I've never done it myself so I can't help on that one. The db file is located at /db/mmlibrary.db for media files stored on device and at /db/mmlibrary_SD.db for media files stored on SD card.

否则,您可以递归地浏览设备并保留文件路径的全局列表.请注意,这样做可能会花费很长时间,对于我的个人设备,它花了25秒来递归浏览所有文件夹并找到186个音频文件,5127个图片文件和28个视频文件.您可能希望在单独的线程中执行此代码,以避免阻塞UI.

Otherwise, you can recursively navigate through the device and keep a global list of file paths. Note that doing so can take a long time, for my personal device it took 25 seconds to recursively go through all folders and find 186 audio files, 5127 picture files and 28 video files. You might want to execute this code in a separate thread to avoid blocking 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());
        }
    }
}

这篇关于黑莓10扫描库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆