From b11adda333e8980c7bf245afae2523b5ec42c88a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20B=C3=B6hning?= <1497707+bohning@users.noreply.github.com> Date: Sat, 14 Sep 2024 19:24:15 +0200 Subject: [PATCH 1/2] Fix most clazy issues. --- src/QUMainWindow.cpp | 16 +-- src/QUSongSupport.cpp | 29 ++-- src/QUStringSupport.cpp | 24 ++-- src/filter/QUMetaphoneString.cpp | 12 +- src/lyricseditor/QULyricsEdit.cpp | 9 +- src/lyricseditor/QULyricsEditorDialog.cpp | 2 +- src/mediaplayer/QUAutoCue.cpp | 5 +- src/mediaplayer/QUMediaPlayer.cpp | 4 +- src/playlist/QUPlaylistDatabase.cpp | 10 +- src/playlist/QUPlaylistFile.cpp | 10 +- src/playlistdetails/QUPlayList.cpp | 4 +- src/playlistdetails/QUPlayListItem.cpp | 4 +- src/playlistdetails/QUPlaylistArea.cpp | 7 +- src/playlistdetails/QUPlaylistDBModel.cpp | 4 +- src/playlistdetails/QUPlaylistModel.cpp | 12 +- src/plugins/QUPluginModel.cpp | 7 +- src/preview/QUPreviewTree.cpp | 14 +- src/remoteimages/QUCoverGroup.cpp | 12 +- src/remoteimages/QURemoteImageDialog.cpp | 4 +- src/report/QUCSVReport.cpp | 2 +- src/report/QUHtmlReport.cpp | 6 +- src/report/QUPdfReport.cpp | 2 +- src/report/QUPlainTextReport.cpp | 9 +- src/ribbon/QURibbonBar.cpp | 2 +- src/slideshow/QUSlideShowDialog.cpp | 3 +- src/song/QUSongDatabase.cpp | 2 +- src/song/QUSongFile.cpp | 165 +++++++++++----------- src/song/QUSongFile.h | 2 +- src/songdetails/QUDetailItem.cpp | 10 +- src/songdetails/QUDropDownDelegate.cpp | 7 +- src/songtree/QUSongItem.cpp | 12 +- src/songtree/QUSongTree.cpp | 44 +++--- src/support/QUTextDialog.cpp | 5 +- src/webinfo/QUWebInfoTree.cpp | 23 +-- 34 files changed, 245 insertions(+), 238 deletions(-) diff --git a/src/QUMainWindow.cpp b/src/QUMainWindow.cpp index 56323f43..693ebdab 100644 --- a/src/QUMainWindow.cpp +++ b/src/QUMainWindow.cpp @@ -258,7 +258,7 @@ void QUMainWindow::initWindow() { windowIcon.addFile(":/icons/UltraStar-Manager128.png", QSize(128, 128)); setWindowIcon(windowIcon); - setWindowTitle(QString("%1%2").arg(tr("UltraStar Manager")).arg(WIP_TEXT)); + setWindowTitle(QString("%1%2").arg(tr("UltraStar Manager"), WIP_TEXT)); resize(1000, 500); addDockWidget(Qt::LeftDockWidgetArea, detailsDock); @@ -743,25 +743,25 @@ void QUMainWindow::editSongSetFileLink(QTreeWidgetItem *item, int column) { if( songItem->icon(MP3_COLUMN).isNull() && QUSongSupport::allowedAudioFiles().contains(fileScheme, Qt::CaseInsensitive) && column == MP3_COLUMN ) { - logSrv->add(QString(tr("Audio file changed from \"%1\" to: \"%2\".")).arg(song->mp3()).arg(songItem->text(FOLDER_COLUMN)), QU::Information); + logSrv->add(QString(tr("Audio file changed from \"%1\" to: \"%2\".")).arg(song->mp3(), songItem->text(FOLDER_COLUMN)), QU::Information); song->setInfo(MP3_TAG, songItem->text(FOLDER_COLUMN)); song->save(); } else if( songItem->icon(COVER_COLUMN).isNull() && QUSongSupport::allowedImageFiles().contains(fileScheme, Qt::CaseInsensitive) && column == COVER_COLUMN ) { - logSrv->add(QString(tr("Cover changed from \"%1\" to: \"%2\".")).arg(song->cover()).arg(songItem->text(FOLDER_COLUMN)), QU::Information); + logSrv->add(QString(tr("Cover changed from \"%1\" to: \"%2\".")).arg(song->cover(), songItem->text(FOLDER_COLUMN)), QU::Information); song->setInfo(COVER_TAG, songItem->text(FOLDER_COLUMN)); song->save(); } else if( songItem->icon(BACKGROUND_COLUMN).isNull() && QUSongSupport::allowedImageFiles().contains(fileScheme, Qt::CaseInsensitive) && column == BACKGROUND_COLUMN ) { - logSrv->add(QString(tr("Background changed from \"%1\" to: \"%2\".")).arg(song->background()).arg(songItem->text(FOLDER_COLUMN)), QU::Information); + logSrv->add(QString(tr("Background changed from \"%1\" to: \"%2\".")).arg(song->background(), songItem->text(FOLDER_COLUMN)), QU::Information); song->setInfo(BACKGROUND_TAG, songItem->text(FOLDER_COLUMN)); song->save(); } else if( songItem->icon(VIDEO_COLUMN).isNull() && QUSongSupport::allowedVideoFiles().contains(fileScheme, Qt::CaseInsensitive) && column == VIDEO_COLUMN ) { - logSrv->add(QString(tr("Video file changed from \"%1\" to: \"%2\".")).arg(song->video()).arg(songItem->text(FOLDER_COLUMN)), QU::Information); + logSrv->add(QString(tr("Video file changed from \"%1\" to: \"%2\".")).arg(song->video(), songItem->text(FOLDER_COLUMN)), QU::Information); song->setInfo(VIDEO_TAG, songItem->text(FOLDER_COLUMN)); song->save(); } @@ -792,7 +792,7 @@ void QUMainWindow::editSongSetDetail(QTableWidgetItem *item) { // save changes for each song foreach(QUSongItem *songItem, selectedItems) { - dlg.update(QString("%1 - %2").arg(songItem->song()->artist()).arg(songItem->song()->title())); + dlg.update(QString("%1 - %2").arg(songItem->song()->artist(), songItem->song()->title())); if(dlg.cancelled()) break; // delete medley tags if CALCMEDLEY_TAG is set to OFF @@ -835,7 +835,7 @@ void QUMainWindow::editSongApplyTasks() { QUSongFile *song = songItem->song(); itemExpandedStates.append(songItem->isExpanded()); - dlg.update(QString("%1 - %2").arg(song->artist()).arg(song->title())); + dlg.update(QString("%1 - %2").arg(song->artist(), song->title())); if(dlg.cancelled()) break; songDB->ignoreChangesForSong(song); @@ -942,7 +942,7 @@ void QUMainWindow::saveLog() { out.setGenerateByteOrderMark(true); for(int row = 0; row < log->count(); ++row) { - out << QString("%1 %2").arg(log->item(row)->data(Qt::UserRole).toString()).arg(log->item(row)->text()) << Qt::endl; + out << QString("%1 %2").arg(log->item(row)->data(Qt::UserRole).toString(), log->item(row)->text()) << Qt::endl; } file.close(); diff --git a/src/QUSongSupport.cpp b/src/QUSongSupport.cpp index 18827b8e..cddacbd1 100644 --- a/src/QUSongSupport.cpp +++ b/src/QUSongSupport.cpp @@ -1,4 +1,4 @@ -#include "QUSongSupport.h" +#include "QUSongSupport.h" #include "QUSongInterface.h" #include @@ -488,39 +488,48 @@ QStringList QUSongSupport::availableSongYears() { } QString QUSongSupport::defaultInputEncoding() { - return registryKey("defaultInputEncoding", "CP1252").first(); + QStringList result = registryKey("defaultInputEncoding", "CP1252"); + return result.first(); } int QUSongSupport::mediumMp3Quality() { - return registryKey("mediumMp3Quality", "96").first().toInt(); + QStringList result = registryKey("mediumMp3Quality", "96"); + return result.first().toInt(); } int QUSongSupport::highMp3Quality() { - return registryKey("highMp3Quality", "128").first().toInt(); + QStringList result = registryKey("highMp3Quality", "128"); + return result.first().toInt(); } int QUSongSupport::mediumCoverQuality() { - return registryKey("mediumCoverQuality", "400 x 400").first().toInt(); + QStringList result = registryKey("mediumCoverQuality", "400 x 400"); + return result.first().toInt(); } int QUSongSupport::highCoverQuality() { - return registryKey("highCoverQuality", "600 x 600").first().toInt(); + QStringList result = registryKey("highCoverQuality", "600 x 600"); + return result.first().toInt(); } int QUSongSupport::mediumBackgroundQuality() { - return registryKey("mediumBackgroundQuality", "1280 x 720").first().toInt(); + QStringList result = registryKey("mediumBackgroundQuality", "1280 x 720"); + return result.first().toInt(); } int QUSongSupport::highBackgroundQuality() { - return registryKey("highBackgroundQuality", "1920 x 1080").first().toInt(); + QStringList result = registryKey("highBackgroundQuality", "1920 x 1080"); + return result.first().toInt(); } int QUSongSupport::mediumVideoQuality() { - return registryKey("mediumVideoQuality", "1280 x 720").first().toInt(); + QStringList result = registryKey("mediumVideoQuality", "1280 x 720"); + return result.first().toInt(); } int QUSongSupport::highVideoQuality() { - return registryKey("highVideoQuality", "1920 x 1080").first().toInt(); + QStringList result = registryKey("highVideoQuality", "1920 x 1080"); + return result.first().toInt(); } /*! diff --git a/src/QUStringSupport.cpp b/src/QUStringSupport.cpp index 1f858233..46ecd206 100644 --- a/src/QUStringSupport.cpp +++ b/src/QUStringSupport.cpp @@ -22,7 +22,8 @@ QString QUStringSupport::withoutUnsupportedCharacters(const QString &text) { // replace asterixes by dashes cleanText.replace('*', '-'); // remove everything else: '\', ':', '*', '?', '"', '|', '<', '>', '^' - cleanText.remove(QRegularExpression("[\\\\:\\*\\?\"\\|<>\\^]")); + static const QRegularExpression regex("[\\\\:\\*\\?\"\\|<>\\^]"); + cleanText.remove(regex); bool dotsRemoved = false; @@ -52,8 +53,8 @@ QString QUStringSupport::withoutPathDelimiters(const QString &text) { * Remove all "folder tags" like [SC], [VIDEO], a.s.o. from the given text. */ QString QUStringSupport::withoutFolderTags(const QString &text) { - QRegularExpression rx("\\[.*\\]", QRegularExpression::InvertedGreedinessOption); - return QString(text).remove(rx).trimmed(); + static const QRegularExpression regex("\\[.*\\]", QRegularExpression::InvertedGreedinessOption); + return QString(text).remove(regex).trimmed(); } /*! @@ -109,12 +110,17 @@ QString QUStringSupport::simplifiedQueryString(const QString &text) { QString result = text; // remove any additions in parentheses - result.remove(QRegularExpression("\\(.*\\)")); + static const QRegularExpression regex1("\\(.*\\)"); + result.remove(regex1); // remove additional artists listed as 'feat.', 'ft.', 'with' or 'vs.'/'vs' - result.remove(QRegularExpression(" feat\\. .*")); - result.remove(QRegularExpression(" ft\\. .*")); - result.remove(QRegularExpression(" with .*")); - result.remove(QRegularExpression(" vs\\.? .*")); + static const QRegularExpression regex2(" feat\\. .*"); + result.remove(regex2); + static const QRegularExpression regex3(" ft\\. .*"); + result.remove(regex3); + static const QRegularExpression regex4(" with .*"); + result.remove(regex4); + static const QRegularExpression regex5(" vs\\.? .*"); + result.remove(regex5); // remove the ampersand character result.replace(" & ", " "); // remove the plus character @@ -129,7 +135,7 @@ QString QUStringSupport::simplifiedQueryString(const QString &text) { } QStringList QUStringSupport::extractTags(const QString &text) { - QRegularExpression rx = QRegularExpression("\\[([^\\]]+)\\]"); + static const QRegularExpression rx = QRegularExpression("\\[([^\\]]+)\\]"); QRegularExpressionMatchIterator i = rx.globalMatch(text); QStringList tags; diff --git a/src/filter/QUMetaphoneString.cpp b/src/filter/QUMetaphoneString.cpp index e773a48d..4bdb3212 100644 --- a/src/filter/QUMetaphoneString.cpp +++ b/src/filter/QUMetaphoneString.cpp @@ -6,14 +6,16 @@ #include bool QUMetaphoneString::isSlavoGermanic() { - return contains(QRegularExpression("W|K|CZ|WITZ")); + static const QRegularExpression regex("W|K|CZ|WITZ"); + return contains(regex); } bool QUMetaphoneString::hasVowel(int at) { if( (at < 0) || (at >= _length) ) return false; - return QRegularExpression(QRegularExpression::anchoredPattern("[AEIOUY]")).match(mid(at, 1)).hasMatch(); + static const QRegularExpression regex(QRegularExpression::anchoredPattern("[AEIOUY]")); + return regex.match(mid(at, 1)).hasMatch(); } @@ -815,9 +817,9 @@ bool QUMetaphoneString::equal(QString token1, QString token2, bool ignoreEmpty) // replace "lonely, unimportant" words token1.append(' '); token1.prepend(' '); token2.append(' '); token2.prepend(' '); - QRegularExpression rx(" THE | DER | DIE | DAS | A | AN | EIN "); - token1.replace(rx, " "); - token2.replace(rx, " "); + static const QRegularExpression regex(" THE | DER | DIE | DAS | A | AN | EIN "); + token1.replace(regex, " "); + token2.replace(regex, " "); token1 = token1.simplified().trimmed(); token2 = token2.simplified().trimmed(); diff --git a/src/lyricseditor/QULyricsEdit.cpp b/src/lyricseditor/QULyricsEdit.cpp index 8eeacf3a..470686a0 100644 --- a/src/lyricseditor/QULyricsEdit.cpp +++ b/src/lyricseditor/QULyricsEdit.cpp @@ -75,11 +75,12 @@ void QULyricsEdit::initLyrics() { setItem(index, 0, timeItem); setRowHeight(index, 16); - if(!line->notes().isEmpty() && bpm != 0.0) { // show timestamps + auto notes = line->notes(); + if(!notes.isEmpty() && bpm != 0.0) { // show timestamps if(!_song->isRelative()) { - beats = line->notes().first()->timestamp(); + beats = notes.first()->timestamp(); } else { - beats += line->notes().first()->timestamp(); + beats += notes.first()->timestamp(); } int seconds = qMax(0, int((beats / (bpm * 4)) * 60 + gap)); @@ -88,7 +89,7 @@ void QULyricsEdit::initLyrics() { .arg(int(seconds % 60), 2, 10, QChar('0'))); if(_song->isRelative()) - beats += line->inTime() - line->notes().first()->timestamp(); + beats += line->inTime() - notes.first()->timestamp(); } index++; diff --git a/src/lyricseditor/QULyricsEditorDialog.cpp b/src/lyricseditor/QULyricsEditorDialog.cpp index bfaa7f26..7f06fc08 100644 --- a/src/lyricseditor/QULyricsEditorDialog.cpp +++ b/src/lyricseditor/QULyricsEditorDialog.cpp @@ -13,7 +13,7 @@ QULyricsEditorDialog::QULyricsEditorDialog(QUSongFile *song, QWidget *parent): Q connect(searchEdit, SIGNAL(textEdited(QString)), this, SLOT(search(QString))); textLbl->setText(tr("Edit each syllable of each line and fix spelling or wrong whitespaces manually.")); - this->setWindowTitle(QString(tr("Edit Lyrics: \"%1 - %2\"")).arg(song->artist()).arg(song->title())); + this->setWindowTitle(QString(tr("Edit Lyrics: \"%1 - %2\"")).arg(song->artist(), song->title())); songLbl->setText(song->songFileInfo().fileName()); } diff --git a/src/mediaplayer/QUAutoCue.cpp b/src/mediaplayer/QUAutoCue.cpp index 05b3c4bd..fc397009 100644 --- a/src/mediaplayer/QUAutoCue.cpp +++ b/src/mediaplayer/QUAutoCue.cpp @@ -32,8 +32,9 @@ void QUAutoCue::reset(const QList &lines, double bpm, doub int lineNumber = 0; foreach(QUSongLineInterface *line, lines) { int last = 0; - foreach(QUSongNoteInterface *note, line->notes()) { - if(note != line->notes().first()) { + auto notes = line->notes(); + foreach(QUSongNoteInterface *note, notes) { + if(note != notes.first()) { if(last == note->timestamp()) // no space _cueList.pop_back(); } diff --git a/src/mediaplayer/QUMediaPlayer.cpp b/src/mediaplayer/QUMediaPlayer.cpp index 839e13c1..36c4fdc1 100644 --- a/src/mediaplayer/QUMediaPlayer.cpp +++ b/src/mediaplayer/QUMediaPlayer.cpp @@ -114,7 +114,7 @@ void QUMediaPlayer::play() { _freeIndices.removeAll(_currentSongIndex); if(!info.isValid()) { - logSrv->add(tr("[Media Player] The song \"%1 - %2\" has no valid audio file.").arg(info.artist).arg(info.title), QU::Warning); + logSrv->add(tr("[Media Player] The song \"%1 - %2\" has no valid audio file.").arg(info.artist, info.title), QU::Warning); loopBtn->setChecked(false); // avoid endless-loops next(); return; @@ -296,7 +296,7 @@ void QUMediaPlayer::updateInfoLabel(QUMediaPlayer::States state) { return; // invalid index QUSongInfo info = _songs.at(_currentSongIndex); - currentSongLbl->setText(QString("%1
%2").arg(info.artist).arg(info.title)); + currentSongLbl->setText(QString("%1
%2").arg(info.artist, info.title)); infoIconLbl->setToolTip( QString(tr("Bitrate: %1 kbit/s
Channels: %2
Sample Rate: %3 kHz")) .arg(info.bitrate) diff --git a/src/playlist/QUPlaylistDatabase.cpp b/src/playlist/QUPlaylistDatabase.cpp index 2d780169..f5b5cac9 100644 --- a/src/playlist/QUPlaylistDatabase.cpp +++ b/src/playlist/QUPlaylistDatabase.cpp @@ -62,7 +62,7 @@ void QUPlaylistDatabase::connectAllPlaylists() { dlg.show(); foreach(QUPlaylistFile *playlist, _playlists) { - dlg.update(QString("%1 (%2)").arg(playlist->name()).arg(playlist->fileInfo().fileName())); + dlg.update(QString("%1 (%2)").arg(playlist->name(), playlist->fileInfo().fileName())); playlist->connectSongs(); } @@ -75,7 +75,7 @@ void QUPlaylistDatabase::disconnectAllPlaylists() { dlg.show(); foreach(QUPlaylistFile *playlist, _playlists) { - dlg.update(QString("%1 (%2)").arg(playlist->name()).arg(playlist->fileInfo().fileName())); + dlg.update(QString("%1 (%2)").arg(playlist->name(), playlist->fileInfo().fileName())); playlist->disconnectSongs(); } @@ -133,7 +133,7 @@ void QUPlaylistDatabase::save() { QString( tr("Save playlist \"%1\" as...")).arg(playlist->name()), dir().path(), - QString(tr("UltraStar Playlists (%1);;Vocaluxe Playlists (%2)")).arg(QUSongSupport::allowedUltraStarPlaylistFiles().join(" ")).arg(QUSongSupport::allowedVocaluxePlaylistFiles().join(" "))); + QString(tr("UltraStar Playlists (%1);;Vocaluxe Playlists (%2)")).arg(QUSongSupport::allowedUltraStarPlaylistFiles().join(" "), QUSongSupport::allowedVocaluxePlaylistFiles().join(" "))); if(!filePath.isEmpty()) { playlist->setFileInfo(QFileInfo(filePath)); @@ -177,7 +177,7 @@ bool QUPlaylistDatabase::hasUnsavedChanges() const { dlg.show(); foreach(QUPlaylistFile *playlist, playlists()) { - dlg.update(QString("%1 (%2)").arg(playlist->name()).arg(playlist->fileInfo().fileName())); + dlg.update(QString("%1 (%2)").arg(playlist->name(), playlist->fileInfo().fileName())); if(playlist->hasUnsavedChanges()) return true; @@ -192,7 +192,7 @@ void QUPlaylistDatabase::saveUnsavedChanges() { dlg.show(); foreach(QUPlaylistFile *playlist, playlists()) { - dlg.update(QString("%1 (%2)").arg(playlist->name()).arg(playlist->fileInfo().fileName())); + dlg.update(QString("%1 (%2)").arg(playlist->name(), playlist->fileInfo().fileName())); if(playlist->hasUnsavedChanges()) playlist->save(); diff --git a/src/playlist/QUPlaylistFile.cpp b/src/playlist/QUPlaylistFile.cpp index 153e93b5..91951d78 100644 --- a/src/playlist/QUPlaylistFile.cpp +++ b/src/playlist/QUPlaylistFile.cpp @@ -75,7 +75,7 @@ bool QUPlaylistFile::save() { uint num = 1; foreach(QUPlaylistEntry *entry, _playlist) { if(!entry->song()) - logSrv->add(QString(tr("Warning! The playlist entry \"%1 - %2\" will NOT be found by Vocaluxe/UltraStar!")).arg(entry->artistLink()).arg(entry->titleLink()), QU::Warning); + logSrv->add(QString(tr("Warning! The playlist entry \"%1 - %2\" will NOT be found by Vocaluxe/UltraStar!")).arg(entry->artistLink(), entry->titleLink()), QU::Warning); else entry->setLinks(entry->song()->artist(), entry->song()->title()); @@ -115,7 +115,7 @@ bool QUPlaylistFile::save() { } // write name of playlist - _out << QString("#%1: %2\n").arg(NAME_TAG).arg(_name); + _out << QString("#%1: %2\n").arg(NAME_TAG, _name); _nameChanged = false; _playlistChanged = false; @@ -123,11 +123,11 @@ bool QUPlaylistFile::save() { _out << QString("#%1:\n").arg(SONGS_TAG); foreach(QUPlaylistEntry *entry, _playlist) { if(!entry->song()) - logSrv->add(QString(tr("Warning! The playlist entry \"%1 - %2\" will NOT be found by UltraStar!")).arg(entry->artistLink()).arg(entry->titleLink()), QU::Warning); + logSrv->add(QString(tr("Warning! The playlist entry \"%1 - %2\" will NOT be found by UltraStar!")).arg(entry->artistLink(), entry->titleLink()), QU::Warning); else entry->setLinks(entry->song()->artist(), entry->song()->title()); - _out << QString("%1 : %2\n").arg(entry->artistLink()).arg(entry->titleLink()); + _out << QString("%1 : %2\n").arg(entry->artistLink(), entry->titleLink()); } } @@ -169,7 +169,7 @@ bool QUPlaylistFile::addEntry(QUSongFile *song) { foreach(QUPlaylistEntry *entry, _playlist) { // TODO: a progressbar helpful?! (for big playlists) if(song == entry->song()) { - logSrv->add(QString(tr("The song \"%1 - %2\" is already in the current playlist. It was not added.")).arg(song->artist()).arg(song->title()), QU::Warning); + logSrv->add(QString(tr("The song \"%1 - %2\" is already in the current playlist. It was not added.")).arg(song->artist(), song->title()), QU::Warning); return false; } } diff --git a/src/playlistdetails/QUPlayList.cpp b/src/playlistdetails/QUPlayList.cpp index 05df6c2b..792e7210 100644 --- a/src/playlistdetails/QUPlayList.cpp +++ b/src/playlistdetails/QUPlayList.cpp @@ -116,7 +116,7 @@ void QUPlayList::setGameModeMedley() { if(entry->song()->hasMedley()) { entry->setGameMode(GAMEMODE_MEDLEY); } else { - logSrv->add(QString(tr("Unable to set game mode to 'Medley'. The playlist entry \"%1 - %2\" does NOT have a medley section!")).arg(entry->artistLink()).arg(entry->titleLink()), QU::Warning); + logSrv->add(QString(tr("Unable to set game mode to 'Medley'. The playlist entry \"%1 - %2\" does NOT have a medley section!")).arg(entry->artistLink(), entry->titleLink()), QU::Warning); } } update(); @@ -128,7 +128,7 @@ void QUPlayList::setGameModeDuet() { if(entry->song()->isDuet()) { entry->setGameMode(GAMEMODE_DUET); } else { - logSrv->add(QString(tr("Unable to set game mode to 'Duet'. The playlist entry \"%1 - %2\" is NOT a duet!")).arg(entry->artistLink()).arg(entry->titleLink()), QU::Warning); + logSrv->add(QString(tr("Unable to set game mode to 'Duet'. The playlist entry \"%1 - %2\" is NOT a duet!")).arg(entry->artistLink(), entry->titleLink()), QU::Warning); } } update(); diff --git a/src/playlistdetails/QUPlayListItem.cpp b/src/playlistdetails/QUPlayListItem.cpp index 4d205330..a032e5b1 100644 --- a/src/playlistdetails/QUPlayListItem.cpp +++ b/src/playlistdetails/QUPlayListItem.cpp @@ -18,14 +18,14 @@ void QUPlayListItem::updateData() { f.setBold(false); if(entry()->song()) { - this->setText(QString("%1. %2 - %3").arg(listWidget()->row(this) + 1).arg(entry()->song()->artist()).arg(entry()->song()->title())); + this->setText(QString("%1. %2 - %3").arg(listWidget()->row(this) + 1).arg(entry()->song()->artist(), entry()->song()->title())); this->setForeground(Qt::black); if(entry()->hasUnsavedChanges()) f.setBold(true); } else { - this->setText(QString("%1. %2 - %3 (not found)").arg(listWidget()->row(this) + 1).arg(entry()->artistLink()).arg(entry()->titleLink())); + this->setText(QString("%1. %2 - %3 (not found)").arg(listWidget()->row(this) + 1).arg(entry()->artistLink(), entry()->titleLink())); this->setForeground(Qt::gray); } diff --git a/src/playlistdetails/QUPlaylistArea.cpp b/src/playlistdetails/QUPlaylistArea.cpp index ee06d150..1a39a562 100644 --- a/src/playlistdetails/QUPlaylistArea.cpp +++ b/src/playlistdetails/QUPlaylistArea.cpp @@ -69,7 +69,7 @@ void QUPlaylistArea::addSongToCurrentPlaylist(QUSongFile *song) { return; if(!playlistDB->currentPlaylist()) { - logSrv->add(QString(tr("Could NOT add song \"%1 - %2\" to playlist. Try to create a new playlist.")).arg(song->artist()).arg(song->title()), QU::Warning); + logSrv->add(QString(tr("Could NOT add song \"%1 - %2\" to playlist. Try to create a new playlist.")).arg(song->artist(), song->title()), QU::Warning); return; } @@ -113,7 +113,7 @@ void QUPlaylistArea::saveCurrentPlaylistAs() { if(!playlistDB->currentPlaylist()) return; - QString filePath = QFileDialog::getSaveFileName(this, tr("Save playlist as..."), playlistDB->dir().path(), QString(tr("UltraStar Playlists (%1);;Vocaluxe Playlists (%2)")).arg(QUSongSupport::allowedUltraStarPlaylistFiles().join(" ")).arg(QUSongSupport::allowedVocaluxePlaylistFiles().join(" "))); + QString filePath = QFileDialog::getSaveFileName(this, tr("Save playlist as..."), playlistDB->dir().path(), QString(tr("UltraStar Playlists (%1);;Vocaluxe Playlists (%2)")).arg(QUSongSupport::allowedUltraStarPlaylistFiles().join(" "), QUSongSupport::allowedVocaluxePlaylistFiles().join(" "))); if(!filePath.isEmpty()) { QFileInfo oldFi = playlistDB->currentPlaylist()->fileInfo(); @@ -187,8 +187,7 @@ void QUPlaylistArea::removeCurrentPlaylist() { int result = QUMessageBox::information(this, tr("Delete Playlist"), QString(tr("\"%1 (%2)\" will be deleted permanently. You cannot undo a delete operation.")) - .arg(playlistDB->currentPlaylist()->name()) - .arg(playlistDB->currentPlaylist()->fileInfo().fileName()), + .arg(playlistDB->currentPlaylist()->name(), playlistDB->currentPlaylist()->fileInfo().fileName()), BTN << ":/control/bin.png" << tr("Delete this playlist.") << ":/marks/cancel.png" << tr("Cancel delete operation.")); if(result == 1) diff --git a/src/playlistdetails/QUPlaylistDBModel.cpp b/src/playlistdetails/QUPlaylistDBModel.cpp index 55dcd69b..5740028d 100644 --- a/src/playlistdetails/QUPlaylistDBModel.cpp +++ b/src/playlistdetails/QUPlaylistDBModel.cpp @@ -24,9 +24,7 @@ QVariant QUPlaylistDBModel::data(const QModelIndex &index, int role) const { if(role == Qt::DisplayRole) { return QString("%1%2 (%3)") - .arg( playlistDB->at(index.row())->name() ) - .arg( playlistDB->at(index.row())->hasUnsavedChanges() ? "*" : "" ) - .arg( playlistDB->dir().relativeFilePath( playlistDB->at(index.row())->fileInfo().filePath()) ); + .arg(playlistDB->at(index.row())->name(), playlistDB->at(index.row())->hasUnsavedChanges() ? "*" : "", playlistDB->dir().relativeFilePath( playlistDB->at(index.row())->fileInfo().filePath())); } else if(role == Qt::FontRole) { QFont f( "MS Shell Dlg", 8, diff --git a/src/playlistdetails/QUPlaylistModel.cpp b/src/playlistdetails/QUPlaylistModel.cpp index 83e394c4..16d8b77c 100644 --- a/src/playlistdetails/QUPlaylistModel.cpp +++ b/src/playlistdetails/QUPlaylistModel.cpp @@ -33,17 +33,9 @@ QVariant QUPlaylistModel::data(const QModelIndex &index, int role) const { if(role == Qt::DisplayRole) { if(song) - return QString("%1. %2 - %3 (%4)") - .arg( index.row() + 1) - .arg( song->artist() ) - .arg( song->title() ) - .arg( entry->gameMode().remove("TR_GAMEMODE_").toLower() ); + return QString("%1. %2 - %3 (%4)").arg(QString::number(index.row() + 1), song->artist(), song->title(), entry->gameMode().remove("TR_GAMEMODE_").toLower()); else - return QString(tr("%1. %2 - %3 (%4) (not found)")) - .arg( index.row() + 1) - .arg( entry->artistLink() ) - .arg( entry->titleLink() ) - .arg( entry->gameMode().remove("TR_GAMEMODE_").toLower() ); + return QString(tr("%1. %2 - %3 (%4) (not found)")).arg(QString::number(index.row() + 1), entry->artistLink(), entry->titleLink(), entry->gameMode().remove("TR_GAMEMODE_").toLower()); } else if(role == Qt::FontRole) { QFont f("MS Shell Dlg", 8, QFont::Normal, false); if(entry->hasUnsavedChanges()) diff --git a/src/plugins/QUPluginModel.cpp b/src/plugins/QUPluginModel.cpp index f75f9e9d..5205ed7d 100644 --- a/src/plugins/QUPluginModel.cpp +++ b/src/plugins/QUPluginModel.cpp @@ -47,12 +47,7 @@ QVariant QUPluginModel::data(const QModelIndex &index, int role) const { stuff += tr("
Subtype: Background Images"); } - return tr("%1
%2

Author: %3
Version: %4
%5") - .arg(pluginMGR->plugins().at(index.row())->name()) - .arg(pluginMGR->plugins().at(index.row())->description()) - .arg(pluginMGR->plugins().at(index.row())->author()) - .arg(pluginMGR->plugins().at(index.row())->version()) - .arg(stuff); + return tr("%1
%2

Author: %3
Version: %4
%5").arg(pluginMGR->plugins().at(index.row())->name(), pluginMGR->plugins().at(index.row())->description(), pluginMGR->plugins().at(index.row())->author(), pluginMGR->plugins().at(index.row())->version(), stuff); } return QVariant(); diff --git a/src/preview/QUPreviewTree.cpp b/src/preview/QUPreviewTree.cpp index e3a8aaac..94b80961 100644 --- a/src/preview/QUPreviewTree.cpp +++ b/src/preview/QUPreviewTree.cpp @@ -354,7 +354,7 @@ void QUPreviewTree::showAudioFileInformation(const QFileInfo &fi) { QString formatAudio(QString::fromStdWString(MI.Get(Stream_Audio, 0, __T("Format"), Info_Text, Info_Name))); QString codecIDAudio(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("CodecID"), Info_Text, Info_Name))); if(formatAudio != "") { - if(codecIDAudio != "") audio->addChild(this->createInfoItem(tr("Format"), QString("%1 (%2)").arg(formatAudio).arg(codecIDAudio))); + if(codecIDAudio != "") audio->addChild(this->createInfoItem(tr("Format"), QString("%1 (%2)").arg(formatAudio, codecIDAudio))); else audio->addChild(this->createInfoItem(tr("Format"), QString("%1").arg(formatAudio))); } QString profileAudio(QString::fromStdWString(MI.Get(Stream_Audio, 0, __T("Format_Profile"), Info_Text, Info_Name))); @@ -428,7 +428,7 @@ void QUPreviewTree::showVideoFileInformation(const QFileInfo &fi) { QString format(QString::fromStdWString(MI.Get(Stream_General, 0, __T("Format"), Info_Text, Info_Name))); QString codecID(QString::fromStdWString(MI.Get(Stream_General, 0, __T("CodecID"), Info_Text, Info_Name))); if(format != "") { - if(codecID != "") video->addChild(this->createInfoItem(tr("Format"), QString("%1 (%2)").arg(format).arg(codecID))); + if(codecID != "") video->addChild(this->createInfoItem(tr("Format"), QString("%1 (%2)").arg(format, codecID))); else video->addChild(this->createInfoItem(tr("Format"), QString("%1").arg(format))); } QString profile(QString::fromStdWString(MI.Get(Stream_General, 0, __T("Format_Profile"), Info_Text, Info_Name))); @@ -436,7 +436,7 @@ void QUPreviewTree::showVideoFileInformation(const QFileInfo &fi) { QString countVideo(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("StreamCount"), Info_Text, Info_Name))); QString countAudio(QString::fromStdWString(MI.Get(Stream_Audio, 0, __T("StreamCount"), Info_Text, Info_Name))); if(countAudio == "") countAudio = "no"; - video->addChild(this->createInfoItem(tr("Streams"), QString("%1 (%2 video, %3 audio)").arg(countVideo.toInt()+countAudio.toInt()).arg(countVideo).arg(countAudio))); + video->addChild(this->createInfoItem(tr("Streams"), QString("%1 (%2 video, %3 audio)").arg(countVideo.toInt()+countAudio.toInt()).arg(countVideo, countAudio))); // video stream information video->addChild(this->createInfoItem("", "")); @@ -446,11 +446,11 @@ void QUPreviewTree::showVideoFileInformation(const QFileInfo &fi) { QString width(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("Width"), Info_Text, Info_Name))); QString height(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("Height"), Info_Text, Info_Name))); QString aspectRatio(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("DisplayAspectRatio/String"), Info_Text, Info_Name))); - if(width != "" || height != "" || aspectRatio != "") video->addChild(this->createInfoItem(tr("Dimensions"), QString("%1 x %2 px (%3)").arg(width).arg(height).arg(aspectRatio))); + if(width != "" || height != "" || aspectRatio != "") video->addChild(this->createInfoItem(tr("Dimensions"), QString("%1 x %2 px (%3)").arg(width, height, aspectRatio))); QString formatVideo(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("Format"), Info_Text, Info_Name))); QString codecIDVideo(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("CodecID"), Info_Text, Info_Name))); if(formatVideo != "") { - if(codecIDVideo != "") video->addChild(this->createInfoItem(tr("Format"), QString("%1 (%2)").arg(formatVideo).arg(codecIDVideo))); + if(codecIDVideo != "") video->addChild(this->createInfoItem(tr("Format"), QString("%1 (%2)").arg(formatVideo, codecIDVideo))); else video->addChild(this->createInfoItem(tr("Format"), QString("%1").arg(formatVideo))); } QString profileVideo(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("Format_Profile"), Info_Text, Info_Name))); @@ -469,7 +469,7 @@ void QUPreviewTree::showVideoFileInformation(const QFileInfo &fi) { QString frameRate(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("FrameRate"), Info_Text, Info_Name))); QString frameRateMode(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("FrameRate_Mode/String"), Info_Text, Info_Name))); if(frameRate != "") { - if(frameRateMode != "") video->addChild(this->createInfoItem(tr("Framerate"), QString("%1 fps (%2)").arg(frameRate).arg(frameRateMode.toLower()))); + if(frameRateMode != "") video->addChild(this->createInfoItem(tr("Framerate"), QString("%1 fps (%2)").arg(frameRate, frameRateMode.toLower()))); else video->addChild(this->createInfoItem(tr("Framerate"), QString("%1 fps").arg(frameRate))); } QString colorSpace(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("ColorSpace"), Info_Text, Info_Name))); @@ -491,7 +491,7 @@ void QUPreviewTree::showVideoFileInformation(const QFileInfo &fi) { QString formatAudio(QString::fromStdWString(MI.Get(Stream_Audio, 0, __T("Format"), Info_Text, Info_Name))); QString codecIDAudio(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("CodecID"), Info_Text, Info_Name))); if(formatAudio != "") { - if(codecIDAudio != "") video->addChild(this->createInfoItem(tr("Format"), QString("%1 (%2)").arg(formatAudio).arg(codecIDAudio))); + if(codecIDAudio != "") video->addChild(this->createInfoItem(tr("Format"), QString("%1 (%2)").arg(formatAudio, codecIDAudio))); else video->addChild(this->createInfoItem(tr("Format"), QString("%1").arg(formatAudio))); } QString profileAudio(QString::fromStdWString(MI.Get(Stream_Audio, 0, __T("Format_Profile"), Info_Text, Info_Name))); diff --git a/src/remoteimages/QUCoverGroup.cpp b/src/remoteimages/QUCoverGroup.cpp index c9be5beb..a93fc2e6 100644 --- a/src/remoteimages/QUCoverGroup.cpp +++ b/src/remoteimages/QUCoverGroup.cpp @@ -67,7 +67,7 @@ void QUCoverGroup::showCovers() { } void QUCoverGroup::showFailure() { - logSrv->add(tr("Cover download failed for \"%1 - %2\"").arg(song()->artist()).arg(song()->title()), QU::Error); + logSrv->add(tr("Cover download failed for \"%1 - %2\"").arg(song()->artist(), song()->title()), QU::Error); } /*! @@ -82,14 +82,14 @@ QString QUCoverGroup::currentFilePath() const { */ void QUCoverGroup::copyCoverToSongPath(bool deleteCurrentCover) { if(currentFilePath().isEmpty()) { - logSrv->add(QString(tr("Could not copy cover to song path. No cover selected for: \"%1 - %2\"")).arg(song()->artist()).arg(song()->title()), QU::Warning); + logSrv->add(QString(tr("Could not copy cover to song path. No cover selected for: \"%1 - %2\"")).arg(song()->artist(), song()->title()), QU::Warning); return; } QFileInfo target(song()->songFileInfo().dir(), "cover_" + QFileInfo(currentFilePath()).fileName()); if(!QFile::copy(currentFilePath(), target.filePath())) { - logSrv->add(QString(tr("Could not copy the new cover \"%1\" to \"%2\".")).arg(currentFilePath()).arg(target.filePath()), QU::Warning); + logSrv->add(QString(tr("Could not copy the new cover \"%1\" to \"%2\".")).arg(currentFilePath(), target.filePath()), QU::Warning); return; } @@ -99,7 +99,7 @@ void QUCoverGroup::copyCoverToSongPath(bool deleteCurrentCover) { logSrv->add(QString(tr("Could not delete current cover: \"%1\"")).arg(song()->coverFileInfo().filePath()), QU::Warning); song()->autoSetFile(target, true); } else { - logSrv->add(QString(tr("Current cover was replaced successfully for: \"%1 - %2\"")).arg(song()->artist()).arg(song()->title()), QU::Information); + logSrv->add(QString(tr("Current cover was replaced successfully for: \"%1 - %2\"")).arg(song()->artist(), song()->title()), QU::Information); QFile::rename(target.filePath(), oldName); } } else { @@ -113,9 +113,9 @@ void QUCoverGroup::copyCoverToSongPath(bool deleteCurrentCover) { void QUCoverGroup::showStatus(const QString &status) { if(!status.isEmpty()) - group->setTitle(QString("%1 - %2 (%3)").arg(song()->artist()).arg(song()->title()).arg(status)); + group->setTitle(QString("%1 - %2 (%3)").arg(song()->artist(), song()->title(), status)); else - group->setTitle(QString("%1 - %2").arg(song()->artist()).arg(song()->title())); + group->setTitle(QString("%1 - %2").arg(song()->artist(), song()->title())); } void QUCoverGroup::openAmazonSearchUrl() { diff --git a/src/remoteimages/QURemoteImageDialog.cpp b/src/remoteimages/QURemoteImageDialog.cpp index 015e057a..35793a0a 100644 --- a/src/remoteimages/QURemoteImageDialog.cpp +++ b/src/remoteimages/QURemoteImageDialog.cpp @@ -87,7 +87,7 @@ void QURemoteImageDialog::initResultsPage(const QList &items) { bool createGroups = _groups.isEmpty(); for(int i = 0; i < songs.size(); ++i) { - dlg.update(QString("%1 - %2").arg(songs.at(i)->artist()).arg(songs.at(i)->title())); + dlg.update(QString("%1 - %2").arg(songs.at(i)->artist(), songs.at(i)->title())); if(dlg.cancelled()) break; if(createGroups) { @@ -132,7 +132,7 @@ void QURemoteImageDialog::updateResultsPage() { } for(int i = 0; i < songs.size(); ++i) { - dlg.update(QString("%1 - %2").arg(songs.at(i)->artist()).arg(songs.at(i)->title())); + dlg.update(QString("%1 - %2").arg(songs.at(i)->artist(), songs.at(i)->title())); if(dlg.cancelled()) break; _groups.at(i)->setCollector(collectors.at(i)); diff --git a/src/report/QUCSVReport.cpp b/src/report/QUCSVReport.cpp index 5e773ed4..801218fc 100644 --- a/src/report/QUCSVReport.cpp +++ b/src/report/QUCSVReport.cpp @@ -49,7 +49,7 @@ void QUCSVReport::printSongTable(QTextStream &out) { int rn = 1, max = QVariant(songs().size()).toString().length(); foreach(QUSongFile *song, songs()) { - pDlg.update(QString("%1 - %2").arg(song->artist()).arg(song->title())); + pDlg.update(QString("%1 - %2").arg(song->artist(), song->title())); if(pDlg.cancelled()) break; /* running number */ diff --git a/src/report/QUHtmlReport.cpp b/src/report/QUHtmlReport.cpp index c1932fca..7d967992 100644 --- a/src/report/QUHtmlReport.cpp +++ b/src/report/QUHtmlReport.cpp @@ -144,7 +144,7 @@ void QUHtmlReport::appendSongsTableBody(QDomNode &parent) { int rn = 1; foreach(QUSongFile *song, songs()) { - pDlg.update(QString("%1 - %2").arg(song->artist()).arg(song->title())); + pDlg.update(QString("%1 - %2").arg(song->artist(), song->title())); if(pDlg.cancelled()) break; QDomElement tr = _report.createElement("tr"); @@ -217,7 +217,7 @@ void QUHtmlReport::appendLyrics(QDomNode &parent) { int rn = 1; foreach(QUSongFile *song, songs()) { - pDlg.update(QString("%1 - %2").arg(song->artist()).arg(song->title())); + pDlg.update(QString("%1 - %2").arg(song->artist(), song->title())); if(pDlg.cancelled()) break; QDomElement div = _report.createElement("div"); @@ -226,7 +226,7 @@ void QUHtmlReport::appendLyrics(QDomNode &parent) { div.setAttribute("id", QVariant(rn).toString()); QDomElement h1 = _report.createElement("h1"); - h1.appendChild(_report.createTextNode(QString("%3. %1 - %2").arg(song->artist()).arg(song->title()).arg(rn))); + h1.appendChild(_report.createTextNode(QString("%3. %1 - %2").arg(song->artist(), song->title(), QString::number(rn)))); div.appendChild(h1); QString lyrics = "

"; diff --git a/src/report/QUPdfReport.cpp b/src/report/QUPdfReport.cpp index 7f24f8ce..43791ec8 100644 --- a/src/report/QUPdfReport.cpp +++ b/src/report/QUPdfReport.cpp @@ -172,7 +172,7 @@ bool QUPdfReport::save() { int currentColumn = 0; foreach(QUSongFile *song, songs()) { - pDlg.update(QString("%1 - %2").arg(song->artist()).arg(song->title())); + pDlg.update(QString("%1 - %2").arg(song->artist(), song->title())); if(pDlg.cancelled()) break; diff --git a/src/report/QUPlainTextReport.cpp b/src/report/QUPlainTextReport.cpp index 676d8379..d7e61c3c 100644 --- a/src/report/QUPlainTextReport.cpp +++ b/src/report/QUPlainTextReport.cpp @@ -71,7 +71,7 @@ void QUPlainTextReport::printSongTable(QTextStream &out) { int rn = 1, max = QVariant(songs().size()).toString().length(); foreach(QUSongFile *song, songs()) { - pDlg.update(QString("%1 - %2").arg(song->artist()).arg(song->title())); + pDlg.update(QString("%1 - %2").arg(song->artist(), song->title())); if(pDlg.cancelled()) break; /* running number */ @@ -101,15 +101,16 @@ void QUPlainTextReport::printLyrics(QTextStream &out) { int i = 1; foreach(QUSongFile *song, songs()) { - pDlg.update(QString("%1 - %2").arg(song->artist()).arg(song->title())); + pDlg.update(QString("%1 - %2").arg(song->artist(), song->title())); if(pDlg.cancelled()) break; - QString subheader = QString("%3. %1 - %2").arg(song->artist()).arg(song->title()).arg(i++, QVariant(songs().size()).toString().length(), 10, QChar('0')); + QString subheader = QString("%3. %1 - %2").arg(song->artist(), song->title()).arg(i++, QVariant(songs().size()).toString().length(), 10, QChar('0')); out << QString(subheader.length(), '-') << Qt::endl; out << subheader << Qt::endl; out << QString(subheader.length(), '-') << Qt::endl; - out << song->lyrics().join("\n").remove(QRegularExpression("|||")) << Qt::endl << Qt::endl; + static const QRegularExpression regex("|||"); + out << song->lyrics().join("\n").remove(regex) << Qt::endl << Qt::endl; } } diff --git a/src/ribbon/QURibbonBar.cpp b/src/ribbon/QURibbonBar.cpp index fec6eb98..ccc9cdf6 100644 --- a/src/ribbon/QURibbonBar.cpp +++ b/src/ribbon/QURibbonBar.cpp @@ -59,7 +59,7 @@ void QURibbonBar::setShortcut(QToolButton *w, const QKeySequence &key) { connect(a, SIGNAL(triggered()), w, SLOT(click())); addAction(a); - w->setToolTip(QString("%1 (%2)").arg(w->toolTip()).arg(key.toString())); + w->setToolTip(QString("%1 (%2)").arg(w->toolTip(), key.toString())); } QSize QURibbonBar::sizeHint() const { diff --git a/src/slideshow/QUSlideShowDialog.cpp b/src/slideshow/QUSlideShowDialog.cpp index fbe24ffb..4849fbb6 100644 --- a/src/slideshow/QUSlideShowDialog.cpp +++ b/src/slideshow/QUSlideShowDialog.cpp @@ -50,8 +50,7 @@ void QUSlideShowDialog::changeSelection(int index) { return; songLbl->setText(QString("%1
%2") - .arg(_items.at(index)->song()->artist()) - .arg(_items.at(index)->song()->titleCompact())); + .arg(_items.at(index)->song()->artist(), _items.at(index)->song()->titleCompact())); disconnect(unlinkChk, SIGNAL(toggled(bool)), this, SLOT(changeUnlinkFlag(bool))); unlinkChk->setChecked(_items.at(index)->data(COVER_COLUMN, Qt::UserRole + 1).toBool()); diff --git a/src/song/QUSongDatabase.cpp b/src/song/QUSongDatabase.cpp index 8b958234..25df09b8 100644 --- a/src/song/QUSongDatabase.cpp +++ b/src/song/QUSongDatabase.cpp @@ -63,7 +63,7 @@ void QUSongDatabase::deleteSong(QUSongFile *song) { delete song; - logSrv->add(QString(tr("Song was deleted successfully: \"%1 - %2\"")).arg(artist).arg(title), QU::Information); + logSrv->add(QString(tr("Song was deleted successfully: \"%1 - %2\"")).arg(artist, title), QU::Information); } void QUSongDatabase::clear() { diff --git a/src/song/QUSongFile.cpp b/src/song/QUSongFile.cpp index f2c73c71..4b5fa028 100644 --- a/src/song/QUSongFile.cpp +++ b/src/song/QUSongFile.cpp @@ -217,12 +217,12 @@ bool QUSongFile::updateCache() { setInfo(ENCODING_TAG, QUSongSupport::defaultInputEncoding()); //_in.setCodec(QTextCodec::codecForName("windows-1252")); _in.setEncoding(QStringConverter::Latin1); - logSrv->add(QString(tr("Encoding mismatch. Defaulting to %1 for song file: \"%2\"")).arg(encoding()).arg(QDir::toNativeSeparators(_fi.filePath())), QU::Warning); + logSrv->add(QString(tr("Encoding mismatch. Defaulting to %1 for song file: \"%2\"")).arg(encoding(), QDir::toNativeSeparators(_fi.filePath())), QU::Warning); } else { setInfo(ENCODING_TAG, QUSongSupport::defaultInputEncoding()); //_in.setCodec(QTextCodec::codecForName("windows-1252")); _in.setEncoding(QStringConverter::Latin1); - logSrv->add(QString(tr("\"%1\" unsupported. Defaulting to %2 for song file: \"%3\"")).arg(firstLine).arg(encoding()).arg(QDir::toNativeSeparators(_fi.filePath())), QU::Warning); + logSrv->add(QString(tr("\"%1\" unsupported. Defaulting to %2 for song file: \"%3\"")).arg(firstLine, encoding(), QDir::toNativeSeparators(_fi.filePath())), QU::Warning); } } else { // no #ENCODING tag present // undo reading first line @@ -231,7 +231,7 @@ bool QUSongFile::updateCache() { setInfo(ENCODING_TAG, QUSongSupport::defaultInputEncoding()); //_in.setCodec(QTextCodec::codecForName("windows-1252")); _in.setEncoding(QStringConverter::Latin1); - logSrv->add(QString(tr("Not a valid UTF8 file and ENCODING tag missing. Defaulting to %1 in song file: \"%2\"")).arg(encoding()).arg(QDir::toNativeSeparators(_fi.filePath())), QU::Information); + logSrv->add(QString(tr("Not a valid UTF8 file and ENCODING tag missing. Defaulting to %1 in song file: \"%2\"")).arg(encoding(), QDir::toNativeSeparators(_fi.filePath())), QU::Information); } } @@ -242,7 +242,8 @@ bool QUSongFile::updateCache() { */ QString line; - while( !(QRegularExpression(QRegularExpression::anchoredPattern("([:\\*FRGE\\-].*)|(P\\s*[123].*)")).match(line).hasMatch() || _in.atEnd()) ) { + static const QRegularExpression regex(QRegularExpression::anchoredPattern("([:\\*FRGE\\-].*)|(P\\s*[123].*)")); + while( !(regex.match(line).hasMatch() || _in.atEnd()) ) { line = QUStringSupport::withoutLeadingBlanks(_in.readLine()); // read supported tags @@ -276,7 +277,8 @@ bool QUSongFile::updateCache() { // read lyrics + other stuff (distinct them) while( !_in.atEnd() ) { - if(QRegularExpression(QRegularExpression::anchoredPattern("([:\\*FRG\\-].*)|(P\\s*[123].*)")).match(line).hasMatch()) + static const QRegularExpression regex(QRegularExpression::anchoredPattern("([:\\*FRG\\-].*)|(P\\s*[123].*)")); + if(regex.match(line).hasMatch()) _lyrics << line; else if(QString::compare(line.trimmed(), "E", Qt::CaseInsensitive) != 0 && !line.isEmpty()) _footer << line; @@ -286,7 +288,8 @@ bool QUSongFile::updateCache() { // use last line buffer // TODO: a little bit dirty here (duplicate code) - if(QRegularExpression(QRegularExpression::anchoredPattern("[:\\*FRG\\-].*")).match(line).hasMatch()) + static const QRegularExpression regexNote(QRegularExpression::anchoredPattern("[:\\*FRG\\-].*")); + if(regexNote.match(line).hasMatch()) _lyrics << line; else if(QString::compare(line.trimmed(), "E", Qt::CaseInsensitive) != 0 && !line.isEmpty()) _footer << line; @@ -437,7 +440,7 @@ bool QUSongFile::isDuet() const { } bool QUSongFile::isKaraoke() const { - QRegularExpression rxTag("kar(aoke)?", QRegularExpression::CaseInsensitiveOption); + static const QRegularExpression rxTag("kar(aoke)?", QRegularExpression::CaseInsensitiveOption); foreach(QString fiTag, _fiTags) { // look for a []-tag that could be the singer name if(fiTag.contains(rxTag)) @@ -614,9 +617,9 @@ QStringList QUSongFile::lyrics() const { QStringList _lyricsCopy = _lyrics; QStringList result; result << QString(); - QRegularExpression lineBreak(QRegularExpression::anchoredPattern("\\s*-.*")); - QRegularExpression lineSinger(QRegularExpression::anchoredPattern("\\s*P\\s*[123].*")); - QRegularExpression linePrefix(QRegularExpression::anchoredPattern("\\s*[:\\*FRG]\\s*-?\\d+\\s+\\d+\\s+-?\\d+\\s")); + static const QRegularExpression lineBreak(QRegularExpression::anchoredPattern("\\s*-.*")); + static const QRegularExpression lineSinger(QRegularExpression::anchoredPattern("\\s*P\\s*[123].*")); + static const QRegularExpression linePrefix(QRegularExpression::anchoredPattern("\\s*[:\\*FRG]\\s*-?\\d+\\s+\\d+\\s+-?\\d+\\s")); int lastBeat = -1; @@ -641,7 +644,8 @@ QStringList QUSongFile::lyrics() const { if(lastBeat != -1) { // insert an empty line? QString lineCopy = line; - lineCopy.remove(QRegularExpression("[:\\*FRG]")); + static const QRegularExpression regex("[:\\*FRG]"); + lineCopy.remove(regex); int nextBeat = QVariant(lineCopy.section(" ", 0, 0, QString::SectionSkipEmpty)).toInt(); if(nextBeat - lastBeat > 20) @@ -650,14 +654,18 @@ QStringList QUSongFile::lyrics() const { } line.remove("\n"); + static const QRegularExpression golden(QRegularExpression::anchoredPattern("\\s*\\*.*")); + static const QRegularExpression freestyle(QRegularExpression::anchoredPattern("\\s*F.*")); + static const QRegularExpression rap(QRegularExpression::anchoredPattern("\\s*R.*")); + static const QRegularExpression rapgolden(QRegularExpression::anchoredPattern("\\s*G.*")); - if(QRegularExpression(QRegularExpression::anchoredPattern("\\s*\\*.*")).match(line).hasMatch()) // golden note + if(golden.match(line).hasMatch()) result.last() += line.remove(linePrefix).append("").prepend(""); - else if(QRegularExpression(QRegularExpression::anchoredPattern("\\s*F.*")).match(line).hasMatch()) // freestyle note + else if(freestyle.match(line).hasMatch()) result.last() += line.remove(linePrefix).append("").prepend(""); - else if(QRegularExpression(QRegularExpression::anchoredPattern("\\s*R.*")).match(line).hasMatch()) // rap note + else if(rap.match(line).hasMatch()) result.last() += line.remove(linePrefix).append("").prepend(""); - else if(QRegularExpression(QRegularExpression::anchoredPattern("\\s*G.*")).match(line).hasMatch()) // rap golden note + else if(rapgolden.match(line).hasMatch()) result.last() += line.remove(linePrefix).append("").prepend(""); else result.last() += line.remove(linePrefix); @@ -790,7 +798,7 @@ void QUSongFile::renameSongDir(const QString &newName) { QString oldName(_fi.dir().dirName()); if(!rename(dir, oldName, newName)) { - logSrv->add(QString(tr("Could NOT rename the song directory \"%1\" to \"%2\".")).arg(oldName).arg(newName), QU::Warning); + logSrv->add(QString(tr("Could NOT rename the song directory \"%1\" to \"%2\".")).arg(oldName, newName), QU::Warning); return; } @@ -798,7 +806,7 @@ void QUSongFile::renameSongDir(const QString &newName) { setFile(dir.absoluteFilePath(_fi.fileName()), false); emit songPathChanged(_fi.filePath()); - logSrv->add(QString(tr("Song directory renamed from: \"%1\" to: \"%2\".")).arg(oldName).arg(newName), QU::Information); + logSrv->add(QString(tr("Song directory renamed from: \"%1\" to: \"%2\".")).arg(oldName, newName), QU::Information); } /*! @@ -809,14 +817,14 @@ void QUSongFile::renameSongTxt(const QString &newName) { QString oldName(_fi.fileName()); if(!rename(_fi.dir(), oldName, newName)) { - logSrv->add(QString(tr("Could NOT rename the song file \"%1\" to \"%2\".")).arg(oldName).arg(newName), QU::Warning); + logSrv->add(QString(tr("Could NOT rename the song file \"%1\" to \"%2\".")).arg(oldName, newName), QU::Warning); return; } setFile(_fi.dir().absoluteFilePath(newName), false); emit songRenamed(newName); - logSrv->add(QString(tr("Song file renamed from: \"%1\" to: \"%2\".")).arg(oldName).arg(newName), QU::Information); + logSrv->add(QString(tr("Song file renamed from: \"%1\" to: \"%2\".")).arg(oldName, newName), QU::Information); } /*! @@ -828,16 +836,16 @@ void QUSongFile::renameSongMp3(const QString &newName) { QString oldName(mp3()); if(!rename(_fi.dir(), oldName, newName)) { - logSrv->add(QString(tr("Could NOT rename the audio file \"%1\" to \"%2\".")).arg(oldName).arg(newName), QU::Warning); + logSrv->add(QString(tr("Could NOT rename the audio file \"%1\" to \"%2\".")).arg(oldName, newName), QU::Warning); return; } setInfo(MP3_TAG, newName); - logSrv->add(QString(tr("Audio file renamed from: \"%1\" to: \"%2\".")).arg(oldName).arg(newName), QU::Information); + logSrv->add(QString(tr("Audio file renamed from: \"%1\" to: \"%2\".")).arg(oldName, newName), QU::Information); if(QString::compare(video(), oldName, Qt::CaseInsensitive) == 0) { setInfo(VIDEO_TAG, newName); - logSrv->add(QString(tr("Video file renamed from: \"%1\" to: \"%2\".")).arg(oldName).arg(newName), QU::Information); + logSrv->add(QString(tr("Video file renamed from: \"%1\" to: \"%2\".")).arg(oldName, newName), QU::Information); } } @@ -850,16 +858,16 @@ void QUSongFile::renameSongCover(const QString &newName) { QString oldName(cover()); if(!rename(_fi.dir(), oldName, newName)) { - logSrv->add(QString(tr("Could NOT rename the cover picture \"%1\" to \"%2\".")).arg(oldName).arg(newName), QU::Warning); + logSrv->add(QString(tr("Could NOT rename the cover picture \"%1\" to \"%2\".")).arg(oldName, newName), QU::Warning); return; } setInfo(COVER_TAG, newName); - logSrv->add(QString(tr("Cover picture renamed from: \"%1\" to: \"%2\".")).arg(oldName).arg(newName), QU::Information); + logSrv->add(QString(tr("Cover picture renamed from: \"%1\" to: \"%2\".")).arg(oldName, newName), QU::Information); if(QString::compare(background(), oldName, Qt::CaseInsensitive) == 0) { setInfo(BACKGROUND_TAG, newName); - logSrv->add(QString(tr("Background picture renamed from: \"%1\" to: \"%2\".")).arg(oldName).arg(newName), QU::Information); + logSrv->add(QString(tr("Background picture renamed from: \"%1\" to: \"%2\".")).arg(oldName, newName), QU::Information); } } @@ -872,16 +880,16 @@ void QUSongFile::renameSongBackground(const QString &newName) { QString oldName(background()); if(!rename(_fi.dir(), oldName, newName)) { - logSrv->add(QString(tr("Could NOT rename the background picture \"%1\" to \"%2\".")).arg(oldName).arg(newName), QU::Warning); + logSrv->add(QString(tr("Could NOT rename the background picture \"%1\" to \"%2\".")).arg(oldName, newName), QU::Warning); return; } setInfo(BACKGROUND_TAG, newName); - logSrv->add(QString(tr("Background picture renamed from: \"%1\" to: \"%2\".")).arg(oldName).arg(newName), QU::Information); + logSrv->add(QString(tr("Background picture renamed from: \"%1\" to: \"%2\".")).arg(oldName, newName), QU::Information); if(QString::compare(cover(), oldName, Qt::CaseInsensitive) == 0) { setInfo(COVER_TAG, newName); - logSrv->add(QString(tr("Cover picture renamed from: \"%1\" to: \"%2\".")).arg(oldName).arg(newName), QU::Information); + logSrv->add(QString(tr("Cover picture renamed from: \"%1\" to: \"%2\".")).arg(oldName, newName), QU::Information); } } @@ -894,16 +902,16 @@ void QUSongFile::renameSongVideo(const QString &newName) { QString oldName(video()); if(!rename(_fi.dir(), oldName, newName)) { - logSrv->add(QString(tr("Could NOT rename the video file \"%1\" to \"%2\".")).arg(oldName).arg(newName), QU::Warning); + logSrv->add(QString(tr("Could NOT rename the video file \"%1\" to \"%2\".")).arg(oldName, newName), QU::Warning); return; } setInfo(VIDEO_TAG, newName); - logSrv->add(QString(tr("Video file renamed from: \"%1\" to: \"%2\".")).arg(oldName).arg(newName), QU::Information); + logSrv->add(QString(tr("Video file renamed from: \"%1\" to: \"%2\".")).arg(oldName, newName), QU::Information); if(QString::compare(mp3(), oldName, Qt::CaseInsensitive) == 0) { setInfo(MP3_TAG, newName); - logSrv->add(QString(tr("Audio file renamed from: \"%1\" to: \"%2\".")).arg(oldName).arg(newName), QU::Information); + logSrv->add(QString(tr("Audio file renamed from: \"%1\" to: \"%2\".")).arg(oldName, newName), QU::Information); } } @@ -913,7 +921,7 @@ void QUSongFile::renameSongVideo(const QString &newName) { */ void QUSongFile::useID3TagForArtist() { if(!hasMp3()) { - logSrv->add(QString(tr("The song \"%1 - %2\" has no audio file assigned. Cannot use ID3 tag for artist.")).arg(this->artist()).arg(this->title()), QU::Warning); + logSrv->add(QString(tr("The song \"%1 - %2\" has no audio file assigned. Cannot use ID3 tag for artist.")).arg(this->artist(), this->title()), QU::Warning); return; } @@ -929,12 +937,12 @@ void QUSongFile::useID3TagForArtist() { } setInfo(ARTIST_TAG, newArtist); - logSrv->add(QString(tr("ID3 tag of \"%1\" used for artist. Changed from: \"%2\" to: \"%3\".")).arg(this->mp3()).arg(oldArtist).arg(this->artist()), QU::Information); + logSrv->add(QString(tr("ID3 tag of \"%1\" used for artist. Changed from: \"%2\" to: \"%3\".")).arg(this->mp3(), oldArtist, this->artist()), QU::Information); } void QUSongFile::useID3TagForTitle() { if(!hasMp3()) { - logSrv->add(QString(tr("The song \"%1 - %2\" has no audio file assigned. Cannot use ID3 tag for title.")).arg(this->artist()).arg(this->title()), QU::Warning); + logSrv->add(QString(tr("The song \"%1 - %2\" has no audio file assigned. Cannot use ID3 tag for title.")).arg(this->artist(), this->title()), QU::Warning); return; } @@ -949,12 +957,12 @@ void QUSongFile::useID3TagForTitle() { } setInfo(TITLE_TAG, newTitle); - logSrv->add(QString(tr("ID3 tag of \"%1\" used for title. Changed from: \"%2\" to: \"%3\".")).arg(this->mp3()).arg(oldTitle).arg(this->title()), QU::Information); + logSrv->add(QString(tr("ID3 tag of \"%1\" used for title. Changed from: \"%2\" to: \"%3\".")).arg(this->mp3(), oldTitle, this->title()), QU::Information); } void QUSongFile::useID3TagForGenre() { if(!hasMp3()) { - logSrv->add(QString(tr("The song \"%1 - %2\" has no audio file assigned. Cannot use ID3 tag for genre.")).arg(this->artist()).arg(this->title()), QU::Warning); + logSrv->add(QString(tr("The song \"%1 - %2\" has no audio file assigned. Cannot use ID3 tag for genre.")).arg(this->artist(), this->title()), QU::Warning); return; } @@ -969,12 +977,12 @@ void QUSongFile::useID3TagForGenre() { } setInfo(GENRE_TAG, newGenre); - logSrv->add(QString(tr("ID3 tag of \"%1\" used for genre. Changed from: \"%2\" to: \"%3\".")).arg(this->mp3()).arg(oldGenre).arg(this->genre()), QU::Information); + logSrv->add(QString(tr("ID3 tag of \"%1\" used for genre. Changed from: \"%2\" to: \"%3\".")).arg(this->mp3(), oldGenre, this->genre()), QU::Information); } void QUSongFile::useID3TagForYear() { if(!hasMp3()) { - logSrv->add(QString(tr("The song \"%1 - %2\" has no audio file assigned. Cannot use ID3 tag for year.")).arg(this->artist()).arg(this->title()), QU::Warning); + logSrv->add(QString(tr("The song \"%1 - %2\" has no audio file assigned. Cannot use ID3 tag for year.")).arg(this->artist(), this->title()), QU::Warning); return; } @@ -989,12 +997,12 @@ void QUSongFile::useID3TagForYear() { } setInfo(YEAR_TAG, newYear); - logSrv->add(QString(tr("ID3 tag of \"%1\" used for year. Changed from: \"%2\" to: \"%3\".")).arg(this->mp3()).arg(oldYear).arg(this->year()), QU::Information); + logSrv->add(QString(tr("ID3 tag of \"%1\" used for year. Changed from: \"%2\" to: \"%3\".")).arg(this->mp3(), oldYear, this->year()), QU::Information); } void QUSongFile::removeUnsupportedTags(const QStringList &filter, bool useFilter) { if(!this->unsupportedTagsFound()) { - logSrv->add(QString(tr("The song \"%1 - %2\" has no unsupported tags.")).arg(this->artist()).arg(this->title()), QU::Information); + logSrv->add(QString(tr("The song \"%1 - %2\" has no unsupported tags.")).arg(this->artist(), this->title()), QU::Information); return; } @@ -1020,23 +1028,23 @@ void QUSongFile::autoSetFile(const QFileInfo &fi, bool force, const QString &cov if(QUSongSupport::allowedVideoFiles().contains(fileScheme, Qt::CaseInsensitive)) { if(!this->hasVideo() || force) { this->setInfo(VIDEO_TAG, fi.fileName()); - logSrv->add(QString(tr("Assigned \"%1\" as video file for \"%2 - %3\".")).arg(video()).arg(artist()).arg(title()), QU::Information); + logSrv->add(QString(tr("Assigned \"%1\" as video file for \"%2 - %3\".")).arg(video(), artist(), title()), QU::Information); } } else if(QUSongSupport::allowedAudioFiles().contains(fileScheme, Qt::CaseInsensitive)) { if(!this->hasMp3() || force) { this->setInfo(MP3_TAG, fi.fileName()); - logSrv->add(QString(tr("Assigned \"%1\" as audio file for \"%2 - %3\".")).arg(mp3()).arg(artist()).arg(title()), QU::Information); + logSrv->add(QString(tr("Assigned \"%1\" as audio file for \"%2 - %3\".")).arg(mp3(), artist(), title()), QU::Information); } } else if(QUSongSupport::allowedImageFiles().contains(fileScheme, Qt::CaseInsensitive)) { - QRegularExpression reCover(coverPattern, QRegularExpression::CaseInsensitiveOption); - QRegularExpression reBackground(backgroundPattern, QRegularExpression::CaseInsensitiveOption); + static const QRegularExpression reCover(coverPattern, QRegularExpression::CaseInsensitiveOption); + static const QRegularExpression reBackground(backgroundPattern, QRegularExpression::CaseInsensitiveOption); if(fi.fileName().contains(reCover) && (!this->hasCover() || force) ) { this->setInfo(COVER_TAG, fi.fileName()); - logSrv->add(QString(tr("Assigned \"%1\" as cover picture for \"%2 - %3\".")).arg(cover()).arg(artist()).arg(title()), QU::Information); + logSrv->add(QString(tr("Assigned \"%1\" as cover picture for \"%2 - %3\".")).arg(cover(), artist(), title()), QU::Information); } else if(fi.fileName().contains(reBackground) && (!this->hasBackground() || force) ) { this->setInfo(BACKGROUND_TAG, fi.fileName()); - logSrv->add(QString(tr("Assigned \"%1\" as background picture for \"%2 - %3\".")).arg(background()).arg(artist()).arg(title()), QU::Information); + logSrv->add(QString(tr("Assigned \"%1\" as background picture for \"%2 - %3\".")).arg(background(), artist(), title()), QU::Information); } } } @@ -1051,11 +1059,11 @@ void QUSongFile::useExternalFile(const QString &filePath) { QFileInfo destination(this->songFileInfo().dir(), source.fileName()); if(!QFile::copy(source.filePath(), destination.filePath())) { - logSrv->add(QString(tr("Could not copy the file \"%1\" to \"%2\".")).arg(source.fileName()).arg(QDir::toNativeSeparators(destination.path())), QU::Warning); + logSrv->add(QString(tr("Could not copy the file \"%1\" to \"%2\".")).arg(source.fileName(), QDir::toNativeSeparators(destination.path())), QU::Warning); return; } - logSrv->add(QString(tr("The file \"%1\" was successfully copied to \"%2\".")).arg(source.fileName()).arg(QDir::toNativeSeparators(destination.path())), QU::Saving); + logSrv->add(QString(tr("The file \"%1\" was successfully copied to \"%2\".")).arg(source.fileName(), QDir::toNativeSeparators(destination.path())), QU::Saving); this->autoSetFile(destination, true); } @@ -1100,20 +1108,20 @@ void QUSongFile::clearInvalidFileTags() { this->setInfo(MP3_TAG, ""); this->setInfo(START_TAG, ""); this->setInfo(END_TAG, ""); - logSrv->add(QString(tr("Audio file tag removed for \"%1 - %2\".")).arg(this->artist()).arg(this->title()), QU::Information); + logSrv->add(QString(tr("Audio file tag removed for \"%1 - %2\".")).arg(this->artist(), this->title()), QU::Information); } if(this->cover() != N_A && !this->hasCover()) { this->setInfo(COVER_TAG, ""); - logSrv->add(QString(tr("Cover tag removed for \"%1 - %2\".")).arg(this->artist()).arg(this->title()), QU::Information); + logSrv->add(QString(tr("Cover tag removed for \"%1 - %2\".")).arg(this->artist(), this->title()), QU::Information); } if(this->background() != N_A && !this->hasBackground()) { this->setInfo(BACKGROUND_TAG, ""); - logSrv->add(QString(tr("Background tag removed for \"%1 - %2\".")).arg(this->artist()).arg(this->title()), QU::Information); + logSrv->add(QString(tr("Background tag removed for \"%1 - %2\".")).arg(this->artist(), this->title()), QU::Information); } if( (this->video() != N_A || this->videogap() != N_A) && !this->hasVideo()) { this->setInfo(VIDEO_TAG, ""); this->setInfo(VIDEOGAP_TAG, ""); - logSrv->add(QString(tr("Video tag removed for \"%1 - %2\".")).arg(this->artist()).arg(this->title()), QU::Information); + logSrv->add(QString(tr("Video tag removed for \"%1 - %2\".")).arg(this->artist(), this->title()), QU::Information); } } @@ -1146,14 +1154,14 @@ void QUSongFile::moveAllFiles(const QString &newRelativePath) { QString to = QFileInfo(QU::BaseDir, destination + "/" + fi.fileName()).filePath(); if(!QFile::rename(from, to)) { - logSrv->add(QString(tr("Failed to move \"%1\" to \"%2\".")).arg(from).arg(to), QU::Warning); + logSrv->add(QString(tr("Failed to move \"%1\" to \"%2\".")).arg(from, to), QU::Warning); allFilesCopied = false; } else - logSrv->add(QString(tr("The file \"%1\" was successfully moved to \"%2\".")).arg(from).arg(to), QU::Saving); + logSrv->add(QString(tr("The file \"%1\" was successfully moved to \"%2\".")).arg(from, to), QU::Saving); } if(!allFilesCopied) { - logSrv->add(QString(tr("Could NOT move all files of the song \"%2\" to a new location. Check out \"%1\" for the files which were copied.")).arg(newRelativePath).arg(QString("%1 - %2").arg(artist()).arg(title())), QU::Warning); + logSrv->add(QString(tr("Could NOT move all files of the song \"%2\" to a new location. Check out \"%1\" for the files which were copied.")).arg(newRelativePath, QString("%1 - %2").arg(artist(), title())), QU::Warning); return; } @@ -1170,7 +1178,7 @@ void QUSongFile::moveAllFiles(const QString &newRelativePath) { setFile(QFileInfo(QU::BaseDir, destination + "/" + _fi.fileName()).filePath(), false); emit songPathChanged(_fi.filePath()); - logSrv->add(QString(tr("Location of song \"%1 - %2\" successfully changed to \"%3\" in your UltraStar song folder.")).arg(artist()).arg(title()).arg(newRelativePath), QU::Information); + logSrv->add(QString(tr("Location of song \"%1 - %2\" successfully changed to \"%3\" in your UltraStar song folder.")).arg(artist(), title(), newRelativePath), QU::Information); } /*! @@ -1181,7 +1189,7 @@ void QUSongFile::moveAllFiles(const QString &newRelativePath) { */ void QUSongFile::fixAudioLength(int buffer) { if(!hasMp3()) { - logSrv->add(QString(tr("Could not fix audio length because no audio file is present: \"%1 - %2\"")).arg(artist()).arg(title()), QU::Warning); + logSrv->add(QString(tr("Could not fix audio length because no audio file is present: \"%1 - %2\"")).arg(artist(), title()), QU::Warning); return; } @@ -1192,21 +1200,21 @@ void QUSongFile::fixAudioLength(int buffer) { int lengthMp3 = this->lengthMp3(); // length of audio file because #END was set to 0 if(length > lengthMp3) { - logSrv->add(QString(tr("Could not fix audio length because audio file is shorter than song: \"%1 - %2\"")).arg(artist()).arg(title()), QU::Warning); + logSrv->add(QString(tr("Could not fix audio length because audio file is shorter than song: \"%1 - %2\"")).arg(artist(), title()), QU::Warning); return; } int end = length + buffer; // calculate the new #END value if(end > lengthMp3) { - logSrv->add(QString(tr("Could not fix audio length because new value for #END would be greater than length of audio file: \"%1 - %2\"")).arg(artist()).arg(title()), QU::Warning); + logSrv->add(QString(tr("Could not fix audio length because new value for #END would be greater than length of audio file: \"%1 - %2\"")).arg(artist(), title()), QU::Warning); return; } // set new value for #END, in milliseconds setInfo(END_TAG, QVariant(end * 1000).toString()); - logSrv->add(QString(tr("Audio length was fixed for song \"%1 - %2\". #END changed to: %3")).arg(artist()).arg(title()).arg(end * 1000), QU::Information); + logSrv->add(QString(tr("Audio length was fixed for song \"%1 - %2\". #END changed to: %3")).arg(artist(), title(), QString::number(end * 1000)), QU::Information); } /*! @@ -1221,7 +1229,7 @@ void QUSongFile::roundGap() { this->setInfo(GAP_TAG, QVariant(qRound(gap)).toString()); - logSrv->add(QString(tr("#GAP changed from %1 to %2 for \"%3 - %4\".")).arg(oldGap).arg(this->gap()).arg(artist()).arg(title()), QU::Information); + logSrv->add(QString(tr("#GAP changed from %1 to %2 for \"%3 - %4\".")).arg(oldGap, this->gap(), artist(), title()), QU::Information); } /*! @@ -1230,7 +1238,7 @@ void QUSongFile::roundGap() { void QUSongFile::removeEndTag() { if(end() != N_A) { setInfo(END_TAG, ""); - logSrv->add(QString(tr("The tag #END was removed for: \"%1 - %2\"")).arg(artist()).arg(title()), QU::Information); + logSrv->add(QString(tr("The tag #END was removed for: \"%1 - %2\"")).arg(artist(), title()), QU::Information); } } @@ -1242,7 +1250,7 @@ void QUSongFile::songFileChanged(const QString &filePath) { return; if(hasUnsavedChanges()) { - logSrv->add(QString(tr("INCONSISTENT STATE! The song \"%1 - %2\" has unsaved changes and its persistent song file \"%3\" was modified externally. Save your changes or rebuild the tree manually.")).arg(artist()).arg(title()).arg(songFileInfo().filePath()), QU::Warning); + logSrv->add(QString(tr("INCONSISTENT STATE! The song \"%1 - %2\" has unsaved changes and its persistent song file \"%3\" was modified externally. Save your changes or rebuild the tree manually.")).arg(artist(), title(), songFileInfo().filePath()), QU::Warning); return; } @@ -1383,10 +1391,7 @@ void QUSongFile::changeData(const QString &tag, const QString &value) { * Rename yourself if your friend was renamed. */ void QUSongFile::renameSong(const QString &fileName) { - renameSongTxt(QString("%1%2.%3") - .arg(QUStringSupport::withoutFolderTags(QFileInfo(songFileInfo().dir(), fileName).baseName())) - .arg(_fiTags.isEmpty() ? "" : _fiTags.join("] [").prepend(" [").append("]")) // just use your own []-tags - .arg(songFileInfo().suffix())); + renameSongTxt(QString("%1%2.%3").arg(QUStringSupport::withoutFolderTags(QFileInfo(songFileInfo().dir(), fileName).baseName()), _fiTags.isEmpty() ? "" : _fiTags.join("] [").prepend(" [").append("]"), songFileInfo().suffix())); } /*! @@ -1427,9 +1432,7 @@ bool QUSongFile::swapWithFriend(QUSongFile *song) { song->addFriend(this); _friends.clear(); - logSrv->add(tr("Primary song file changed from \"%1\" to \"%2\".") - .arg(songFileInfo().fileName()) - .arg(song->songFileInfo().fileName()), QU::Information); + logSrv->add(tr("Primary song file changed from \"%1\" to \"%2\".").arg(songFileInfo().fileName(), song->songFileInfo().fileName()), QU::Information); return true; } @@ -1491,11 +1494,9 @@ void QUSongFile::convertLyricsToRaw() { * Takes a raw lyrics line (e.g. ": 2345 10 90 foo ") and converts that to an internal format. */ void QUSongFile::lyricsAddNote(QString line) { - if(!QRegularExpression(QRegularExpression::anchoredPattern("([:\\*FRG\\-].*)|(P\\s*[123].*)")).match(line).hasMatch()) { - logSrv->add(QString(tr("Error while preparing lyrics for %1 - %2. Could not parse the following line: %3")) - .arg(artist()) - .arg(title()) - .arg(line.trimmed()), QU::Warning); + static const QRegularExpression regex(QRegularExpression::anchoredPattern("([:\\*FRG\\-].*)|(P\\s*[123].*)")); + if(!regex.match(line).hasMatch()) { + logSrv->add(QString(tr("Error while preparing lyrics for %1 - %2. Could not parse the following line: %3")).arg(artist(), title(), line.trimmed()), QU::Warning); return; // no valid line } @@ -1508,9 +1509,7 @@ void QUSongFile::lyricsAddNote(QString line) { if(line.startsWith("-")) { // line break // if song starts with line break, ignore it if(_melody.first()->notes().isEmpty()) { - logSrv->add(QString(tr("Error while preparing lyrics for %1 - %2. Songs may not start with a line break.")) - .arg(artist()) - .arg(title()), QU::Warning); + logSrv->add(QString(tr("Error while preparing lyrics for %1 - %2. Songs may not start with a line break.")).arg(artist(), title()), QU::Warning); } else { line.remove(0, 1); QStringList lineSplit = line.trimmed().split(" ", Qt::SkipEmptyParts); @@ -1549,8 +1548,10 @@ void QUSongFile::lyricsAddNote(QString line) { t = QUSongNoteInterface::normal; // extract the lyric/syllable - line.remove(QRegularExpression("[:\\*FRG]\\s*\\-?\\d+\\s+\\d+\\s+\\-?\\d+\\s")); - line.remove(QRegularExpression("[:\\*FRG]\\s*\\-?\\d+\\s+\\d+\\s+\\-?\\d+")); // if no syllable is present + static const QRegularExpression regex1("[:\\*FRG]\\s*\\-?\\d+\\s+\\d+\\s+\\-?\\d+\\s"); + line.remove(regex1); + static const QRegularExpression regex2("[:\\*FRG]\\s*\\-?\\d+\\s+\\d+\\s+\\-?\\d+"); + line.remove(regex2); // if no syllable is present QUSongNote *note = new QUSongNote( t, @@ -1588,9 +1589,7 @@ void QUSongFile::initScoreFile() { // no exact match, just use anyone if(scoreFiles.size() > 1) - logSrv->add(tr("More than one score file found for \"%1 - %2\". Only one will be used.") - .arg(artist()) - .arg(title()), QU::Warning); + logSrv->add(tr("More than one score file found for \"%1 - %2\". Only one will be used.").arg(artist(), title()), QU::Warning); _score = new QUScoreFile(scoreFiles.first().filePath(), this); } diff --git a/src/song/QUSongFile.h b/src/song/QUSongFile.h index 5391a72e..9badc682 100644 --- a/src/song/QUSongFile.h +++ b/src/song/QUSongFile.h @@ -59,7 +59,7 @@ class QUSongFile: public QUSongInterface { // comparing functions static bool equal(QUSongFile *s1, QUSongFile *s2); -public slots: +public: QString artist() const {return _info.value(ARTIST_TAG, QString(N_A));} QString title() const {return _info.value(TITLE_TAG, QString(N_A));} QString mp3() const {return _info.value(MP3_TAG, QString(N_A));} diff --git a/src/songdetails/QUDetailItem.cpp b/src/songdetails/QUDetailItem.cpp index 813eedb4..62828765 100644 --- a/src/songdetails/QUDetailItem.cpp +++ b/src/songdetails/QUDetailItem.cpp @@ -233,8 +233,9 @@ QStringList QUDetailItem::defaultData(QUSongFile *song) { } foreach(QUSongLineInterface *line, song->loadMelody()) { - if(!line->notes().isEmpty()) - dropDownData << QString::number(line->notes().first()->timestamp()); + auto notes = line->notes(); + if(!notes.isEmpty()) + dropDownData << QString::number(notes.first()->timestamp()); } } else if(QString::compare(tag(), MEDLEYENDBEAT_TAG) == 0) { @@ -243,8 +244,9 @@ QStringList QUDetailItem::defaultData(QUSongFile *song) { } foreach(QUSongLineInterface *line, song->loadMelody()) { - if(!line->notes().isEmpty()) - dropDownData << QString::number(line->notes().last()->timestamp() + line->notes().last()->duration()); + auto notes = line->notes(); + if(!notes.isEmpty()) + dropDownData << QString::number(notes.last()->timestamp() + notes.last()->duration()); } } diff --git a/src/songdetails/QUDropDownDelegate.cpp b/src/songdetails/QUDropDownDelegate.cpp index ccf2b43c..d9b61c5d 100644 --- a/src/songdetails/QUDropDownDelegate.cpp +++ b/src/songdetails/QUDropDownDelegate.cpp @@ -45,8 +45,11 @@ void QUDropDownDelegate::setEditorData( if(QString::compare(value, N_A, Qt::CaseSensitive) == 0) value = ""; - if(QRegularExpression(QRegularExpression::anchoredPattern(QString("(-*)(\\d*|\\d*[,.]\\d*) (") + tr("seconds") + "|" + tr("milliseconds") + ")")).match(value).hasMatch()) - value.remove(QRegularExpression(QString("(") + tr("seconds") + "|" + tr("milliseconds") + ")")); + static const QRegularExpression regex1(QRegularExpression::anchoredPattern(QString("(-*)(\\d*|\\d*[,.]\\d*) (") + tr("seconds") + "|" + tr("milliseconds") + ")")); + if(regex1.match(value).hasMatch()) { + static const QRegularExpression regex2(QString("(") + tr("seconds") + "|" + tr("milliseconds") + ")"); + value.remove(regex2); + } comboBox->setEditText(value.trimmed()); comboBox->lineEdit()->selectAll(); diff --git a/src/songtree/QUSongItem.cpp b/src/songtree/QUSongItem.cpp index 0f3ccaab..0939d491 100644 --- a/src/songtree/QUSongItem.cpp +++ b/src/songtree/QUSongItem.cpp @@ -354,7 +354,7 @@ void QUSongItem::showUnusedFilesIcon(QString fileName) { this->setToolTip(UNUSED_FILES_COLUMN, QObject::tr("Unused files found:")); // headline for the tooltip if(!fileName.isEmpty()) - this->setToolTip(UNUSED_FILES_COLUMN, QString("%1\n* %2").arg(this->toolTip(UNUSED_FILES_COLUMN)).arg(fileName)); + this->setToolTip(UNUSED_FILES_COLUMN, QString("%1\n* %2").arg(this->toolTip(UNUSED_FILES_COLUMN), fileName)); // used for sorting, should be smaller than zero this->setData(UNUSED_FILES_COLUMN, Qt::UserRole, QVariant(-1)); @@ -367,7 +367,7 @@ void QUSongItem::showMultipleSongsIcon(QString fileName) { this->setToolTip(MULTIPLE_SONGS_COLUMN, QString(QObject::tr("Multiple songs found:\n* %1 (primary)")).arg(song()->songFileInfo().fileName())); // headline for the tooltip if(!fileName.isEmpty()) - this->setToolTip(MULTIPLE_SONGS_COLUMN, QString("%1\n* %2").arg(this->toolTip(MULTIPLE_SONGS_COLUMN)).arg(fileName)); + this->setToolTip(MULTIPLE_SONGS_COLUMN, QString("%1\n* %2").arg(this->toolTip(MULTIPLE_SONGS_COLUMN), fileName)); // used for sorting, should be smaller than zero this->setData(MULTIPLE_SONGS_COLUMN, Qt::UserRole, QVariant(-1)); @@ -639,9 +639,9 @@ void QUSongItem::updateSpellCheckColumns() { if(QString::compare(part1, part2, Qt::CaseSensitive) == 0) this->setSmiley(ARTIST_COLUMN); else if(QString::compare(part1, part2, Qt::CaseInsensitive) == 0) - this->setSmiley(ARTIST_COLUMN, QU::spellingWarning, toolTip.arg(part1).arg(part2).arg(CHAR_UTF8_APPROX)); + this->setSmiley(ARTIST_COLUMN, QU::spellingWarning, toolTip.arg(part1).arg(part2, CHAR_UTF8_APPROX)); else - this->setSmiley(ARTIST_COLUMN, QU::spellingError, toolTip.arg(part1).arg(part2).arg(CHAR_UTF8_NEQUAL)); + this->setSmiley(ARTIST_COLUMN, QU::spellingError, toolTip.arg(part1).arg(part2, CHAR_UTF8_NEQUAL)); /* title column */ part1 = QUStringSupport::withoutUnsupportedCharacters(song()->title()); @@ -654,9 +654,9 @@ void QUSongItem::updateSpellCheckColumns() { if(QString::compare(part1, part2, Qt::CaseSensitive) == 0) this->setSmiley(TITLE_COLUMN); else if(QString::compare(part1, part2, Qt::CaseInsensitive) == 0) - this->setSmiley(TITLE_COLUMN, QU::spellingWarning, toolTip.arg(part1).arg(part2).arg(CHAR_UTF8_APPROX)); + this->setSmiley(TITLE_COLUMN, QU::spellingWarning, toolTip.arg(part1, part2, CHAR_UTF8_APPROX)); else - this->setSmiley(TITLE_COLUMN, QU::spellingError, toolTip.arg(part1).arg(part2).arg(CHAR_UTF8_NEQUAL)); + this->setSmiley(TITLE_COLUMN, QU::spellingError, toolTip.arg(part1, part2, CHAR_UTF8_NEQUAL)); } void QUSongItem::updateFileCheckColumns() { diff --git a/src/songtree/QUSongTree.cpp b/src/songtree/QUSongTree.cpp index 9bc5483d..84265b69 100644 --- a/src/songtree/QUSongTree.cpp +++ b/src/songtree/QUSongTree.cpp @@ -408,7 +408,7 @@ void QUSongTree::filterItems(const QString ®exp, QU::FilterModes mode) { if(songItem) { QUSongFile *song = songItem->song(); - progress.update(QString("%1 - %2").arg(song->artist()).arg(song->title())); + progress.update(QString("%1 - %2").arg(song->artist(), song->title())); if(progress.cancelled()) break; bool filterInfo = true; @@ -487,7 +487,7 @@ void QUSongTree::filterItems(const QString ®exp, QU::FilterModes mode) { restoreSelection(selectedItems); emit itemSelectionChanged(); // update details - logSrv->add(QString(tr("Filter applied: \"%1\"%2")).arg(regexp).arg(mode.testFlag(QU::negateFilter) ? tr(", negated") : ""), QU::Information); + logSrv->add(QString(tr("Filter applied: \"%1\"%2")).arg(regexp, mode.testFlag(QU::negateFilter) ? tr(", negated") : ""), QU::Information); } /*! @@ -501,7 +501,7 @@ void QUSongTree::filterDuplicates() { QList uniqueList; // store unique items; int nextID = 0; - QMap id; + QHash id; // sort after an invisible column to combine duplicate items this->sortItems(FOLDER_COLUMN, Qt::AscendingOrder); @@ -512,7 +512,7 @@ void QUSongTree::filterDuplicates() { dlg.show(); foreach(QUSongItem *item, allItems) { - dlg.update(QString("%1 - %2").arg(item->song()->artist()).arg(item->song()->title())); + dlg.update(QString("%1 - %2").arg(item->song()->artist(), item->song()->title())); if(dlg.cancelled()) break; bool isItemUnique = true; @@ -947,7 +947,7 @@ void QUSongTree::requestDeleteSelectedSongs() { break; } - infoText.append(QString("
  %1 - %2").arg(songItem->song()->artist()).arg(songItem->song()->title())); + infoText.append(QString("
  %1 - %2").arg(songItem->song()->artist(), songItem->song()->title())); } int result = QUMessageBox::information(this, @@ -1005,9 +1005,7 @@ void QUSongTree::mergeSelectedSongs() { // --------------------------------- QString infoText = QString(tr("You want to merge songs with \"%1 - %2\". All files of the other songs will be moved to that song's path.

The following %3 songs will disappear:")) - .arg(currentSongItem->song()->artist()) - .arg(currentSongItem->song()->title()) - .arg(selectedItems.size()); + .arg(currentSongItem->song()->artist(), currentSongItem->song()->title(), QString::number(selectedItems.size())); int i = 0; foreach(QUSongItem *songItem, selectedItems) { @@ -1016,7 +1014,7 @@ void QUSongTree::mergeSelectedSongs() { break; } - infoText.append(QString("
  %1 - %2").arg(songItem->song()->artist()).arg(songItem->song()->title())); + infoText.append(QString("
  %1 - %2").arg(songItem->song()->artist(), songItem->song()->title())); } int result = QUMessageBox::information(this, @@ -1030,7 +1028,7 @@ void QUSongTree::mergeSelectedSongs() { // ---------------------------------- - QUProgressDialog dlg(QString(tr("Merging selected songs with \"%1 - %2\"...")).arg(currentSongItem->song()->artist()).arg(currentSongItem->song()->title()), selectedItems.size(), this); + QUProgressDialog dlg(QString(tr("Merging selected songs with \"%1 - %2\"...")).arg(currentSongItem->song()->artist(), currentSongItem->song()->title()), selectedItems.size(), this); // dlg.setPixmap(":/control/bin.png"); dlg.show(); @@ -1047,13 +1045,13 @@ void QUSongTree::mergeSelectedSongs() { bool allFilesCopied = true; foreach(QFileInfo fi, fiList) { - QString target = QFileInfo(currentSongItem->song()->songFileInfo().dir(), QString("%1%2_%3").arg(i++, 3, 10, QChar('0')).arg(QTime::currentTime().toString("sszzz")).arg(fi.fileName())).filePath(); + QString target = QFileInfo(currentSongItem->song()->songFileInfo().dir(), QString("%1%2_%3").arg(i++, 3, 10, QChar('0')).arg(QTime::currentTime().toString("sszzz"), fi.fileName())).filePath(); if(!QFile::copy(fi.filePath(), target)) { allFilesCopied = false; - logSrv->add(QString(tr("Could NOT copy file \"%1\" to \"%2\".")).arg(fi.filePath()).arg(target), QU::Warning); + logSrv->add(QString(tr("Could NOT copy file \"%1\" to \"%2\".")).arg(fi.filePath(), target), QU::Warning); } else - logSrv->add(QString(tr("File was copied successfully from \"%1\" to \"%2\".")).arg(fi.filePath()).arg(target), QU::Information); + logSrv->add(QString(tr("File was copied successfully from \"%1\" to \"%2\".")).arg(fi.filePath(), target), QU::Information); } if(allFilesCopied) { @@ -1062,7 +1060,7 @@ void QUSongTree::mergeSelectedSongs() { songDB->deleteSong(song); } else { - logSrv->add(QString(tr("Not all files of \"%1 - %2\" were copied. Song will not be deleted. Merging failed.")).arg(songItem->song()->artist()).arg(songItem->song()->title()), QU::Warning); + logSrv->add(QString(tr("Not all files of \"%1 - %2\" were copied. Song will not be deleted. Merging failed.")).arg(songItem->song()->artist(), songItem->song()->title()), QU::Warning); } } @@ -1082,7 +1080,7 @@ void QUSongTree::calculateSpeed() { clearSelection(); foreach(QUSongItem *item, selectedItems) { - dlg.update(QString("%1 - %2").arg(item->song()->artist()).arg(item->song()->title())); + dlg.update(QString("%1 - %2").arg(item->song()->artist(), item->song()->title())); if(dlg.cancelled()) break; item->song()->syllablesPerSecond(false); @@ -1106,7 +1104,7 @@ bool QUSongTree::copyFilesToSong(const QList &files, QUSongItem *item) { bool dataUsed = false; - QUProgressDialog dlg(QString(tr("Copy & Use files for the song: \"%1 - %2\"...")).arg(item->song()->artist()).arg(item->song()->title()), files.size(), this); + QUProgressDialog dlg(QString(tr("Copy & Use files for the song: \"%1 - %2\"...")).arg(item->song()->artist(), item->song()->title()), files.size(), this); dlg.setPixmap(":/marks/disk.png"); dlg.show(); @@ -1166,9 +1164,7 @@ void QUSongTree::dropSongFiles(const QList &urls) { continue; // dir creation did not work if(!QFile::copy(fi.filePath(), newFileInfo.filePath())) { - logSrv->add(QString(tr("Could not copy song file \"%1\" to new song directory \"%2\"!")) - .arg(fi.fileName()) - .arg(QDir::toNativeSeparators(newFileInfo.path())), QU::Warning); + logSrv->add(QString(tr("Could not copy song file \"%1\" to new song directory \"%2\"!")).arg(fi.fileName(), QDir::toNativeSeparators(newFileInfo.path())), QU::Warning); continue; } @@ -1176,7 +1172,7 @@ void QUSongTree::dropSongFiles(const QList &urls) { newSong = new QUSongFile(newFileInfo.filePath()); newSongs.append(newSong); - logSrv->add(QString(tr("New song included to your song collection: \"%1 - %2\".")).arg(newSong->artist()).arg(newSong->title()), QU::Information); + logSrv->add(QString(tr("New song included to your song collection: \"%1 - %2\".")).arg(newSong->artist(), newSong->title()), QU::Information); songDB->addSong(newSong); } @@ -1208,7 +1204,7 @@ void QUSongTree::dropSongFiles(const QList &urls) { * Set the given song to that folder. */ QFileInfo QUSongTree::createSongFolder(QUSongFile *song) { - QString newDirName = QUStringSupport::withoutUnsupportedCharacters(QString("%1 - %2").arg(song->artist()).arg(song->title())).trimmed(); + QString newDirName = QUStringSupport::withoutUnsupportedCharacters(QString("%1 - %2").arg(song->artist(), song->title())).trimmed(); int i = 0; QString tmp = newDirName; @@ -1559,7 +1555,8 @@ void QUSongTree::searchForCoverOnAAE() { if(songItem) { QUrl url("https://www.albumartexchange.com/covers"); QUrlQuery urlQuery; - QString queryString = QString(songItem->song()->artist() + " " + songItem->song()->title()).replace(QRegularExpression("(\\s+)"), "+").replace("’", "'"); + static const QRegularExpression regex("(\\s+)"); + QString queryString = QString(songItem->song()->artist() + " " + songItem->song()->title()).replace(regex, "+").replace("’", "'"); urlQuery.addQueryItem("q", queryString); urlQuery.addQueryItem("fltr", "ALL"); urlQuery.addQueryItem("sort", "TITLE"); @@ -1631,7 +1628,8 @@ void QUSongTree::searchForArtworkOnFanart() { QUrlQuery urlQuery; urlQuery.addQueryItem("sect", "2"); // There seems to be a bug on fanart.tv that does not return any results if the artist contains an apostrophe - urlQuery.addQueryItem("s", songItem->song()->artist().remove(QRegularExpression("[’|']\\w+"))); + static const QRegularExpression regex("[’|']\\w+"); + urlQuery.addQueryItem("s", songItem->song()->artist().remove(regex)); url.setQuery(urlQuery); QDesktopServices::openUrl(url); diff --git a/src/support/QUTextDialog.cpp b/src/support/QUTextDialog.cpp index ac4114c4..91213e74 100644 --- a/src/support/QUTextDialog.cpp +++ b/src/support/QUTextDialog.cpp @@ -43,7 +43,7 @@ QUTextDialog::QUTextDialog(const QString &filePath, QWidget *parent): QDialog(pa void QUTextDialog::showLyrics(QUSongFile *song) { this->setWindowTitle(tr("Lyrics")); - textLbl->setText(QString("%1 - %2").arg(song->artist()).arg(song->title())); + textLbl->setText(QString("%1 - %2").arg(song->artist(), song->title())); this->initLyrics(song); } @@ -88,7 +88,8 @@ void QUTextDialog::initFile(QUSongFile *song) { content.replace(" ", "  "); content.replace(" \n", " 
"); content.replace("\n", "
"); - content.replace(QRegularExpression("(#[^<]*:)"), "\\1"); + static const QRegularExpression regex("(#[^<]*:)"); + content.replace(regex, "\\1"); textEdit->insertHtml(content); file.close(); diff --git a/src/webinfo/QUWebInfoTree.cpp b/src/webinfo/QUWebInfoTree.cpp index 5d8ee57e..9174de08 100644 --- a/src/webinfo/QUWebInfoTree.cpp +++ b/src/webinfo/QUWebInfoTree.cpp @@ -124,10 +124,10 @@ QTreeWidgetItem* QUWebInfoTree::createInfoItem(const QIcon &icon, const QString toolTip = ""; } else if(spellState == QU::spellingWarning) { status = QIcon(":/marks/spell_warn.png"); - toolTip = QString("Double-click to change %1 to '%2'.").arg(tag.toLower()).arg(value); + toolTip = QString("Double-click to change %1 to '%2'.").arg(tag.toLower(), value); } else { status = QIcon(":/marks/spell_error.png"); - toolTip = QString("Double-click to change %1 to '%2'.").arg(tag.toLower()).arg(value); + toolTip = QString("Double-click to change %1 to '%2'.").arg(tag.toLower(), value); } infoItem->setIcon(2, status); infoItem->setToolTip(0, toolTip); @@ -294,7 +294,8 @@ void QUWebInfoTree::getAllmusicInformation() { _allmusic->setHidden(false); return; - QUrl url("http://www.allmusic.com/search/songs/" + _artist.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts).join('+') + "+" + _title.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts).join('+')); + static const QRegularExpression regex("\\s+"); + QUrl url("http://www.allmusic.com/search/songs/" + _artist.split(regex, Qt::SkipEmptyParts).join('+') + "+" + _title.split(regex, Qt::SkipEmptyParts).join('+')); _manager->get(QNetworkRequest(url)); } @@ -323,7 +324,7 @@ void QUWebInfoTree::processHitparadeReply(QNetworkReply* reply) { QByteArray newData = reply->readAll(); QString searchresult = QString::fromLatin1(newData).remove("\r\n"); - QRegularExpression re = QRegularExpression("(.*?).*?(.*?).*?(\\d{4}| |\\s*)", QRegularExpression::DotMatchesEverythingOption); + static const QRegularExpression re = QRegularExpression("(.*?).*?(.*?).*?(\\d{4}| |\\s*)", QRegularExpression::DotMatchesEverythingOption); QRegularExpressionMatchIterator mi = re.globalMatch(searchresult); if (mi.hasNext()) { @@ -465,7 +466,7 @@ void QUWebInfoTree::processDiscogsSongReply(QNetworkReply* reply) { QIcon icon; QString toolTip; - QRegularExpression rx2 = QRegularExpression("\\s*(.+)\\s*.*\\s*(.+)\\s*\\s*\\s*

.*:
\\s*
\\s*(.+)\\s*
\\s*
.*:
\\s*
\\s*(.+)", QRegularExpression::InvertedGreedinessOption | QRegularExpression::CaseInsensitiveOption); + static const QRegularExpression rx2 = QRegularExpression("\\s*(.+)\\s*.*\\s*(.+)\\s*\\s*\\s*
.*:
\\s*
\\s*(.+)\\s*
\\s*
.*:
\\s*
\\s*(.+)", QRegularExpression::InvertedGreedinessOption | QRegularExpression::CaseInsensitiveOption); QRegularExpressionMatch match = rx2.match(discogs_reply); QString discogs_url; @@ -486,10 +487,10 @@ void QUWebInfoTree::processDiscogsSongReply(QNetworkReply* reply) { toolTip = ""; } else if(QString::compare(_artist, discogs_artist, Qt::CaseInsensitive) == 0) { icon = QIcon(":/marks/spell_warn.png"); - toolTip = QString("Double-click to change artist from '%1' to '%2'.").arg(_artist).arg(discogs_artist); + toolTip = QString("Double-click to change artist from '%1' to '%2'.").arg(_artist, discogs_artist); } else { icon = QIcon(":/marks/spell_error.png"); - toolTip = QString("Double-click to change artist from '%1' to '%2'.").arg(_artist).arg(discogs_artist); + toolTip = QString("Double-click to change artist from '%1' to '%2'.").arg(_artist, discogs_artist); } _discogs->addChild(this->createInfoItem(QIcon(":/types/user.png"), tr("Artist"), discogs_artist, icon, toolTip)); @@ -498,10 +499,10 @@ void QUWebInfoTree::processDiscogsSongReply(QNetworkReply* reply) { toolTip = ""; } else if(QString::compare(_title, discogs_title, Qt::CaseInsensitive) == 0) { icon = QIcon(":/marks/spell_warn.png"); - toolTip = QString("Double-click to change title from '%1' to '%2'.").arg(_title).arg(discogs_title); + toolTip = QString("Double-click to change title from '%1' to '%2'.").arg(_title, discogs_title); } else { icon = QIcon(":/marks/spell_error.png"); - toolTip = QString("Double-click to change title from '%1' to '%2'.").arg(_title).arg(discogs_title); + toolTip = QString("Double-click to change title from '%1' to '%2'.").arg(_title, discogs_title); } _discogs->addChild(this->createInfoItem(QIcon(":/types/font.png"), tr("Title"), discogs_title, icon, toolTip)); @@ -510,10 +511,10 @@ void QUWebInfoTree::processDiscogsSongReply(QNetworkReply* reply) { toolTip = ""; } else if(QString::compare(_genre, discogs_genre, Qt::CaseInsensitive) == 0) { icon = QIcon(":/marks/spell_warn.png"); - toolTip = QString("Double-click to change genre from '%1' to '%2'.").arg(_genre).arg(discogs_genre); + toolTip = QString("Double-click to change genre from '%1' to '%2'.").arg(_genre, discogs_genre); } else { icon = QIcon(":/marks/spell_error.png"); - toolTip = QString("Double-click to change genre from '%1' to '%2'.").arg(_genre).arg(discogs_genre); + toolTip = QString("Double-click to change genre from '%1' to '%2'.").arg(_genre, discogs_genre); } _discogs->addChild(this->createInfoItem(QIcon(":/types/genre.png"), tr("Genre"), discogs_genre, icon, toolTip)); _discogs->addChild(this->createInfoItem(QIcon(":/types/genre.png"), tr("Style"), discogs_style, QIcon())); From f4301c2bf8ff06bd2cd28a0c0492a148d2054243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20B=C3=B6hning?= <1497707+bohning@users.noreply.github.com> Date: Sat, 14 Sep 2024 23:47:49 +0200 Subject: [PATCH 2/2] Additional fixes after review. --- src/plugins/QUPluginModel.cpp | 3 ++- src/preview/QUPreviewTree.cpp | 2 +- src/song/QUSongFile.h | 2 +- src/songtree/QUSongItem.cpp | 4 ++-- src/songtree/QUSongTree.cpp | 3 +-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/QUPluginModel.cpp b/src/plugins/QUPluginModel.cpp index 5205ed7d..e925b563 100644 --- a/src/plugins/QUPluginModel.cpp +++ b/src/plugins/QUPluginModel.cpp @@ -47,7 +47,8 @@ QVariant QUPluginModel::data(const QModelIndex &index, int role) const { stuff += tr("
Subtype: Background Images"); } - return tr("%1
%2

Author: %3
Version: %4
%5").arg(pluginMGR->plugins().at(index.row())->name(), pluginMGR->plugins().at(index.row())->description(), pluginMGR->plugins().at(index.row())->author(), pluginMGR->plugins().at(index.row())->version(), stuff); + auto plugin = pluginMGR->plugins().at(index.row()); + return tr("%1
%2

Author: %3
Version: %4
%5").arg(plugin->name(), plugin->description(), plugin->author(), plugin->version(), stuff); } return QVariant(); diff --git a/src/preview/QUPreviewTree.cpp b/src/preview/QUPreviewTree.cpp index 94b80961..bee424c4 100644 --- a/src/preview/QUPreviewTree.cpp +++ b/src/preview/QUPreviewTree.cpp @@ -436,7 +436,7 @@ void QUPreviewTree::showVideoFileInformation(const QFileInfo &fi) { QString countVideo(QString::fromStdWString(MI.Get(Stream_Video, 0, __T("StreamCount"), Info_Text, Info_Name))); QString countAudio(QString::fromStdWString(MI.Get(Stream_Audio, 0, __T("StreamCount"), Info_Text, Info_Name))); if(countAudio == "") countAudio = "no"; - video->addChild(this->createInfoItem(tr("Streams"), QString("%1 (%2 video, %3 audio)").arg(countVideo.toInt()+countAudio.toInt()).arg(countVideo, countAudio))); + video->addChild(this->createInfoItem(tr("Streams"), QString("%1 (%2 video, %3 audio)").arg(QString::number(countVideo.toInt()+countAudio.toInt()), countVideo, countAudio))); // video stream information video->addChild(this->createInfoItem("", "")); diff --git a/src/song/QUSongFile.h b/src/song/QUSongFile.h index 9badc682..5391a72e 100644 --- a/src/song/QUSongFile.h +++ b/src/song/QUSongFile.h @@ -59,7 +59,7 @@ class QUSongFile: public QUSongInterface { // comparing functions static bool equal(QUSongFile *s1, QUSongFile *s2); -public: +public slots: QString artist() const {return _info.value(ARTIST_TAG, QString(N_A));} QString title() const {return _info.value(TITLE_TAG, QString(N_A));} QString mp3() const {return _info.value(MP3_TAG, QString(N_A));} diff --git a/src/songtree/QUSongItem.cpp b/src/songtree/QUSongItem.cpp index 0939d491..50b405e6 100644 --- a/src/songtree/QUSongItem.cpp +++ b/src/songtree/QUSongItem.cpp @@ -639,9 +639,9 @@ void QUSongItem::updateSpellCheckColumns() { if(QString::compare(part1, part2, Qt::CaseSensitive) == 0) this->setSmiley(ARTIST_COLUMN); else if(QString::compare(part1, part2, Qt::CaseInsensitive) == 0) - this->setSmiley(ARTIST_COLUMN, QU::spellingWarning, toolTip.arg(part1).arg(part2, CHAR_UTF8_APPROX)); + this->setSmiley(ARTIST_COLUMN, QU::spellingWarning, toolTip.arg(part1, part2, CHAR_UTF8_APPROX)); else - this->setSmiley(ARTIST_COLUMN, QU::spellingError, toolTip.arg(part1).arg(part2, CHAR_UTF8_NEQUAL)); + this->setSmiley(ARTIST_COLUMN, QU::spellingError, toolTip.arg(part1, part2, CHAR_UTF8_NEQUAL)); /* title column */ part1 = QUStringSupport::withoutUnsupportedCharacters(song()->title()); diff --git a/src/songtree/QUSongTree.cpp b/src/songtree/QUSongTree.cpp index 84265b69..9ef8cf13 100644 --- a/src/songtree/QUSongTree.cpp +++ b/src/songtree/QUSongTree.cpp @@ -1004,8 +1004,7 @@ void QUSongTree::mergeSelectedSongs() { // --------------------------------- - QString infoText = QString(tr("You want to merge songs with \"%1 - %2\". All files of the other songs will be moved to that song's path.

The following %3 songs will disappear:")) - .arg(currentSongItem->song()->artist(), currentSongItem->song()->title(), QString::number(selectedItems.size())); + QString infoText = QString(tr("You want to merge songs with \"%1 - %2\". All files of the other songs will be moved to that song's path.

The following %3 songs will disappear:")).arg(currentSongItem->song()->artist(), currentSongItem->song()->title(), QString::number(selectedItems.size())); int i = 0; foreach(QUSongItem *songItem, selectedItems) {