Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Don't merge / Obsolete] Custom Tags #2656

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,13 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/sources/soundsourceproviderregistry.cpp
src/sources/soundsourceproxy.cpp
src/sources/soundsourcesndfile.cpp
src/tagging/customtags.cpp
src/tagging/customtagsdb.cpp
src/tagging/taggingconfig.cpp
src/tagging/taggingcontext.cpp
src/tagging/taggingui.cpp
src/tagging/tagmapping.cpp
src/tagging/tags.cpp
src/track/albuminfo.cpp
src/track/beatfactory.cpp
src/track/beatgrid.cpp
Expand Down Expand Up @@ -1506,6 +1513,7 @@ add_executable(mixxx-test
src/test/cratestorage_test.cpp
src/test/cue_test.cpp
src/test/cuecontrol_test.cpp
src/test/customtags_test.cpp
src/test/dbconnectionpool_test.cpp
src/test/dbidtest.cpp
src/test/directorydaotest.cpp
Expand Down Expand Up @@ -1567,6 +1575,8 @@ add_executable(mixxx-test
src/test/sqliteliketest.cpp
src/test/synccontroltest.cpp
src/test/tableview_test.cpp
src/test/tagging_tests.cpp
src/test/tagmapping_test.cpp
src/test/taglibtest.cpp
src/test/trackdao_test.cpp
src/test/trackexport_test.cpp
Expand Down
19 changes: 19 additions & 0 deletions res/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -574,4 +574,23 @@ reapplying those migrations.
UPDATE library SET source_synchronized_ms=NULL WHERE source_synchronized_ms=0;
</sql>
</revision>
<revision version="39" min_compatible="3">
<description>
Add custom tags for tracks
</description>
<sql>
CREATE TABLE IF NOT EXISTS track_custom_tags (
id INTEGER PRIMARY KEY,
track_id INTEGER NOT NULL,
facet TEXT, -- NULL for plain tags / NOT NULL for faceted tags
label TEXT, -- NOT NULL for plain tags
score REAL NOT NULL, -- [0.0, 1.0]
FOREIGN KEY(track_id) REFERENCES library(id),
UNIQUE (facet, label, track_id)
);
CREATE INDEX IF NOT EXISTS idx_track_custom_tags_label ON track_custom_tags (
label
);
</sql>
</revision>
</schema>
2 changes: 1 addition & 1 deletion src/database/mixxxdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
const QString MixxxDb::kDefaultSchemaFile(":/schema.xml");

//static
const int MixxxDb::kRequiredSchemaVersion = 38;
const int MixxxDb::kRequiredSchemaVersion = 39;

namespace {

Expand Down
2 changes: 1 addition & 1 deletion src/library/banshee/bansheeplaylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ TrackPointer BansheePlaylistModel::getTrack(const QModelIndex& index) const {
pTrack->setAlbum(getFieldString(index, CLM_ALBUM));
pTrack->setAlbumArtist(getFieldString(index, CLM_ALBUM_ARTIST));
pTrack->setYear(getFieldString(index, CLM_YEAR));
pTrack->setGenre(getFieldString(index, CLM_GENRE));
updateTrackGenreText(pTrack.get(), getFieldString(index, CLM_GENRE));
pTrack->setGrouping(getFieldString(index, CLM_GROUPING));
pTrack->setRating(getFieldString(index, CLM_RATING).toInt());
pTrack->setTrackNumber(getFieldString(index, CLM_TRACKNUMBER));
Expand Down
2 changes: 1 addition & 1 deletion src/library/baseexternalplaylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TrackPointer BaseExternalPlaylistModel::getTrack(const QModelIndex& index) const
pTrack->setYear(year);

QString genre = index.sibling(index.row(), fieldIndex("genre")).data().toString();
pTrack->setGenre(genre);
updateTrackGenreText(pTrack.get(), genre);

float bpm = index.sibling(
index.row(), fieldIndex("bpm")).data().toString().toFloat();
Expand Down
2 changes: 1 addition & 1 deletion src/library/baseexternaltrackmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ TrackPointer BaseExternalTrackModel::getTrack(const QModelIndex& index) const {
pTrack->setTitle(title);
pTrack->setAlbum(album);
pTrack->setYear(year);
pTrack->setGenre(genre);
updateTrackGenreText(pTrack.get(), genre);
pTrack->trySetBpm(bpm);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/library/basesqltablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ bool BaseSqlTableModel::setTrackValueForColumn(
} else if (fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_YEAR) == column) {
pTrack->setYear(value.toString());
} else if (fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_GENRE) == column) {
pTrack->setGenre(value.toString());
updateTrackGenreText(pTrack.get(), value.toString());
} else if (fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COMPOSER) == column) {
pTrack->setComposer(value.toString());
} else if (fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_GROUPING) == column) {
Expand Down
4 changes: 2 additions & 2 deletions src/library/basetrackcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ BaseTrackCache::BaseTrackCache(TrackCollection* pTrackCollection,
m_columnCount(columns.size()),
m_columnsJoined(columns.join(",")),
m_columnCache(columns),
m_pQueryParser(new SearchQueryParser(pTrackCollection)),
m_pQueryParser(new SearchQueryParser(pTrackCollection, idColumn)),
m_bIndexBuilt(false),
m_bIsCaching(isCaching),
m_database(pTrackCollection->database()) {
Expand Down Expand Up @@ -370,7 +370,7 @@ void BaseTrackCache::getTrackValueForColumn(TrackPointer pTrack,
} else if (fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_LAST_PLAYED_AT) == column) {
trackValue.setValue(pTrack->getLastPlayedAt());
} else if (fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_GENRE) == column) {
trackValue.setValue(pTrack->getGenre());
trackValue.setValue(pTrack->getGenreText());
} else if (fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COMPOSER) == column) {
trackValue.setValue(pTrack->getComposer());
} else if (fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_GROUPING) == column) {
Expand Down
14 changes: 14 additions & 0 deletions src/library/basetracktablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,3 +1041,17 @@ TrackId BaseTrackTableModel::doGetTrackId(
const TrackPointer& pTrack) const {
return pTrack ? pTrack->getId() : TrackId();
}

bool BaseTrackTableModel::updateTrackGenreText(
Track* pTrack,
const mixxx::TagLabel::value_t& genreText) const {
return m_pTrackCollectionManager->updateTrackGenreText(pTrack, genreText);
}

#if defined(__EXTRA_METADATA__)
bool BaseTrackTableModel::updateTrackMoodText(
Track* pTrack,
const mixxx::TagLabel::value_t& moodText) const {
return m_pTrackCollectionManager->updateTrackMoodText(pTrack, moodText);
}
#endif // __EXTRA_METADATA__
9 changes: 9 additions & 0 deletions src/library/basetracktablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel {
TrackPointer getTrackByRef(
const TrackRef& trackRef) const override;

bool updateTrackGenreText(
Track* pTrack,
const mixxx::TagLabel::value_t& genreText) const override;
#if defined(__EXTRA_METADATA__)
bool updateTrackMoodText(
Track* pTrack,
const mixxx::TagLabel::value_t& moodText) const override;
#endif // __EXTRA_METADATA__

protected:
static constexpr int defaultColumnWidth() {
return 50;
Expand Down
16 changes: 15 additions & 1 deletion src/library/browse/browsetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ bool BrowseTableModel::setData(
pTrack->setComment(value.toString());
break;
case COLUMN_GENRE:
pTrack->setGenre(value.toString());
m_pTrackCollectionManager->updateTrackGenreText(pTrack.get(), value.toString());
break;
case COLUMN_COMPOSER:
pTrack->setComposer(value.toString());
Expand Down Expand Up @@ -475,3 +475,17 @@ QAbstractItemDelegate* BrowseTableModel::delegateForColumn(const int i, QObject*
}
return nullptr;
}

bool BrowseTableModel::updateTrackGenreText(
Track* pTrack,
const mixxx::TagLabel::value_t& genreText) const {
return m_pTrackCollectionManager->updateTrackGenreText(pTrack, genreText);
}

#if defined(__EXTRA_METADATA__)
bool BrowseTableModel::updateTrackMoodText(
Track* pTrack,
const mixxx::TagLabel::value_t& moodText) const {
return m_pTrackCollectionManager->updateTrackMoodText(pTrack, moodText);
}
#endif // __EXTRA_METADATA__
9 changes: 9 additions & 0 deletions src/library/browse/browsetablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ class BrowseTableModel final : public QStandardItemModel, public virtual TrackMo
TrackModel::SortColumnId sortColumnIdFromColumnIndex(int index) const override;
int columnIndexFromSortColumnId(TrackModel::SortColumnId sortColumn) const override;

bool updateTrackGenreText(
Track* pTrack,
const mixxx::TagLabel::value_t& genreText) const override;
#if defined(__EXTRA_METADATA__)
bool updateTrackMoodText(
Track* pTrack,
const mixxx::TagLabel::value_t& moodText) const override;
#endif // __EXTRA_METADATA__

public slots:
void slotClear(BrowseTableModel*);
void slotInsert(const QList< QList<QStandardItem*> >&, BrowseTableModel*);
Expand Down
2 changes: 2 additions & 0 deletions src/library/browse/browsethread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "library/browse/browsetablemodel.h"
#include "moc_browsethread.cpp"
#include "sources/soundsourceproxy.h"
#include "tagging/taggingconfig.h"
#include "track/track.h"
#include "util/datetime.h"
#include "util/trace.h"
Expand Down Expand Up @@ -137,6 +138,7 @@ void BrowseThread::populateModel() {
QList< QList<QStandardItem*> > rows;

int row = 0;

// Iterate over the files
while (fileIt.hasNext()) {
// If a user quickly jumps through the folders
Expand Down
Loading