Merge lp:~jamesh/mediascanner/qml-plugin into lp:mediascanner/v2

Proposed by James Henstridge
Status: Superseded
Proposed branch: lp:~jamesh/mediascanner/qml-plugin
Merge into: lp:mediascanner/v2
Diff against target: 384 lines (+287/-1)
13 files modified
CMakeLists.txt (+2/-0)
debian/control (+16/-0)
debian/copyright (+1/-1)
debian/qtdeclarative5-ubuntu-mediascanner0.1.install (+1/-0)
src/qml/Ubuntu/MediaScanner/CMakeLists.txt (+52/-0)
src/qml/Ubuntu/MediaScanner/MediaFileWrapper.cc (+49/-0)
src/qml/Ubuntu/MediaScanner/MediaFileWrapper.hh (+39/-0)
src/qml/Ubuntu/MediaScanner/MediaStoreWrapper.cc (+22/-0)
src/qml/Ubuntu/MediaScanner/MediaStoreWrapper.hh (+30/-0)
src/qml/Ubuntu/MediaScanner/plugin.cc (+9/-0)
src/qml/Ubuntu/MediaScanner/plugin.hh (+15/-0)
src/qml/Ubuntu/MediaScanner/plugin.qmltypes (+49/-0)
src/qml/Ubuntu/MediaScanner/qmldir (+2/-0)
To merge this branch: bzr merge lp:~jamesh/mediascanner/qml-plugin
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Timo Jyrinki (community) Approve
Michal Hruby (community) Needs Fixing
Review via email: mp+199078@code.launchpad.net

This proposal has been superseded by a proposal from 2014-01-15.

Commit message

First stages of a QML plugin for the Media Scanner. At present it only exposes the query() and lookup() interfaces.

Description of the change

QML binding for mediascanner library. Not yet complete, but enough to perform a simple query from QML.

Currently work in progress, but I wanted Jenkins to see it.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:195
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~jamesh/mediascanner/qml-plugin/+merge/199078/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/mediascanner-v2-ci/13/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-amd64-ci/13/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-armhf-ci/13/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-i386-ci/13/console

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mediascanner-v2-ci/13/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote :

124 + return new MediaFileWrapper(store.lookup(filename.toStdString()));

This doesn't indicate who's the owner of the object, you should either set parent, or explicitly assign ownership to QML.

review: Needs Fixing
Revision history for this message
Michal Hruby (mhr3) wrote :

You probably want:

QQmlEngine::setObjectOwnership(wrapper, QQmlEngine::JavaScriptOwnership);

Revision history for this message
Michal Hruby (mhr3) wrote :

153 + Q_INVOKABLE QList<QObject*> query(const QString &q, MediaType type);

It'd probably be better if this was returning a real model instance - subclass of QAbstractItemModel, it's not clear to me whether QML would know how to manage the object lifecycle of the List + ObjectPtrs.

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

From what I know of QML, looks fine so far.

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

The documentation says that a QML engine will take ownership of every Qt object without a parent that is passed to it.

Revision history for this message
Michał Sawicz (saviq) wrote :

Added ubuntu-sdk-team to review the QML API.

lp:~jamesh/mediascanner/qml-plugin updated
196. By James Henstridge

Update packaging to cover QML plugin, and set plugin version to 0.1.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:196
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~jamesh/mediascanner/qml-plugin/+merge/199078/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/mediascanner-v2-ci/14/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-amd64-ci/14/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-armhf-ci/14/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-i386-ci/14/console

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mediascanner-v2-ci/14/rebuild

review: Needs Fixing (continuous-integration)
lp:~jamesh/mediascanner/qml-plugin updated
197. By James Henstridge

Depend on qtdeclarative5-dev too.

198. By James Henstridge

Correctly namespace the QML file.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:198
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~jamesh/mediascanner/qml-plugin/+merge/199078/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/mediascanner-v2-ci/15/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-amd64-ci/15/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-armhf-ci/15/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-i386-ci/15/console

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mediascanner-v2-ci/15/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

A policy for our own QML plugins is that it's installed into a version specific folder (/usr/lib/ARCH/qt5/qml/Foo.0.1) and has a package name of sort "qtdeclarative5-plugin-foo0.1". See Friends for an example http://bazaar.launchpad.net/~super-friends/qml-friends/trunk/files/head:/debian/

review: Needs Fixing
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

(in order to have, if necessary, multiple API versions of the plugin available for backwards compatibility)

lp:~jamesh/mediascanner/qml-plugin updated
199. By James Henstridge

Version the QML plugin package and installation dir.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:199
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~jamesh/mediascanner/qml-plugin/+merge/199078/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/mediascanner-v2-ci/16/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-amd64-ci/16
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-armhf-ci/16
        deb: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-armhf-ci/16/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-i386-ci/16

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mediascanner-v2-ci/16/rebuild

review: Needs Fixing (continuous-integration)
lp:~jamesh/mediascanner/qml-plugin updated
200. By James Henstridge

Explicitly set ownership of MediaFileWrapper objects.

201. By James Henstridge

Add remaining MediaFile properties to QML wrapper.

Revision history for this message
James Henstridge (jamesh) wrote :

Thanks for everyone's feedback.

@mhr3: I've added the explicit QQmlEngine::setObjectOwnership() calls, and verified that the MediaFileWrapper instances are being destroyed when my test program exits. That would seem to indicate that it can handle a QList<QObject*> okay.

I agree that we should provide some QAbstractItemModel based APIs, but at this point I just wanted to get the basics working so we could ask the music-app guys what kind of interface they're after. The alternative would be to spend a lot of time on something they ultimately can't use.

@timo: thanks for the pointers. I think I've got the install directory and package name fixed up now.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:201
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~jamesh/mediascanner/qml-plugin/+merge/199078/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/mediascanner-v2-ci/17/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-amd64-ci/17
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-armhf-ci/17
        deb: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-armhf-ci/17/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mediascanner-v2-trusty-i386-ci/17

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mediascanner-v2-ci/17/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Looks good to me!

review: Approve
lp:~jamesh/mediascanner/qml-plugin updated
202. By James Henstridge

Merge from trunk.

203. By James Henstridge

Rearrange source tree to match QML import paths so we can generate the
plugins.qmltypes file.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~jamesh/mediascanner/qml-plugin updated
204. By James Henstridge

Build-depend on QtQuick, since qmlplugindump seems to need it.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~jamesh/mediascanner/qml-plugin updated
205. By James Henstridge

Include the generated plugin.qmltypes file under source control, and add
a "make update-qmltypes" command to update it.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

205. By James Henstridge

Include the generated plugin.qmltypes file under source control, and add
a "make update-qmltypes" command to update it.

204. By James Henstridge

Build-depend on QtQuick, since qmlplugindump seems to need it.

203. By James Henstridge

Rearrange source tree to match QML import paths so we can generate the
plugins.qmltypes file.

202. By James Henstridge

Merge from trunk.

201. By James Henstridge

Add remaining MediaFile properties to QML wrapper.

200. By James Henstridge

Explicitly set ownership of MediaFileWrapper objects.

199. By James Henstridge

Version the QML plugin package and installation dir.

198. By James Henstridge

Correctly namespace the QML file.

197. By James Henstridge

Depend on qtdeclarative5-dev too.

196. By James Henstridge

Update packaging to cover QML plugin, and set plugin version to 0.1.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-12-18 10:57:10 +0000
+++ CMakeLists.txt 2014-01-02 10:16:09 +0000
@@ -17,6 +17,7 @@
17pkg_check_modules(GST gstreamer-1.0 gstreamer-pbutils-1.0 REQUIRED)17pkg_check_modules(GST gstreamer-1.0 gstreamer-pbutils-1.0 REQUIRED)
18pkg_check_modules(UNITY unity REQUIRED)18pkg_check_modules(UNITY unity REQUIRED)
19find_package(Threads REQUIRED)19find_package(Threads REQUIRED)
20find_package(Qt5Core REQUIRED)
2021
21set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wextra -std=c99")22set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wextra -std=c99")
22set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -std=c++11")23set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -std=c++11")
@@ -32,6 +33,7 @@
3233
33add_subdirectory(src/mediascanner)34add_subdirectory(src/mediascanner)
34add_subdirectory(src/daemon)35add_subdirectory(src/daemon)
36add_subdirectory(src/qml/Ubuntu/MediaScanner)
35add_subdirectory(src/utils)37add_subdirectory(src/utils)
36add_subdirectory(test)38add_subdirectory(test)
3739
3840
=== modified file 'debian/control'
--- debian/control 2013-12-18 10:42:48 +0000
+++ debian/control 2014-01-02 10:16:09 +0000
@@ -10,6 +10,12 @@
10 libgstreamer1.0-dev,10 libgstreamer1.0-dev,
11 libgtest-dev,11 libgtest-dev,
12 libsqlite3-dev,12 libsqlite3-dev,
13 qt5-default,
14 qtbase5-dev,
15 qtbase5-dev-tools,
16 qtdeclarative5-dev,
17 qtdeclarative5-dev-tools,
18 qtdeclarative5-qtquick2-plugin,
13# For running unit tests19# For running unit tests
14 gstreamer1.0-plugins-base,20 gstreamer1.0-plugins-base,
15 gstreamer1.0-plugins-good,21 gstreamer1.0-plugins-good,
@@ -52,3 +58,13 @@
52Description: Development files for libmediascanner58Description: Development files for libmediascanner
53 This package provides the infrastructure for using the media scanner's59 This package provides the infrastructure for using the media scanner's
54 access library in C++ based projects.60 access library in C++ based projects.
61
62Package: qtdeclarative5-ubuntu-mediascanner0.1
63Architecture: any
64Pre-Depends: ${misc:Pre-Depends},
65Depends: mediascanner (= ${binary:Version}),
66 ${misc:Depends},
67 ${shlibs:Depends},
68Description: QML plugin for the Ubuntu Media Scanner
69 This package provides components that allow access to the media
70 scanner index from Qt Quick 2 / QML applications.
5571
=== modified file 'debian/copyright'
--- debian/copyright 2013-12-20 11:11:54 +0000
+++ debian/copyright 2014-01-02 10:16:09 +0000
@@ -17,7 +17,7 @@
17 On Debian/Ubuntu systems, the full text of the GPL v3 can be found in17 On Debian/Ubuntu systems, the full text of the GPL v3 can be found in
18 `/usr/share/common-licenses/GPL-3'18 `/usr/share/common-licenses/GPL-3'
1919
20Files: src/mediascanner/*20Files: src/mediascanner/* src/qml/*
21Copyright: 2013 Canonical Ltd.21Copyright: 2013 Canonical Ltd.
22License: LGPL-322License: LGPL-3
23 This library is free software; you can redistribute it and/or23 This library is free software; you can redistribute it and/or
2424
=== added file 'debian/qtdeclarative5-ubuntu-mediascanner0.1.install'
--- debian/qtdeclarative5-ubuntu-mediascanner0.1.install 1970-01-01 00:00:00 +0000
+++ debian/qtdeclarative5-ubuntu-mediascanner0.1.install 2014-01-02 10:16:09 +0000
@@ -0,0 +1,1 @@
1usr/lib/*/qt5/qml/Ubuntu/MediaScanner.0.1/*
02
=== added directory 'src/qml'
=== added directory 'src/qml/Ubuntu'
=== added directory 'src/qml/Ubuntu/MediaScanner'
=== added file 'src/qml/Ubuntu/MediaScanner/CMakeLists.txt'
--- src/qml/Ubuntu/MediaScanner/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/qml/Ubuntu/MediaScanner/CMakeLists.txt 2014-01-02 10:16:09 +0000
@@ -0,0 +1,52 @@
1include_directories(../../..)
2
3set(QML_PLUGIN_DIR "${CMAKE_INSTALL_LIBDIR}/qt5/qml/Ubuntu/MediaScanner.0.1")
4
5add_library(mediascanner-qml MODULE
6 plugin.cc
7 MediaFileWrapper.cc
8 MediaStoreWrapper.cc
9)
10
11set_target_properties(mediascanner-qml PROPERTIES AUTOMOC TRUE)
12qt5_use_modules(mediascanner-qml Qml)
13target_link_libraries(mediascanner-qml mediascanner)
14
15install(
16 TARGETS mediascanner-qml
17 LIBRARY DESTINATION ${QML_PLUGIN_DIR}
18)
19
20file(GLOB QMLFILES
21 qmldir
22)
23
24add_custom_target(mediascanner-qmlfiles ALL
25 COMMAND cp ${QMLFILES} ${CMAKE_CURRENT_BINARY_DIR}
26 DEPENDS ${QMLFILES}
27)
28
29install(
30 FILES ${QMLFILES}
31 DESTINATION ${QML_PLUGIN_DIR}
32)
33
34if(NOT CMAKE_CROSSCOMPILING)
35 find_program(qmlplugindump_exe qmlplugindump)
36 if(NOT qmlplugindump_exe)
37 msg(FATAL_ERROR "Could not locate qmlplugindump.")
38 endif()
39
40 # qmlplugindump doesn't run reliably in the CI environment (it seems
41 # to be instantiating the types, which fails when there is no media
42 # database). So add a
43 add_custom_target(update-qmltypes
44 COMMAND QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/src/qml ${qmlplugindump_exe} -notrelocatable Ubuntu.MediaScanner 0.1 > ${CMAKE_CURRENT_SOURCE_DIR}/plugin.qmltypes
45 DEPENDS mediascanner-qml mediascanner-qmlfiles
46 )
47endif()
48
49install(
50 FILES plugin.qmltypes
51 DESTINATION ${QML_PLUGIN_DIR}
52)
053
=== added file 'src/qml/Ubuntu/MediaScanner/MediaFileWrapper.cc'
--- src/qml/Ubuntu/MediaScanner/MediaFileWrapper.cc 1970-01-01 00:00:00 +0000
+++ src/qml/Ubuntu/MediaScanner/MediaFileWrapper.cc 2014-01-02 10:16:09 +0000
@@ -0,0 +1,49 @@
1#include "MediaFileWrapper.hh"
2
3MediaFileWrapper::MediaFileWrapper(const MediaFile media, QObject *parent)
4 : QObject(parent), media(media) {
5}
6
7QString MediaFileWrapper::filename() const {
8 return QString::fromStdString(media.getFileName());
9}
10
11QString MediaFileWrapper::uri() const {
12 return QString::fromStdString(media.getUri());
13}
14
15QString MediaFileWrapper::contentType() const {
16 return QString::fromStdString(media.getContentType());
17}
18
19QString MediaFileWrapper::eTag() const {
20 return QString::fromStdString(media.getETag());
21}
22
23QString MediaFileWrapper::title() const {
24 return QString::fromStdString(media.getTitle());
25}
26
27QString MediaFileWrapper::author() const {
28 return QString::fromStdString(media.getAuthor());
29}
30
31QString MediaFileWrapper::album() const {
32 return QString::fromStdString(media.getAlbum());
33}
34
35QString MediaFileWrapper::albumArtist() const {
36 return QString::fromStdString(media.getAlbumArtist());
37}
38
39QString MediaFileWrapper::date() const {
40 return QString::fromStdString(media.getDate());
41}
42
43int MediaFileWrapper::trackNumber() const {
44 return media.getTrackNumber();
45}
46
47int MediaFileWrapper::duration() const {
48 return media.getDuration();
49}
050
=== added file 'src/qml/Ubuntu/MediaScanner/MediaFileWrapper.hh'
--- src/qml/Ubuntu/MediaScanner/MediaFileWrapper.hh 1970-01-01 00:00:00 +0000
+++ src/qml/Ubuntu/MediaScanner/MediaFileWrapper.hh 2014-01-02 10:16:09 +0000
@@ -0,0 +1,39 @@
1#ifndef MEDIASCANNER_QML_MEDIAFILEWRAPPER_H
2#define MEDIASCANNER_QML_MEDIAFILEWRAPPER_H
3
4#include <QObject>
5#include <QString>
6
7#include <mediascanner/MediaFile.hh>
8
9class MediaFileWrapper : public QObject {
10 Q_OBJECT
11 Q_PROPERTY(QString filename READ filename CONSTANT)
12 Q_PROPERTY(QString uri READ uri CONSTANT)
13 Q_PROPERTY(QString contentType READ contentType CONSTANT)
14 Q_PROPERTY(QString eTag READ eTag CONSTANT)
15 Q_PROPERTY(QString title READ title CONSTANT)
16 Q_PROPERTY(QString author READ author CONSTANT)
17 Q_PROPERTY(QString album READ album CONSTANT)
18 Q_PROPERTY(QString albumArtist READ albumArtist CONSTANT)
19 Q_PROPERTY(QString date READ date CONSTANT)
20 Q_PROPERTY(int trackNumber READ trackNumber CONSTANT)
21 Q_PROPERTY(int duration READ duration CONSTANT)
22public:
23 MediaFileWrapper(MediaFile media, QObject *parent=0);
24 QString filename() const;
25 QString uri() const;
26 QString contentType() const;
27 QString eTag() const;
28 QString title() const;
29 QString author() const;
30 QString album() const;
31 QString albumArtist() const;
32 QString date() const;
33 int trackNumber() const;
34 int duration() const;
35private:
36 const MediaFile media;
37};
38
39#endif
040
=== added file 'src/qml/Ubuntu/MediaScanner/MediaStoreWrapper.cc'
--- src/qml/Ubuntu/MediaScanner/MediaStoreWrapper.cc 1970-01-01 00:00:00 +0000
+++ src/qml/Ubuntu/MediaScanner/MediaStoreWrapper.cc 2014-01-02 10:16:09 +0000
@@ -0,0 +1,22 @@
1#include "MediaStoreWrapper.hh"
2#include <QQmlEngine>
3
4MediaStoreWrapper::MediaStoreWrapper(QObject *parent)
5 : QObject(parent), store(MS_READ_ONLY) {
6}
7
8QList<QObject*> MediaStoreWrapper::query(const QString &q, MediaType type) {
9 QList<QObject*> result;
10 for (const auto &media : store.query(q.toStdString(), static_cast<::MediaType>(type))) {
11 auto wrapper = new MediaFileWrapper(media);
12 QQmlEngine::setObjectOwnership(wrapper, QQmlEngine::JavaScriptOwnership);
13 result.append(wrapper);
14 }
15 return result;
16}
17
18MediaFileWrapper *MediaStoreWrapper::lookup(const QString &filename) {
19 auto wrapper = new MediaFileWrapper(store.lookup(filename.toStdString()));
20 QQmlEngine::setObjectOwnership(wrapper, QQmlEngine::JavaScriptOwnership);
21 return wrapper;
22}
023
=== added file 'src/qml/Ubuntu/MediaScanner/MediaStoreWrapper.hh'
--- src/qml/Ubuntu/MediaScanner/MediaStoreWrapper.hh 1970-01-01 00:00:00 +0000
+++ src/qml/Ubuntu/MediaScanner/MediaStoreWrapper.hh 2014-01-02 10:16:09 +0000
@@ -0,0 +1,30 @@
1#ifndef MEDIASCANNER_QML_MEDIASTOREWRAPPER_H
2#define MEDIASCANNER_QML_MEDIASTOREWRAPPER_H
3
4#include <QList>
5#include <QObject>
6#include <QString>
7
8#include <mediascanner/MediaStore.hh>
9#include "MediaFileWrapper.hh"
10
11class MediaStoreWrapper : public QObject {
12 Q_OBJECT
13 Q_ENUMS(MediaType)
14public:
15 enum MediaType {
16 Audio = AudioMedia,
17 Video = VideoMedia,
18 All = AllMedia,
19 };
20 typedef enum MediaType MediaType;
21 MediaStoreWrapper(QObject *parent=0);
22
23 Q_INVOKABLE QList<QObject*> query(const QString &q, MediaType type);
24 Q_INVOKABLE MediaFileWrapper *lookup(const QString &filename);
25
26private:
27 MediaStore store;
28};
29
30#endif
031
=== added file 'src/qml/Ubuntu/MediaScanner/plugin.cc'
--- src/qml/Ubuntu/MediaScanner/plugin.cc 1970-01-01 00:00:00 +0000
+++ src/qml/Ubuntu/MediaScanner/plugin.cc 2014-01-02 10:16:09 +0000
@@ -0,0 +1,9 @@
1#include "plugin.hh"
2#include "MediaFileWrapper.hh"
3#include "MediaStoreWrapper.hh"
4
5void MediaScannerPlugin::registerTypes(const char *uri) {
6 qmlRegisterType<MediaStoreWrapper>(uri, 0, 1, "MediaStore");
7 qmlRegisterUncreatableType<MediaFileWrapper>(uri, 0, 1, "MediaFile",
8 "Use a MediaStore to retrieve MediaFiles");
9}
010
=== added file 'src/qml/Ubuntu/MediaScanner/plugin.hh'
--- src/qml/Ubuntu/MediaScanner/plugin.hh 1970-01-01 00:00:00 +0000
+++ src/qml/Ubuntu/MediaScanner/plugin.hh 2014-01-02 10:16:09 +0000
@@ -0,0 +1,15 @@
1#ifndef PLUGIN_HH_
2#define PLUGIN_HH_
3
4#include <QtQml>
5
6class MediaScannerPlugin : public QQmlExtensionPlugin
7{
8 Q_OBJECT
9 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
10
11public:
12 virtual void registerTypes(const char *uri) override;
13};
14
15#endif
016
=== added file 'src/qml/Ubuntu/MediaScanner/plugin.qmltypes'
--- src/qml/Ubuntu/MediaScanner/plugin.qmltypes 1970-01-01 00:00:00 +0000
+++ src/qml/Ubuntu/MediaScanner/plugin.qmltypes 2014-01-02 10:16:09 +0000
@@ -0,0 +1,49 @@
1import QtQuick.tooling 1.1
2
3// This file describes the plugin-supplied types contained in the library.
4// It is used for QML tooling purposes only.
5//
6// This file was auto-generated with the command '/usr/lib/x86_64-linux-gnu/qt5/bin/qmlplugindump -notrelocatable Ubuntu.MediaScanner 0.1'.
7
8Module {
9 Component {
10 name: "MediaFileWrapper"
11 prototype: "QObject"
12 exports: ["Ubuntu.MediaScanner/MediaFile 0.1"]
13 Property { name: "filename"; type: "string"; isReadonly: true }
14 Property { name: "uri"; type: "string"; isReadonly: true }
15 Property { name: "contentType"; type: "string"; isReadonly: true }
16 Property { name: "eTag"; type: "string"; isReadonly: true }
17 Property { name: "title"; type: "string"; isReadonly: true }
18 Property { name: "author"; type: "string"; isReadonly: true }
19 Property { name: "album"; type: "string"; isReadonly: true }
20 Property { name: "albumArtist"; type: "string"; isReadonly: true }
21 Property { name: "date"; type: "string"; isReadonly: true }
22 Property { name: "trackNumber"; type: "int"; isReadonly: true }
23 Property { name: "duration"; type: "int"; isReadonly: true }
24 }
25 Component {
26 name: "MediaStoreWrapper"
27 prototype: "QObject"
28 exports: ["Ubuntu.MediaScanner/MediaStore 0.1"]
29 Enum {
30 name: "MediaType"
31 values: {
32 "Audio": 1,
33 "Video": 2,
34 "All": 3
35 }
36 }
37 Method {
38 name: "query"
39 type: "QList<QObject*>"
40 Parameter { name: "q"; type: "string" }
41 Parameter { name: "type"; type: "MediaType" }
42 }
43 Method {
44 name: "lookup"
45 type: "MediaFileWrapper*"
46 Parameter { name: "filename"; type: "string" }
47 }
48 }
49}
050
=== added file 'src/qml/Ubuntu/MediaScanner/qmldir'
--- src/qml/Ubuntu/MediaScanner/qmldir 1970-01-01 00:00:00 +0000
+++ src/qml/Ubuntu/MediaScanner/qmldir 2014-01-02 10:16:09 +0000
@@ -0,0 +1,2 @@
1module Ubuntu.MediaScanner
2plugin mediascanner-qml

Subscribers

People subscribed via source and target branches