Changeset View
Changeset View
Standalone View
Standalone View
src/manageheaderbar.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
51 | } | 51 | } | ||
52 | 52 | | |||
53 | void ManageHeaderBar::setAlbumRole(int value) | 53 | void ManageHeaderBar::setAlbumRole(int value) | ||
54 | { | 54 | { | ||
55 | mAlbumRole = value; | 55 | mAlbumRole = value; | ||
56 | Q_EMIT albumRoleChanged(); | 56 | Q_EMIT albumRoleChanged(); | ||
57 | } | 57 | } | ||
58 | 58 | | |||
59 | void ManageHeaderBar::setFileNameRole(int value) | ||||
60 | { | ||||
61 | mFileNameRole = value; | ||||
62 | Q_EMIT fileNameRoleChanged(); | ||||
63 | } | ||||
64 | | ||||
59 | int ManageHeaderBar::albumRole() const | 65 | int ManageHeaderBar::albumRole() const | ||
60 | { | 66 | { | ||
61 | return mAlbumRole; | 67 | return mAlbumRole; | ||
62 | } | 68 | } | ||
63 | 69 | | |||
70 | int ManageHeaderBar::fileNameRole() const | ||||
71 | { | ||||
72 | return mFileNameRole; | ||||
73 | } | ||||
74 | | ||||
64 | void ManageHeaderBar::setImageRole(int value) | 75 | void ManageHeaderBar::setImageRole(int value) | ||
65 | { | 76 | { | ||
66 | mImageRole = value; | 77 | mImageRole = value; | ||
67 | Q_EMIT imageRoleChanged(); | 78 | Q_EMIT imageRoleChanged(); | ||
68 | } | 79 | } | ||
69 | 80 | | |||
81 | void ManageHeaderBar::setDatabaseIdRole(int databaseIdRole) | ||||
82 | { | ||||
83 | mDatabaseIdRole = databaseIdRole; | ||||
84 | Q_EMIT databaseIdRoleChanged(); | ||||
85 | } | ||||
86 | | ||||
70 | int ManageHeaderBar::imageRole() const | 87 | int ManageHeaderBar::imageRole() const | ||
71 | { | 88 | { | ||
72 | return mImageRole; | 89 | return mImageRole; | ||
73 | } | 90 | } | ||
74 | 91 | | |||
92 | int ManageHeaderBar::databaseIdRole() const | ||||
93 | { | ||||
94 | return mDatabaseIdRole; | ||||
95 | } | ||||
96 | | ||||
75 | void ManageHeaderBar::setAlbumIdRole(int albumIdRole) | 97 | void ManageHeaderBar::setAlbumIdRole(int albumIdRole) | ||
76 | { | 98 | { | ||
77 | mAlbumIdRole = albumIdRole; | 99 | mAlbumIdRole = albumIdRole; | ||
78 | Q_EMIT albumIdRoleChanged(); | 100 | Q_EMIT albumIdRoleChanged(); | ||
79 | } | 101 | } | ||
80 | 102 | | |||
81 | int ManageHeaderBar::albumIdRole() const | 103 | int ManageHeaderBar::albumIdRole() const | ||
82 | { | 104 | { | ||
83 | return mAlbumIdRole; | 105 | return mAlbumIdRole; | ||
84 | } | 106 | } | ||
85 | 107 | | |||
86 | QVariant ManageHeaderBar::album() const | 108 | QVariant ManageHeaderBar::album() const | ||
87 | { | 109 | { | ||
88 | if (!mCurrentTrack.isValid()) { | 110 | if (!mCurrentTrack.isValid()) { | ||
89 | return QString(); | 111 | return QString(); | ||
90 | } | 112 | } | ||
91 | 113 | | |||
92 | return mCurrentTrack.data(mAlbumRole); | 114 | return mCurrentTrack.data(mAlbumRole); | ||
93 | } | 115 | } | ||
94 | 116 | | |||
117 | QString ManageHeaderBar::fileName() const | ||||
118 | { | ||||
119 | QString result; | ||||
120 | | ||||
121 | if (!mCurrentTrack.isValid()) { | ||||
122 | return result; | ||||
123 | } | ||||
124 | | ||||
125 | auto fileNameUrl = mCurrentTrack.data(mFileNameRole).toUrl(); | ||||
126 | if (fileNameUrl.isLocalFile()) { | ||||
127 | result = fileNameUrl.toLocalFile(); | ||||
128 | } else { | ||||
129 | result = fileNameUrl.toString(); | ||||
130 | } | ||||
131 | | ||||
132 | return result; | ||||
133 | } | ||||
134 | | ||||
95 | QVariant ManageHeaderBar::title() const | 135 | QVariant ManageHeaderBar::title() const | ||
96 | { | 136 | { | ||
97 | if (!mCurrentTrack.isValid()) { | 137 | if (!mCurrentTrack.isValid()) { | ||
98 | return QString(); | 138 | return QString(); | ||
99 | } | 139 | } | ||
100 | 140 | | |||
101 | return mCurrentTrack.data(mTitleRole); | 141 | return mCurrentTrack.data(mTitleRole); | ||
102 | } | 142 | } | ||
Show All 11 Lines | |||||
114 | { | 154 | { | ||
115 | if (!mCurrentTrack.isValid()) { | 155 | if (!mCurrentTrack.isValid()) { | ||
116 | return {}; | 156 | return {}; | ||
117 | } | 157 | } | ||
118 | 158 | | |||
119 | return mCurrentTrack.data(mImageRole).toUrl(); | 159 | return mCurrentTrack.data(mImageRole).toUrl(); | ||
120 | } | 160 | } | ||
121 | 161 | | |||
162 | qulonglong ManageHeaderBar::databaseId() const | ||||
163 | { | ||||
164 | if (!mCurrentTrack.isValid()) { | ||||
165 | return 0; | ||||
166 | } | ||||
167 | | ||||
168 | return mCurrentTrack.data(mDatabaseIdRole).toULongLong(); | ||||
169 | } | ||||
170 | | ||||
122 | qulonglong ManageHeaderBar::albumId() const | 171 | qulonglong ManageHeaderBar::albumId() const | ||
123 | { | 172 | { | ||
124 | if (!mCurrentTrack.isValid()) { | 173 | if (!mCurrentTrack.isValid()) { | ||
125 | return 0; | 174 | return 0; | ||
126 | } | 175 | } | ||
127 | 176 | | |||
128 | return mCurrentTrack.data(mAlbumIdRole).toULongLong(); | 177 | return mCurrentTrack.data(mAlbumIdRole).toULongLong(); | ||
129 | } | 178 | } | ||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 235 | { | |||
195 | if (mCurrentTrack.column() > bottomRight.column() || mCurrentTrack.column() < topLeft.column()) { | 244 | if (mCurrentTrack.column() > bottomRight.column() || mCurrentTrack.column() < topLeft.column()) { | ||
196 | return; | 245 | return; | ||
197 | } | 246 | } | ||
198 | 247 | | |||
199 | if (roles.isEmpty()) { | 248 | if (roles.isEmpty()) { | ||
200 | notifyArtistProperty(); | 249 | notifyArtistProperty(); | ||
201 | notifyTitleProperty(); | 250 | notifyTitleProperty(); | ||
202 | notifyAlbumProperty(); | 251 | notifyAlbumProperty(); | ||
252 | notifyFileNameProperty(); | ||||
203 | notifyImageProperty(); | 253 | notifyImageProperty(); | ||
254 | notifyDatabaseIdProperty(); | ||||
204 | notifyAlbumIdProperty(); | 255 | notifyAlbumIdProperty(); | ||
205 | notifyIsValidProperty(); | 256 | notifyIsValidProperty(); | ||
206 | } else { | 257 | } else { | ||
207 | for(auto oneRole : roles) { | 258 | for(auto oneRole : roles) { | ||
208 | if (oneRole == mArtistRole) { | 259 | if (oneRole == mArtistRole) { | ||
209 | notifyArtistProperty(); | 260 | notifyArtistProperty(); | ||
210 | } | 261 | } | ||
211 | if (oneRole == mTitleRole) { | 262 | if (oneRole == mTitleRole) { | ||
212 | notifyTitleProperty(); | 263 | notifyTitleProperty(); | ||
213 | } | 264 | } | ||
214 | if (oneRole == mAlbumRole) { | 265 | if (oneRole == mAlbumRole) { | ||
215 | notifyAlbumProperty(); | 266 | notifyAlbumProperty(); | ||
216 | } | 267 | } | ||
268 | if (oneRole == mFileNameRole) { | ||||
269 | notifyFileNameProperty(); | ||||
270 | } | ||||
217 | if (oneRole == mImageRole) { | 271 | if (oneRole == mImageRole) { | ||
218 | notifyImageProperty(); | 272 | notifyImageProperty(); | ||
219 | } | 273 | } | ||
274 | if (oneRole == mDatabaseIdRole) { | ||||
275 | notifyDatabaseIdProperty(); | ||||
276 | } | ||||
220 | if (oneRole == mAlbumIdRole) { | 277 | if (oneRole == mAlbumIdRole) { | ||
221 | notifyAlbumIdProperty(); | 278 | notifyAlbumIdProperty(); | ||
222 | } | 279 | } | ||
223 | if (oneRole == mIsValidRole) { | 280 | if (oneRole == mIsValidRole) { | ||
224 | notifyIsValidProperty(); | 281 | notifyIsValidProperty(); | ||
225 | } | 282 | } | ||
226 | } | 283 | } | ||
227 | } | 284 | } | ||
Show All 29 Lines | 313 | { | |||
257 | Q_UNUSED(parent); | 314 | Q_UNUSED(parent); | ||
258 | Q_UNUSED(first); | 315 | Q_UNUSED(first); | ||
259 | Q_UNUSED(last); | 316 | Q_UNUSED(last); | ||
260 | 317 | | |||
261 | if (!mCurrentTrack.isValid()) { | 318 | if (!mCurrentTrack.isValid()) { | ||
262 | notifyArtistProperty(); | 319 | notifyArtistProperty(); | ||
263 | notifyTitleProperty(); | 320 | notifyTitleProperty(); | ||
264 | notifyAlbumProperty(); | 321 | notifyAlbumProperty(); | ||
322 | notifyFileNameProperty(); | ||||
265 | notifyImageProperty(); | 323 | notifyImageProperty(); | ||
324 | notifyDatabaseIdProperty(); | ||||
266 | notifyAlbumIdProperty(); | 325 | notifyAlbumIdProperty(); | ||
267 | notifyIsValidProperty(); | 326 | notifyIsValidProperty(); | ||
268 | notifyRemainingTracksProperty(); | 327 | notifyRemainingTracksProperty(); | ||
269 | 328 | | |||
270 | return; | 329 | return; | ||
271 | } | 330 | } | ||
272 | 331 | | |||
273 | notifyRemainingTracksProperty(); | 332 | notifyRemainingTracksProperty(); | ||
Show All 24 Lines | 356 | { | |||
298 | auto newAlbumValue = mCurrentTrack.data(mAlbumRole); | 357 | auto newAlbumValue = mCurrentTrack.data(mAlbumRole); | ||
299 | if (mOldAlbum != newAlbumValue) { | 358 | if (mOldAlbum != newAlbumValue) { | ||
300 | Q_EMIT albumChanged(); | 359 | Q_EMIT albumChanged(); | ||
301 | 360 | | |||
302 | mOldAlbum = newAlbumValue; | 361 | mOldAlbum = newAlbumValue; | ||
303 | } | 362 | } | ||
304 | } | 363 | } | ||
305 | 364 | | |||
365 | void ManageHeaderBar::notifyFileNameProperty() | ||||
366 | { | ||||
367 | auto newFileNameValue = mCurrentTrack.data(mFileNameRole); | ||||
368 | if (mOldFileName != newFileNameValue) { | ||||
369 | Q_EMIT fileNameChanged(); | ||||
370 | | ||||
371 | mOldFileName = newFileNameValue; | ||||
372 | } | ||||
373 | } | ||||
374 | | ||||
306 | void ManageHeaderBar::notifyImageProperty() | 375 | void ManageHeaderBar::notifyImageProperty() | ||
307 | { | 376 | { | ||
308 | auto newImageValue = mCurrentTrack.data(mImageRole); | 377 | auto newImageValue = mCurrentTrack.data(mImageRole); | ||
309 | if (mOldImage != newImageValue) { | 378 | if (mOldImage != newImageValue) { | ||
310 | Q_EMIT imageChanged(); | 379 | Q_EMIT imageChanged(); | ||
311 | 380 | | |||
312 | mOldImage = newImageValue; | 381 | mOldImage = newImageValue; | ||
313 | } | 382 | } | ||
314 | } | 383 | } | ||
315 | 384 | | |||
385 | void ManageHeaderBar::notifyDatabaseIdProperty() | ||||
386 | { | ||||
387 | bool conversionOk; | ||||
388 | auto newDatabaseIdValue = mCurrentTrack.data(mDatabaseIdRole).toULongLong(&conversionOk); | ||||
389 | if (conversionOk && mOldDatabaseId != newDatabaseIdValue) { | ||||
390 | Q_EMIT databaseIdChanged(); | ||||
391 | | ||||
392 | mOldDatabaseId = newDatabaseIdValue; | ||||
393 | } else if (!conversionOk && mOldDatabaseId != 0) { | ||||
394 | Q_EMIT databaseIdChanged(); | ||||
395 | | ||||
396 | mOldDatabaseId = 0; | ||||
397 | } | ||||
398 | } | ||||
399 | | ||||
316 | void ManageHeaderBar::notifyAlbumIdProperty() | 400 | void ManageHeaderBar::notifyAlbumIdProperty() | ||
317 | { | 401 | { | ||
318 | bool conversionOk; | 402 | bool conversionOk; | ||
319 | auto newAlbumIdValue = mCurrentTrack.data(mAlbumIdRole).toULongLong(&conversionOk); | 403 | auto newAlbumIdValue = mCurrentTrack.data(mAlbumIdRole).toULongLong(&conversionOk); | ||
320 | if (conversionOk && mOldAlbumId != newAlbumIdValue) { | 404 | if (conversionOk && mOldAlbumId != newAlbumIdValue) { | ||
321 | Q_EMIT albumIdChanged(); | 405 | Q_EMIT albumIdChanged(); | ||
322 | 406 | | |||
323 | mOldAlbumId = newAlbumIdValue; | 407 | mOldAlbumId = newAlbumIdValue; | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 442 | { | |||
368 | if (mCurrentTrack.isValid() && oldRemainingTracksCount != remainingTracks()) { | 452 | if (mCurrentTrack.isValid() && oldRemainingTracksCount != remainingTracks()) { | ||
369 | Q_EMIT remainingTracksChanged(); | 453 | Q_EMIT remainingTracksChanged(); | ||
370 | mOldRemainingTracks = remainingTracks(); | 454 | mOldRemainingTracks = remainingTracks(); | ||
371 | } | 455 | } | ||
372 | 456 | | |||
373 | notifyArtistProperty(); | 457 | notifyArtistProperty(); | ||
374 | notifyTitleProperty(); | 458 | notifyTitleProperty(); | ||
375 | notifyAlbumProperty(); | 459 | notifyAlbumProperty(); | ||
460 | notifyFileNameProperty(); | ||||
376 | notifyImageProperty(); | 461 | notifyImageProperty(); | ||
462 | notifyDatabaseIdProperty(); | ||||
377 | notifyAlbumIdProperty(); | 463 | notifyAlbumIdProperty(); | ||
378 | notifyIsValidProperty(); | 464 | notifyIsValidProperty(); | ||
379 | } | 465 | } | ||
380 | 466 | | |||
381 | void ManageHeaderBar::setPlayListModel(QAbstractItemModel *aPlayListModel) | 467 | void ManageHeaderBar::setPlayListModel(QAbstractItemModel *aPlayListModel) | ||
382 | { | 468 | { | ||
383 | if (mPlayListModel) { | 469 | if (mPlayListModel) { | ||
384 | disconnect(mPlayListModel, &QAbstractItemModel::rowsInserted, this, &ManageHeaderBar::tracksInserted); | 470 | disconnect(mPlayListModel, &QAbstractItemModel::rowsInserted, this, &ManageHeaderBar::tracksInserted); | ||
Show All 28 Lines |