Replace QDateTime::toTime_t() with QDateTime::toSecsSinceEpoch()
This commit is contained in:
parent
4140163ab2
commit
f24b6a520c
|
@ -177,11 +177,11 @@ void TagReader::ReadFile(const QString &filename, pb::tagreader::SongMetadata *s
|
|||
song->set_basefilename(DataCommaSizeFromQString(info.fileName()));
|
||||
song->set_url(url.constData(), url.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))
|
||||
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
|
||||
song->set_ctime(info.created().toTime_t());
|
||||
song->set_ctime(info.created().toSecsSinceEpoch());
|
||||
#endif
|
||||
|
||||
std::unique_ptr<TagLib::FileRef> fileref(factory_->GetFileRef(filename));
|
||||
|
|
|
@ -328,7 +328,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
|||
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
|
||||
t->AddToProgress(1);
|
||||
return;
|
||||
|
@ -362,7 +362,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
|||
Subdirectory new_subdir;
|
||||
new_subdir.directory_id = -1;
|
||||
new_subdir.path = child;
|
||||
new_subdir.mtime = child_info.lastModified().toTime_t();
|
||||
new_subdir.mtime = child_info.lastModified().toSecsSinceEpoch();
|
||||
my_new_subdirs << new_subdir;
|
||||
}
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const Subdirectory
|
|||
|
||||
Song matching_song(source_);
|
||||
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.
|
||||
// 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)
|
||||
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_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)
|
||||
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
|
||||
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
|
||||
Subdirectory updated_subdir;
|
||||
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;
|
||||
|
||||
if (subdir.directory_id == -1)
|
||||
|
@ -560,7 +560,7 @@ SongList CollectionWatcher::ScanNewFile(const QString &file, const QString &path
|
|||
|
||||
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 (matching_cue_mtime) {
|
||||
// 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
|
||||
if (cue_path.isEmpty()) {
|
||||
|
@ -643,7 +643,7 @@ uint CollectionWatcher::GetMtimeForCue(const QString &cue_path) {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -166,7 +166,7 @@ class CollectionWatcher : public QObject {
|
|||
QUrl ImageForSong(const QString &path, QMap<QString, QStringList> &album_art);
|
||||
void AddWatch(const Directory &dir, const QString &path);
|
||||
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);
|
||||
|
||||
// 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) {
|
||||
return time != -1 ? QDateTime::fromTime_t(time).toString(Qt::ISODate) : "";
|
||||
return time != -1 ? QDateTime::fromSecsSinceEpoch(time).toString(Qt::ISODate) : "";
|
||||
}
|
||||
|
||||
} // namespace mpris
|
||||
|
|
|
@ -77,7 +77,7 @@ SpotifyCoverProvider::SpotifyCoverProvider(Application *app, QObject *parent) :
|
|||
s.endGroup();
|
||||
|
||||
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;
|
||||
refresh_login_timer_.setInterval(time * kMsecPerSec);
|
||||
refresh_login_timer_.start();
|
||||
|
@ -330,7 +330,7 @@ void SpotifyCoverProvider::AccessTokenRequestFinished(QNetworkReply *reply) {
|
|||
refresh_token_ = json_obj["refresh_token"].toString();
|
||||
}
|
||||
expires_in_ = json_obj["expires_in"].toInt();
|
||||
login_time_ = QDateTime::currentDateTime().toTime_t();
|
||||
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
|
|
@ -66,7 +66,7 @@ bool GlobalShortcutBackendGSD::DoRegister() {
|
|||
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);
|
||||
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)
|
||||
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();
|
||||
|
||||
song_playing_ = song;
|
||||
timestamp_ = QDateTime::currentDateTime().toTime_t();
|
||||
timestamp_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
scrobbled_ = false;
|
||||
|
||||
if (!IsAuthenticated() || !song.is_metadata_good() || app_->scrobbler()->IsOffline()) return;
|
||||
|
@ -1030,7 +1030,7 @@ QString ScrobblingAPI20::ErrorString(const ScrobbleErrorCode error) const {
|
|||
|
||||
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) {
|
||||
Song song(song_playing_);
|
||||
|
|
|
@ -250,7 +250,7 @@ void TidalService::LoadSession() {
|
|||
s.endGroup();
|
||||
|
||||
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;
|
||||
timer_refresh_login_->setInterval(time * kMsecPerSec);
|
||||
timer_refresh_login_->start();
|
||||
|
@ -330,7 +330,7 @@ void TidalService::AuthorizationUrlReceived(const QUrl &url) {
|
|||
refresh_token_ = url_query.queryItemValue("refresh_token").toUtf8();
|
||||
}
|
||||
expires_in_ = url_query.queryItemValue("expires_in").toInt();
|
||||
login_time_ = QDateTime::currentDateTime().toTime_t();
|
||||
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
session_id_.clear();
|
||||
|
||||
QSettings s;
|
||||
|
@ -483,7 +483,7 @@ void TidalService::AccessTokenRequestFinished(QNetworkReply *reply) {
|
|||
if (json_obj.contains("refresh_token")) {
|
||||
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()) {
|
||||
QJsonObject obj_user = json_obj["user"].toObject();
|
||||
|
|
Loading…
Reference in New Issue