diff --git a/src/collection/collectionbackend.cpp b/src/collection/collectionbackend.cpp index f0cebc2af..e39798381 100644 --- a/src/collection/collectionbackend.cpp +++ b/src/collection/collectionbackend.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include @@ -1031,7 +1031,7 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist, info.first_url = QUrl::fromEncoded(query.Value(7).toByteArray()); QString art_automatic = query.Value(5).toString(); - if (art_automatic.contains(QRegExp("..+:.*"))) { + if (art_automatic.contains(QRegularExpression("..+:.*"))) { info.art_automatic = QUrl::fromEncoded(art_automatic.toUtf8()); } else { @@ -1039,7 +1039,7 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist, } QString art_manual = query.Value(6).toString(); - if (art_manual.contains(QRegExp("..+:.*"))) { + if (art_manual.contains(QRegularExpression("..+:.*"))) { info.art_manual = QUrl::fromEncoded(art_manual.toUtf8()); } else { @@ -1228,7 +1228,7 @@ void CollectionBackend::IncrementPlayCount(int id) { QSqlQuery q(db); q.prepare(QString("UPDATE %1 SET playcount = playcount + 1, lastplayed = :now WHERE ROWID = :id").arg(songs_table_)); - q.bindValue(":now", QDateTime::currentDateTime().toTime_t()); + q.bindValue(":now", QDateTime::currentDateTime().toSecsSinceEpoch()); q.bindValue(":id", id); q.exec(); if (db_->CheckErrors(q)) return; diff --git a/src/collection/collectionfilterwidget.cpp b/src/collection/collectionfilterwidget.cpp index 89d3dd815..73fb27529 100644 --- a/src/collection/collectionfilterwidget.cpp +++ b/src/collection/collectionfilterwidget.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -63,7 +63,7 @@ CollectionFilterWidget::CollectionFilterWidget(QWidget *parent) ui_->setupUi(this); - QString available_fields = Song::kFtsColumns.join(", ").replace(QRegExp("\\bfts"), ""); + QString available_fields = Song::kFtsColumns.join(", ").replace(QRegularExpression("\\bfts"), ""); ui_->filter->setToolTip( "

" + diff --git a/src/collection/collectionmodel.cpp b/src/collection/collectionmodel.cpp index 7ab572df4..47d1eac0c 100644 --- a/src/collection/collectionmodel.cpp +++ b/src/collection/collectionmodel.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -861,7 +861,6 @@ void CollectionModel::LazyPopulate(CollectionItem *parent, const bool signal) { void CollectionModel::ResetAsync() { QFuture future = QtConcurrent::run(this, &CollectionModel::RunQuery, root_); NewClosure(future, this, SLOT(ResetAsyncQueryFinished(QFuture)), future); - } void CollectionModel::ResetAsyncQueryFinished(QFuture future) { @@ -1421,7 +1420,7 @@ QString CollectionModel::PrettyYearAlbum(const int year, const QString &album) { QString CollectionModel::PrettyAlbumDisc(const QString &album, const int disc) { - if (disc <= 0 || album.contains(QRegExp(Song::kAlbumRemoveDisc))) return TextOrUnknown(album); + if (disc <= 0 || album.contains(QRegularExpression(Song::kAlbumRemoveDisc))) return TextOrUnknown(album); else return TextOrUnknown(album) + " - (Disc " + QString::number(disc) + ")"; } @@ -1433,7 +1432,7 @@ QString CollectionModel::PrettyYearAlbumDisc(const int year, const QString &albu if (year <= 0) str = TextOrUnknown(album); else str = QString::number(year) + " - " + TextOrUnknown(album); - if (!album.contains(QRegExp(Song::kAlbumRemoveDisc)) && disc > 0) str += " - (Disc " + QString::number(disc) + ")"; + if (!album.contains(QRegularExpression(Song::kAlbumRemoveDisc)) && disc > 0) str += " - (Disc " + QString::number(disc) + ")"; return str; @@ -1447,7 +1446,7 @@ QString CollectionModel::SortText(QString text) { else { text = text.toLower(); } - text = text.remove(QRegExp("[^\\w ]")); + text = text.remove(QRegularExpression("[^\\w ]")); return text; diff --git a/src/collection/collectionquery.cpp b/src/collection/collectionquery.cpp index 0ffc616be..ce81faba4 100644 --- a/src/collection/collectionquery.cpp +++ b/src/collection/collectionquery.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include @@ -46,9 +46,9 @@ CollectionQuery::CollectionQuery(const QueryOptions &options) // Split on whitespace #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QStringList tokens(options.filter().split(QRegExp("\\s+"), Qt::SkipEmptyParts)); + QStringList tokens(options.filter().split(QRegularExpression("\\s+"), Qt::SkipEmptyParts)); #else - QStringList tokens(options.filter().split(QRegExp("\\s+"), QString::SkipEmptyParts)); + QStringList tokens(options.filter().split(QRegularExpression("\\s+"), QString::SkipEmptyParts)); #endif QString query; for (QString token : tokens) { @@ -86,7 +86,7 @@ CollectionQuery::CollectionQuery(const QueryOptions &options) } if (options.max_age() != -1) { - int cutoff = QDateTime::currentDateTime().toTime_t() - options.max_age(); + int cutoff = QDateTime::currentDateTime().toSecsSinceEpoch() - options.max_age(); where_clauses_ << "ctime > ?"; bound_values_ << cutoff; @@ -202,7 +202,7 @@ QVariant CollectionQuery::Value(int column) const { return query_.value(column); bool QueryOptions::Matches(const Song &song) const { if (max_age_ != -1) { - const uint cutoff = QDateTime::currentDateTime().toTime_t() - max_age_; + const uint cutoff = QDateTime::currentDateTime().toSecsSinceEpoch() - max_age_; if (song.ctime() <= cutoff) return false; } diff --git a/src/context/contextalbumsmodel.cpp b/src/context/contextalbumsmodel.cpp index dfb2ae268..d4aee0e27 100644 --- a/src/context/contextalbumsmodel.cpp +++ b/src/context/contextalbumsmodel.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -370,7 +370,7 @@ QString ContextAlbumsModel::SortText(QString text) { else { text = text.toLower(); } - text = text.remove(QRegExp("[^\\w ]")); + text = text.remove(QRegularExpression("[^\\w ]")); return text; diff --git a/src/core/database.cpp b/src/core/database.cpp index 58e55769b..5c31213e2 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -392,7 +392,7 @@ void Database::ExecSchemaCommandsFromFile(QSqlDatabase &db, const QString &filen void Database::ExecSchemaCommands(QSqlDatabase &db, const QString &schema, int schema_version, bool in_transaction) { // Run each command - const QStringList commands(schema.split(QRegExp("; *\n\n"))); + const QStringList commands(schema.split(QRegularExpression("; *\n\n"))); // We don't want this list to reflect possible DB schema changes so we initialize it before executing any statements. // If no outer transaction is provided the song tables need to be queried before beginning an inner transaction! Otherwise diff --git a/src/core/song.cpp b/src/core/song.cpp index a09675f17..9ec51794a 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -148,9 +149,9 @@ const QString Song::kFtsUpdateSpec = Utilities::Updateify(Song::kFtsColumns).joi const QString Song::kManuallyUnsetCover = "(unset)"; const QString Song::kEmbeddedCover = "(embedded)"; -const QRegExp Song::kAlbumRemoveDisc(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$"); -const QRegExp Song::kAlbumRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|([0-9]{1,4}) *Remaster) ?((\\)|\\])?)$"); -const QRegExp Song::kTitleRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|Live|Remastered Version|([0-9]{1,4}) *Remaster) ?((\\)|\\])?)$"); +const QRegularExpression Song::kAlbumRemoveDisc(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$"); +const QRegularExpression Song::kAlbumRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|([0-9]{1,4}) *Remaster) ?((\\)|\\])?)$"); +const QRegularExpression Song::kTitleRemoveMisc(" ?-? ((\\(|\\[)?)(Remastered|Live|Remastered Version|([0-9]{1,4}) *Remaster) ?((\\)|\\])?)$"); const QString Song::kVariousArtists("various artists"); const QStringList Song::kArticles = QStringList() << "the " << "a " << "an "; @@ -322,8 +323,8 @@ const QUrl &Song::url() const { return d->url_; } const QString &Song::basefilename() const { return d->basefilename_; } Song::FileType Song::filetype() const { return d->filetype_; } int Song::filesize() const { return d->filesize_; } -uint Song::mtime() const { return d->mtime_; } -uint Song::ctime() const { return d->ctime_; } +quint64 Song::mtime() const { return d->mtime_; } +quint64 Song::ctime() const { return d->ctime_; } int Song::playcount() const { return d->playcount_; } int Song::skipcount() const { return d->skipcount_; } @@ -958,7 +959,7 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) { else if (Song::kColumns.value(i) == "art_automatic") { QString art_automatic = tostr(x); - if (art_automatic.contains(QRegExp("..+:.*"))) { + if (art_automatic.contains(QRegularExpression("..+:.*"))) { set_art_automatic(QUrl::fromEncoded(art_automatic.toUtf8())); } else { @@ -967,7 +968,7 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) { } else if (Song::kColumns.value(i) == "art_manual") { QString art_manual = tostr(x); - if (art_manual.contains(QRegExp("..+:.*"))) { + if (art_manual.contains(QRegularExpression("..+:.*"))) { set_art_manual(QUrl::fromEncoded(art_manual.toUtf8())); } else { diff --git a/src/core/song.h b/src/core/song.h index 29149b0af..208e010c1 100644 --- a/src/core/song.h +++ b/src/core/song.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -120,10 +120,9 @@ class Song { static const QString kManuallyUnsetCover; static const QString kEmbeddedCover; - static const QRegExp kAlbumRemoveDisc; - static const QRegExp kAlbumRemoveMisc; - static const QRegExp kTitleRemoveMisc; - static const QRegExp kFilenameRemoveNonFatChars; + static const QRegularExpression kAlbumRemoveDisc; + static const QRegularExpression kAlbumRemoveMisc; + static const QRegularExpression kTitleRemoveMisc; static const QString kVariousArtists; @@ -228,8 +227,8 @@ class Song { const QString &basefilename() const; FileType filetype() const; int filesize() const; - uint mtime() const; - uint ctime() const; + quint64 mtime() const; + quint64 ctime() const; int playcount() const; int skipcount() const; diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 07e74871b..56572cd8c 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -157,7 +158,7 @@ QString WordyTimeNanosec(qint64 nanoseconds) { QString Ago(int seconds_since_epoch, const QLocale &locale) { const QDateTime now = QDateTime::currentDateTime(); - const QDateTime then = QDateTime::fromTime_t(seconds_since_epoch); + const QDateTime then = QDateTime::fromSecsSinceEpoch(seconds_since_epoch); const int days_ago = then.date().daysTo(now.date()); const QString time = then.time().toString(locale.timeFormat(QLocale::ShortFormat)); @@ -533,16 +534,6 @@ QString PrettySize(const QSize &size) { return QString::number(size.width()) + "x" + QString::number(size.height()); } -void ForwardMouseEvent(const QMouseEvent *e, QWidget *target) { - QMouseEvent c(e->type(), target->mapFromGlobal(e->globalPos()), e->globalPos(), e->button(), e->buttons(), e->modifiers()); - - QApplication::sendEvent(target, &c); -} - -bool IsMouseEventInWidget(const QMouseEvent *e, const QWidget *widget) { - return widget->rect().contains(widget->mapFromGlobal(e->globalPos())); -} - quint16 PickUnusedPort() { forever { @@ -944,7 +935,7 @@ QString ReplaceMessage(const QString &message, const Song &song, const QString & pos += variable_replacer.matchedLength(); } - int index_of = copy.indexOf(QRegExp(" - (>|$)")); + int index_of = copy.indexOf(QRegularExpression(" - (>|$)")); if (index_of >= 0) copy = copy.remove(index_of, 3); return copy; diff --git a/src/core/utilities.h b/src/core/utilities.h index 53a14b814..717783d6a 100644 --- a/src/core/utilities.h +++ b/src/core/utilities.h @@ -85,12 +85,6 @@ QByteArray Sha1CoverHash(const QString &artist, const QString &album); // Picks an unused ephemeral port number. Doesn't hold the port open so there's the obvious race condition quint16 PickUnusedPort(); -// Forwards a mouse event to a different widget, remapping the event's widget coordinates relative to those of the target widget. -void ForwardMouseEvent(const QMouseEvent *e, QWidget *target); - -// Checks if the mouse event was inside the widget's rectangle. -bool IsMouseEventInWidget(const QMouseEvent *e, const QWidget *widget); - // Reads all children of the current element, // and returns with the stream reader either on the EndElement for the current element, or the end of the file - whichever came first. void ConsumeCurrentElement(QXmlStreamReader *reader); diff --git a/src/covermanager/albumcoverchoicecontroller.cpp b/src/covermanager/albumcoverchoicecontroller.cpp index aa1774fe0..b88766a61 100644 --- a/src/covermanager/albumcoverchoicecontroller.cpp +++ b/src/covermanager/albumcoverchoicecontroller.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -163,7 +163,7 @@ void AlbumCoverChoiceController::SaveCoverToFileManual(const Song &song, const Q } initial_file_name = initial_file_name + "-" + (song.effective_album().isEmpty() ? tr("unknown") : song.effective_album()) + ".jpg"; initial_file_name = initial_file_name.toLower(); - initial_file_name.replace(QRegExp("\\s"), "-"); + initial_file_name.replace(QRegularExpression("\\s"), "-"); initial_file_name.remove(OrganiseFormat::kInvalidFatCharacters); QString save_filename = QFileDialog::getSaveFileName(this, tr("Save album cover"), GetInitialPathForFileDialog(song, initial_file_name), tr(kSaveImageFileFilter) + ";;" + tr(kAllFilesFilter)); diff --git a/src/covermanager/albumcoverloader.cpp b/src/covermanager/albumcoverloader.cpp index 08f8729fb..0f638f648 100644 --- a/src/covermanager/albumcoverloader.cpp +++ b/src/covermanager/albumcoverloader.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -150,7 +151,7 @@ QString AlbumCoverLoader::CoverFilePath(const Song::Source source, const QString filename = CoverFilenameFromVariable(artist, album); filename.remove(OrganiseFormat::kInvalidFatCharacters); if (cover_lowercase_) filename = filename.toLower(); - if (cover_replace_spaces_) filename.replace(QRegExp("\\s"), "-"); + if (cover_replace_spaces_) filename.replace(QRegularExpression("\\s"), "-"); if (!extension.isEmpty()) { filename.append('.'); filename.append(extension); diff --git a/src/covermanager/musixmatchcoverprovider.cpp b/src/covermanager/musixmatchcoverprovider.cpp index 3fe857f84..e8155a8fb 100644 --- a/src/covermanager/musixmatchcoverprovider.cpp +++ b/src/covermanager/musixmatchcoverprovider.cpp @@ -25,10 +25,11 @@ #include #include #include +#include +#include #include #include #include -#include #include #include #include @@ -61,17 +62,17 @@ bool MusixmatchCoverProvider::StartSearch(const QString &artist, const QString & QString album_stripped = album; artist_stripped = artist_stripped.replace('/', '-'); - artist_stripped = artist_stripped.remove(QRegExp("[^A-Za-z0-9\\- ]")); + artist_stripped = artist_stripped.remove(QRegularExpression("[^A-Za-z0-9\\- ]")); artist_stripped = artist_stripped.simplified(); artist_stripped = artist_stripped.replace(' ', '-'); - artist_stripped = artist_stripped.replace(QRegExp("(-)\\1+"), "-"); + artist_stripped = artist_stripped.replace(QRegularExpression("(-)\\1+"), "-"); artist_stripped = artist_stripped.toLower(); album_stripped = album_stripped.replace('/', '-'); - album_stripped = album_stripped.remove(QRegExp("[^a-zA-Z0-9\\- ]")); + album_stripped = album_stripped.remove(QRegularExpression("[^a-zA-Z0-9\\- ]")); album_stripped = album_stripped.simplified(); album_stripped = album_stripped.replace(' ', '-').toLower(); - album_stripped = album_stripped.replace(QRegExp("(-)\\1+"), "-"); + album_stripped = album_stripped.replace(QRegularExpression("(-)\\1+"), "-"); album_stripped = album_stripped.toLower(); if (artist_stripped.isEmpty() || album_stripped.isEmpty()) return false; @@ -142,7 +143,7 @@ void MusixmatchCoverProvider::HandleSearchReply(QNetworkReply *reply, const int return; } - if (content_json.contains(QRegExp("<[^>]*>"))) { // Make sure it's not HTML code. + if (content_json.contains(QRegularExpression("<[^>]*>"))) { // Make sure it's not HTML code. emit SearchFinished(id, results); return; } diff --git a/src/device/giolister.cpp b/src/device/giolister.cpp index 0805c23ff..f3e1fccb8 100644 --- a/src/device/giolister.cpp +++ b/src/device/giolister.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -218,11 +219,11 @@ QList GioLister::MakeDeviceUrls(const QString &id) { for (QString uri : uris) { // gphoto2 gives invalid hostnames with []:, characters in - uri.replace(QRegExp("//\\[usb:(\\d+),(\\d+)\\]"), "//usb-\\1-\\2"); + uri.replace(QRegularExpression("//\\[usb:(\\d+),(\\d+)\\]"), "//usb-\\1-\\2"); QUrl url; - if (uri.contains(QRegExp("..+:.*"))) { + if (uri.contains(QRegularExpression("..+:.*"))) { url = QUrl::fromEncoded(uri.toUtf8()); } else { diff --git a/src/internet/internetsearchview.cpp b/src/internet/internetsearchview.cpp index b8c6fd699..1cc1f12ad 100644 --- a/src/internet/internetsearchview.cpp +++ b/src/internet/internetsearchview.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -427,7 +427,7 @@ void InternetSearchView::SwapModels() { QStringList InternetSearchView::TokenizeQuery(const QString &query) { - QStringList tokens(query.split(QRegExp("\\s+"))); + QStringList tokens(query.split(QRegularExpression("\\s+"))); for (QStringList::iterator it = tokens.begin(); it != tokens.end(); ++it) { (*it).remove('('); diff --git a/src/lyrics/geniuslyricsprovider.cpp b/src/lyrics/geniuslyricsprovider.cpp index 063ff62ca..2ce49ef36 100644 --- a/src/lyrics/geniuslyricsprovider.cpp +++ b/src/lyrics/geniuslyricsprovider.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -501,7 +502,7 @@ void GeniusLyricsProvider::HandleLyricReply(QNetworkReply *reply, const int sear begin_idx += tag_begin.length(); int end_idx = content.indexOf(tag_end, begin_idx); lyrics = content.mid(begin_idx, end_idx - begin_idx); - lyrics = lyrics.remove(QRegExp("<[^>]*>")); + lyrics = lyrics.remove(QRegularExpression("<[^>]*>")); lyrics = lyrics.trimmed(); } diff --git a/src/organise/organiseformat.cpp b/src/organise/organiseformat.cpp index e7df94d3c..011208a7d 100644 --- a/src/organise/organiseformat.cpp +++ b/src/organise/organiseformat.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -68,10 +69,10 @@ const QStringList OrganiseFormat::kKnownTags = QStringList() << "title" << "grouping" << "lyrics"; -const QRegExp OrganiseFormat::kInvalidDirCharacters("[/\\\\]"); -const QRegExp OrganiseFormat::kProblematicCharacters("[:?*\"<>|]"); +const QRegularExpression OrganiseFormat::kInvalidDirCharacters("[/\\\\]"); +const QRegularExpression OrganiseFormat::kProblematicCharacters("[:?*\"<>|]"); // From http://en.wikipedia.org/wiki/8.3_filename#Directory_table -const QRegExp OrganiseFormat::kInvalidFatCharacters("[^a-zA-Z0-9!#\\$%&'()\\-@\\^_`{}~/. ]"); +const QRegularExpression OrganiseFormat::kInvalidFatCharacters("[^a-zA-Z0-9!#\\$%&'()\\-@\\^_`{}~/. ]"); const char OrganiseFormat::kInvalidPrefixCharacters[] = "."; const int OrganiseFormat::kInvalidPrefixCharactersCount = arraysize(OrganiseFormat::kInvalidPrefixCharacters) - 1; @@ -126,7 +127,7 @@ QString OrganiseFormat::GetFilenameForSong(const Song &song) const { if (allow_ascii_ext_) ascii = 255; QString stripped; for (int i = 0 ; i < filename.length() ; ++i) { - const QCharRef c = filename[i]; + const QChar c = filename[i]; if (c < ascii) { stripped.append(c); } @@ -167,7 +168,7 @@ QString OrganiseFormat::GetFilenameForSong(const Song &song) const { } filename = parts_new.join("/"); - if (replace_spaces_) filename.replace(QRegExp("\\s"), "_"); + if (replace_spaces_) filename.replace(QRegularExpression("\\s"), "_"); if (!extension.isEmpty()) { filename.append(QString(".%1").arg(extension)); @@ -254,7 +255,7 @@ QString OrganiseFormat::TagValue(const QString &tag, const Song &song) const { else if (tag == "artistinitial") { value = song.effective_albumartist().trimmed(); if (!value.isEmpty()) { - value.replace(QRegExp("^the\\s+", Qt::CaseInsensitive), ""); + value.replace(QRegularExpression("^the\\s+", QRegularExpression::CaseInsensitiveOption), ""); value = value[0].toUpper(); } } diff --git a/src/organise/organiseformat.h b/src/organise/organiseformat.h index 87aece1fb..85d63b26a 100644 --- a/src/organise/organiseformat.h +++ b/src/organise/organiseformat.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -43,9 +43,9 @@ class OrganiseFormat { static const char *kTagPattern; static const char *kBlockPattern; static const QStringList kKnownTags; - static const QRegExp kInvalidDirCharacters; - static const QRegExp kProblematicCharacters; - static const QRegExp kInvalidFatCharacters; + static const QRegularExpression kInvalidDirCharacters; + static const QRegularExpression kProblematicCharacters; + static const QRegularExpression kInvalidFatCharacters; static const char kInvalidPrefixCharacters[]; static const int kInvalidPrefixCharactersCount; diff --git a/src/playlist/playlistcontainer.cpp b/src/playlist/playlistcontainer.cpp index 4cfb63f3b..10d73264e 100644 --- a/src/playlist/playlistcontainer.cpp +++ b/src/playlist/playlistcontainer.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -46,6 +46,9 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) +# include +#endif #include "core/iconloader.h" #include "playlist.h" @@ -197,7 +200,11 @@ void PlaylistContainer::SetViewModel(Playlist *playlist) { emit ViewSelectionModelChanged(); // Update filter +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + ui_->filter->setText(playlist->proxy()->filterRegularExpression().pattern()); +#else ui_->filter->setText(playlist->proxy()->filterRegExp().pattern()); +#endif // Update the no matches label connect(playlist_->proxy(), SIGNAL(modelReset()), SLOT(UpdateNoMatchesLabel())); diff --git a/src/playlist/playlistfilter.cpp b/src/playlist/playlistfilter.cpp index cb96b2ac8..9cb18f11b 100644 --- a/src/playlist/playlistfilter.cpp +++ b/src/playlist/playlistfilter.cpp @@ -22,9 +22,12 @@ #include #include -#include +#include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) +# include +#endif #include "playlist/playlist.h" #include "playlistfilter.h" @@ -78,7 +81,11 @@ void PlaylistFilter::sort(int column, Qt::SortOrder order) { bool PlaylistFilter::filterAcceptsRow(int row, const QModelIndex &parent) const { +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + QString filter = filterRegularExpression().pattern(); +#else QString filter = filterRegExp().pattern(); +#endif uint hash = qHash(filter); if (hash != query_hash_) { diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 0321fb66e..a41741c05 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -212,7 +212,6 @@ void PlaylistManager::Save(int id, const QString &filename, Playlist::Path path_ else { // Playlist is not in the playlist manager: probably save action was triggered from the left side bar and the playlist isn't loaded. QFuture> future = QtConcurrent::run(playlist_backend_, &PlaylistBackend::GetPlaylistSongs, id); - NewClosure(future, this, SLOT(ItemsLoadedForSavePlaylist(QFuture, QString, Playlist::Path)), future, filename, path_type); } @@ -233,7 +232,7 @@ void PlaylistManager::SaveWithUI(int id, const QString &playlist_name) { QString filter = settings.value("last_save_filter", parser()->default_filter()).toString(); QString suggested_filename = playlist_name; - suggested_filename.replace(QRegExp("\\W"), ""); + suggested_filename.replace(QRegularExpression("\\W"), ""); qLog(Debug) << "Using extension:" << extension; diff --git a/src/playlistparsers/asxparser.cpp b/src/playlistparsers/asxparser.cpp index 7c163e277..40befbe8b 100644 --- a/src/playlistparsers/asxparser.cpp +++ b/src/playlistparsers/asxparser.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -52,7 +53,7 @@ SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const int index = 0; while ((index = ex.indexIn(data, index)) != -1) { QString url = ex.cap(2); - url.replace(QRegExp("&(?!amp;|quot;|apos;|lt;|gt;)"), "&"); + url.replace(QRegularExpression("&(?!amp;|quot;|apos;|lt;|gt;)"), "&"); QByteArray replacement = QString(ex.cap(1) + url + "\"").toLocal8Bit(); data.replace(ex.cap(0).toLocal8Bit(), replacement); diff --git a/src/playlistparsers/cueparser.cpp b/src/playlistparsers/cueparser.cpp index 6311fd6a7..229f302b5 100644 --- a/src/playlistparsers/cueparser.cpp +++ b/src/playlistparsers/cueparser.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,9 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const SongList ret; QTextStream text_stream(device); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) text_stream.setCodec(QTextCodec::codecForUtfText(device->peek(1024), QTextCodec::codecForName("UTF-8"))); +#endif QString dir_path = dir.absolutePath(); // read the first line already @@ -234,7 +237,7 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const // Cue song has mtime equal to qMax(media_file_mtime, cue_sheet_mtime) if (cue_mtime.isValid()) { - song.set_mtime(qMax(cue_mtime.toTime_t(), song.mtime())); + song.set_mtime(qMax(static_cast(cue_mtime.toSecsSinceEpoch()), song.mtime())); } song.set_cue_path(playlist_path); @@ -275,7 +278,7 @@ QStringList CueParser::SplitCueLine(const QString &line) const { } // Let's remove the empty entries while we're at it - return line_regexp.capturedTexts().filter(QRegExp(".+")).mid(1, -1); + return line_regexp.capturedTexts().filter(QRegularExpression(".+")).mid(1, -1); } diff --git a/src/playlistparsers/parserbase.cpp b/src/playlistparsers/parserbase.cpp index d9fbea897..fa8fd5f0f 100644 --- a/src/playlistparsers/parserbase.cpp +++ b/src/playlistparsers/parserbase.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include "core/logging.h" @@ -43,7 +43,7 @@ void ParserBase::LoadSong(const QString &filename_or_url, qint64 beginning, cons QString filename = filename_or_url; - if (filename_or_url.contains(QRegExp("^[a-z]{2,}:"))) { + if (filename_or_url.contains(QRegularExpression("^[a-z]{2,}:"))) { QUrl url(filename_or_url); song->set_source(Song::SourceFromURL(url)); if (song->source() == Song::Source_LocalFile) { diff --git a/src/settings/backendsettingspage.cpp b/src/settings/backendsettingspage.cpp index d1c641d55..cdbebf6d6 100644 --- a/src/settings/backendsettingspage.cpp +++ b/src/settings/backendsettingspage.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -311,7 +311,7 @@ void BackendSettingsPage::Load_Device(QString output, QVariant device) { if (engine()->ALSADeviceSupport(output)) { ui_->radiobutton_alsa_hw->setEnabled(true); ui_->radiobutton_alsa_plughw->setEnabled(true); - if (device.toString().contains(QRegExp("^plughw:.*"))) { + if (device.toString().contains(QRegularExpression("^plughw:.*"))) { ui_->radiobutton_alsa_hw->setChecked(false); ui_->radiobutton_alsa_plughw->setChecked(true); SwitchALSADevices(alsa_plugin::alsa_plughw); @@ -476,11 +476,11 @@ void BackendSettingsPage::DeviceStringChanged() { #ifdef HAVE_ALSA if (engine()->ALSADeviceSupport(output.name)) { - if (ui_->lineedit_device->text().contains(QRegExp("^hw:.*")) && !ui_->radiobutton_alsa_hw->isChecked()) { + if (ui_->lineedit_device->text().contains(QRegularExpression("^hw:.*")) && !ui_->radiobutton_alsa_hw->isChecked()) { ui_->radiobutton_alsa_hw->setChecked(true); SwitchALSADevices(alsa_plugin::alsa_hw); } - else if (ui_->lineedit_device->text().contains(QRegExp("^plughw:.*")) && !ui_->radiobutton_alsa_plughw->isChecked()) { + else if (ui_->lineedit_device->text().contains(QRegularExpression("^plughw:.*")) && !ui_->radiobutton_alsa_plughw->isChecked()) { ui_->radiobutton_alsa_plughw->setChecked(true); SwitchALSADevices(alsa_plugin::alsa_plughw); } @@ -542,10 +542,10 @@ void BackendSettingsPage::SwitchALSADevices(alsa_plugin alsaplugin) { for (int i = 0; i < ui_->combobox_device->count(); ++i) { QListView *view = qobject_cast(ui_->combobox_device->view()); if (!view) continue; - if (alsaplugin == alsa_plugin::alsa_hw && ui_->combobox_device->itemData(i).toString().contains(QRegExp("^plughw:.*"))) { + if (alsaplugin == alsa_plugin::alsa_hw && ui_->combobox_device->itemData(i).toString().contains(QRegularExpression("^plughw:.*"))) { view->setRowHidden(i, true); } - else if (alsaplugin == alsa_plugin::alsa_plughw && ui_->combobox_device->itemData(i).toString().contains(QRegExp("^hw:.*"))) { + else if (alsaplugin == alsa_plugin::alsa_plughw && ui_->combobox_device->itemData(i).toString().contains(QRegularExpression("^hw:.*"))) { view->setRowHidden(i, true); } else { @@ -567,9 +567,9 @@ void BackendSettingsPage::radiobutton_alsa_hw_clicked(bool checked) { EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value(); if (!engine()->ALSADeviceSupport(output.name)) return; - if (ui_->lineedit_device->text().contains(QRegExp("^plughw:.*"))) { + if (ui_->lineedit_device->text().contains(QRegularExpression("^plughw:.*"))) { SwitchALSADevices(alsa_plugin::alsa_hw); - QString device_new = ui_->lineedit_device->text().replace(QRegExp("^plughw:"), "hw:"); + QString device_new = ui_->lineedit_device->text().replace(QRegularExpression("^plughw:"), "hw:"); bool found(false); for (int i = 0; i < ui_->combobox_device->count(); ++i) { QVariant device = ui_->combobox_device->itemData(i).value(); @@ -598,9 +598,9 @@ void BackendSettingsPage::radiobutton_alsa_plughw_clicked(bool checked) { EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value(); if (!engine()->ALSADeviceSupport(output.name)) return; - if (ui_->lineedit_device->text().contains(QRegExp("^hw:.*"))) { + if (ui_->lineedit_device->text().contains(QRegularExpression("^hw:.*"))) { SwitchALSADevices(alsa_plugin::alsa_plughw); - QString device_new = ui_->lineedit_device->text().replace(QRegExp("^hw:"), "plughw:"); + QString device_new = ui_->lineedit_device->text().replace(QRegularExpression("^hw:"), "plughw:"); bool found(false); for (int i = 0; i < ui_->combobox_device->count(); ++i) { QVariant device = ui_->combobox_device->itemData(i).value();