~ci-train-bot/qtubuntu-media/qtubuntu-media-ubuntu-yakkety-landing-056

« back to all changes in this revision

Viewing changes to src/aal/aalmediaplaylistprovider.cpp

  • Committer: CI Train Bot
  • Author(s): Jim Hodapp
  • Date: 2016-01-12 15:55:53 UTC
  • mfrom: (83.1.17 qtubuntu-media-1528898)
  • Revision ID: ci-train-bot@canonical.com-20160112155553-a9a73lqaktpkj500
Fix bug #1528898 Fixes: #1528898
Approved by: Andrew Hayzen

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <QDebug>
24
24
 
 
25
// Uncomment for more verbose debugging to stdout/err
 
26
//#define VERBOSE_DEBUG
 
27
 
25
28
namespace media = core::ubuntu::media;
26
29
 
27
30
Q_DECLARE_METATYPE(core::ubuntu::media::Track::Id)
40
43
      m_trackListResetConnection(the_void.connect([](){})),
41
44
      m_insertTrackIndex(-1)
42
45
{
43
 
    qDebug() << Q_FUNC_INFO;
44
46
    qRegisterMetaType<core::ubuntu::media::Track::Id>();
45
47
}
46
48
 
57
59
        return 0;
58
60
    }
59
61
 
60
 
    //qDebug() << "track_index_lut.size(): " << track_index_lut.size();
61
 
 
62
62
    return track_index_lut.size();
63
63
}
64
64
 
148
148
 
149
149
    media::TrackList::ContainerURI uris;
150
150
    for (const auto mediaContent : contentList) {
 
151
#ifdef VERBOSE_DEBUG
151
152
        qDebug() << "Adding track " << AalUtility::unescape(mediaContent).toString();
 
153
#endif
152
154
        uris.push_back(AalUtility::unescape_str(mediaContent));
153
155
    }
154
156
 
325
327
 
326
328
bool AalMediaPlaylistProvider::removeMedia(int start, int end)
327
329
{
328
 
    for (int i=start; i<=end; i++)
329
 
    {
330
 
        if (!removeMedia(i))
 
330
    // If we are removing everything then just use clear()
 
331
    if (start == 0 and (end + 1) == mediaCount())
 
332
    {
 
333
        return clear();
 
334
    }
 
335
    else
 
336
    {
 
337
        // Signal AalMediaPlaylistControl
 
338
        Q_EMIT removeTracks(start, end);
 
339
 
 
340
        // It's important that we remove tracks from end to start as removing tracks can
 
341
        // change the relative index value in track_index_lut relative to the Track::Id
 
342
        for (int i=end; i>=start; i--)
331
343
        {
332
 
            qWarning() << "Failed to remove the full range of tracks requested";
333
 
            return false;
 
344
            if (!removeMedia(i))
 
345
            {
 
346
                qWarning() << "Failed to remove the full range of tracks requested";
 
347
                return false;
 
348
            }
334
349
        }
335
350
    }
336
351
 
462
477
    m_trackRemovedConnection = m_hubTrackList->on_track_removed().connect([this](const media::Track::Id& id)
463
478
    {
464
479
        const int index = indexOfTrack(id);
 
480
        qDebug() << "*** Removing track Id: " << id.c_str() << "with index " << index;
465
481
        Q_EMIT mediaAboutToBeRemoved(index, index);
466
482
        // Remove the track from the local look-up-table
467
483
        const bool ret = removeTrack(id);