Merge lp:~mixxxdevelopers/mixxx/features_library into lp:~mixxxdevelopers/mixxx/trunk

Proposed by RJ Skerry-Ryan
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
Reviewer Review Type Date Requested Status
Albert Santoni Approve
Review via email: mp+38802@code.launchpad.net

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!

To post a comment you must log in.
2489. By RJ Skerry-Ryan

Clear the prepare and missing headers on upgarde to schema version 6.

Revision history for this message
RAFFI TEA (raffitea) wrote :

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)

Revision history for this message
Albert Santoni (gamegod) wrote :
Revision history for this message
Albert Santoni (gamegod) wrote :

I've reviewed your code and everything pretty much looks good to me.

review: Approve
Revision history for this message
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?

Revision history for this message
RAFFI TEA (raffitea) wrote :

It sounds reasonable. How can I archive such a behaviour?

Revision history for this message
RAFFI TEA (raffitea) wrote :

Key columns are now hidden by default. Basically, I have extended TrackModel with a method 'isColumnHiddenByDefault(int column)'. All concrete TrackModels such as LibraryTableModel implement this method. So we can even hide more columns by default but a user can bring it to front on request.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'mixxx/build/depends.py'
--- mixxx/build/depends.py 2010-10-19 00:05:55 +0000
+++ mixxx/build/depends.py 2010-10-19 05:33:52 +0000
@@ -454,6 +454,9 @@
454 "library/featuredartistswebview.cpp",454 "library/featuredartistswebview.cpp",
455 "library/bundledsongswebview.cpp",455 "library/bundledsongswebview.cpp",
456 "library/songdownloader.cpp",456 "library/songdownloader.cpp",
457 "library/starrating.cpp",
458 "library/stardelegate.cpp",
459 "library/stareditor.cpp",
457460
458 "xmlparse.cpp",461 "xmlparse.cpp",
459 "parser.cpp",462 "parser.cpp",
@@ -676,7 +679,7 @@
676 build.env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT.lib',679 build.env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT.lib',
677 '/nodefaultlib:LIBCMTd.lib',680 '/nodefaultlib:LIBCMTd.lib',
678 '/entry:mainCRTStartup'])681 '/entry:mainCRTStartup'])
679 # Makes the program not launch a shell first 682 # Makes the program not launch a shell first
680 if build.toolchain_is_msvs:683 if build.toolchain_is_msvs:
681 build.env.Append(LINKFLAGS = '/subsystem:windows')684 build.env.Append(LINKFLAGS = '/subsystem:windows')
682 elif build.toolchain_is_gnu:685 elif build.toolchain_is_gnu:
683686
=== modified file 'mixxx/res/schema.xml'
--- mixxx/res/schema.xml 2010-09-14 14:45:35 +0000
+++ mixxx/res/schema.xml 2010-10-19 05:33:52 +0000
@@ -146,4 +146,22 @@
146 ALTER TABLE LibraryHashes ADD COLUMN needs_verification INTEGER DEFAULT 0;146 ALTER TABLE LibraryHashes ADD COLUMN needs_verification INTEGER DEFAULT 0;
147 </sql>147 </sql>
148 </revision>148 </revision>
149 <revision version="6">
150 <description>
151 Add timesplayed and rating column. Reset header state.
152 </description>
153 <sql>
154 ALTER TABLE library ADD COLUMN timesplayed integer DEFAULT 0;
155 ALTER TABLE library ADD COLUMN rating integer DEFAULT 0;
156
157 UPDATE library SET timesplayed = played;
158 UPDATE library SET played = 0;
159
160 DELETE FROM settings WHERE name="mixxx.db.model.library.header_state";
161 DELETE FROM settings WHERE name="mixxx.db.model.playlist.header_state";
162 DELETE FROM settings WHERE name="mixxx.db.model.crate.header_state";
163 DELETE FROM settings WHERE name="mixxx.db.model.prepare.header_state";
164 DELETE FROM settings WHERE name="mixxx.db.model.missing.header_state";
165 </sql>
166 </revision>
149</schema>167</schema>
150168
=== modified file 'mixxx/src/library/basesqltablemodel.cpp'
--- mixxx/src/library/basesqltablemodel.cpp 2010-08-27 20:29:12 +0000
+++ mixxx/src/library/basesqltablemodel.cpp 2010-10-19 05:33:52 +0000
@@ -6,6 +6,9 @@
6#include "trackinfoobject.h"6#include "trackinfoobject.h"
7#include "library/trackcollection.h"7#include "library/trackcollection.h"
8#include "library/basesqltablemodel.h"8#include "library/basesqltablemodel.h"
9#include "mixxxutils.cpp"
10#include "library/starrating.h"
11
912
10BaseSqlTableModel::BaseSqlTableModel(QObject* parent,13BaseSqlTableModel::BaseSqlTableModel(QObject* parent,
11 TrackCollection* pTrackCollection,14 TrackCollection* pTrackCollection,
@@ -20,6 +23,44 @@
20}23}
2124
22BaseSqlTableModel::~BaseSqlTableModel() {25BaseSqlTableModel::~BaseSqlTableModel() {
26
27}
28
29void BaseSqlTableModel::initHeaderData() {
30 //Set the column heading labels, rename them for translations and have
31 //proper capitalization
32 setHeaderData(fieldIndex(LIBRARYTABLE_TIMESPLAYED),
33 Qt::Horizontal, tr("Played"));
34 setHeaderData(fieldIndex(LIBRARYTABLE_ARTIST),
35 Qt::Horizontal, tr("Artist"));
36 setHeaderData(fieldIndex(LIBRARYTABLE_TITLE),
37 Qt::Horizontal, tr("Title"));
38 setHeaderData(fieldIndex(LIBRARYTABLE_ALBUM),
39 Qt::Horizontal, tr("Album"));
40 setHeaderData(fieldIndex(LIBRARYTABLE_GENRE),
41 Qt::Horizontal, tr("Genre"));
42 setHeaderData(fieldIndex(LIBRARYTABLE_YEAR),
43 Qt::Horizontal, tr("Year"));
44 setHeaderData(fieldIndex(LIBRARYTABLE_FILETYPE),
45 Qt::Horizontal, tr("Type"));
46 setHeaderData(fieldIndex(LIBRARYTABLE_LOCATION),
47 Qt::Horizontal, tr("Location"));
48 setHeaderData(fieldIndex(LIBRARYTABLE_COMMENT),
49 Qt::Horizontal, tr("Comment"));
50 setHeaderData(fieldIndex(LIBRARYTABLE_DURATION),
51 Qt::Horizontal, tr("Duration"));
52 setHeaderData(fieldIndex(LIBRARYTABLE_RATING),
53 Qt::Horizontal, tr("Rating"));
54 setHeaderData(fieldIndex(LIBRARYTABLE_BITRATE),
55 Qt::Horizontal, tr("Bitrate"));
56 setHeaderData(fieldIndex(LIBRARYTABLE_BPM),
57 Qt::Horizontal, tr("BPM"));
58 setHeaderData(fieldIndex(LIBRARYTABLE_TRACKNUMBER),
59 Qt::Horizontal, tr("Track #"));
60 setHeaderData(fieldIndex(LIBRARYTABLE_DATETIMEADDED),
61 Qt::Horizontal, tr("Date Added"));
62 setHeaderData(fieldIndex(PLAYLISTTRACKSTABLE_POSITION),
63 Qt::Horizontal, tr("#"));
23}64}
2465
25bool BaseSqlTableModel::select() {66bool BaseSqlTableModel::select() {
@@ -48,9 +89,10 @@
48 return result;89 return result;
49}90}
5091
51QVariant BaseSqlTableModel::data(const QModelIndex& index, int role) const {92QVariant BaseSqlTableModel::getBaseValue(const QModelIndex& index, int role) const {
52 if (!index.isValid())93 if (!index.isValid()) {
53 return QVariant();94 return QVariant();
95 }
5496
55 int row = index.row();97 int row = index.row();
56 int col = index.column();98 int col = index.column();
@@ -62,7 +104,12 @@
62104
63 int trackId = m_rowToTrackId[row];105 int trackId = m_rowToTrackId[row];
64106
65 if (role == Qt::DisplayRole && m_trackOverrides.contains(trackId)) {107 /*
108 * The if-block below is only executed when a table item has been edited.
109 *
110 */
111 if ((role == Qt::DisplayRole || role == Qt::ToolTipRole || role == Qt::EditRole) &&
112 m_trackOverrides.contains(trackId)) {
66 //qDebug() << "Returning override for track" << trackId;113 //qDebug() << "Returning override for track" << trackId;
67 TrackPointer pTrack = m_trackDAO.getTrack(trackId);114 TrackPointer pTrack = m_trackDAO.getTrack(trackId);
68115
@@ -86,16 +133,146 @@
86 } else if (fieldIndex(LIBRARYTABLE_COMMENT) == col) {133 } else if (fieldIndex(LIBRARYTABLE_COMMENT) == col) {
87 return QVariant(pTrack->getComment());134 return QVariant(pTrack->getComment());
88 } else if (fieldIndex(LIBRARYTABLE_DURATION) == col) {135 } else if (fieldIndex(LIBRARYTABLE_DURATION) == col) {
89 return QVariant(pTrack->getDuration());136 return pTrack->getDuration();
90 } else if (fieldIndex(LIBRARYTABLE_BITRATE) == col) {137 } else if (fieldIndex(LIBRARYTABLE_BITRATE) == col) {
91 return QVariant(pTrack->getBitrate());138 return QVariant(pTrack->getBitrate());
92 } else if (fieldIndex(LIBRARYTABLE_BPM) == col) {139 } else if (fieldIndex(LIBRARYTABLE_BPM) == col) {
93 return QVariant(pTrack->getBpm());140 return QVariant(pTrack->getBpm());
141 } else if (fieldIndex(LIBRARYTABLE_PLAYED) == col) {
142 return QVariant(pTrack->getPlayed());
143 } else if (fieldIndex(LIBRARYTABLE_TIMESPLAYED) == col) {
144 return QVariant(pTrack->getTimesPlayed());
145 } else if (fieldIndex(LIBRARYTABLE_RATING) == col) {
146 return pTrack->getRating();
94 }147 }
95 }148 }
149
150 // If none of these work, hand off to the lower layer to deal with. The role
151 // might not be Edit/Display/ToolTip, or we might have a bug.
96 return QSqlTableModel::data(index, role);152 return QSqlTableModel::data(index, role);
97}153}
98154
155
156QVariant BaseSqlTableModel::data(const QModelIndex& index, int role) const {
157 if (!index.isValid()) {
158 return QVariant();
159 }
160
161 int row = index.row();
162 int col = index.column();
163
164 //qDebug() << "BaseSqlTableModel::data() column:" << col << "role:" << role;
165
166 // This value is the value in its most raw form. It was looked up either
167 // from the SQL table or from the cached track layer.
168 QVariant value = getBaseValue(index, role);
169
170 // Format the value based on whether we are in a tooltip, display, or edit
171 // role
172 if (role == Qt::ToolTipRole || role == Qt::DisplayRole) {
173 if (index.column() == fieldIndex(LIBRARYTABLE_DURATION)) {
174 if (qVariantCanConvert<int>(value))
175 value = MixxxUtils::secondsToMinutes(qVariantValue<int>(value));
176 } else if (index.column() == fieldIndex(LIBRARYTABLE_RATING)) {
177 if (qVariantCanConvert<int>(value))
178 value = qVariantFromValue(StarRating(value.toInt()));
179 } else if (index.column() == fieldIndex(LIBRARYTABLE_TIMESPLAYED)) {
180 if (qVariantCanConvert<int>(value))
181 value = QString("(%1)").arg(value.toInt());
182 } else if (index.column() == fieldIndex(LIBRARYTABLE_PLAYED)) {
183 // Convert to a bool. Not really that useful since it gets converted
184 // right back to a QVariant
185 value = (value == "true") ? true : false;
186 }
187 } else if (role == Qt::EditRole) {
188 if (index.column() == fieldIndex(LIBRARYTABLE_BPM)) {
189 return value.toDouble();
190 } else if (index.column() == fieldIndex(LIBRARYTABLE_TIMESPLAYED)) {
191 return index.sibling(index.row(), fieldIndex(LIBRARYTABLE_PLAYED)).data().toBool();
192 } else if (index.column() == fieldIndex(LIBRARYTABLE_RATING)) {
193 if (qVariantCanConvert<int>(value))
194 value = qVariantFromValue(StarRating(value.toInt()));
195 }
196 } else if (role == Qt::CheckStateRole) {
197 if (index.column() == fieldIndex(LIBRARYTABLE_TIMESPLAYED)) {
198 bool played = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_PLAYED)).data().toBool();
199 value = played ? Qt::Checked : Qt::Unchecked;
200 }
201 }
202
203 return value;
204}
205
206bool BaseSqlTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
207{
208 if (!index.isValid())
209 return false;
210
211 int row = index.row();
212 int col = index.column();
213
214 //qDebug() << "BaseSqlTableModel::setData() column:" << col << "value:" << value << "role:" << role;
215
216 // Over-ride sets to TIMESPLAYED and re-direct them to PLAYED
217 if (role == Qt::CheckStateRole) {
218 if (index.column() == fieldIndex(LIBRARYTABLE_TIMESPLAYED)) {
219 QString val = value.toInt() > 0 ? QString("true") : QString("false");
220 QModelIndex playedIndex = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_PLAYED));
221 return setData(playedIndex, val, Qt::EditRole);
222 }
223 }
224
225 Q_ASSERT(m_rowToTrackId.contains(row));
226 if (!m_rowToTrackId.contains(row)) {
227 return QSqlTableModel::setData(index, value, role);
228 }
229
230 int trackId = m_rowToTrackId[row];
231 TrackPointer pTrack = m_trackDAO.getTrack(trackId);
232
233 // TODO(XXX) Qt properties could really help here.
234 if (fieldIndex(LIBRARYTABLE_ARTIST) == col) {
235 pTrack->setArtist(value.toString());
236 } else if (fieldIndex(LIBRARYTABLE_TITLE) == col) {
237 pTrack->setTitle(value.toString());
238 } else if (fieldIndex(LIBRARYTABLE_ALBUM) == col) {
239 pTrack->setAlbum(value.toString());
240 } else if (fieldIndex(LIBRARYTABLE_YEAR) == col) {
241 pTrack->setYear(value.toString());
242 } else if (fieldIndex(LIBRARYTABLE_GENRE) == col) {
243 pTrack->setGenre(value.toString());
244 } else if (fieldIndex(LIBRARYTABLE_FILETYPE) == col) {
245 pTrack->setType(value.toString());
246 } else if (fieldIndex(LIBRARYTABLE_TRACKNUMBER) == col) {
247 pTrack->setTrackNumber(value.toString());
248 } else if (fieldIndex(LIBRARYTABLE_LOCATION) == col) {
249 pTrack->setLocation(value.toString());
250 } else if (fieldIndex(LIBRARYTABLE_COMMENT) == col) {
251 pTrack->setComment(value.toString());
252 } else if (fieldIndex(LIBRARYTABLE_DURATION) == col) {
253 pTrack->setDuration(value.toInt());
254 } else if (fieldIndex(LIBRARYTABLE_BITRATE) == col) {
255 pTrack->setBitrate(value.toInt());
256 } else if (fieldIndex(LIBRARYTABLE_BPM) == col) {
257 //QVariant::toFloat needs >= QT 4.6.x
258 pTrack->setBpm((float) value.toDouble());
259 } else if (fieldIndex(LIBRARYTABLE_PLAYED) == col) {
260 pTrack->setPlayed(value.toBool());
261 } else if (fieldIndex(LIBRARYTABLE_TIMESPLAYED) == col) {
262 pTrack->setTimesPlayed(value.toInt());
263 } else if (fieldIndex(LIBRARYTABLE_RATING) == col) {
264 StarRating starRating = qVariantValue<StarRating>(value);
265 pTrack->setRating(starRating.starCount());
266 }
267
268 // Do not save the track here. Changing the track dirties it and the caching
269 // system will automatically save the track once it is unloaded from
270 // memory. rryan 10/2010
271 //m_trackDAO.saveTrack(pTrack);
272
273 return true;
274}
275
99void BaseSqlTableModel::trackChanged(int trackId) {276void BaseSqlTableModel::trackChanged(int trackId) {
100 m_trackOverrides.insert(trackId);277 m_trackOverrides.insert(trackId);
101 if (m_trackIdToRow.contains(trackId)) {278 if (m_trackIdToRow.contains(trackId)) {
@@ -129,7 +306,7 @@
129306
130 QString table = m_qTableName;307 QString table = m_qTableName;
131 QString field = database().driver()->escapeIdentifier(f.name(),308 QString field = database().driver()->escapeIdentifier(f.name(),
132 QSqlDriver::FieldName);309 QSqlDriver::FieldName);
133 s.append(QLatin1String("ORDER BY "));310 s.append(QLatin1String("ORDER BY "));
134 QString sort_field = QString("%1.%2").arg(table).arg(field);311 QString sort_field = QString("%1.%2").arg(table).arg(field);
135312
@@ -149,3 +326,48 @@
149 s += m_eSortOrder == Qt::AscendingOrder ? QLatin1String(" ASC") : QLatin1String(" DESC");326 s += m_eSortOrder == Qt::AscendingOrder ? QLatin1String(" ASC") : QLatin1String(" DESC");
150 return s;327 return s;
151}328}
329
330Qt::ItemFlags BaseSqlTableModel::readWriteFlags(const QModelIndex &index) const
331{
332 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
333 if (!index.isValid())
334 return Qt::ItemIsEnabled;
335
336 //Enable dragging songs from this data model to elsewhere (like the waveform
337 //widget to load a track into a Player).
338 defaultFlags |= Qt::ItemIsDragEnabled;
339
340 if ( index.column() == fieldIndex(LIBRARYTABLE_FILETYPE)
341 || index.column() == fieldIndex(LIBRARYTABLE_LOCATION)
342 || index.column() == fieldIndex(LIBRARYTABLE_DURATION)
343 || index.column() == fieldIndex(LIBRARYTABLE_BITRATE)
344 || index.column() == fieldIndex(LIBRARYTABLE_DATETIMEADDED))
345 {
346 return defaultFlags | QAbstractItemModel::flags(index);
347 }
348 else if (index.column() == fieldIndex(LIBRARYTABLE_TIMESPLAYED)) {
349 return defaultFlags | QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable;
350 }
351 else {
352 return defaultFlags | QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
353 }
354}
355
356Qt::ItemFlags BaseSqlTableModel::readOnlyFlags(const QModelIndex &index) const
357{
358 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
359 if (!index.isValid())
360 return Qt::ItemIsEnabled;
361
362 //Enable dragging songs from this data model to elsewhere (like the waveform widget to
363 //load a track into a Player).
364 defaultFlags |= Qt::ItemIsDragEnabled;
365
366 return defaultFlags;
367
368}
369
370Qt::ItemFlags BaseSqlTableModel::flags(const QModelIndex &index) const
371{
372 return readWriteFlags(index);
373}
152374
=== modified file 'mixxx/src/library/basesqltablemodel.h'
--- mixxx/src/library/basesqltablemodel.h 2010-07-15 19:07:16 +0000
+++ mixxx/src/library/basesqltablemodel.h 2010-10-19 05:33:52 +0000
@@ -23,12 +23,21 @@
23 virtual void setSort(int column, Qt::SortOrder order);23 virtual void setSort(int column, Qt::SortOrder order);
24 virtual bool select();24 virtual bool select();
25 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;25 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
2626 virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
27 /** Use this if you want a model that is read-only. */
28 virtual Qt::ItemFlags readOnlyFlags(const QModelIndex &index) const;
29 /** Use this if you want a model that can be changed */
30 virtual Qt::ItemFlags readWriteFlags(const QModelIndex &index) const;
31 /** calls readWriteFlags() by default */
32 virtual Qt::ItemFlags flags(const QModelIndex &index) const;
27 protected:33 protected:
28 virtual QString orderByClause() const;34 virtual QString orderByClause() const;
35 virtual void initHeaderData();
29 private slots:36 private slots:
30 void trackChanged(int trackId);37 void trackChanged(int trackId);
31 private:38 private:
39 QVariant getBaseValue(const QModelIndex& index, int role = Qt::DisplayRole) const;
40
32 QString m_qTableName;41 QString m_qTableName;
33 int m_iSortColumn;42 int m_iSortColumn;
34 Qt::SortOrder m_eSortOrder;43 Qt::SortOrder m_eSortOrder;
3544
=== modified file 'mixxx/src/library/cratetablemodel.cpp'
--- mixxx/src/library/cratetablemodel.cpp 2010-09-14 20:32:32 +0000
+++ mixxx/src/library/cratetablemodel.cpp 2010-10-19 05:33:52 +0000
@@ -33,11 +33,14 @@
33 QString queryString = QString("CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS "33 QString queryString = QString("CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS "
34 "SELECT "34 "SELECT "
35 "library." + LIBRARYTABLE_ID + "," +35 "library." + LIBRARYTABLE_ID + "," +
36 LIBRARYTABLE_PLAYED + "," +
37 LIBRARYTABLE_TIMESPLAYED + "," +
36 LIBRARYTABLE_ARTIST + "," +38 LIBRARYTABLE_ARTIST + "," +
37 LIBRARYTABLE_TITLE + "," +39 LIBRARYTABLE_TITLE + "," +
38 LIBRARYTABLE_ALBUM + "," +40 LIBRARYTABLE_ALBUM + "," +
39 LIBRARYTABLE_YEAR + "," +41 LIBRARYTABLE_YEAR + "," +
40 LIBRARYTABLE_DURATION + "," +42 LIBRARYTABLE_DURATION + "," +
43 LIBRARYTABLE_RATING + "," +
41 LIBRARYTABLE_GENRE + "," +44 LIBRARYTABLE_GENRE + "," +
42 LIBRARYTABLE_FILETYPE + "," +45 LIBRARYTABLE_FILETYPE + "," +
43 LIBRARYTABLE_TRACKNUMBER + "," +46 LIBRARYTABLE_TRACKNUMBER + "," +
@@ -69,34 +72,8 @@
6972
70 select();73 select();
7174
72 setHeaderData(fieldIndex(LIBRARYTABLE_ID),75 // BaseSqlTableModel sets up the header names
73 Qt::Horizontal, tr("ID"));76 initHeaderData();
74 setHeaderData(fieldIndex(LIBRARYTABLE_ARTIST),
75 Qt::Horizontal, tr("Artist"));
76 setHeaderData(fieldIndex(LIBRARYTABLE_TITLE),
77 Qt::Horizontal, tr("Title"));
78 setHeaderData(fieldIndex(LIBRARYTABLE_ALBUM),
79 Qt::Horizontal, tr("Album"));
80 setHeaderData(fieldIndex(LIBRARYTABLE_GENRE),
81 Qt::Horizontal, tr("Genre"));
82 setHeaderData(fieldIndex(LIBRARYTABLE_YEAR),
83 Qt::Horizontal, tr("Year"));
84 setHeaderData(fieldIndex(LIBRARYTABLE_FILETYPE),
85 Qt::Horizontal, tr("Type"));
86 setHeaderData(fieldIndex("location"),
87 Qt::Horizontal, tr("Location"));
88 setHeaderData(fieldIndex(LIBRARYTABLE_COMMENT),
89 Qt::Horizontal, tr("Comment"));
90 setHeaderData(fieldIndex(LIBRARYTABLE_DURATION),
91 Qt::Horizontal, tr("Duration"));
92 setHeaderData(fieldIndex(LIBRARYTABLE_TRACKNUMBER),
93 Qt::Horizontal, tr("Track #"));
94 setHeaderData(fieldIndex(LIBRARYTABLE_BITRATE),
95 Qt::Horizontal, tr("Bitrate"));
96 setHeaderData(fieldIndex(LIBRARYTABLE_BPM),
97 Qt::Horizontal, tr("BPM"));
98 setHeaderData(fieldIndex(LIBRARYTABLE_DATETIMEADDED),
99 Qt::Horizontal, tr("Date Added"));
100}77}
10178
102bool CrateTableModel::addTrack(const QModelIndex& index, QString location) {79bool CrateTableModel::addTrack(const QModelIndex& index, QString location) {
@@ -186,12 +163,22 @@
186 filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + ")";163 filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + ")";
187 else {164 else {
188 QSqlField search("search", QVariant::String);165 QSqlField search("search", QVariant::String);
189 search.setValue("%" + searchText + "%");166
190 QString escapedText = database().driver()->formatValue(search);167
191 filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + " AND " +168 filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER;
192 "(artist LIKE " + escapedText + " OR " +169
193 "album LIKE " + escapedText + " OR " +170 foreach(QString term, searchText.split(" "))
194 "title LIKE " + escapedText + "))";171 {
172 search.setValue("%" + term + "%");
173 QString escapedText = database().driver()->formatValue(search);
174 filter += " AND (artist LIKE " + escapedText + " OR " +
175 "album LIKE " + escapedText + " OR " +
176 "location LIKE " + escapedText + " OR " +
177 "comment LIKE " + escapedText + " OR " +
178 "title LIKE " + escapedText + ")";
179 }
180
181 filter += ")";
195 }182 }
196183
197 setFilter(filter);184 setFilter(filter);
@@ -203,6 +190,7 @@
203190
204bool CrateTableModel::isColumnInternal(int column) {191bool CrateTableModel::isColumnInternal(int column) {
205 if (column == fieldIndex(LIBRARYTABLE_ID) ||192 if (column == fieldIndex(LIBRARYTABLE_ID) ||
193 column == fieldIndex(LIBRARYTABLE_PLAYED) ||
206 column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) ||194 column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) ||
207 column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED)) {195 column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED)) {
208 return true;196 return true;
@@ -235,42 +223,10 @@
235 return mimeData;223 return mimeData;
236}224}
237225
238Qt::ItemFlags CrateTableModel::flags(const QModelIndex& index) const {
239 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
240 if (!index.isValid())
241 return Qt::ItemIsEnabled;
242
243 //Enable dragging songs from this data model to elsewhere (like the waveform
244 //widget to load a track into a Player).
245 defaultFlags |= Qt::ItemIsDragEnabled;
246
247 return defaultFlags;
248}
249
250QItemDelegate* CrateTableModel::delegateForColumn(int i) {226QItemDelegate* CrateTableModel::delegateForColumn(int i) {
251 return NULL;227 return NULL;
252}228}
253229
254QVariant CrateTableModel::data(const QModelIndex& item, int role) const {
255 if (!item.isValid())
256 return QVariant();
257
258 QVariant value;
259
260 if (role == Qt::ToolTipRole)
261 value = BaseSqlTableModel::data(item, Qt::DisplayRole);
262 else
263 value = BaseSqlTableModel::data(item, role);
264
265 if ((role == Qt::DisplayRole || role == Qt::ToolTipRole) &&
266 item.column() == fieldIndex(LIBRARYTABLE_DURATION)) {
267 if (qVariantCanConvert<int>(value)) {
268 value = MixxxUtils::secondsToMinutes(qVariantValue<int>(value));
269 }
270 }
271 return value;
272}
273
274TrackModel::CapabilitiesFlags CrateTableModel::getCapabilities() const {230TrackModel::CapabilitiesFlags CrateTableModel::getCapabilities() const {
275 return TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_ADDTOPLAYLIST |231 return TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_ADDTOPLAYLIST |
276 TRACKMODELCAPS_ADDTOCRATE | TRACKMODELCAPS_ADDTOAUTODJ;232 TRACKMODELCAPS_ADDTOCRATE | TRACKMODELCAPS_ADDTOAUTODJ;
277233
=== modified file 'mixxx/src/library/cratetablemodel.h'
--- mixxx/src/library/cratetablemodel.h 2010-09-13 06:23:38 +0000
+++ mixxx/src/library/cratetablemodel.h 2010-10-19 05:33:52 +0000
@@ -20,9 +20,7 @@
2020
21 void setCrate(int crateId);21 void setCrate(int crateId);
2222
23 virtual QVariant data(const QModelIndex& item, int role) const;
24 QMimeData* mimeData(const QModelIndexList &indexes) const;23 QMimeData* mimeData(const QModelIndexList &indexes) const;
25 Qt::ItemFlags flags(const QModelIndex &index) const;
2624
27 // From TrackModel25 // From TrackModel
28 virtual TrackPointer getTrack(const QModelIndex& index) const;26 virtual TrackPointer getTrack(const QModelIndex& index) const;
2927
=== modified file 'mixxx/src/library/dao/trackdao.cpp'
--- mixxx/src/library/dao/trackdao.cpp 2010-09-17 04:15:33 +0000
+++ mixxx/src/library/dao/trackdao.cpp 2010-10-19 05:33:52 +0000
@@ -19,6 +19,18 @@
1919
20}20}
2121
22void TrackDAO::finish()
23{
24 //clear out played information on exit
25 //crash prevention: if mixxx crashes, played information will be maintained
26 qDebug() << "Clearing played information for this session";
27 QSqlQuery query(m_database);
28 if (!query.exec("UPDATE library SET played=0"))
29 {
30 qDebug() << "Error clearing played value";
31 }
32}
33
22TrackDAO::~TrackDAO()34TrackDAO::~TrackDAO()
23{35{
24}36}
@@ -187,13 +199,15 @@
187199
188void TrackDAO::prepareLibraryInsert(QSqlQuery& query) {200void TrackDAO::prepareLibraryInsert(QSqlQuery& query) {
189 query.prepare("INSERT INTO library (artist, title, album, year, genre, tracknumber, "201 query.prepare("INSERT INTO library (artist, title, album, year, genre, tracknumber, "
190 "filetype, location, comment, url, duration, "202 "filetype, location, comment, url, duration, rating, "
191 "bitrate, samplerate, cuepoint, bpm, wavesummaryhex, "203 "bitrate, samplerate, cuepoint, bpm, wavesummaryhex, "
204 "timesplayed, "
192 "channels, mixxx_deleted, header_parsed) "205 "channels, mixxx_deleted, header_parsed) "
193 "VALUES (:artist, "206 "VALUES (:artist, "
194 ":title, :album, :year, :genre, :tracknumber, "207 ":title, :album, :year, :genre, :tracknumber, "
195 ":filetype, :location, :comment, :url, :duration, "208 ":filetype, :location, :comment, :url, :duration, :rating,"
196 ":bitrate, :samplerate, :cuepoint, :bpm, :wavesummaryhex, "209 ":bitrate, :samplerate, :cuepoint, :bpm, :wavesummaryhex, "
210 ":timesplayed, "
197 ":channels, :mixxx_deleted, :header_parsed)");211 ":channels, :mixxx_deleted, :header_parsed)");
198}212}
199213
@@ -209,6 +223,7 @@
209 query.bindValue(":comment", pTrack->getComment());223 query.bindValue(":comment", pTrack->getComment());
210 query.bindValue(":url", pTrack->getURL());224 query.bindValue(":url", pTrack->getURL());
211 query.bindValue(":duration", pTrack->getDuration());225 query.bindValue(":duration", pTrack->getDuration());
226 query.bindValue(":rating", pTrack->getRating());
212 query.bindValue(":bitrate", pTrack->getBitrate());227 query.bindValue(":bitrate", pTrack->getBitrate());
213 query.bindValue(":samplerate", pTrack->getSampleRate());228 query.bindValue(":samplerate", pTrack->getSampleRate());
214 query.bindValue(":cuepoint", pTrack->getCuePoint());229 query.bindValue(":cuepoint", pTrack->getCuePoint());
@@ -216,7 +231,7 @@
216 const QByteArray* pWaveSummary = pTrack->getWaveSummary();231 const QByteArray* pWaveSummary = pTrack->getWaveSummary();
217 if (pWaveSummary) //Avoid null pointer deref232 if (pWaveSummary) //Avoid null pointer deref
218 query.bindValue(":wavesummaryhex", *pWaveSummary);233 query.bindValue(":wavesummaryhex", *pWaveSummary);
219 //query.bindValue(":timesplayed", pTrack->getCuePoint());234 query.bindValue(":timesplayed", pTrack->getTimesPlayed());
220 //query.bindValue(":datetime_added", pTrack->getDateAdded());235 //query.bindValue(":datetime_added", pTrack->getDateAdded());
221 query.bindValue(":channels", pTrack->getChannels());236 query.bindValue(":channels", pTrack->getChannels());
222 query.bindValue(":mixxx_deleted", 0);237 query.bindValue(":mixxx_deleted", 0);
@@ -322,7 +337,7 @@
322 time.start();337 time.start();
323338
324 //qDebug() << "TrackDAO::addTrack" << QThread::currentThread() << m_database.connectionName();339 //qDebug() << "TrackDAO::addTrack" << QThread::currentThread() << m_database.connectionName();
325 //qDebug() << "TrackCollection::addTrack(), inserting into DB";340 //qDebug() << "TrackCollection::addTrack(), inserting into DB";
326 Q_ASSERT(pTrack); //Why you be giving me NULL pTracks341 Q_ASSERT(pTrack); //Why you be giving me NULL pTracks
327342
328 //Start the transaction343 //Start the transaction
@@ -500,12 +515,14 @@
500 QString url = query.value(query.record().indexOf("url")).toString();515 QString url = query.value(query.record().indexOf("url")).toString();
501 int duration = query.value(query.record().indexOf("duration")).toInt();516 int duration = query.value(query.record().indexOf("duration")).toInt();
502 int bitrate = query.value(query.record().indexOf("bitrate")).toInt();517 int bitrate = query.value(query.record().indexOf("bitrate")).toInt();
518 int rating = query.value(query.record().indexOf("rating")).toInt();
503 int samplerate = query.value(query.record().indexOf("samplerate")).toInt();519 int samplerate = query.value(query.record().indexOf("samplerate")).toInt();
504 int cuepoint = query.value(query.record().indexOf("cuepoint")).toInt();520 int cuepoint = query.value(query.record().indexOf("cuepoint")).toInt();
505 QString bpm = query.value(query.record().indexOf("bpm")).toString();521 QString bpm = query.value(query.record().indexOf("bpm")).toString();
506 QByteArray* wavesummaryhex = new QByteArray(522 QByteArray* wavesummaryhex = new QByteArray(
507 query.value(query.record().indexOf("wavesummaryhex")).toByteArray());523 query.value(query.record().indexOf("wavesummaryhex")).toByteArray());
508 //int timesplayed = query.value(query.record().indexOf("timesplayed")).toInt();524 int timesplayed = query.value(query.record().indexOf("timesplayed")).toInt();
525 int played = query.value(query.record().indexOf("played")).toInt();
509 int channels = query.value(query.record().indexOf("channels")).toInt();526 int channels = query.value(query.record().indexOf("channels")).toInt();
510 int filesize = query.value(query.record().indexOf("filesize")).toInt();527 int filesize = query.value(query.record().indexOf("filesize")).toInt();
511 QString filetype = query.value(query.record().indexOf("filetype")).toString();528 QString filetype = query.value(query.record().indexOf("filetype")).toString();
@@ -525,6 +542,7 @@
525 track->setYear(year);542 track->setYear(year);
526 track->setGenre(genre);543 track->setGenre(genre);
527 track->setTrackNumber(tracknumber);544 track->setTrackNumber(tracknumber);
545 track->setRating(rating);
528546
529 track->setComment(comment);547 track->setComment(comment);
530 track->setURL(url);548 track->setURL(url);
@@ -535,7 +553,8 @@
535 track->setBpm(bpm.toFloat());553 track->setBpm(bpm.toFloat());
536 track->setWaveSummary(wavesummaryhex, false);554 track->setWaveSummary(wavesummaryhex, false);
537 delete wavesummaryhex;555 delete wavesummaryhex;
538 //track->setTimesPlayed //Doesn't exist wtfbbq556 track->setTimesPlayed(timesplayed);
557 track->setPlayed(played);
539 track->setChannels(channels);558 track->setChannels(channels);
540 track->setType(filetype);559 track->setType(filetype);
541 track->setLocation(location);560 track->setLocation(location);
@@ -607,7 +626,8 @@
607 time.start();626 time.start();
608 QSqlQuery query(m_database);627 QSqlQuery query(m_database);
609628
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));
630
611 TrackPointer pTrack;631 TrackPointer pTrack;
612632
613 if (query.exec()) {633 if (query.exec()) {
@@ -641,9 +661,10 @@
641 "SET artist=:artist, "661 "SET artist=:artist, "
642 "title=:title, album=:album, year=:year, genre=:genre, "662 "title=:title, album=:album, year=:year, genre=:genre, "
643 "filetype=:filetype, tracknumber=:tracknumber, "663 "filetype=:filetype, tracknumber=:tracknumber, "
644 "comment=:comment, url=:url, duration=:duration, "664 "comment=:comment, url=:url, duration=:duration, rating=:rating, "
645 "bitrate=:bitrate, samplerate=:samplerate, cuepoint=:cuepoint, "665 "bitrate=:bitrate, samplerate=:samplerate, cuepoint=:cuepoint, "
646 "bpm=:bpm, wavesummaryhex=:wavesummaryhex, "666 "bpm=:bpm, wavesummaryhex=:wavesummaryhex, "
667 "timesplayed=:timesplayed, played=:played, "
647 "channels=:channels, header_parsed=:header_parsed "668 "channels=:channels, header_parsed=:header_parsed "
648 "WHERE id="+QString("%1").arg(trackId));669 "WHERE id="+QString("%1").arg(trackId));
649 query.bindValue(":artist", pTrack->getArtist());670 query.bindValue(":artist", pTrack->getArtist());
@@ -660,10 +681,12 @@
660 query.bindValue(":samplerate", pTrack->getSampleRate());681 query.bindValue(":samplerate", pTrack->getSampleRate());
661 query.bindValue(":cuepoint", pTrack->getCuePoint());682 query.bindValue(":cuepoint", pTrack->getCuePoint());
662 query.bindValue(":bpm", pTrack->getBpm());683 query.bindValue(":bpm", pTrack->getBpm());
684 query.bindValue(":rating", pTrack->getRating());
663 const QByteArray* pWaveSummary = pTrack->getWaveSummary();685 const QByteArray* pWaveSummary = pTrack->getWaveSummary();
664 if (pWaveSummary) //Avoid null pointer deref686 if (pWaveSummary) //Avoid null pointer deref
665 query.bindValue(":wavesummaryhex", *pWaveSummary);687 query.bindValue(":wavesummaryhex", *pWaveSummary);
666 //query.bindValue(":timesplayed", pTrack->getCuePoint());688 query.bindValue(":timesplayed", pTrack->getTimesPlayed());
689 query.bindValue(":played", pTrack->getPlayed());
667 query.bindValue(":channels", pTrack->getChannels());690 query.bindValue(":channels", pTrack->getChannels());
668 query.bindValue(":header_parsed", pTrack->getHeaderParsed() ? 1 : 0);691 query.bindValue(":header_parsed", pTrack->getHeaderParsed() ? 1 : 0);
669 //query.bindValue(":location", pTrack->getLocation());692 //query.bindValue(":location", pTrack->getLocation());
670693
=== modified file 'mixxx/src/library/dao/trackdao.h'
--- mixxx/src/library/dao/trackdao.h 2010-09-13 06:23:38 +0000
+++ mixxx/src/library/dao/trackdao.h 2010-10-19 05:33:52 +0000
@@ -38,6 +38,9 @@
38const QString LIBRARYTABLE_MIXXXDELETED = "mixxx_deleted";38const QString LIBRARYTABLE_MIXXXDELETED = "mixxx_deleted";
39const QString LIBRARYTABLE_DATETIMEADDED = "datetime_added";39const QString LIBRARYTABLE_DATETIMEADDED = "datetime_added";
40const QString LIBRARYTABLE_HEADERPARSED = "header_parsed";40const QString LIBRARYTABLE_HEADERPARSED = "header_parsed";
41const QString LIBRARYTABLE_TIMESPLAYED = "timesplayed";
42const QString LIBRARYTABLE_PLAYED = "played";
43const QString LIBRARYTABLE_RATING = "rating";
4144
42const QString TRACKLOCATIONSTABLE_ID = "id";45const QString TRACKLOCATIONSTABLE_ID = "id";
43const QString TRACKLOCATIONSTABLE_LOCATION = "location";46const QString TRACKLOCATIONSTABLE_LOCATION = "location";
@@ -52,6 +55,7 @@
52 public:55 public:
53 //TrackDAO() {};56 //TrackDAO() {};
54 TrackDAO(QSqlDatabase& database, CueDAO& cueDao);57 TrackDAO(QSqlDatabase& database, CueDAO& cueDao);
58 void finish();
55 virtual ~TrackDAO();59 virtual ~TrackDAO();
56 void setDatabase(QSqlDatabase& database) { m_database = database; };60 void setDatabase(QSqlDatabase& database) { m_database = database; };
5761
5862
=== modified file 'mixxx/src/library/legacylibraryimporter.cpp'
--- mixxx/src/library/legacylibraryimporter.cpp 2010-09-11 08:15:14 +0000
+++ mixxx/src/library/legacylibraryimporter.cpp 2010-10-19 05:33:52 +0000
@@ -174,9 +174,16 @@
174 }174 }
175 }175 }
176176
177 //now change the file to mixxxtrack.bak so that its not readded next time program loads177 QString upgrade_filename = QDir::homePath().append("/").append(SETTINGS_PATH).append("DBUPGRADED");
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
179 file.remove();179 QFile upgradefile(upgrade_filename);
180 if (!upgradefile.open(QIODevice::WriteOnly | QIODevice::Text))
181 qDebug() << "Couldn't open" << upgrade_filename << "for writing";
182 else
183 {
184 file.write("",0);
185 file.close();
186 }
180 } else {187 } else {
181 qDebug() << errorMsg << " line: " << errorLine << " column: " << errorColumn;188 qDebug() << errorMsg << " line: " << errorLine << " column: " << errorColumn;
182 }189 }
183190
=== modified file 'mixxx/src/library/libraryscanner.cpp'
--- mixxx/src/library/libraryscanner.cpp 2010-09-18 19:30:15 +0000
+++ mixxx/src/library/libraryscanner.cpp 2010-10-19 05:33:52 +0000
@@ -55,10 +55,10 @@
55 */55 */
56 QString iTunesArtFolder = "";56 QString iTunesArtFolder = "";
57#if defined(__WINDOWS__)57#if defined(__WINDOWS__)
58 iTunesArtFolder = QDesktopServices::storageLocation(QDesktopServices::MusicLocation) + "\\iTunes\\Album Artwork";58 iTunesArtFolder = QDesktopServices::storageLocation(QDesktopServices::MusicLocation) + "\\iTunes\\Album Artwork";
59 iTunesArtFolder.replace(QString("\\"), QString("/"));59 iTunesArtFolder.replace(QString("\\"), QString("/"));
60#elif defined(__APPLE__)60#elif defined(__APPLE__)
61 iTunesArtFolder = QDesktopServices::storageLocation(QDesktopServices::MusicLocation) + "/iTunes/Album Artwork";61 iTunesArtFolder = QDesktopServices::storageLocation(QDesktopServices::MusicLocation) + "/iTunes/Album Artwork";
62#endif62#endif
63 m_directoriesBlacklist << iTunesArtFolder;63 m_directoriesBlacklist << iTunesArtFolder;
64 qDebug() << "iTunes Album Art path is:" << iTunesArtFolder;64 qDebug() << "iTunes Album Art path is:" << iTunesArtFolder;
@@ -109,7 +109,7 @@
109109
110 //Print out any SQL error, if there was one.110 //Print out any SQL error, if there was one.
111 if (query.lastError().isValid()) {111 if (query.lastError().isValid()) {
112 qDebug() << query.lastError();112 qDebug() << query.lastError();
113 }113 }
114114
115 QString dir;115 QString dir;
@@ -167,15 +167,25 @@
167167
168 QTime t2;168 QTime t2;
169 t2.start();169 t2.start();
170 //Try to upgrade the library from 1.7 (XML) to 1.8+ (DB) if needed170
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
172 connect(&libImport, SIGNAL(progress(QString)),172 //upgrade_filename already exists, then do not try to upgrade since we have
173 m_pProgress, SLOT(slotUpdate(QString)),173 //already done it.
174 Qt::BlockingQueuedConnection);174 QString upgrade_filename = QDir::homePath().append("/").append(SETTINGS_PATH).append("DBUPGRADED");
175 m_database.transaction();175 qDebug() << "upgrade filename is " << upgrade_filename;
176 libImport.import();176 QFile upgradefile(upgrade_filename);
177 m_database.commit();177 if (!upgradefile.exists())
178 qDebug("Legacy importer took %d ms", t2.elapsed());178 {
179 LegacyLibraryImporter libImport(m_trackDao, m_playlistDao);
180 connect(&libImport, SIGNAL(progress(QString)),
181 m_pProgress, SLOT(slotUpdate(QString)),
182 Qt::BlockingQueuedConnection);
183 m_database.transaction();
184 libImport.import();
185 m_database.commit();
186 qDebug("Legacy importer took %d ms", t2.elapsed());
187
188 }
179189
180 //Refresh the name filters in case we loaded new190 //Refresh the name filters in case we loaded new
181 //SoundSource plugins.191 //SoundSource plugins.
182192
=== modified file 'mixxx/src/library/librarytablemodel.cpp'
--- mixxx/src/library/librarytablemodel.cpp 2010-09-14 20:32:32 +0000
+++ mixxx/src/library/librarytablemodel.cpp 2010-10-19 05:33:52 +0000
@@ -20,11 +20,14 @@
20 query.prepare("CREATE TEMPORARY VIEW IF NOT EXISTS library_view AS "20 query.prepare("CREATE TEMPORARY VIEW IF NOT EXISTS library_view AS "
21 "SELECT "21 "SELECT "
22 "library." + LIBRARYTABLE_ID + "," +22 "library." + LIBRARYTABLE_ID + "," +
23 "library." + LIBRARYTABLE_PLAYED + "," +
24 "library." + LIBRARYTABLE_TIMESPLAYED + "," +
23 "library." + LIBRARYTABLE_ARTIST + "," +25 "library." + LIBRARYTABLE_ARTIST + "," +
24 "library." + LIBRARYTABLE_TITLE + "," +26 "library." + LIBRARYTABLE_TITLE + "," +
25 "library." + LIBRARYTABLE_ALBUM + "," +27 "library." + LIBRARYTABLE_ALBUM + "," +
26 "library." + LIBRARYTABLE_YEAR + "," +28 "library." + LIBRARYTABLE_YEAR + "," +
27 "library." + LIBRARYTABLE_DURATION + "," +29 "library." + LIBRARYTABLE_DURATION + "," +
30 "library." + LIBRARYTABLE_RATING + "," +
28 "library." + LIBRARYTABLE_GENRE + "," +31 "library." + LIBRARYTABLE_GENRE + "," +
29 "library." + LIBRARYTABLE_FILETYPE + "," +32 "library." + LIBRARYTABLE_FILETYPE + "," +
30 "library." + LIBRARYTABLE_TRACKNUMBER + "," +33 "library." + LIBRARYTABLE_TRACKNUMBER + "," +
@@ -43,7 +46,7 @@
4346
44 //Print out any SQL error, if there was one.47 //Print out any SQL error, if there was one.
45 if (query.lastError().isValid()) {48 if (query.lastError().isValid()) {
46 qDebug() << __FILE__ << __LINE__ << query.lastError();49 qDebug() << __FILE__ << __LINE__ << query.lastError();
47 }50 }
4851
49 //setTable("library");52 //setTable("library");
@@ -56,34 +59,9 @@
56 //and shows it...59 //and shows it...
57 //setRelation(fieldIndex(LIBRARYTABLE_LOCATION), QSqlRelation("track_locations", "id", "location"));60 //setRelation(fieldIndex(LIBRARYTABLE_LOCATION), QSqlRelation("track_locations", "id", "location"));
5861
59 //Set the column heading labels, rename them for translations and have62
60 //proper capitalization63 // BaseSqlTabelModel will setup the header info
61 setHeaderData(fieldIndex(LIBRARYTABLE_ARTIST),64 initHeaderData();
62 Qt::Horizontal, tr("Artist"));
63 setHeaderData(fieldIndex(LIBRARYTABLE_TITLE),
64 Qt::Horizontal, tr("Title"));
65 setHeaderData(fieldIndex(LIBRARYTABLE_ALBUM),
66 Qt::Horizontal, tr("Album"));
67 setHeaderData(fieldIndex(LIBRARYTABLE_GENRE),
68 Qt::Horizontal, tr("Genre"));
69 setHeaderData(fieldIndex(LIBRARYTABLE_YEAR),
70 Qt::Horizontal, tr("Year"));
71 setHeaderData(fieldIndex(LIBRARYTABLE_FILETYPE),
72 Qt::Horizontal, tr("Type"));
73 setHeaderData(fieldIndex(LIBRARYTABLE_LOCATION),
74 Qt::Horizontal, tr("Location"));
75 setHeaderData(fieldIndex(LIBRARYTABLE_COMMENT),
76 Qt::Horizontal, tr("Comment"));
77 setHeaderData(fieldIndex(LIBRARYTABLE_DURATION),
78 Qt::Horizontal, tr("Duration"));
79 setHeaderData(fieldIndex(LIBRARYTABLE_BITRATE),
80 Qt::Horizontal, tr("Bitrate"));
81 setHeaderData(fieldIndex(LIBRARYTABLE_BPM),
82 Qt::Horizontal, tr("BPM"));
83 setHeaderData(fieldIndex(LIBRARYTABLE_TRACKNUMBER),
84 Qt::Horizontal, tr("Track #"));
85 setHeaderData(fieldIndex(LIBRARYTABLE_DATETIMEADDED),
86 Qt::Horizontal, tr("Date Added"));
8765
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).
89 slotSearch("");67 slotSearch("");
@@ -126,15 +104,15 @@
126104
127TrackPointer LibraryTableModel::getTrack(const QModelIndex& index) const105TrackPointer LibraryTableModel::getTrack(const QModelIndex& index) const
128{106{
129 int trackId = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_ID)).data().toInt();107 int trackId = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_ID)).data().toInt();
130 return m_trackDao.getTrack(trackId);108 return m_trackDao.getTrack(trackId);
131}109}
132110
133QString LibraryTableModel::getTrackLocation(const QModelIndex& index) const111QString LibraryTableModel::getTrackLocation(const QModelIndex& index) const
134{112{
135 const int locationColumnIndex = fieldIndex(LIBRARYTABLE_LOCATION);113 const int locationColumnIndex = fieldIndex(LIBRARYTABLE_LOCATION);
136 QString location = index.sibling(index.row(), locationColumnIndex).data().toString();114 QString location = index.sibling(index.row(), locationColumnIndex).data().toString();
137 return location;115 return location;
138}116}
139117
140void LibraryTableModel::removeTracks(const QModelIndexList& indices) {118void LibraryTableModel::removeTracks(const QModelIndexList& indices) {
@@ -152,9 +130,9 @@
152130
153void LibraryTableModel::removeTrack(const QModelIndex& index)131void LibraryTableModel::removeTrack(const QModelIndex& index)
154{132{
155 int trackId = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_ID)).data().toInt();133 int trackId = index.sibling(index.row(), fieldIndex(LIBRARYTABLE_ID)).data().toInt();
156 m_trackDao.removeTrack(trackId);134 m_trackDao.removeTrack(trackId);
157 select(); //Repopulate the data model.135 select(); //Repopulate the data model.
158}136}
159137
160void LibraryTableModel::moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex)138void LibraryTableModel::moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex)
@@ -181,12 +159,21 @@
181 filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + ")";159 filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + ")";
182 else {160 else {
183 QSqlField search("search", QVariant::String);161 QSqlField search("search", QVariant::String);
184 search.setValue("%" + searchText + "%");162
185 QString escapedText = database().driver()->formatValue(search);163 filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER;
186 filter = "(" + LibraryTableModel::DEFAULT_LIBRARYFILTER + " AND " +164
187 "(artist LIKE " + escapedText + " OR " +165 foreach(QString term, searchText.split(" "))
188 "album LIKE " + escapedText + " OR " +166 {
189 "title LIKE " + escapedText + "))";167 search.setValue("%" + term + "%");
168 QString escapedText = database().driver()->formatValue(search);
169 filter += " AND (artist LIKE " + escapedText + " OR " +
170 "album LIKE " + escapedText + " OR " +
171 "location LIKE " + escapedText + " OR " +
172 "comment LIKE " + escapedText + " OR " +
173 "title LIKE " + escapedText + ")";
174 }
175
176 filter += ")";
190 }177 }
191 setFilter(filter);178 setFilter(filter);
192}179}
@@ -205,6 +192,7 @@
205 (column == fieldIndex(LIBRARYTABLE_SAMPLERATE)) ||192 (column == fieldIndex(LIBRARYTABLE_SAMPLERATE)) ||
206 (column == fieldIndex(LIBRARYTABLE_MIXXXDELETED)) ||193 (column == fieldIndex(LIBRARYTABLE_MIXXXDELETED)) ||
207 (column == fieldIndex(LIBRARYTABLE_HEADERPARSED)) ||194 (column == fieldIndex(LIBRARYTABLE_HEADERPARSED)) ||
195 (column == fieldIndex(LIBRARYTABLE_PLAYED)) ||
208 (column == fieldIndex(LIBRARYTABLE_CHANNELS)) ||196 (column == fieldIndex(LIBRARYTABLE_CHANNELS)) ||
209 (column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED))) {197 (column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED))) {
210 return true;198 return true;
@@ -216,26 +204,6 @@
216 return NULL;204 return NULL;
217}205}
218206
219QVariant LibraryTableModel::data(const QModelIndex& item, int role) const {
220 if (!item.isValid())
221 return QVariant();
222
223 QVariant value;
224 if (role == Qt::ToolTipRole)
225 value = BaseSqlTableModel::data(item, Qt::DisplayRole);
226 else
227 value = BaseSqlTableModel::data(item, role);
228
229 if ((role == Qt::DisplayRole || role == Qt::ToolTipRole) &&
230 item.column() == fieldIndex(LIBRARYTABLE_DURATION)) {
231 if (qVariantCanConvert<int>(value)) {
232 value = MixxxUtils::secondsToMinutes(qVariantValue<int>(value));
233 }
234 }
235
236 return value;
237}
238
239QMimeData* LibraryTableModel::mimeData(const QModelIndexList &indexes) const {207QMimeData* LibraryTableModel::mimeData(const QModelIndexList &indexes) const {
240 QMimeData *mimeData = new QMimeData();208 QMimeData *mimeData = new QMimeData();
241 QList<QUrl> urls;209 QList<QUrl> urls;
@@ -263,26 +231,6 @@
263 return mimeData;231 return mimeData;
264}232}
265233
266Qt::ItemFlags LibraryTableModel::flags(const QModelIndex &index) const
267{
268 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
269 if (!index.isValid())
270 return Qt::ItemIsEnabled;
271
272 //Enable dragging songs from this data model to elsewhere (like the waveform
273 //widget to load a track into a Player).
274 defaultFlags |= Qt::ItemIsDragEnabled;
275
276 /** FIXME: This doesn't seem to work - Albert */
277 const int bpmColumnIndex = fieldIndex(LIBRARYTABLE_BPM);
278 if (index.column() == bpmColumnIndex)
279 {
280 return defaultFlags | Qt::ItemIsEditable;
281 }
282
283 return defaultFlags;
284}
285
286TrackModel::CapabilitiesFlags LibraryTableModel::getCapabilities() const234TrackModel::CapabilitiesFlags LibraryTableModel::getCapabilities() const
287{235{
288 return TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_ADDTOPLAYLIST |236 return TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_ADDTOPLAYLIST |
289237
=== modified file 'mixxx/src/library/librarytablemodel.h'
--- mixxx/src/library/librarytablemodel.h 2010-09-13 06:23:38 +0000
+++ mixxx/src/library/librarytablemodel.h 2010-10-19 05:33:52 +0000
@@ -27,11 +27,9 @@
27 virtual bool addTrack(const QModelIndex& index, QString location);27 virtual bool addTrack(const QModelIndex& index, QString location);
28 virtual void moveTrack(const QModelIndex& sourceIndex,28 virtual void moveTrack(const QModelIndex& sourceIndex,
29 const QModelIndex& destIndex);29 const QModelIndex& destIndex);
30 virtual QVariant data(const QModelIndex& item, int role) const;
3130
3231
33 QMimeData* mimeData(const QModelIndexList &indexes) const;32 QMimeData* mimeData(const QModelIndexList &indexes) const;
34 Qt::ItemFlags flags(const QModelIndex &index) const;
35 QItemDelegate* delegateForColumn(const int i);33 QItemDelegate* delegateForColumn(const int i);
36 TrackModel::CapabilitiesFlags getCapabilities() const;34 TrackModel::CapabilitiesFlags getCapabilities() const;
37 static const QString DEFAULT_LIBRARYFILTER;35 static const QString DEFAULT_LIBRARYFILTER;
3836
=== modified file 'mixxx/src/library/missingtablemodel.cpp'
--- mixxx/src/library/missingtablemodel.cpp 2010-09-14 20:32:32 +0000
+++ mixxx/src/library/missingtablemodel.cpp 2010-10-19 05:33:52 +0000
@@ -25,11 +25,14 @@
25 query.prepare("CREATE TEMPORARY VIEW IF NOT EXISTS " + tableName + " AS "25 query.prepare("CREATE TEMPORARY VIEW IF NOT EXISTS " + tableName + " AS "
26 "SELECT " +26 "SELECT " +
27 "library." + LIBRARYTABLE_ID + "," +27 "library." + LIBRARYTABLE_ID + "," +
28 "library." + LIBRARYTABLE_PLAYED + "," +
29 "library." + LIBRARYTABLE_TIMESPLAYED + "," +
28 "library." + LIBRARYTABLE_ARTIST + "," +30 "library." + LIBRARYTABLE_ARTIST + "," +
29 "library." + LIBRARYTABLE_TITLE + "," +31 "library." + LIBRARYTABLE_TITLE + "," +
30 "library." + LIBRARYTABLE_ALBUM + "," +32 "library." + LIBRARYTABLE_ALBUM + "," +
31 "library." + LIBRARYTABLE_YEAR + "," +33 "library." + LIBRARYTABLE_YEAR + "," +
32 "library." + LIBRARYTABLE_DURATION + "," +34 "library." + LIBRARYTABLE_DURATION + "," +
35 "library." + LIBRARYTABLE_RATING + "," +
33 "library." + LIBRARYTABLE_GENRE + "," +36 "library." + LIBRARYTABLE_GENRE + "," +
34 "library." + LIBRARYTABLE_FILETYPE + "," +37 "library." + LIBRARYTABLE_FILETYPE + "," +
35 "library." + LIBRARYTABLE_TRACKNUMBER + "," +38 "library." + LIBRARYTABLE_TRACKNUMBER + "," +
@@ -58,36 +61,7 @@
5861
59 qDebug() << "Created MissingTracksModel!";62 qDebug() << "Created MissingTracksModel!";
6063
61 //Set the column heading labels, rename them for translations and have64 initHeaderData(); //derived from BaseSqlModel
62 //proper capitalization
63 setHeaderData(fieldIndex("track_locations.location"),
64 Qt::Horizontal, tr("Location"));
65 setHeaderData(fieldIndex(LIBRARYTABLE_ARTIST),
66 Qt::Horizontal, tr("Artist"));
67 setHeaderData(fieldIndex(LIBRARYTABLE_TITLE),
68 Qt::Horizontal, tr("Title"));
69 setHeaderData(fieldIndex(LIBRARYTABLE_ALBUM),
70 Qt::Horizontal, tr("Album"));
71 setHeaderData(fieldIndex(LIBRARYTABLE_GENRE),
72 Qt::Horizontal, tr("Genre"));
73 setHeaderData(fieldIndex(LIBRARYTABLE_YEAR),
74 Qt::Horizontal, tr("Year"));
75 setHeaderData(fieldIndex(LIBRARYTABLE_FILETYPE),
76 Qt::Horizontal, tr("Type"));
77 setHeaderData(fieldIndex(LIBRARYTABLE_LOCATION),
78 Qt::Horizontal, tr("Location"));
79 setHeaderData(fieldIndex(LIBRARYTABLE_COMMENT),
80 Qt::Horizontal, tr("Comment"));
81 setHeaderData(fieldIndex(LIBRARYTABLE_DURATION),
82 Qt::Horizontal, tr("Duration"));
83 setHeaderData(fieldIndex(LIBRARYTABLE_TRACKNUMBER),
84 Qt::Horizontal, tr("Track #"));
85 setHeaderData(fieldIndex(LIBRARYTABLE_BITRATE),
86 Qt::Horizontal, tr("Bitrate"));
87 setHeaderData(fieldIndex(LIBRARYTABLE_BPM),
88 Qt::Horizontal, tr("BPM"));
89 setHeaderData(fieldIndex(LIBRARYTABLE_DATETIMEADDED),
90 Qt::Horizontal, tr("Date Added"));
9165
92 slotSearch("");66 slotSearch("");
9367
@@ -168,6 +142,7 @@
168142
169bool MissingTableModel::isColumnInternal(int column) {143bool MissingTableModel::isColumnInternal(int column) {
170 if (column == fieldIndex(LIBRARYTABLE_ID) ||144 if (column == fieldIndex(LIBRARYTABLE_ID) ||
145 column == fieldIndex(LIBRARYTABLE_PLAYED) ||
171 column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) ||146 column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) ||
172 column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED))147 column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED))
173 return true;148 return true;
@@ -200,42 +175,16 @@
200 return mimeData;175 return mimeData;
201}176}
202177
178/** Override flags from BaseSqlModel since we don't want edit this model */
203Qt::ItemFlags MissingTableModel::flags(const QModelIndex &index) const179Qt::ItemFlags MissingTableModel::flags(const QModelIndex &index) const
204{180{
205 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);181 return readOnlyFlags(index);
206 if (!index.isValid())
207 return Qt::ItemIsEnabled;
208
209 //defaultFlags |= Qt::ItemIsDragEnabled;
210 //defaultFlags = 0;
211
212 return defaultFlags;
213}182}
214183
215QItemDelegate* MissingTableModel::delegateForColumn(const int i) {184QItemDelegate* MissingTableModel::delegateForColumn(const int i) {
216 return NULL;185 return NULL;
217}186}
218187
219QVariant MissingTableModel::data(const QModelIndex& item, int role) const {
220 if (!item.isValid())
221 return QVariant();
222
223 QVariant value;
224
225 if (role == Qt::ToolTipRole)
226 value = BaseSqlTableModel::data(item, Qt::DisplayRole);
227 else
228 value = BaseSqlTableModel::data(item, role);
229
230 if ((role == Qt::DisplayRole || role == Qt::ToolTipRole) &&
231 item.column() == fieldIndex(LIBRARYTABLE_DURATION)) {
232 if (qVariantCanConvert<int>(value)) {
233 value = MixxxUtils::secondsToMinutes(qVariantValue<int>(value));
234 }
235 }
236 return value;
237}
238
239TrackModel::CapabilitiesFlags MissingTableModel::getCapabilities() const188TrackModel::CapabilitiesFlags MissingTableModel::getCapabilities() const
240{189{
241 return 0;190 return 0;
242191
=== modified file 'mixxx/src/library/missingtablemodel.h'
--- mixxx/src/library/missingtablemodel.h 2010-09-13 06:23:38 +0000
+++ mixxx/src/library/missingtablemodel.h 2010-10-19 05:33:52 +0000
@@ -26,7 +26,7 @@
26 virtual void removeTracks(const QModelIndexList& indices);26 virtual void removeTracks(const QModelIndexList& indices);
27 virtual bool addTrack(const QModelIndex& index, QString location);27 virtual bool addTrack(const QModelIndex& index, QString location);
28 virtual void moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex);28 virtual void moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex);
29 virtual QVariant data(const QModelIndex& item, int role) const;29
30 QMimeData* mimeData(const QModelIndexList &indexes) const;30 QMimeData* mimeData(const QModelIndexList &indexes) const;
31 Qt::ItemFlags flags(const QModelIndex &index) const;31 Qt::ItemFlags flags(const QModelIndex &index) const;
32 QItemDelegate* delegateForColumn(const int i);32 QItemDelegate* delegateForColumn(const int i);
3333
=== modified file 'mixxx/src/library/playlisttablemodel.cpp'
--- mixxx/src/library/playlisttablemodel.cpp 2010-09-14 20:32:32 +0000
+++ mixxx/src/library/playlisttablemodel.cpp 2010-10-19 05:33:52 +0000
@@ -44,11 +44,14 @@
44 "PlaylistTracks." + PLAYLISTTRACKSTABLE_POSITION + "," +44 "PlaylistTracks." + PLAYLISTTRACKSTABLE_POSITION + "," +
45 //"playlist_id, " + //DEBUG45 //"playlist_id, " + //DEBUG
46 "library." + LIBRARYTABLE_ID + "," +46 "library." + LIBRARYTABLE_ID + "," +
47 "library." + LIBRARYTABLE_PLAYED + "," +
48 "library." + LIBRARYTABLE_TIMESPLAYED + "," +
47 "library." + LIBRARYTABLE_ARTIST + "," +49 "library." + LIBRARYTABLE_ARTIST + "," +
48 "library." + LIBRARYTABLE_TITLE + "," +50 "library." + LIBRARYTABLE_TITLE + "," +
49 "library." + LIBRARYTABLE_ALBUM + "," +51 "library." + LIBRARYTABLE_ALBUM + "," +
50 "library." + LIBRARYTABLE_YEAR + "," +52 "library." + LIBRARYTABLE_YEAR + "," +
51 "library." + LIBRARYTABLE_DURATION + "," +53 "library." + LIBRARYTABLE_DURATION + "," +
54 "library." + LIBRARYTABLE_RATING + "," +
52 "library." + LIBRARYTABLE_GENRE + "," +55 "library." + LIBRARYTABLE_GENRE + "," +
53 "library." + LIBRARYTABLE_FILETYPE + "," +56 "library." + LIBRARYTABLE_FILETYPE + "," +
54 "library." + LIBRARYTABLE_TRACKNUMBER + "," +57 "library." + LIBRARYTABLE_TRACKNUMBER + "," +
@@ -79,36 +82,7 @@
7982
80 setTable(playlistTableName);83 setTable(playlistTableName);
8184
82 //Set the column heading labels, rename them for translations and have85 initHeaderData(); //derived from BaseSqlModel
83 //proper capitalization
84 setHeaderData(fieldIndex(PLAYLISTTRACKSTABLE_POSITION),
85 Qt::Horizontal, tr("#"));
86 setHeaderData(fieldIndex(LIBRARYTABLE_ARTIST),
87 Qt::Horizontal, tr("Artist"));
88 setHeaderData(fieldIndex(LIBRARYTABLE_TITLE),
89 Qt::Horizontal, tr("Title"));
90 setHeaderData(fieldIndex(LIBRARYTABLE_ALBUM),
91 Qt::Horizontal, tr("Album"));
92 setHeaderData(fieldIndex(LIBRARYTABLE_GENRE),
93 Qt::Horizontal, tr("Genre"));
94 setHeaderData(fieldIndex(LIBRARYTABLE_YEAR),
95 Qt::Horizontal, tr("Year"));
96 setHeaderData(fieldIndex(LIBRARYTABLE_FILETYPE),
97 Qt::Horizontal, tr("Type"));
98 setHeaderData(fieldIndex("location"),
99 Qt::Horizontal, tr("Location"));
100 setHeaderData(fieldIndex(LIBRARYTABLE_COMMENT),
101 Qt::Horizontal, tr("Comment"));
102 setHeaderData(fieldIndex(LIBRARYTABLE_DURATION),
103 Qt::Horizontal, tr("Duration"));
104 setHeaderData(fieldIndex(LIBRARYTABLE_TRACKNUMBER),
105 Qt::Horizontal, tr("Track #"));
106 setHeaderData(fieldIndex(LIBRARYTABLE_BITRATE),
107 Qt::Horizontal, tr("Bitrate"));
108 setHeaderData(fieldIndex(LIBRARYTABLE_DATETIMEADDED),
109 Qt::Horizontal, tr("Date Added"));
110 setHeaderData(fieldIndex(LIBRARYTABLE_BPM),
111 Qt::Horizontal, tr("BPM"));
11286
113 slotSearch("");87 slotSearch("");
11488
@@ -323,6 +297,7 @@
323297
324bool PlaylistTableModel::isColumnInternal(int column) {298bool PlaylistTableModel::isColumnInternal(int column) {
325 if (column == fieldIndex(LIBRARYTABLE_ID) ||299 if (column == fieldIndex(LIBRARYTABLE_ID) ||
300 column == fieldIndex(LIBRARYTABLE_PLAYED) ||
326 column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) ||301 column == fieldIndex(LIBRARYTABLE_MIXXXDELETED) ||
327 column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED))302 column == fieldIndex(TRACKLOCATIONSTABLE_FSDELETED))
328 return true;303 return true;
@@ -354,43 +329,11 @@
354 return mimeData;329 return mimeData;
355}330}
356331
357Qt::ItemFlags PlaylistTableModel::flags(const QModelIndex &index) const
358{
359 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
360 if (!index.isValid())
361 return Qt::ItemIsEnabled;
362
363 //Enable dragging songs from this data model to elsewhere (like the waveform widget to
364 //load a track into a Player).
365 defaultFlags |= Qt::ItemIsDragEnabled;
366
367 return defaultFlags;
368}
369332
370QItemDelegate* PlaylistTableModel::delegateForColumn(const int i) {333QItemDelegate* PlaylistTableModel::delegateForColumn(const int i) {
371 return NULL;334 return NULL;
372}335}
373336
374QVariant PlaylistTableModel::data(const QModelIndex& item, int role) const {
375 if (!item.isValid())
376 return QVariant();
377
378 QVariant value;
379
380 if (role == Qt::ToolTipRole)
381 value = BaseSqlTableModel::data(item, Qt::DisplayRole);
382 else
383 value = BaseSqlTableModel::data(item, role);
384
385 if ((role == Qt::DisplayRole || role == Qt::ToolTipRole) &&
386 item.column() == fieldIndex(LIBRARYTABLE_DURATION)) {
387 if (qVariantCanConvert<int>(value)) {
388 value = MixxxUtils::secondsToMinutes(qVariantValue<int>(value));
389 }
390 }
391 return value;
392}
393
394TrackModel::CapabilitiesFlags PlaylistTableModel::getCapabilities() const337TrackModel::CapabilitiesFlags PlaylistTableModel::getCapabilities() const
395{338{
396 TrackModel::CapabilitiesFlags caps = TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_REORDER | TRACKMODELCAPS_ADDTOCRATE | TRACKMODELCAPS_ADDTOPLAYLIST;339 TrackModel::CapabilitiesFlags caps = TRACKMODELCAPS_RECEIVEDROPS | TRACKMODELCAPS_REORDER | TRACKMODELCAPS_ADDTOCRATE | TRACKMODELCAPS_ADDTOPLAYLIST;
397340
=== added file 'mixxx/src/library/playlisttablemodel.h'
--- mixxx/src/library/playlisttablemodel.h 1970-01-01 00:00:00 +0000
+++ mixxx/src/library/playlisttablemodel.h 2010-10-19 05:33:52 +0000
@@ -0,0 +1,51 @@
1#ifndef PLAYLISTTABLEMODEL_H
2#define PLAYLISTTABLEMODEL_H
3
4#include <QtSql>
5#include <QItemDelegate>
6#include <QtCore>
7#include "trackmodel.h"
8#include "library/basesqltablemodel.h"
9#include "library/librarytablemodel.h"
10#include "library/dao/playlistdao.h"
11#include "library/dao/trackdao.h"
12
13class TrackCollection;
14
15class PlaylistTableModel : public BaseSqlTableModel, public virtual TrackModel
16{
17 Q_OBJECT
18 public:
19 PlaylistTableModel(QObject* parent, TrackCollection* pTrackCollection);
20 virtual ~PlaylistTableModel();
21 void setPlaylist(int playlistId);
22 virtual TrackPointer getTrack(const QModelIndex& index) const;
23 virtual QString getTrackLocation(const QModelIndex& index) const;
24 virtual void search(const QString& searchText);
25 virtual const QString currentSearch();
26 virtual bool isColumnInternal(int column);
27 virtual void removeTrack(const QModelIndex& index);
28 virtual void removeTracks(const QModelIndexList& indices);
29 virtual bool addTrack(const QModelIndex& index, QString location);
30 virtual void moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex);
31
32 QMimeData* mimeData(const QModelIndexList &indexes) const;
33
34 QItemDelegate* delegateForColumn(const int i);
35 TrackModel::CapabilitiesFlags getCapabilities() const;
36
37 private slots:
38 void slotSearch(const QString& searchText);
39
40 signals:
41 void doSearch(const QString& searchText);
42
43 private:
44 TrackCollection* m_pTrackCollection;
45 PlaylistDAO& m_playlistDao;
46 TrackDAO& m_trackDao;
47 int m_iPlaylistId;
48 QString m_currentSearch;
49};
50
51#endif
052
=== removed file 'mixxx/src/library/playlisttablemodel.h'
--- mixxx/src/library/playlisttablemodel.h 2010-09-13 06:23:38 +0000
+++ mixxx/src/library/playlisttablemodel.h 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
1#ifndef PLAYLISTTABLEMODEL_H
2#define PLAYLISTTABLEMODEL_H
3
4#include <QtSql>
5#include <QItemDelegate>
6#include <QtCore>
7#include "trackmodel.h"
8#include "library/basesqltablemodel.h"
9#include "library/librarytablemodel.h"
10#include "library/dao/playlistdao.h"
11#include "library/dao/trackdao.h"
12
13class TrackCollection;
14
15class PlaylistTableModel : public BaseSqlTableModel, public virtual TrackModel
16{
17 Q_OBJECT
18 public:
19 PlaylistTableModel(QObject* parent, TrackCollection* pTrackCollection);
20 virtual ~PlaylistTableModel();
21 void setPlaylist(int playlistId);
22 virtual TrackPointer getTrack(const QModelIndex& index) const;
23 virtual QString getTrackLocation(const QModelIndex& index) const;
24 virtual void search(const QString& searchText);
25 virtual const QString currentSearch();
26 virtual bool isColumnInternal(int column);
27 virtual void removeTrack(const QModelIndex& index);
28 virtual void removeTracks(const QModelIndexList& indices);
29 virtual bool addTrack(const QModelIndex& index, QString location);
30 virtual void moveTrack(const QModelIndex& sourceIndex, const QModelIndex& destIndex);
31 virtual QVariant data(const QModelIndex& item, int role) const;
32 QMimeData* mimeData(const QModelIndexList &indexes) const;
33 Qt::ItemFlags flags(const QModelIndex &index) const;
34 QItemDelegate* delegateForColumn(const int i);
35 TrackModel::CapabilitiesFlags getCapabilities() const;
36
37 private slots:
38 void slotSearch(const QString& searchText);
39
40 signals:
41 void doSearch(const QString& searchText);
42
43 private:
44 TrackCollection* m_pTrackCollection;
45 PlaylistDAO& m_playlistDao;
46 TrackDAO& m_trackDao;
47 int m_iPlaylistId;
48 QString m_currentSearch;
49};
50
51#endif
520
=== modified file 'mixxx/src/library/rhythmboxtrackmodel.cpp'
--- mixxx/src/library/rhythmboxtrackmodel.cpp 2010-10-15 21:17:06 +0000
+++ mixxx/src/library/rhythmboxtrackmodel.cpp 2010-10-19 05:33:52 +0000
@@ -160,6 +160,9 @@
160 pTrack->setGenre(songNode.firstChildElement("genre").text());160 pTrack->setGenre(songNode.firstChildElement("genre").text());
161 pTrack->setDuration(songNode.firstChildElement("duration").text().toUInt());161 pTrack->setDuration(songNode.firstChildElement("duration").text().toUInt());
162162
163 // TODO(ywwg) why was this added? constructor above does the same -- rryan
164 pTrack->setLocation(trackLocation);
165
163 // Have QObject handle deleting this track166 // Have QObject handle deleting this track
164 return TrackPointer(pTrack, &QObject::deleteLater);167 return TrackPointer(pTrack, &QObject::deleteLater);
165}168}
166169
=== added file 'mixxx/src/library/stardelegate.cpp'
--- mixxx/src/library/stardelegate.cpp 1970-01-01 00:00:00 +0000
+++ mixxx/src/library/stardelegate.cpp 2010-10-19 05:33:52 +0000
@@ -0,0 +1,114 @@
1/***************************************************************************
2 stardelegate.cpp
3 -------------------
4 copyright : (C) 2010 Tobias Rafreider
5 copyright : (C) 2009 Nokia Corporation
6
7***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18
19#include <QtDebug>
20#include <QtGui>
21
22#include "stardelegate.h"
23#include "stareditor.h"
24#include "starrating.h"
25
26/*
27 * The function is invoked once for each item, represented by a QModelIndex object from the model.
28 * If the data stored in the item is a StarRating, we paint it use a star editor for displaying;
29 * otherwise, we let QItemDelegate paint it for us.
30 * This ensures that the StarDelegate can handle the most common data types.
31 */
32void StarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
33{
34 // Populate the correct colors based on the styling
35 QStyleOptionViewItem newOption = option;
36 initStyleOption(&newOption, index);
37
38 // Set the palette appropriately based on whether the row is selected or not
39 if (newOption.state & QStyle::State_Selected) {
40 painter->fillRect(newOption.rect, newOption.palette.highlight());
41 painter->setBrush(newOption.palette.highlightedText());
42 } else {
43 painter->fillRect(newOption.rect, newOption.palette.base());
44 painter->setBrush(newOption.palette.text());
45 }
46
47 if (qVariantCanConvert<StarRating>(index.data())) {
48 StarRating starRating = qVariantValue<StarRating>(index.data());
49 starRating.paint(painter, newOption.rect, newOption.palette, StarRating::ReadOnly);
50 } else {
51 QStyledItemDelegate::paint(painter, newOption, index);
52 }
53}
54
55QSize StarDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
56{
57 if (qVariantCanConvert<StarRating>(index.data())) {
58 StarRating starRating = qVariantValue<StarRating>(index.data());
59 return starRating.sizeHint();
60 } else {
61 return QStyledItemDelegate::sizeHint(option, index);
62 }
63}
64/*
65 * If the item is a StarRating, we create a StarEditor and connect
66 * its editingFinished() signal to our commitAndCloseEditor() slot,
67 * so we can update the model when the editor closes.
68 */
69QWidget *StarDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const
70{
71 // Populate the correct colors based on the styling
72 QStyleOptionViewItem newOption = option;
73 initStyleOption(&newOption, index);
74
75 if (qVariantCanConvert<StarRating>(index.data())) {
76 StarEditor *editor = new StarEditor(parent, newOption);
77 connect(editor, SIGNAL(editingFinished()),
78 this, SLOT(commitAndCloseEditor()));
79 return editor;
80 } else {
81 return QStyledItemDelegate::createEditor(parent, newOption, index);
82 }
83}
84
85void StarDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
86{
87 if (qVariantCanConvert<StarRating>(index.data())) {
88 StarRating starRating = qVariantValue<StarRating>(index.data());
89 StarEditor *starEditor = qobject_cast<StarEditor *>(editor);
90 starEditor->setStarRating(starRating);
91 } else {
92 QStyledItemDelegate::setEditorData(editor, index);
93 }
94}
95
96void StarDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
97{
98 if (qVariantCanConvert<StarRating>(index.data())) {
99 StarEditor *starEditor = qobject_cast<StarEditor *>(editor);
100 model->setData(index, qVariantFromValue(starEditor->starRating()));
101 } else {
102 QStyledItemDelegate::setModelData(editor, model, index);
103 }
104}
105/*
106 * When the user is done editing, we emit commitData() and closeEditor() (both declared in QAbstractItemDelegate),
107 * to tell the model that there is edited data and to inform the view that the editor is no longer needed.
108 */
109void StarDelegate::commitAndCloseEditor()
110{
111 StarEditor *editor = qobject_cast<StarEditor *>(sender());
112 emit commitData(editor);
113 emit closeEditor(editor);
114}
0115
=== added file 'mixxx/src/library/stardelegate.h'
--- mixxx/src/library/stardelegate.h 1970-01-01 00:00:00 +0000
+++ mixxx/src/library/stardelegate.h 2010-10-19 05:33:52 +0000
@@ -0,0 +1,56 @@
1/***************************************************************************
2 stardelegate.h
3 -------------------
4 copyright : (C) 2010 Tobias Rafreider
5 copyright : (C) 2009 Nokia Corporation
6
7***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18
19#ifndef STARDELEGATE_H
20#define STARDELEGATE_H
21
22#include <QStyledItemDelegate>
23
24/*
25 * When displaying data in a QListView, QTableView, or QTreeView,
26 * the individual items are drawn by a delegate.
27 * Also, when the user starts editing an item (e.g., by double-clicking the item),
28 * the delegate provides an editor widget that is placed on top of the item while editing takes place.
29 *
30 * By default a QListView, QTableView, or QTreeView has a QItemDelegate attached,
31 * which inherits QAbstractItemDelegate and handles the most common data types (notably int and QString).
32 * If we need to support custom data types, or want to customize the rendering or the editing for
33 * existing data types, we can subclass QAbstractItemDelegate or QItemDelegate or QStyledItemDelegate
34 */
35class StarDelegate : public QStyledItemDelegate
36{
37 Q_OBJECT
38
39public:
40 StarDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
41 /** reimplemented from QItemDelegate and is called whenever the view needs to repaint an item **/
42 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
43 /** eturns an item's preferred size **/
44 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
45 /** called when the user starts editing an item: **/
46 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const;
47 /** called when an editor is created to initialize it with data from the model: **/
48 void setEditorData(QWidget *editor, const QModelIndex &index) const;
49 /** called when editing is finished, to commit data from the editor to the model: **/
50 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
51
52private slots:
53 void commitAndCloseEditor();
54};
55
56#endif
057
=== added file 'mixxx/src/library/stareditor.cpp'
--- mixxx/src/library/stareditor.cpp 1970-01-01 00:00:00 +0000
+++ mixxx/src/library/stareditor.cpp 2010-10-19 05:33:52 +0000
@@ -0,0 +1,95 @@
1/***************************************************************************
2 stareditor.cpp
3 -------------------
4 copyright : (C) 2010 Tobias Rafreider
5 copyright : (C) 2009 Nokia Corporation
6
7***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18/***************************************************************************
19 * *
20 * StarEditor inherits QWidget and is used by StarDelegate to let the user *
21 * edit a star rating in the library using the mouse. *
22 * *
23 * The class has been adapted from the official "Star Delegate Example", *
24 * see http://doc.trolltech.com/4.5/itemviews-stardelegate.html *
25 ***************************************************************************/
26
27 #include <QtGui>
28
29 #include "stareditor.h"
30 #include "starrating.h"
31
32/*
33 * We enable mouse tracking on the widget so we can follow the cursor even
34 * when the user doesn't hold down any mouse button. We also turn on
35 * QWidget's auto-fill background feature to obtain an opaque background.
36 * (Without the call, the view's background would shine through the editor.)
37 */
38StarEditor::StarEditor(QWidget *parent, const QStyleOptionViewItem &option)
39 : QWidget(parent)
40{
41 setPalette(option.palette);
42 setMouseTracking(true);
43 setAutoFillBackground(true);
44}
45
46QSize StarEditor::sizeHint() const
47 {
48 return m_starRating.sizeHint();
49 }
50/*
51 * We simply call StarRating::paint() to draw the stars,
52 * just like we did when implementing StarDelegate
53 */
54void StarEditor::paintEvent(QPaintEvent *)
55 {
56 QPainter painter(this);
57 m_starRating.paint(&painter, rect(), palette(), StarRating::Editable);
58 }
59/*
60 * In the mouse event handler, we call setStarCount() on
61 * the private data member m_starRating to reflect the current cursor position,
62 * and we call QWidget::update() to force a repaint.
63 */
64 void StarEditor::mouseMoveEvent(QMouseEvent *event)
65 {
66 int star = starAtPosition(event->x());
67
68 if (star != m_starRating.starCount() && star != -1) {
69 m_starRating.setStarCount(star);
70 update();
71 }
72 }
73/*
74 * When the user releases a mouse button, we simply emit the editingFinished() signal.
75 */
76 void StarEditor::mouseReleaseEvent(QMouseEvent * /* event */)
77 {
78 emit editingFinished();
79 }
80/*
81 * The method uses basic linear algebra to find out which star is under the cursor.
82 */
83 int StarEditor::starAtPosition(int x)
84 {
85 // If the mouse is very close to the left edge, set 0 stars.
86 if (x < m_starRating.sizeHint().width() * 0.05) {
87 return 0;
88 }
89 int star = (x / (m_starRating.sizeHint().width() / m_starRating.maxStarCount())) + 1;
90
91 if (star <= 0 || star > m_starRating.maxStarCount())
92 return 0;
93
94 return star;
95 }
096
=== added file 'mixxx/src/library/stareditor.h'
--- mixxx/src/library/stareditor.h 1970-01-01 00:00:00 +0000
+++ mixxx/src/library/stareditor.h 2010-10-19 05:33:52 +0000
@@ -0,0 +1,61 @@
1/***************************************************************************
2 stareditor.h
3 -------------------
4 copyright : (C) 2010 Tobias Rafreider
5 copyright : (C) 2009 Nokia Corporation
6
7***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18/***************************************************************************
19 * *
20 * StarEditor inherits QWidget and is used by StarDelegate to let the user *
21 * edit a star rating in the library using the mouse. *
22 * *
23 * The class has been adapted from the official "Star Delegate Example", *
24 * see http://doc.trolltech.com/4.5/itemviews-stardelegate.html *
25 ***************************************************************************/
26
27#ifndef STAREDITOR_H
28#define STAREDITOR_H
29
30#include <QWidget>
31
32#include "starrating.h"
33
34class StarEditor : public QWidget
35{
36 Q_OBJECT
37
38public:
39 StarEditor(QWidget *parent, const QStyleOptionViewItem& option);
40
41 QSize sizeHint() const;
42 void setStarRating(const StarRating &starRating) {
43 m_starRating = starRating;
44 }
45 StarRating starRating() { return m_starRating; }
46
47signals:
48 void editingFinished();
49
50protected:
51 void paintEvent(QPaintEvent *event);
52 void mouseMoveEvent(QMouseEvent *event);
53 void mouseReleaseEvent(QMouseEvent *event);
54
55private:
56 int starAtPosition(int x);
57
58 StarRating m_starRating;
59};
60
61#endif
062
=== added file 'mixxx/src/library/starrating.cpp'
--- mixxx/src/library/starrating.cpp 1970-01-01 00:00:00 +0000
+++ mixxx/src/library/starrating.cpp 2010-10-19 05:33:52 +0000
@@ -0,0 +1,74 @@
1/***************************************************************************
2 starrating.cpp
3 -------------------
4 copyright : (C) 2010 Tobias Rafreider
5 copyright : (C) 2009 Nokia Corporation
6
7***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18
19#include <QtGui>
20#include <math.h>
21
22#include "starrating.h"
23
24const int PaintingScaleFactor = 20;
25
26
27
28StarRating::StarRating(int starCount, int maxStarCount)
29{
30 m_myStarCount = starCount;
31 m_myMaxStarCount = maxStarCount;
32
33 m_starPolygon << QPointF(1.0, 0.5);
34 for (int i = 1; i < 5; ++i)
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);
36}
37
38QSize StarRating::sizeHint() const
39{
40 return PaintingScaleFactor * QSize(m_myMaxStarCount, 1);
41}
42
43/*
44 * function paints the stars in this StarRating object on a paint device
45 */
46void StarRating::paint(QPainter *painter, const QRect &rect, const QPalette &palette, EditMode mode) const
47{
48 painter->save();
49
50 painter->setRenderHint(QPainter::Antialiasing, true);
51 painter->setPen(Qt::NoPen);
52
53 // Workaround for painting issue. If we are editable, assume we are
54 // selected, so use the highlight and hightlightedText colors.
55 if (mode == Editable) {
56 painter->fillRect(rect, palette.highlight());
57 painter->setBrush(palette.highlightedText());
58 }
59
60 int yOffset = (rect.height() - PaintingScaleFactor) / 2;
61 painter->translate(rect.x(), rect.y() + yOffset);
62 painter->scale(PaintingScaleFactor, PaintingScaleFactor);
63
64 for (int i = 0; i < m_myMaxStarCount; ++i) {
65 if (i < m_myStarCount) {
66 painter->drawPolygon(m_starPolygon, Qt::WindingFill);
67 } else {
68 painter->drawPolygon(m_diamondPolygon, Qt::WindingFill);
69 }
70 painter->translate(1.0, 0.0);
71 }
72
73 painter->restore();
74}
075
=== added file 'mixxx/src/library/starrating.h'
--- mixxx/src/library/starrating.h 1970-01-01 00:00:00 +0000
+++ mixxx/src/library/starrating.h 2010-10-19 05:33:52 +0000
@@ -0,0 +1,62 @@
1/***************************************************************************
2 starrating.h
3 -------------------
4 copyright : (C) 2010 Tobias Rafreider
5 copyright : (C) 2009 Nokia Corporation
6
7***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18
19#ifndef STARRATING_H
20#define STARRATING_H
21
22#include <QMetaType>
23#include <QPointF>
24#include <QVector>
25#include <QPainter>
26#include <QStyledItemDelegate>
27
28/*
29 * The StarRating class represents a rating as a number of stars.
30 * In addition to holding the data, it is also capable of painting the stars on a QPaintDevice,
31 * which in this example is either a view or an editor.
32 * The myStarCount member variable stores the current rating, and myMaxStarCount stores
33 * the highest possible rating (typically 5).
34 */
35class StarRating
36{
37 public:
38 enum EditMode { Editable, ReadOnly };
39
40
41 StarRating(int starCount = 1, int maxStarCount = 5);
42
43 void paint(QPainter *painter, const QRect &rect, const QPalette &palette, EditMode mode) const;
44 QSize sizeHint() const;
45
46 int starCount() const { return m_myStarCount; }
47 int maxStarCount() const { return m_myMaxStarCount; }
48 void setStarCount(int starCount) { m_myStarCount = starCount; }
49 void setMaxStarCount(int maxStarCount) { m_myMaxStarCount = maxStarCount; }
50
51
52private:
53 QPolygonF m_starPolygon;
54 QPolygonF m_diamondPolygon;
55 int m_myStarCount;
56 int m_myMaxStarCount;
57
58};
59
60Q_DECLARE_METATYPE(StarRating)
61
62#endif
063
=== modified file 'mixxx/src/library/trackcollection.cpp'
--- mixxx/src/library/trackcollection.cpp 2010-10-07 03:05:48 +0000
+++ mixxx/src/library/trackcollection.cpp 2010-10-19 05:33:52 +0000
@@ -44,6 +44,9 @@
44{44{
45 // Save all tracks that haven't been saved yet.45 // Save all tracks that haven't been saved yet.
46 m_trackDao.saveDirtyTracks();46 m_trackDao.saveDirtyTracks();
47 // TODO(XXX) Maybe fold saveDirtyTracks into TrackDAO::finish now that it
48 // exists? -- rryan 10/2010
49 m_trackDao.finish();
4750
48 Q_ASSERT(!m_db.rollback()); //Rollback any uncommitted transaction51 Q_ASSERT(!m_db.rollback()); //Rollback any uncommitted transaction
49 //The above is an ASSERT because there should never be an outstanding52 //The above is an ASSERT because there should never be an outstanding
@@ -65,7 +68,7 @@
65 return false;68 return false;
66 }69 }
6770
68 int requiredSchemaVersion = 5;71 int requiredSchemaVersion = 6;
69 if (!SchemaManager::upgradeToSchemaVersion(m_pConfig, m_db,72 if (!SchemaManager::upgradeToSchemaVersion(m_pConfig, m_db,
70 requiredSchemaVersion)) {73 requiredSchemaVersion)) {
71 QMessageBox::warning(0, qApp->tr("Cannot upgrade database schema"),74 QMessageBox::warning(0, qApp->tr("Cannot upgrade database schema"),
7275
=== modified file 'mixxx/src/mixxx.cpp'
--- mixxx/src/mixxx.cpp 2010-10-18 21:55:09 +0000
+++ mixxx/src/mixxx.cpp 2010-10-19 05:33:52 +0000
@@ -185,10 +185,10 @@
185 QDir dir(config->getValueString(ConfigKey("[Playlist]","Directory")));185 QDir dir(config->getValueString(ConfigKey("[Playlist]","Directory")));
186 if ((config->getValueString(ConfigKey("[Playlist]","Directory")).length()<1) || (!dir.exists()))186 if ((config->getValueString(ConfigKey("[Playlist]","Directory")).length()<1) || (!dir.exists()))
187 {187 {
188 QString fd = QFileDialog::getExistingDirectory(this, 188 QString fd = QFileDialog::getExistingDirectory(this,
189 tr("Choose music library directory"),189 tr("Choose music library directory"),
190 QDesktopServices::storageLocation(QDesktopServices::MusicLocation));190 QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
191 191
192 if (fd != "")192 if (fd != "")
193 {193 {
194 config->set(ConfigKey("[Playlist]","Directory"), fd);194 config->set(ConfigKey("[Playlist]","Directory"), fd);
195195
=== modified file 'mixxx/src/player.cpp'
--- mixxx/src/player.cpp 2010-10-07 09:03:35 +0000
+++ mixxx/src/player.cpp 2010-10-19 05:33:52 +0000
@@ -178,6 +178,8 @@
178 if(!m_pLoadedTrack->getHeaderParsed())178 if(!m_pLoadedTrack->getHeaderParsed())
179 SoundSourceProxy::ParseHeader(m_pLoadedTrack.data());179 SoundSourceProxy::ParseHeader(m_pLoadedTrack.data());
180180
181 m_pLoadedTrack->incTimesPlayed();
182
181 // Generate waveform summary183 // Generate waveform summary
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.
183 // TODO(rryan) : fix this crap -- the waveform renderers should be owned by185 // TODO(rryan) : fix this crap -- the waveform renderers should be owned by
184186
=== modified file 'mixxx/src/trackinfoobject.cpp'
--- mixxx/src/trackinfoobject.cpp 2010-10-07 03:05:48 +0000
+++ mixxx/src/trackinfoobject.cpp 2010-10-19 05:33:52 +0000
@@ -48,6 +48,7 @@
48 : m_qMutex(QMutex::Recursive) {48 : m_qMutex(QMutex::Recursive) {
49 m_sFilename = XmlParse::selectNodeQString(nodeHeader, "Filename");49 m_sFilename = XmlParse::selectNodeQString(nodeHeader, "Filename");
50 m_sLocation = XmlParse::selectNodeQString(nodeHeader, "Filepath") + "/" + m_sFilename;50 m_sLocation = XmlParse::selectNodeQString(nodeHeader, "Filepath") + "/" + m_sFilename;
51 QString create_date;
5152
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()
53 // on the file. Plus those initializations weren't done before, so it might54 // on the file. Plus those initializations weren't done before, so it might
@@ -72,6 +73,11 @@
72 m_bBpmConfirm = XmlParse::selectNodeQString(nodeHeader, "BpmConfirm").toInt();73 m_bBpmConfirm = XmlParse::selectNodeQString(nodeHeader, "BpmConfirm").toInt();
73 m_fBeatFirst = XmlParse::selectNodeQString(nodeHeader, "BeatFirst").toFloat();74 m_fBeatFirst = XmlParse::selectNodeQString(nodeHeader, "BeatFirst").toFloat();
74 m_bHeaderParsed = false;75 m_bHeaderParsed = false;
76 create_date = XmlParse::selectNodeQString(nodeHeader, "CreateDate");
77 if (create_date == "")
78 m_dCreateDate = fileInfo.created();
79 else
80 m_dCreateDate = QDateTime::fromString(create_date);
7581
76 // Mixxx <1.8 recorded track IDs in mixxxtrack.xml, but we are going to82 // Mixxx <1.8 recorded track IDs in mixxxtrack.xml, but we are going to
77 // ignore those. Tracks will get a new ID from the database.83 // ignore those. Tracks will get a new ID from the database.
@@ -79,6 +85,7 @@
79 m_iId = -1;85 m_iId = -1;
8086
81 m_fCuePoint = XmlParse::selectNodeQString(nodeHeader, "CuePoint").toFloat();87 m_fCuePoint = XmlParse::selectNodeQString(nodeHeader, "CuePoint").toFloat();
88 m_bPlayed = false;
8289
83 m_pVisualWave = 0;90 m_pVisualWave = 0;
84 m_dVisualResampleRate = 0;91 m_dVisualResampleRate = 0;
@@ -112,6 +119,7 @@
112 m_iDuration = 0;119 m_iDuration = 0;
113 m_iBitrate = 0;120 m_iBitrate = 0;
114 m_iTimesPlayed = 0;121 m_iTimesPlayed = 0;
122 m_bPlayed = false;
115 m_fBpm = 0.;123 m_fBpm = 0.;
116 m_bBpmConfirm = false;124 m_bBpmConfirm = false;
117 m_bIsValid = false;125 m_bIsValid = false;
@@ -123,6 +131,8 @@
123 m_iChannels = 0;131 m_iChannels = 0;
124 m_fCuePoint = 0.0f;132 m_fCuePoint = 0.0f;
125 m_dVisualResampleRate = 0;133 m_dVisualResampleRate = 0;
134 m_dCreateDate = QDateTime::currentDateTime();
135 m_Rating = 0;
126136
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!
128 if (parseHeader)138 if (parseHeader)
@@ -148,6 +158,7 @@
148{158{
149 QMutexLocker lock(&m_qMutex);159 QMutexLocker lock(&m_qMutex);
150160
161 QString create_date;
151 XmlParse::addElement( doc, header, "Filename", m_sFilename );162 XmlParse::addElement( doc, header, "Filename", m_sFilename );
152 //XmlParse::addElement( doc, header, "Filepath", m_sFilepath );163 //XmlParse::addElement( doc, header, "Filepath", m_sFilepath );
153 XmlParse::addElement( doc, header, "Title", m_sTitle );164 XmlParse::addElement( doc, header, "Title", m_sTitle );
@@ -165,6 +176,7 @@
165 XmlParse::addElement( doc, header, "BeatFirst", QString("%1").arg(m_fBeatFirst) );176 XmlParse::addElement( doc, header, "BeatFirst", QString("%1").arg(m_fBeatFirst) );
166 XmlParse::addElement( doc, header, "Id", QString("%1").arg(m_iId) );177 XmlParse::addElement( doc, header, "Id", QString("%1").arg(m_iId) );
167 XmlParse::addElement( doc, header, "CuePoint", QString::number(m_fCuePoint) );178 XmlParse::addElement( doc, header, "CuePoint", QString::number(m_fCuePoint) );
179 XmlParse::addElement( doc, header, "CreateDate", m_dCreateDate.toString() );
168 //if (m_pWave) {180 //if (m_pWave) {
169 //XmlParse::addHexElement(doc, header, "WaveSummaryHex", m_pWave);181 //XmlParse::addHexElement(doc, header, "WaveSummaryHex", m_pWave);
170 //}182 //}
@@ -255,6 +267,13 @@
255 return m_sFilename;267 return m_sFilename;
256}268}
257269
270QDateTime TrackInfoObject::getCreateDate() const
271{
272 QMutexLocker lock(&m_qMutex);
273 QDateTime create_date = QDateTime(m_dCreateDate);
274 return create_date;
275}
276
258bool TrackInfoObject::exists() const277bool TrackInfoObject::exists() const
259{278{
260 QMutexLocker lock(&m_qMutex);279 QMutexLocker lock(&m_qMutex);
@@ -439,13 +458,53 @@
439 return m_iTimesPlayed;458 return m_iTimesPlayed;
440}459}
441460
461void TrackInfoObject::setTimesPlayed(int t)
462{
463 QMutexLocker lock(&m_qMutex);
464 bool dirty = t != m_iTimesPlayed;
465 m_iTimesPlayed = t;
466 if (dirty)
467 setDirty(true);
468}
469
442void TrackInfoObject::incTimesPlayed()470void TrackInfoObject::incTimesPlayed()
443{471{
444 QMutexLocker lock(&m_qMutex);472 QMutexLocker lock(&m_qMutex);
473 std::cout << "Track Played:" << m_sArtist.toStdString() << " - " << m_sTitle.toStdString();
474 qDebug() << "Track Played:" << m_sArtist << " - " << m_sTitle;
475 m_bPlayed = true;
445 ++m_iTimesPlayed;476 ++m_iTimesPlayed;
446 setDirty(true);477 setDirty(true);
447}478}
448479
480bool TrackInfoObject::getPlayed() const
481{
482 QMutexLocker lock(&m_qMutex);
483 bool bPlayed = m_bPlayed;
484 return bPlayed;
485}
486
487void TrackInfoObject::setPlayed(bool bPlayed)
488{
489 QMutexLocker lock(&m_qMutex);
490 bool dirty = bPlayed != m_bPlayed;
491 m_bPlayed = bPlayed;
492 if (dirty)
493 {
494 if (bPlayed)
495 {
496 std::cout << "Track Played:" << m_sArtist.toStdString() << " - " << m_sTitle.toStdString();
497 qDebug() << "Track Played:" << m_sArtist << " - " << m_sTitle;
498 }
499 else
500 {
501 std::cout << "Track Unplayed:" << m_sArtist.toStdString() << " - " << m_sTitle.toStdString();
502 qDebug() << "Track Unplayed:" << m_sArtist << " - " << m_sTitle;
503 }
504 setDirty(true);
505 }
506}
507
449QString TrackInfoObject::getComment() const508QString TrackInfoObject::getComment() const
450{509{
451 QMutexLocker lock(&m_qMutex);510 QMutexLocker lock(&m_qMutex);
@@ -721,3 +780,18 @@
721 QMutexLocker lock(&m_qMutex);780 QMutexLocker lock(&m_qMutex);
722 return m_bLocationChanged;781 return m_bLocationChanged;
723}782}
783/** Returns the rating */
784int TrackInfoObject::getRating() const{
785 QMutexLocker lock(&m_qMutex);
786
787 return m_Rating;
788}
789 /** Set rating */
790void TrackInfoObject::setRating (int rating){
791 QMutexLocker lock(&m_qMutex);
792
793 bool dirty = rating != m_Rating;
794 m_Rating = rating;
795 if (dirty)
796 setDirty(true);
797}
724798
=== modified file 'mixxx/src/trackinfoobject.h'
--- mixxx/src/trackinfoobject.h 2010-10-07 03:05:48 +0000
+++ mixxx/src/trackinfoobject.h 2010-10-19 05:33:52 +0000
@@ -19,6 +19,7 @@
19#define TRACKINFOOBJECT_H19#define TRACKINFOOBJECT_H
2020
21#include <QList>21#include <QList>
22#include <QDateTime>
22#include <QObject>23#include <QObject>
23#include <QFileInfo>24#include <QFileInfo>
24#include <QMutex>25#include <QMutex>
@@ -76,6 +77,8 @@
76 QString getDirectory() const;77 QString getDirectory() const;
77 // Returns the filename of the file.78 // Returns the filename of the file.
78 QString getFilename() const;79 QString getFilename() const;
80 // Returns file creation date
81 QDateTime getCreateDate() const;
79 // Returns the length of the file in bytes82 // Returns the length of the file in bytes
80 int getLength() const;83 int getLength() const;
81 // Returns whether the file exists on disk or not. Updated as of the time84 // Returns whether the file exists on disk or not. Updated as of the time
@@ -152,11 +155,21 @@
152 void setTrackNumber(QString);155 void setTrackNumber(QString);
153 /** Return number of times the track has been played */156 /** Return number of times the track has been played */
154 int getTimesPlayed() const;157 int getTimesPlayed() const;
158 /** Set number of times the track has been played */
159 void setTimesPlayed(int t);
155 /** Increment times played with one */160 /** Increment times played with one */
156 void incTimesPlayed();161 void incTimesPlayed();
162 /** Returns true if track has been played this instance*/
163 bool getPlayed() const;
164 /** Set Played status*/
165 void setPlayed(bool);
157166
158 int getId() const;167 int getId() const;
159168
169 /** Returns rating */
170 int getRating() const;
171 /** Sets rating */
172 void setRating(int);
160173
161 /** Get URL for track */174 /** Get URL for track */
162 QString getURL();175 QString getURL();
@@ -282,10 +295,14 @@
282 int m_iSampleRate;295 int m_iSampleRate;
283 /** Number of channels */296 /** Number of channels */
284 int m_iChannels;297 int m_iChannels;
298 /**Track rating */
299 int m_Rating;;
285 /** Bitrate, number of kilobits per second of audio in the track*/300 /** Bitrate, number of kilobits per second of audio in the track*/
286 int m_iBitrate;301 int m_iBitrate;
287 /** Number of times the track has been played */302 /** Number of times the track has been played */
288 int m_iTimesPlayed;303 int m_iTimesPlayed;
304 /** Has this track been played this sessions? */
305 bool m_bPlayed;
289 /** Beat per minutes (BPM) */306 /** Beat per minutes (BPM) */
290 float m_fBpm;307 float m_fBpm;
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 */
@@ -302,6 +319,8 @@
302 int m_iId;319 int m_iId;
303 /** Cue point in samples or something */320 /** Cue point in samples or something */
304 float m_fCuePoint;321 float m_fCuePoint;
322 /** Date. creation date of file */
323 QDateTime m_dCreateDate;
305324
306 // The list of cue points for the track325 // The list of cue points for the track
307 QList<Cue*> m_cuePoints;326 QList<Cue*> m_cuePoints;
308327
=== modified file 'mixxx/src/widget/wlibrarytableview.cpp'
--- mixxx/src/widget/wlibrarytableview.cpp 2010-09-19 22:08:15 +0000
+++ mixxx/src/widget/wlibrarytableview.cpp 2010-10-19 05:33:52 +0000
@@ -8,6 +8,7 @@
8#include "widget/wwidget.h"8#include "widget/wwidget.h"
9#include "widget/wskincolor.h"9#include "widget/wskincolor.h"
10#include "widget/wlibrarytableview.h"10#include "widget/wlibrarytableview.h"
11#include "../library/stardelegate.h"
1112
12WLibraryTableView::WLibraryTableView(QWidget* parent,13WLibraryTableView::WLibraryTableView(QWidget* parent,
13 ConfigObject<ConfigValue>* pConfig,14 ConfigObject<ConfigValue>* pConfig,
@@ -16,7 +17,13 @@
16 m_pConfig(pConfig),17 m_pConfig(pConfig),
17 m_vScrollBarPosKey(vScrollBarPosKey) {18 m_vScrollBarPosKey(vScrollBarPosKey) {
1819
19 //Setup properties for table20 // Setup properties for table
21
22 // Editing starts when clicking on an already selected item.
23 setEditTriggers(QAbstractItemView::SelectedClicked);
24
25 // This is to support rating of tracks
26 setItemDelegate(new StarDelegate());
2027
21 //Enable selection by rows and extended selection (ctrl/shift click)28 //Enable selection by rows and extended selection (ctrl/shift click)
22 setSelectionBehavior(QAbstractItemView::SelectRows);29 setSelectionBehavior(QAbstractItemView::SelectRows);
2330
=== modified file 'mixxx/src/widget/wstatuslight.cpp'
--- mixxx/src/widget/wstatuslight.cpp 2009-03-05 15:14:48 +0000
+++ mixxx/src/widget/wstatuslight.cpp 2010-10-19 05:33:52 +0000
@@ -26,59 +26,90 @@
2626
27WStatusLight::WStatusLight(QWidget * parent) : WWidget(parent)27WStatusLight::WStatusLight(QWidget * parent) : WWidget(parent)
28{28{
29 m_pPixmapBack = 0;29 m_pPixmapSLs = 0;
30 m_pPixmapSL = 0;30 m_iNoPos = 0;
31 m_iPos = 0;
32
33 setNoPos(0);
31}34}
3235
33WStatusLight::~WStatusLight()36WStatusLight::~WStatusLight()
34{37{
35 resetPositions();38 for (int i = 0; i < m_iNoPos; i++) {
39 WPixmapStore::deletePixmap(m_pPixmapSLs[i]);
40 }
41}
42
43void WStatusLight::setNoPos(int iNoPos)
44{
45 m_iNoPos = iNoPos;
46 m_fValue = 0.;
47
48 // If pixmap array is already allocated, delete it
49 if (m_pPixmapSLs)
50 delete [] m_pPixmapSLs;
51
52 if (m_iNoPos>0)
53 {
54 m_pPixmapSLs = new QPixmap*[m_iNoPos];
55 for (int i=0; i<m_iNoPos; ++i)
56 m_pPixmapSLs[i] = 0;
57 }
36}58}
3759
38void WStatusLight::setup(QDomNode node)60void WStatusLight::setup(QDomNode node)
39{61{
40 WWidget::setup(node);62 WWidget::setup(node);
4163 // Number of states
42 // Set pixmaps64 m_iNoPos = selectNodeInt(node, "NumberPos") + 1;
43 bool bHorizontal = false;65 setNoPos(m_iNoPos);
44 if (!selectNode(node, "Horizontal").isNull() && selectNodeQString(node, "Horizontal")=="true")66
45 bHorizontal = true;67 for (int i=0; i<m_iNoPos; i++)
46 setPixmaps(getPath(selectNodeQString(node, "PathBack")), getPath(selectNodeQString(node, "PathStatusLight")), bHorizontal);68 {
47}69 switch(i)
4870 {
49void WStatusLight::resetPositions()71 case 0:
50{72 // Set background pixmap if available
51 if (m_pPixmapBack)73 if (!selectNode(node, "BackPath").isNull())
52 {74 setPixmap(0, getPath(selectNodeQString(node, "BackPath")));
53 WPixmapStore::deletePixmap(m_pPixmapBack);75 else
54 m_pPixmapBack = 0;76 m_pPixmapSLs[0] = 0;
55 WPixmapStore::deletePixmap(m_pPixmapSL);77 break;
56 m_pPixmapSL = 0;78 case 1:
57 }79 setPixmap(1, getPath(selectNodeQString(node, "PathStatusLight")));
58}80 break;
5981 default:
60void WStatusLight::setPixmaps(const QString &backFilename, const QString &vuFilename, bool bHorizontal)82 setPixmap(i, getPath(selectNodeQString(node, QString("PathStatusLight%1").arg(i))));
61{83 }
62 m_pPixmapBack = WPixmapStore::getPixmap(backFilename);84 }
63 if (!m_pPixmapBack || m_pPixmapBack->size()==QSize(0,0))85}
64 qDebug() << "WStatusLight: Error loading back pixmap" << backFilename;86
65 m_pPixmapSL = WPixmapStore::getPixmap(vuFilename);87void WStatusLight::setPixmap(int iState, const QString &filename)
66 if (!m_pPixmapSL || m_pPixmapSL->size()==QSize(0,0))88{
67 qDebug() << "WStatusLight: Error loading statuslight pixmap" << vuFilename;89 int pixIdx = iState;
6890 m_pPixmapSLs[pixIdx] = WPixmapStore::getPixmap(filename);
69 setFixedSize(m_pPixmapBack->size());91 if (!m_pPixmapSLs[pixIdx])
70 m_bHorizontal = bHorizontal;92 qDebug() << "WPushButton: Error loading pixmap:" << filename << iState;
93
94 // Set size of widget equal to pixmap size
95 setFixedSize(m_pPixmapSLs[pixIdx]->size());
96}
97
98void WStatusLight::setValue(double v)
99{
100 if (m_iPos != (int)v)
101 {
102 m_iPos = (int)v;
103 update();
104 }
71}105}
72106
73void WStatusLight::paintEvent(QPaintEvent *)107void WStatusLight::paintEvent(QPaintEvent *)
74{108{
75 if (m_pPixmapBack!=0 && m_pPixmapSL!=0)109 if (m_pPixmapSLs[m_iPos])
76 {110 {
77 QPainter p(this);111 QPainter p(this);
78112 if(m_iPos != 0 && m_pPixmapSLs[0]) p.drawPixmap(0, 0, *m_pPixmapSLs[0]);
79 if(m_fValue == 0)113 p.drawPixmap(0, 0, *m_pPixmapSLs[m_iPos]);
80 p.drawPixmap(0, 0, *m_pPixmapBack);
81 else
82 p.drawPixmap(0, 0, *m_pPixmapSL);
83 }114 }
84}115}
85116
=== modified file 'mixxx/src/widget/wstatuslight.h'
--- mixxx/src/widget/wstatuslight.h 2009-03-05 15:45:39 +0000
+++ mixxx/src/widget/wstatuslight.h 2010-10-19 05:33:52 +0000
@@ -31,26 +31,24 @@
31 */31 */
3232
33class WStatusLight : public WWidget {33class WStatusLight : public WWidget {
34 Q_OBJECT34 Q_OBJECT
35public: 35 public:
36 WStatusLight(QWidget *parent=0);36 WStatusLight(QWidget *parent=0);
37 ~WStatusLight();37 virtual ~WStatusLight();
38 void setup(QDomNode node);38 void setup(QDomNode node);
39 void setPixmaps(const QString &backFilename, const QString &vuFilename, bool bHorizontal=false);39 void setPixmap(int iState, const QString &filename);
40 40 void setNoPos(int iNoPos);
41private:41 public slots:
42 /** Set position number to zero and deallocate pixmaps */42 void setValue(double v);
43 void resetPositions();43 private:
44 void paintEvent(QPaintEvent *);44 void paintEvent(QPaintEvent *);
4545
46 /** Current position */46 /** Current position */
47 int m_iPos;47 int m_iPos;
48 /** Number of positions associated with this knob */48 /** Number of positions associated with this light */
49 int m_iNoPos;49 int m_iNoPos;
50 /** Associated pixmaps */50 /** Associated pixmaps */
51 QPixmap *m_pPixmapBack, *m_pPixmapSL;51 QPixmap **m_pPixmapSLs;
52 /** True if it's a horizontal vu meter */
53 bool m_bHorizontal;
54};52};
5553
56#endif54#endif
5755
=== modified file 'mixxx/src/widget/wtracktableview.cpp'
--- mixxx/src/widget/wtracktableview.cpp 2010-09-17 06:09:27 +0000
+++ mixxx/src/widget/wtracktableview.cpp 2010-10-19 05:33:52 +0000
@@ -31,12 +31,11 @@
31 this, SLOT(slotPrevTrackInfo()));31 this, SLOT(slotPrevTrackInfo()));
3232
33 m_pMenu = new QMenu(this);33 m_pMenu = new QMenu(this);
34
34 m_pPlaylistMenu = new QMenu(this);35 m_pPlaylistMenu = new QMenu(this);
35 m_pPlaylistMenu->setTitle(tr("Add to Playlist"));36 m_pPlaylistMenu->setTitle(tr("Add to Playlist"));
36 m_pCrateMenu = new QMenu(this);37 m_pCrateMenu = new QMenu(this);
37 m_pCrateMenu->setTitle(tr("Add to Crate"));38 m_pCrateMenu->setTitle(tr("Add to Crate"));
38 //Disable editing
39 //setEditTriggers(QAbstractItemView::NoEditTriggers);
4039
41 //Create all the context m_pMenu->actions (stuff that shows up when you40 //Create all the context m_pMenu->actions (stuff that shows up when you
42 //right-click)41 //right-click)
@@ -614,13 +613,15 @@
614613
615void WTrackTableView::keyPressEvent(QKeyEvent* event)614void WTrackTableView::keyPressEvent(QKeyEvent* event)
616{615{
617 m_selectedIndices = this->selectionModel()->selectedRows();616
618 if (event->key() == Qt::Key_Return)617 if (event->key() == Qt::Key_Return)
619 {618 {
620 if (m_selectedIndices.size() > 0) {619 /*
621 QModelIndex index = m_selectedIndices.at(0);620 * It is not a good idea if 'key_return'
622 slotMouseDoubleClicked(index);621 * causes a track to load since we allow in-line editing
623 }622 * of table items in general
623 */
624 return;
624 }625 }
625 else if (event->key() == Qt::Key_BracketLeft)626 else if (event->key() == Qt::Key_BracketLeft)
626 {627 {

Subscribers

People subscribed via source and target branches