diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/bineditor/bineditorplugin.cpp | 2 | ||||
-rw-r--r-- | src/plugins/bineditor/bineditorwidget.cpp | 21 | ||||
-rw-r--r-- | src/plugins/bineditor/bineditorwidget.h | 6 |
3 files changed, 15 insertions, 14 deletions
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 1ca61f0bae..2856f44c25 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -234,7 +234,7 @@ public: { QTC_ASSERT(!autoSave, return true); // bineditor does not support autosave - it would be a bit expensive const FilePath &fileNameToUse = filePath.isEmpty() ? this->filePath() : filePath; - if (m_widget->save(errorString, this->filePath().toString(), fileNameToUse.toString())) { + if (m_widget->save(errorString, this->filePath(), fileNameToUse)) { setFilePath(fileNameToUse); return true; } diff --git a/src/plugins/bineditor/bineditorwidget.cpp b/src/plugins/bineditor/bineditorwidget.cpp index 73b822c5c4..d2ea7b28c4 100644 --- a/src/plugins/bineditor/bineditorwidget.cpp +++ b/src/plugins/bineditor/bineditorwidget.cpp @@ -60,6 +60,7 @@ #include <QWheelEvent> using namespace Core; +using namespace Utils; namespace BinEditor { namespace Internal { @@ -402,25 +403,25 @@ bool BinEditorWidget::isReadOnly() const return m_readOnly; } -bool BinEditorWidget::save(QString *errorString, const QString &oldFileName, const QString &newFileName) +bool BinEditorWidget::save(QString *errorString, const FilePath &oldFilePath, const FilePath &newFilePath) { - if (oldFileName != newFileName) { - QString tmpName; + if (oldFilePath != newFilePath) { + FilePath tmpName; { - QTemporaryFile tmp(newFileName + QLatin1String("_XXXXXX.new")); + QTemporaryFile tmp(newFilePath.toString() + QLatin1String("_XXXXXX.new")); if (!tmp.open()) return false; - tmpName = tmp.fileName(); + tmpName = FilePath::fromString(tmp.fileName()); } - if (!QFile::copy(oldFileName, tmpName)) + if (!oldFilePath.copyFile(tmpName)) return false; - if (QFile::exists(newFileName) && !QFile::remove(newFileName)) + if (newFilePath.exists() && !newFilePath.removeFile()) return false; - if (!QFile::rename(tmpName, newFileName)) + if (!tmpName.renameFile(newFilePath)) return false; } - Utils::FileSaver saver(Utils::FilePath::fromString(newFileName), - QIODevice::ReadWrite); // QtBug: WriteOnly truncates. + + FileSaver saver(newFilePath, QIODevice::ReadWrite); // QtBug: WriteOnly truncates. if (!saver.hasError()) { QFile *output = saver.file(); const qint64 size = output->size(); diff --git a/src/plugins/bineditor/bineditorwidget.h b/src/plugins/bineditor/bineditorwidget.h index 0bd217ff66..6a89445442 100644 --- a/src/plugins/bineditor/bineditorwidget.h +++ b/src/plugins/bineditor/bineditorwidget.h @@ -29,15 +29,15 @@ #include "markup.h" #include "bineditorservice.h" +#include <utils/filepath.h> #include <utils/optional.h> +#include <QAbstractScrollArea> #include <QBasicTimer> #include <QMap> #include <QSet> #include <QStack> #include <QString> - -#include <QAbstractScrollArea> #include <QTextDocument> #include <QTextFormat> @@ -78,7 +78,7 @@ public: bool newWindowRequestAllowed() const { return m_canRequestNewWindow; } void updateContents(); - bool save(QString *errorString, const QString &oldFileName, const QString &newFileName); + bool save(QString *errorString, const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath); void zoomF(float delta); |