Merge lp:~schwann/gallery-app/gallery-content-hub into lp:gallery-app

Proposed by Günter Schwann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 824
Merged at revision: 827
Proposed branch: lp:~schwann/gallery-app/gallery-content-hub
Merge into: lp:gallery-app
Diff against target: 622 lines (+313/-23)
14 files modified
CMakeLists.txt (+5/-0)
debian/control (+1/-0)
rc/qml/GalleryApplication.qml (+10/-12)
rc/qml/PickerScreen.qml (+0/-2)
src/CMakeLists.txt (+4/-1)
src/content-communicator.cpp (+96/-0)
src/content-communicator.h (+51/-0)
src/gallery-application.cpp (+2/-1)
src/gallery-application.h (+0/-1)
src/gallery-manager.cpp (+69/-4)
src/gallery-manager.h (+15/-1)
tests/unittests/stubs/content-communicator_stub.cpp (+43/-0)
tests/unittests/stubs/gallery-manager_stub.cpp (+10/-1)
tests/unittests/video/CMakeLists.txt (+7/-0)
To merge this branch: bzr merge lp:~schwann/gallery-app/gallery-content-hub
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Gustavo Pichorim Boiko (community) Approve
Bill Filler (community) Needs Fixing
Review via email: mp+180378@code.launchpad.net

Commit message

Use content hub for content picking

Description of the change

Use content hub for content picking

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
816. By Günter Schwann

Minor cmake improvement

817. By Günter Schwann

Trunk merged

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
818. By Günter Schwann

trunk merged

Revision history for this message
Bill Filler (bfiller) wrote :

looks like typo in line 13
+set(CONTENTHUB_INCLUDE_DIRS "/usr/include/com/ununtu/content")

Also is Nick D'Offay intentionally listed as author of new files?

review: Needs Fixing
819. By Günter Schwann

* remove (wrong) author of copyright
* mark the cmake variables for the content hub as fixme

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
820. By Günter Schwann

Trunk merged

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
821. By Günter Schwann

Dynamicly switch to pick mode if needed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
822. By Günter Schwann

Fix to start with --pick-mode

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

275 + * Simple class which encapsulates instantiates objects which require only one instance.

The "encapsulates instantiates" part seems to be a typo?

review: Needs Fixing
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

285 + virtual void handle_export(content::Transfer*transfer);

Just nitpicking, can you fix the coding style in there so that it is the same as used in the other methods of the same file?

review: Needs Fixing
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

236 + foreach (const QUrl url, urls) {

can this be a const reference instead? (const QUrl &url)

review: Needs Fixing
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

437 + * \brief GalleryManager::pickMode returns if the current UI mode should be for

That should read GalleryManager::pickModeEnabled

review: Needs Fixing
823. By Günter Schwann

Better name for "normal" mode of gallery

824. By Günter Schwann

Fix comments from MR

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good now!

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-08-16 12:55:55 +0000
+++ CMakeLists.txt 2013-08-28 19:23:56 +0000
@@ -38,10 +38,15 @@
38endif()38endif()
3939
40find_package(PkgConfig REQUIRED)40find_package(PkgConfig REQUIRED)
41#pkg_check_modules(CONTENTHUB REQUIRED libcontent-hub)
41pkg_check_modules(EXIV2 REQUIRED exiv2)42pkg_check_modules(EXIV2 REQUIRED exiv2)
42pkg_check_modules(GSTLIB REQUIRED gstreamer-0.10)43pkg_check_modules(GSTLIB REQUIRED gstreamer-0.10)
43pkg_check_modules(MEDIAINFO REQUIRED libmediainfo)44pkg_check_modules(MEDIAINFO REQUIRED libmediainfo)
4445
46# FIXME use cmake to find the proper variables
47set(CONTENTHUB_INCLUDE_DIRS "/usr/include/com/ubuntu/content")
48set(CONTENTHUB_LIBRARIES "content-hub")
49
45set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")50set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")
4651
47# Standard install paths52# Standard install paths
4853
=== modified file 'debian/control'
--- debian/control 2013-08-26 09:28:46 +0000
+++ debian/control 2013-08-28 19:23:56 +0000
@@ -5,6 +5,7 @@
5Build-Depends: debhelper (>= 9),5Build-Depends: debhelper (>= 9),
6 cmake,6 cmake,
7 dh-translations,7 dh-translations,
8 libcontent-hub-dev,
8 libgstreamer0.10-dev,9 libgstreamer0.10-dev,
9 libexiv2-dev,10 libexiv2-dev,
10 libgl1-mesa-dev | libgl-dev,11 libgl1-mesa-dev | libgl-dev,
1112
=== modified file 'rc/qml/GalleryApplication.qml'
--- rc/qml/GalleryApplication.qml 2013-06-26 08:59:08 +0000
+++ rc/qml/GalleryApplication.qml 2013-08-28 19:23:56 +0000
@@ -37,6 +37,9 @@
3737
38 property bool automaticOrientation: true38 property bool automaticOrientation: true
3939
40 /// Indicates if the backend is loaded and the UI can be shown
41 property bool allLoaded: false
42
40 // Big list of form factor-specific values. 'default' is used if the key43 // Big list of form factor-specific values. 'default' is used if the key
41 // can't be found under any other form_factor (otherwise, form_factors should44 // can't be found under any other form_factor (otherwise, form_factors should
42 // match the FORM_FACTOR values passed from main.cpp). Just add Portrait to45 // match the FORM_FACTOR values passed from main.cpp). Just add Portrait to
@@ -141,8 +144,7 @@
141 /*!144 /*!
142 */145 */
143 function onLoaded() {146 function onLoaded() {
144 mainScreenLoader.load();147 allLoaded = true;
145 loadingScreen.visible = false;
146 }148 }
147149
148 width: units.gu(DEVICE_WIDTH)150 width: units.gu(DEVICE_WIDTH)
@@ -161,26 +163,22 @@
161 }163 }
162 }164 }
163165
164 LoadingScreen {166 Loader {
165 id: loadingScreen167 id: loadingScreen
166
167 anchors.fill: parent168 anchors.fill: parent
169 visible: mainScreenLoader.status !== Loader.Ready
170 source: visible ? Qt.resolvedUrl("LoadingScreen.qml") : ""
168 }171 }
169172
170 Loader {173 Loader {
171 id: mainScreenLoader174 id: mainScreenLoader
172
173 // find the loader with autopilot:175 // find the loader with autopilot:
174 objectName: "mainLoader"176 objectName: "mainLoader"
175177
176 function load() {
177 if (PICK_MODE_ENABLED)
178 source = "PickerScreen.qml";
179 else
180 source = "MainScreen.qml";
181 }
182
183 anchors.fill: parent178 anchors.fill: parent
179 source: allLoaded ? (MANAGER.pickModeEnabled ? Qt.resolvedUrl("PickerScreen.qml")
180 : Qt.resolvedUrl("MainScreen.qml"))
181 : ""
184 }182 }
185183
186 HUD.HUD {184 HUD.HUD {
187185
=== modified file 'rc/qml/PickerScreen.qml'
--- rc/qml/PickerScreen.qml 2013-08-27 06:48:42 +0000
+++ rc/qml/PickerScreen.qml 2013-08-28 19:23:56 +0000
@@ -102,7 +102,6 @@
102 return;102 return;
103103
104 MANAGER.returnPickedContent(mediaLibrary.selectedMedias);104 MANAGER.returnPickedContent(mediaLibrary.selectedMedias);
105 Qt.quit();
106 }105 }
107 }106 }
108107
@@ -113,7 +112,6 @@
113 width: units.gu(10)112 width: units.gu(10)
114 onClicked: {113 onClicked: {
115 MANAGER.contentPickingCanceled()114 MANAGER.contentPickingCanceled()
116 Qt.quit();
117 }115 }
118 }116 }
119 opened: true117 opened: true
120118
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2013-08-14 20:19:09 +0000
+++ src/CMakeLists.txt 2013-08-28 19:23:56 +0000
@@ -31,15 +31,18 @@
31 ${gallery_video_src_SOURCE_DIR}31 ${gallery_video_src_SOURCE_DIR}
32 ${gallery_qml_src_SOURCE_DIR}32 ${gallery_qml_src_SOURCE_DIR}
33 ${CMAKE_BINARY_DIR}33 ${CMAKE_BINARY_DIR}
34 ${CONTENTHUB_INCLUDE_DIRS}
34 )35 )
3536
36set(gallery_HDRS37set(gallery_HDRS
38 content-communicator.h
37 gallery-application.h39 gallery-application.h
38 gallery-manager.h40 gallery-manager.h
39 media-object-factory.h41 media-object-factory.h
40 )42 )
4143
42set(gallery_SRCS44set(gallery_SRCS
45 content-communicator.cpp
43 gallery-application.cpp46 gallery-application.cpp
44 gallery-manager.cpp47 gallery-manager.cpp
45 main.cpp48 main.cpp
@@ -63,7 +66,7 @@
63 gallery-qml66 gallery-qml
64 gallery-util67 gallery-util
65 gallery-video68 gallery-video
66 ${GSTLIB_LDFLAGS}69 ${CONTENTHUB_LIBRARIES}
67 )70 )
6871
69install(TARGETS ${GALLERY} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})72install(TARGETS ${GALLERY} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
7073
=== added file 'src/content-communicator.cpp'
--- src/content-communicator.cpp 1970-01-01 00:00:00 +0000
+++ src/content-communicator.cpp 2013-08-28 19:23:56 +0000
@@ -0,0 +1,96 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include <content-communicator.h>
19
20#include <QDebug>
21#include <QFileInfo>
22
23#include <com/ubuntu/content/hub.h>
24#include <com/ubuntu/content/item.h>
25#include <com/ubuntu/content/transfer.h>
26
27using namespace com::ubuntu::content;
28
29/*!
30 * \brief ContentCommunicator::ContentCommunicator
31 * \param parent
32 */
33ContentCommunicator::ContentCommunicator(QObject *parent)
34 : ImportExportHandler(parent),
35 m_transfer(nullptr)
36{
37 Hub *hub = Hub::Client::instance();
38 hub->register_import_export_handler(this);
39}
40
41/*!
42 * \brief \reimp
43 */
44void ContentCommunicator::handle_import(content::Transfer *)
45{
46 qDebug() << Q_FUNC_INFO << "gallery does not import content";
47}
48
49/*!
50 * \brief \reimp
51 */
52void ContentCommunicator::handle_export(content::Transfer *transfer)
53{
54 if (m_transfer != nullptr) {
55 qWarning() << "gallery-app does only one content export at a time";
56 transfer->abort();
57 return;
58 }
59
60 m_transfer = transfer;
61 emit photoRequested();
62}
63
64/*!
65 * \brief ContentCommunicator::cancelTransfer aborts the current transfer
66 */
67void ContentCommunicator::cancelTransfer()
68{
69 if (!m_transfer) {
70 qWarning() << "No ongoing transfer to cancel";
71 return;
72 }
73
74 m_transfer->abort();
75}
76
77/*!
78 * \brief ContentCommunicator::returnPhoto returns the given photos
79 * via content hub to the requester
80 * \param urls
81 */
82void ContentCommunicator::returnPhotos(const QVector<QUrl> &urls)
83{
84 if (!m_transfer) {
85 qWarning() << "No ongoing transfer to return a photo";
86 return;
87 }
88
89 QVector<Item> items;
90 items.reserve(urls.size());
91 foreach (const QUrl &url, urls) {
92 items.append(Item(url));
93 }
94 m_transfer->charge(items);
95 m_transfer = nullptr;
96}
097
=== added file 'src/content-communicator.h'
--- src/content-communicator.h 1970-01-01 00:00:00 +0000
+++ src/content-communicator.h 2013-08-28 19:23:56 +0000
@@ -0,0 +1,51 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#ifndef CONTENTCOMMUNICATOR_H
19#define CONTENTCOMMUNICATOR_H
20
21#include <com/ubuntu/content/import_export_handler.h>
22
23#include <QUrl>
24#include <QVector>
25
26using namespace com::ubuntu;
27
28/*!
29 * Class to handle the communication with the content manager
30 */
31class ContentCommunicator : public content::ImportExportHandler
32{
33 Q_OBJECT
34
35public:
36 ContentCommunicator(QObject *parent = nullptr);
37
38 virtual void handle_import(content::Transfer*);
39 virtual void handle_export(content::Transfer *transfer);
40
41 void cancelTransfer();
42 void returnPhotos(const QVector<QUrl> &urls);
43
44signals:
45 void photoRequested();
46
47private:
48 content::Transfer *m_transfer;
49};
50
51#endif // CONTENTCOMMUNICATOR_H
052
=== modified file 'src/gallery-application.cpp'
--- src/gallery-application.cpp 2013-08-27 06:48:42 +0000
+++ src/gallery-application.cpp 2013-08-28 19:23:56 +0000
@@ -81,6 +81,8 @@
8181
82 m_galleryManager = new GalleryManager(m_cmdLineParser->picturesDir(), m_view);82 m_galleryManager = new GalleryManager(m_cmdLineParser->picturesDir(), m_view);
83 m_galleryManager->logImageLoading(m_cmdLineParser->logImageLoading());83 m_galleryManager->logImageLoading(m_cmdLineParser->logImageLoading());
84 if (m_cmdLineParser->pickModeEnabled())
85 m_galleryManager->setDefaultUiMode(GalleryManager::PickContentMode);
8486
85 if (m_cmdLineParser->startupTimer())87 if (m_cmdLineParser->startupTimer())
86 qDebug() << "Construct GalleryApplication" << m_timer->elapsed() << "ms";88 qDebug() << "Construct GalleryApplication" << m_timer->elapsed() << "ms";
@@ -161,7 +163,6 @@
161 rootContext->setContextProperty("DEVICE_WIDTH", QVariant(size.width()));163 rootContext->setContextProperty("DEVICE_WIDTH", QVariant(size.width()));
162 rootContext->setContextProperty("DEVICE_HEIGHT", QVariant(size.height()));164 rootContext->setContextProperty("DEVICE_HEIGHT", QVariant(size.height()));
163 rootContext->setContextProperty("FORM_FACTOR", QVariant(m_cmdLineParser->formFactor()));165 rootContext->setContextProperty("FORM_FACTOR", QVariant(m_cmdLineParser->formFactor()));
164 rootContext->setContextProperty("PICK_MODE_ENABLED", QVariant(m_cmdLineParser->pickModeEnabled()));
165 rootContext->setContextProperty("MAX_GL_TEXTURE_SIZE",166 rootContext->setContextProperty("MAX_GL_TEXTURE_SIZE",
166 QVariant(m_galleryManager->resource()->maxTextureSize()));167 QVariant(m_galleryManager->resource()->maxTextureSize()));
167168
168169
=== modified file 'src/gallery-application.h'
--- src/gallery-application.h 2013-06-28 11:53:54 +0000
+++ src/gallery-application.h 2013-08-28 19:23:56 +0000
@@ -56,7 +56,6 @@
56 void registerQML();56 void registerQML();
57 void createView();57 void createView();
5858
59
60 QQuickView *m_view;59 QQuickView *m_view;
61 GalleryManager *m_galleryManager;60 GalleryManager *m_galleryManager;
62 CommandLineParser* m_cmdLineParser;61 CommandLineParser* m_cmdLineParser;
6362
=== modified file 'src/gallery-manager.cpp'
--- src/gallery-manager.cpp 2013-08-13 09:31:23 +0000
+++ src/gallery-manager.cpp 2013-08-28 19:23:56 +0000
@@ -19,6 +19,7 @@
19 */19 */
2020
21#include "gallery-manager.h"21#include "gallery-manager.h"
22#include "content-communicator.h"
22#include "media-object-factory.h"23#include "media-object-factory.h"
2324
24// album25// album
@@ -45,6 +46,7 @@
45// util46// util
46#include "resource.h"47#include "resource.h"
4748
49#include <QApplication>
48#include <QElapsedTimer>50#include <QElapsedTimer>
4951
50#include <exiv2/exiv2.hpp>52#include <exiv2/exiv2.hpp>
@@ -70,6 +72,9 @@
70 m_eventCollection(0),72 m_eventCollection(0),
71 m_previewManager(0),73 m_previewManager(0),
72 m_monitor(0),74 m_monitor(0),
75 m_contentCommunicator(new ContentCommunicator(this)),
76 m_pickModeEnabled(false),
77 m_defaultUiMode(BrowseContentMode),
73 m_mediaLibrary(0)78 m_mediaLibrary(0)
74{79{
75 const int maxTextureSize = m_resource->maxTextureSize();80 const int maxTextureSize = m_resource->maxTextureSize();
@@ -77,6 +82,9 @@
77 m_mediaFactory = new MediaObjectFactory();82 m_mediaFactory = new MediaObjectFactory();
7883
79 m_galleryManager = this;84 m_galleryManager = this;
85
86 QObject::connect(m_contentCommunicator, SIGNAL(photoRequested()),
87 this, SLOT(switchToPickMode()));
80}88}
8189
82/*!90/*!
@@ -125,10 +133,18 @@
125 }133 }
126134
127 QList<MediaSource*> sources = qvariant_cast<QList<MediaSource*> >(variant);135 QList<MediaSource*> sources = qvariant_cast<QList<MediaSource*> >(variant);
128136 QVector<QUrl> selectedMedias;
137 selectedMedias.reserve(sources.size());
129 foreach (const MediaSource *media, sources) {138 foreach (const MediaSource *media, sources) {
130 //FIXME call content manager API139 QUrl url(media->path().toLocalFile());
131 qDebug() << "Picked media:" << media->path();140 selectedMedias.append(url);
141 }
142 m_contentCommunicator->returnPhotos(selectedMedias);
143
144 if (m_defaultUiMode == BrowseContentMode) {
145 setUiMode(BrowseContentMode);
146 } else {
147 qApp->quit();
132 }148 }
133}149}
134150
@@ -138,7 +154,13 @@
138 */154 */
139void GalleryManager::contentPickingCanceled()155void GalleryManager::contentPickingCanceled()
140{156{
141 //FIXME call content manager API157 m_contentCommunicator->cancelTransfer();
158
159 if (m_defaultUiMode == BrowseContentMode) {
160 setUiMode(BrowseContentMode);
161 } else {
162 qApp->quit();
163 }
142}164}
143165
144/*!166/*!
@@ -240,6 +262,41 @@
240}262}
241263
242/*!264/*!
265 * \brief GalleryManager::setDefaultUiMode set the default UI mode. This might
266 * get overridden during the lifetime
267 * \param mode
268 */
269void GalleryManager::setDefaultUiMode(GalleryManager::UiMode mode)
270{
271 m_defaultUiMode = mode;
272 m_pickModeEnabled = true;
273}
274
275/*!
276 * \brief GalleryManager::setUiMode set's the current UI mode
277 * \param mode
278 */
279void GalleryManager::setUiMode(GalleryManager::UiMode mode)
280{
281 bool enablePickMode = (mode == PickContentMode);
282
283 if (enablePickMode != m_pickModeEnabled) {
284 m_pickModeEnabled = enablePickMode;
285 Q_EMIT pickModeEnabledChanged();
286 }
287}
288
289/*!
290 * \brief GalleryManager::pickModeEnabled returns if the current UI mode should be for
291 * picking acontent
292 * \return
293 */
294bool GalleryManager::pickModeEnabled() const
295{
296 return m_pickModeEnabled;
297}
298
299/*!
243 * \brief GalleryManager::logImageLoading enabled or disbaled logging image load300 * \brief GalleryManager::logImageLoading enabled or disbaled logging image load
244 * times to stdout301 * times to stdout
245 * \param log302 * \param log
@@ -343,6 +400,14 @@
343}400}
344401
345/*!402/*!
403 * \brief GalleryManager::switchToPickMode
404 */
405void GalleryManager::switchToPickMode()
406{
407 setUiMode(PickContentMode);
408}
409
410/*!
346 * \brief GalleryManager::takeGalleryStandardImageProvider returns the standard image provider411 * \brief GalleryManager::takeGalleryStandardImageProvider returns the standard image provider
347 * and gives up the owndership 412 * and gives up the owndership
348 */413 */
349414
=== modified file 'src/gallery-manager.h'
--- src/gallery-manager.h 2013-08-13 09:31:23 +0000
+++ src/gallery-manager.h 2013-08-28 19:23:56 +0000
@@ -32,6 +32,7 @@
3232
33class AlbumCollection;33class AlbumCollection;
34class AlbumDefaultTemplate;34class AlbumDefaultTemplate;
35class ContentCommunicator;
35class Database;36class Database;
36class EventCollection;37class EventCollection;
37class GalleryManager;38class GalleryManager;
@@ -51,9 +52,13 @@
51{52{
52 Q_OBJECT53 Q_OBJECT
53 Q_PROPERTY(QmlMediaCollectionModel* mediaLibrary READ mediaLibrary NOTIFY mediaLibraryChanged)54 Q_PROPERTY(QmlMediaCollectionModel* mediaLibrary READ mediaLibrary NOTIFY mediaLibraryChanged)
5455 Q_PROPERTY(bool pickModeEnabled READ pickModeEnabled NOTIFY pickModeEnabledChanged)
5556
56public:57public:
58 enum UiMode{
59 BrowseContentMode,
60 PickContentMode
61 };
57 GalleryManager(const QString &picturesDir, QQuickView *view);62 GalleryManager(const QString &picturesDir, QQuickView *view);
58 ~GalleryManager();63 ~GalleryManager();
5964
@@ -78,12 +83,18 @@
7883
79 QmlMediaCollectionModel *mediaLibrary() const;84 QmlMediaCollectionModel *mediaLibrary() const;
8085
86 void setDefaultUiMode(UiMode mode);
87 void setUiMode(UiMode mode);
88 bool pickModeEnabled() const;
89
81signals:90signals:
82 void mediaLibraryChanged();91 void mediaLibraryChanged();
92 void pickModeEnabledChanged();
8393
84private slots:94private slots:
85 void onMediaItemAdded(QString file);95 void onMediaItemAdded(QString file);
86 void onMediaItemRemoved(qint64 mediaId);96 void onMediaItemRemoved(qint64 mediaId);
97 void switchToPickMode();
8798
88private:99private:
89 GalleryManager(const GalleryManager&);100 GalleryManager(const GalleryManager&);
@@ -108,6 +119,9 @@
108 PreviewManager* m_previewManager;119 PreviewManager* m_previewManager;
109 MediaObjectFactory *m_mediaFactory;120 MediaObjectFactory *m_mediaFactory;
110 MediaMonitor *m_monitor;121 MediaMonitor *m_monitor;
122 ContentCommunicator *m_contentCommunicator;
123 bool m_pickModeEnabled;
124 UiMode m_defaultUiMode;
111125
112 mutable QmlMediaCollectionModel *m_mediaLibrary;126 mutable QmlMediaCollectionModel *m_mediaLibrary;
113};127};
114128
=== added file 'tests/unittests/stubs/content-communicator_stub.cpp'
--- tests/unittests/stubs/content-communicator_stub.cpp 1970-01-01 00:00:00 +0000
+++ tests/unittests/stubs/content-communicator_stub.cpp 2013-08-28 19:23:56 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include <content-communicator.h>
19
20using namespace com::ubuntu::content;
21
22ContentCommunicator::ContentCommunicator(QObject *parent)
23 : ImportExportHandler(parent),
24 m_transfer(nullptr)
25{
26}
27
28void ContentCommunicator::handle_import(content::Transfer *)
29{
30}
31
32void ContentCommunicator::handle_export(content::Transfer *)
33{
34}
35
36void ContentCommunicator::cancelTransfer()
37{
38}
39
40void ContentCommunicator::returnPhotos(const QVector<QUrl> &urls)
41{
42 Q_UNUSED(urls);
43}
044
=== modified file 'tests/unittests/stubs/gallery-manager_stub.cpp'
--- tests/unittests/stubs/gallery-manager_stub.cpp 2013-08-13 09:31:23 +0000
+++ tests/unittests/stubs/gallery-manager_stub.cpp 2013-08-28 19:23:56 +0000
@@ -119,6 +119,15 @@
119 Q_UNUSED(mediaId);119 Q_UNUSED(mediaId);
120}120}
121121
122bool GalleryManager::pickModeEnabled() const
123{
124 return false;
125}
126
127void GalleryManager::switchToPickMode()
128{
129}
130
122GalleryStandardImageProvider* GalleryManager::takeGalleryStandardImageProvider()131GalleryStandardImageProvider* GalleryManager::takeGalleryStandardImageProvider()
123{132{
124 return 0;133 return 0;
@@ -127,4 +136,4 @@
127GalleryThumbnailImageProvider* GalleryManager::takeGalleryThumbnailImageProvider()136GalleryThumbnailImageProvider* GalleryManager::takeGalleryThumbnailImageProvider()
128{137{
129 return 0;138 return 0;
130}
131\ No newline at end of file139\ No newline at end of file
140}
132141
=== modified file 'tests/unittests/video/CMakeLists.txt'
--- tests/unittests/video/CMakeLists.txt 2013-08-14 07:26:50 +0000
+++ tests/unittests/video/CMakeLists.txt 2013-08-28 19:23:56 +0000
@@ -24,10 +24,16 @@
24 ${gallery_video_src_SOURCE_DIR}24 ${gallery_video_src_SOURCE_DIR}
25 )25 )
2626
27QT_WRAP_CPP(mediaobjectfactory TST_VIDEO_MOCS
28 ${gallery_src_SOURCE_DIR}/content-communicator.h
29 )
30
27add_executable(video31add_executable(video
28 tst_video.cpp32 tst_video.cpp
29 ${gallery_src_SOURCE_DIR}/gallery-manager.cpp33 ${gallery_src_SOURCE_DIR}/gallery-manager.cpp
30 ${gallery_src_SOURCE_DIR}/media-object-factory.cpp34 ${gallery_src_SOURCE_DIR}/media-object-factory.cpp
35 ../stubs/content-communicator_stub.cpp
36 ${TST_VIDEO_MOCS}
31 )37 )
3238
33qt5_use_modules(video Widgets Core Qml Quick Test)39qt5_use_modules(video Widgets Core Qml Quick Test)
@@ -48,4 +54,5 @@
48 gallery-qml54 gallery-qml
49 gallery-util55 gallery-util
50 gallery-video56 gallery-video
57 "content-hub"
51 )58 )

Subscribers

People subscribed via source and target branches