Changeset View
Changeset View
Standalone View
Standalone View
src/manageheaderbar.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
57 | } | 57 | } | ||
58 | 58 | | |||
59 | void ManageHeaderBar::setAlbumArtistRole(int value) | 59 | void ManageHeaderBar::setAlbumArtistRole(int value) | ||
60 | { | 60 | { | ||
61 | mAlbumArtistRole = value; | 61 | mAlbumArtistRole = value; | ||
62 | Q_EMIT albumArtistRoleChanged(); | 62 | Q_EMIT albumArtistRoleChanged(); | ||
63 | } | 63 | } | ||
64 | 64 | | |||
65 | void ManageHeaderBar::setFileNameRole(int value) | ||||
66 | { | ||||
67 | mFileNameRole = value; | ||||
68 | Q_EMIT fileNameRoleChanged(); | ||||
69 | } | ||||
70 | | ||||
65 | int ManageHeaderBar::albumRole() const | 71 | int ManageHeaderBar::albumRole() const | ||
66 | { | 72 | { | ||
67 | return mAlbumRole; | 73 | return mAlbumRole; | ||
68 | } | 74 | } | ||
69 | 75 | | |||
70 | int ManageHeaderBar::albumArtistRole() const | 76 | int ManageHeaderBar::albumArtistRole() const | ||
71 | { | 77 | { | ||
72 | return mAlbumArtistRole; | 78 | return mAlbumArtistRole; | ||
73 | } | 79 | } | ||
74 | 80 | | |||
81 | int ManageHeaderBar::fileNameRole() const | ||||
82 | { | ||||
83 | return mFileNameRole; | ||||
84 | } | ||||
85 | | ||||
75 | void ManageHeaderBar::setImageRole(int value) | 86 | void ManageHeaderBar::setImageRole(int value) | ||
76 | { | 87 | { | ||
77 | mImageRole = value; | 88 | mImageRole = value; | ||
78 | Q_EMIT imageRoleChanged(); | 89 | Q_EMIT imageRoleChanged(); | ||
79 | } | 90 | } | ||
80 | 91 | | |||
92 | void ManageHeaderBar::setDatabaseIdRole(int databaseIdRole) | ||||
93 | { | ||||
94 | mDatabaseIdRole = databaseIdRole; | ||||
95 | Q_EMIT databaseIdRoleChanged(); | ||||
96 | } | ||||
97 | | ||||
81 | int ManageHeaderBar::imageRole() const | 98 | int ManageHeaderBar::imageRole() const | ||
82 | { | 99 | { | ||
83 | return mImageRole; | 100 | return mImageRole; | ||
84 | } | 101 | } | ||
85 | 102 | | |||
103 | int ManageHeaderBar::databaseIdRole() const | ||||
104 | { | ||||
105 | return mDatabaseIdRole; | ||||
106 | } | ||||
107 | | ||||
86 | void ManageHeaderBar::setAlbumIdRole(int albumIdRole) | 108 | void ManageHeaderBar::setAlbumIdRole(int albumIdRole) | ||
87 | { | 109 | { | ||
88 | mAlbumIdRole = albumIdRole; | 110 | mAlbumIdRole = albumIdRole; | ||
89 | Q_EMIT albumIdRoleChanged(); | 111 | Q_EMIT albumIdRoleChanged(); | ||
90 | } | 112 | } | ||
91 | 113 | | |||
92 | int ManageHeaderBar::albumIdRole() const | 114 | int ManageHeaderBar::albumIdRole() const | ||
93 | { | 115 | { | ||
Show All 13 Lines | |||||
107 | { | 129 | { | ||
108 | if (!mCurrentTrack.isValid()) { | 130 | if (!mCurrentTrack.isValid()) { | ||
109 | return QString(); | 131 | return QString(); | ||
110 | } | 132 | } | ||
111 | 133 | | |||
112 | return mCurrentTrack.data(mAlbumArtistRole); | 134 | return mCurrentTrack.data(mAlbumArtistRole); | ||
113 | } | 135 | } | ||
114 | 136 | | |||
137 | QString ManageHeaderBar::fileName() const | ||||
138 | { | ||||
139 | QString result; | ||||
140 | | ||||
141 | if (!mCurrentTrack.isValid()) { | ||||
142 | return result; | ||||
143 | } | ||||
144 | | ||||
145 | auto fileNameUrl = mCurrentTrack.data(mFileNameRole).toUrl(); | ||||
146 | if (fileNameUrl.isLocalFile()) { | ||||
147 | result = fileNameUrl.toLocalFile(); | ||||
148 | } else { | ||||
149 | result = fileNameUrl.toString(); | ||||
150 | } | ||||
151 | | ||||
152 | return result; | ||||
153 | } | ||||
154 | | ||||
115 | QVariant ManageHeaderBar::title() const | 155 | QVariant ManageHeaderBar::title() const | ||
116 | { | 156 | { | ||
117 | if (!mCurrentTrack.isValid()) { | 157 | if (!mCurrentTrack.isValid()) { | ||
118 | return QString(); | 158 | return QString(); | ||
119 | } | 159 | } | ||
120 | 160 | | |||
121 | return mCurrentTrack.data(mTitleRole); | 161 | return mCurrentTrack.data(mTitleRole); | ||
122 | } | 162 | } | ||
Show All 11 Lines | |||||
134 | { | 174 | { | ||
135 | if (!mCurrentTrack.isValid()) { | 175 | if (!mCurrentTrack.isValid()) { | ||
136 | return {}; | 176 | return {}; | ||
137 | } | 177 | } | ||
138 | 178 | | |||
139 | return mCurrentTrack.data(mImageRole).toUrl(); | 179 | return mCurrentTrack.data(mImageRole).toUrl(); | ||
140 | } | 180 | } | ||
141 | 181 | | |||
182 | qulonglong ManageHeaderBar::databaseId() const | ||||
183 | { | ||||
184 | if (!mCurrentTrack.isValid()) { | ||||
185 | return 0; | ||||
186 | } | ||||
187 | | ||||
188 | return mCurrentTrack.data(mDatabaseIdRole).toULongLong(); | ||||
189 | } | ||||
190 | | ||||
142 | qulonglong ManageHeaderBar::albumId() const | 191 | qulonglong ManageHeaderBar::albumId() const | ||
143 | { | 192 | { | ||
144 | if (!mCurrentTrack.isValid()) { | 193 | if (!mCurrentTrack.isValid()) { | ||
145 | return 0; | 194 | return 0; | ||
146 | } | 195 | } | ||
147 | 196 | | |||
148 | return mCurrentTrack.data(mAlbumIdRole).toULongLong(); | 197 | return mCurrentTrack.data(mAlbumIdRole).toULongLong(); | ||
149 | } | 198 | } | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 264 | if (mCurrentTrack.column() > bottomRight.column() || mCurrentTrack.column() < topLeft.column()) { | |||
216 | return; | 265 | return; | ||
217 | } | 266 | } | ||
218 | 267 | | |||
219 | if (roles.isEmpty()) { | 268 | if (roles.isEmpty()) { | ||
220 | notifyArtistProperty(); | 269 | notifyArtistProperty(); | ||
221 | notifyTitleProperty(); | 270 | notifyTitleProperty(); | ||
222 | notifyAlbumProperty(); | 271 | notifyAlbumProperty(); | ||
223 | notifyAlbumArtistProperty(); | 272 | notifyAlbumArtistProperty(); | ||
273 | notifyFileNameProperty(); | ||||
224 | notifyImageProperty(); | 274 | notifyImageProperty(); | ||
275 | notifyDatabaseIdProperty(); | ||||
225 | notifyAlbumIdProperty(); | 276 | notifyAlbumIdProperty(); | ||
226 | notifyIsValidProperty(); | 277 | notifyIsValidProperty(); | ||
227 | } else { | 278 | } else { | ||
228 | for(auto oneRole : roles) { | 279 | for(auto oneRole : roles) { | ||
229 | if (oneRole == mArtistRole) { | 280 | if (oneRole == mArtistRole) { | ||
230 | notifyArtistProperty(); | 281 | notifyArtistProperty(); | ||
231 | } | 282 | } | ||
232 | if (oneRole == mTitleRole) { | 283 | if (oneRole == mTitleRole) { | ||
233 | notifyTitleProperty(); | 284 | notifyTitleProperty(); | ||
234 | } | 285 | } | ||
235 | if (oneRole == mAlbumRole) { | 286 | if (oneRole == mAlbumRole) { | ||
236 | notifyAlbumProperty(); | 287 | notifyAlbumProperty(); | ||
237 | } | 288 | } | ||
238 | if (oneRole == mAlbumArtistRole) { | 289 | if (oneRole == mAlbumArtistRole) { | ||
239 | notifyAlbumArtistProperty(); | 290 | notifyAlbumArtistProperty(); | ||
240 | } | 291 | } | ||
292 | if (oneRole == mFileNameRole) { | ||||
293 | notifyFileNameProperty(); | ||||
294 | } | ||||
241 | if (oneRole == mImageRole) { | 295 | if (oneRole == mImageRole) { | ||
242 | notifyImageProperty(); | 296 | notifyImageProperty(); | ||
243 | } | 297 | } | ||
298 | if (oneRole == mDatabaseIdRole) { | ||||
299 | notifyDatabaseIdProperty(); | ||||
300 | } | ||||
244 | if (oneRole == mAlbumIdRole) { | 301 | if (oneRole == mAlbumIdRole) { | ||
245 | notifyAlbumIdProperty(); | 302 | notifyAlbumIdProperty(); | ||
246 | } | 303 | } | ||
247 | if (oneRole == mIsValidRole) { | 304 | if (oneRole == mIsValidRole) { | ||
248 | notifyIsValidProperty(); | 305 | notifyIsValidProperty(); | ||
249 | } | 306 | } | ||
250 | } | 307 | } | ||
251 | } | 308 | } | ||
Show All 30 Lines | 337 | { | |||
282 | Q_UNUSED(first); | 339 | Q_UNUSED(first); | ||
283 | Q_UNUSED(last); | 340 | Q_UNUSED(last); | ||
284 | 341 | | |||
285 | if (!mCurrentTrack.isValid()) { | 342 | if (!mCurrentTrack.isValid()) { | ||
286 | notifyArtistProperty(); | 343 | notifyArtistProperty(); | ||
287 | notifyTitleProperty(); | 344 | notifyTitleProperty(); | ||
288 | notifyAlbumProperty(); | 345 | notifyAlbumProperty(); | ||
289 | notifyAlbumArtistProperty(); | 346 | notifyAlbumArtistProperty(); | ||
347 | notifyFileNameProperty(); | ||||
290 | notifyImageProperty(); | 348 | notifyImageProperty(); | ||
349 | notifyDatabaseIdProperty(); | ||||
291 | notifyAlbumIdProperty(); | 350 | notifyAlbumIdProperty(); | ||
292 | notifyIsValidProperty(); | 351 | notifyIsValidProperty(); | ||
293 | notifyRemainingTracksProperty(); | 352 | notifyRemainingTracksProperty(); | ||
294 | 353 | | |||
295 | return; | 354 | return; | ||
296 | } | 355 | } | ||
297 | 356 | | |||
298 | notifyRemainingTracksProperty(); | 357 | notifyRemainingTracksProperty(); | ||
Show All 34 Lines | 391 | { | |||
333 | auto newAlbumArtistValue = mCurrentTrack.data(mAlbumArtistRole); | 392 | auto newAlbumArtistValue = mCurrentTrack.data(mAlbumArtistRole); | ||
334 | if (mOldAlbumArtist != newAlbumArtistValue) { | 393 | if (mOldAlbumArtist != newAlbumArtistValue) { | ||
335 | Q_EMIT albumArtistChanged(); | 394 | Q_EMIT albumArtistChanged(); | ||
336 | 395 | | |||
337 | mOldAlbumArtist = newAlbumArtistValue; | 396 | mOldAlbumArtist = newAlbumArtistValue; | ||
338 | } | 397 | } | ||
339 | } | 398 | } | ||
340 | 399 | | |||
400 | void ManageHeaderBar::notifyFileNameProperty() | ||||
401 | { | ||||
402 | auto newFileNameValue = mCurrentTrack.data(mFileNameRole); | ||||
403 | if (mOldFileName != newFileNameValue) { | ||||
404 | Q_EMIT fileNameChanged(); | ||||
405 | | ||||
406 | mOldFileName = newFileNameValue; | ||||
407 | } | ||||
408 | } | ||||
409 | | ||||
341 | void ManageHeaderBar::notifyImageProperty() | 410 | void ManageHeaderBar::notifyImageProperty() | ||
342 | { | 411 | { | ||
343 | auto newImageValue = mCurrentTrack.data(mImageRole); | 412 | auto newImageValue = mCurrentTrack.data(mImageRole); | ||
344 | if (mOldImage != newImageValue) { | 413 | if (mOldImage != newImageValue) { | ||
345 | Q_EMIT imageChanged(); | 414 | Q_EMIT imageChanged(); | ||
346 | 415 | | |||
347 | mOldImage = newImageValue; | 416 | mOldImage = newImageValue; | ||
348 | } | 417 | } | ||
349 | } | 418 | } | ||
350 | 419 | | |||
420 | void ManageHeaderBar::notifyDatabaseIdProperty() | ||||
421 | { | ||||
422 | bool conversionOk; | ||||
423 | auto newDatabaseIdValue = mCurrentTrack.data(mDatabaseIdRole).toULongLong(&conversionOk); | ||||
424 | if (conversionOk && mOldDatabaseId != newDatabaseIdValue) { | ||||
425 | Q_EMIT databaseIdChanged(); | ||||
426 | | ||||
427 | mOldDatabaseId = newDatabaseIdValue; | ||||
428 | } else if (!conversionOk && mOldDatabaseId != 0) { | ||||
429 | Q_EMIT databaseIdChanged(); | ||||
430 | | ||||
431 | mOldDatabaseId = 0; | ||||
432 | } | ||||
433 | } | ||||
434 | | ||||
351 | void ManageHeaderBar::notifyAlbumIdProperty() | 435 | void ManageHeaderBar::notifyAlbumIdProperty() | ||
352 | { | 436 | { | ||
353 | bool conversionOk; | 437 | bool conversionOk; | ||
354 | auto newAlbumIdValue = mCurrentTrack.data(mAlbumIdRole).toULongLong(&conversionOk); | 438 | auto newAlbumIdValue = mCurrentTrack.data(mAlbumIdRole).toULongLong(&conversionOk); | ||
355 | if (conversionOk && mOldAlbumId != newAlbumIdValue) { | 439 | if (conversionOk && mOldAlbumId != newAlbumIdValue) { | ||
356 | Q_EMIT albumIdChanged(); | 440 | Q_EMIT albumIdChanged(); | ||
357 | 441 | | |||
358 | mOldAlbumId = newAlbumIdValue; | 442 | mOldAlbumId = newAlbumIdValue; | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 487 | if (mCurrentTrack.isValid() && oldRemainingTracksCount != remainingTracks()) { | |||
404 | Q_EMIT remainingTracksChanged(); | 488 | Q_EMIT remainingTracksChanged(); | ||
405 | mOldRemainingTracks = remainingTracks(); | 489 | mOldRemainingTracks = remainingTracks(); | ||
406 | } | 490 | } | ||
407 | 491 | | |||
408 | notifyArtistProperty(); | 492 | notifyArtistProperty(); | ||
409 | notifyTitleProperty(); | 493 | notifyTitleProperty(); | ||
410 | notifyAlbumProperty(); | 494 | notifyAlbumProperty(); | ||
411 | notifyAlbumArtistProperty(); | 495 | notifyAlbumArtistProperty(); | ||
496 | notifyFileNameProperty(); | ||||
412 | notifyImageProperty(); | 497 | notifyImageProperty(); | ||
498 | notifyDatabaseIdProperty(); | ||||
413 | notifyAlbumIdProperty(); | 499 | notifyAlbumIdProperty(); | ||
414 | notifyIsValidProperty(); | 500 | notifyIsValidProperty(); | ||
415 | } | 501 | } | ||
416 | 502 | | |||
417 | void ManageHeaderBar::setPlayListModel(QAbstractItemModel *aPlayListModel) | 503 | void ManageHeaderBar::setPlayListModel(QAbstractItemModel *aPlayListModel) | ||
418 | { | 504 | { | ||
419 | if (mPlayListModel) { | 505 | if (mPlayListModel) { | ||
420 | disconnect(mPlayListModel, &QAbstractItemModel::rowsInserted, this, &ManageHeaderBar::tracksInserted); | 506 | disconnect(mPlayListModel, &QAbstractItemModel::rowsInserted, this, &ManageHeaderBar::tracksInserted); | ||
Show All 28 Lines |