mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Use QSaveFile also in other places
This commit is contained in:
parent
1a818e5b6c
commit
c9a52e59c3
@ -35,6 +35,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QUrlQuery>
|
||||
#include <QMutexLocker>
|
||||
#include <QSaveFile>
|
||||
|
||||
//#define ADBLOCK_DEBUG
|
||||
|
||||
@ -200,14 +201,13 @@ AdBlockSubscription* AdBlockManager::addSubscription(const QString &title, const
|
||||
|
||||
QByteArray data = QString("Title: %1\nUrl: %2\n[Adblock Plus 1.1.1]").arg(title, url).toLatin1();
|
||||
|
||||
QFile file(filePath);
|
||||
QSaveFile file(filePath);
|
||||
if (!file.open(QFile::WriteOnly | QFile::Truncate)) {
|
||||
qWarning() << "AdBlockManager: Cannot write to file" << filePath;
|
||||
return 0;
|
||||
}
|
||||
|
||||
file.write(data);
|
||||
file.close();
|
||||
file.commit();
|
||||
|
||||
AdBlockSubscription* subscription = new AdBlockSubscription(title, this);
|
||||
subscription->setUrl(QUrl(url));
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include <QFile>
|
||||
#include <QTimer>
|
||||
#include <QNetworkReply>
|
||||
#include <QSaveFile>
|
||||
|
||||
AdBlockSubscription::AdBlockSubscription(const QString &title, QObject* parent)
|
||||
: QObject(parent)
|
||||
@ -179,7 +180,7 @@ void AdBlockSubscription::subscriptionDownloaded()
|
||||
|
||||
bool AdBlockSubscription::saveDownloadedData(const QByteArray &data)
|
||||
{
|
||||
QFile file(m_filePath);
|
||||
QSaveFile file(m_filePath);
|
||||
|
||||
if (!file.open(QFile::ReadWrite | QFile::Truncate)) {
|
||||
qWarning() << "AdBlockSubscription::" << __FUNCTION__ << "Unable to open adblock file for writing:" << m_filePath;
|
||||
@ -189,7 +190,7 @@ bool AdBlockSubscription::saveDownloadedData(const QByteArray &data)
|
||||
// Write subscription header
|
||||
file.write(QString("Title: %1\nUrl: %2\n").arg(title(), url().toString()).toUtf8());
|
||||
file.write(data);
|
||||
file.close();
|
||||
file.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -24,7 +24,7 @@
|
||||
#include "settings.h"
|
||||
#include "qztools.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QSaveFile>
|
||||
#include <QJsonDocument>
|
||||
|
||||
Bookmarks::Bookmarks(QObject* parent)
|
||||
@ -293,14 +293,14 @@ void Bookmarks::saveBookmarks()
|
||||
return;
|
||||
}
|
||||
|
||||
QFile file(DataPaths::currentProfilePath() + QLatin1String("/bookmarks.json"));
|
||||
QSaveFile file(DataPaths::currentProfilePath() + QLatin1String("/bookmarks.json"));
|
||||
|
||||
if (!file.open(QFile::WriteOnly)) {
|
||||
qWarning() << "Bookmarks::saveBookmarks() Error opening bookmarks file for writing!";
|
||||
}
|
||||
|
||||
file.write(data);
|
||||
file.close();
|
||||
file.commit();
|
||||
}
|
||||
|
||||
void Bookmarks::loadBookmarksFromMap(const QVariantMap &map)
|
||||
|
Loading…
Reference in New Issue
Block a user