Merge lp:~mixxxdevelopers/mixxx/features_library into lp:~mixxxdevelopers/mixxx/trunk
- features_library
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 2489 | ||||||||
Proposed branch: | lp:~mixxxdevelopers/mixxx/features_library | ||||||||
Merge into: | lp:~mixxxdevelopers/mixxx/trunk | ||||||||
Diff against target: |
2332 lines (+1056/-419) 32 files modified
mixxx/build/depends.py (+4/-1) mixxx/res/schema.xml (+18/-0) mixxx/src/library/basesqltablemodel.cpp (+227/-5) mixxx/src/library/basesqltablemodel.h (+10/-1) mixxx/src/library/cratetablemodel.cpp (+22/-66) mixxx/src/library/cratetablemodel.h (+0/-2) mixxx/src/library/dao/trackdao.cpp (+32/-9) mixxx/src/library/dao/trackdao.h (+4/-0) mixxx/src/library/legacylibraryimporter.cpp (+10/-3) mixxx/src/library/libraryscanner.cpp (+23/-13) mixxx/src/library/librarytablemodel.cpp (+31/-83) mixxx/src/library/librarytablemodel.h (+0/-2) mixxx/src/library/missingtablemodel.cpp (+7/-58) mixxx/src/library/missingtablemodel.h (+1/-1) mixxx/src/library/playlisttablemodel.cpp (+5/-62) mixxx/src/library/playlisttablemodel.h (+0/-51) mixxx/src/library/rhythmboxtrackmodel.cpp (+3/-0) mixxx/src/library/stardelegate.cpp (+114/-0) mixxx/src/library/stardelegate.h (+56/-0) mixxx/src/library/stareditor.cpp (+95/-0) mixxx/src/library/stareditor.h (+61/-0) mixxx/src/library/starrating.cpp (+74/-0) mixxx/src/library/starrating.h (+62/-0) mixxx/src/library/trackcollection.cpp (+4/-1) mixxx/src/mixxx.cpp (+2/-2) mixxx/src/player.cpp (+2/-0) mixxx/src/trackinfoobject.cpp (+74/-0) mixxx/src/trackinfoobject.h (+19/-0) mixxx/src/widget/wlibrarytableview.cpp (+8/-1) mixxx/src/widget/wstatuslight.cpp (+70/-39) mixxx/src/widget/wstatuslight.h (+10/-12) mixxx/src/widget/wtracktableview.cpp (+8/-7) |
||||||||
To merge this branch: | bzr merge lp:~mixxxdevelopers/mixxx/features_library | ||||||||
Related bugs: |
|
||||||||
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Santoni | Approve | ||
Review via email: mp+38802@code.launchpad.net |
Commit message
Description of the change
This branch is the combination of both lp:~ywwg/mixxx/features_library and lp:~raffitea/mixxx/features_library.
The combined set of features added here by both Tobias and Owen are:
* Adding a times played column to the library
* Adding a rating column to the library
* Adding a played column to the library
* Version bump to schema version 6, clear all the headerstate so that the new columns show up
* Adding a checkbox widget to the times-played column which is shown next to the # of times the track was played in the library track table
* Adding a star-widget to the rating column in the library track table.
* Increase the play count of a track and set it played when it is successfully loaded to a player.
* Making search queries search based on individual terms instead of the whole phrase
* Search now searches album, location, comment, and title.
* Make artist, album, title, year, track number, genre, comment, BPM in the track table editable on a single click.
* Disable loading track by hitting enter to avoid accidental loads from editing
* Rewrite part of WStatusLight (Owen, can you describe what the change here was?)
* Test for the existence of the 1.7-library conversion file result and skip legacy import if it exists.
* Added some logic to record the creation date of a Track, but it isn't used anywhere as far as I can tell.
Thanks to Tobias and Owen for this great work!
- 2489. By RJ Skerry-Ryan
-
Clear the prepare and missing headers on upgarde to schema version 6.
RAFFI TEA (raffitea) wrote : | # |
Albert Santoni (gamegod) wrote : | # |
Yeeeeeeeeah Qt 4.7 on Ubuntu 10.10:
http://
Albert Santoni (gamegod) wrote : | # |
I've reviewed your code and everything pretty much looks good to me.
Albert Santoni (gamegod) wrote : | # |
Actually, I lied. I think we should make the Key column hidden by default, since it'll probably be blank for most people, and we don't yet offer key analysis. What do you think?
RAFFI TEA (raffitea) wrote : | # |
It sounds reasonable. How can I archive such a behaviour?
RAFFI TEA (raffitea) wrote : | # |
Key columns are now hidden by default. Basically, I have extended TrackModel with a method 'isColumnHidden
Preview Diff
1 | === modified file 'mixxx/build/depends.py' | |||
2 | --- mixxx/build/depends.py 2010-10-19 00:05:55 +0000 | |||
3 | +++ mixxx/build/depends.py 2010-10-19 05:33:52 +0000 | |||
4 | @@ -454,6 +454,9 @@ | |||
5 | 454 | "library/featuredartistswebview.cpp", | 454 | "library/featuredartistswebview.cpp", |
6 | 455 | "library/bundledsongswebview.cpp", | 455 | "library/bundledsongswebview.cpp", |
7 | 456 | "library/songdownloader.cpp", | 456 | "library/songdownloader.cpp", |
8 | 457 | "library/starrating.cpp", | ||
9 | 458 | "library/stardelegate.cpp", | ||
10 | 459 | "library/stareditor.cpp", | ||
11 | 457 | 460 | ||
12 | 458 | "xmlparse.cpp", | 461 | "xmlparse.cpp", |
13 | 459 | "parser.cpp", | 462 | "parser.cpp", |
14 | @@ -676,7 +679,7 @@ | |||
15 | 676 | build.env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT.lib', | 679 | build.env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT.lib', |
16 | 677 | '/nodefaultlib:LIBCMTd.lib', | 680 | '/nodefaultlib:LIBCMTd.lib', |
17 | 678 | '/entry:mainCRTStartup']) | 681 | '/entry:mainCRTStartup']) |
19 | 679 | # Makes the program not launch a shell first | 682 | # Makes the program not launch a shell first |
20 | 680 | if build.toolchain_is_msvs: | 683 | if build.toolchain_is_msvs: |
21 | 681 | build.env.Append(LINKFLAGS = '/subsystem:windows') | 684 | build.env.Append(LINKFLAGS = '/subsystem:windows') |
22 | 682 | elif build.toolchain_is_gnu: | 685 | elif build.toolchain_is_gnu: |
23 | 683 | 686 | ||
24 | === modified file 'mixxx/res/schema.xml' | |||
25 | --- mixxx/res/schema.xml 2010-09-14 14:45:35 +0000 | |||
26 | +++ mixxx/res/schema.xml 2010-10-19 05:33:52 +0000 | |||
27 | @@ -146,4 +146,22 @@ | |||
28 | 146 | ALTER TABLE LibraryHashes ADD COLUMN needs_verification INTEGER DEFAULT 0; | 146 | ALTER TABLE LibraryHashes ADD COLUMN needs_verification INTEGER DEFAULT 0; |
29 | 147 | </sql> | 147 | </sql> |
30 | 148 | </revision> | 148 | </revision> |
31 | 149 | <revision version="6"> | ||
32 | 150 | <description> | ||
33 | 151 | Add timesplayed and rating column. Reset header state. | ||
34 | 152 | </description> | ||
35 | 153 | <sql> | ||
36 | 154 | ALTER TABLE library ADD COLUMN timesplayed integer DEFAULT 0; | ||
37 | 155 | ALTER TABLE library ADD COLUMN rating integer DEFAULT 0; | ||
38 | 156 | |||
39 | 157 | UPDATE library SET timesplayed = played; | ||
40 | 158 | UPDATE library SET played = 0; | ||
41 | 159 | |||
42 | 160 | DELETE FROM settings WHERE name="mixxx.db.model.library.header_state"; | ||
43 | 161 | DELETE FROM settings WHERE name="mixxx.db.model.playlist.header_state"; | ||
44 | 162 | DELETE FROM settings WHERE name="mixxx.db.model.crate.header_state"; | ||
45 | 163 | DELETE FROM settings WHERE name="mixxx.db.model.prepare.header_state"; | ||
46 | 164 | DELETE FROM settings WHERE name="mixxx.db.model.missing.header_state"; | ||
47 | 165 | </sql> | ||
48 | 166 | </revision> | ||
49 | 149 | </schema> | 167 | </schema> |
50 | 150 | 168 | ||
51 | === modified file 'mixxx/src/library/basesqltablemodel.cpp' | |||
52 | --- mixxx/src/library/basesqltablemodel.cpp 2010-08-27 20:29:12 +0000 | |||
53 | +++ mixxx/src/library/basesqltablemodel.cpp 2010-10-19 05:33:52 +0000 | |||
54 | @@ -6,6 +6,9 @@ | |||
55 | 6 | #include "trackinfoobject.h" | 6 | #include "trackinfoobject.h" |
56 | 7 | #include "library/trackcollection.h" | 7 | #include "library/trackcollection.h" |
57 | 8 | #include "library/basesqltablemodel.h" | 8 | #include "library/basesqltablemodel.h" |
58 | 9 | #include "mixxxutils.cpp" | ||
59 | 10 | #include "library/starrating.h" | ||
60 | 11 | |||
61 | 9 | 12 | ||
62 | 10 | BaseSqlTableModel::BaseSqlTableModel(QObject* parent, | 13 | BaseSqlTableModel::BaseSqlTableModel(QObject* parent, |
63 | 11 | TrackCollection* pTrackCollection, | 14 | TrackCollection* pTrackCollection, |
64 | @@ -20,6 +23,44 @@ | |||
65 | 20 | } | 23 | } |
66 | 21 | 24 | ||
67 | 22 | BaseSqlTableModel::~BaseSqlTableModel() { | 25 | BaseSqlTableModel::~BaseSqlTableModel() { |
68 | 26 | |||
69 | 27 | } | ||
70 | 28 | |||
71 | 29 | void BaseSqlTableModel::initHeaderData() { | ||
72 | 30 | //Set the column heading labels, rename them for translations and have | ||
73 | 31 | //proper capitalization | ||
74 | 32 | setHeaderData(fieldIndex(LIBRARYTABLE_TIMESPLAYED), | ||
75 | 33 | Qt::Horizontal, tr("Played")); | ||
76 | 34 | setHeaderData(fieldIndex(LIBRARYTABLE_ARTIST), | ||
77 | 35 | Qt::Horizontal, tr("Artist")); | ||
78 | 36 | setHeaderData(fieldIndex(LIBRARYTABLE_TITLE), | ||
79 | 37 | Qt::Horizontal, tr("Title")); | ||
80 | 38 | setHeaderData(fieldIndex(LIBRARYTABLE_ALBUM), | ||
81 | 39 | Qt::Horizontal, tr("Album")); | ||
82 | 40 | setHeaderData(fieldIndex(LIBRARYTABLE_GENRE), | ||
83 | 41 | Qt::Horizontal, tr("Genre")); | ||
84 | 42 | setHeaderData(fieldIndex(LIBRARYTABLE_YEAR), | ||
85 | 43 | Qt::Horizontal, tr("Year")); | ||
86 | 44 | setHeaderData(fieldIndex(LIBRARYTABLE_FILETYPE), | ||
87 | 45 | Qt::Horizontal, tr("Type")); | ||
88 | 46 | setHeaderData(fieldIndex(LIBRARYTABLE_LOCATION), | ||
89 | 47 | Qt::Horizontal, tr("Location")); | ||
90 | 48 | setHeaderData(fieldIndex(LIBRARYTABLE_COMMENT), | ||
91 | 49 | Qt::Horizontal, tr("Comment")); | ||
92 | 50 | setHeaderData(fieldIndex(LIBRARYTABLE_DURATION), | ||
93 | 51 | Qt::Horizontal, tr("Duration")); | ||
94 | 52 | setHeaderData(fieldIndex(LIBRARYTABLE_RATING), | ||
95 | 53 | Qt::Horizontal, tr("Rating")); | ||
96 | 54 | setHeaderData(fieldIndex(LIBRARYTABLE_BITRATE), | ||
97 | 55 | Qt::Horizontal, tr("Bitrate")); | ||
98 | 56 | setHeaderData(fieldIndex(LIBRARYTABLE_BPM), | ||
99 | 57 | Qt::Horizontal, tr("BPM")); | ||
100 | 58 | setHeaderData(fieldIndex(LIBRARYTABLE_TRACKNUMBER), | ||
101 | 59 | Qt::Horizontal, tr("Track #")); | ||
102 | 60 | setHeaderData(fieldIndex(LIBRARYTABLE_DATETIMEADDED), | ||
103 | 61 | Qt::Horizontal, tr("Date Added")); | ||
104 | 62 | setHeaderData(fieldIndex(PLAYLISTTRACKSTABLE_POSITION), | ||
105 | 63 | Qt::Horizontal, tr("#")); | ||
106 | 23 | } | 64 | } |
107 | 24 | 65 | ||
108 | 25 | bool BaseSqlTableModel::select() { | 66 | bool BaseSqlTableModel::select() { |
109 | @@ -48,9 +89,10 @@ | |||
110 | 48 | return result; | 89 | return result; |
111 | 49 | } | 90 | } |
112 | 50 | 91 | ||
115 | 51 | QVariant BaseSqlTableModel::data(const QModelIndex& index, int role) const { | 92 | QVariant BaseSqlTableModel::getBaseValue(const QModelIndex& index, int role) const { |
116 | 52 | if (!index.isValid()) | 93 | if (!index.isValid()) { |
117 | 53 | return QVariant(); | 94 | return QVariant(); |
118 | 95 | } | ||
119 | 54 | 96 | ||
120 | 55 | int row = index.row(); | 97 | int row = index.row(); |
121 | 56 | int col = index.column(); | 98 | int col = index.column(); |
122 | @@ -62,7 +104,12 @@ | |||
123 | 62 | 104 | ||
124 | 63 | int trackId = m_rowToTrackId[row]; | 105 | int trackId = m_rowToTrackId[row]; |
125 | 64 | 106 | ||
127 | 65 | if (role == Qt::DisplayRole && m_trackOverrides.contains(trackId)) { | 107 | /* |
128 | 108 | * The if-block below is only executed when a table item has been edited. | ||
129 | 109 | * | ||
130 | 110 | */ | ||
131 | 111 | if ((role == Qt::DisplayRole || role == Qt::ToolTipRole || role == Qt::EditRole) && | ||
132 | 112 | m_trackOverrides.contains(trackId)) { | ||
133 | 66 | //qDebug() << "Returning override for track" << trackId; | 113 | //qDebug() << "Returning override for track" << trackId; |
134 | 67 | TrackPointer pTrack = m_trackDAO.getTrack(trackId); | 114 | TrackPointer pTrack = m_trackDAO.getTrack(trackId); |
135 | 68 | 115 | ||
136 | @@ -86,16 +133,146 @@ | |||
137 | 86 | } else if (fieldIndex(LIBRARYTABLE_COMMENT) == col) { | 133 | } else if (fieldIndex(LIBRARYTABLE_COMMENT) == col) { |
138 | 87 | return QVariant(pTrack->getComment()); | 134 | return QVariant(pTrack->getComment()); |
139 | 88 | } else if (fieldIndex(LIBRARYTABLE_DURATION) == col) { | 135 | } else if (fieldIndex(LIBRARYTABLE_DURATION) == col) { |
141 | 89 | return QVariant(pTrack->getDuration()); | 136 | return pTrack->getDuration(); |
142 | 90 | } else if (fieldIndex(LIBRARYTABLE_BITRATE) == col) { | 137 | } else if (fieldIndex(LIBRARYTABLE_BITRATE) == col) { |
143 | 91 | return QVariant(pTrack->getBitrate()); | 138 | return QVariant(pTrack->getBitrate()); |
144 | 92 | } else if (fieldIndex(LIBRARYTABLE_BPM) == col) { | 139 | } else if (fieldIndex(LIBRARYTABLE_BPM) == col) { |
145 | 93 | return QVariant(pTrack->getBpm()); | 140 | return QVariant(pTrack->getBpm()); |
146 | 141 | } else if (fieldIndex(LIBRARYTABLE_PLAYED) == col) { | ||
147 | 142 | return QVariant(pTrack->getPlayed()); | ||
148 | 143 | } else if (fieldIndex(LIBRARYTABLE_TIMESPLAYED) == col) { | ||
149 | 144 | return QVariant(pTrack->getTimesPlayed()); | ||
150 | 145 | } else if (fieldIndex(LIBRARYTABLE_RATING) == col) { | ||
151 | 146 | return pTrack->getRating(); | ||
152 | 94 | } | 147 | } |
153 | 95 | } | 148 | } |
154 | 149 | |||
155 | 150 | // If none of these work, hand off to the lower layer to deal with. The role | ||
156 | 151 | // might not be Edit/Display/ToolTip, or we might have a bug. | ||
157 | 96 | return QSqlTableModel::data(index, role); | 152 | return QSqlTableModel::data(index, role); |
158 | 97 | } | 153 | } |
159 | 98 | 154 | ||
160 | 155 | |||
161 | 156 | QVariant BaseSqlTableModel::data(const QModelIndex& index, int role) const { | ||
162 | 157 | if (!index.isValid()) { | ||
163 | 158 | return QVariant(); | ||
164 | 159 | } | ||
165 | 160 | |||
166 | 161 | int row = index.row(); | ||
167 | 162 | int col = index.column(); | ||
168 | 163 | |||
169 | 164 | //qDebug() << "BaseSqlTableModel::data() column:" << col << "role:" << role; | ||
170 | 165 | |||
171 | 166 | // This value is the value in its most raw form. It was looked up either | ||
172 | 167 | // from the SQL table or from the cached track layer. | ||
173 | 168 | QVariant value = getBaseValue(index, role); | ||
174 | 169 | |||
175 | 170 | // Format the value based on whether we are in a tooltip, display, or edit | ||
176 | 171 | // role | ||
177 | 172 | if (role == Qt::ToolTipRole || role == Qt::DisplayRole) { | ||
178 | 173 | if (index.column() == fieldIndex(LIBRARYTABLE_DURATION)) { | ||
179 | 174 | if (qVariantCanConvert<int>(value)) | ||
180 | 175 | value = MixxxUtils::secondsToMinutes(qVariantValue<int>(value)); | ||
181 | 176 | } else if (index.column() == fieldIndex(LIBRARYTABLE_RATING)) { | ||
182 | 177 | if (qVariantCanConvert<int>(value)) | ||
183 | 178 | value = qVariantFromValue(StarRating(value.toInt())); | ||
184 | 179 | } else if (index.column() == fieldIndex(LIBRARYTABLE_TIMESPLAYED)) { | ||
185 | 180 | if (qVariantCanConvert<int>(value)) | ||
186 | 181 | value = QString("(%1)").arg(value.toInt()); | ||
187 | 182 | } else if (index.column() == fieldIndex(LIBRARYTABLE_PLAYED)) { | ||
188 | 183 | // Convert to a bool. Not really that useful since it gets converted | ||
189 | 184 | // right back to a QVariant | ||
190 | 185 | value = (value == "true") ? true : false; | ||
191 | 186 | } | ||
192 | 187 | } else if (role == Qt::EditRole) { | ||
193 | 188 | if (index.column() == fieldIndex(LIBRARYTABLE_BPM)) { | ||
194 | 189 | return value.toDouble(); | ||
195 | 190 | } else if (index.column() == fieldIndex(LIBRARYTABLE_TIMESPLAYED)) { | ||
196 | 191 | return index.sibling(index.row(), fieldIndex(LIBRARYTABLE_PLAYED)).data().toBool(); | ||
197 | 192 | } else if (index.column() == fieldIndex(LIBRARYTABLE_RATING)) { | ||
198 | 193 | if (qVariantCanConvert<int>(value)) | ||
199 | 194 | value = qVariantFromValue(StarRating(value.toInt())); | ||
200 | 195 | } | ||
201 | 196 | } else if (role == Qt::CheckStateRole) { | ||
202 | 197 | if (index.column() == fieldIndex(LIBRARYTABLE_TIMESPLAYED)) { | ||
203 | 198 | bool played = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_PLAYED)).data().toBool(); | ||
204 | 199 | value = played ? Qt::Checked : Qt::Unchecked; | ||
205 | 200 | } | ||
206 | 201 | } | ||
207 | 202 | |||
208 | 203 | return value; | ||
209 | 204 | } | ||
210 | 205 | |||
211 | 206 | bool BaseSqlTableModel::setData(const QModelIndex &index, const QVariant &value, int role) | ||
212 | 207 | { | ||
213 | 208 | if (!index.isValid()) | ||
214 | 209 | return false; | ||
215 | 210 | |||
216 | 211 | int row = index.row(); | ||
217 | 212 | int col = index.column(); | ||
218 | 213 | |||
219 | 214 | //qDebug() << "BaseSqlTableModel::setData() column:" << col << "value:" << value << "role:" << role; | ||
220 | 215 | |||
221 | 216 | // Over-ride sets to TIMESPLAYED and re-direct them to PLAYED | ||
222 | 217 | if (role == Qt::CheckStateRole) { | ||
223 | 218 | if (index.column() == fieldIndex(LIBRARYTABLE_TIMESPLAYED)) { | ||
224 | 219 | QString val = value.toInt() > 0 ? QString("true") : QString("false"); | ||
225 | 220 | QModelIndex playedIndex = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_PLAYED)); | ||
226 | 221 | return setData(playedIndex, val, Qt::EditRole); | ||
227 | 222 | } | ||
228 | 223 | } | ||
229 | 224 | |||
230 | 225 | Q_ASSERT(m_rowToTrackId.contains(row)); | ||
231 | 226 | if (!m_rowToTrackId.contains(row)) { | ||
232 | 227 | return QSqlTableModel::setData(index, value, role); | ||
233 | 228 | } | ||
234 | 229 | |||
235 | 230 | int trackId = m_rowToTrackId[row]; | ||
236 | 231 | TrackPointer pTrack = m_trackDAO.getTrack(trackId); | ||
237 | 232 | |||
238 | 233 | // TODO(XXX) Qt properties could really help here. | ||
239 | 234 | if (fieldIndex(LIBRARYTABLE_ARTIST) == col) { | ||
240 | 235 | pTrack->setArtist(value.toString()); | ||
241 | 236 | } else if (fieldIndex(LIBRARYTABLE_TITLE) == col) { | ||
242 | 237 | pTrack->setTitle(value.toString()); | ||
243 | 238 | } else if (fieldIndex(LIBRARYTABLE_ALBUM) == col) { | ||
244 | 239 | pTrack->setAlbum(value.toString()); | ||
245 | 240 | } else if (fieldIndex(LIBRARYTABLE_YEAR) == col) { | ||
246 | 241 | pTrack->setYear(value.toString()); | ||
247 | 242 | } else if (fieldIndex(LIBRARYTABLE_GENRE) == col) { | ||
248 | 243 | pTrack->setGenre(value.toString()); | ||
249 | 244 | } else if (fieldIndex(LIBRARYTABLE_FILETYPE) == col) { | ||
250 | 245 | pTrack->setType(value.toString()); | ||
251 | 246 | } else if (fieldIndex(LIBRARYTABLE_TRACKNUMBER) == col) { | ||
252 | 247 | pTrack->setTrackNumber(value.toString()); | ||
253 | 248 | } else if (fieldIndex(LIBRARYTABLE_LOCATION) == col) { | ||
254 | 249 | pTrack->setLocation(value.toString()); | ||
255 | 250 | } else if (fieldIndex(LIBRARYTABLE_COMMENT) == col) { | ||
256 | 251 | pTrack->setComment(value.toString()); | ||
257 | 252 | } else if (fieldIndex(LIBRARYTABLE_DURATION) == col) { | ||
258 | 253 | pTrack->setDuration(value.toInt()); | ||
259 | 254 | } else if (fieldIndex(LIBRARYTABLE_BITRATE) == col) { | ||
260 | 255 | pTrack->setBitrate(value.toInt()); | ||
261 | 256 | } else if (fieldIndex(LIBRARYTABLE_BPM) == col) { | ||
262 | 257 | //QVariant::toFloat needs >= QT 4.6.x | ||
263 | 258 | pTrack->setBpm((float) value.toDouble()); | ||
264 | 259 | } else if (fieldIndex(LIBRARYTABLE_PLAYED) == col) { | ||
265 | 260 | pTrack->setPlayed(value.toBool()); | ||
266 | 261 | } else if (fieldIndex(LIBRARYTABLE_TIMESPLAYED) == col) { | ||
267 | 262 | pTrack->setTimesPlayed(value.toInt()); | ||
268 | 263 | } else if (fieldIndex(LIBRARYTABLE_RATING) == col) { | ||
269 | 264 | StarRating starRating = qVariantValue<StarRating>(value); | ||
270 | 265 | pTrack->setRating(starRating.starCount()); | ||
271 | 266 | } | ||
272 | 267 | |||
273 | 268 | // Do not save the track here. Changing the track dirties it and the caching | ||
274 | 269 | // system will automatically save the track once it is unloaded from | ||
275 | 270 | // memory. rryan 10/2010 | ||
276 | 271 | //m_trackDAO.saveTrack(pTrack); | ||
277 | 272 | |||
278 | 273 | return true; | ||
279 | 274 | } | ||
280 | 275 | |||
281 | 99 | void BaseSqlTableModel::trackChanged(int trackId) { | 276 | void BaseSqlTableModel::trackChanged(int trackId) { |
282 | 100 | m_trackOverrides.insert(trackId); | 277 | m_trackOverrides.insert(trackId); |
283 | 101 | if (m_trackIdToRow.contains(trackId)) { | 278 | if (m_trackIdToRow.contains(trackId)) { |
284 | @@ -129,7 +306,7 @@ | |||
285 | 129 | 306 | ||
286 | 130 | QString table = m_qTableName; | 307 | QString table = m_qTableName; |
287 | 131 | QString field = database().driver()->escapeIdentifier(f.name(), | 308 | QString field = database().driver()->escapeIdentifier(f.name(), |
289 | 132 | QSqlDriver::FieldName); | 309 | QSqlDriver::FieldName); |
290 | 133 | s.append(QLatin1String("ORDER BY ")); | 310 | s.append(QLatin1String("ORDER BY ")); |
291 | 134 | QString sort_field = QString("%1.%2").arg(table).arg(field); | 311 | QString sort_field = QString("%1.%2").arg(table).arg(field); |
292 | 135 | 312 | ||
293 | @@ -149,3 +326,48 @@ | |||
294 | 149 | s += m_eSortOrder == Qt::AscendingOrder ? QLatin1String(" ASC") : QLatin1String(" DESC"); | 326 | s += m_eSortOrder == Qt::AscendingOrder ? QLatin1String(" ASC") : QLatin1String(" DESC"); |
295 | 150 | return s; | 327 | return s; |
296 | 151 | } | 328 | } |
297 | 329 | |||
298 | 330 | Qt::ItemFlags BaseSqlTableModel::readWriteFlags(const QModelIndex &index) const | ||
299 | 331 | { | ||
300 | 332 | Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); | ||
301 | 333 | if (!index.isValid()) | ||
302 | 334 | return Qt::ItemIsEnabled; | ||
303 | 335 | |||
304 | 336 | //Enable dragging songs from this data model to elsewhere (like the waveform | ||
305 | 337 | //widget to load a track into a Player). | ||
306 | 338 | defaultFlags |= Qt::ItemIsDragEnabled; | ||
307 | 339 | |||
308 | 340 | if ( index.column() == fieldIndex(LIBRARYTABLE_FILETYPE) | ||
309 | 341 | || index.column() == fieldIndex(LIBRARYTABLE_LOCATION) | ||
310 | 342 | || index.column() == fieldIndex(LIBRARYTABLE_DURATION) | ||
311 | 343 | || index.column() == fieldIndex(LIBRARYTABLE_BITRATE) | ||
312 | 344 | || index.column() == fieldIndex(LIBRARYTABLE_DATETIMEADDED)) | ||
313 | 345 | { | ||
314 | 346 | return defaultFlags | QAbstractItemModel::flags(index); | ||
315 | 347 | } | ||
316 | 348 | else if (index.column() == fieldIndex(LIBRARYTABLE_TIMESPLAYED)) { | ||
317 | 349 | return defaultFlags | QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable; | ||
318 | 350 | } | ||
319 | 351 | else { | ||
320 | 352 | return defaultFlags | QAbstractItemModel::flags(index) | Qt::ItemIsEditable; | ||
321 | 353 | } | ||
322 | 354 | } | ||
323 | 355 | |||
324 | 356 | Qt::ItemFlags BaseSqlTableModel::readOnlyFlags(const QModelIndex &index) const | ||
325 | 357 | { | ||
326 | 358 | Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); | ||
327 | 359 | if (!index.isValid()) | ||
328 | 360 | return Qt::ItemIsEnabled; | ||
329 | 361 | |||
330 | 362 | //Enable dragging songs from this data model to elsewhere (like the waveform widget to | ||
331 | 363 | //load a track into a Player). | ||
332 | 364 | defaultFlags |= Qt::ItemIsDragEnabled; | ||
333 | 365 | |||
334 | 366 | return defaultFlags; | ||
335 | 367 | |||
336 | 368 | } | ||
337 | 369 | |||
338 | 370 | Qt::ItemFlags BaseSqlTableModel::flags(const QModelIndex &index) const | ||
339 | 371 | { | ||
340 | 372 | return readWriteFlags(index); | ||
341 | 373 | } | ||
342 | 152 | 374 | ||
343 | === modified file 'mixxx/src/library/basesqltablemodel.h' | |||
344 | --- mixxx/src/library/basesqltablemodel.h 2010-07-15 19:07:16 +0000 | |||
345 | +++ mixxx/src/library/basesqltablemodel.h 2010-10-19 05:33:52 +0000 | |||
346 | @@ -23,12 +23,21 @@ | |||
347 | 23 | virtual void setSort(int column, Qt::SortOrder order); | 23 | virtual void setSort(int column, Qt::SortOrder order); |
348 | 24 | virtual bool select(); | 24 | virtual bool select(); |
349 | 25 | virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; | 25 | virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; |
351 | 26 | 26 | virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); | |
352 | 27 | /** Use this if you want a model that is read-only. */ | ||
353 | 28 | virtual Qt::ItemFlags readOnlyFlags(const QModelIndex &index) const; | ||
354 | 29 | /** Use this if you want a model that can be changed */ | ||
355 | 30 | virtual Qt::ItemFlags readWriteFlags(const QModelIndex &index) const; | ||
356 | 31 | /** calls readWriteFlags() by default */ | ||
357 | 32 | virtual Qt::ItemFlags flags(const QModelIndex &index) const; | ||
358 | 27 | protected: | 33 | protected: |
359 | 28 | virtual QString orderByClause() const; | 34 | virtual QString orderByClause() const; |
360 | 35 | virtual void initHeaderData(); | ||
361 | 29 | private slots: | 36 | private slots: |
362 | 30 | void trackChanged(int trackId); | 37 | void trackChanged(int trackId); |
363 | 31 | private: | 38 | private: |
364 | 39 | QVariant getBaseValue(const QModelIndex& index, int role = Qt::DisplayRole) const; | ||
365 | 40 | |||
366 | 32 | QString m_qTableName; | 41 | QString m_qTableName; |
367 | 33 | int m_iSortColumn; | 42 | int m_iSortColumn; |
368 | 34 | Qt::SortOrder m_eSortOrder; | 43 | Qt::SortOrder m_eSortOrder; |
369 | 35 | 44 | ||
370 | === modified file 'mixxx/src/library/cratetablemodel.cpp' | |||
371 | --- mixxx/src/library/cratetablemodel.cpp 2010-09-14 20:32:32 +0000 | |||
372 | +++ mixxx/src/library/cratetablemodel.cpp 2010-10-19 05:33:52 +0000 | |||
373 | @@ -33,11 +33,14 @@ | |||
374 | 33 | QString queryString = QString("CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS " | 33 | QString queryString = QString("CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS " |
375 | 34 | "SELECT " | 34 | "SELECT " |
376 | 35 | "library." + LIBRARYTABLE_ID + "," + | 35 | "library." + LIBRARYTABLE_ID + "," + |
377 | 36 | LIBRARYTABLE_PLAYED + "," + | ||
378 | 37 | LIBRARYTABLE_TIMESPLAYED + "," + | ||
379 | 36 | LIBRARYTABLE_ARTIST + "," + | 38 | LIBRARYTABLE_ARTIST + "," + |
380 | 37 | LIBRARYTABLE_TITLE + "," + | 39 | LIBRARYTABLE_TITLE + "," + |
381 | 38 | LIBRARYTABLE_ALBUM + "," + | 40 | LIBRARYTABLE_ALBUM + "," + |
382 | 39 | LIBRARYTABLE_YEAR + "," + | 41 | LIBRARYTABLE_YEAR + "," + |
383 | 40 | LIBRARYTABLE_DURATION + "," + | 42 | LIBRARYTABLE_DURATION + "," + |
384 | 43 | LIBRARYTABLE_RATING + "," + | ||
385 | 41 | LIBRARYTABLE_GENRE + "," + | 44 | LIBRARYTABLE_GENRE + "," + |
386 | 42 | LIBRARYTABLE_FILETYPE + "," + | 45 | LIBRARYTABLE_FILETYPE + "," + |
387 | 43 | LIBRARYTABLE_TRACKNUMBER + "," + | 46 | LIBRARYTABLE_TRACKNUMBER + "," + |
388 | @@ -69,34 +72,8 @@ | |||
389 | 69 | 72 | ||
390 | 70 | select(); | 73 | select(); |
391 | 71 | 74 | ||
420 | 72 | setHeaderData(fieldIndex(LIBRARYTABLE_ID), | 75 | // BaseSqlTableModel sets up the header names |
421 | 73 | Qt::Horizontal, tr("ID")); | 76 | initHeaderData(); |
394 | 74 | setHeaderData(fieldIndex(LIBRARYTABLE_ARTIST), | ||
395 | 75 | Qt::Horizontal, tr("Artist")); | ||
396 | 76 | setHeaderData(fieldIndex(LIBRARYTABLE_TITLE), | ||
397 | 77 | Qt::Horizontal, tr("Title")); | ||
398 | 78 | setHeaderData(fieldIndex(LIBRARYTABLE_ALBUM), | ||
399 | 79 | Qt::Horizontal, tr("Album")); | ||
400 | 80 | setHeaderData(fieldIndex(LIBRARYTABLE_GENRE), | ||
401 | 81 | Qt::Horizontal, tr("Genre")); | ||
402 | 82 | setHeaderData(fieldIndex(LIBRARYTABLE_YEAR), | ||
403 | 83 | Qt::Horizontal, tr("Year")); | ||
404 | 84 | setHeaderData(fieldIndex(LIBRARYTABLE_FILETYPE), | ||
405 | 85 | Qt::Horizontal, tr("Type")); | ||
406 | 86 | setHeaderData(fieldIndex("location"), | ||
407 | 87 | Qt::Horizontal, tr("Location")); | ||
408 | 88 | setHeaderData(fieldIndex(LIBRARYTABLE_COMMENT), | ||
409 | 89 | Qt::Horizontal, tr("Comment")); | ||
410 | 90 | setHeaderData(fieldIndex(LIBRARYTABLE_DURATION), | ||
411 | 91 | Qt::Horizontal, tr("Duration")); | ||
412 | 92 | setHeaderData(fieldIndex(LIBRARYTABLE_TRACKNUMBER), | ||
413 | 93 | Qt::Horizontal, tr("Track #")); | ||
414 | 94 | setHeaderData(fieldIndex(LIBRARYTABLE_BITRATE), | ||
415 | 95 | Qt::Horizontal, tr("Bitrate")); | ||
416 | 96 | setHeaderData(fieldIndex(LIBRARYTABLE_BPM), | ||
417 | 97 | Qt::Horizontal, tr("BPM")); | ||
418 | 98 | setHeaderData(fieldIndex(LIBRARYTABLE_DATETIMEADDED), | ||
419 | 99 | Qt::Horizontal, tr("Date Added")); | ||
422 | 100 | } | 77 | } |
423 | 101 | 78 | ||
424 | 102 | bool CrateTableModel::addTrack(const QModelIndex& index, QString location) { | 79 | bool CrateTableModel::addTrack(const QModelIndex& index, QString location) { |
425 | @@ -186,12 +163,22 @@ | |||
426 | 186 | filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + ")"; | 163 | filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + ")"; |
427 | 187 | else { | 164 | else { |
428 | 188 | QSqlField search("search", QVariant::String); | 165 | QSqlField search("search", QVariant::String); |
435 | 189 | search.setValue("%" + searchText + "%"); | 166 | |
436 | 190 | QString escapedText = database().driver()->formatValue(search); | 167 | |
437 | 191 | filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + " AND " + | 168 | filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER; |
438 | 192 | "(artist LIKE " + escapedText + " OR " + | 169 | |
439 | 193 | "album LIKE " + escapedText + " OR " + | 170 | foreach(QString term, searchText.split(" ")) |
440 | 194 | "title LIKE " + escapedText + "))"; | 171 | { |
441 | 172 | search.setValue("%" + term + "%"); | ||
442 | 173 | QString escapedText = database().driver()->formatValue(search); | ||
443 | 174 | filter += " AND (artist LIKE " + escapedText + " OR " + | ||
444 | 175 | "album LIKE " + escapedText + " OR " + | ||
445 | 176 | "location LIKE " + escapedText + " OR " + | ||
446 | 177 | "comment LIKE " + escapedText + " OR " + | ||
447 | 178 | "title LIKE " + escapedText + ")"; | ||
448 | 179 | } | ||
449 | 180 | |||
450 | 181 | filter += ")"; | ||
451 | 195 | } | 182 | } |
452 | 196 | 183 | ||
453 | 197 | setFilter(filter); | 184 | setFilter(filter); |
454 | @@ -203,6 +190,7 @@ | |||
455 | 203 | 190 | ||
456 | 204 | bool CrateTableModel::isColumnInternal(int column) { | 191 | bool CrateTableModel::isColumnInternal(int column) { |
457 | 205 | if (column == fieldIndex(LIBRARYTABLE_ID) || | 192 | if (column == fieldIndex(LIBRARYTABLE_ID) || |
458 | 193 | column == fieldIndex(LIBRARYTABLE_PLAYED) || | ||
459 | 206 | column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) || | 194 | column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) || |
460 | 207 | column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED)) { | 195 | column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED)) { |
461 | 208 | return true; | 196 | return true; |
462 | @@ -235,42 +223,10 @@ | |||
463 | 235 | return mimeData; | 223 | return mimeData; |
464 | 236 | } | 224 | } |
465 | 237 | 225 | ||
466 | 238 | Qt::ItemFlags CrateTableModel::flags(const QModelIndex& index) const { | ||
467 | 239 | Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); | ||
468 | 240 | if (!index.isValid()) | ||
469 | 241 | return Qt::ItemIsEnabled; | ||
470 | 242 | |||
471 | 243 | //Enable dragging songs from this data model to elsewhere (like the waveform | ||
472 | 244 | //widget to load a track into a Player). | ||
473 | 245 | defaultFlags |= Qt::ItemIsDragEnabled; | ||
474 | 246 | |||
475 | 247 | return defaultFlags; | ||
476 | 248 | } | ||
477 | 249 | |||
478 | 250 | QItemDelegate* CrateTableModel::delegateForColumn(int i) { | 226 | QItemDelegate* CrateTableModel::delegateForColumn(int i) { |
479 | 251 | return NULL; | 227 | return NULL; |
480 | 252 | } | 228 | } |
481 | 253 | 229 | ||
482 | 254 | QVariant CrateTableModel::data(const QModelIndex& item, int role) const { | ||
483 | 255 | if (!item.isValid()) | ||
484 | 256 | return QVariant(); | ||
485 | 257 | |||
486 | 258 | QVariant value; | ||
487 | 259 | |||
488 | 260 | if (role == Qt::ToolTipRole) | ||
489 | 261 | value = BaseSqlTableModel::data(item, Qt::DisplayRole); | ||
490 | 262 | else | ||
491 | 263 | value = BaseSqlTableModel::data(item, role); | ||
492 | 264 | |||
493 | 265 | if ((role == Qt::DisplayRole || role == Qt::ToolTipRole) && | ||
494 | 266 | item.column() == fieldIndex(LIBRARYTABLE_DURATION)) { | ||
495 | 267 | if (qVariantCanConvert<int>(value)) { | ||
496 | 268 | value = MixxxUtils::secondsToMinutes(qVariantValue<int>(value)); | ||
497 | 269 | } | ||
498 | 270 | } | ||
499 | 271 | return value; | ||
500 | 272 | } | ||
501 | 273 | |||
502 | 274 | TrackModel::CapabilitiesFlags CrateTableModel::getCapabilities() const { | 230 | TrackModel::CapabilitiesFlags CrateTableModel::getCapabilities() const { |
503 | 275 | return TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_ADDTOPLAYLIST | | 231 | return TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_ADDTOPLAYLIST | |
504 | 276 | TRACKMODELCAPS_ADDTOCRATE | TRACKMODELCAPS_ADDTOAUTODJ; | 232 | TRACKMODELCAPS_ADDTOCRATE | TRACKMODELCAPS_ADDTOAUTODJ; |
505 | 277 | 233 | ||
506 | === modified file 'mixxx/src/library/cratetablemodel.h' | |||
507 | --- mixxx/src/library/cratetablemodel.h 2010-09-13 06:23:38 +0000 | |||
508 | +++ mixxx/src/library/cratetablemodel.h 2010-10-19 05:33:52 +0000 | |||
509 | @@ -20,9 +20,7 @@ | |||
510 | 20 | 20 | ||
511 | 21 | void setCrate(int crateId); | 21 | void setCrate(int crateId); |
512 | 22 | 22 | ||
513 | 23 | virtual QVariant data(const QModelIndex& item, int role) const; | ||
514 | 24 | QMimeData* mimeData(const QModelIndexList &indexes) const; | 23 | QMimeData* mimeData(const QModelIndexList &indexes) const; |
515 | 25 | Qt::ItemFlags flags(const QModelIndex &index) const; | ||
516 | 26 | 24 | ||
517 | 27 | // From TrackModel | 25 | // From TrackModel |
518 | 28 | virtual TrackPointer getTrack(const QModelIndex& index) const; | 26 | virtual TrackPointer getTrack(const QModelIndex& index) const; |
519 | 29 | 27 | ||
520 | === modified file 'mixxx/src/library/dao/trackdao.cpp' | |||
521 | --- mixxx/src/library/dao/trackdao.cpp 2010-09-17 04:15:33 +0000 | |||
522 | +++ mixxx/src/library/dao/trackdao.cpp 2010-10-19 05:33:52 +0000 | |||
523 | @@ -19,6 +19,18 @@ | |||
524 | 19 | 19 | ||
525 | 20 | } | 20 | } |
526 | 21 | 21 | ||
527 | 22 | void TrackDAO::finish() | ||
528 | 23 | { | ||
529 | 24 | //clear out played information on exit | ||
530 | 25 | //crash prevention: if mixxx crashes, played information will be maintained | ||
531 | 26 | qDebug() << "Clearing played information for this session"; | ||
532 | 27 | QSqlQuery query(m_database); | ||
533 | 28 | if (!query.exec("UPDATE library SET played=0")) | ||
534 | 29 | { | ||
535 | 30 | qDebug() << "Error clearing played value"; | ||
536 | 31 | } | ||
537 | 32 | } | ||
538 | 33 | |||
539 | 22 | TrackDAO::~TrackDAO() | 34 | TrackDAO::~TrackDAO() |
540 | 23 | { | 35 | { |
541 | 24 | } | 36 | } |
542 | @@ -187,13 +199,15 @@ | |||
543 | 187 | 199 | ||
544 | 188 | void TrackDAO::prepareLibraryInsert(QSqlQuery& query) { | 200 | void TrackDAO::prepareLibraryInsert(QSqlQuery& query) { |
545 | 189 | query.prepare("INSERT INTO library (artist, title, album, year, genre, tracknumber, " | 201 | query.prepare("INSERT INTO library (artist, title, album, year, genre, tracknumber, " |
547 | 190 | "filetype, location, comment, url, duration, " | 202 | "filetype, location, comment, url, duration, rating, " |
548 | 191 | "bitrate, samplerate, cuepoint, bpm, wavesummaryhex, " | 203 | "bitrate, samplerate, cuepoint, bpm, wavesummaryhex, " |
549 | 204 | "timesplayed, " | ||
550 | 192 | "channels, mixxx_deleted, header_parsed) " | 205 | "channels, mixxx_deleted, header_parsed) " |
551 | 193 | "VALUES (:artist, " | 206 | "VALUES (:artist, " |
552 | 194 | ":title, :album, :year, :genre, :tracknumber, " | 207 | ":title, :album, :year, :genre, :tracknumber, " |
554 | 195 | ":filetype, :location, :comment, :url, :duration, " | 208 | ":filetype, :location, :comment, :url, :duration, :rating," |
555 | 196 | ":bitrate, :samplerate, :cuepoint, :bpm, :wavesummaryhex, " | 209 | ":bitrate, :samplerate, :cuepoint, :bpm, :wavesummaryhex, " |
556 | 210 | ":timesplayed, " | ||
557 | 197 | ":channels, :mixxx_deleted, :header_parsed)"); | 211 | ":channels, :mixxx_deleted, :header_parsed)"); |
558 | 198 | } | 212 | } |
559 | 199 | 213 | ||
560 | @@ -209,6 +223,7 @@ | |||
561 | 209 | query.bindValue(":comment", pTrack->getComment()); | 223 | query.bindValue(":comment", pTrack->getComment()); |
562 | 210 | query.bindValue(":url", pTrack->getURL()); | 224 | query.bindValue(":url", pTrack->getURL()); |
563 | 211 | query.bindValue(":duration", pTrack->getDuration()); | 225 | query.bindValue(":duration", pTrack->getDuration()); |
564 | 226 | query.bindValue(":rating", pTrack->getRating()); | ||
565 | 212 | query.bindValue(":bitrate", pTrack->getBitrate()); | 227 | query.bindValue(":bitrate", pTrack->getBitrate()); |
566 | 213 | query.bindValue(":samplerate", pTrack->getSampleRate()); | 228 | query.bindValue(":samplerate", pTrack->getSampleRate()); |
567 | 214 | query.bindValue(":cuepoint", pTrack->getCuePoint()); | 229 | query.bindValue(":cuepoint", pTrack->getCuePoint()); |
568 | @@ -216,7 +231,7 @@ | |||
569 | 216 | const QByteArray* pWaveSummary = pTrack->getWaveSummary(); | 231 | const QByteArray* pWaveSummary = pTrack->getWaveSummary(); |
570 | 217 | if (pWaveSummary) //Avoid null pointer deref | 232 | if (pWaveSummary) //Avoid null pointer deref |
571 | 218 | query.bindValue(":wavesummaryhex", *pWaveSummary); | 233 | query.bindValue(":wavesummaryhex", *pWaveSummary); |
573 | 219 | //query.bindValue(":timesplayed", pTrack->getCuePoint()); | 234 | query.bindValue(":timesplayed", pTrack->getTimesPlayed()); |
574 | 220 | //query.bindValue(":datetime_added", pTrack->getDateAdded()); | 235 | //query.bindValue(":datetime_added", pTrack->getDateAdded()); |
575 | 221 | query.bindValue(":channels", pTrack->getChannels()); | 236 | query.bindValue(":channels", pTrack->getChannels()); |
576 | 222 | query.bindValue(":mixxx_deleted", 0); | 237 | query.bindValue(":mixxx_deleted", 0); |
577 | @@ -322,7 +337,7 @@ | |||
578 | 322 | time.start(); | 337 | time.start(); |
579 | 323 | 338 | ||
580 | 324 | //qDebug() << "TrackDAO::addTrack" << QThread::currentThread() << m_database.connectionName(); | 339 | //qDebug() << "TrackDAO::addTrack" << QThread::currentThread() << m_database.connectionName(); |
582 | 325 | //qDebug() << "TrackCollection::addTrack(), inserting into DB"; | 340 | //qDebug() << "TrackCollection::addTrack(), inserting into DB"; |
583 | 326 | Q_ASSERT(pTrack); //Why you be giving me NULL pTracks | 341 | Q_ASSERT(pTrack); //Why you be giving me NULL pTracks |
584 | 327 | 342 | ||
585 | 328 | //Start the transaction | 343 | //Start the transaction |
586 | @@ -500,12 +515,14 @@ | |||
587 | 500 | QString url = query.value(query.record().indexOf("url")).toString(); | 515 | QString url = query.value(query.record().indexOf("url")).toString(); |
588 | 501 | int duration = query.value(query.record().indexOf("duration")).toInt(); | 516 | int duration = query.value(query.record().indexOf("duration")).toInt(); |
589 | 502 | int bitrate = query.value(query.record().indexOf("bitrate")).toInt(); | 517 | int bitrate = query.value(query.record().indexOf("bitrate")).toInt(); |
590 | 518 | int rating = query.value(query.record().indexOf("rating")).toInt(); | ||
591 | 503 | int samplerate = query.value(query.record().indexOf("samplerate")).toInt(); | 519 | int samplerate = query.value(query.record().indexOf("samplerate")).toInt(); |
592 | 504 | int cuepoint = query.value(query.record().indexOf("cuepoint")).toInt(); | 520 | int cuepoint = query.value(query.record().indexOf("cuepoint")).toInt(); |
593 | 505 | QString bpm = query.value(query.record().indexOf("bpm")).toString(); | 521 | QString bpm = query.value(query.record().indexOf("bpm")).toString(); |
594 | 506 | QByteArray* wavesummaryhex = new QByteArray( | 522 | QByteArray* wavesummaryhex = new QByteArray( |
595 | 507 | query.value(query.record().indexOf("wavesummaryhex")).toByteArray()); | 523 | query.value(query.record().indexOf("wavesummaryhex")).toByteArray()); |
597 | 508 | //int timesplayed = query.value(query.record().indexOf("timesplayed")).toInt(); | 524 | int timesplayed = query.value(query.record().indexOf("timesplayed")).toInt(); |
598 | 525 | int played = query.value(query.record().indexOf("played")).toInt(); | ||
599 | 509 | int channels = query.value(query.record().indexOf("channels")).toInt(); | 526 | int channels = query.value(query.record().indexOf("channels")).toInt(); |
600 | 510 | int filesize = query.value(query.record().indexOf("filesize")).toInt(); | 527 | int filesize = query.value(query.record().indexOf("filesize")).toInt(); |
601 | 511 | QString filetype = query.value(query.record().indexOf("filetype")).toString(); | 528 | QString filetype = query.value(query.record().indexOf("filetype")).toString(); |
602 | @@ -525,6 +542,7 @@ | |||
603 | 525 | track->setYear(year); | 542 | track->setYear(year); |
604 | 526 | track->setGenre(genre); | 543 | track->setGenre(genre); |
605 | 527 | track->setTrackNumber(tracknumber); | 544 | track->setTrackNumber(tracknumber); |
606 | 545 | track->setRating(rating); | ||
607 | 528 | 546 | ||
608 | 529 | track->setComment(comment); | 547 | track->setComment(comment); |
609 | 530 | track->setURL(url); | 548 | track->setURL(url); |
610 | @@ -535,7 +553,8 @@ | |||
611 | 535 | track->setBpm(bpm.toFloat()); | 553 | track->setBpm(bpm.toFloat()); |
612 | 536 | track->setWaveSummary(wavesummaryhex, false); | 554 | track->setWaveSummary(wavesummaryhex, false); |
613 | 537 | delete wavesummaryhex; | 555 | delete wavesummaryhex; |
615 | 538 | //track->setTimesPlayed //Doesn't exist wtfbbq | 556 | track->setTimesPlayed(timesplayed); |
616 | 557 | track->setPlayed(played); | ||
617 | 539 | track->setChannels(channels); | 558 | track->setChannels(channels); |
618 | 540 | track->setType(filetype); | 559 | track->setType(filetype); |
619 | 541 | track->setLocation(location); | 560 | track->setLocation(location); |
620 | @@ -607,7 +626,8 @@ | |||
621 | 607 | time.start(); | 626 | time.start(); |
622 | 608 | QSqlQuery query(m_database); | 627 | QSqlQuery query(m_database); |
623 | 609 | 628 | ||
625 | 610 | query.prepare("SELECT library.id, artist, title, album, year, genre, tracknumber, filetype, track_locations.location as location, track_locations.filesize as filesize, comment, url, duration, bitrate, samplerate, cuepoint, bpm, wavesummaryhex, channels, header_parsed FROM Library INNER JOIN track_locations ON library.location = track_locations.id WHERE library.id=" + QString("%1").arg(id)); | 629 | query.prepare("SELECT library.id, artist, title, album, year, genre, tracknumber, filetype, rating, track_locations.location as location, track_locations.filesize as filesize, comment, url, duration, bitrate, samplerate, cuepoint, bpm, wavesummaryhex, channels, header_parsed, timesplayed, played FROM Library INNER JOIN track_locations ON library.location = track_locations.id WHERE library.id=" + QString("%1").arg(id)); |
626 | 630 | |||
627 | 611 | TrackPointer pTrack; | 631 | TrackPointer pTrack; |
628 | 612 | 632 | ||
629 | 613 | if (query.exec()) { | 633 | if (query.exec()) { |
630 | @@ -641,9 +661,10 @@ | |||
631 | 641 | "SET artist=:artist, " | 661 | "SET artist=:artist, " |
632 | 642 | "title=:title, album=:album, year=:year, genre=:genre, " | 662 | "title=:title, album=:album, year=:year, genre=:genre, " |
633 | 643 | "filetype=:filetype, tracknumber=:tracknumber, " | 663 | "filetype=:filetype, tracknumber=:tracknumber, " |
635 | 644 | "comment=:comment, url=:url, duration=:duration, " | 664 | "comment=:comment, url=:url, duration=:duration, rating=:rating, " |
636 | 645 | "bitrate=:bitrate, samplerate=:samplerate, cuepoint=:cuepoint, " | 665 | "bitrate=:bitrate, samplerate=:samplerate, cuepoint=:cuepoint, " |
637 | 646 | "bpm=:bpm, wavesummaryhex=:wavesummaryhex, " | 666 | "bpm=:bpm, wavesummaryhex=:wavesummaryhex, " |
638 | 667 | "timesplayed=:timesplayed, played=:played, " | ||
639 | 647 | "channels=:channels, header_parsed=:header_parsed " | 668 | "channels=:channels, header_parsed=:header_parsed " |
640 | 648 | "WHERE id="+QString("%1").arg(trackId)); | 669 | "WHERE id="+QString("%1").arg(trackId)); |
641 | 649 | query.bindValue(":artist", pTrack->getArtist()); | 670 | query.bindValue(":artist", pTrack->getArtist()); |
642 | @@ -660,10 +681,12 @@ | |||
643 | 660 | query.bindValue(":samplerate", pTrack->getSampleRate()); | 681 | query.bindValue(":samplerate", pTrack->getSampleRate()); |
644 | 661 | query.bindValue(":cuepoint", pTrack->getCuePoint()); | 682 | query.bindValue(":cuepoint", pTrack->getCuePoint()); |
645 | 662 | query.bindValue(":bpm", pTrack->getBpm()); | 683 | query.bindValue(":bpm", pTrack->getBpm()); |
646 | 684 | query.bindValue(":rating", pTrack->getRating()); | ||
647 | 663 | const QByteArray* pWaveSummary = pTrack->getWaveSummary(); | 685 | const QByteArray* pWaveSummary = pTrack->getWaveSummary(); |
648 | 664 | if (pWaveSummary) //Avoid null pointer deref | 686 | if (pWaveSummary) //Avoid null pointer deref |
649 | 665 | query.bindValue(":wavesummaryhex", *pWaveSummary); | 687 | query.bindValue(":wavesummaryhex", *pWaveSummary); |
651 | 666 | //query.bindValue(":timesplayed", pTrack->getCuePoint()); | 688 | query.bindValue(":timesplayed", pTrack->getTimesPlayed()); |
652 | 689 | query.bindValue(":played", pTrack->getPlayed()); | ||
653 | 667 | query.bindValue(":channels", pTrack->getChannels()); | 690 | query.bindValue(":channels", pTrack->getChannels()); |
654 | 668 | query.bindValue(":header_parsed", pTrack->getHeaderParsed() ? 1 : 0); | 691 | query.bindValue(":header_parsed", pTrack->getHeaderParsed() ? 1 : 0); |
655 | 669 | //query.bindValue(":location", pTrack->getLocation()); | 692 | //query.bindValue(":location", pTrack->getLocation()); |
656 | 670 | 693 | ||
657 | === modified file 'mixxx/src/library/dao/trackdao.h' | |||
658 | --- mixxx/src/library/dao/trackdao.h 2010-09-13 06:23:38 +0000 | |||
659 | +++ mixxx/src/library/dao/trackdao.h 2010-10-19 05:33:52 +0000 | |||
660 | @@ -38,6 +38,9 @@ | |||
661 | 38 | const QString LIBRARYTABLE_MIXXXDELETED = "mixxx_deleted"; | 38 | const QString LIBRARYTABLE_MIXXXDELETED = "mixxx_deleted"; |
662 | 39 | const QString LIBRARYTABLE_DATETIMEADDED = "datetime_added"; | 39 | const QString LIBRARYTABLE_DATETIMEADDED = "datetime_added"; |
663 | 40 | const QString LIBRARYTABLE_HEADERPARSED = "header_parsed"; | 40 | const QString LIBRARYTABLE_HEADERPARSED = "header_parsed"; |
664 | 41 | const QString LIBRARYTABLE_TIMESPLAYED = "timesplayed"; | ||
665 | 42 | const QString LIBRARYTABLE_PLAYED = "played"; | ||
666 | 43 | const QString LIBRARYTABLE_RATING = "rating"; | ||
667 | 41 | 44 | ||
668 | 42 | const QString TRACKLOCATIONSTABLE_ID = "id"; | 45 | const QString TRACKLOCATIONSTABLE_ID = "id"; |
669 | 43 | const QString TRACKLOCATIONSTABLE_LOCATION = "location"; | 46 | const QString TRACKLOCATIONSTABLE_LOCATION = "location"; |
670 | @@ -52,6 +55,7 @@ | |||
671 | 52 | public: | 55 | public: |
672 | 53 | //TrackDAO() {}; | 56 | //TrackDAO() {}; |
673 | 54 | TrackDAO(QSqlDatabase& database, CueDAO& cueDao); | 57 | TrackDAO(QSqlDatabase& database, CueDAO& cueDao); |
674 | 58 | void finish(); | ||
675 | 55 | virtual ~TrackDAO(); | 59 | virtual ~TrackDAO(); |
676 | 56 | void setDatabase(QSqlDatabase& database) { m_database = database; }; | 60 | void setDatabase(QSqlDatabase& database) { m_database = database; }; |
677 | 57 | 61 | ||
678 | 58 | 62 | ||
679 | === modified file 'mixxx/src/library/legacylibraryimporter.cpp' | |||
680 | --- mixxx/src/library/legacylibraryimporter.cpp 2010-09-11 08:15:14 +0000 | |||
681 | +++ mixxx/src/library/legacylibraryimporter.cpp 2010-10-19 05:33:52 +0000 | |||
682 | @@ -174,9 +174,16 @@ | |||
683 | 174 | } | 174 | } |
684 | 175 | } | 175 | } |
685 | 176 | 176 | ||
689 | 177 | //now change the file to mixxxtrack.bak so that its not readded next time program loads | 177 | QString upgrade_filename = QDir::homePath().append("/").append(SETTINGS_PATH).append("DBUPGRADED"); |
690 | 178 | file.copy(QDir::homePath().append("/").append(SETTINGS_PATH).append("mixxxtrack.bak")); | 178 | //now create stub so that the library is not readded next time program loads |
691 | 179 | file.remove(); | 179 | QFile upgradefile(upgrade_filename); |
692 | 180 | if (!upgradefile.open(QIODevice::WriteOnly | QIODevice::Text)) | ||
693 | 181 | qDebug() << "Couldn't open" << upgrade_filename << "for writing"; | ||
694 | 182 | else | ||
695 | 183 | { | ||
696 | 184 | file.write("",0); | ||
697 | 185 | file.close(); | ||
698 | 186 | } | ||
699 | 180 | } else { | 187 | } else { |
700 | 181 | qDebug() << errorMsg << " line: " << errorLine << " column: " << errorColumn; | 188 | qDebug() << errorMsg << " line: " << errorLine << " column: " << errorColumn; |
701 | 182 | } | 189 | } |
702 | 183 | 190 | ||
703 | === modified file 'mixxx/src/library/libraryscanner.cpp' | |||
704 | --- mixxx/src/library/libraryscanner.cpp 2010-09-18 19:30:15 +0000 | |||
705 | +++ mixxx/src/library/libraryscanner.cpp 2010-10-19 05:33:52 +0000 | |||
706 | @@ -55,10 +55,10 @@ | |||
707 | 55 | */ | 55 | */ |
708 | 56 | QString iTunesArtFolder = ""; | 56 | QString iTunesArtFolder = ""; |
709 | 57 | #if defined(__WINDOWS__) | 57 | #if defined(__WINDOWS__) |
712 | 58 | iTunesArtFolder = QDesktopServices::storageLocation(QDesktopServices::MusicLocation) + "\\iTunes\\Album Artwork"; | 58 | iTunesArtFolder = QDesktopServices::storageLocation(QDesktopServices::MusicLocation) + "\\iTunes\\Album Artwork"; |
713 | 59 | iTunesArtFolder.replace(QString("\\"), QString("/")); | 59 | iTunesArtFolder.replace(QString("\\"), QString("/")); |
714 | 60 | #elif defined(__APPLE__) | 60 | #elif defined(__APPLE__) |
716 | 61 | iTunesArtFolder = QDesktopServices::storageLocation(QDesktopServices::MusicLocation) + "/iTunes/Album Artwork"; | 61 | iTunesArtFolder = QDesktopServices::storageLocation(QDesktopServices::MusicLocation) + "/iTunes/Album Artwork"; |
717 | 62 | #endif | 62 | #endif |
718 | 63 | m_directoriesBlacklist << iTunesArtFolder; | 63 | m_directoriesBlacklist << iTunesArtFolder; |
719 | 64 | qDebug() << "iTunes Album Art path is:" << iTunesArtFolder; | 64 | qDebug() << "iTunes Album Art path is:" << iTunesArtFolder; |
720 | @@ -109,7 +109,7 @@ | |||
721 | 109 | 109 | ||
722 | 110 | //Print out any SQL error, if there was one. | 110 | //Print out any SQL error, if there was one. |
723 | 111 | if (query.lastError().isValid()) { | 111 | if (query.lastError().isValid()) { |
725 | 112 | qDebug() << query.lastError(); | 112 | qDebug() << query.lastError(); |
726 | 113 | } | 113 | } |
727 | 114 | 114 | ||
728 | 115 | QString dir; | 115 | QString dir; |
729 | @@ -167,15 +167,25 @@ | |||
730 | 167 | 167 | ||
731 | 168 | QTime t2; | 168 | QTime t2; |
732 | 169 | t2.start(); | 169 | t2.start(); |
742 | 170 | //Try to upgrade the library from 1.7 (XML) to 1.8+ (DB) if needed | 170 | |
743 | 171 | LegacyLibraryImporter libImport(m_trackDao, m_playlistDao); | 171 | //Try to upgrade the library from 1.7 (XML) to 1.8+ (DB) if needed. If the |
744 | 172 | connect(&libImport, SIGNAL(progress(QString)), | 172 | //upgrade_filename already exists, then do not try to upgrade since we have |
745 | 173 | m_pProgress, SLOT(slotUpdate(QString)), | 173 | //already done it. |
746 | 174 | Qt::BlockingQueuedConnection); | 174 | QString upgrade_filename = QDir::homePath().append("/").append(SETTINGS_PATH).append("DBUPGRADED"); |
747 | 175 | m_database.transaction(); | 175 | qDebug() << "upgrade filename is " << upgrade_filename; |
748 | 176 | libImport.import(); | 176 | QFile upgradefile(upgrade_filename); |
749 | 177 | m_database.commit(); | 177 | if (!upgradefile.exists()) |
750 | 178 | qDebug("Legacy importer took %d ms", t2.elapsed()); | 178 | { |
751 | 179 | LegacyLibraryImporter libImport(m_trackDao, m_playlistDao); | ||
752 | 180 | connect(&libImport, SIGNAL(progress(QString)), | ||
753 | 181 | m_pProgress, SLOT(slotUpdate(QString)), | ||
754 | 182 | Qt::BlockingQueuedConnection); | ||
755 | 183 | m_database.transaction(); | ||
756 | 184 | libImport.import(); | ||
757 | 185 | m_database.commit(); | ||
758 | 186 | qDebug("Legacy importer took %d ms", t2.elapsed()); | ||
759 | 187 | |||
760 | 188 | } | ||
761 | 179 | 189 | ||
762 | 180 | //Refresh the name filters in case we loaded new | 190 | //Refresh the name filters in case we loaded new |
763 | 181 | //SoundSource plugins. | 191 | //SoundSource plugins. |
764 | 182 | 192 | ||
765 | === modified file 'mixxx/src/library/librarytablemodel.cpp' | |||
766 | --- mixxx/src/library/librarytablemodel.cpp 2010-09-14 20:32:32 +0000 | |||
767 | +++ mixxx/src/library/librarytablemodel.cpp 2010-10-19 05:33:52 +0000 | |||
768 | @@ -20,11 +20,14 @@ | |||
769 | 20 | query.prepare("CREATE TEMPORARY VIEW IF NOT EXISTS library_view AS " | 20 | query.prepare("CREATE TEMPORARY VIEW IF NOT EXISTS library_view AS " |
770 | 21 | "SELECT " | 21 | "SELECT " |
771 | 22 | "library." + LIBRARYTABLE_ID + "," + | 22 | "library." + LIBRARYTABLE_ID + "," + |
772 | 23 | "library." + LIBRARYTABLE_PLAYED + "," + | ||
773 | 24 | "library." + LIBRARYTABLE_TIMESPLAYED + "," + | ||
774 | 23 | "library." + LIBRARYTABLE_ARTIST + "," + | 25 | "library." + LIBRARYTABLE_ARTIST + "," + |
775 | 24 | "library." + LIBRARYTABLE_TITLE + "," + | 26 | "library." + LIBRARYTABLE_TITLE + "," + |
776 | 25 | "library." + LIBRARYTABLE_ALBUM + "," + | 27 | "library." + LIBRARYTABLE_ALBUM + "," + |
777 | 26 | "library." + LIBRARYTABLE_YEAR + "," + | 28 | "library." + LIBRARYTABLE_YEAR + "," + |
778 | 27 | "library." + LIBRARYTABLE_DURATION + "," + | 29 | "library." + LIBRARYTABLE_DURATION + "," + |
779 | 30 | "library." + LIBRARYTABLE_RATING + "," + | ||
780 | 28 | "library." + LIBRARYTABLE_GENRE + "," + | 31 | "library." + LIBRARYTABLE_GENRE + "," + |
781 | 29 | "library." + LIBRARYTABLE_FILETYPE + "," + | 32 | "library." + LIBRARYTABLE_FILETYPE + "," + |
782 | 30 | "library." + LIBRARYTABLE_TRACKNUMBER + "," + | 33 | "library." + LIBRARYTABLE_TRACKNUMBER + "," + |
783 | @@ -43,7 +46,7 @@ | |||
784 | 43 | 46 | ||
785 | 44 | //Print out any SQL error, if there was one. | 47 | //Print out any SQL error, if there was one. |
786 | 45 | if (query.lastError().isValid()) { | 48 | if (query.lastError().isValid()) { |
788 | 46 | qDebug() << __FILE__ << __LINE__ << query.lastError(); | 49 | qDebug() << __FILE__ << __LINE__ << query.lastError(); |
789 | 47 | } | 50 | } |
790 | 48 | 51 | ||
791 | 49 | //setTable("library"); | 52 | //setTable("library"); |
792 | @@ -56,34 +59,9 @@ | |||
793 | 56 | //and shows it... | 59 | //and shows it... |
794 | 57 | //setRelation(fieldIndex(LIBRARYTABLE_LOCATION), QSqlRelation("track_locations", "id", "location")); | 60 | //setRelation(fieldIndex(LIBRARYTABLE_LOCATION), QSqlRelation("track_locations", "id", "location")); |
795 | 58 | 61 | ||
824 | 59 | //Set the column heading labels, rename them for translations and have | 62 | |
825 | 60 | //proper capitalization | 63 | // BaseSqlTabelModel will setup the header info |
826 | 61 | setHeaderData(fieldIndex(LIBRARYTABLE_ARTIST), | 64 | initHeaderData(); |
799 | 62 | Qt::Horizontal, tr("Artist")); | ||
800 | 63 | setHeaderData(fieldIndex(LIBRARYTABLE_TITLE), | ||
801 | 64 | Qt::Horizontal, tr("Title")); | ||
802 | 65 | setHeaderData(fieldIndex(LIBRARYTABLE_ALBUM), | ||
803 | 66 | Qt::Horizontal, tr("Album")); | ||
804 | 67 | setHeaderData(fieldIndex(LIBRARYTABLE_GENRE), | ||
805 | 68 | Qt::Horizontal, tr("Genre")); | ||
806 | 69 | setHeaderData(fieldIndex(LIBRARYTABLE_YEAR), | ||
807 | 70 | Qt::Horizontal, tr("Year")); | ||
808 | 71 | setHeaderData(fieldIndex(LIBRARYTABLE_FILETYPE), | ||
809 | 72 | Qt::Horizontal, tr("Type")); | ||
810 | 73 | setHeaderData(fieldIndex(LIBRARYTABLE_LOCATION), | ||
811 | 74 | Qt::Horizontal, tr("Location")); | ||
812 | 75 | setHeaderData(fieldIndex(LIBRARYTABLE_COMMENT), | ||
813 | 76 | Qt::Horizontal, tr("Comment")); | ||
814 | 77 | setHeaderData(fieldIndex(LIBRARYTABLE_DURATION), | ||
815 | 78 | Qt::Horizontal, tr("Duration")); | ||
816 | 79 | setHeaderData(fieldIndex(LIBRARYTABLE_BITRATE), | ||
817 | 80 | Qt::Horizontal, tr("Bitrate")); | ||
818 | 81 | setHeaderData(fieldIndex(LIBRARYTABLE_BPM), | ||
819 | 82 | Qt::Horizontal, tr("BPM")); | ||
820 | 83 | setHeaderData(fieldIndex(LIBRARYTABLE_TRACKNUMBER), | ||
821 | 84 | Qt::Horizontal, tr("Track #")); | ||
822 | 85 | setHeaderData(fieldIndex(LIBRARYTABLE_DATETIMEADDED), | ||
823 | 86 | Qt::Horizontal, tr("Date Added")); | ||
827 | 87 | 65 | ||
828 | 88 | //Sets up the table filter so that we don't show "deleted" tracks (only show mixxx_deleted=0). | 66 | //Sets up the table filter so that we don't show "deleted" tracks (only show mixxx_deleted=0). |
829 | 89 | slotSearch(""); | 67 | slotSearch(""); |
830 | @@ -126,15 +104,15 @@ | |||
831 | 126 | 104 | ||
832 | 127 | TrackPointer LibraryTableModel::getTrack(const QModelIndex& index) const | 105 | TrackPointer LibraryTableModel::getTrack(const QModelIndex& index) const |
833 | 128 | { | 106 | { |
836 | 129 | int trackId = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_ID)).data().toInt(); | 107 | int trackId = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_ID)).data().toInt(); |
837 | 130 | return m_trackDao.getTrack(trackId); | 108 | return m_trackDao.getTrack(trackId); |
838 | 131 | } | 109 | } |
839 | 132 | 110 | ||
840 | 133 | QString LibraryTableModel::getTrackLocation(const QModelIndex& index) const | 111 | QString LibraryTableModel::getTrackLocation(const QModelIndex& index) const |
841 | 134 | { | 112 | { |
845 | 135 | const int locationColumnIndex = fieldIndex(LIBRARYTABLE_LOCATION); | 113 | const int locationColumnIndex = fieldIndex(LIBRARYTABLE_LOCATION); |
846 | 136 | QString location = index.sibling(index.row(), locationColumnIndex).data().toString(); | 114 | QString location = index.sibling(index.row(), locationColumnIndex).data().toString(); |
847 | 137 | return location; | 115 | return location; |
848 | 138 | } | 116 | } |
849 | 139 | 117 | ||
850 | 140 | void LibraryTableModel::removeTracks(const QModelIndexList& indices) { | 118 | void LibraryTableModel::removeTracks(const QModelIndexList& indices) { |
851 | @@ -152,9 +130,9 @@ | |||
852 | 152 | 130 | ||
853 | 153 | void LibraryTableModel::removeTrack(const QModelIndex& index) | 131 | void LibraryTableModel::removeTrack(const QModelIndex& index) |
854 | 154 | { | 132 | { |
858 | 155 | int trackId = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_ID)).data().toInt(); | 133 | int trackId = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_ID)).data().toInt(); |
859 | 156 | m_trackDao.removeTrack(trackId); | 134 | m_trackDao.removeTrack(trackId); |
860 | 157 | select(); //Repopulate the data model. | 135 | select(); //Repopulate the data model. |
861 | 158 | } | 136 | } |
862 | 159 | 137 | ||
863 | 160 | void LibraryTableModel::moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex) | 138 | void LibraryTableModel::moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex) |
864 | @@ -181,12 +159,21 @@ | |||
865 | 181 | filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + ")"; | 159 | filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + ")"; |
866 | 182 | else { | 160 | else { |
867 | 183 | QSqlField search("search", QVariant::String); | 161 | QSqlField search("search", QVariant::String); |
874 | 184 | search.setValue("%" + searchText + "%"); | 162 | |
875 | 185 | QString escapedText = database().driver()->formatValue(search); | 163 | filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER; |
876 | 186 | filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + " AND " + | 164 | |
877 | 187 | "(artist LIKE " + escapedText + " OR " + | 165 | foreach(QString term, searchText.split(" ")) |
878 | 188 | "album LIKE " + escapedText + " OR " + | 166 | { |
879 | 189 | "title LIKE " + escapedText + "))"; | 167 | search.setValue("%" + term + "%"); |
880 | 168 | QString escapedText = database().driver()->formatValue(search); | ||
881 | 169 | filter += " AND (artist LIKE " + escapedText + " OR " + | ||
882 | 170 | "album LIKE " + escapedText + " OR " + | ||
883 | 171 | "location LIKE " + escapedText + " OR " + | ||
884 | 172 | "comment LIKE " + escapedText + " OR " + | ||
885 | 173 | "title LIKE " + escapedText + ")"; | ||
886 | 174 | } | ||
887 | 175 | |||
888 | 176 | filter += ")"; | ||
889 | 190 | } | 177 | } |
890 | 191 | setFilter(filter); | 178 | setFilter(filter); |
891 | 192 | } | 179 | } |
892 | @@ -205,6 +192,7 @@ | |||
893 | 205 | (column == fieldIndex(LIBRARYTABLE_SAMPLERATE)) || | 192 | (column == fieldIndex(LIBRARYTABLE_SAMPLERATE)) || |
894 | 206 | (column == fieldIndex(LIBRARYTABLE_MIXXXDELETED)) || | 193 | (column == fieldIndex(LIBRARYTABLE_MIXXXDELETED)) || |
895 | 207 | (column == fieldIndex(LIBRARYTABLE_HEADERPARSED)) || | 194 | (column == fieldIndex(LIBRARYTABLE_HEADERPARSED)) || |
896 | 195 | (column == fieldIndex(LIBRARYTABLE_PLAYED)) || | ||
897 | 208 | (column == fieldIndex(LIBRARYTABLE_CHANNELS)) || | 196 | (column == fieldIndex(LIBRARYTABLE_CHANNELS)) || |
898 | 209 | (column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED))) { | 197 | (column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED))) { |
899 | 210 | return true; | 198 | return true; |
900 | @@ -216,26 +204,6 @@ | |||
901 | 216 | return NULL; | 204 | return NULL; |
902 | 217 | } | 205 | } |
903 | 218 | 206 | ||
904 | 219 | QVariant LibraryTableModel::data(const QModelIndex& item, int role) const { | ||
905 | 220 | if (!item.isValid()) | ||
906 | 221 | return QVariant(); | ||
907 | 222 | |||
908 | 223 | QVariant value; | ||
909 | 224 | if (role == Qt::ToolTipRole) | ||
910 | 225 | value = BaseSqlTableModel::data(item, Qt::DisplayRole); | ||
911 | 226 | else | ||
912 | 227 | value = BaseSqlTableModel::data(item, role); | ||
913 | 228 | |||
914 | 229 | if ((role == Qt::DisplayRole || role == Qt::ToolTipRole) && | ||
915 | 230 | item.column() == fieldIndex(LIBRARYTABLE_DURATION)) { | ||
916 | 231 | if (qVariantCanConvert<int>(value)) { | ||
917 | 232 | value = MixxxUtils::secondsToMinutes(qVariantValue<int>(value)); | ||
918 | 233 | } | ||
919 | 234 | } | ||
920 | 235 | |||
921 | 236 | return value; | ||
922 | 237 | } | ||
923 | 238 | |||
924 | 239 | QMimeData* LibraryTableModel::mimeData(const QModelIndexList &indexes) const { | 207 | QMimeData* LibraryTableModel::mimeData(const QModelIndexList &indexes) const { |
925 | 240 | QMimeData *mimeData = new QMimeData(); | 208 | QMimeData *mimeData = new QMimeData(); |
926 | 241 | QList<QUrl> urls; | 209 | QList<QUrl> urls; |
927 | @@ -263,26 +231,6 @@ | |||
928 | 263 | return mimeData; | 231 | return mimeData; |
929 | 264 | } | 232 | } |
930 | 265 | 233 | ||
931 | 266 | Qt::ItemFlags LibraryTableModel::flags(const QModelIndex &index) const | ||
932 | 267 | { | ||
933 | 268 | Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); | ||
934 | 269 | if (!index.isValid()) | ||
935 | 270 | return Qt::ItemIsEnabled; | ||
936 | 271 | |||
937 | 272 | //Enable dragging songs from this data model to elsewhere (like the waveform | ||
938 | 273 | //widget to load a track into a Player). | ||
939 | 274 | defaultFlags |= Qt::ItemIsDragEnabled; | ||
940 | 275 | |||
941 | 276 | /** FIXME: This doesn't seem to work - Albert */ | ||
942 | 277 | const int bpmColumnIndex = fieldIndex(LIBRARYTABLE_BPM); | ||
943 | 278 | if (index.column() == bpmColumnIndex) | ||
944 | 279 | { | ||
945 | 280 | return defaultFlags | Qt::ItemIsEditable; | ||
946 | 281 | } | ||
947 | 282 | |||
948 | 283 | return defaultFlags; | ||
949 | 284 | } | ||
950 | 285 | |||
951 | 286 | TrackModel::CapabilitiesFlags LibraryTableModel::getCapabilities() const | 234 | TrackModel::CapabilitiesFlags LibraryTableModel::getCapabilities() const |
952 | 287 | { | 235 | { |
953 | 288 | return TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_ADDTOPLAYLIST | | 236 | return TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_ADDTOPLAYLIST | |
954 | 289 | 237 | ||
955 | === modified file 'mixxx/src/library/librarytablemodel.h' | |||
956 | --- mixxx/src/library/librarytablemodel.h 2010-09-13 06:23:38 +0000 | |||
957 | +++ mixxx/src/library/librarytablemodel.h 2010-10-19 05:33:52 +0000 | |||
958 | @@ -27,11 +27,9 @@ | |||
959 | 27 | virtual bool addTrack(const QModelIndex& index, QString location); | 27 | virtual bool addTrack(const QModelIndex& index, QString location); |
960 | 28 | virtual void moveTrack(const QModelIndex& sourceIndex, | 28 | virtual void moveTrack(const QModelIndex& sourceIndex, |
961 | 29 | const QModelIndex& destIndex); | 29 | const QModelIndex& destIndex); |
962 | 30 | virtual QVariant data(const QModelIndex& item, int role) const; | ||
963 | 31 | 30 | ||
964 | 32 | 31 | ||
965 | 33 | QMimeData* mimeData(const QModelIndexList &indexes) const; | 32 | QMimeData* mimeData(const QModelIndexList &indexes) const; |
966 | 34 | Qt::ItemFlags flags(const QModelIndex &index) const; | ||
967 | 35 | QItemDelegate* delegateForColumn(const int i); | 33 | QItemDelegate* delegateForColumn(const int i); |
968 | 36 | TrackModel::CapabilitiesFlags getCapabilities() const; | 34 | TrackModel::CapabilitiesFlags getCapabilities() const; |
969 | 37 | static const QString DEFAULT_LIBRARYFILTER; | 35 | static const QString DEFAULT_LIBRARYFILTER; |
970 | 38 | 36 | ||
971 | === modified file 'mixxx/src/library/missingtablemodel.cpp' | |||
972 | --- mixxx/src/library/missingtablemodel.cpp 2010-09-14 20:32:32 +0000 | |||
973 | +++ mixxx/src/library/missingtablemodel.cpp 2010-10-19 05:33:52 +0000 | |||
974 | @@ -25,11 +25,14 @@ | |||
975 | 25 | query.prepare("CREATE TEMPORARY VIEW IF NOT EXISTS " + tableName + " AS " | 25 | query.prepare("CREATE TEMPORARY VIEW IF NOT EXISTS " + tableName + " AS " |
976 | 26 | "SELECT " + | 26 | "SELECT " + |
977 | 27 | "library." + LIBRARYTABLE_ID + "," + | 27 | "library." + LIBRARYTABLE_ID + "," + |
978 | 28 | "library." + LIBRARYTABLE_PLAYED + "," + | ||
979 | 29 | "library." + LIBRARYTABLE_TIMESPLAYED + "," + | ||
980 | 28 | "library." + LIBRARYTABLE_ARTIST + "," + | 30 | "library." + LIBRARYTABLE_ARTIST + "," + |
981 | 29 | "library." + LIBRARYTABLE_TITLE + "," + | 31 | "library." + LIBRARYTABLE_TITLE + "," + |
982 | 30 | "library." + LIBRARYTABLE_ALBUM + "," + | 32 | "library." + LIBRARYTABLE_ALBUM + "," + |
983 | 31 | "library." + LIBRARYTABLE_YEAR + "," + | 33 | "library." + LIBRARYTABLE_YEAR + "," + |
984 | 32 | "library." + LIBRARYTABLE_DURATION + "," + | 34 | "library." + LIBRARYTABLE_DURATION + "," + |
985 | 35 | "library." + LIBRARYTABLE_RATING + "," + | ||
986 | 33 | "library." + LIBRARYTABLE_GENRE + "," + | 36 | "library." + LIBRARYTABLE_GENRE + "," + |
987 | 34 | "library." + LIBRARYTABLE_FILETYPE + "," + | 37 | "library." + LIBRARYTABLE_FILETYPE + "," + |
988 | 35 | "library." + LIBRARYTABLE_TRACKNUMBER + "," + | 38 | "library." + LIBRARYTABLE_TRACKNUMBER + "," + |
989 | @@ -58,36 +61,7 @@ | |||
990 | 58 | 61 | ||
991 | 59 | qDebug() << "Created MissingTracksModel!"; | 62 | qDebug() << "Created MissingTracksModel!"; |
992 | 60 | 63 | ||
1023 | 61 | //Set the column heading labels, rename them for translations and have | 64 | initHeaderData(); //derived from BaseSqlModel |
994 | 62 | //proper capitalization | ||
995 | 63 | setHeaderData(fieldIndex("track_locations.location"), | ||
996 | 64 | Qt::Horizontal, tr("Location")); | ||
997 | 65 | setHeaderData(fieldIndex(LIBRARYTABLE_ARTIST), | ||
998 | 66 | Qt::Horizontal, tr("Artist")); | ||
999 | 67 | setHeaderData(fieldIndex(LIBRARYTABLE_TITLE), | ||
1000 | 68 | Qt::Horizontal, tr("Title")); | ||
1001 | 69 | setHeaderData(fieldIndex(LIBRARYTABLE_ALBUM), | ||
1002 | 70 | Qt::Horizontal, tr("Album")); | ||
1003 | 71 | setHeaderData(fieldIndex(LIBRARYTABLE_GENRE), | ||
1004 | 72 | Qt::Horizontal, tr("Genre")); | ||
1005 | 73 | setHeaderData(fieldIndex(LIBRARYTABLE_YEAR), | ||
1006 | 74 | Qt::Horizontal, tr("Year")); | ||
1007 | 75 | setHeaderData(fieldIndex(LIBRARYTABLE_FILETYPE), | ||
1008 | 76 | Qt::Horizontal, tr("Type")); | ||
1009 | 77 | setHeaderData(fieldIndex(LIBRARYTABLE_LOCATION), | ||
1010 | 78 | Qt::Horizontal, tr("Location")); | ||
1011 | 79 | setHeaderData(fieldIndex(LIBRARYTABLE_COMMENT), | ||
1012 | 80 | Qt::Horizontal, tr("Comment")); | ||
1013 | 81 | setHeaderData(fieldIndex(LIBRARYTABLE_DURATION), | ||
1014 | 82 | Qt::Horizontal, tr("Duration")); | ||
1015 | 83 | setHeaderData(fieldIndex(LIBRARYTABLE_TRACKNUMBER), | ||
1016 | 84 | Qt::Horizontal, tr("Track #")); | ||
1017 | 85 | setHeaderData(fieldIndex(LIBRARYTABLE_BITRATE), | ||
1018 | 86 | Qt::Horizontal, tr("Bitrate")); | ||
1019 | 87 | setHeaderData(fieldIndex(LIBRARYTABLE_BPM), | ||
1020 | 88 | Qt::Horizontal, tr("BPM")); | ||
1021 | 89 | setHeaderData(fieldIndex(LIBRARYTABLE_DATETIMEADDED), | ||
1022 | 90 | Qt::Horizontal, tr("Date Added")); | ||
1024 | 91 | 65 | ||
1025 | 92 | slotSearch(""); | 66 | slotSearch(""); |
1026 | 93 | 67 | ||
1027 | @@ -168,6 +142,7 @@ | |||
1028 | 168 | 142 | ||
1029 | 169 | bool MissingTableModel::isColumnInternal(int column) { | 143 | bool MissingTableModel::isColumnInternal(int column) { |
1030 | 170 | if (column == fieldIndex(LIBRARYTABLE_ID) || | 144 | if (column == fieldIndex(LIBRARYTABLE_ID) || |
1031 | 145 | column == fieldIndex(LIBRARYTABLE_PLAYED) || | ||
1032 | 171 | column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) || | 146 | column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) || |
1033 | 172 | column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED)) | 147 | column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED)) |
1034 | 173 | return true; | 148 | return true; |
1035 | @@ -200,42 +175,16 @@ | |||
1036 | 200 | return mimeData; | 175 | return mimeData; |
1037 | 201 | } | 176 | } |
1038 | 202 | 177 | ||
1039 | 178 | /** Override flags from BaseSqlModel since we don't want edit this model */ | ||
1040 | 203 | Qt::ItemFlags MissingTableModel::flags(const QModelIndex &index) const | 179 | Qt::ItemFlags MissingTableModel::flags(const QModelIndex &index) const |
1041 | 204 | { | 180 | { |
1050 | 205 | Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); | 181 | return readOnlyFlags(index); |
1043 | 206 | if (!index.isValid()) | ||
1044 | 207 | return Qt::ItemIsEnabled; | ||
1045 | 208 | |||
1046 | 209 | //defaultFlags |= Qt::ItemIsDragEnabled; | ||
1047 | 210 | //defaultFlags = 0; | ||
1048 | 211 | |||
1049 | 212 | return defaultFlags; | ||
1051 | 213 | } | 182 | } |
1052 | 214 | 183 | ||
1053 | 215 | QItemDelegate* MissingTableModel::delegateForColumn(const int i) { | 184 | QItemDelegate* MissingTableModel::delegateForColumn(const int i) { |
1054 | 216 | return NULL; | 185 | return NULL; |
1055 | 217 | } | 186 | } |
1056 | 218 | 187 | ||
1057 | 219 | QVariant MissingTableModel::data(const QModelIndex& item, int role) const { | ||
1058 | 220 | if (!item.isValid()) | ||
1059 | 221 | return QVariant(); | ||
1060 | 222 | |||
1061 | 223 | QVariant value; | ||
1062 | 224 | |||
1063 | 225 | if (role == Qt::ToolTipRole) | ||
1064 | 226 | value = BaseSqlTableModel::data(item, Qt::DisplayRole); | ||
1065 | 227 | else | ||
1066 | 228 | value = BaseSqlTableModel::data(item, role); | ||
1067 | 229 | |||
1068 | 230 | if ((role == Qt::DisplayRole || role == Qt::ToolTipRole) && | ||
1069 | 231 | item.column() == fieldIndex(LIBRARYTABLE_DURATION)) { | ||
1070 | 232 | if (qVariantCanConvert<int>(value)) { | ||
1071 | 233 | value = MixxxUtils::secondsToMinutes(qVariantValue<int>(value)); | ||
1072 | 234 | } | ||
1073 | 235 | } | ||
1074 | 236 | return value; | ||
1075 | 237 | } | ||
1076 | 238 | |||
1077 | 239 | TrackModel::CapabilitiesFlags MissingTableModel::getCapabilities() const | 188 | TrackModel::CapabilitiesFlags MissingTableModel::getCapabilities() const |
1078 | 240 | { | 189 | { |
1079 | 241 | return 0; | 190 | return 0; |
1080 | 242 | 191 | ||
1081 | === modified file 'mixxx/src/library/missingtablemodel.h' | |||
1082 | --- mixxx/src/library/missingtablemodel.h 2010-09-13 06:23:38 +0000 | |||
1083 | +++ mixxx/src/library/missingtablemodel.h 2010-10-19 05:33:52 +0000 | |||
1084 | @@ -26,7 +26,7 @@ | |||
1085 | 26 | virtual void removeTracks(const QModelIndexList& indices); | 26 | virtual void removeTracks(const QModelIndexList& indices); |
1086 | 27 | virtual bool addTrack(const QModelIndex& index, QString location); | 27 | virtual bool addTrack(const QModelIndex& index, QString location); |
1087 | 28 | virtual void moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex); | 28 | virtual void moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex); |
1089 | 29 | virtual QVariant data(const QModelIndex& item, int role) const; | 29 | |
1090 | 30 | QMimeData* mimeData(const QModelIndexList &indexes) const; | 30 | QMimeData* mimeData(const QModelIndexList &indexes) const; |
1091 | 31 | Qt::ItemFlags flags(const QModelIndex &index) const; | 31 | Qt::ItemFlags flags(const QModelIndex &index) const; |
1092 | 32 | QItemDelegate* delegateForColumn(const int i); | 32 | QItemDelegate* delegateForColumn(const int i); |
1093 | 33 | 33 | ||
1094 | === modified file 'mixxx/src/library/playlisttablemodel.cpp' | |||
1095 | --- mixxx/src/library/playlisttablemodel.cpp 2010-09-14 20:32:32 +0000 | |||
1096 | +++ mixxx/src/library/playlisttablemodel.cpp 2010-10-19 05:33:52 +0000 | |||
1097 | @@ -44,11 +44,14 @@ | |||
1098 | 44 | "PlaylistTracks." + PLAYLISTTRACKSTABLE_POSITION + "," + | 44 | "PlaylistTracks." + PLAYLISTTRACKSTABLE_POSITION + "," + |
1099 | 45 | //"playlist_id, " + //DEBUG | 45 | //"playlist_id, " + //DEBUG |
1100 | 46 | "library." + LIBRARYTABLE_ID + "," + | 46 | "library." + LIBRARYTABLE_ID + "," + |
1101 | 47 | "library." + LIBRARYTABLE_PLAYED + "," + | ||
1102 | 48 | "library." + LIBRARYTABLE_TIMESPLAYED + "," + | ||
1103 | 47 | "library." + LIBRARYTABLE_ARTIST + "," + | 49 | "library." + LIBRARYTABLE_ARTIST + "," + |
1104 | 48 | "library." + LIBRARYTABLE_TITLE + "," + | 50 | "library." + LIBRARYTABLE_TITLE + "," + |
1105 | 49 | "library." + LIBRARYTABLE_ALBUM + "," + | 51 | "library." + LIBRARYTABLE_ALBUM + "," + |
1106 | 50 | "library." + LIBRARYTABLE_YEAR + "," + | 52 | "library." + LIBRARYTABLE_YEAR + "," + |
1107 | 51 | "library." + LIBRARYTABLE_DURATION + "," + | 53 | "library." + LIBRARYTABLE_DURATION + "," + |
1108 | 54 | "library." + LIBRARYTABLE_RATING + "," + | ||
1109 | 52 | "library." + LIBRARYTABLE_GENRE + "," + | 55 | "library." + LIBRARYTABLE_GENRE + "," + |
1110 | 53 | "library." + LIBRARYTABLE_FILETYPE + "," + | 56 | "library." + LIBRARYTABLE_FILETYPE + "," + |
1111 | 54 | "library." + LIBRARYTABLE_TRACKNUMBER + "," + | 57 | "library." + LIBRARYTABLE_TRACKNUMBER + "," + |
1112 | @@ -79,36 +82,7 @@ | |||
1113 | 79 | 82 | ||
1114 | 80 | setTable(playlistTableName); | 83 | setTable(playlistTableName); |
1115 | 81 | 84 | ||
1146 | 82 | //Set the column heading labels, rename them for translations and have | 85 | initHeaderData(); //derived from BaseSqlModel |
1117 | 83 | //proper capitalization | ||
1118 | 84 | setHeaderData(fieldIndex(PLAYLISTTRACKSTABLE_POSITION), | ||
1119 | 85 | Qt::Horizontal, tr("#")); | ||
1120 | 86 | setHeaderData(fieldIndex(LIBRARYTABLE_ARTIST), | ||
1121 | 87 | Qt::Horizontal, tr("Artist")); | ||
1122 | 88 | setHeaderData(fieldIndex(LIBRARYTABLE_TITLE), | ||
1123 | 89 | Qt::Horizontal, tr("Title")); | ||
1124 | 90 | setHeaderData(fieldIndex(LIBRARYTABLE_ALBUM), | ||
1125 | 91 | Qt::Horizontal, tr("Album")); | ||
1126 | 92 | setHeaderData(fieldIndex(LIBRARYTABLE_GENRE), | ||
1127 | 93 | Qt::Horizontal, tr("Genre")); | ||
1128 | 94 | setHeaderData(fieldIndex(LIBRARYTABLE_YEAR), | ||
1129 | 95 | Qt::Horizontal, tr("Year")); | ||
1130 | 96 | setHeaderData(fieldIndex(LIBRARYTABLE_FILETYPE), | ||
1131 | 97 | Qt::Horizontal, tr("Type")); | ||
1132 | 98 | setHeaderData(fieldIndex("location"), | ||
1133 | 99 | Qt::Horizontal, tr("Location")); | ||
1134 | 100 | setHeaderData(fieldIndex(LIBRARYTABLE_COMMENT), | ||
1135 | 101 | Qt::Horizontal, tr("Comment")); | ||
1136 | 102 | setHeaderData(fieldIndex(LIBRARYTABLE_DURATION), | ||
1137 | 103 | Qt::Horizontal, tr("Duration")); | ||
1138 | 104 | setHeaderData(fieldIndex(LIBRARYTABLE_TRACKNUMBER), | ||
1139 | 105 | Qt::Horizontal, tr("Track #")); | ||
1140 | 106 | setHeaderData(fieldIndex(LIBRARYTABLE_BITRATE), | ||
1141 | 107 | Qt::Horizontal, tr("Bitrate")); | ||
1142 | 108 | setHeaderData(fieldIndex(LIBRARYTABLE_DATETIMEADDED), | ||
1143 | 109 | Qt::Horizontal, tr("Date Added")); | ||
1144 | 110 | setHeaderData(fieldIndex(LIBRARYTABLE_BPM), | ||
1145 | 111 | Qt::Horizontal, tr("BPM")); | ||
1147 | 112 | 86 | ||
1148 | 113 | slotSearch(""); | 87 | slotSearch(""); |
1149 | 114 | 88 | ||
1150 | @@ -323,6 +297,7 @@ | |||
1151 | 323 | 297 | ||
1152 | 324 | bool PlaylistTableModel::isColumnInternal(int column) { | 298 | bool PlaylistTableModel::isColumnInternal(int column) { |
1153 | 325 | if (column == fieldIndex(LIBRARYTABLE_ID) || | 299 | if (column == fieldIndex(LIBRARYTABLE_ID) || |
1154 | 300 | column == fieldIndex(LIBRARYTABLE_PLAYED) || | ||
1155 | 326 | column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) || | 301 | column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) || |
1156 | 327 | column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED)) | 302 | column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED)) |
1157 | 328 | return true; | 303 | return true; |
1158 | @@ -354,43 +329,11 @@ | |||
1159 | 354 | return mimeData; | 329 | return mimeData; |
1160 | 355 | } | 330 | } |
1161 | 356 | 331 | ||
1162 | 357 | Qt::ItemFlags PlaylistTableModel::flags(const QModelIndex &index) const | ||
1163 | 358 | { | ||
1164 | 359 | Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); | ||
1165 | 360 | if (!index.isValid()) | ||
1166 | 361 | return Qt::ItemIsEnabled; | ||
1167 | 362 | |||
1168 | 363 | //Enable dragging songs from this data model to elsewhere (like the waveform widget to | ||
1169 | 364 | //load a track into a Player). | ||
1170 | 365 | defaultFlags |= Qt::ItemIsDragEnabled; | ||
1171 | 366 | |||
1172 | 367 | return defaultFlags; | ||
1173 | 368 | } | ||
1174 | 369 | 332 | ||
1175 | 370 | QItemDelegate* PlaylistTableModel::delegateForColumn(const int i) { | 333 | QItemDelegate* PlaylistTableModel::delegateForColumn(const int i) { |
1176 | 371 | return NULL; | 334 | return NULL; |
1177 | 372 | } | 335 | } |
1178 | 373 | 336 | ||
1179 | 374 | QVariant PlaylistTableModel::data(const QModelIndex& item, int role) const { | ||
1180 | 375 | if (!item.isValid()) | ||
1181 | 376 | return QVariant(); | ||
1182 | 377 | |||
1183 | 378 | QVariant value; | ||
1184 | 379 | |||
1185 | 380 | if (role == Qt::ToolTipRole) | ||
1186 | 381 | value = BaseSqlTableModel::data(item, Qt::DisplayRole); | ||
1187 | 382 | else | ||
1188 | 383 | value = BaseSqlTableModel::data(item, role); | ||
1189 | 384 | |||
1190 | 385 | if ((role == Qt::DisplayRole || role == Qt::ToolTipRole) && | ||
1191 | 386 | item.column() == fieldIndex(LIBRARYTABLE_DURATION)) { | ||
1192 | 387 | if (qVariantCanConvert<int>(value)) { | ||
1193 | 388 | value = MixxxUtils::secondsToMinutes(qVariantValue<int>(value)); | ||
1194 | 389 | } | ||
1195 | 390 | } | ||
1196 | 391 | return value; | ||
1197 | 392 | } | ||
1198 | 393 | |||
1199 | 394 | TrackModel::CapabilitiesFlags PlaylistTableModel::getCapabilities() const | 337 | TrackModel::CapabilitiesFlags PlaylistTableModel::getCapabilities() const |
1200 | 395 | { | 338 | { |
1201 | 396 | TrackModel::CapabilitiesFlags caps = TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_REORDER | TRACKMODELCAPS_ADDTOCRATE | TRACKMODELCAPS_ADDTOPLAYLIST; | 339 | TrackModel::CapabilitiesFlags caps = TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_REORDER | TRACKMODELCAPS_ADDTOCRATE | TRACKMODELCAPS_ADDTOPLAYLIST; |
1202 | 397 | 340 | ||
1203 | === added file 'mixxx/src/library/playlisttablemodel.h' | |||
1204 | --- mixxx/src/library/playlisttablemodel.h 1970-01-01 00:00:00 +0000 | |||
1205 | +++ mixxx/src/library/playlisttablemodel.h 2010-10-19 05:33:52 +0000 | |||
1206 | @@ -0,0 +1,51 @@ | |||
1207 | 1 | #ifndef PLAYLISTTABLEMODEL_H | ||
1208 | 2 | #define PLAYLISTTABLEMODEL_H | ||
1209 | 3 | |||
1210 | 4 | #include <QtSql> | ||
1211 | 5 | #include <QItemDelegate> | ||
1212 | 6 | #include <QtCore> | ||
1213 | 7 | #include "trackmodel.h" | ||
1214 | 8 | #include "library/basesqltablemodel.h" | ||
1215 | 9 | #include "library/librarytablemodel.h" | ||
1216 | 10 | #include "library/dao/playlistdao.h" | ||
1217 | 11 | #include "library/dao/trackdao.h" | ||
1218 | 12 | |||
1219 | 13 | class TrackCollection; | ||
1220 | 14 | |||
1221 | 15 | class PlaylistTableModel : public BaseSqlTableModel, public virtual TrackModel | ||
1222 | 16 | { | ||
1223 | 17 | Q_OBJECT | ||
1224 | 18 | public: | ||
1225 | 19 | PlaylistTableModel(QObject* parent, TrackCollection* pTrackCollection); | ||
1226 | 20 | virtual ~PlaylistTableModel(); | ||
1227 | 21 | void setPlaylist(int playlistId); | ||
1228 | 22 | virtual TrackPointer getTrack(const QModelIndex& index) const; | ||
1229 | 23 | virtual QString getTrackLocation(const QModelIndex& index) const; | ||
1230 | 24 | virtual void search(const QString& searchText); | ||
1231 | 25 | virtual const QString currentSearch(); | ||
1232 | 26 | virtual bool isColumnInternal(int column); | ||
1233 | 27 | virtual void removeTrack(const QModelIndex& index); | ||
1234 | 28 | virtual void removeTracks(const QModelIndexList& indices); | ||
1235 | 29 | virtual bool addTrack(const QModelIndex& index, QString location); | ||
1236 | 30 | virtual void moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex); | ||
1237 | 31 | |||
1238 | 32 | QMimeData* mimeData(const QModelIndexList &indexes) const; | ||
1239 | 33 | |||
1240 | 34 | QItemDelegate* delegateForColumn(const int i); | ||
1241 | 35 | TrackModel::CapabilitiesFlags getCapabilities() const; | ||
1242 | 36 | |||
1243 | 37 | private slots: | ||
1244 | 38 | void slotSearch(const QString& searchText); | ||
1245 | 39 | |||
1246 | 40 | signals: | ||
1247 | 41 | void doSearch(const QString& searchText); | ||
1248 | 42 | |||
1249 | 43 | private: | ||
1250 | 44 | TrackCollection* m_pTrackCollection; | ||
1251 | 45 | PlaylistDAO& m_playlistDao; | ||
1252 | 46 | TrackDAO& m_trackDao; | ||
1253 | 47 | int m_iPlaylistId; | ||
1254 | 48 | QString m_currentSearch; | ||
1255 | 49 | }; | ||
1256 | 50 | |||
1257 | 51 | #endif | ||
1258 | 0 | 52 | ||
1259 | === removed file 'mixxx/src/library/playlisttablemodel.h' | |||
1260 | --- mixxx/src/library/playlisttablemodel.h 2010-09-13 06:23:38 +0000 | |||
1261 | +++ mixxx/src/library/playlisttablemodel.h 1970-01-01 00:00:00 +0000 | |||
1262 | @@ -1,51 +0,0 @@ | |||
1263 | 1 | #ifndef PLAYLISTTABLEMODEL_H | ||
1264 | 2 | #define PLAYLISTTABLEMODEL_H | ||
1265 | 3 | |||
1266 | 4 | #include <QtSql> | ||
1267 | 5 | #include <QItemDelegate> | ||
1268 | 6 | #include <QtCore> | ||
1269 | 7 | #include "trackmodel.h" | ||
1270 | 8 | #include "library/basesqltablemodel.h" | ||
1271 | 9 | #include "library/librarytablemodel.h" | ||
1272 | 10 | #include "library/dao/playlistdao.h" | ||
1273 | 11 | #include "library/dao/trackdao.h" | ||
1274 | 12 | |||
1275 | 13 | class TrackCollection; | ||
1276 | 14 | |||
1277 | 15 | class PlaylistTableModel : public BaseSqlTableModel, public virtual TrackModel | ||
1278 | 16 | { | ||
1279 | 17 | Q_OBJECT | ||
1280 | 18 | public: | ||
1281 | 19 | PlaylistTableModel(QObject* parent, TrackCollection* pTrackCollection); | ||
1282 | 20 | virtual ~PlaylistTableModel(); | ||
1283 | 21 | void setPlaylist(int playlistId); | ||
1284 | 22 | virtual TrackPointer getTrack(const QModelIndex& index) const; | ||
1285 | 23 | virtual QString getTrackLocation(const QModelIndex& index) const; | ||
1286 | 24 | virtual void search(const QString& searchText); | ||
1287 | 25 | virtual const QString currentSearch(); | ||
1288 | 26 | virtual bool isColumnInternal(int column); | ||
1289 | 27 | virtual void removeTrack(const QModelIndex& index); | ||
1290 | 28 | virtual void removeTracks(const QModelIndexList& indices); | ||
1291 | 29 | virtual bool addTrack(const QModelIndex& index, QString location); | ||
1292 | 30 | virtual void moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex); | ||
1293 | 31 | virtual QVariant data(const QModelIndex& item, int role) const; | ||
1294 | 32 | QMimeData* mimeData(const QModelIndexList &indexes) const; | ||
1295 | 33 | Qt::ItemFlags flags(const QModelIndex &index) const; | ||
1296 | 34 | QItemDelegate* delegateForColumn(const int i); | ||
1297 | 35 | TrackModel::CapabilitiesFlags getCapabilities() const; | ||
1298 | 36 | |||
1299 | 37 | private slots: | ||
1300 | 38 | void slotSearch(const QString& searchText); | ||
1301 | 39 | |||
1302 | 40 | signals: | ||
1303 | 41 | void doSearch(const QString& searchText); | ||
1304 | 42 | |||
1305 | 43 | private: | ||
1306 | 44 | TrackCollection* m_pTrackCollection; | ||
1307 | 45 | PlaylistDAO& m_playlistDao; | ||
1308 | 46 | TrackDAO& m_trackDao; | ||
1309 | 47 | int m_iPlaylistId; | ||
1310 | 48 | QString m_currentSearch; | ||
1311 | 49 | }; | ||
1312 | 50 | |||
1313 | 51 | #endif | ||
1314 | 52 | 0 | ||
1315 | === modified file 'mixxx/src/library/rhythmboxtrackmodel.cpp' | |||
1316 | --- mixxx/src/library/rhythmboxtrackmodel.cpp 2010-10-15 21:17:06 +0000 | |||
1317 | +++ mixxx/src/library/rhythmboxtrackmodel.cpp 2010-10-19 05:33:52 +0000 | |||
1318 | @@ -160,6 +160,9 @@ | |||
1319 | 160 | pTrack->setGenre(songNode.firstChildElement("genre").text()); | 160 | pTrack->setGenre(songNode.firstChildElement("genre").text()); |
1320 | 161 | pTrack->setDuration(songNode.firstChildElement("duration").text().toUInt()); | 161 | pTrack->setDuration(songNode.firstChildElement("duration").text().toUInt()); |
1321 | 162 | 162 | ||
1322 | 163 | // TODO(ywwg) why was this added? constructor above does the same -- rryan | ||
1323 | 164 | pTrack->setLocation(trackLocation); | ||
1324 | 165 | |||
1325 | 163 | // Have QObject handle deleting this track | 166 | // Have QObject handle deleting this track |
1326 | 164 | return TrackPointer(pTrack, &QObject::deleteLater); | 167 | return TrackPointer(pTrack, &QObject::deleteLater); |
1327 | 165 | } | 168 | } |
1328 | 166 | 169 | ||
1329 | === added file 'mixxx/src/library/stardelegate.cpp' | |||
1330 | --- mixxx/src/library/stardelegate.cpp 1970-01-01 00:00:00 +0000 | |||
1331 | +++ mixxx/src/library/stardelegate.cpp 2010-10-19 05:33:52 +0000 | |||
1332 | @@ -0,0 +1,114 @@ | |||
1333 | 1 | /*************************************************************************** | ||
1334 | 2 | stardelegate.cpp | ||
1335 | 3 | ------------------- | ||
1336 | 4 | copyright : (C) 2010 Tobias Rafreider | ||
1337 | 5 | copyright : (C) 2009 Nokia Corporation | ||
1338 | 6 | |||
1339 | 7 | ***************************************************************************/ | ||
1340 | 8 | |||
1341 | 9 | /*************************************************************************** | ||
1342 | 10 | * * | ||
1343 | 11 | * This program is free software; you can redistribute it and/or modify * | ||
1344 | 12 | * it under the terms of the GNU General Public License as published by * | ||
1345 | 13 | * the Free Software Foundation; either version 2 of the License, or * | ||
1346 | 14 | * (at your option) any later version. * | ||
1347 | 15 | * * | ||
1348 | 16 | ***************************************************************************/ | ||
1349 | 17 | |||
1350 | 18 | |||
1351 | 19 | #include <QtDebug> | ||
1352 | 20 | #include <QtGui> | ||
1353 | 21 | |||
1354 | 22 | #include "stardelegate.h" | ||
1355 | 23 | #include "stareditor.h" | ||
1356 | 24 | #include "starrating.h" | ||
1357 | 25 | |||
1358 | 26 | /* | ||
1359 | 27 | * The function is invoked once for each item, represented by a QModelIndex object from the model. | ||
1360 | 28 | * If the data stored in the item is a StarRating, we paint it use a star editor for displaying; | ||
1361 | 29 | * otherwise, we let QItemDelegate paint it for us. | ||
1362 | 30 | * This ensures that the StarDelegate can handle the most common data types. | ||
1363 | 31 | */ | ||
1364 | 32 | void StarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const | ||
1365 | 33 | { | ||
1366 | 34 | // Populate the correct colors based on the styling | ||
1367 | 35 | QStyleOptionViewItem newOption = option; | ||
1368 | 36 | initStyleOption(&newOption, index); | ||
1369 | 37 | |||
1370 | 38 | // Set the palette appropriately based on whether the row is selected or not | ||
1371 | 39 | if (newOption.state & QStyle::State_Selected) { | ||
1372 | 40 | painter->fillRect(newOption.rect, newOption.palette.highlight()); | ||
1373 | 41 | painter->setBrush(newOption.palette.highlightedText()); | ||
1374 | 42 | } else { | ||
1375 | 43 | painter->fillRect(newOption.rect, newOption.palette.base()); | ||
1376 | 44 | painter->setBrush(newOption.palette.text()); | ||
1377 | 45 | } | ||
1378 | 46 | |||
1379 | 47 | if (qVariantCanConvert<StarRating>(index.data())) { | ||
1380 | 48 | StarRating starRating = qVariantValue<StarRating>(index.data()); | ||
1381 | 49 | starRating.paint(painter, newOption.rect, newOption.palette, StarRating::ReadOnly); | ||
1382 | 50 | } else { | ||
1383 | 51 | QStyledItemDelegate::paint(painter, newOption, index); | ||
1384 | 52 | } | ||
1385 | 53 | } | ||
1386 | 54 | |||
1387 | 55 | QSize StarDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const | ||
1388 | 56 | { | ||
1389 | 57 | if (qVariantCanConvert<StarRating>(index.data())) { | ||
1390 | 58 | StarRating starRating = qVariantValue<StarRating>(index.data()); | ||
1391 | 59 | return starRating.sizeHint(); | ||
1392 | 60 | } else { | ||
1393 | 61 | return QStyledItemDelegate::sizeHint(option, index); | ||
1394 | 62 | } | ||
1395 | 63 | } | ||
1396 | 64 | /* | ||
1397 | 65 | * If the item is a StarRating, we create a StarEditor and connect | ||
1398 | 66 | * its editingFinished() signal to our commitAndCloseEditor() slot, | ||
1399 | 67 | * so we can update the model when the editor closes. | ||
1400 | 68 | */ | ||
1401 | 69 | QWidget *StarDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const | ||
1402 | 70 | { | ||
1403 | 71 | // Populate the correct colors based on the styling | ||
1404 | 72 | QStyleOptionViewItem newOption = option; | ||
1405 | 73 | initStyleOption(&newOption, index); | ||
1406 | 74 | |||
1407 | 75 | if (qVariantCanConvert<StarRating>(index.data())) { | ||
1408 | 76 | StarEditor *editor = new StarEditor(parent, newOption); | ||
1409 | 77 | connect(editor, SIGNAL(editingFinished()), | ||
1410 | 78 | this, SLOT(commitAndCloseEditor())); | ||
1411 | 79 | return editor; | ||
1412 | 80 | } else { | ||
1413 | 81 | return QStyledItemDelegate::createEditor(parent, newOption, index); | ||
1414 | 82 | } | ||
1415 | 83 | } | ||
1416 | 84 | |||
1417 | 85 | void StarDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const | ||
1418 | 86 | { | ||
1419 | 87 | if (qVariantCanConvert<StarRating>(index.data())) { | ||
1420 | 88 | StarRating starRating = qVariantValue<StarRating>(index.data()); | ||
1421 | 89 | StarEditor *starEditor = qobject_cast<StarEditor *>(editor); | ||
1422 | 90 | starEditor->setStarRating(starRating); | ||
1423 | 91 | } else { | ||
1424 | 92 | QStyledItemDelegate::setEditorData(editor, index); | ||
1425 | 93 | } | ||
1426 | 94 | } | ||
1427 | 95 | |||
1428 | 96 | void StarDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const | ||
1429 | 97 | { | ||
1430 | 98 | if (qVariantCanConvert<StarRating>(index.data())) { | ||
1431 | 99 | StarEditor *starEditor = qobject_cast<StarEditor *>(editor); | ||
1432 | 100 | model->setData(index, qVariantFromValue(starEditor->starRating())); | ||
1433 | 101 | } else { | ||
1434 | 102 | QStyledItemDelegate::setModelData(editor, model, index); | ||
1435 | 103 | } | ||
1436 | 104 | } | ||
1437 | 105 | /* | ||
1438 | 106 | * When the user is done editing, we emit commitData() and closeEditor() (both declared in QAbstractItemDelegate), | ||
1439 | 107 | * to tell the model that there is edited data and to inform the view that the editor is no longer needed. | ||
1440 | 108 | */ | ||
1441 | 109 | void StarDelegate::commitAndCloseEditor() | ||
1442 | 110 | { | ||
1443 | 111 | StarEditor *editor = qobject_cast<StarEditor *>(sender()); | ||
1444 | 112 | emit commitData(editor); | ||
1445 | 113 | emit closeEditor(editor); | ||
1446 | 114 | } | ||
1447 | 0 | 115 | ||
1448 | === added file 'mixxx/src/library/stardelegate.h' | |||
1449 | --- mixxx/src/library/stardelegate.h 1970-01-01 00:00:00 +0000 | |||
1450 | +++ mixxx/src/library/stardelegate.h 2010-10-19 05:33:52 +0000 | |||
1451 | @@ -0,0 +1,56 @@ | |||
1452 | 1 | /*************************************************************************** | ||
1453 | 2 | stardelegate.h | ||
1454 | 3 | ------------------- | ||
1455 | 4 | copyright : (C) 2010 Tobias Rafreider | ||
1456 | 5 | copyright : (C) 2009 Nokia Corporation | ||
1457 | 6 | |||
1458 | 7 | ***************************************************************************/ | ||
1459 | 8 | |||
1460 | 9 | /*************************************************************************** | ||
1461 | 10 | * * | ||
1462 | 11 | * This program is free software; you can redistribute it and/or modify * | ||
1463 | 12 | * it under the terms of the GNU General Public License as published by * | ||
1464 | 13 | * the Free Software Foundation; either version 2 of the License, or * | ||
1465 | 14 | * (at your option) any later version. * | ||
1466 | 15 | * * | ||
1467 | 16 | ***************************************************************************/ | ||
1468 | 17 | |||
1469 | 18 | |||
1470 | 19 | #ifndef STARDELEGATE_H | ||
1471 | 20 | #define STARDELEGATE_H | ||
1472 | 21 | |||
1473 | 22 | #include <QStyledItemDelegate> | ||
1474 | 23 | |||
1475 | 24 | /* | ||
1476 | 25 | * When displaying data in a QListView, QTableView, or QTreeView, | ||
1477 | 26 | * the individual items are drawn by a delegate. | ||
1478 | 27 | * Also, when the user starts editing an item (e.g., by double-clicking the item), | ||
1479 | 28 | * the delegate provides an editor widget that is placed on top of the item while editing takes place. | ||
1480 | 29 | * | ||
1481 | 30 | * By default a QListView, QTableView, or QTreeView has a QItemDelegate attached, | ||
1482 | 31 | * which inherits QAbstractItemDelegate and handles the most common data types (notably int and QString). | ||
1483 | 32 | * If we need to support custom data types, or want to customize the rendering or the editing for | ||
1484 | 33 | * existing data types, we can subclass QAbstractItemDelegate or QItemDelegate or QStyledItemDelegate | ||
1485 | 34 | */ | ||
1486 | 35 | class StarDelegate : public QStyledItemDelegate | ||
1487 | 36 | { | ||
1488 | 37 | Q_OBJECT | ||
1489 | 38 | |||
1490 | 39 | public: | ||
1491 | 40 | StarDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {} | ||
1492 | 41 | /** reimplemented from QItemDelegate and is called whenever the view needs to repaint an item **/ | ||
1493 | 42 | void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; | ||
1494 | 43 | /** eturns an item's preferred size **/ | ||
1495 | 44 | QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; | ||
1496 | 45 | /** called when the user starts editing an item: **/ | ||
1497 | 46 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const; | ||
1498 | 47 | /** called when an editor is created to initialize it with data from the model: **/ | ||
1499 | 48 | void setEditorData(QWidget *editor, const QModelIndex &index) const; | ||
1500 | 49 | /** called when editing is finished, to commit data from the editor to the model: **/ | ||
1501 | 50 | void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; | ||
1502 | 51 | |||
1503 | 52 | private slots: | ||
1504 | 53 | void commitAndCloseEditor(); | ||
1505 | 54 | }; | ||
1506 | 55 | |||
1507 | 56 | #endif | ||
1508 | 0 | 57 | ||
1509 | === added file 'mixxx/src/library/stareditor.cpp' | |||
1510 | --- mixxx/src/library/stareditor.cpp 1970-01-01 00:00:00 +0000 | |||
1511 | +++ mixxx/src/library/stareditor.cpp 2010-10-19 05:33:52 +0000 | |||
1512 | @@ -0,0 +1,95 @@ | |||
1513 | 1 | /*************************************************************************** | ||
1514 | 2 | stareditor.cpp | ||
1515 | 3 | ------------------- | ||
1516 | 4 | copyright : (C) 2010 Tobias Rafreider | ||
1517 | 5 | copyright : (C) 2009 Nokia Corporation | ||
1518 | 6 | |||
1519 | 7 | ***************************************************************************/ | ||
1520 | 8 | |||
1521 | 9 | /*************************************************************************** | ||
1522 | 10 | * * | ||
1523 | 11 | * This program is free software; you can redistribute it and/or modify * | ||
1524 | 12 | * it under the terms of the GNU General Public License as published by * | ||
1525 | 13 | * the Free Software Foundation; either version 2 of the License, or * | ||
1526 | 14 | * (at your option) any later version. * | ||
1527 | 15 | * * | ||
1528 | 16 | ***************************************************************************/ | ||
1529 | 17 | |||
1530 | 18 | /*************************************************************************** | ||
1531 | 19 | * * | ||
1532 | 20 | * StarEditor inherits QWidget and is used by StarDelegate to let the user * | ||
1533 | 21 | * edit a star rating in the library using the mouse. * | ||
1534 | 22 | * * | ||
1535 | 23 | * The class has been adapted from the official "Star Delegate Example", * | ||
1536 | 24 | * see http://doc.trolltech.com/4.5/itemviews-stardelegate.html * | ||
1537 | 25 | ***************************************************************************/ | ||
1538 | 26 | |||
1539 | 27 | #include <QtGui> | ||
1540 | 28 | |||
1541 | 29 | #include "stareditor.h" | ||
1542 | 30 | #include "starrating.h" | ||
1543 | 31 | |||
1544 | 32 | /* | ||
1545 | 33 | * We enable mouse tracking on the widget so we can follow the cursor even | ||
1546 | 34 | * when the user doesn't hold down any mouse button. We also turn on | ||
1547 | 35 | * QWidget's auto-fill background feature to obtain an opaque background. | ||
1548 | 36 | * (Without the call, the view's background would shine through the editor.) | ||
1549 | 37 | */ | ||
1550 | 38 | StarEditor::StarEditor(QWidget *parent, const QStyleOptionViewItem &option) | ||
1551 | 39 | : QWidget(parent) | ||
1552 | 40 | { | ||
1553 | 41 | setPalette(option.palette); | ||
1554 | 42 | setMouseTracking(true); | ||
1555 | 43 | setAutoFillBackground(true); | ||
1556 | 44 | } | ||
1557 | 45 | |||
1558 | 46 | QSize StarEditor::sizeHint() const | ||
1559 | 47 | { | ||
1560 | 48 | return m_starRating.sizeHint(); | ||
1561 | 49 | } | ||
1562 | 50 | /* | ||
1563 | 51 | * We simply call StarRating::paint() to draw the stars, | ||
1564 | 52 | * just like we did when implementing StarDelegate | ||
1565 | 53 | */ | ||
1566 | 54 | void StarEditor::paintEvent(QPaintEvent *) | ||
1567 | 55 | { | ||
1568 | 56 | QPainter painter(this); | ||
1569 | 57 | m_starRating.paint(&painter, rect(), palette(), StarRating::Editable); | ||
1570 | 58 | } | ||
1571 | 59 | /* | ||
1572 | 60 | * In the mouse event handler, we call setStarCount() on | ||
1573 | 61 | * the private data member m_starRating to reflect the current cursor position, | ||
1574 | 62 | * and we call QWidget::update() to force a repaint. | ||
1575 | 63 | */ | ||
1576 | 64 | void StarEditor::mouseMoveEvent(QMouseEvent *event) | ||
1577 | 65 | { | ||
1578 | 66 | int star = starAtPosition(event->x()); | ||
1579 | 67 | |||
1580 | 68 | if (star != m_starRating.starCount() && star != -1) { | ||
1581 | 69 | m_starRating.setStarCount(star); | ||
1582 | 70 | update(); | ||
1583 | 71 | } | ||
1584 | 72 | } | ||
1585 | 73 | /* | ||
1586 | 74 | * When the user releases a mouse button, we simply emit the editingFinished() signal. | ||
1587 | 75 | */ | ||
1588 | 76 | void StarEditor::mouseReleaseEvent(QMouseEvent * /* event */) | ||
1589 | 77 | { | ||
1590 | 78 | emit editingFinished(); | ||
1591 | 79 | } | ||
1592 | 80 | /* | ||
1593 | 81 | * The method uses basic linear algebra to find out which star is under the cursor. | ||
1594 | 82 | */ | ||
1595 | 83 | int StarEditor::starAtPosition(int x) | ||
1596 | 84 | { | ||
1597 | 85 | // If the mouse is very close to the left edge, set 0 stars. | ||
1598 | 86 | if (x < m_starRating.sizeHint().width() * 0.05) { | ||
1599 | 87 | return 0; | ||
1600 | 88 | } | ||
1601 | 89 | int star = (x / (m_starRating.sizeHint().width() / m_starRating.maxStarCount())) + 1; | ||
1602 | 90 | |||
1603 | 91 | if (star <= 0 || star > m_starRating.maxStarCount()) | ||
1604 | 92 | return 0; | ||
1605 | 93 | |||
1606 | 94 | return star; | ||
1607 | 95 | } | ||
1608 | 0 | 96 | ||
1609 | === added file 'mixxx/src/library/stareditor.h' | |||
1610 | --- mixxx/src/library/stareditor.h 1970-01-01 00:00:00 +0000 | |||
1611 | +++ mixxx/src/library/stareditor.h 2010-10-19 05:33:52 +0000 | |||
1612 | @@ -0,0 +1,61 @@ | |||
1613 | 1 | /*************************************************************************** | ||
1614 | 2 | stareditor.h | ||
1615 | 3 | ------------------- | ||
1616 | 4 | copyright : (C) 2010 Tobias Rafreider | ||
1617 | 5 | copyright : (C) 2009 Nokia Corporation | ||
1618 | 6 | |||
1619 | 7 | ***************************************************************************/ | ||
1620 | 8 | |||
1621 | 9 | /*************************************************************************** | ||
1622 | 10 | * * | ||
1623 | 11 | * This program is free software; you can redistribute it and/or modify * | ||
1624 | 12 | * it under the terms of the GNU General Public License as published by * | ||
1625 | 13 | * the Free Software Foundation; either version 2 of the License, or * | ||
1626 | 14 | * (at your option) any later version. * | ||
1627 | 15 | * * | ||
1628 | 16 | ***************************************************************************/ | ||
1629 | 17 | |||
1630 | 18 | /*************************************************************************** | ||
1631 | 19 | * * | ||
1632 | 20 | * StarEditor inherits QWidget and is used by StarDelegate to let the user * | ||
1633 | 21 | * edit a star rating in the library using the mouse. * | ||
1634 | 22 | * * | ||
1635 | 23 | * The class has been adapted from the official "Star Delegate Example", * | ||
1636 | 24 | * see http://doc.trolltech.com/4.5/itemviews-stardelegate.html * | ||
1637 | 25 | ***************************************************************************/ | ||
1638 | 26 | |||
1639 | 27 | #ifndef STAREDITOR_H | ||
1640 | 28 | #define STAREDITOR_H | ||
1641 | 29 | |||
1642 | 30 | #include <QWidget> | ||
1643 | 31 | |||
1644 | 32 | #include "starrating.h" | ||
1645 | 33 | |||
1646 | 34 | class StarEditor : public QWidget | ||
1647 | 35 | { | ||
1648 | 36 | Q_OBJECT | ||
1649 | 37 | |||
1650 | 38 | public: | ||
1651 | 39 | StarEditor(QWidget *parent, const QStyleOptionViewItem& option); | ||
1652 | 40 | |||
1653 | 41 | QSize sizeHint() const; | ||
1654 | 42 | void setStarRating(const StarRating &starRating) { | ||
1655 | 43 | m_starRating = starRating; | ||
1656 | 44 | } | ||
1657 | 45 | StarRating starRating() { return m_starRating; } | ||
1658 | 46 | |||
1659 | 47 | signals: | ||
1660 | 48 | void editingFinished(); | ||
1661 | 49 | |||
1662 | 50 | protected: | ||
1663 | 51 | void paintEvent(QPaintEvent *event); | ||
1664 | 52 | void mouseMoveEvent(QMouseEvent *event); | ||
1665 | 53 | void mouseReleaseEvent(QMouseEvent *event); | ||
1666 | 54 | |||
1667 | 55 | private: | ||
1668 | 56 | int starAtPosition(int x); | ||
1669 | 57 | |||
1670 | 58 | StarRating m_starRating; | ||
1671 | 59 | }; | ||
1672 | 60 | |||
1673 | 61 | #endif | ||
1674 | 0 | 62 | ||
1675 | === added file 'mixxx/src/library/starrating.cpp' | |||
1676 | --- mixxx/src/library/starrating.cpp 1970-01-01 00:00:00 +0000 | |||
1677 | +++ mixxx/src/library/starrating.cpp 2010-10-19 05:33:52 +0000 | |||
1678 | @@ -0,0 +1,74 @@ | |||
1679 | 1 | /*************************************************************************** | ||
1680 | 2 | starrating.cpp | ||
1681 | 3 | ------------------- | ||
1682 | 4 | copyright : (C) 2010 Tobias Rafreider | ||
1683 | 5 | copyright : (C) 2009 Nokia Corporation | ||
1684 | 6 | |||
1685 | 7 | ***************************************************************************/ | ||
1686 | 8 | |||
1687 | 9 | /*************************************************************************** | ||
1688 | 10 | * * | ||
1689 | 11 | * This program is free software; you can redistribute it and/or modify * | ||
1690 | 12 | * it under the terms of the GNU General Public License as published by * | ||
1691 | 13 | * the Free Software Foundation; either version 2 of the License, or * | ||
1692 | 14 | * (at your option) any later version. * | ||
1693 | 15 | * * | ||
1694 | 16 | ***************************************************************************/ | ||
1695 | 17 | |||
1696 | 18 | |||
1697 | 19 | #include <QtGui> | ||
1698 | 20 | #include <math.h> | ||
1699 | 21 | |||
1700 | 22 | #include "starrating.h" | ||
1701 | 23 | |||
1702 | 24 | const int PaintingScaleFactor = 20; | ||
1703 | 25 | |||
1704 | 26 | |||
1705 | 27 | |||
1706 | 28 | StarRating::StarRating(int starCount, int maxStarCount) | ||
1707 | 29 | { | ||
1708 | 30 | m_myStarCount = starCount; | ||
1709 | 31 | m_myMaxStarCount = maxStarCount; | ||
1710 | 32 | |||
1711 | 33 | m_starPolygon << QPointF(1.0, 0.5); | ||
1712 | 34 | for (int i = 1; i < 5; ++i) | ||
1713 | 35 | m_starPolygon << QPointF(0.5 + 0.5 * cos(0.8 * i * 3.14), 0.5 + 0.5 * sin(0.8 * i * 3.14)); m_diamondPolygon << QPointF(0.4, 0.5) << QPointF(0.5, 0.4) << QPointF(0.6, 0.5) << QPointF(0.5, 0.6) << QPointF(0.4, 0.5); | ||
1714 | 36 | } | ||
1715 | 37 | |||
1716 | 38 | QSize StarRating::sizeHint() const | ||
1717 | 39 | { | ||
1718 | 40 | return PaintingScaleFactor * QSize(m_myMaxStarCount, 1); | ||
1719 | 41 | } | ||
1720 | 42 | |||
1721 | 43 | /* | ||
1722 | 44 | * function paints the stars in this StarRating object on a paint device | ||
1723 | 45 | */ | ||
1724 | 46 | void StarRating::paint(QPainter *painter, const QRect &rect, const QPalette &palette, EditMode mode) const | ||
1725 | 47 | { | ||
1726 | 48 | painter->save(); | ||
1727 | 49 | |||
1728 | 50 | painter->setRenderHint(QPainter::Antialiasing, true); | ||
1729 | 51 | painter->setPen(Qt::NoPen); | ||
1730 | 52 | |||
1731 | 53 | // Workaround for painting issue. If we are editable, assume we are | ||
1732 | 54 | // selected, so use the highlight and hightlightedText colors. | ||
1733 | 55 | if (mode == Editable) { | ||
1734 | 56 | painter->fillRect(rect, palette.highlight()); | ||
1735 | 57 | painter->setBrush(palette.highlightedText()); | ||
1736 | 58 | } | ||
1737 | 59 | |||
1738 | 60 | int yOffset = (rect.height() - PaintingScaleFactor) / 2; | ||
1739 | 61 | painter->translate(rect.x(), rect.y() + yOffset); | ||
1740 | 62 | painter->scale(PaintingScaleFactor, PaintingScaleFactor); | ||
1741 | 63 | |||
1742 | 64 | for (int i = 0; i < m_myMaxStarCount; ++i) { | ||
1743 | 65 | if (i < m_myStarCount) { | ||
1744 | 66 | painter->drawPolygon(m_starPolygon, Qt::WindingFill); | ||
1745 | 67 | } else { | ||
1746 | 68 | painter->drawPolygon(m_diamondPolygon, Qt::WindingFill); | ||
1747 | 69 | } | ||
1748 | 70 | painter->translate(1.0, 0.0); | ||
1749 | 71 | } | ||
1750 | 72 | |||
1751 | 73 | painter->restore(); | ||
1752 | 74 | } | ||
1753 | 0 | 75 | ||
1754 | === added file 'mixxx/src/library/starrating.h' | |||
1755 | --- mixxx/src/library/starrating.h 1970-01-01 00:00:00 +0000 | |||
1756 | +++ mixxx/src/library/starrating.h 2010-10-19 05:33:52 +0000 | |||
1757 | @@ -0,0 +1,62 @@ | |||
1758 | 1 | /*************************************************************************** | ||
1759 | 2 | starrating.h | ||
1760 | 3 | ------------------- | ||
1761 | 4 | copyright : (C) 2010 Tobias Rafreider | ||
1762 | 5 | copyright : (C) 2009 Nokia Corporation | ||
1763 | 6 | |||
1764 | 7 | ***************************************************************************/ | ||
1765 | 8 | |||
1766 | 9 | /*************************************************************************** | ||
1767 | 10 | * * | ||
1768 | 11 | * This program is free software; you can redistribute it and/or modify * | ||
1769 | 12 | * it under the terms of the GNU General Public License as published by * | ||
1770 | 13 | * the Free Software Foundation; either version 2 of the License, or * | ||
1771 | 14 | * (at your option) any later version. * | ||
1772 | 15 | * * | ||
1773 | 16 | ***************************************************************************/ | ||
1774 | 17 | |||
1775 | 18 | |||
1776 | 19 | #ifndef STARRATING_H | ||
1777 | 20 | #define STARRATING_H | ||
1778 | 21 | |||
1779 | 22 | #include <QMetaType> | ||
1780 | 23 | #include <QPointF> | ||
1781 | 24 | #include <QVector> | ||
1782 | 25 | #include <QPainter> | ||
1783 | 26 | #include <QStyledItemDelegate> | ||
1784 | 27 | |||
1785 | 28 | /* | ||
1786 | 29 | * The StarRating class represents a rating as a number of stars. | ||
1787 | 30 | * In addition to holding the data, it is also capable of painting the stars on a QPaintDevice, | ||
1788 | 31 | * which in this example is either a view or an editor. | ||
1789 | 32 | * The myStarCount member variable stores the current rating, and myMaxStarCount stores | ||
1790 | 33 | * the highest possible rating (typically 5). | ||
1791 | 34 | */ | ||
1792 | 35 | class StarRating | ||
1793 | 36 | { | ||
1794 | 37 | public: | ||
1795 | 38 | enum EditMode { Editable, ReadOnly }; | ||
1796 | 39 | |||
1797 | 40 | |||
1798 | 41 | StarRating(int starCount = 1, int maxStarCount = 5); | ||
1799 | 42 | |||
1800 | 43 | void paint(QPainter *painter, const QRect &rect, const QPalette &palette, EditMode mode) const; | ||
1801 | 44 | QSize sizeHint() const; | ||
1802 | 45 | |||
1803 | 46 | int starCount() const { return m_myStarCount; } | ||
1804 | 47 | int maxStarCount() const { return m_myMaxStarCount; } | ||
1805 | 48 | void setStarCount(int starCount) { m_myStarCount = starCount; } | ||
1806 | 49 | void setMaxStarCount(int maxStarCount) { m_myMaxStarCount = maxStarCount; } | ||
1807 | 50 | |||
1808 | 51 | |||
1809 | 52 | private: | ||
1810 | 53 | QPolygonF m_starPolygon; | ||
1811 | 54 | QPolygonF m_diamondPolygon; | ||
1812 | 55 | int m_myStarCount; | ||
1813 | 56 | int m_myMaxStarCount; | ||
1814 | 57 | |||
1815 | 58 | }; | ||
1816 | 59 | |||
1817 | 60 | Q_DECLARE_METATYPE(StarRating) | ||
1818 | 61 | |||
1819 | 62 | #endif | ||
1820 | 0 | 63 | ||
1821 | === modified file 'mixxx/src/library/trackcollection.cpp' | |||
1822 | --- mixxx/src/library/trackcollection.cpp 2010-10-07 03:05:48 +0000 | |||
1823 | +++ mixxx/src/library/trackcollection.cpp 2010-10-19 05:33:52 +0000 | |||
1824 | @@ -44,6 +44,9 @@ | |||
1825 | 44 | { | 44 | { |
1826 | 45 | // Save all tracks that haven't been saved yet. | 45 | // Save all tracks that haven't been saved yet. |
1827 | 46 | m_trackDao.saveDirtyTracks(); | 46 | m_trackDao.saveDirtyTracks(); |
1828 | 47 | // TODO(XXX) Maybe fold saveDirtyTracks into TrackDAO::finish now that it | ||
1829 | 48 | // exists? -- rryan 10/2010 | ||
1830 | 49 | m_trackDao.finish(); | ||
1831 | 47 | 50 | ||
1832 | 48 | Q_ASSERT(!m_db.rollback()); //Rollback any uncommitted transaction | 51 | Q_ASSERT(!m_db.rollback()); //Rollback any uncommitted transaction |
1833 | 49 | //The above is an ASSERT because there should never be an outstanding | 52 | //The above is an ASSERT because there should never be an outstanding |
1834 | @@ -65,7 +68,7 @@ | |||
1835 | 65 | return false; | 68 | return false; |
1836 | 66 | } | 69 | } |
1837 | 67 | 70 | ||
1839 | 68 | int requiredSchemaVersion = 5; | 71 | int requiredSchemaVersion = 6; |
1840 | 69 | if (!SchemaManager::upgradeToSchemaVersion(m_pConfig, m_db, | 72 | if (!SchemaManager::upgradeToSchemaVersion(m_pConfig, m_db, |
1841 | 70 | requiredSchemaVersion)) { | 73 | requiredSchemaVersion)) { |
1842 | 71 | QMessageBox::warning(0, qApp->tr("Cannot upgrade database schema"), | 74 | QMessageBox::warning(0, qApp->tr("Cannot upgrade database schema"), |
1843 | 72 | 75 | ||
1844 | === modified file 'mixxx/src/mixxx.cpp' | |||
1845 | --- mixxx/src/mixxx.cpp 2010-10-18 21:55:09 +0000 | |||
1846 | +++ mixxx/src/mixxx.cpp 2010-10-19 05:33:52 +0000 | |||
1847 | @@ -185,10 +185,10 @@ | |||
1848 | 185 | QDir dir(config->getValueString(ConfigKey("[Playlist]","Directory"))); | 185 | QDir dir(config->getValueString(ConfigKey("[Playlist]","Directory"))); |
1849 | 186 | if ((config->getValueString(ConfigKey("[Playlist]","Directory")).length()<1) || (!dir.exists())) | 186 | if ((config->getValueString(ConfigKey("[Playlist]","Directory")).length()<1) || (!dir.exists())) |
1850 | 187 | { | 187 | { |
1852 | 188 | QString fd = QFileDialog::getExistingDirectory(this, | 188 | QString fd = QFileDialog::getExistingDirectory(this, |
1853 | 189 | tr("Choose music library directory"), | 189 | tr("Choose music library directory"), |
1854 | 190 | QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); | 190 | QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); |
1856 | 191 | 191 | ||
1857 | 192 | if (fd != "") | 192 | if (fd != "") |
1858 | 193 | { | 193 | { |
1859 | 194 | config->set(ConfigKey("[Playlist]","Directory"), fd); | 194 | config->set(ConfigKey("[Playlist]","Directory"), fd); |
1860 | 195 | 195 | ||
1861 | === modified file 'mixxx/src/player.cpp' | |||
1862 | --- mixxx/src/player.cpp 2010-10-07 09:03:35 +0000 | |||
1863 | +++ mixxx/src/player.cpp 2010-10-19 05:33:52 +0000 | |||
1864 | @@ -178,6 +178,8 @@ | |||
1865 | 178 | if(!m_pLoadedTrack->getHeaderParsed()) | 178 | if(!m_pLoadedTrack->getHeaderParsed()) |
1866 | 179 | SoundSourceProxy::ParseHeader(m_pLoadedTrack.data()); | 179 | SoundSourceProxy::ParseHeader(m_pLoadedTrack.data()); |
1867 | 180 | 180 | ||
1868 | 181 | m_pLoadedTrack->incTimesPlayed(); | ||
1869 | 182 | |||
1870 | 181 | // Generate waveform summary | 183 | // Generate waveform summary |
1871 | 182 | //TODO: Consider reworking this visual resample stuff... need to ask rryan about this -- Albert. | 184 | //TODO: Consider reworking this visual resample stuff... need to ask rryan about this -- Albert. |
1872 | 183 | // TODO(rryan) : fix this crap -- the waveform renderers should be owned by | 185 | // TODO(rryan) : fix this crap -- the waveform renderers should be owned by |
1873 | 184 | 186 | ||
1874 | === modified file 'mixxx/src/trackinfoobject.cpp' | |||
1875 | --- mixxx/src/trackinfoobject.cpp 2010-10-07 03:05:48 +0000 | |||
1876 | +++ mixxx/src/trackinfoobject.cpp 2010-10-19 05:33:52 +0000 | |||
1877 | @@ -48,6 +48,7 @@ | |||
1878 | 48 | : m_qMutex(QMutex::Recursive) { | 48 | : m_qMutex(QMutex::Recursive) { |
1879 | 49 | m_sFilename = XmlParse::selectNodeQString(nodeHeader, "Filename"); | 49 | m_sFilename = XmlParse::selectNodeQString(nodeHeader, "Filename"); |
1880 | 50 | m_sLocation = XmlParse::selectNodeQString(nodeHeader, "Filepath") + "/" + m_sFilename; | 50 | m_sLocation = XmlParse::selectNodeQString(nodeHeader, "Filepath") + "/" + m_sFilename; |
1881 | 51 | QString create_date; | ||
1882 | 51 | 52 | ||
1883 | 52 | // We don't call initialize() here because it would end up calling parse() | 53 | // We don't call initialize() here because it would end up calling parse() |
1884 | 53 | // on the file. Plus those initializations weren't done before, so it might | 54 | // on the file. Plus those initializations weren't done before, so it might |
1885 | @@ -72,6 +73,11 @@ | |||
1886 | 72 | m_bBpmConfirm = XmlParse::selectNodeQString(nodeHeader, "BpmConfirm").toInt(); | 73 | m_bBpmConfirm = XmlParse::selectNodeQString(nodeHeader, "BpmConfirm").toInt(); |
1887 | 73 | m_fBeatFirst = XmlParse::selectNodeQString(nodeHeader, "BeatFirst").toFloat(); | 74 | m_fBeatFirst = XmlParse::selectNodeQString(nodeHeader, "BeatFirst").toFloat(); |
1888 | 74 | m_bHeaderParsed = false; | 75 | m_bHeaderParsed = false; |
1889 | 76 | create_date = XmlParse::selectNodeQString(nodeHeader, "CreateDate"); | ||
1890 | 77 | if (create_date == "") | ||
1891 | 78 | m_dCreateDate = fileInfo.created(); | ||
1892 | 79 | else | ||
1893 | 80 | m_dCreateDate = QDateTime::fromString(create_date); | ||
1894 | 75 | 81 | ||
1895 | 76 | // Mixxx <1.8 recorded track IDs in mixxxtrack.xml, but we are going to | 82 | // Mixxx <1.8 recorded track IDs in mixxxtrack.xml, but we are going to |
1896 | 77 | // ignore those. Tracks will get a new ID from the database. | 83 | // ignore those. Tracks will get a new ID from the database. |
1897 | @@ -79,6 +85,7 @@ | |||
1898 | 79 | m_iId = -1; | 85 | m_iId = -1; |
1899 | 80 | 86 | ||
1900 | 81 | m_fCuePoint = XmlParse::selectNodeQString(nodeHeader, "CuePoint").toFloat(); | 87 | m_fCuePoint = XmlParse::selectNodeQString(nodeHeader, "CuePoint").toFloat(); |
1901 | 88 | m_bPlayed = false; | ||
1902 | 82 | 89 | ||
1903 | 83 | m_pVisualWave = 0; | 90 | m_pVisualWave = 0; |
1904 | 84 | m_dVisualResampleRate = 0; | 91 | m_dVisualResampleRate = 0; |
1905 | @@ -112,6 +119,7 @@ | |||
1906 | 112 | m_iDuration = 0; | 119 | m_iDuration = 0; |
1907 | 113 | m_iBitrate = 0; | 120 | m_iBitrate = 0; |
1908 | 114 | m_iTimesPlayed = 0; | 121 | m_iTimesPlayed = 0; |
1909 | 122 | m_bPlayed = false; | ||
1910 | 115 | m_fBpm = 0.; | 123 | m_fBpm = 0.; |
1911 | 116 | m_bBpmConfirm = false; | 124 | m_bBpmConfirm = false; |
1912 | 117 | m_bIsValid = false; | 125 | m_bIsValid = false; |
1913 | @@ -123,6 +131,8 @@ | |||
1914 | 123 | m_iChannels = 0; | 131 | m_iChannels = 0; |
1915 | 124 | m_fCuePoint = 0.0f; | 132 | m_fCuePoint = 0.0f; |
1916 | 125 | m_dVisualResampleRate = 0; | 133 | m_dVisualResampleRate = 0; |
1917 | 134 | m_dCreateDate = QDateTime::currentDateTime(); | ||
1918 | 135 | m_Rating = 0; | ||
1919 | 126 | 136 | ||
1920 | 127 | // parse() parses the metadata from file. This is not a quick operation! | 137 | // parse() parses the metadata from file. This is not a quick operation! |
1921 | 128 | if (parseHeader) | 138 | if (parseHeader) |
1922 | @@ -148,6 +158,7 @@ | |||
1923 | 148 | { | 158 | { |
1924 | 149 | QMutexLocker lock(&m_qMutex); | 159 | QMutexLocker lock(&m_qMutex); |
1925 | 150 | 160 | ||
1926 | 161 | QString create_date; | ||
1927 | 151 | XmlParse::addElement( doc, header, "Filename", m_sFilename ); | 162 | XmlParse::addElement( doc, header, "Filename", m_sFilename ); |
1928 | 152 | //XmlParse::addElement( doc, header, "Filepath", m_sFilepath ); | 163 | //XmlParse::addElement( doc, header, "Filepath", m_sFilepath ); |
1929 | 153 | XmlParse::addElement( doc, header, "Title", m_sTitle ); | 164 | XmlParse::addElement( doc, header, "Title", m_sTitle ); |
1930 | @@ -165,6 +176,7 @@ | |||
1931 | 165 | XmlParse::addElement( doc, header, "BeatFirst", QString("%1").arg(m_fBeatFirst) ); | 176 | XmlParse::addElement( doc, header, "BeatFirst", QString("%1").arg(m_fBeatFirst) ); |
1932 | 166 | XmlParse::addElement( doc, header, "Id", QString("%1").arg(m_iId) ); | 177 | XmlParse::addElement( doc, header, "Id", QString("%1").arg(m_iId) ); |
1933 | 167 | XmlParse::addElement( doc, header, "CuePoint", QString::number(m_fCuePoint) ); | 178 | XmlParse::addElement( doc, header, "CuePoint", QString::number(m_fCuePoint) ); |
1934 | 179 | XmlParse::addElement( doc, header, "CreateDate", m_dCreateDate.toString() ); | ||
1935 | 168 | //if (m_pWave) { | 180 | //if (m_pWave) { |
1936 | 169 | //XmlParse::addHexElement(doc, header, "WaveSummaryHex", m_pWave); | 181 | //XmlParse::addHexElement(doc, header, "WaveSummaryHex", m_pWave); |
1937 | 170 | //} | 182 | //} |
1938 | @@ -255,6 +267,13 @@ | |||
1939 | 255 | return m_sFilename; | 267 | return m_sFilename; |
1940 | 256 | } | 268 | } |
1941 | 257 | 269 | ||
1942 | 270 | QDateTime TrackInfoObject::getCreateDate() const | ||
1943 | 271 | { | ||
1944 | 272 | QMutexLocker lock(&m_qMutex); | ||
1945 | 273 | QDateTime create_date = QDateTime(m_dCreateDate); | ||
1946 | 274 | return create_date; | ||
1947 | 275 | } | ||
1948 | 276 | |||
1949 | 258 | bool TrackInfoObject::exists() const | 277 | bool TrackInfoObject::exists() const |
1950 | 259 | { | 278 | { |
1951 | 260 | QMutexLocker lock(&m_qMutex); | 279 | QMutexLocker lock(&m_qMutex); |
1952 | @@ -439,13 +458,53 @@ | |||
1953 | 439 | return m_iTimesPlayed; | 458 | return m_iTimesPlayed; |
1954 | 440 | } | 459 | } |
1955 | 441 | 460 | ||
1956 | 461 | void TrackInfoObject::setTimesPlayed(int t) | ||
1957 | 462 | { | ||
1958 | 463 | QMutexLocker lock(&m_qMutex); | ||
1959 | 464 | bool dirty = t != m_iTimesPlayed; | ||
1960 | 465 | m_iTimesPlayed = t; | ||
1961 | 466 | if (dirty) | ||
1962 | 467 | setDirty(true); | ||
1963 | 468 | } | ||
1964 | 469 | |||
1965 | 442 | void TrackInfoObject::incTimesPlayed() | 470 | void TrackInfoObject::incTimesPlayed() |
1966 | 443 | { | 471 | { |
1967 | 444 | QMutexLocker lock(&m_qMutex); | 472 | QMutexLocker lock(&m_qMutex); |
1968 | 473 | std::cout << "Track Played:" << m_sArtist.toStdString() << " - " << m_sTitle.toStdString(); | ||
1969 | 474 | qDebug() << "Track Played:" << m_sArtist << " - " << m_sTitle; | ||
1970 | 475 | m_bPlayed = true; | ||
1971 | 445 | ++m_iTimesPlayed; | 476 | ++m_iTimesPlayed; |
1972 | 446 | setDirty(true); | 477 | setDirty(true); |
1973 | 447 | } | 478 | } |
1974 | 448 | 479 | ||
1975 | 480 | bool TrackInfoObject::getPlayed() const | ||
1976 | 481 | { | ||
1977 | 482 | QMutexLocker lock(&m_qMutex); | ||
1978 | 483 | bool bPlayed = m_bPlayed; | ||
1979 | 484 | return bPlayed; | ||
1980 | 485 | } | ||
1981 | 486 | |||
1982 | 487 | void TrackInfoObject::setPlayed(bool bPlayed) | ||
1983 | 488 | { | ||
1984 | 489 | QMutexLocker lock(&m_qMutex); | ||
1985 | 490 | bool dirty = bPlayed != m_bPlayed; | ||
1986 | 491 | m_bPlayed = bPlayed; | ||
1987 | 492 | if (dirty) | ||
1988 | 493 | { | ||
1989 | 494 | if (bPlayed) | ||
1990 | 495 | { | ||
1991 | 496 | std::cout << "Track Played:" << m_sArtist.toStdString() << " - " << m_sTitle.toStdString(); | ||
1992 | 497 | qDebug() << "Track Played:" << m_sArtist << " - " << m_sTitle; | ||
1993 | 498 | } | ||
1994 | 499 | else | ||
1995 | 500 | { | ||
1996 | 501 | std::cout << "Track Unplayed:" << m_sArtist.toStdString() << " - " << m_sTitle.toStdString(); | ||
1997 | 502 | qDebug() << "Track Unplayed:" << m_sArtist << " - " << m_sTitle; | ||
1998 | 503 | } | ||
1999 | 504 | setDirty(true); | ||
2000 | 505 | } | ||
2001 | 506 | } | ||
2002 | 507 | |||
2003 | 449 | QString TrackInfoObject::getComment() const | 508 | QString TrackInfoObject::getComment() const |
2004 | 450 | { | 509 | { |
2005 | 451 | QMutexLocker lock(&m_qMutex); | 510 | QMutexLocker lock(&m_qMutex); |
2006 | @@ -721,3 +780,18 @@ | |||
2007 | 721 | QMutexLocker lock(&m_qMutex); | 780 | QMutexLocker lock(&m_qMutex); |
2008 | 722 | return m_bLocationChanged; | 781 | return m_bLocationChanged; |
2009 | 723 | } | 782 | } |
2010 | 783 | /** Returns the rating */ | ||
2011 | 784 | int TrackInfoObject::getRating() const{ | ||
2012 | 785 | QMutexLocker lock(&m_qMutex); | ||
2013 | 786 | |||
2014 | 787 | return m_Rating; | ||
2015 | 788 | } | ||
2016 | 789 | /** Set rating */ | ||
2017 | 790 | void TrackInfoObject::setRating (int rating){ | ||
2018 | 791 | QMutexLocker lock(&m_qMutex); | ||
2019 | 792 | |||
2020 | 793 | bool dirty = rating != m_Rating; | ||
2021 | 794 | m_Rating = rating; | ||
2022 | 795 | if (dirty) | ||
2023 | 796 | setDirty(true); | ||
2024 | 797 | } | ||
2025 | 724 | 798 | ||
2026 | === modified file 'mixxx/src/trackinfoobject.h' | |||
2027 | --- mixxx/src/trackinfoobject.h 2010-10-07 03:05:48 +0000 | |||
2028 | +++ mixxx/src/trackinfoobject.h 2010-10-19 05:33:52 +0000 | |||
2029 | @@ -19,6 +19,7 @@ | |||
2030 | 19 | #define TRACKINFOOBJECT_H | 19 | #define TRACKINFOOBJECT_H |
2031 | 20 | 20 | ||
2032 | 21 | #include <QList> | 21 | #include <QList> |
2033 | 22 | #include <QDateTime> | ||
2034 | 22 | #include <QObject> | 23 | #include <QObject> |
2035 | 23 | #include <QFileInfo> | 24 | #include <QFileInfo> |
2036 | 24 | #include <QMutex> | 25 | #include <QMutex> |
2037 | @@ -76,6 +77,8 @@ | |||
2038 | 76 | QString getDirectory() const; | 77 | QString getDirectory() const; |
2039 | 77 | // Returns the filename of the file. | 78 | // Returns the filename of the file. |
2040 | 78 | QString getFilename() const; | 79 | QString getFilename() const; |
2041 | 80 | // Returns file creation date | ||
2042 | 81 | QDateTime getCreateDate() const; | ||
2043 | 79 | // Returns the length of the file in bytes | 82 | // Returns the length of the file in bytes |
2044 | 80 | int getLength() const; | 83 | int getLength() const; |
2045 | 81 | // Returns whether the file exists on disk or not. Updated as of the time | 84 | // Returns whether the file exists on disk or not. Updated as of the time |
2046 | @@ -152,11 +155,21 @@ | |||
2047 | 152 | void setTrackNumber(QString); | 155 | void setTrackNumber(QString); |
2048 | 153 | /** Return number of times the track has been played */ | 156 | /** Return number of times the track has been played */ |
2049 | 154 | int getTimesPlayed() const; | 157 | int getTimesPlayed() const; |
2050 | 158 | /** Set number of times the track has been played */ | ||
2051 | 159 | void setTimesPlayed(int t); | ||
2052 | 155 | /** Increment times played with one */ | 160 | /** Increment times played with one */ |
2053 | 156 | void incTimesPlayed(); | 161 | void incTimesPlayed(); |
2054 | 162 | /** Returns true if track has been played this instance*/ | ||
2055 | 163 | bool getPlayed() const; | ||
2056 | 164 | /** Set Played status*/ | ||
2057 | 165 | void setPlayed(bool); | ||
2058 | 157 | 166 | ||
2059 | 158 | int getId() const; | 167 | int getId() const; |
2060 | 159 | 168 | ||
2061 | 169 | /** Returns rating */ | ||
2062 | 170 | int getRating() const; | ||
2063 | 171 | /** Sets rating */ | ||
2064 | 172 | void setRating(int); | ||
2065 | 160 | 173 | ||
2066 | 161 | /** Get URL for track */ | 174 | /** Get URL for track */ |
2067 | 162 | QString getURL(); | 175 | QString getURL(); |
2068 | @@ -282,10 +295,14 @@ | |||
2069 | 282 | int m_iSampleRate; | 295 | int m_iSampleRate; |
2070 | 283 | /** Number of channels */ | 296 | /** Number of channels */ |
2071 | 284 | int m_iChannels; | 297 | int m_iChannels; |
2072 | 298 | /**Track rating */ | ||
2073 | 299 | int m_Rating;; | ||
2074 | 285 | /** Bitrate, number of kilobits per second of audio in the track*/ | 300 | /** Bitrate, number of kilobits per second of audio in the track*/ |
2075 | 286 | int m_iBitrate; | 301 | int m_iBitrate; |
2076 | 287 | /** Number of times the track has been played */ | 302 | /** Number of times the track has been played */ |
2077 | 288 | int m_iTimesPlayed; | 303 | int m_iTimesPlayed; |
2078 | 304 | /** Has this track been played this sessions? */ | ||
2079 | 305 | bool m_bPlayed; | ||
2080 | 289 | /** Beat per minutes (BPM) */ | 306 | /** Beat per minutes (BPM) */ |
2081 | 290 | float m_fBpm; | 307 | float m_fBpm; |
2082 | 291 | /** Minimum BPM range. If this is 0.0, then the config min BPM will be used */ | 308 | /** Minimum BPM range. If this is 0.0, then the config min BPM will be used */ |
2083 | @@ -302,6 +319,8 @@ | |||
2084 | 302 | int m_iId; | 319 | int m_iId; |
2085 | 303 | /** Cue point in samples or something */ | 320 | /** Cue point in samples or something */ |
2086 | 304 | float m_fCuePoint; | 321 | float m_fCuePoint; |
2087 | 322 | /** Date. creation date of file */ | ||
2088 | 323 | QDateTime m_dCreateDate; | ||
2089 | 305 | 324 | ||
2090 | 306 | // The list of cue points for the track | 325 | // The list of cue points for the track |
2091 | 307 | QList<Cue*> m_cuePoints; | 326 | QList<Cue*> m_cuePoints; |
2092 | 308 | 327 | ||
2093 | === modified file 'mixxx/src/widget/wlibrarytableview.cpp' | |||
2094 | --- mixxx/src/widget/wlibrarytableview.cpp 2010-09-19 22:08:15 +0000 | |||
2095 | +++ mixxx/src/widget/wlibrarytableview.cpp 2010-10-19 05:33:52 +0000 | |||
2096 | @@ -8,6 +8,7 @@ | |||
2097 | 8 | #include "widget/wwidget.h" | 8 | #include "widget/wwidget.h" |
2098 | 9 | #include "widget/wskincolor.h" | 9 | #include "widget/wskincolor.h" |
2099 | 10 | #include "widget/wlibrarytableview.h" | 10 | #include "widget/wlibrarytableview.h" |
2100 | 11 | #include "../library/stardelegate.h" | ||
2101 | 11 | 12 | ||
2102 | 12 | WLibraryTableView::WLibraryTableView(QWidget* parent, | 13 | WLibraryTableView::WLibraryTableView(QWidget* parent, |
2103 | 13 | ConfigObject<ConfigValue>* pConfig, | 14 | ConfigObject<ConfigValue>* pConfig, |
2104 | @@ -16,7 +17,13 @@ | |||
2105 | 16 | m_pConfig(pConfig), | 17 | m_pConfig(pConfig), |
2106 | 17 | m_vScrollBarPosKey(vScrollBarPosKey) { | 18 | m_vScrollBarPosKey(vScrollBarPosKey) { |
2107 | 18 | 19 | ||
2109 | 19 | //Setup properties for table | 20 | // Setup properties for table |
2110 | 21 | |||
2111 | 22 | // Editing starts when clicking on an already selected item. | ||
2112 | 23 | setEditTriggers(QAbstractItemView::SelectedClicked); | ||
2113 | 24 | |||
2114 | 25 | // This is to support rating of tracks | ||
2115 | 26 | setItemDelegate(new StarDelegate()); | ||
2116 | 20 | 27 | ||
2117 | 21 | //Enable selection by rows and extended selection (ctrl/shift click) | 28 | //Enable selection by rows and extended selection (ctrl/shift click) |
2118 | 22 | setSelectionBehavior(QAbstractItemView::SelectRows); | 29 | setSelectionBehavior(QAbstractItemView::SelectRows); |
2119 | 23 | 30 | ||
2120 | === modified file 'mixxx/src/widget/wstatuslight.cpp' | |||
2121 | --- mixxx/src/widget/wstatuslight.cpp 2009-03-05 15:14:48 +0000 | |||
2122 | +++ mixxx/src/widget/wstatuslight.cpp 2010-10-19 05:33:52 +0000 | |||
2123 | @@ -26,59 +26,90 @@ | |||
2124 | 26 | 26 | ||
2125 | 27 | WStatusLight::WStatusLight(QWidget * parent) : WWidget(parent) | 27 | WStatusLight::WStatusLight(QWidget * parent) : WWidget(parent) |
2126 | 28 | { | 28 | { |
2129 | 29 | m_pPixmapBack = 0; | 29 | m_pPixmapSLs = 0; |
2130 | 30 | m_pPixmapSL = 0; | 30 | m_iNoPos = 0; |
2131 | 31 | m_iPos = 0; | ||
2132 | 32 | |||
2133 | 33 | setNoPos(0); | ||
2134 | 31 | } | 34 | } |
2135 | 32 | 35 | ||
2136 | 33 | WStatusLight::~WStatusLight() | 36 | WStatusLight::~WStatusLight() |
2137 | 34 | { | 37 | { |
2139 | 35 | resetPositions(); | 38 | for (int i = 0; i < m_iNoPos; i++) { |
2140 | 39 | WPixmapStore::deletePixmap(m_pPixmapSLs[i]); | ||
2141 | 40 | } | ||
2142 | 41 | } | ||
2143 | 42 | |||
2144 | 43 | void WStatusLight::setNoPos(int iNoPos) | ||
2145 | 44 | { | ||
2146 | 45 | m_iNoPos = iNoPos; | ||
2147 | 46 | m_fValue = 0.; | ||
2148 | 47 | |||
2149 | 48 | // If pixmap array is already allocated, delete it | ||
2150 | 49 | if (m_pPixmapSLs) | ||
2151 | 50 | delete [] m_pPixmapSLs; | ||
2152 | 51 | |||
2153 | 52 | if (m_iNoPos>0) | ||
2154 | 53 | { | ||
2155 | 54 | m_pPixmapSLs = new QPixmap*[m_iNoPos]; | ||
2156 | 55 | for (int i=0; i<m_iNoPos; ++i) | ||
2157 | 56 | m_pPixmapSLs[i] = 0; | ||
2158 | 57 | } | ||
2159 | 36 | } | 58 | } |
2160 | 37 | 59 | ||
2161 | 38 | void WStatusLight::setup(QDomNode node) | 60 | void WStatusLight::setup(QDomNode node) |
2162 | 39 | { | 61 | { |
2163 | 40 | WWidget::setup(node); | 62 | WWidget::setup(node); |
2194 | 41 | 63 | // Number of states | |
2195 | 42 | // Set pixmaps | 64 | m_iNoPos = selectNodeInt(node, "NumberPos") + 1; |
2196 | 43 | bool bHorizontal = false; | 65 | setNoPos(m_iNoPos); |
2197 | 44 | if (!selectNode(node, "Horizontal").isNull() && selectNodeQString(node, "Horizontal")=="true") | 66 | |
2198 | 45 | bHorizontal = true; | 67 | for (int i=0; i<m_iNoPos; i++) |
2199 | 46 | setPixmaps(getPath(selectNodeQString(node, "PathBack")), getPath(selectNodeQString(node, "PathStatusLight")), bHorizontal); | 68 | { |
2200 | 47 | } | 69 | switch(i) |
2201 | 48 | 70 | { | |
2202 | 49 | void WStatusLight::resetPositions() | 71 | case 0: |
2203 | 50 | { | 72 | // Set background pixmap if available |
2204 | 51 | if (m_pPixmapBack) | 73 | if (!selectNode(node, "BackPath").isNull()) |
2205 | 52 | { | 74 | setPixmap(0, getPath(selectNodeQString(node, "BackPath"))); |
2206 | 53 | WPixmapStore::deletePixmap(m_pPixmapBack); | 75 | else |
2207 | 54 | m_pPixmapBack = 0; | 76 | m_pPixmapSLs[0] = 0; |
2208 | 55 | WPixmapStore::deletePixmap(m_pPixmapSL); | 77 | break; |
2209 | 56 | m_pPixmapSL = 0; | 78 | case 1: |
2210 | 57 | } | 79 | setPixmap(1, getPath(selectNodeQString(node, "PathStatusLight"))); |
2211 | 58 | } | 80 | break; |
2212 | 59 | 81 | default: | |
2213 | 60 | void WStatusLight::setPixmaps(const QString &backFilename, const QString &vuFilename, bool bHorizontal) | 82 | setPixmap(i, getPath(selectNodeQString(node, QString("PathStatusLight%1").arg(i)))); |
2214 | 61 | { | 83 | } |
2215 | 62 | m_pPixmapBack = WPixmapStore::getPixmap(backFilename); | 84 | } |
2216 | 63 | if (!m_pPixmapBack || m_pPixmapBack->size()==QSize(0,0)) | 85 | } |
2217 | 64 | qDebug() << "WStatusLight: Error loading back pixmap" << backFilename; | 86 | |
2218 | 65 | m_pPixmapSL = WPixmapStore::getPixmap(vuFilename); | 87 | void WStatusLight::setPixmap(int iState, const QString &filename) |
2219 | 66 | if (!m_pPixmapSL || m_pPixmapSL->size()==QSize(0,0)) | 88 | { |
2220 | 67 | qDebug() << "WStatusLight: Error loading statuslight pixmap" << vuFilename; | 89 | int pixIdx = iState; |
2221 | 68 | 90 | m_pPixmapSLs[pixIdx] = WPixmapStore::getPixmap(filename); | |
2222 | 69 | setFixedSize(m_pPixmapBack->size()); | 91 | if (!m_pPixmapSLs[pixIdx]) |
2223 | 70 | m_bHorizontal = bHorizontal; | 92 | qDebug() << "WPushButton: Error loading pixmap:" << filename << iState; |
2224 | 93 | |||
2225 | 94 | // Set size of widget equal to pixmap size | ||
2226 | 95 | setFixedSize(m_pPixmapSLs[pixIdx]->size()); | ||
2227 | 96 | } | ||
2228 | 97 | |||
2229 | 98 | void WStatusLight::setValue(double v) | ||
2230 | 99 | { | ||
2231 | 100 | if (m_iPos != (int)v) | ||
2232 | 101 | { | ||
2233 | 102 | m_iPos = (int)v; | ||
2234 | 103 | update(); | ||
2235 | 104 | } | ||
2236 | 71 | } | 105 | } |
2237 | 72 | 106 | ||
2238 | 73 | void WStatusLight::paintEvent(QPaintEvent *) | 107 | void WStatusLight::paintEvent(QPaintEvent *) |
2239 | 74 | { | 108 | { |
2241 | 75 | if (m_pPixmapBack!=0 && m_pPixmapSL!=0) | 109 | if (m_pPixmapSLs[m_iPos]) |
2242 | 76 | { | 110 | { |
2243 | 77 | QPainter p(this); | 111 | QPainter p(this); |
2249 | 78 | 112 | if(m_iPos != 0 && m_pPixmapSLs[0]) p.drawPixmap(0, 0, *m_pPixmapSLs[0]); | |
2250 | 79 | if(m_fValue == 0) | 113 | p.drawPixmap(0, 0, *m_pPixmapSLs[m_iPos]); |
2246 | 80 | p.drawPixmap(0, 0, *m_pPixmapBack); | ||
2247 | 81 | else | ||
2248 | 82 | p.drawPixmap(0, 0, *m_pPixmapSL); | ||
2251 | 83 | } | 114 | } |
2252 | 84 | } | 115 | } |
2253 | 85 | 116 | ||
2254 | === modified file 'mixxx/src/widget/wstatuslight.h' | |||
2255 | --- mixxx/src/widget/wstatuslight.h 2009-03-05 15:45:39 +0000 | |||
2256 | +++ mixxx/src/widget/wstatuslight.h 2010-10-19 05:33:52 +0000 | |||
2257 | @@ -31,26 +31,24 @@ | |||
2258 | 31 | */ | 31 | */ |
2259 | 32 | 32 | ||
2260 | 33 | class WStatusLight : public WWidget { | 33 | class WStatusLight : public WWidget { |
2263 | 34 | Q_OBJECT | 34 | Q_OBJECT |
2264 | 35 | public: | 35 | public: |
2265 | 36 | WStatusLight(QWidget *parent=0); | 36 | WStatusLight(QWidget *parent=0); |
2267 | 37 | ~WStatusLight(); | 37 | virtual ~WStatusLight(); |
2268 | 38 | void setup(QDomNode node); | 38 | void setup(QDomNode node); |
2274 | 39 | void setPixmaps(const QString &backFilename, const QString &vuFilename, bool bHorizontal=false); | 39 | void setPixmap(int iState, const QString &filename); |
2275 | 40 | 40 | void setNoPos(int iNoPos); | |
2276 | 41 | private: | 41 | public slots: |
2277 | 42 | /** Set position number to zero and deallocate pixmaps */ | 42 | void setValue(double v); |
2278 | 43 | void resetPositions(); | 43 | private: |
2279 | 44 | void paintEvent(QPaintEvent *); | 44 | void paintEvent(QPaintEvent *); |
2280 | 45 | 45 | ||
2281 | 46 | /** Current position */ | 46 | /** Current position */ |
2282 | 47 | int m_iPos; | 47 | int m_iPos; |
2284 | 48 | /** Number of positions associated with this knob */ | 48 | /** Number of positions associated with this light */ |
2285 | 49 | int m_iNoPos; | 49 | int m_iNoPos; |
2286 | 50 | /** Associated pixmaps */ | 50 | /** Associated pixmaps */ |
2290 | 51 | QPixmap *m_pPixmapBack, *m_pPixmapSL; | 51 | QPixmap **m_pPixmapSLs; |
2288 | 52 | /** True if it's a horizontal vu meter */ | ||
2289 | 53 | bool m_bHorizontal; | ||
2291 | 54 | }; | 52 | }; |
2292 | 55 | 53 | ||
2293 | 56 | #endif | 54 | #endif |
2294 | 57 | 55 | ||
2295 | === modified file 'mixxx/src/widget/wtracktableview.cpp' | |||
2296 | --- mixxx/src/widget/wtracktableview.cpp 2010-09-17 06:09:27 +0000 | |||
2297 | +++ mixxx/src/widget/wtracktableview.cpp 2010-10-19 05:33:52 +0000 | |||
2298 | @@ -31,12 +31,11 @@ | |||
2299 | 31 | this, SLOT(slotPrevTrackInfo())); | 31 | this, SLOT(slotPrevTrackInfo())); |
2300 | 32 | 32 | ||
2301 | 33 | m_pMenu = new QMenu(this); | 33 | m_pMenu = new QMenu(this); |
2302 | 34 | |||
2303 | 34 | m_pPlaylistMenu = new QMenu(this); | 35 | m_pPlaylistMenu = new QMenu(this); |
2304 | 35 | m_pPlaylistMenu->setTitle(tr("Add to Playlist")); | 36 | m_pPlaylistMenu->setTitle(tr("Add to Playlist")); |
2305 | 36 | m_pCrateMenu = new QMenu(this); | 37 | m_pCrateMenu = new QMenu(this); |
2306 | 37 | m_pCrateMenu->setTitle(tr("Add to Crate")); | 38 | m_pCrateMenu->setTitle(tr("Add to Crate")); |
2307 | 38 | //Disable editing | ||
2308 | 39 | //setEditTriggers(QAbstractItemView::NoEditTriggers); | ||
2309 | 40 | 39 | ||
2310 | 41 | //Create all the context m_pMenu->actions (stuff that shows up when you | 40 | //Create all the context m_pMenu->actions (stuff that shows up when you |
2311 | 42 | //right-click) | 41 | //right-click) |
2312 | @@ -614,13 +613,15 @@ | |||
2313 | 614 | 613 | ||
2314 | 615 | void WTrackTableView::keyPressEvent(QKeyEvent* event) | 614 | void WTrackTableView::keyPressEvent(QKeyEvent* event) |
2315 | 616 | { | 615 | { |
2317 | 617 | m_selectedIndices = this->selectionModel()->selectedRows(); | 616 | |
2318 | 618 | if (event->key() == Qt::Key_Return) | 617 | if (event->key() == Qt::Key_Return) |
2319 | 619 | { | 618 | { |
2324 | 620 | if (m_selectedIndices.size() > 0) { | 619 | /* |
2325 | 621 | QModelIndex index = m_selectedIndices.at(0); | 620 | * It is not a good idea if 'key_return' |
2326 | 622 | slotMouseDoubleClicked(index); | 621 | * causes a track to load since we allow in-line editing |
2327 | 623 | } | 622 | * of table items in general |
2328 | 623 | */ | ||
2329 | 624 | return; | ||
2330 | 624 | } | 625 | } |
2331 | 625 | else if (event->key() == Qt::Key_BracketLeft) | 626 | else if (event->key() == Qt::Key_BracketLeft) |
2332 | 626 | { | 627 | { |
Please note that Jus requested a way to specify the rating colour via skins. I have not found a good solution to that since star rating editors are created from delegates and I do not know how to read from skin.xml there :-( A singleton 'SkinManager' would be great.
BTW: Star ratings look good on Windows and Ubuntu 9.04. On Ubuntu 10.10 is does not look nice anymore (maybe QT 7.0 related)