|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "qmediaplaylistprovider.h" |
|
43 #include "qmediaplaylistprovider_p.h" |
|
44 |
|
45 #include <QtCore/qurl.h> |
|
46 |
|
47 QT_BEGIN_NAMESPACE |
|
48 |
|
49 /*! |
|
50 \class QMediaPlaylistProvider |
|
51 \preliminary |
|
52 \brief The QMediaPlaylistProvider class provides an abstract list of media. |
|
53 |
|
54 \sa QMediaPlaylist |
|
55 */ |
|
56 |
|
57 /*! |
|
58 Constructs a playlist provider with the given \a parent. |
|
59 */ |
|
60 QMediaPlaylistProvider::QMediaPlaylistProvider(QObject *parent) |
|
61 :QObject(parent), d_ptr(new QMediaPlaylistProviderPrivate) |
|
62 { |
|
63 } |
|
64 |
|
65 /*! |
|
66 \internal |
|
67 */ |
|
68 QMediaPlaylistProvider::QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent) |
|
69 :QObject(parent), d_ptr(&dd) |
|
70 { |
|
71 } |
|
72 |
|
73 /*! |
|
74 Destroys a playlist provider. |
|
75 */ |
|
76 QMediaPlaylistProvider::~QMediaPlaylistProvider() |
|
77 { |
|
78 delete d_ptr; |
|
79 } |
|
80 |
|
81 /*! |
|
82 \fn QMediaPlaylistProvider::mediaCount() const; |
|
83 |
|
84 Returns the size of playlist. |
|
85 */ |
|
86 |
|
87 /*! |
|
88 \fn QMediaPlaylistProvider::media(int index) const; |
|
89 |
|
90 Returns the media at \a index in the playlist. |
|
91 |
|
92 If the index is invalid this will return a null media content. |
|
93 */ |
|
94 |
|
95 |
|
96 /*! |
|
97 Loads a playlist from from a URL \a location. If no playlist \a format is specified the loader |
|
98 will inspect the URL or probe the headers to guess the format. |
|
99 |
|
100 New items are appended to playlist. |
|
101 |
|
102 Returns true if the provider supports the format and loading from the locations URL protocol, |
|
103 otherwise this will return false. |
|
104 */ |
|
105 bool QMediaPlaylistProvider::load(const QUrl &location, const char *format) |
|
106 { |
|
107 Q_UNUSED(location); |
|
108 Q_UNUSED(format); |
|
109 return false; |
|
110 } |
|
111 |
|
112 /*! |
|
113 Loads a playlist from from an I/O \a device. If no playlist \a format is specified the loader |
|
114 will probe the headers to guess the format. |
|
115 |
|
116 New items are appended to playlist. |
|
117 |
|
118 Returns true if the provider supports the format and loading from an I/O device, otherwise this |
|
119 will return false. |
|
120 */ |
|
121 bool QMediaPlaylistProvider::load(QIODevice * device, const char *format) |
|
122 { |
|
123 Q_UNUSED(device); |
|
124 Q_UNUSED(format); |
|
125 return false; |
|
126 } |
|
127 |
|
128 /*! |
|
129 Saves the contents of a playlist to a URL \a location. If no playlist \a format is specified |
|
130 the writer will inspect the URL to guess the format. |
|
131 |
|
132 Returns true if the playlist was saved succesfully; and false otherwise. |
|
133 */ |
|
134 bool QMediaPlaylistProvider::save(const QUrl &location, const char *format) |
|
135 { |
|
136 Q_UNUSED(location); |
|
137 Q_UNUSED(format); |
|
138 return false; |
|
139 } |
|
140 |
|
141 /*! |
|
142 Saves the contents of a playlist to an I/O \a device in the specified \a format. |
|
143 |
|
144 Returns true if the playlist was saved succesfully; and false otherwise. |
|
145 */ |
|
146 bool QMediaPlaylistProvider::save(QIODevice * device, const char *format) |
|
147 { |
|
148 Q_UNUSED(device); |
|
149 Q_UNUSED(format); |
|
150 return false; |
|
151 } |
|
152 |
|
153 /*! |
|
154 Returns true if a playlist is read-only; otherwise returns false. |
|
155 */ |
|
156 bool QMediaPlaylistProvider::isReadOnly() const |
|
157 { |
|
158 return true; |
|
159 } |
|
160 |
|
161 /*! |
|
162 Append \a media to a playlist. |
|
163 |
|
164 Returns true if the media was appended; and false otherwise. |
|
165 */ |
|
166 bool QMediaPlaylistProvider::addMedia(const QMediaContent &media) |
|
167 { |
|
168 Q_UNUSED(media); |
|
169 return false; |
|
170 } |
|
171 |
|
172 /*! |
|
173 Append multiple media \a items to a playlist. |
|
174 |
|
175 Returns true if the media items were appended; and false otherwise. |
|
176 */ |
|
177 bool QMediaPlaylistProvider::addMedia(const QList<QMediaContent> &items) |
|
178 { |
|
179 foreach(const QMediaContent &item, items) { |
|
180 if (!addMedia(item)) |
|
181 return false; |
|
182 } |
|
183 |
|
184 return true; |
|
185 } |
|
186 |
|
187 /*! |
|
188 Inserts \a media into a playlist at \a position. |
|
189 |
|
190 Returns true if the media was inserted; and false otherwise. |
|
191 */ |
|
192 bool QMediaPlaylistProvider::insertMedia(int position, const QMediaContent &media) |
|
193 { |
|
194 Q_UNUSED(position); |
|
195 Q_UNUSED(media); |
|
196 return false; |
|
197 } |
|
198 |
|
199 /*! |
|
200 Inserts multiple media \a items into a playlist at \a position. |
|
201 |
|
202 Returns true if the media \a items were inserted; and false otherwise. |
|
203 */ |
|
204 bool QMediaPlaylistProvider::insertMedia(int position, const QList<QMediaContent> &items) |
|
205 { |
|
206 for (int i=0; i<items.count(); i++) { |
|
207 if (!insertMedia(position+i,items.at(i))) |
|
208 return false; |
|
209 } |
|
210 |
|
211 return true; |
|
212 } |
|
213 |
|
214 |
|
215 /*! |
|
216 Removes the media at \a position from a playlist. |
|
217 |
|
218 Returns true if the media was removed; and false otherwise. |
|
219 */ |
|
220 bool QMediaPlaylistProvider::removeMedia(int position) |
|
221 { |
|
222 Q_UNUSED(position); |
|
223 return false; |
|
224 } |
|
225 |
|
226 /*! |
|
227 Removes the media between the given \a start and \a end positions from a playlist. |
|
228 |
|
229 Returns true if the media was removed; and false otherwise. |
|
230 */ |
|
231 bool QMediaPlaylistProvider::removeMedia(int start, int end) |
|
232 { |
|
233 for (int pos=start; pos<=end; pos++) { |
|
234 if (!removeMedia(pos)) |
|
235 return false; |
|
236 } |
|
237 |
|
238 return true; |
|
239 } |
|
240 |
|
241 /*! |
|
242 Removes all media from a playlist. |
|
243 |
|
244 Returns true if the media was removed; and false otherwise. |
|
245 */ |
|
246 bool QMediaPlaylistProvider::clear() |
|
247 { |
|
248 return removeMedia(0, mediaCount()-1); |
|
249 } |
|
250 |
|
251 /*! |
|
252 Shuffles the contents of a playlist. |
|
253 */ |
|
254 void QMediaPlaylistProvider::shuffle() |
|
255 { |
|
256 } |
|
257 |
|
258 /*! |
|
259 \fn void QMediaPlaylistProvider::mediaAboutToBeInserted(int start, int end); |
|
260 |
|
261 Signals that new media is about to be inserted into a playlist between the \a start and \a end |
|
262 positions. |
|
263 */ |
|
264 |
|
265 /*! |
|
266 \fn void QMediaPlaylistProvider::mediaInserted(int start, int end); |
|
267 |
|
268 Signals that new media has been inserted into a playlist between the \a start and \a end |
|
269 positions. |
|
270 */ |
|
271 |
|
272 /*! |
|
273 \fn void QMediaPlaylistProvider::mediaAboutToBeRemoved(int start, int end); |
|
274 |
|
275 Signals that media is about to be removed from a playlist between the \a start and \a end |
|
276 positions. |
|
277 */ |
|
278 |
|
279 /*! |
|
280 \fn void QMediaPlaylistProvider::mediaRemoved(int start, int end); |
|
281 |
|
282 Signals that media has been removed from a playlist between the \a start and \a end positions. |
|
283 */ |
|
284 |
|
285 /*! |
|
286 \fn void QMediaPlaylistProvider::mediaChanged(int start, int end); |
|
287 |
|
288 Signals that media in playlist between the \a start and \a end positions inclusive has changed. |
|
289 */ |
|
290 |
|
291 /*! |
|
292 \fn void QMediaPlaylistProvider::loaded() |
|
293 |
|
294 Signals that a load() finished successfully. |
|
295 */ |
|
296 |
|
297 /*! |
|
298 \fn void QMediaPlaylistProvider::loadFailed(QMediaPlaylist::Error error, const QString& errorMessage) |
|
299 |
|
300 Signals that a load failed() due to an \a error. The \a errorMessage provides more information. |
|
301 */ |
|
302 |
|
303 #include "moc_qmediaplaylistprovider.cpp" |
|
304 QT_END_NAMESPACE |
|
305 |