Replace QDateTime::toTime_t() with QDateTime::toSecsSinceEpoch()
This commit is contained in:
@@ -177,11 +177,11 @@ void TagReader::ReadFile(const QString &filename, pb::tagreader::SongMetadata *s
|
|||||||
song->set_basefilename(DataCommaSizeFromQString(info.fileName()));
|
song->set_basefilename(DataCommaSizeFromQString(info.fileName()));
|
||||||
song->set_url(url.constData(), url.size());
|
song->set_url(url.constData(), url.size());
|
||||||
song->set_filesize(info.size());
|
song->set_filesize(info.size());
|
||||||
song->set_mtime(info.lastModified().toTime_t());
|
song->set_mtime(info.lastModified().toSecsSinceEpoch());
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
song->set_ctime(info.birthTime().isValid() ? info.birthTime().toTime_t() : info.lastModified().toTime_t());
|
song->set_ctime(info.birthTime().isValid() ? info.birthTime().toSecsSinceEpoch() : info.lastModified().toSecsSinceEpoch());
|
||||||
#else
|
#else
|
||||||
song->set_ctime(info.created().toTime_t());
|
song->set_ctime(info.created().toSecsSinceEpoch());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<TagLib::FileRef> fileref(factory_->GetFileRef(filename));
|
std::unique_ptr<TagLib::FileRef> fileref(factory_->GetFileRef(filename));
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!t->ignores_mtime() && !force_noincremental && t->is_incremental() && subdir.mtime == path_info.lastModified().toTime_t()) {
|
if (!t->ignores_mtime() && !force_noincremental && t->is_incremental() && subdir.mtime == path_info.lastModified().toSecsSinceEpoch()) {
|
||||||
// The directory hasn't changed since last time
|
// The directory hasn't changed since last time
|
||||||
t->AddToProgress(1);
|
t->AddToProgress(1);
|
||||||
return;
|
return;
|
||||||
@@ -362,7 +362,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
|||||||
Subdirectory new_subdir;
|
Subdirectory new_subdir;
|
||||||
new_subdir.directory_id = -1;
|
new_subdir.directory_id = -1;
|
||||||
new_subdir.path = child;
|
new_subdir.path = child;
|
||||||
new_subdir.mtime = child_info.lastModified().toTime_t();
|
new_subdir.mtime = child_info.lastModified().toSecsSinceEpoch();
|
||||||
my_new_subdirs << new_subdir;
|
my_new_subdirs << new_subdir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -393,7 +393,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
|||||||
|
|
||||||
Song matching_song(source_);
|
Song matching_song(source_);
|
||||||
if (FindSongByPath(songs_in_db, file, &matching_song)) {
|
if (FindSongByPath(songs_in_db, file, &matching_song)) {
|
||||||
uint matching_cue_mtime = GetMtimeForCue(matching_cue);
|
quint64 matching_cue_mtime = GetMtimeForCue(matching_cue);
|
||||||
|
|
||||||
// The song is in the database and still on disk.
|
// The song is in the database and still on disk.
|
||||||
// Check the mtime to see if it's been changed since it was added.
|
// Check the mtime to see if it's been changed since it was added.
|
||||||
@@ -407,13 +407,13 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
|||||||
|
|
||||||
// cue sheet's path from collection (if any)
|
// cue sheet's path from collection (if any)
|
||||||
QString song_cue = matching_song.cue_path();
|
QString song_cue = matching_song.cue_path();
|
||||||
uint song_cue_mtime = GetMtimeForCue(song_cue);
|
qint64 song_cue_mtime = GetMtimeForCue(song_cue);
|
||||||
|
|
||||||
bool cue_deleted = song_cue_mtime == 0 && matching_song.has_cue();
|
bool cue_deleted = song_cue_mtime == 0 && matching_song.has_cue();
|
||||||
bool cue_added = matching_cue_mtime != 0 && !matching_song.has_cue();
|
bool cue_added = matching_cue_mtime != 0 && !matching_song.has_cue();
|
||||||
|
|
||||||
// watch out for cue songs which have their mtime equal to qMax(media_file_mtime, cue_sheet_mtime)
|
// watch out for cue songs which have their mtime equal to qMax(media_file_mtime, cue_sheet_mtime)
|
||||||
bool changed = (matching_song.mtime() != qMax(file_info.lastModified().toTime_t(), song_cue_mtime)) || cue_deleted || cue_added;
|
bool changed = (matching_song.mtime() != static_cast<quint64>(qMax(file_info.lastModified().toSecsSinceEpoch(), song_cue_mtime))) || cue_deleted || cue_added;
|
||||||
|
|
||||||
// Also want to look to see whether the album art has changed
|
// Also want to look to see whether the album art has changed
|
||||||
QUrl image = ImageForSong(file, album_art);
|
QUrl image = ImageForSong(file, album_art);
|
||||||
@@ -470,7 +470,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
|||||||
// Add this subdir to the new or touched list
|
// Add this subdir to the new or touched list
|
||||||
Subdirectory updated_subdir;
|
Subdirectory updated_subdir;
|
||||||
updated_subdir.directory_id = t->dir();
|
updated_subdir.directory_id = t->dir();
|
||||||
updated_subdir.mtime = path_info.exists() ? path_info.lastModified().toTime_t() : 0;
|
updated_subdir.mtime = path_info.exists() ? path_info.lastModified().toSecsSinceEpoch() : 0;
|
||||||
updated_subdir.path = path;
|
updated_subdir.path = path;
|
||||||
|
|
||||||
if (subdir.directory_id == -1)
|
if (subdir.directory_id == -1)
|
||||||
@@ -560,7 +560,7 @@ SongList CollectionWatcher::ScanNewFile(const QString &file, const QString &path
|
|||||||
|
|
||||||
SongList song_list;
|
SongList song_list;
|
||||||
|
|
||||||
uint matching_cue_mtime = GetMtimeForCue(matching_cue);
|
quint64 matching_cue_mtime = GetMtimeForCue(matching_cue);
|
||||||
// If it's a cue - create virtual tracks
|
// If it's a cue - create virtual tracks
|
||||||
if (matching_cue_mtime) {
|
if (matching_cue_mtime) {
|
||||||
// don't process the same cue many times
|
// don't process the same cue many times
|
||||||
@@ -629,7 +629,7 @@ void CollectionWatcher::PreserveUserSetData(const QString &file, const QUrl &ima
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint CollectionWatcher::GetMtimeForCue(const QString &cue_path) {
|
quint64 CollectionWatcher::GetMtimeForCue(const QString &cue_path) {
|
||||||
|
|
||||||
// Slight optimisation
|
// Slight optimisation
|
||||||
if (cue_path.isEmpty()) {
|
if (cue_path.isEmpty()) {
|
||||||
@@ -643,7 +643,7 @@ uint CollectionWatcher::GetMtimeForCue(const QString &cue_path) {
|
|||||||
|
|
||||||
const QDateTime cue_last_modified = file_info.lastModified();
|
const QDateTime cue_last_modified = file_info.lastModified();
|
||||||
|
|
||||||
return cue_last_modified.isValid() ? cue_last_modified.toTime_t() : 0;
|
return cue_last_modified.isValid() ? cue_last_modified.toSecsSinceEpoch() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollectionWatcher::AddWatch(const Directory &dir, const QString &path) {
|
void CollectionWatcher::AddWatch(const Directory &dir, const QString &path) {
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class CollectionWatcher : public QObject {
|
|||||||
QUrl ImageForSong(const QString &path, QMap<QString, QStringList> &album_art);
|
QUrl ImageForSong(const QString &path, QMap<QString, QStringList> &album_art);
|
||||||
void AddWatch(const Directory &dir, const QString &path);
|
void AddWatch(const Directory &dir, const QString &path);
|
||||||
void RemoveWatch(const Directory &dir, const Subdirectory &subdir);
|
void RemoveWatch(const Directory &dir, const Subdirectory &subdir);
|
||||||
uint GetMtimeForCue(const QString &cue_path);
|
quint64 GetMtimeForCue(const QString &cue_path);
|
||||||
void PerformScan(bool incremental, bool ignore_mtimes);
|
void PerformScan(bool incremental, bool ignore_mtimes);
|
||||||
|
|
||||||
// Updates the sections of a cue associated and altered (according to mtime) media file during a scan.
|
// Updates the sections of a cue associated and altered (according to mtime) media file during a scan.
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ inline void AddMetadata(const QString &key, const QDateTime &metadata, QVariantM
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline QString AsMPRISDateTimeType(const int time) {
|
inline QString AsMPRISDateTimeType(const int time) {
|
||||||
return time != -1 ? QDateTime::fromTime_t(time).toString(Qt::ISODate) : "";
|
return time != -1 ? QDateTime::fromSecsSinceEpoch(time).toString(Qt::ISODate) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mpris
|
} // namespace mpris
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ SpotifyCoverProvider::SpotifyCoverProvider(Application *app, QObject *parent) :
|
|||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
if (!refresh_token_.isEmpty()) {
|
if (!refresh_token_.isEmpty()) {
|
||||||
qint64 time = expires_in_ - (QDateTime::currentDateTime().toTime_t() - login_time_);
|
qint64 time = expires_in_ - (QDateTime::currentDateTime().toSecsSinceEpoch() - login_time_);
|
||||||
if (time < 6) time = 6;
|
if (time < 6) time = 6;
|
||||||
refresh_login_timer_.setInterval(time * kMsecPerSec);
|
refresh_login_timer_.setInterval(time * kMsecPerSec);
|
||||||
refresh_login_timer_.start();
|
refresh_login_timer_.start();
|
||||||
@@ -330,7 +330,7 @@ void SpotifyCoverProvider::AccessTokenRequestFinished(QNetworkReply *reply) {
|
|||||||
refresh_token_ = json_obj["refresh_token"].toString();
|
refresh_token_ = json_obj["refresh_token"].toString();
|
||||||
}
|
}
|
||||||
expires_in_ = json_obj["expires_in"].toInt();
|
expires_in_ = json_obj["expires_in"].toInt();
|
||||||
login_time_ = QDateTime::currentDateTime().toTime_t();
|
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ bool GlobalShortcutBackendGSD::DoRegister() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentDateTime().toTime_t());
|
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||||
|
|
||||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||||
NewClosure(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(RegisterFinished(QDBusPendingCallWatcher*)), watcher);
|
NewClosure(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(RegisterFinished(QDBusPendingCallWatcher*)), watcher);
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ QString DateItemDelegate::displayText(const QVariant &value, const QLocale &loca
|
|||||||
if (!ok || time == -1)
|
if (!ok || time == -1)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
return QDateTime::fromTime_t(time).toString(QLocale::system().dateTimeFormat(QLocale::ShortFormat));
|
return QDateTime::fromSecsSinceEpoch(time).toString(QLocale::system().dateTimeFormat(QLocale::ShortFormat));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ void ScrobblingAPI20::UpdateNowPlaying(const Song &song) {
|
|||||||
CheckScrobblePrevSong();
|
CheckScrobblePrevSong();
|
||||||
|
|
||||||
song_playing_ = song;
|
song_playing_ = song;
|
||||||
timestamp_ = QDateTime::currentDateTime().toTime_t();
|
timestamp_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||||
scrobbled_ = false;
|
scrobbled_ = false;
|
||||||
|
|
||||||
if (!IsAuthenticated() || !song.is_metadata_good() || app_->scrobbler()->IsOffline()) return;
|
if (!IsAuthenticated() || !song.is_metadata_good() || app_->scrobbler()->IsOffline()) return;
|
||||||
@@ -1030,7 +1030,7 @@ QString ScrobblingAPI20::ErrorString(const ScrobbleErrorCode error) const {
|
|||||||
|
|
||||||
void ScrobblingAPI20::CheckScrobblePrevSong() {
|
void ScrobblingAPI20::CheckScrobblePrevSong() {
|
||||||
|
|
||||||
quint64 duration = QDateTime::currentDateTime().toTime_t() - timestamp_;
|
quint64 duration = QDateTime::currentDateTime().toSecsSinceEpoch() - timestamp_;
|
||||||
|
|
||||||
if (!scrobbled_ && song_playing_.is_metadata_good() && song_playing_.source() == Song::Source_Stream && duration > 30) {
|
if (!scrobbled_ && song_playing_.is_metadata_good() && song_playing_.source() == Song::Source_Stream && duration > 30) {
|
||||||
Song song(song_playing_);
|
Song song(song_playing_);
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ void TidalService::LoadSession() {
|
|||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
if (!refresh_token_.isEmpty()) {
|
if (!refresh_token_.isEmpty()) {
|
||||||
qint64 time = expires_in_ - (QDateTime::currentDateTime().toTime_t() - login_time_);
|
qint64 time = expires_in_ - (QDateTime::currentDateTime().toSecsSinceEpoch() - login_time_);
|
||||||
if (time < 6) time = 6;
|
if (time < 6) time = 6;
|
||||||
timer_refresh_login_->setInterval(time * kMsecPerSec);
|
timer_refresh_login_->setInterval(time * kMsecPerSec);
|
||||||
timer_refresh_login_->start();
|
timer_refresh_login_->start();
|
||||||
@@ -330,7 +330,7 @@ void TidalService::AuthorizationUrlReceived(const QUrl &url) {
|
|||||||
refresh_token_ = url_query.queryItemValue("refresh_token").toUtf8();
|
refresh_token_ = url_query.queryItemValue("refresh_token").toUtf8();
|
||||||
}
|
}
|
||||||
expires_in_ = url_query.queryItemValue("expires_in").toInt();
|
expires_in_ = url_query.queryItemValue("expires_in").toInt();
|
||||||
login_time_ = QDateTime::currentDateTime().toTime_t();
|
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||||
session_id_.clear();
|
session_id_.clear();
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
@@ -483,7 +483,7 @@ void TidalService::AccessTokenRequestFinished(QNetworkReply *reply) {
|
|||||||
if (json_obj.contains("refresh_token")) {
|
if (json_obj.contains("refresh_token")) {
|
||||||
refresh_token_ = json_obj["refresh_token"].toString();
|
refresh_token_ = json_obj["refresh_token"].toString();
|
||||||
}
|
}
|
||||||
login_time_ = QDateTime::currentDateTime().toTime_t();
|
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||||
|
|
||||||
if (json_obj.contains("user") && json_obj["user"].isObject()) {
|
if (json_obj.contains("user") && json_obj["user"].isObject()) {
|
||||||
QJsonObject obj_user = json_obj["user"].toObject();
|
QJsonObject obj_user = json_obj["user"].toObject();
|
||||||
|
|||||||
Reference in New Issue
Block a user