Skip to content

Commit

Permalink
Merge pull request #42 from UltraStar-Deluxe/support_tags
Browse files Browse the repository at this point in the history
Add support for #TAGS tag.
  • Loading branch information
bohning authored Sep 18, 2024
2 parents 442c326 + 02a59bf commit 2eb5984
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 18 deletions.
14 changes: 14 additions & 0 deletions src/QUSongSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ QStringList QUSongSupport::availableTags() {
result << GENRE_TAG;
result << YEAR_TAG;
result << CREATOR_TAG;
result << TAGS_TAG;
result << MP3_TAG;
result << COVER_TAG;
result << BACKGROUND_TAG;
Expand Down Expand Up @@ -487,6 +488,19 @@ QStringList QUSongSupport::availableSongYears() {
return result;
}

QStringList QUSongSupport::availableSongTags() {
QStringList result;

result << "Christmas";
result << "Clean";
result << "Duet";
result << "Explicit";
result << "Eurovision";
result << "Kids";

return result;
}

QString QUSongSupport::defaultInputEncoding() {
QStringList result = registryKey("defaultInputEncoding", "CP1252");
return result.first();
Expand Down
1 change: 1 addition & 0 deletions src/QUSongSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class QUSongSupport: QObject {
static QStringList availableSongEditions();
static QStringList availableSongGenres();
static QStringList availableSongYears();
static QStringList availableSongTags();

static QString defaultInputEncoding();

Expand Down
27 changes: 14 additions & 13 deletions src/report/QUAbstractReportData.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@
#define GENRE_COL 4
#define YEAR_COL 5
#define CREATOR_COL 6
#define AUDIO_EXISTS_COL 7
#define COVER_EXISTS_COL 8
#define BACKGROUND_EXISTS_COL 9
#define VIDEO_EXISTS_COL 10
#define MEDLEY_EXISTS_COL 11
#define GOLDEN_NOTES_EXIST_COL 12
#define RAP_NOTES_EXIST_COL 13
#define SONG_PATH_COL 14
#define SONG_FILE_PATH_COL 15
#define REL_SONG_FILE_PATH_COL 16
#define LENGTH_COL 17
#define SPEED_COL 18
#define CUSTOM_TAG_COL 19
#define TAGS_COL 7
#define AUDIO_EXISTS_COL 8
#define COVER_EXISTS_COL 9
#define BACKGROUND_EXISTS_COL 10
#define VIDEO_EXISTS_COL 11
#define MEDLEY_EXISTS_COL 12
#define GOLDEN_NOTES_EXIST_COL 13
#define RAP_NOTES_EXIST_COL 14
#define SONG_PATH_COL 15
#define SONG_FILE_PATH_COL 16
#define REL_SONG_FILE_PATH_COL 17
#define LENGTH_COL 18
#define SPEED_COL 19
#define CUSTOM_TAG_COL 20

class QUAbstractReportData: public QObject {
Q_OBJECT
Expand Down
1 change: 1 addition & 0 deletions src/report/QUReportDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void QUReportDialog::initReportList() {
reportList->addItem(new QUReportItem(new QUSongTagData(GENRE_TAG)));
reportList->addItem(new QUReportItem(new QUSongTagData(YEAR_TAG)));
reportList->addItem(new QUReportItem(new QUSongTagData(CREATOR_TAG)));
reportList->addItem(new QUReportItem(new QUSongTagData(TAGS_TAG)));

reportList->addItem(new QUReportItem(new QUBooleanSongData(MP3_TAG)));
reportList->addItem(new QUReportItem(new QUBooleanSongData(COVER_TAG)));
Expand Down
8 changes: 8 additions & 0 deletions src/report/QUSongTagData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ QUSongTagData::QUSongTagData(const QString &tag, QObject *parent): QUAbstractRep
this->setIcon(QIcon(":/types/creator.png"));
this->setDescription(tr("Creator"));
this->setID(CREATOR_COL);
} else if(QString::compare(_tag, TAGS_TAG, Qt::CaseInsensitive) == 0) {
this->setIcon(QIcon(":/types/tags.png"));
this->setDescription(tr("Tags"));
this->setID(TAGS_COL);
} else if(QUSongSupport::availableCustomTags().contains(tag, Qt::CaseInsensitive)) {
this->setIcon(QIcon(":/bullets/bullet_star.png"));
this->setDescription(tag);
Expand All @@ -54,6 +58,8 @@ QString QUSongTagData::textData(QUSongFile *song) {
return song->year();
if(QString::compare(_tag, CREATOR_TAG, Qt::CaseInsensitive) == 0)
return song->creator();
if(QString::compare(_tag, TAGS_TAG, Qt::CaseInsensitive) == 0)
return song->tags();
if(QUSongSupport::availableCustomTags().contains(_tag, Qt::CaseInsensitive))
return song->customTag(_tag);

Expand Down Expand Up @@ -82,6 +88,8 @@ void QUSongTagData::sort(QList<QUSongFile*> &songs) {
std::stable_sort(songs.begin(), songs.end(), QUSongFile::yearLessThan);
else if(QString::compare(_tag, CREATOR_TAG, Qt::CaseInsensitive) == 0)
std::stable_sort(songs.begin(), songs.end(), QUSongFile::creatorLessThan);
else if(QString::compare(_tag, TAGS_TAG, Qt::CaseInsensitive) == 0)
std::stable_sort(songs.begin(), songs.end(), QUSongFile::tagsLessThan);

// TODO: sort custom tag columns
}
1 change: 1 addition & 0 deletions src/resources/UltraStar-Manager.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
<file>rap_notes.png</file>
<file>writeID3.png</file>
<file>sync.png</file>
<file>tags.png</file>
</qresource>
<qresource prefix="/big">
<file>save_big.png</file>
Expand Down
Binary file added src/resources/tags.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/song/QUSongFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ bool QUSongFile::editionLessThan (QUSongFile *s1, QUSongFile *s2) { return QSt
bool QUSongFile::genreLessThan (QUSongFile *s1, QUSongFile *s2) { return QString::compare(s1->genre(), s2->genre(), Qt::CaseInsensitive) < 0; }
bool QUSongFile::yearLessThan (QUSongFile *s1, QUSongFile *s2) { return QString::compare(s1->year(), s2->year(), Qt::CaseInsensitive) < 0; }
bool QUSongFile::creatorLessThan (QUSongFile *s1, QUSongFile *s2) { return QString::compare(s1->creator(), s2->creator(), Qt::CaseInsensitive) < 0; }
bool QUSongFile::tagsLessThan (QUSongFile *s1, QUSongFile *s2) { return QString::compare(s1->tags(), s2->tags(), Qt::CaseInsensitive) < 0; }

bool QUSongFile::pathLessThan (QUSongFile *s1, QUSongFile *s2) { return QString::compare(s1->path(), s2->path(), Qt::CaseInsensitive) < 0; }
bool QUSongFile::filePathLessThan (QUSongFile *s1, QUSongFile *s2) { return QString::compare(s1->filePath(), s2->filePath(), Qt::CaseInsensitive) < 0; }
Expand Down
2 changes: 2 additions & 0 deletions src/song/QUSongFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class QUSongFile: public QUSongInterface {
static bool genreLessThan (QUSongFile *s1, QUSongFile *s2);
static bool yearLessThan (QUSongFile *s1, QUSongFile *s2);
static bool creatorLessThan (QUSongFile *s1, QUSongFile *s2);
static bool tagsLessThan (QUSongFile *s1, QUSongFile *s2);

static bool pathLessThan (QUSongFile *s1, QUSongFile *s2);
static bool filePathLessThan (QUSongFile *s1, QUSongFile *s2);
Expand Down Expand Up @@ -77,6 +78,7 @@ public slots:
QString year() const {return _info.value(YEAR_TAG, QString(N_A));}
QString end() const {return _info.value(END_TAG, QString(N_A));}
QString creator() const {return _info.value(CREATOR_TAG, QString(N_A));}
QString tags() const {return _info.value(TAGS_TAG, QString(N_A));}
QString encoding() const {return _info.value(ENCODING_TAG, QString(N_A));}
QString previewstart() const {return _info.value(PREVIEWSTART_TAG, QString(N_A));}
QString calcmedley() const {return _info.value(CALCMEDLEY_TAG, QString(N_A));}
Expand Down
3 changes: 3 additions & 0 deletions src/song/QUSongInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class QFileInfo;
#define GENRE_TAG "GENRE"
#define YEAR_TAG "YEAR"
#define CREATOR_TAG "CREATOR"
#define TAGS_TAG "TAGS"
#define MP3_TAG "MP3"
#define COVER_TAG "COVER"
#define BACKGROUND_TAG "BACKGROUND"
Expand Down Expand Up @@ -134,6 +135,7 @@ class QUSongInterface: public QObject {
Q_PROPERTY(QString year READ year)
Q_PROPERTY(QString end READ end)
Q_PROPERTY(QString creator READ creator)
Q_PROPERTY(QString tags READ tags)
Q_PROPERTY(QString encoding READ encoding)
Q_PROPERTY(QString previewstart READ previewstart)
Q_PROPERTY(QString calcmedley READ calcmedley)
Expand Down Expand Up @@ -192,6 +194,7 @@ class QUSongInterface: public QObject {
virtual QString year() const = 0;
virtual QString end() const = 0;
virtual QString creator() const = 0;
virtual QString tags() const = 0;
virtual QString encoding() const = 0;
virtual QString previewstart() const = 0;
virtual QString calcmedley() const = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/songdetails/QUDetailItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ void QUDetailItem::reset() {
_hasDynamicDefaultData = false;
} else if(QString::compare(_tag, CREATOR_TAG) == 0) {
_flagsForMultipleSongs = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
} else if(QString::compare(_tag, TAGS_TAG) == 0) {
_flagsForMultipleSongs = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
setData(Qt::UserRole, QUSongSupport::availableSongTags()); // static default data
_hasDynamicDefaultData = false;
// } else if(QString::compare(_tag, MP3_TAG) == 0) {
// } else if(QString::compare(_tag, COVER_TAG) == 0) {
// } else if(QString::compare(_tag, BACKGROUND_TAG) == 0) {
Expand Down
2 changes: 2 additions & 0 deletions src/songdetails/QUDetailsTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void QUDetailsTable::initTagColumn() {
this->setItem(row++, 0, new QUTagItem(QIcon(":/types/genre.png"), tr("Genre")));
this->setItem(row++, 0, new QUTagItem(QIcon(":/types/date.png"), tr("Year")));
this->setItem(row++, 0, new QUTagItem(QIcon(":/types/creator.png"), tr("Creator")));
this->setItem(row++, 0, new QUTagItem(QIcon(":/types/tags.png"), tr("Tags")));
this->setItem(row++, 0, new QUTagItem(QIcon(":/types/album.png"), tr("Album")));
this->setItem(row++, 0, new QUTagItem(QIcon(":/types/comment.png"), tr("Comment")));
this->setItem(row++, 0, new QUTagItem(QIcon(":/types/source.png"), tr("Source")));
Expand Down Expand Up @@ -98,6 +99,7 @@ void QUDetailsTable::initValueColumn() {
this->setItem(row++, 1, new QUDetailItem(GENRE_TAG));
this->setItem(row++, 1, new QUDetailItem(YEAR_TAG));
this->setItem(row++, 1, new QUDetailItem(CREATOR_TAG));
this->setItem(row++, 1, new QUDetailItem(TAGS_TAG));
this->setItem(row++, 1, new QUDetailItem(ALBUM_TAG));
this->setItem(row++, 1, new QUDetailItem(COMMENT_TAG));
this->setItem(row++, 1, new QUDetailItem(SOURCE_TAG));
Expand Down
1 change: 1 addition & 0 deletions src/songtree/QUSongItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ void QUSongItem::updateTextColumns() {
this->setText(GENRE_COLUMN, song()->genre()); if(song()->genre() != N_A) this->setToolTip(GENRE_COLUMN, song()->genre());
this->setText(YEAR_COLUMN, song()->year()); if(song()->year() != N_A) this->setToolTip(YEAR_COLUMN, song()->year());
this->setText(CREATOR_COLUMN, song()->creator()); if(song()->creator() != N_A) this->setToolTip(CREATOR_COLUMN, song()->creator());
this->setText(TAGS_COLUMN, song()->tags()); if(song()->tags() != N_A) this->setToolTip(TAGS_COLUMN, song()->tags());

// show custom tags
int i = 0;
Expand Down
11 changes: 6 additions & 5 deletions src/songtree/QUSongItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@
#define GENRE_COLUMN 28
#define YEAR_COLUMN 29
#define CREATOR_COLUMN 30
#define TAGS_COLUMN 31

#define RELATIVE_COLUMN 31
#define BPM_COLUMN 32
#define GAP_COLUMN 33
#define RELATIVE_COLUMN 32
#define BPM_COLUMN 33
#define GAP_COLUMN 34

#define DUPLICATE_ID_COLUMN 34
#define DUPLICATE_ID_COLUMN 35

#define FIRST_CUSTOM_TAG_COLUMN 35
#define FIRST_CUSTOM_TAG_COLUMN 36

/*!
* This class encapsulates a pointer to a QUSongFile object to be able
Expand Down
4 changes: 4 additions & 0 deletions src/songtree/QUSongTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ void QUSongTree::initHorizontalHeader() {
header->setIcon(YEAR_COLUMN, QIcon(":/types/date.png"));
header->setText(CREATOR_COLUMN, tr("Creator"));
header->setIcon(CREATOR_COLUMN, QIcon(":/types/creator.png"));
header->setText(TAGS_COLUMN, tr("Tags"));
header->setIcon(TAGS_COLUMN, QIcon(":/types/tags.png"));

header->setText(LENGTH_COLUMN, tr("Song"));
header->setIcon(LENGTH_COLUMN, QIcon(":/types/time_song.png"));
Expand Down Expand Up @@ -424,6 +426,7 @@ void QUSongTree::filterItems(const QString &regexp, QU::FilterModes mode) {
song->year().contains(rx) ||
song->edition().contains(rx) ||
song->creator().contains(rx) ||
song->tags().contains(rx) ||
song->language().contains(rx);

if(!matchesInfoTag)
Expand Down Expand Up @@ -732,6 +735,7 @@ void QUSongTree::showDefaultColumns(bool save) {
this->header()->showSection(GENRE_COLUMN);
this->header()->showSection(YEAR_COLUMN);
this->header()->showSection(CREATOR_COLUMN);
this->header()->showSection(TAGS_COLUMN);

int customTagsCount = QUSongSupport::availableCustomTags().size();
for(int i = 0; i < customTagsCount; ++i)
Expand Down

0 comments on commit 2eb5984

Please sign in to comment.