Changeset View
Changeset View
Standalone View
Standalone View
src/viewmanager.h
Show All 38 Lines | 33 | enum ViewsType { | |||
---|---|---|---|---|---|
39 | OneAlbumFromArtist, | 39 | OneAlbumFromArtist, | ||
40 | AllTracks, | 40 | AllTracks, | ||
41 | AllGenres, | 41 | AllGenres, | ||
42 | AllArtistsFromGenre, | 42 | AllArtistsFromGenre, | ||
43 | OneArtistFromGenre, | 43 | OneArtistFromGenre, | ||
44 | OneAlbumFromArtistAndGenre, | 44 | OneAlbumFromArtistAndGenre, | ||
45 | FrequentlyPlayedTracks, | 45 | FrequentlyPlayedTracks, | ||
46 | RecentlyPlayedTracks, | 46 | RecentlyPlayedTracks, | ||
47 | FilesBrowser | 47 | FilesBrowser, | ||
48 | RadiosBrowser | ||||
48 | }; | 49 | }; | ||
49 | 50 | | |||
50 | Q_ENUM(ViewsType) | 51 | Q_ENUM(ViewsType) | ||
51 | 52 | | |||
52 | explicit ViewManager(QObject *parent = nullptr); | 53 | explicit ViewManager(QObject *parent = nullptr); | ||
53 | 54 | | |||
54 | Q_SIGNALS: | 55 | Q_SIGNALS: | ||
55 | 56 | | |||
56 | void openGridView(ViewManager::ViewsType viewType, int expectedDepth, | 57 | void openGridView(ViewManager::ViewsType viewType, int expectedDepth, | ||
57 | const QString &mainTitle, const QString &secondaryTitle, const QUrl &imageUrl, | 58 | const QString &mainTitle, const QString &secondaryTitle, const QUrl &imageUrl, | ||
58 | ElisaUtils::PlayListEntryType dataType, const QUrl &viewDefaultIcon, | 59 | ElisaUtils::PlayListEntryType dataType, const QUrl &viewDefaultIcon, | ||
59 | const QString &genreNameFilter, const QString &artistNameFilter, | 60 | const QString &genreNameFilter, const QString &artistNameFilter, | ||
60 | bool viewShowRating, bool viewDelegateDisplaySecondaryText); | 61 | bool viewShowRating, bool viewDelegateDisplaySecondaryText); | ||
61 | 62 | | |||
62 | void switchRecentlyPlayedTracksView(ViewManager::ViewsType viewType, int expectedDepth, | 63 | void switchRecentlyPlayedTracksView(ViewManager::ViewsType viewType, int expectedDepth, | ||
63 | const QString &mainTitle, const QUrl &imageUrl, | 64 | const QString &mainTitle, const QUrl &imageUrl, | ||
64 | ElisaUtils::PlayListEntryType dataType); | 65 | ElisaUtils::PlayListEntryType dataType); | ||
65 | 66 | | |||
66 | void switchFrequentlyPlayedTracksView(ViewManager::ViewsType viewType, int expectedDepth, | 67 | void switchFrequentlyPlayedTracksView(ViewManager::ViewsType viewType, int expectedDepth, | ||
67 | const QString &mainTitle, const QUrl &imageUrl, | 68 | const QString &mainTitle, const QUrl &imageUrl, | ||
68 | ElisaUtils::PlayListEntryType dataType); | 69 | ElisaUtils::PlayListEntryType dataType); | ||
69 | 70 | | |||
mgallien: Please do not use a bool but a named constant (from an enum).
And yes, there is a bool before… | |||||
Thank you for the reading, I am a little bit confused about the "best" solution here. "bool radioCase" is heavily linked to dataType (ElisaUtils::PlayListEntryType::Radio). Should I expose the enum in qml and do the check in DataListView.qml with something like modelType == ElisaUtils::PlayListEntryType::Radio instead of the property "radioCase"? jguidon: Thank you for the reading,
I am a little bit confused about the "best" solution here. "bool… | |||||
You can simply use a two values enum like IsRadio and IsTrack . That would be easier to read than a true/false . You will have to expose it like ViewManager::AlbumViewStyle is. mgallien: You can simply use a two values enum like IsRadio and IsTrack . That would be easier to read… | |||||
70 | void switchOneAlbumView(ViewManager::ViewsType viewType, int expectedDepth, | 71 | void switchOneAlbumView(ViewManager::ViewsType viewType, int expectedDepth, | ||
71 | const QString &mainTitle, const QUrl &imageUrl, const QString &secondaryTitle, qulonglong databaseId); | 72 | const QString &mainTitle, const QUrl &imageUrl, const QString &secondaryTitle, qulonglong databaseId); | ||
72 | 73 | | |||
73 | void switchAllTracksView(ViewManager::ViewsType viewType, int expectedDepth, const QString &mainTitle, | 74 | void switchAllTracksView(ViewManager::ViewsType viewType, int expectedDepth, const QString &mainTitle, | ||
74 | const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType); | 75 | const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType); | ||
75 | 76 | | |||
76 | void switchFilesBrowserView(ViewManager::ViewsType viewType, int expectedDepth, | 77 | void switchFilesBrowserView(ViewManager::ViewsType viewType, int expectedDepth, | ||
77 | const QString &mainTitle, const QUrl &imageUrl); | 78 | const QString &mainTitle, const QUrl &imageUrl); | ||
78 | 79 | | |||
80 | void switchRadiosView(ViewManager::ViewsType viewType, int expectedDepth, const QString &mainTitle, | ||||
81 | const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType); | ||||
82 | | ||||
79 | void switchOffAllViews(ViewManager::ViewsType viewType); | 83 | void switchOffAllViews(ViewManager::ViewsType viewType); | ||
80 | 84 | | |||
81 | void popOneView(); | 85 | void popOneView(); | ||
82 | 86 | | |||
83 | public Q_SLOTS: | 87 | public Q_SLOTS: | ||
84 | 88 | | |||
85 | void closeAllViews(); | 89 | void closeAllViews(); | ||
86 | 90 | | |||
Show All 18 Lines | 101 | private: | |||
105 | void openAllArtists(const QString &mainTitle, const QUrl &imageUrl); | 109 | void openAllArtists(const QString &mainTitle, const QUrl &imageUrl); | ||
106 | 110 | | |||
107 | void openAllTracks(const QString &mainTitle, const QUrl &imageUrl); | 111 | void openAllTracks(const QString &mainTitle, const QUrl &imageUrl); | ||
108 | 112 | | |||
109 | void openAllGenres(const QString &mainTitle, const QUrl &imageUrl); | 113 | void openAllGenres(const QString &mainTitle, const QUrl &imageUrl); | ||
110 | 114 | | |||
111 | void openFilesBrowser(const QString &mainTitle, const QUrl &imageUrl); | 115 | void openFilesBrowser(const QString &mainTitle, const QUrl &imageUrl); | ||
112 | 116 | | |||
117 | void openRadiosBrowser(const QString &mainTitle, const QUrl &imageUrl); | ||||
118 | | ||||
113 | void openOneAlbum(const QString &albumTitle, const QString &albumAuthor, | 119 | void openOneAlbum(const QString &albumTitle, const QString &albumAuthor, | ||
114 | const QUrl &albumCover, qulonglong albumDatabaseId); | 120 | const QUrl &albumCover, qulonglong albumDatabaseId); | ||
115 | 121 | | |||
116 | void openOneArtist(const QString &artistName, const QUrl &artistImageUrl, qulonglong artistDatabaseId); | 122 | void openOneArtist(const QString &artistName, const QUrl &artistImageUrl, qulonglong artistDatabaseId); | ||
117 | 123 | | |||
118 | void openAllArtistsFromGenre(const QString &genreName); | 124 | void openAllArtistsFromGenre(const QString &genreName); | ||
119 | 125 | | |||
120 | void recentlyPlayedTracksIsLoaded(); | 126 | void recentlyPlayedTracksIsLoaded(); | ||
Show All 11 Lines | |||||
132 | void allTracksViewIsLoaded(); | 138 | void allTracksViewIsLoaded(); | ||
133 | 139 | | |||
134 | void allGenresViewIsLoaded(); | 140 | void allGenresViewIsLoaded(); | ||
135 | 141 | | |||
136 | void allArtistsFromGenreViewIsLoaded(); | 142 | void allArtistsFromGenreViewIsLoaded(); | ||
137 | 143 | | |||
138 | void filesBrowserViewIsLoaded(); | 144 | void filesBrowserViewIsLoaded(); | ||
139 | 145 | | |||
146 | void radiosBrowserViewIsLoaded(); | ||||
147 | | ||||
140 | ViewsType mCurrentView = ViewsType::NoViews; | 148 | ViewsType mCurrentView = ViewsType::NoViews; | ||
141 | QString mCurrentAlbumTitle; | 149 | QString mCurrentAlbumTitle; | ||
142 | QString mCurrentAlbumAuthor; | 150 | QString mCurrentAlbumAuthor; | ||
143 | QString mCurrentArtistName; | 151 | QString mCurrentArtistName; | ||
144 | QString mCurrentGenreName; | 152 | QString mCurrentGenreName; | ||
145 | 153 | | |||
146 | ViewsType mTargetView = ViewsType::NoViews; | 154 | ViewsType mTargetView = ViewsType::NoViews; | ||
147 | QString mTargetAlbumTitle; | 155 | QString mTargetAlbumTitle; | ||
Show All 9 Lines |
Please do not use a bool but a named constant (from an enum).
And yes, there is a bool before your modification and that is an error (from me).
See https://ariya.io/2011/08/hall-of-api-shame-boolean-trap for a good explanation.