File indexing completed on 2024-04-21 04:48:59

0001 /*
0002    SPDX-FileCopyrightText: 2016 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr>
0003 
0004    SPDX-License-Identifier: LGPL-3.0-or-later
0005  */
0006 
0007 #ifndef MANAGEHEADERBAR_H
0008 #define MANAGEHEADERBAR_H
0009 
0010 #include "elisaLib_export.h"
0011 
0012 #include "elisautils.h"
0013 
0014 #include <QObject>
0015 #include <QPersistentModelIndex>
0016 #include <QUrl>
0017 
0018 class ELISALIB_EXPORT ManageHeaderBar : public QObject
0019 {
0020     Q_OBJECT
0021 
0022     Q_PROPERTY(QPersistentModelIndex currentTrack
0023                READ currentTrack
0024                WRITE setCurrentTrack
0025                NOTIFY currentTrackChanged)
0026 
0027     Q_PROPERTY(int artistRole
0028                READ artistRole
0029                WRITE setArtistRole
0030                NOTIFY artistRoleChanged)
0031 
0032     Q_PROPERTY(int titleRole
0033                READ titleRole
0034                WRITE setTitleRole
0035                NOTIFY titleRoleChanged)
0036 
0037     Q_PROPERTY(int albumRole
0038                READ albumRole
0039                WRITE setAlbumRole
0040                NOTIFY albumRoleChanged)
0041 
0042     Q_PROPERTY(int albumArtistRole
0043                READ albumArtistRole
0044                WRITE setAlbumArtistRole
0045                NOTIFY albumArtistRoleChanged)
0046 
0047     Q_PROPERTY(int fileNameRole
0048                READ fileNameRole
0049                WRITE setFileNameRole
0050                NOTIFY fileNameRoleChanged)
0051 
0052     Q_PROPERTY(int imageRole
0053                READ imageRole
0054                WRITE setImageRole
0055                NOTIFY imageRoleChanged)
0056 
0057     Q_PROPERTY(int databaseIdRole
0058                READ databaseIdRole
0059                WRITE setDatabaseIdRole
0060                NOTIFY databaseIdRoleChanged)
0061 
0062     Q_PROPERTY(int trackTypeRole
0063                READ trackTypeRole
0064                WRITE setTrackTypeRole
0065                NOTIFY trackTypeRoleChanged)
0066 
0067     Q_PROPERTY(int albumIdRole
0068                READ albumIdRole
0069                WRITE setAlbumIdRole
0070                NOTIFY albumIdRoleChanged)
0071 
0072     Q_PROPERTY(int isValidRole
0073                READ isValidRole
0074                WRITE setIsValidRole
0075                NOTIFY isValidRoleChanged)
0076 
0077     Q_PROPERTY(QVariant artist
0078                READ artist
0079                NOTIFY artistChanged)
0080 
0081     Q_PROPERTY(QVariant title
0082                READ title
0083                NOTIFY titleChanged)
0084 
0085     Q_PROPERTY(QVariant album
0086                READ album
0087                NOTIFY albumChanged)
0088 
0089     Q_PROPERTY(QVariant albumArtist
0090                READ albumArtist
0091                NOTIFY albumArtistChanged)
0092 
0093     Q_PROPERTY(QUrl fileUrl
0094                READ fileUrl
0095                NOTIFY fileUrlChanged)
0096 
0097     Q_PROPERTY(QUrl image
0098                READ image
0099                NOTIFY imageChanged)
0100 
0101     Q_PROPERTY(qulonglong databaseId
0102                READ databaseId
0103                NOTIFY databaseIdChanged)
0104 
0105     Q_PROPERTY(ElisaUtils::PlayListEntryType trackType
0106                READ trackType
0107                NOTIFY trackTypeChanged)
0108 
0109     Q_PROPERTY(qulonglong albumId
0110                READ albumId
0111                NOTIFY albumIdChanged)
0112 
0113     Q_PROPERTY(bool isValid
0114                READ isValid
0115                NOTIFY isValidChanged)
0116 
0117 public:
0118 
0119     explicit ManageHeaderBar(QObject *parent = nullptr);
0120 
0121     [[nodiscard]] QPersistentModelIndex currentTrack() const;
0122 
0123     [[nodiscard]] int artistRole() const;
0124 
0125     [[nodiscard]] int titleRole() const;
0126 
0127     [[nodiscard]] int albumRole() const;
0128 
0129     [[nodiscard]] int albumArtistRole() const;
0130 
0131     [[nodiscard]] int fileNameRole() const;
0132 
0133     [[nodiscard]] int imageRole() const;
0134 
0135     [[nodiscard]] int databaseIdRole() const;
0136 
0137     [[nodiscard]] int trackTypeRole() const;
0138 
0139     [[nodiscard]] int albumIdRole() const;
0140 
0141     [[nodiscard]] int isValidRole() const;
0142 
0143     [[nodiscard]] QVariant artist() const;
0144 
0145     [[nodiscard]] QVariant title() const;
0146 
0147     [[nodiscard]] QVariant album() const;
0148 
0149     [[nodiscard]] QVariant albumArtist() const;
0150 
0151     [[nodiscard]] QUrl fileUrl() const;
0152 
0153     [[nodiscard]] QUrl image() const;
0154 
0155     [[nodiscard]] qulonglong databaseId() const;
0156 
0157     [[nodiscard]] ElisaUtils::PlayListEntryType trackType() const;
0158 
0159     [[nodiscard]] qulonglong albumId() const;
0160 
0161     [[nodiscard]] bool isValid() const;
0162 
0163 Q_SIGNALS:
0164 
0165     void currentTrackChanged();
0166 
0167     void artistRoleChanged();
0168 
0169     void titleRoleChanged();
0170 
0171     void albumRoleChanged();
0172 
0173     void albumArtistRoleChanged();
0174 
0175     void fileNameRoleChanged();
0176 
0177     void imageRoleChanged();
0178 
0179     void databaseIdRoleChanged();
0180 
0181     void trackTypeRoleChanged();
0182 
0183     void albumIdRoleChanged();
0184 
0185     void isValidRoleChanged();
0186 
0187     void artistChanged();
0188 
0189     void titleChanged();
0190 
0191     void albumChanged();
0192 
0193     void albumArtistChanged();
0194 
0195     void fileUrlChanged();
0196 
0197     void imageChanged();
0198 
0199     void databaseIdChanged();
0200 
0201     void albumIdChanged();
0202 
0203     void trackTypeChanged();
0204 
0205     void isValidChanged();
0206 
0207 public Q_SLOTS:
0208 
0209     void setCurrentTrack(const QPersistentModelIndex &currentTrack);
0210 
0211     void updateCurrentTrackData();
0212 
0213     void setArtistRole(int value);
0214 
0215     void setTitleRole(int value);
0216 
0217     void setAlbumRole(int value);
0218 
0219     void setAlbumArtistRole(int value);
0220 
0221     void setFileNameRole(int value);
0222 
0223     void setImageRole(int value);
0224 
0225     void setDatabaseIdRole(int databaseIdRole);
0226 
0227     void setTrackTypeRole(int trackTypeRole);
0228 
0229     void setAlbumIdRole(int albumIdRole);
0230 
0231     void setIsValidRole(int isValidRole);
0232 
0233 private:
0234 
0235     void notifyArtistProperty();
0236 
0237     void notifyTitleProperty();
0238 
0239     void notifyAlbumProperty();
0240 
0241     void notifyAlbumArtistProperty();
0242 
0243     void notifyFileNameProperty();
0244 
0245     void notifyImageProperty();
0246 
0247     void notifyDatabaseIdProperty();
0248 
0249     void notifyTrackTypeProperty();
0250 
0251     void notifyAlbumIdProperty();
0252 
0253     void notifyIsValidProperty();
0254 
0255     QPersistentModelIndex mCurrentTrack;
0256 
0257     int mArtistRole = Qt::DisplayRole;
0258 
0259     int mTitleRole = Qt::DisplayRole;
0260 
0261     int mAlbumRole = Qt::DisplayRole;
0262 
0263     int mAlbumArtistRole = Qt::DisplayRole;
0264 
0265     int mFileNameRole = Qt::DisplayRole;
0266 
0267     int mImageRole = Qt::DisplayRole;
0268 
0269     int mDatabaseIdRole = Qt::DisplayRole;
0270 
0271     int mTrackTypeIdRole = Qt::DisplayRole;
0272 
0273     int mAlbumIdRole = Qt::DisplayRole;
0274 
0275     int mIsValidRole = Qt::DisplayRole;
0276 
0277     QVariant mOldArtist;
0278 
0279     QVariant mOldTitle;
0280 
0281     QVariant mOldAlbum;
0282 
0283     QVariant mOldAlbumArtist;
0284 
0285     QVariant mOldFileName;
0286 
0287     QVariant mOldImage;
0288 
0289     qulonglong mOldDatabaseId = 0;
0290 
0291     ElisaUtils::PlayListEntryType mOldTrackType = ElisaUtils::Unknown;
0292 
0293     qulonglong mOldAlbumId = 0;
0294 
0295     bool mOldIsValid = false;
0296 
0297 };
0298 
0299 
0300 
0301 #endif // MANAGEHEADERBAR_H