]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetInfo.cpp
Fix deprecation warning (from|toTime_t)
[lyx.git] / src / insets / InsetInfo.cpp
index 819d8ff62e55ec92eb8858ecdb556642b8787a87..61b39adc12719e826b90f107d171f3a714cc05e9 100644 (file)
@@ -297,7 +297,11 @@ vector<pair<string,docstring>> InsetInfoParams::getArguments(Buffer const * buf,
                string const dt = split(name, '@');
                QDate date;
                if (itype == "moddate")
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+                       date = QDateTime::fromSecsSinceEpoch(buf->fileName().lastModified()).date();
+#else
                        date = QDateTime::fromTime_t(buf->fileName().lastModified()).date();
+#endif
                else if (itype == "fixdate" && !dt.empty()) {
                        QDate const gdate = QDate::fromString(toqstr(dt), Qt::ISODate);
                        date = (gdate.isValid()) ? gdate : QDate::currentDate();
@@ -323,7 +327,11 @@ vector<pair<string,docstring>> InsetInfoParams::getArguments(Buffer const * buf,
                string const tt = split(name, '@');
                QTime time;
                if (itype == "modtime")
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+                       time = QDateTime::fromSecsSinceEpoch(buf->fileName().lastModified()).time();
+#else
                        time = QDateTime::fromTime_t(buf->fileName().lastModified()).time();
+#endif
                else if (itype == "fixtime" && !tt.empty()) {
                        QTime const gtime = QTime::fromString(toqstr(tt), Qt::ISODate);
                        time = (gtime.isValid()) ? gtime : QTime::currentTime();
@@ -1149,7 +1157,11 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype, bool cons
                                ? split(params_.name, date_format, '@') : string();
                QDate date;
                if (params_.type == InsetInfoParams::MODDATE_INFO)
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+                       date = QDateTime::fromSecsSinceEpoch(buffer().fileName().lastModified()).date();
+#else
                        date = QDateTime::fromTime_t(buffer().fileName().lastModified()).date();
+#endif
                else if (params_.type == InsetInfoParams::FIXDATE_INFO && !date_specifier.empty())
                        date = QDate::fromString(toqstr(date_specifier), Qt::ISODate);
                else
@@ -1166,7 +1178,11 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype, bool cons
                                ? split(params_.name, time_format, '@') : string();
                QTime time;
                if (params_.type == InsetInfoParams::MODTIME_INFO)
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+                       time = QDateTime::fromSecsSinceEpoch(buffer().fileName().lastModified()).time();
+#else
                        time = QDateTime::fromTime_t(buffer().fileName().lastModified()).time();
+#endif
                else if (params_.type == InsetInfoParams::FIXTIME_INFO && !time_specifier.empty())
                        time = QTime::fromString(toqstr(time_specifier), Qt::ISODate);
                else