Commit c8ee79a7 authored by Henrik Fehlauer's avatar Henrik Fehlauer Committed by Luigi Toscano

Port more deprecated functions and fix warnings

Summary:
KFileItem(mode, permissions, ...) is deprecated.
Port deprecated KRun::run to KRun:runService.
Replace deprecated std::auto_ptr with std::unique_ptr.
Add Q_DECL_OVERRIDE to MainWindow::eventFilter.

Depends on D5750
Depends on D5751

Test Plan: Tests pass.

Reviewers: ltoscano, sandsmark, gateau

Reviewed By: gateau

Differential Revision: https://phabricator.kde.org/D5752
parent 7dc3595d
...@@ -409,7 +409,7 @@ void FileOpsContextManagerItem::openWith(QAction* action) ...@@ -409,7 +409,7 @@ void FileOpsContextManagerItem::openWith(QAction* action)
} }
Q_ASSERT(service); Q_ASSERT(service);
KRun::run(*service, list, mGroup); KRun::runService(*service, list, mGroup);
} }
} // namespace } // namespace
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
KIPIImageInfo(KIPI::Interface* interface, const QUrl &url) KIPIImageInfo(KIPI::Interface* interface, const QUrl &url)
: KIPI::ImageInfoShared(interface, url) : KIPI::ImageInfoShared(interface, url)
{ {
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); KFileItem item(url);
mAttributes.insert("name", url.fileName()); mAttributes.insert("name", url.fileName());
mAttributes.insert("comment", comment()); mAttributes.insert("comment", comment());
......
...@@ -78,7 +78,7 @@ protected: ...@@ -78,7 +78,7 @@ protected:
virtual void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE; virtual void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE;
virtual void saveProperties(KConfigGroup&) Q_DECL_OVERRIDE; virtual void saveProperties(KConfigGroup&) Q_DECL_OVERRIDE;
virtual void readProperties(const KConfigGroup&) Q_DECL_OVERRIDE; virtual void readProperties(const KConfigGroup&) Q_DECL_OVERRIDE;
bool eventFilter(QObject *, QEvent *); bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
private Q_SLOTS: private Q_SLOTS:
void setActiveViewModeAction(QAction* action); void setActiveViewModeAction(QAction* action);
......
...@@ -146,7 +146,7 @@ public: ...@@ -146,7 +146,7 @@ public:
if (!service) { if (!service) {
qCritical() << "Could not find gwenview"; qCritical() << "Could not find gwenview";
} else { } else {
KRun::run(*service, {mThumbnailPage->destinationUrl()}, 0 /* window */); KRun::runService(*service, {mThumbnailPage->destinationUrl()}, 0 /* window */);
} }
} }
......
...@@ -51,7 +51,7 @@ struct ImporterPrivate ...@@ -51,7 +51,7 @@ struct ImporterPrivate
{ {
Importer* q; Importer* q;
QWidget* mAuthWindow; QWidget* mAuthWindow;
std::auto_ptr<FileNameFormater> mFileNameFormater; std::unique_ptr<FileNameFormater> mFileNameFormater;
QUrl mTempImportDirUrl; QUrl mTempImportDirUrl;
/* @defgroup reset Should be reset in start() /* @defgroup reset Should be reset in start()
...@@ -112,7 +112,8 @@ struct ImporterPrivate ...@@ -112,7 +112,8 @@ struct ImporterPrivate
QUrl dst = src.resolved(QUrl("..")); QUrl dst = src.resolved(QUrl(".."));
QString fileName; QString fileName;
if (mFileNameFormater.get()) { if (mFileNameFormater.get()) {
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, src, true /* delayedMimeTypes */); KFileItem item(src);
item.setDelayedMimeTypes(true);
// Get the document time, but do not cache the result because the // Get the document time, but do not cache the result because the
// 'src' url is temporary: if we import "foo/image.jpg" and // 'src' url is temporary: if we import "foo/image.jpg" and
// "bar/image.jpg", both images will be temporarily saved in the // "bar/image.jpg", both images will be temporarily saved in the
......
...@@ -46,7 +46,7 @@ private Q_SLOTS: ...@@ -46,7 +46,7 @@ private Q_SLOTS:
void testRenamedCount(); void testRenamedCount();
private: private:
std::auto_ptr<QTemporaryDir> mTempDir; std::unique_ptr<QTemporaryDir> mTempDir;
QList<QUrl> mDocumentList; QList<QUrl> mDocumentList;
}; };
......
...@@ -122,7 +122,7 @@ void ThumbnailProviderTest::testLoadLocal() ...@@ -122,7 +122,7 @@ void ThumbnailProviderTest::testLoadLocal()
KFileItemList list; KFileItemList list;
Q_FOREACH(const QFileInfo & info, dir.entryInfoList(QDir::Files)) { Q_FOREACH(const QFileInfo & info, dir.entryInfoList(QDir::Files)) {
QUrl url("file://" + info.absoluteFilePath()); QUrl url("file://" + info.absoluteFilePath());
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); KFileItem item(url);
list << item; list << item;
} }
...@@ -198,7 +198,7 @@ void ThumbnailProviderTest::testUseEmbeddedOrNot() ...@@ -198,7 +198,7 @@ void ThumbnailProviderTest::testUseEmbeddedOrNot()
KFileItemList list; KFileItemList list;
QUrl url("file://" + QDir(sandBox.mPath).absoluteFilePath("embedded-thumbnail.jpg")); QUrl url("file://" + QDir(sandBox.mPath).absoluteFilePath("embedded-thumbnail.jpg"));
list << KFileItem(KFileItem::Unknown, KFileItem::Unknown, url); list << KFileItem(url);
// Loading a normal thumbnail should bring the white one // Loading a normal thumbnail should bring the white one
{ {
...@@ -239,7 +239,7 @@ void ThumbnailProviderTest::testLoadRemote() ...@@ -239,7 +239,7 @@ void ThumbnailProviderTest::testLoadRemote()
url.setPath(url.path() + '/' + "test.png"); url.setPath(url.path() + '/' + "test.png");
KFileItemList list; KFileItemList list;
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); KFileItem item(url);
list << item; list << item;
ThumbnailProvider provider; ThumbnailProvider provider;
...@@ -263,7 +263,7 @@ void ThumbnailProviderTest::testRemoveItemsWhileGenerating() ...@@ -263,7 +263,7 @@ void ThumbnailProviderTest::testRemoveItemsWhileGenerating()
KFileItemList list; KFileItemList list;
Q_FOREACH(const QFileInfo & info, dir.entryInfoList(QDir::Files)) { Q_FOREACH(const QFileInfo & info, dir.entryInfoList(QDir::Files)) {
QUrl url("file://" + info.absoluteFilePath()); QUrl url("file://" + info.absoluteFilePath());
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); KFileItem item(url);
list << item; list << item;
} }
......
...@@ -52,7 +52,7 @@ void TimeUtilsTest::testBasic_data() ...@@ -52,7 +52,7 @@ void TimeUtilsTest::testBasic_data()
NEW_ROW("date/exif-datetime-only.jpg", QDateTime::fromString("2003-03-25T02:02:21", Qt::ISODate)); NEW_ROW("date/exif-datetime-only.jpg", QDateTime::fromString("2003-03-25T02:02:21", Qt::ISODate));
QUrl url = urlForTestFile("test.png"); QUrl url = urlForTestFile("test.png");
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); KFileItem item(url);
NEW_ROW("test.png", item.time(KFileItem::ModificationTime)); NEW_ROW("test.png", item.time(KFileItem::ModificationTime));
} }
...@@ -62,7 +62,7 @@ void TimeUtilsTest::testBasic() ...@@ -62,7 +62,7 @@ void TimeUtilsTest::testBasic()
QFETCH(QDateTime, expectedDateTime); QFETCH(QDateTime, expectedDateTime);
QDateTime dateTime; QDateTime dateTime;
QUrl url = urlForTestFile(fileName); QUrl url = urlForTestFile(fileName);
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); KFileItem item(url);
dateTime = TimeUtils::dateTimeForFileItem(item); dateTime = TimeUtils::dateTimeForFileItem(item);
QCOMPARE(dateTime, expectedDateTime); QCOMPARE(dateTime, expectedDateTime);
...@@ -76,14 +76,14 @@ void TimeUtilsTest::testCache() ...@@ -76,14 +76,14 @@ void TimeUtilsTest::testCache()
QTemporaryFile tempFile; QTemporaryFile tempFile;
QVERIFY(tempFile.open()); QVERIFY(tempFile.open());
QUrl url = QUrl::fromLocalFile(tempFile.fileName()); QUrl url = QUrl::fromLocalFile(tempFile.fileName());
KFileItem item1(KFileItem::Unknown, KFileItem::Unknown, url); KFileItem item1(url);
QDateTime dateTime1 = TimeUtils::dateTimeForFileItem(item1); QDateTime dateTime1 = TimeUtils::dateTimeForFileItem(item1);
QCOMPARE(dateTime1, item1.time(KFileItem::ModificationTime)); QCOMPARE(dateTime1, item1.time(KFileItem::ModificationTime));
QTest::qWait(1200); QTest::qWait(1200);
touchFile(url.toLocalFile()); touchFile(url.toLocalFile());
KFileItem item2(KFileItem::Unknown, KFileItem::Unknown, url); KFileItem item2(url);
QDateTime dateTime2 = TimeUtils::dateTimeForFileItem(item2); QDateTime dateTime2 = TimeUtils::dateTimeForFileItem(item2);
QVERIFY(dateTime1 != dateTime2); QVERIFY(dateTime1 != dateTime2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment