Changeset View
Changeset View
Standalone View
Standalone View
src/models/singleartistproxymodel.cpp
Show All 16 Lines | |||||
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | * Boston, MA 02110-1301, USA. | 18 | * Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "singleartistproxymodel.h" | 21 | #include "singleartistproxymodel.h" | ||
22 | 22 | | |||
23 | #include "allalbumsmodel.h" | 23 | #include "allalbumsmodel.h" | ||
24 | 24 | | |||
25 | #include <QReadLocker> | ||||
26 | #include <QtConcurrentRun> | ||||
27 | | ||||
28 | SingleArtistProxyModel::SingleArtistProxyModel(QObject *parent) : AbstractMediaProxyModel(parent) | ||||
29 | { | ||||
30 | } | ||||
31 | | ||||
32 | SingleArtistProxyModel::~SingleArtistProxyModel() | ||||
33 | { | ||||
34 | } | ||||
35 | | ||||
25 | QString SingleArtistProxyModel::artistFilter() const | 36 | QString SingleArtistProxyModel::artistFilter() const | ||
26 | { | 37 | { | ||
27 | return mArtistFilter; | 38 | return mArtistFilter; | ||
28 | } | 39 | } | ||
29 | 40 | | |||
30 | 41 | | |||
31 | void SingleArtistProxyModel::setArtistFilterText(const QString &filterText) | 42 | void SingleArtistProxyModel::setArtistFilterText(const QString &filterText) | ||
32 | { | 43 | { | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 62 | for (int column = 0, columnCount = sourceModel()->columnCount(source_parent); column < columnCount; ++column) { | |||
77 | } | 88 | } | ||
78 | } | 89 | } | ||
79 | 90 | | |||
80 | return result; | 91 | return result; | ||
81 | } | 92 | } | ||
82 | 93 | | |||
83 | void SingleArtistProxyModel::enqueueToPlayList() | 94 | void SingleArtistProxyModel::enqueueToPlayList() | ||
84 | { | 95 | { | ||
85 | MediaPlayList *playList = AbstractMediaProxyModel::mediaPlayList(); | 96 | QtConcurrent::run(&mThreadPool, [=] () { | ||
86 | for (int columnIndex = 0, columnCount = this->columnCount(); columnIndex < columnCount; ++columnIndex) { | 97 | QReadLocker locker(&mDataLock); | ||
87 | for (int rowIndex = 0, rowCount = this->rowCount(); rowIndex < rowCount; ++rowIndex) { | 98 | auto allAlbums = QList<MusicAlbum>(); | ||
88 | auto currentIndex = this->index(rowIndex, columnIndex); | 99 | allAlbums.reserve(rowCount()); | ||
89 | playList->enqueue(this->data(currentIndex,AllAlbumsModel::ContainerDataRole).value<MusicAlbum>()); | 100 | for (int rowIndex = 0, maxRowCount = rowCount(); rowIndex < maxRowCount; ++rowIndex) { | ||
90 | } | 101 | auto currentIndex = index(rowIndex, 0); | ||
102 | allAlbums.push_back(data(currentIndex, AllAlbumsModel::ContainerDataRole). value<MusicAlbum>()); | ||||
103 | } | ||||
104 | Q_EMIT albumToEnqueue(allAlbums, | ||||
105 | ElisaUtils::AppendPlayList, | ||||
106 | ElisaUtils::DoNotTriggerPlay); | ||||
107 | }); | ||||
91 | } | 108 | } | ||
92 | 109 | | |||
110 | void SingleArtistProxyModel::replaceAndPlayOfPlayList() | ||||
111 | { | ||||
112 | QtConcurrent::run(&mThreadPool, [=] () { | ||||
113 | QReadLocker locker(&mDataLock); | ||||
114 | auto allAlbums = QList<MusicAlbum>(); | ||||
115 | allAlbums.reserve(rowCount()); | ||||
116 | for (int rowIndex = 0, maxRowCount = rowCount(); rowIndex < maxRowCount; ++rowIndex) { | ||||
117 | auto currentIndex = index(rowIndex, 0); | ||||
118 | allAlbums.push_back(data(currentIndex, AllAlbumsModel::ContainerDataRole). value<MusicAlbum>()); | ||||
119 | } | ||||
120 | Q_EMIT albumToEnqueue(allAlbums, | ||||
121 | ElisaUtils::ReplacePlayList, | ||||
122 | ElisaUtils::TriggerPlay); | ||||
123 | }); | ||||
93 | } | 124 | } | ||
94 | 125 | | |||
126 | | ||||
95 | #include "moc_singleartistproxymodel.cpp" | 127 | #include "moc_singleartistproxymodel.cpp" |