~ubuntu-branches/ubuntu/trusty/tomahawk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libtomahawk/playlist/PlayableProxyModel.cpp

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-03-07 21:50:13 UTC
  • Revision ID: package-import@ubuntu.com-20130307215013-6gdjkdds7i9uenvs
Tags: upstream-0.6.0+dfsg
ImportĀ upstreamĀ versionĀ 0.6.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 
2
 *
 
3
 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 
4
 *   Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
 
5
 *
 
6
 *   Tomahawk is free software: you can redistribute it and/or modify
 
7
 *   it under the terms of the GNU General Public License as published by
 
8
 *   the Free Software Foundation, either version 3 of the License, or
 
9
 *   (at your option) any later version.
 
10
 *
 
11
 *   Tomahawk is distributed in the hope that it will be useful,
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
 *   GNU General Public License for more details.
 
15
 *
 
16
 *   You should have received a copy of the GNU General Public License
 
17
 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include "PlayableProxyModel.h"
 
21
 
 
22
#include <QTreeView>
 
23
 
 
24
#include "PlayableProxyModelPlaylistInterface.h"
 
25
#include "Artist.h"
 
26
#include "Album.h"
 
27
#include "Query.h"
 
28
#include "Source.h"
 
29
#include "PlayableItem.h"
 
30
#include "utils/Logger.h"
 
31
 
 
32
 
 
33
PlayableProxyModel::PlayableProxyModel( QObject* parent )
 
34
    : QSortFilterProxyModel( parent )
 
35
    , m_model( 0 )
 
36
    , m_showOfflineResults( true )
 
37
    , m_hideDupeItems( false )
 
38
    , m_maxVisibleItems( -1 )
 
39
    , m_style( Detailed )
 
40
{
 
41
    m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::PlayableProxyModelPlaylistInterface( this ) );
 
42
 
 
43
    setFilterCaseSensitivity( Qt::CaseInsensitive );
 
44
    setSortCaseSensitivity( Qt::CaseInsensitive );
 
45
    setDynamicSortFilter( true );
 
46
 
 
47
    setSourcePlayableModel( 0 );
 
48
 
 
49
    m_headerStyle[ Large ]      << PlayableModel::Name;
 
50
    m_headerStyle[ Detailed ]   << PlayableModel::Artist << PlayableModel::Track << PlayableModel::Composer << PlayableModel::Album << PlayableModel::AlbumPos << PlayableModel::Duration << PlayableModel::Bitrate << PlayableModel::Age << PlayableModel::Year << PlayableModel::Filesize << PlayableModel::Origin << PlayableModel::Score;
 
51
    m_headerStyle[ Collection ] << PlayableModel::Name << PlayableModel::Composer << PlayableModel::Duration << PlayableModel::Bitrate << PlayableModel::Age << PlayableModel::Year << PlayableModel::Filesize << PlayableModel::Origin;
 
52
}
 
53
 
 
54
 
 
55
Tomahawk::playlistinterface_ptr
 
56
PlayableProxyModel::playlistInterface() const
 
57
{
 
58
    return m_playlistInterface;
 
59
}
 
60
 
 
61
 
 
62
void
 
63
PlayableProxyModel::setPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlistInterface )
 
64
{
 
65
    m_playlistInterface = playlistInterface;
 
66
}
 
67
 
 
68
 
 
69
QString
 
70
PlayableProxyModel::guid() const
 
71
{
 
72
    if ( m_model )
 
73
    {
 
74
        return m_model->guid();
 
75
    }
 
76
    else
 
77
        return QString();
 
78
}
 
79
 
 
80
 
 
81
bool
 
82
PlayableProxyModel::isLoading() const
 
83
{
 
84
    if ( m_model )
 
85
    {
 
86
        return m_model->isLoading();
 
87
    }
 
88
 
 
89
    return false;
 
90
}
 
91
 
 
92
 
 
93
void
 
94
PlayableProxyModel::setSourceModel( QAbstractItemModel* model )
 
95
{
 
96
    Q_UNUSED( model );
 
97
    qDebug() << "Explicitly use setSourcePlayableModel instead";
 
98
    Q_ASSERT( false );
 
99
}
 
100
 
 
101
 
 
102
void
 
103
PlayableProxyModel::setSourcePlayableModel( PlayableModel* sourceModel )
 
104
{
 
105
    if ( m_model )
 
106
    {
 
107
        disconnect( m_model, SIGNAL( loadingStarted() ), this, SIGNAL( loadingStarted() ) );
 
108
        disconnect( m_model, SIGNAL( loadingFinished() ), this, SIGNAL( loadingFinished() ) );
 
109
        disconnect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), this, SIGNAL( itemCountChanged( unsigned int ) ) );
 
110
        disconnect( m_model, SIGNAL( indexPlayable( QModelIndex ) ), this, SLOT( onIndexPlayable( QModelIndex ) ) );
 
111
        disconnect( m_model, SIGNAL( indexResolved( QModelIndex ) ), this, SLOT( onIndexResolved( QModelIndex ) ) );
 
112
        disconnect( m_model, SIGNAL( currentIndexChanged() ), this, SIGNAL( currentIndexChanged() ) );
 
113
    }
 
114
 
 
115
    m_model = sourceModel;
 
116
 
 
117
    if ( m_model )
 
118
    {
 
119
        connect( m_model, SIGNAL( loadingStarted() ), SIGNAL( loadingStarted() ) );
 
120
        connect( m_model, SIGNAL( loadingFinished() ), SIGNAL( loadingFinished() ) );
 
121
        connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SIGNAL( itemCountChanged( unsigned int ) ) );
 
122
        connect( m_model, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onIndexPlayable( QModelIndex ) ) );
 
123
        connect( m_model, SIGNAL( indexResolved( QModelIndex ) ), SLOT( onIndexResolved( QModelIndex ) ) );
 
124
        connect( m_model, SIGNAL( currentIndexChanged() ), SIGNAL( currentIndexChanged() ) );
 
125
    }
 
126
 
 
127
    QSortFilterProxyModel::setSourceModel( m_model );
 
128
}
 
129
 
 
130
 
 
131
bool
 
132
PlayableProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
 
133
{
 
134
    PlayableItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
 
135
    if ( !pi )
 
136
        return false;
 
137
 
 
138
    if ( m_maxVisibleItems > 0 && sourceRow > m_maxVisibleItems - 1 )
 
139
        return false;
 
140
 
 
141
    if ( m_hideDupeItems )
 
142
    {
 
143
        for ( int i = 0; i < sourceRow; i++ )
 
144
        {
 
145
            PlayableItem* di = itemFromIndex( sourceModel()->index( i, 0, sourceParent ) );
 
146
            if ( !di )
 
147
                continue;
 
148
 
 
149
            bool b = ( pi->query() && pi->query()->equals( di->query() ) ) ||
 
150
                     ( pi->album() && pi->album() == di->album() ) ||
 
151
                     ( pi->artist() && pi->artist()->name() == di->artist()->name() );
 
152
 
 
153
            if ( b && filterAcceptsRow( i, sourceParent ) )
 
154
                return false;
 
155
        }
 
156
    }
 
157
 
 
158
    if ( pi->query() )
 
159
    {
 
160
        const Tomahawk::query_ptr& q = pi->query()->displayQuery();
 
161
        if ( q.isNull() ) // uh oh? filter out invalid queries i guess
 
162
            return false;
 
163
 
 
164
        Tomahawk::result_ptr r;
 
165
        if ( q->numResults() )
 
166
            r = q->results().first();
 
167
 
 
168
        if ( !m_showOfflineResults && ( r.isNull() || !r->isOnline() ) )
 
169
            return false;
 
170
 
 
171
        if ( filterRegExp().isEmpty() )
 
172
            return true;
 
173
 
 
174
        QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts );
 
175
        foreach( QString s, sl )
 
176
        {
 
177
            s = s.toLower();
 
178
            if ( !q->artist().toLower().contains( s ) &&
 
179
                !q->album().toLower().contains( s ) &&
 
180
                !q->track().toLower().contains( s ) )
 
181
            {
 
182
                return false;
 
183
            }
 
184
        }
 
185
    }
 
186
 
 
187
    const Tomahawk::album_ptr& al = pi->album();
 
188
    if ( al )
 
189
    {
 
190
        QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts );
 
191
 
 
192
        bool found = true;
 
193
        foreach( const QString& s, sl )
 
194
        {
 
195
            if ( !al->name().contains( s, Qt::CaseInsensitive ) && !al->artist()->name().contains( s, Qt::CaseInsensitive ) )
 
196
            {
 
197
                found = false;
 
198
            }
 
199
        }
 
200
 
 
201
        return found;
 
202
    }
 
203
 
 
204
    const Tomahawk::album_ptr& ar = pi->album();
 
205
    if ( ar )
 
206
    {
 
207
        QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts );
 
208
 
 
209
        bool found = true;
 
210
        foreach( const QString& s, sl )
 
211
        {
 
212
            if ( !ar->name().contains( s, Qt::CaseInsensitive ) && !ar->artist()->name().contains( s, Qt::CaseInsensitive ) )
 
213
            {
 
214
                found = false;
 
215
            }
 
216
        }
 
217
 
 
218
        return found;
 
219
    }
 
220
 
 
221
    return true;
 
222
}
 
223
 
 
224
 
 
225
void
 
226
PlayableProxyModel::removeIndex( const QModelIndex& index )
 
227
{
 
228
    if ( !sourceModel() )
 
229
        return;
 
230
    if ( !index.isValid() )
 
231
        return;
 
232
 
 
233
    sourceModel()->removeIndex( mapToSource( index ) );
 
234
}
 
235
 
 
236
 
 
237
void
 
238
PlayableProxyModel::removeIndexes( const QModelIndexList& indexes )
 
239
{
 
240
    if ( !sourceModel() )
 
241
        return;
 
242
 
 
243
    QList<QPersistentModelIndex> pil;
 
244
    foreach ( const QModelIndex& idx, indexes )
 
245
    {
 
246
        if ( idx.isValid() )
 
247
            pil << mapToSource( idx );
 
248
    }
 
249
 
 
250
    sourceModel()->removeIndexes( pil );
 
251
}
 
252
 
 
253
 
 
254
void
 
255
PlayableProxyModel::removeIndexes( const QList< QPersistentModelIndex >& indexes )
 
256
{
 
257
    if ( !sourceModel() )
 
258
        return;
 
259
 
 
260
    QList<QPersistentModelIndex> pil;
 
261
    foreach ( const QPersistentModelIndex& idx, indexes )
 
262
    {
 
263
        if ( idx.isValid() )
 
264
            pil << mapToSource( idx );
 
265
    }
 
266
 
 
267
    sourceModel()->removeIndexes( pil );
 
268
}
 
269
 
 
270
 
 
271
void
 
272
PlayableProxyModel::setShowOfflineResults( bool b )
 
273
{
 
274
    m_showOfflineResults = b;
 
275
    invalidateFilter();
 
276
}
 
277
 
 
278
 
 
279
void
 
280
PlayableProxyModel::setHideDupeItems( bool b )
 
281
{
 
282
    m_hideDupeItems = b;
 
283
    invalidateFilter();
 
284
}
 
285
 
 
286
 
 
287
void
 
288
PlayableProxyModel::setMaxVisibleItems( int items )
 
289
{
 
290
    if ( m_maxVisibleItems == items )
 
291
        return;
 
292
 
 
293
    m_maxVisibleItems = items;
 
294
    invalidateFilter();
 
295
}
 
296
 
 
297
 
 
298
bool
 
299
PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const Tomahawk::query_ptr& q2 ) const
 
300
{
 
301
    const QString artist1 = q1->artistSortname();
 
302
    const QString artist2 = q2->artistSortname();
 
303
    const QString album1 = q1->albumSortname();
 
304
    const QString album2 = q2->albumSortname();
 
305
    const QString track1 = q1->trackSortname();
 
306
    const QString track2 = q2->trackSortname();
 
307
    const QString composer1 = q1->composerSortname();
 
308
    const QString composer2 = q2->composerSortname();
 
309
    const unsigned int albumpos1 = q1->albumpos();
 
310
    const unsigned int albumpos2 = q2->albumpos();
 
311
    const unsigned int discnumber1 = q1->discnumber();
 
312
    const unsigned int discnumber2 = q2->discnumber();
 
313
    unsigned int duration1 = q1->duration(), duration2 = q2->duration();
 
314
    unsigned int bitrate1 = 0, bitrate2 = 0;
 
315
    unsigned int mtime1 = 0, mtime2 = 0;
 
316
    unsigned int size1 = 0, size2 = 0;
 
317
    unsigned int year1 = 0, year2 = 0;
 
318
    float score1 = 0, score2 = 0;
 
319
    QString origin1;
 
320
    QString origin2;
 
321
    qint64 id1 = 0, id2 = 0;
 
322
 
 
323
    if ( q1->numResults() )
 
324
    {
 
325
        const Tomahawk::result_ptr& r = q1->results().at( 0 );
 
326
        bitrate1 = r->bitrate();
 
327
        duration1 = r->duration();
 
328
        mtime1 = r->modificationTime();
 
329
        size1 = r->size();
 
330
        year1 = r->year();
 
331
        score1 = r->score();
 
332
        origin1 = r->friendlySource().toLower();
 
333
        id1 = (qint64)&r;
 
334
    }
 
335
    if ( q2->numResults() )
 
336
    {
 
337
        const Tomahawk::result_ptr& r = q2->results().at( 0 );
 
338
        bitrate2 = r->bitrate();
 
339
        duration2 = r->duration();
 
340
        mtime2 = r->modificationTime();
 
341
        size2 = r->size();
 
342
        year2 = r->year();
 
343
        score2 = r->score();
 
344
        origin2 = r->friendlySource().toLower();
 
345
        id2 = (qint64)&r;
 
346
    }
 
347
 
 
348
    // This makes it a stable sorter and prevents items from randomly jumping about.
 
349
    if ( id1 == id2 )
 
350
    {
 
351
        id1 = (qint64)&q1;
 
352
        id2 = (qint64)&q2;
 
353
    }
 
354
 
 
355
    if ( column == PlayableModel::Artist ) // sort by artist
 
356
    {
 
357
        if ( artist1 == artist2 )
 
358
        {
 
359
            if ( album1 == album2 )
 
360
            {
 
361
                if ( discnumber1 == discnumber2 )
 
362
                {
 
363
                    if ( albumpos1 == albumpos2 )
 
364
                        return id1 < id2;
 
365
 
 
366
                    return albumpos1 < albumpos2;
 
367
                }
 
368
 
 
369
                return discnumber1 < discnumber2;
 
370
            }
 
371
 
 
372
            return QString::localeAwareCompare( album1, album2 ) < 0;
 
373
        }
 
374
 
 
375
        return QString::localeAwareCompare( artist1, artist2 ) < 0;
 
376
    }
 
377
    else if ( column == PlayableModel::Composer ) // sort by composer
 
378
    {
 
379
        if ( composer1 == composer2 )
 
380
        {
 
381
            if ( album1 == album2 )
 
382
            {
 
383
                if ( discnumber1 == discnumber2 )
 
384
                {
 
385
                    if ( albumpos1 == albumpos2 )
 
386
                        return id1 < id2;
 
387
 
 
388
                    return albumpos1 < albumpos2;
 
389
                }
 
390
 
 
391
                return discnumber1 < discnumber2;
 
392
            }
 
393
 
 
394
            return QString::localeAwareCompare( album1, album2 ) < 0;
 
395
        }
 
396
 
 
397
        return QString::localeAwareCompare( composer1, composer2 ) < 0;
 
398
    }
 
399
    else if ( column == PlayableModel::Album ) // sort by album
 
400
    {
 
401
        if ( album1 == album2 )
 
402
        {
 
403
            if ( discnumber1 == discnumber2 )
 
404
            {
 
405
                if ( albumpos1 == albumpos2 )
 
406
                    return id1 < id2;
 
407
 
 
408
                return albumpos1 < albumpos2;
 
409
            }
 
410
 
 
411
            return discnumber1 < discnumber2;
 
412
        }
 
413
 
 
414
        return QString::localeAwareCompare( album1, album2 ) < 0;
 
415
    }
 
416
    else if ( column == PlayableModel::Bitrate ) // sort by bitrate
 
417
    {
 
418
        if ( bitrate1 == bitrate2 )
 
419
            return id1 < id2;
 
420
 
 
421
        return bitrate1 < bitrate2;
 
422
    }
 
423
    else if ( column == PlayableModel::Duration ) // sort by duration
 
424
    {
 
425
        if ( duration1 == duration2 )
 
426
            return id1 < id2;
 
427
 
 
428
        return duration1 < duration2;
 
429
    }
 
430
    else if ( column == PlayableModel::Age ) // sort by mtime
 
431
    {
 
432
        if ( mtime1 == mtime2 )
 
433
            return id1 < id2;
 
434
 
 
435
        return mtime1 < mtime2;
 
436
    }
 
437
    else if ( column == PlayableModel::Year ) // sort by release year
 
438
    {
 
439
        if ( year1 == year2 )
 
440
            return id1 < id2;
 
441
 
 
442
        return year1 < year2;
 
443
    }
 
444
    else if ( column == PlayableModel::Filesize ) // sort by file size
 
445
    {
 
446
        if ( size1 == size2 )
 
447
            return id1 < id2;
 
448
 
 
449
        return size1 < size2;
 
450
    }
 
451
    else if ( column == PlayableModel::Score ) // sort by file score
 
452
    {
 
453
        if ( score1 == score2 )
 
454
            return id1 < id2;
 
455
 
 
456
        return score1 < score2;
 
457
    }
 
458
    else if ( column == PlayableModel::Origin ) // sort by file origin
 
459
    {
 
460
        if ( origin1 == origin2 )
 
461
            return id1 < id2;
 
462
 
 
463
        return origin1 < origin2;
 
464
    }
 
465
    else if ( column == PlayableModel::AlbumPos ) // sort by album pos
 
466
    {
 
467
        if ( discnumber1 != discnumber2 )
 
468
        {
 
469
            return discnumber1 < discnumber2;
 
470
        }
 
471
        else
 
472
        {
 
473
            if ( albumpos1 != albumpos2 )
 
474
                return albumpos1 < albumpos2;
 
475
        }
 
476
    }
 
477
 
 
478
    const QString& lefts = q1->track();
 
479
    const QString& rights = q2->track();
 
480
    if ( lefts == rights )
 
481
        return id1 < id2;
 
482
 
 
483
    return QString::localeAwareCompare( lefts, rights ) < 0;
 
484
}
 
485
 
 
486
 
 
487
bool
 
488
PlayableProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
 
489
{
 
490
    PlayableItem* p1 = itemFromIndex( left );
 
491
    PlayableItem* p2 = itemFromIndex( right );
 
492
 
 
493
    if ( !p1 )
 
494
        return true;
 
495
    if ( !p2 )
 
496
        return false;
 
497
 
 
498
    if ( p1->query() && p2->query() )
 
499
    {
 
500
        const Tomahawk::query_ptr& q1 = p1->query()->displayQuery();
 
501
        const Tomahawk::query_ptr& q2 = p2->query()->displayQuery();
 
502
        return lessThan( left.column(), q1, q2 );
 
503
    }
 
504
 
 
505
    return QString::localeAwareCompare( sourceModel()->data( left ).toString(), sourceModel()->data( right ).toString() ) < 0;
 
506
}
 
507
 
 
508
 
 
509
int
 
510
PlayableProxyModel::columnCount( const QModelIndex& parent ) const
 
511
{
 
512
    Q_UNUSED( parent );
 
513
 
 
514
    switch ( m_style )
 
515
    {
 
516
        case Short:
 
517
        case ShortWithAvatars:
 
518
        case Large:
 
519
            return 1;
 
520
            break;
 
521
 
 
522
        case Collection:
 
523
            return 8;
 
524
            break;
 
525
 
 
526
        case Detailed:
 
527
        default:
 
528
            return 12;
 
529
            break;
 
530
    }
 
531
}
 
532
 
 
533
 
 
534
QVariant
 
535
PlayableProxyModel::data( const QModelIndex& index, int role ) const
 
536
{
 
537
    if ( role == StyleRole )
 
538
    {
 
539
        return m_style;
 
540
    }
 
541
 
 
542
    if ( !sourceModel() )
 
543
        return QVariant();
 
544
    if ( !m_headerStyle.contains( m_style ) )
 
545
        return QVariant();
 
546
    if ( index.column() < 0 )
 
547
        return QVariant();
 
548
 
 
549
    PlayableModel::Columns col = m_headerStyle[ m_style ].at( index.column() );
 
550
    QModelIndex sourceIdx = mapToSource( index );
 
551
    QModelIndex idx = sourceModel()->index( sourceIdx.row(), (int)col, sourceIdx.parent() );
 
552
 
 
553
    return idx.data( role );
 
554
}
 
555
 
 
556
 
 
557
QVariant
 
558
PlayableProxyModel::headerData( int section, Qt::Orientation orientation, int role ) const
 
559
{
 
560
    if ( !sourceModel() )
 
561
        return QVariant();
 
562
    if ( !m_headerStyle.contains( m_style ) )
 
563
        return QVariant();
 
564
 
 
565
    if ( section < m_headerStyle[ m_style ].count() )
 
566
    {
 
567
        PlayableModel::Columns col = m_headerStyle[ m_style ].at( section );
 
568
        return sourceModel()->headerData( (int)col, orientation, role );
 
569
    }
 
570
    else
 
571
        return sourceModel()->headerData( 255, orientation, role );
 
572
}
 
573
 
 
574
 
 
575
QList< double >
 
576
PlayableProxyModel::columnWeights() const
 
577
{
 
578
    QList< double > w;
 
579
 
 
580
    switch ( m_style )
 
581
    {
 
582
        case Short:
 
583
        case ShortWithAvatars:
 
584
        case Large:
 
585
            w << 1.0;
 
586
            break;
 
587
 
 
588
        case Collection:
 
589
            w << 0.42 << 0.12 << 0.07 << 0.07 << 0.07 << 0.07 << 0.07; // << 0.11;
 
590
            break;
 
591
 
 
592
        case Detailed:
 
593
        default:
 
594
            w << 0.15 << 0.15 << 0.12 << 0.12 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.09; // << 0.03;
 
595
            break;
 
596
    }
 
597
 
 
598
    return w;
 
599
}
 
600
 
 
601
 
 
602
void
 
603
PlayableProxyModel::updateDetailedInfo( const QModelIndex& index )
 
604
{
 
605
    if ( style() != PlayableProxyModel::Short && style() != PlayableProxyModel::Large )
 
606
        return;
 
607
 
 
608
    PlayableItem* item = itemFromIndex( mapToSource( index ) );
 
609
    if ( item->query().isNull() )
 
610
        return;
 
611
 
 
612
    if ( style() == PlayableProxyModel::Short || style() == PlayableProxyModel::Large )
 
613
    {
 
614
        item->query()->displayQuery()->cover( QSize( 0, 0 ) );
 
615
    }
 
616
 
 
617
    if ( style() == PlayableProxyModel::Large )
 
618
    {
 
619
        item->query()->loadSocialActions();
 
620
    }
 
621
}
 
622
 
 
623
 
 
624
void
 
625
PlayableProxyModel::setFilter( const QString& pattern )
 
626
{
 
627
    if ( pattern != filterRegExp().pattern() )
 
628
    {
 
629
        setFilterRegExp( pattern );
 
630
        emit filterChanged( pattern );
 
631
    }
 
632
}
 
633
 
 
634
 
 
635
void
 
636
PlayableProxyModel::setCurrentIndex( const QModelIndex& index )
 
637
{
 
638
    tDebug() << Q_FUNC_INFO;
 
639
    m_model->setCurrentIndex( mapToSource( index ) );
 
640
}
 
641
 
 
642
 
 
643
void
 
644
PlayableProxyModel::onIndexPlayable( const QModelIndex& index )
 
645
{
 
646
    emit indexPlayable( mapFromSource( index ) );
 
647
}
 
648
 
 
649
 
 
650
void
 
651
PlayableProxyModel::onIndexResolved( const QModelIndex& index )
 
652
{
 
653
    emit indexResolved( mapFromSource( index ) );
 
654
}