forked from qt-creator/qt-creator
Utils: filepathify fileutils
Change-Id: Ic9048369f64d793f5f567cdb0c715488fb5a4ff6 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -961,7 +961,7 @@ namespace ADS
|
|||||||
|
|
||||||
QDir tmp;
|
QDir tmp;
|
||||||
tmp.mkpath(fileName.toFileInfo().path());
|
tmp.mkpath(fileName.toFileInfo().path());
|
||||||
Utils::FileSaver fileSaver(fileName.toString(), QIODevice::Text);
|
Utils::FileSaver fileSaver(fileName, QIODevice::Text);
|
||||||
if (!fileSaver.hasError())
|
if (!fileSaver.hasError())
|
||||||
fileSaver.write(data);
|
fileSaver.write(data);
|
||||||
|
|
||||||
|
@@ -370,7 +370,7 @@ QFuture<PluginDumper::QmlTypeDescription> PluginDumper::loadQmlTypeDescription(c
|
|||||||
|
|
||||||
for (const QString &p: paths) {
|
for (const QString &p: paths) {
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
if (!reader.fetch(p, QFile::Text)) {
|
if (!reader.fetch(Utils::FilePath::fromString(p), QFile::Text)) {
|
||||||
result.errors += reader.errorString();
|
result.errors += reader.errorString();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -450,35 +450,41 @@ QByteArray FileUtils::fileId(const FilePath &fileName)
|
|||||||
|
|
||||||
QByteArray FileReader::fetchQrc(const QString &fileName)
|
QByteArray FileReader::fetchQrc(const QString &fileName)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(fileName.startsWith(QLatin1Char(':')), return QByteArray());
|
QTC_ASSERT(fileName.startsWith(':'), return QByteArray());
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
bool ok = file.open(QIODevice::ReadOnly);
|
bool ok = file.open(QIODevice::ReadOnly);
|
||||||
QTC_ASSERT(ok, qWarning() << fileName << "not there!"; return QByteArray());
|
QTC_ASSERT(ok, qWarning() << fileName << "not there!"; return QByteArray());
|
||||||
return file.readAll();
|
return file.readAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileReader::fetch(const QString &fileName, QIODevice::OpenMode mode)
|
bool FileReader::fetch(const FilePath &filePath, QIODevice::OpenMode mode)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!(mode & ~(QIODevice::ReadOnly | QIODevice::Text)), return false);
|
QTC_ASSERT(!(mode & ~(QIODevice::ReadOnly | QIODevice::Text)), return false);
|
||||||
|
|
||||||
QFile file(fileName);
|
if (filePath.needsDevice()) {
|
||||||
|
// TODO: add error handling to FilePath::fileContents
|
||||||
|
m_data = filePath.fileContents();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile file(filePath.toString());
|
||||||
if (!file.open(QIODevice::ReadOnly | mode)) {
|
if (!file.open(QIODevice::ReadOnly | mode)) {
|
||||||
m_errorString = tr("Cannot open %1 for reading: %2").arg(
|
m_errorString = tr("Cannot open %1 for reading: %2").arg(
|
||||||
QDir::toNativeSeparators(fileName), file.errorString());
|
filePath.toUserOutput(), file.errorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_data = file.readAll();
|
m_data = file.readAll();
|
||||||
if (file.error() != QFile::NoError) {
|
if (file.error() != QFile::NoError) {
|
||||||
m_errorString = tr("Cannot read %1: %2").arg(
|
m_errorString = tr("Cannot read %1: %2").arg(
|
||||||
QDir::toNativeSeparators(fileName), file.errorString());
|
filePath.toUserOutput(), file.errorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileReader::fetch(const QString &fileName, QIODevice::OpenMode mode, QString *errorString)
|
bool FileReader::fetch(const FilePath &filePath, QIODevice::OpenMode mode, QString *errorString)
|
||||||
{
|
{
|
||||||
if (fetch(fileName, mode))
|
if (fetch(filePath, mode))
|
||||||
return true;
|
return true;
|
||||||
if (errorString)
|
if (errorString)
|
||||||
*errorString = m_errorString;
|
*errorString = m_errorString;
|
||||||
@@ -486,9 +492,9 @@ bool FileReader::fetch(const QString &fileName, QIODevice::OpenMode mode, QStrin
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef QT_GUI_LIB
|
#ifdef QT_GUI_LIB
|
||||||
bool FileReader::fetch(const QString &fileName, QIODevice::OpenMode mode, QWidget *parent)
|
bool FileReader::fetch(const FilePath &filePath, QIODevice::OpenMode mode, QWidget *parent)
|
||||||
{
|
{
|
||||||
if (fetch(fileName, mode))
|
if (fetch(filePath, mode))
|
||||||
return true;
|
return true;
|
||||||
if (parent)
|
if (parent)
|
||||||
QMessageBox::critical(parent, tr("File Error"), m_errorString);
|
QMessageBox::critical(parent, tr("File Error"), m_errorString);
|
||||||
@@ -545,11 +551,10 @@ bool FileSaverBase::setResult(bool ok)
|
|||||||
{
|
{
|
||||||
if (!ok && !m_hasError) {
|
if (!ok && !m_hasError) {
|
||||||
if (!m_file->errorString().isEmpty()) {
|
if (!m_file->errorString().isEmpty()) {
|
||||||
m_errorString = tr("Cannot write file %1: %2").arg(
|
m_errorString = tr("Cannot write file %1: %2")
|
||||||
QDir::toNativeSeparators(m_fileName), m_file->errorString());
|
.arg(m_filePath.toUserOutput(), m_file->errorString());
|
||||||
} else {
|
} else {
|
||||||
m_errorString = tr("Cannot write file %1. Disk full?").arg(
|
m_errorString = tr("Cannot write file %1. Disk full?").arg(m_filePath.toUserOutput());
|
||||||
QDir::toNativeSeparators(m_fileName));
|
|
||||||
}
|
}
|
||||||
m_hasError = true;
|
m_hasError = true;
|
||||||
}
|
}
|
||||||
@@ -573,9 +578,9 @@ bool FileSaverBase::setResult(QXmlStreamWriter *stream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FileSaver::FileSaver(const QString &filename, QIODevice::OpenMode mode)
|
FileSaver::FileSaver(const FilePath &filePath, QIODevice::OpenMode mode)
|
||||||
{
|
{
|
||||||
m_fileName = filename;
|
m_filePath = filePath;
|
||||||
// Workaround an assert in Qt -- and provide a useful error message, too:
|
// Workaround an assert in Qt -- and provide a useful error message, too:
|
||||||
if (HostOsInfo::isWindowsHost()) {
|
if (HostOsInfo::isWindowsHost()) {
|
||||||
// Taken from: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
// Taken from: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
||||||
@@ -583,24 +588,25 @@ FileSaver::FileSaver(const QString &filename, QIODevice::OpenMode mode)
|
|||||||
= {"CON", "PRN", "AUX", "NUL",
|
= {"CON", "PRN", "AUX", "NUL",
|
||||||
"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
|
"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
|
||||||
"LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"};
|
"LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"};
|
||||||
const QString fn = QFileInfo(filename).baseName().toUpper();
|
const QString fn = filePath.toFileInfo().baseName().toUpper();
|
||||||
if (reservedNames.contains(fn)) {
|
if (reservedNames.contains(fn)) {
|
||||||
m_errorString = tr("%1: Is a reserved filename on Windows. Cannot save.").arg(filename);
|
m_errorString = tr("%1: Is a reserved filename on Windows. Cannot save.")
|
||||||
|
.arg(filePath.toString());
|
||||||
m_hasError = true;
|
m_hasError = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mode & (QIODevice::ReadOnly | QIODevice::Append)) {
|
if (mode & (QIODevice::ReadOnly | QIODevice::Append)) {
|
||||||
m_file.reset(new QFile{filename});
|
m_file.reset(new QFile{filePath.toString()});
|
||||||
m_isSafe = false;
|
m_isSafe = false;
|
||||||
} else {
|
} else {
|
||||||
m_file.reset(new SaveFile{filename});
|
m_file.reset(new SaveFile{filePath.toString()});
|
||||||
m_isSafe = true;
|
m_isSafe = true;
|
||||||
}
|
}
|
||||||
if (!m_file->open(QIODevice::WriteOnly | mode)) {
|
if (!m_file->open(QIODevice::WriteOnly | mode)) {
|
||||||
QString err = QFile::exists(filename) ?
|
QString err = filePath.exists() ?
|
||||||
tr("Cannot overwrite file %1: %2") : tr("Cannot create file %1: %2");
|
tr("Cannot overwrite file %1: %2") : tr("Cannot create file %1: %2");
|
||||||
m_errorString = err.arg(QDir::toNativeSeparators(filename), m_file->errorString());
|
m_errorString = err.arg(filePath.toUserOutput(), m_file->errorString());
|
||||||
m_hasError = true;
|
m_hasError = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -634,14 +640,14 @@ TempFileSaver::TempFileSaver(const QString &templ)
|
|||||||
tempFile->errorString());
|
tempFile->errorString());
|
||||||
m_hasError = true;
|
m_hasError = true;
|
||||||
}
|
}
|
||||||
m_fileName = tempFile->fileName();
|
m_filePath = FilePath::fromString(tempFile->fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
TempFileSaver::~TempFileSaver()
|
TempFileSaver::~TempFileSaver()
|
||||||
{
|
{
|
||||||
m_file.reset();
|
m_file.reset();
|
||||||
if (m_autoRemove)
|
if (m_autoRemove)
|
||||||
QFile::remove(m_fileName);
|
QFile::remove(m_filePath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \class Utils::FilePath
|
/*! \class Utils::FilePath
|
||||||
|
@@ -281,14 +281,14 @@ class QTCREATOR_UTILS_EXPORT FileReader
|
|||||||
Q_DECLARE_TR_FUNCTIONS(Utils::FileUtils) // sic!
|
Q_DECLARE_TR_FUNCTIONS(Utils::FileUtils) // sic!
|
||||||
public:
|
public:
|
||||||
static QByteArray fetchQrc(const QString &fileName); // Only for internal resources
|
static QByteArray fetchQrc(const QString &fileName); // Only for internal resources
|
||||||
bool fetch(const QString &fileName, QIODevice::OpenMode mode = QIODevice::NotOpen); // QIODevice::ReadOnly is implicit
|
bool fetch(const FilePath &filePath, QIODevice::OpenMode mode = QIODevice::NotOpen); // QIODevice::ReadOnly is implicit
|
||||||
bool fetch(const QString &fileName, QIODevice::OpenMode mode, QString *errorString);
|
bool fetch(const FilePath &filePath, QIODevice::OpenMode mode, QString *errorString);
|
||||||
bool fetch(const QString &fileName, QString *errorString)
|
bool fetch(const FilePath &filePath, QString *errorString)
|
||||||
{ return fetch(fileName, QIODevice::NotOpen, errorString); }
|
{ return fetch(filePath, QIODevice::NotOpen, errorString); }
|
||||||
#ifdef QT_GUI_LIB
|
#ifdef QT_GUI_LIB
|
||||||
bool fetch(const QString &fileName, QIODevice::OpenMode mode, QWidget *parent);
|
bool fetch(const FilePath &filePath, QIODevice::OpenMode mode, QWidget *parent);
|
||||||
bool fetch(const QString &fileName, QWidget *parent)
|
bool fetch(const FilePath &filePath, QWidget *parent)
|
||||||
{ return fetch(fileName, QIODevice::NotOpen, parent); }
|
{ return fetch(filePath, QIODevice::NotOpen, parent); }
|
||||||
#endif // QT_GUI_LIB
|
#endif // QT_GUI_LIB
|
||||||
const QByteArray &data() const { return m_data; }
|
const QByteArray &data() const { return m_data; }
|
||||||
const QString &errorString() const { return m_errorString; }
|
const QString &errorString() const { return m_errorString; }
|
||||||
@@ -304,7 +304,7 @@ public:
|
|||||||
FileSaverBase();
|
FileSaverBase();
|
||||||
virtual ~FileSaverBase();
|
virtual ~FileSaverBase();
|
||||||
|
|
||||||
QString fileName() const { return m_fileName; }
|
FilePath filePath() const { return m_filePath; }
|
||||||
bool hasError() const { return m_hasError; }
|
bool hasError() const { return m_hasError; }
|
||||||
QString errorString() const { return m_errorString; }
|
QString errorString() const { return m_errorString; }
|
||||||
virtual bool finalize();
|
virtual bool finalize();
|
||||||
@@ -324,7 +324,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<QFile> m_file;
|
std::unique_ptr<QFile> m_file;
|
||||||
QString m_fileName;
|
FilePath m_filePath;
|
||||||
QString m_errorString;
|
QString m_errorString;
|
||||||
bool m_hasError = false;
|
bool m_hasError = false;
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@ class QTCREATOR_UTILS_EXPORT FileSaver : public FileSaverBase
|
|||||||
Q_DECLARE_TR_FUNCTIONS(Utils::FileUtils) // sic!
|
Q_DECLARE_TR_FUNCTIONS(Utils::FileUtils) // sic!
|
||||||
public:
|
public:
|
||||||
// QIODevice::WriteOnly is implicit
|
// QIODevice::WriteOnly is implicit
|
||||||
explicit FileSaver(const QString &filename, QIODevice::OpenMode mode = QIODevice::NotOpen);
|
explicit FileSaver(const FilePath &filePath, QIODevice::OpenMode mode = QIODevice::NotOpen);
|
||||||
|
|
||||||
bool finalize() override;
|
bool finalize() override;
|
||||||
using FileSaverBase::finalize;
|
using FileSaverBase::finalize;
|
||||||
|
@@ -734,7 +734,7 @@ JsonSchema *JsonSchemaManager::schemaByName(const QString &baseName) const
|
|||||||
JsonSchema *JsonSchemaManager::parseSchema(const QString &schemaFileName) const
|
JsonSchema *JsonSchemaManager::parseSchema(const QString &schemaFileName) const
|
||||||
{
|
{
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (reader.fetch(schemaFileName, QIODevice::Text)) {
|
if (reader.fetch(FilePath::fromString(schemaFileName), QIODevice::Text)) {
|
||||||
const QString &contents = QString::fromUtf8(reader.data());
|
const QString &contents = QString::fromUtf8(reader.data());
|
||||||
JsonValue *json = JsonValue::create(contents, &m_pool);
|
JsonValue *json = JsonValue::create(contents, &m_pool);
|
||||||
if (json && json->kind() == JsonValue::Object)
|
if (json && json->kind() == JsonValue::Object)
|
||||||
|
@@ -465,7 +465,7 @@ bool PersistentSettingsWriter::write(const QVariantMap &data, QString *errorStri
|
|||||||
{
|
{
|
||||||
QDir tmp;
|
QDir tmp;
|
||||||
tmp.mkpath(m_fileName.toFileInfo().path());
|
tmp.mkpath(m_fileName.toFileInfo().path());
|
||||||
FileSaver saver(m_fileName.toString(), QIODevice::Text);
|
FileSaver saver(m_fileName, QIODevice::Text);
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
const Context ctx;
|
const Context ctx;
|
||||||
QXmlStreamWriter w(saver.file());
|
QXmlStreamWriter w(saver.file());
|
||||||
|
@@ -208,7 +208,7 @@ TextFileFormat::ReadResult readTextFile(const FilePath &filePath, const QTextCod
|
|||||||
QByteArray data;
|
QByteArray data;
|
||||||
try {
|
try {
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (!reader.fetch(filePath.toString(), errorString))
|
if (!reader.fetch(filePath, errorString))
|
||||||
return TextFileFormat::ReadIOError;
|
return TextFileFormat::ReadIOError;
|
||||||
data = reader.data();
|
data = reader.data();
|
||||||
} catch (const std::bad_alloc &) {
|
} catch (const std::bad_alloc &) {
|
||||||
@@ -274,7 +274,7 @@ TextFileFormat::ReadResult TextFileFormat::readFileUTF8(const FilePath &filePath
|
|||||||
QByteArray data;
|
QByteArray data;
|
||||||
try {
|
try {
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (!reader.fetch(filePath.toString(), errorString))
|
if (!reader.fetch(filePath, errorString))
|
||||||
return TextFileFormat::ReadIOError;
|
return TextFileFormat::ReadIOError;
|
||||||
data = reader.data();
|
data = reader.data();
|
||||||
} catch (const std::bad_alloc &) {
|
} catch (const std::bad_alloc &) {
|
||||||
@@ -313,7 +313,7 @@ bool TextFileFormat::writeFile(const FilePath &filePath, QString plainText, QStr
|
|||||||
if (lineTerminationMode == CRLFLineTerminator)
|
if (lineTerminationMode == CRLFLineTerminator)
|
||||||
plainText.replace(QLatin1Char('\n'), QLatin1String("\r\n"));
|
plainText.replace(QLatin1Char('\n'), QLatin1String("\r\n"));
|
||||||
|
|
||||||
FileSaver saver(filePath.toString(), fileMode);
|
FileSaver saver(filePath, fileMode);
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
if (hasUtf8Bom && codec->name() == "UTF-8")
|
if (hasUtf8Bom && codec->name() == "UTF-8")
|
||||||
saver.write("\xef\xbb\xbf", 3);
|
saver.write("\xef\xbb\xbf", 3);
|
||||||
|
@@ -856,7 +856,7 @@ QVersionNumber AndroidConfig::ndkVersion(const FilePath &ndkPath) const
|
|||||||
const FilePath ndkReleaseTxtPath = ndkPath.pathAppended("RELEASE.TXT");
|
const FilePath ndkReleaseTxtPath = ndkPath.pathAppended("RELEASE.TXT");
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
QString errorString;
|
QString errorString;
|
||||||
if (reader.fetch(ndkReleaseTxtPath.toString(), &errorString)) {
|
if (reader.fetch(ndkReleaseTxtPath, &errorString)) {
|
||||||
// RELEASE.TXT contains the ndk version in either of the following formats:
|
// RELEASE.TXT contains the ndk version in either of the following formats:
|
||||||
// r6a
|
// r6a
|
||||||
// r10e (64 bit)
|
// r10e (64 bit)
|
||||||
|
@@ -692,7 +692,7 @@ void TestResultsPane::onSaveWholeTriggered()
|
|||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Utils::FileSaver saver(fileName, QIODevice::Text);
|
Utils::FileSaver saver(Utils::FilePath::fromString(fileName), QIODevice::Text);
|
||||||
if (!saver.write(getWholeOutput().toUtf8()) || !saver.finalize()) {
|
if (!saver.write(getWholeOutput().toUtf8()) || !saver.finalize()) {
|
||||||
QMessageBox::critical(ICore::dialogParent(), tr("Error"),
|
QMessageBox::critical(ICore::dialogParent(), tr("Error"),
|
||||||
tr("Failed to write \"%1\".\n\n%2").arg(fileName)
|
tr("Failed to write \"%1\".\n\n%2").arg(fileName)
|
||||||
|
@@ -654,7 +654,7 @@ void BazaarPluginPrivate::showCommitWidget(const QList<VcsBaseClient::StatusItem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEditor *editor = EditorManager::openEditor(saver.fileName(), COMMIT_ID);
|
IEditor *editor = EditorManager::openEditor(saver.filePath().toString(), COMMIT_ID);
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
VcsOutputWindow::appendError(tr("Unable to create an editor for the commit."));
|
VcsOutputWindow::appendError(tr("Unable to create an editor for the commit."));
|
||||||
return;
|
return;
|
||||||
|
@@ -246,16 +246,16 @@ void AbstractSettings::save()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FileSaver saver(fi.absoluteFilePath());
|
Utils::FileSaver saver(Utils::FilePath::fromUserInput(fi.absoluteFilePath()));
|
||||||
if (saver.hasError()) {
|
if (saver.hasError()) {
|
||||||
BeautifierPlugin::showError(tr("Cannot open file \"%1\": %2.")
|
BeautifierPlugin::showError(tr("Cannot open file \"%1\": %2.")
|
||||||
.arg(saver.fileName())
|
.arg(saver.filePath().toUserOutput())
|
||||||
.arg(saver.errorString()));
|
.arg(saver.errorString()));
|
||||||
} else {
|
} else {
|
||||||
saver.write(iStyles.value().toLocal8Bit());
|
saver.write(iStyles.value().toLocal8Bit());
|
||||||
if (!saver.finalize()) {
|
if (!saver.finalize()) {
|
||||||
BeautifierPlugin::showError(tr("Cannot save file \"%1\": %2.")
|
BeautifierPlugin::showError(tr("Cannot save file \"%1\": %2.")
|
||||||
.arg(saver.fileName())
|
.arg(saver.filePath().toUserOutput())
|
||||||
.arg(saver.errorString()));
|
.arg(saver.errorString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -419,7 +419,8 @@ bool BinEditorWidget::save(QString *errorString, const QString &oldFileName, con
|
|||||||
if (!QFile::rename(tmpName, newFileName))
|
if (!QFile::rename(tmpName, newFileName))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Utils::FileSaver saver(newFileName, QIODevice::ReadWrite); // QtBug: WriteOnly truncates.
|
Utils::FileSaver saver(Utils::FilePath::fromString(newFileName),
|
||||||
|
QIODevice::ReadWrite); // QtBug: WriteOnly truncates.
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
QFile *output = saver.file();
|
QFile *output = saver.file();
|
||||||
const qint64 size = output->size();
|
const qint64 size = output->size();
|
||||||
|
@@ -136,7 +136,7 @@ private:
|
|||||||
|
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
// Do not use QIODevice::Text as we have to deal with byte offsets.
|
// Do not use QIODevice::Text as we have to deal with byte offsets.
|
||||||
if (reader.fetch(filePath, QIODevice::ReadOnly))
|
if (reader.fetch(Utils::FilePath::fromString(filePath), QIODevice::ReadOnly))
|
||||||
return reader.data();
|
return reader.data();
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@@ -1437,7 +1437,7 @@ void ClearCasePluginPrivate::startCheckIn(const QString &workingDir, const QStri
|
|||||||
VcsOutputWindow::appendError(saver.errorString());
|
VcsOutputWindow::appendError(saver.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_checkInMessageFileName = saver.fileName();
|
m_checkInMessageFileName = saver.filePath().toString();
|
||||||
m_checkInView = workingDir;
|
m_checkInView = workingDir;
|
||||||
// Create a submit editor and set file list
|
// Create a submit editor and set file list
|
||||||
ClearCaseSubmitEditor *editor = openClearCaseSubmitEditor(m_checkInMessageFileName, m_viewData.isUcm);
|
ClearCaseSubmitEditor *editor = openClearCaseSubmitEditor(m_checkInMessageFileName, m_viewData.isUcm);
|
||||||
@@ -2603,7 +2603,7 @@ void ClearCasePlugin::testLogResolving()
|
|||||||
void ClearCasePlugin::initTestCase()
|
void ClearCasePlugin::initTestCase()
|
||||||
{
|
{
|
||||||
dd->m_tempFile = QDir::currentPath() + QLatin1String("/cc_file.cpp");
|
dd->m_tempFile = QDir::currentPath() + QLatin1String("/cc_file.cpp");
|
||||||
FileSaver srcSaver(dd->m_tempFile);
|
FileSaver srcSaver(Utils::FilePath::fromString(dd->m_tempFile));
|
||||||
srcSaver.write(QByteArray());
|
srcSaver.write(QByteArray());
|
||||||
srcSaver.finalize();
|
srcSaver.finalize();
|
||||||
}
|
}
|
||||||
@@ -2695,7 +2695,7 @@ public:
|
|||||||
ClearCasePluginPrivate::instance()->setFakeCleartool(true);
|
ClearCasePluginPrivate::instance()->setFakeCleartool(true);
|
||||||
VcsManager::clearVersionControlCache();
|
VcsManager::clearVersionControlCache();
|
||||||
|
|
||||||
FileSaver srcSaver(fileName);
|
FileSaver srcSaver(Utils::FilePath::fromString(fileName));
|
||||||
srcSaver.write(QByteArray());
|
srcSaver.write(QByteArray());
|
||||||
srcSaver.finalize();
|
srcSaver.finalize();
|
||||||
m_editor = EditorManager::openEditor(fileName);
|
m_editor = EditorManager::openEditor(fileName);
|
||||||
|
@@ -275,7 +275,7 @@ public:
|
|||||||
TempFile(const QString &fileName)
|
TempFile(const QString &fileName)
|
||||||
: m_fileName(fileName)
|
: m_fileName(fileName)
|
||||||
{
|
{
|
||||||
Utils::FileSaver srcSaver(fileName);
|
Utils::FileSaver srcSaver(Utils::FilePath::fromString(fileName));
|
||||||
srcSaver.write(QByteArray());
|
srcSaver.write(QByteArray());
|
||||||
srcSaver.finalize();
|
srcSaver.finalize();
|
||||||
|
|
||||||
|
@@ -130,7 +130,7 @@ QMap<QString, QList<QKeySequence>> CommandsFile::importCommands() const
|
|||||||
|
|
||||||
bool CommandsFile::exportCommands(const QList<ShortcutItem *> &items)
|
bool CommandsFile::exportCommands(const QList<ShortcutItem *> &items)
|
||||||
{
|
{
|
||||||
Utils::FileSaver saver(m_filename, QIODevice::Text);
|
Utils::FileSaver saver(Utils::FilePath::fromString(m_filename), QIODevice::Text);
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
const Context ctx;
|
const Context ctx;
|
||||||
QXmlStreamWriter w(saver.file());
|
QXmlStreamWriter w(saver.file());
|
||||||
|
@@ -474,7 +474,7 @@ ExternalTool * ExternalTool::createFromFile(const QString &fileName, QString *er
|
|||||||
{
|
{
|
||||||
QString absFileName = QFileInfo(fileName).absoluteFilePath();
|
QString absFileName = QFileInfo(fileName).absoluteFilePath();
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (!reader.fetch(absFileName, errorMessage))
|
if (!reader.fetch(FilePath::fromString(absFileName), errorMessage))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
ExternalTool *tool = ExternalTool::createFromXml(reader.data(), errorMessage, locale);
|
ExternalTool *tool = ExternalTool::createFromXml(reader.data(), errorMessage, locale);
|
||||||
if (!tool)
|
if (!tool)
|
||||||
@@ -500,7 +500,7 @@ bool ExternalTool::save(QString *errorMessage) const
|
|||||||
{
|
{
|
||||||
if (m_fileName.isEmpty())
|
if (m_fileName.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
FileSaver saver(m_fileName);
|
FileSaver saver(FilePath::fromString(m_fileName));
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
QXmlStreamWriter out(saver.file());
|
QXmlStreamWriter out(saver.file());
|
||||||
out.setAutoFormatting(true);
|
out.setAutoFormatting(true);
|
||||||
|
@@ -157,7 +157,7 @@ bool GeneratedFile::write(QString *errorMessage) const
|
|||||||
// Write out
|
// Write out
|
||||||
if (isBinary()) {
|
if (isBinary()) {
|
||||||
QIODevice::OpenMode flags = QIODevice::WriteOnly | QIODevice::Truncate;
|
QIODevice::OpenMode flags = QIODevice::WriteOnly | QIODevice::Truncate;
|
||||||
Utils::FileSaver saver(m_d->path, flags);
|
Utils::FileSaver saver(FilePath::fromString(m_d->path), flags);
|
||||||
saver.write(m_d->contents);
|
saver.write(m_d->contents);
|
||||||
return saver.finalize(errorMessage);
|
return saver.finalize(errorMessage);
|
||||||
}
|
}
|
||||||
|
@@ -400,7 +400,7 @@ void CodePasterPluginPrivate::finishFetch(const QString &titleDescription,
|
|||||||
MessageManager::writeDisrupting(saver.errorString());
|
MessageManager::writeDisrupting(saver.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const QString fileName = saver.fileName();
|
const QString fileName = saver.filePath().toString();
|
||||||
m_fetchedSnippets.push_back(fileName);
|
m_fetchedSnippets.push_back(fileName);
|
||||||
// Open editor with title.
|
// Open editor with title.
|
||||||
IEditor *editor = EditorManager::openEditor(fileName);
|
IEditor *editor = EditorManager::openEditor(fileName);
|
||||||
|
@@ -209,6 +209,6 @@ void FileShareProtocol::paste(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::MessageManager::writeSilently(tr("Pasted: %1").arg(saver.fileName()));
|
Core::MessageManager::writeSilently(tr("Pasted: %1").arg(saver.filePath().toUserOutput()));
|
||||||
}
|
}
|
||||||
} // namespace CodePaster
|
} // namespace CodePaster
|
||||||
|
@@ -85,7 +85,7 @@ static QString makeResourcePath(const QStringList &prefixList, const QString &fi
|
|||||||
static QString findResourceInFile(const QString &resName, const QString &filePathName)
|
static QString findResourceInFile(const QString &resName, const QString &filePathName)
|
||||||
{
|
{
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
if (!reader.fetch(filePathName))
|
if (!reader.fetch(Utils::FilePath::fromString(filePathName)))
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
const QByteArray contents = reader.data();
|
const QByteArray contents = reader.data();
|
||||||
|
@@ -369,7 +369,7 @@ void CppFileSettingsWidget::slotEdit()
|
|||||||
path = QFileDialog::getSaveFileName(this, tr("Choose Location for New License Template File"));
|
path = QFileDialog::getSaveFileName(this, tr("Choose Location for New License Template File"));
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
return;
|
return;
|
||||||
Utils::FileSaver saver(path, QIODevice::Text);
|
Utils::FileSaver saver(Utils::FilePath::fromString(path), QIODevice::Text);
|
||||||
saver.write(tr(licenseTemplateTemplate).arg(Core::Constants::IDE_DISPLAY_NAME).toUtf8());
|
saver.write(tr(licenseTemplateTemplate).arg(Core::Constants::IDE_DISPLAY_NAME).toUtf8());
|
||||||
if (!saver.finalize(this))
|
if (!saver.finalize(this))
|
||||||
return;
|
return;
|
||||||
|
@@ -139,7 +139,7 @@ public:
|
|||||||
bool readContents(QByteArray *contents)
|
bool readContents(QByteArray *contents)
|
||||||
{
|
{
|
||||||
Utils::FileReader fileReader;
|
Utils::FileReader fileReader;
|
||||||
const bool isFetchOk = fileReader.fetch(m_filePath);
|
const bool isFetchOk = fileReader.fetch(Utils::FilePath::fromString(m_filePath));
|
||||||
if (isFetchOk) {
|
if (isFetchOk) {
|
||||||
m_originalFileContents = fileReader.data();
|
m_originalFileContents = fileReader.data();
|
||||||
if (contents)
|
if (contents)
|
||||||
|
@@ -242,7 +242,7 @@ bool TestCase::waitUntilProjectIsFullyOpened(Project *project, int timeOutInMs)
|
|||||||
|
|
||||||
bool TestCase::writeFile(const QString &filePath, const QByteArray &contents)
|
bool TestCase::writeFile(const QString &filePath, const QByteArray &contents)
|
||||||
{
|
{
|
||||||
Utils::FileSaver saver(filePath);
|
Utils::FileSaver saver(Utils::FilePath::fromString(filePath));
|
||||||
if (!saver.write(contents) || !saver.finalize()) {
|
if (!saver.write(contents) || !saver.finalize()) {
|
||||||
const QString warning = QLatin1String("Failed to write file to disk: ") + filePath;
|
const QString warning = QLatin1String("Failed to write file to disk: ") + filePath;
|
||||||
QWARN(qPrintable(warning));
|
QWARN(qPrintable(warning));
|
||||||
|
@@ -1010,7 +1010,7 @@ void CvsPluginPrivate::startCommit(const QString &workingDir, const QString &fil
|
|||||||
VcsOutputWindow::appendError(saver.errorString());
|
VcsOutputWindow::appendError(saver.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_commitMessageFileName = saver.fileName();
|
m_commitMessageFileName = saver.filePath().toString();
|
||||||
// Create a submit editor and set file list
|
// Create a submit editor and set file list
|
||||||
CvsSubmitEditor *editor = openCVSSubmitEditor(m_commitMessageFileName);
|
CvsSubmitEditor *editor = openCVSSubmitEditor(m_commitMessageFileName);
|
||||||
setSubmitEditor(editor);
|
setSubmitEditor(editor);
|
||||||
|
@@ -2453,7 +2453,7 @@ static CPlusPlus::Document::Ptr getParsedDocument(const QString &fileName,
|
|||||||
src = workingCopy.source(fileName);
|
src = workingCopy.source(fileName);
|
||||||
} else {
|
} else {
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (reader.fetch(fileName)) // ### FIXME error reporting
|
if (reader.fetch(Utils::FilePath::fromString(fileName))) // ### FIXME error reporting
|
||||||
src = QString::fromLocal8Bit(reader.data()).toUtf8();
|
src = QString::fromLocal8Bit(reader.data()).toUtf8();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1942,7 +1942,7 @@ void DebuggerPluginPrivate::dumpLog()
|
|||||||
tr("Save Debugger Log"), Utils::TemporaryDirectory::masterDirectoryPath());
|
tr("Save Debugger Log"), Utils::TemporaryDirectory::masterDirectoryPath());
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
return;
|
return;
|
||||||
FileSaver saver(fileName);
|
FileSaver saver(Utils::FilePath::fromUserInput(fileName));
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
QTextStream ts(saver.file());
|
QTextStream ts(saver.file());
|
||||||
ts << logWindow->inputContents();
|
ts << logWindow->inputContents();
|
||||||
|
@@ -95,7 +95,7 @@ static bool writeLogContents(const QPlainTextEdit *editor, QWidget *parent)
|
|||||||
const QString fileName = QFileDialog::getSaveFileName(parent, LogWindow::tr("Log File"));
|
const QString fileName = QFileDialog::getSaveFileName(parent, LogWindow::tr("Log File"));
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
break;
|
break;
|
||||||
Utils::FileSaver saver(fileName, QIODevice::Text);
|
Utils::FileSaver saver(Utils::FilePath::fromString(fileName), QIODevice::Text);
|
||||||
saver.write(editor->toPlainText().toUtf8());
|
saver.write(editor->toPlainText().toUtf8());
|
||||||
if (saver.finalize(parent))
|
if (saver.finalize(parent))
|
||||||
success = true;
|
success = true;
|
||||||
|
@@ -409,7 +409,7 @@ static Document::Ptr getParsedDocument(const QString &fileName,
|
|||||||
src = workingCopy.source(fileName);
|
src = workingCopy.source(fileName);
|
||||||
} else {
|
} else {
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
if (reader.fetch(fileName)) // ### FIXME error reporting
|
if (reader.fetch(Utils::FilePath::fromString(fileName))) // ### FIXME error reporting
|
||||||
src = QString::fromLocal8Bit(reader.data()).toUtf8();
|
src = QString::fromLocal8Bit(reader.data()).toUtf8();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -185,7 +185,8 @@ private:
|
|||||||
|
|
||||||
static bool writeFile(const QString &filePath, const QString &contents)
|
static bool writeFile(const QString &filePath, const QString &contents)
|
||||||
{
|
{
|
||||||
Utils::FileSaver saver(filePath, QIODevice::Text | QIODevice::WriteOnly);
|
Utils::FileSaver saver(Utils::FilePath::fromString(filePath),
|
||||||
|
QIODevice::Text | QIODevice::WriteOnly);
|
||||||
return saver.write(contents.toUtf8()) && saver.finalize();
|
return saver.write(contents.toUtf8()) && saver.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +304,7 @@ bool GenericBuildSystem::saveRawList(const QStringList &rawList, const QString &
|
|||||||
{
|
{
|
||||||
FileChangeBlocker changeGuard(fileName);
|
FileChangeBlocker changeGuard(fileName);
|
||||||
// Make sure we can open the file for writing
|
// Make sure we can open the file for writing
|
||||||
Utils::FileSaver saver(fileName, QIODevice::Text);
|
Utils::FileSaver saver(Utils::FilePath::fromString(fileName), QIODevice::Text);
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
QTextStream stream(saver.file());
|
QTextStream stream(saver.file());
|
||||||
for (const QString &filePath : rawList)
|
for (const QString &filePath : rawList)
|
||||||
|
@@ -154,7 +154,8 @@ bool AuthenticationDialog::setupCredentials()
|
|||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
out << "machine " << m_server->host << " login " << user << " password " << password << '\n';
|
out << "machine " << m_server->host << " login " << user << " password " << password << '\n';
|
||||||
Utils::FileSaver saver(m_netrcFileName, QFile::WriteOnly | QFile::Truncate | QFile::Text);
|
Utils::FileSaver saver(Utils::FilePath::fromString(m_netrcFileName),
|
||||||
|
QFile::WriteOnly | QFile::Truncate | QFile::Text);
|
||||||
saver.write(netrcContents.toUtf8());
|
saver.write(netrcContents.toUtf8());
|
||||||
return saver.finalize();
|
return saver.finalize();
|
||||||
}
|
}
|
||||||
|
@@ -2855,7 +2855,7 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
|||||||
if (templateFileInfo.isRelative())
|
if (templateFileInfo.isRelative())
|
||||||
templateFilename = repoDirectory + '/' + templateFilename;
|
templateFilename = repoDirectory + '/' + templateFilename;
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (!reader.fetch(templateFilename, QIODevice::Text, errorMessage))
|
if (!reader.fetch(Utils::FilePath::fromString(templateFilename), QIODevice::Text, errorMessage))
|
||||||
return false;
|
return false;
|
||||||
*commitTemplate = QString::fromLocal8Bit(reader.data());
|
*commitTemplate = QString::fromLocal8Bit(reader.data());
|
||||||
}
|
}
|
||||||
|
@@ -1354,7 +1354,7 @@ void GitPluginPrivate::startCommit(CommitType commitType)
|
|||||||
VcsOutputWindow::appendError(saver.errorString());
|
VcsOutputWindow::appendError(saver.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_commitMessageFileName = saver.fileName();
|
m_commitMessageFileName = saver.filePath().toString();
|
||||||
openSubmitEditor(m_commitMessageFileName, data);
|
openSubmitEditor(m_commitMessageFileName, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -248,7 +248,7 @@ void GeneralSettingsPage::exportBookmarks()
|
|||||||
if (!fileName.endsWith(suffix))
|
if (!fileName.endsWith(suffix))
|
||||||
fileName.append(suffix);
|
fileName.append(suffix);
|
||||||
|
|
||||||
Utils::FileSaver saver(fileName);
|
Utils::FileSaver saver(Utils::FilePath::fromString(fileName));
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
XbelWriter writer(LocalHelpManager::bookmarkManager().treeBookmarkModel());
|
XbelWriter writer(LocalHelpManager::bookmarkManager().treeBookmarkModel());
|
||||||
writer.writeToFile(saver.file());
|
writer.writeToFile(saver.file());
|
||||||
|
@@ -164,7 +164,7 @@ bool HelpViewer::launchWithExternalApp(const QUrl &url)
|
|||||||
if (!saver.hasError())
|
if (!saver.hasError())
|
||||||
saver.write(helpEngine.fileData(resolvedUrl));
|
saver.write(helpEngine.fileData(resolvedUrl));
|
||||||
if (saver.finalize(Core::ICore::dialogParent()))
|
if (saver.finalize(Core::ICore::dialogParent()))
|
||||||
QDesktopServices::openUrl(QUrl(saver.fileName()));
|
QDesktopServices::openUrl(QUrl(saver.filePath().toString()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -344,7 +344,7 @@ void LspLogWidget::saveLog()
|
|||||||
const QString fileName = QFileDialog::getSaveFileName(this, LspInspector::tr("Log File"));
|
const QString fileName = QFileDialog::getSaveFileName(this, LspInspector::tr("Log File"));
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
return;
|
return;
|
||||||
Utils::FileSaver saver(fileName, QIODevice::Text);
|
Utils::FileSaver saver(Utils::FilePath::fromString(fileName), QIODevice::Text);
|
||||||
saver.write(contents.toUtf8());
|
saver.write(contents.toUtf8());
|
||||||
if (!saver.finalize(this))
|
if (!saver.finalize(this))
|
||||||
saveLog();
|
saveLog();
|
||||||
|
@@ -138,7 +138,7 @@ bool Macro::loadHeader(const QString &fileName)
|
|||||||
|
|
||||||
bool Macro::save(const QString &fileName, QWidget *parent)
|
bool Macro::save(const QString &fileName, QWidget *parent)
|
||||||
{
|
{
|
||||||
Utils::FileSaver saver(fileName);
|
Utils::FileSaver saver(Utils::FilePath::fromString(fileName));
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
QDataStream stream(saver.file());
|
QDataStream stream(saver.file());
|
||||||
stream << d->version;
|
stream << d->version;
|
||||||
|
@@ -141,7 +141,7 @@ bool MercurialClient::synchronousClone(const QString &workingDir,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// By now, there is no hgrc file -> create it
|
// By now, there is no hgrc file -> create it
|
||||||
FileSaver saver(workingDirectory.path() + QLatin1String("/.hg/hgrc"));
|
FileSaver saver(Utils::FilePath::fromString(workingDirectory.path() + "/.hg/hgrc"));
|
||||||
const QString hgrc = QLatin1String("[paths]\ndefault = ") + dstLocation + QLatin1Char('\n');
|
const QString hgrc = QLatin1String("[paths]\ndefault = ") + dstLocation + QLatin1Char('\n');
|
||||||
saver.write(hgrc.toUtf8());
|
saver.write(hgrc.toUtf8());
|
||||||
if (!saver.finalize()) {
|
if (!saver.finalize()) {
|
||||||
|
@@ -643,7 +643,7 @@ void MercurialPluginPrivate::showCommitWidget(const QList<VcsBaseClient::StatusI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IEditor *editor = Core::EditorManager::openEditor(saver.fileName(),
|
Core::IEditor *editor = Core::EditorManager::openEditor(saver.filePath().toString(),
|
||||||
Constants::COMMIT_ID);
|
Constants::COMMIT_ID);
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
VcsOutputWindow::appendError(tr("Unable to create an editor for the commit."));
|
VcsOutputWindow::appendError(tr("Unable to create an editor for the commit."));
|
||||||
|
@@ -775,7 +775,7 @@ void PerforcePluginPrivate::startSubmitProject()
|
|||||||
cleanCommitMessageFile();
|
cleanCommitMessageFile();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_commitMessageFileName = saver.fileName();
|
m_commitMessageFileName = saver.filePath().toString();
|
||||||
|
|
||||||
args.clear();
|
args.clear();
|
||||||
args << QLatin1String("files");
|
args << QLatin1String("files");
|
||||||
@@ -1385,7 +1385,7 @@ PerforceResponse PerforcePluginPrivate::runP4Cmd(const QString &workingDir,
|
|||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
QSharedPointer<TempFileSaver> tempFile = createTemporaryArgumentFile(extraArgs, &errorMessage);
|
QSharedPointer<TempFileSaver> tempFile = createTemporaryArgumentFile(extraArgs, &errorMessage);
|
||||||
if (!tempFile.isNull()) {
|
if (!tempFile.isNull()) {
|
||||||
actualArgs << QLatin1String("-x") << tempFile->fileName();
|
actualArgs << QLatin1String("-x") << tempFile->filePath().toString();
|
||||||
} else if (!errorMessage.isEmpty()) {
|
} else if (!errorMessage.isEmpty()) {
|
||||||
PerforceResponse tempFailResponse;
|
PerforceResponse tempFailResponse;
|
||||||
tempFailResponse.error = true;
|
tempFailResponse.error = true;
|
||||||
@@ -1598,7 +1598,7 @@ bool PerforcePluginPrivate::submitEditorAboutToClose()
|
|||||||
}
|
}
|
||||||
// Pipe file into p4 submit -i
|
// Pipe file into p4 submit -i
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (!reader.fetch(m_commitMessageFileName, QIODevice::Text)) {
|
if (!reader.fetch(Utils::FilePath::fromString(m_commitMessageFileName), QIODevice::Text)) {
|
||||||
VcsOutputWindow::appendError(reader.errorString());
|
VcsOutputWindow::appendError(reader.errorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -198,7 +198,7 @@ static inline bool createFile(CustomWizardFile cwFile,
|
|||||||
const QFile::OpenMode openMode
|
const QFile::OpenMode openMode
|
||||||
= cwFile.binary ? QIODevice::ReadOnly : (QIODevice::ReadOnly|QIODevice::Text);
|
= cwFile.binary ? QIODevice::ReadOnly : (QIODevice::ReadOnly|QIODevice::Text);
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
if (!reader.fetch(sourcePath, openMode, errorMessage))
|
if (!reader.fetch(Utils::FilePath::fromString(sourcePath), openMode, errorMessage))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Core::GeneratedFile generatedFile;
|
Core::GeneratedFile generatedFile;
|
||||||
|
@@ -99,7 +99,7 @@ Core::GeneratedFile JsonWizardFileGenerator::generateFile(const File &file,
|
|||||||
QIODevice::ReadOnly : (QIODevice::ReadOnly|QIODevice::Text);
|
QIODevice::ReadOnly : (QIODevice::ReadOnly|QIODevice::Text);
|
||||||
|
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
if (!reader.fetch(file.source, openMode, errorMessage))
|
if (!reader.fetch(Utils::FilePath::fromString(file.source), openMode, errorMessage))
|
||||||
return Core::GeneratedFile();
|
return Core::GeneratedFile();
|
||||||
|
|
||||||
// Generate file information:
|
// Generate file information:
|
||||||
|
@@ -620,7 +620,7 @@ Macros MsvcToolChain::msvcPredefinedMacros(const QStringList &cxxflags,
|
|||||||
|
|
||||||
if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID)
|
if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID)
|
||||||
arguments << QLatin1String("/TC");
|
arguments << QLatin1String("/TC");
|
||||||
arguments << toProcess << QLatin1String("/EP") << QDir::toNativeSeparators(saver.fileName());
|
arguments << toProcess << QLatin1String("/EP") << saver.filePath().toUserOutput();
|
||||||
cpp.runBlocking({binary, arguments});
|
cpp.runBlocking({binary, arguments});
|
||||||
if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0)
|
if (cpp.result() != QtcProcess::Finished || cpp.exitCode() != 0)
|
||||||
return predefinedMacros;
|
return predefinedMacros;
|
||||||
@@ -2016,7 +2016,7 @@ Utils::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils:
|
|||||||
if (cmdPath.isEmpty())
|
if (cmdPath.isEmpty())
|
||||||
cmdPath = env.searchInPath(QLatin1String("cmd.exe"));
|
cmdPath = env.searchInPath(QLatin1String("cmd.exe"));
|
||||||
// Windows SDK setup scripts require command line switches for environment expansion.
|
// Windows SDK setup scripts require command line switches for environment expansion.
|
||||||
CommandLine cmd(cmdPath, {"/E:ON", "/V:ON", "/c", QDir::toNativeSeparators(saver.fileName())});
|
CommandLine cmd(cmdPath, {"/E:ON", "/V:ON", "/c", saver.filePath().toUserOutput()});
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "readEnvironmentSetting: " << call << cmd.toUserOutput()
|
qDebug() << "readEnvironmentSetting: " << call << cmd.toUserOutput()
|
||||||
<< " Env: " << runEnv.size();
|
<< " Env: " << runEnv.size();
|
||||||
|
@@ -295,7 +295,7 @@ bool PythonBuildSystem::saveRawList(const QStringList &rawList, const QString &f
|
|||||||
|
|
||||||
// New project file
|
// New project file
|
||||||
if (fileName.endsWith(".pyproject")) {
|
if (fileName.endsWith(".pyproject")) {
|
||||||
FileSaver saver(fileName, QIODevice::ReadOnly | QIODevice::Text);
|
FileSaver saver(FilePath::fromString(fileName), QIODevice::ReadOnly | QIODevice::Text);
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
QString content = QTextStream(saver.file()).readAll();
|
QString content = QTextStream(saver.file()).readAll();
|
||||||
if (saver.finalize(ICore::dialogParent())) {
|
if (saver.finalize(ICore::dialogParent())) {
|
||||||
@@ -306,7 +306,7 @@ bool PythonBuildSystem::saveRawList(const QStringList &rawList, const QString &f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // Old project file
|
} else { // Old project file
|
||||||
FileSaver saver(fileName, QIODevice::WriteOnly | QIODevice::Text);
|
FileSaver saver(FilePath::fromString(fileName), QIODevice::WriteOnly | QIODevice::Text);
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
QTextStream stream(saver.file());
|
QTextStream stream(saver.file());
|
||||||
for (const QString &filePath : rawList)
|
for (const QString &filePath : rawList)
|
||||||
|
@@ -55,7 +55,9 @@ struct ProjectContents {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Create a binary icon file
|
// Create a binary icon file
|
||||||
static inline Core::GeneratedFile generateIconFile(const QString &source, const QString &target, QString *errorMessage)
|
static inline Core::GeneratedFile generateIconFile(const Utils::FilePath &source,
|
||||||
|
const QString &target,
|
||||||
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
// Read out source
|
// Read out source
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
@@ -270,7 +272,9 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
|||||||
const QFileInfo qfi(icon);
|
const QFileInfo qfi(icon);
|
||||||
if (qfi.dir() != slashLessBaseDir) {
|
if (qfi.dir() != slashLessBaseDir) {
|
||||||
const QString newIcon = baseDir + qfi.fileName();
|
const QString newIcon = baseDir + qfi.fileName();
|
||||||
const Core::GeneratedFile iconFile = generateIconFile(icon, newIcon, errorMessage);
|
const Core::GeneratedFile iconFile = generateIconFile(Utils::FilePath::fromFileInfo(qfi),
|
||||||
|
newIcon,
|
||||||
|
errorMessage);
|
||||||
if (iconFile.path().isEmpty())
|
if (iconFile.path().isEmpty())
|
||||||
return QList<Core::GeneratedFile>();
|
return QList<Core::GeneratedFile>();
|
||||||
rc.push_back(iconFile);
|
rc.push_back(iconFile);
|
||||||
@@ -311,7 +315,7 @@ QString PluginGenerator::processTemplate(const QString &tmpl,
|
|||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
if (!reader.fetch(tmpl, errorMessage))
|
if (!reader.fetch(Utils::FilePath::fromString(tmpl), errorMessage))
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
|
|
||||||
|
@@ -276,9 +276,9 @@ void AssetExporter::preprocessQmlFile(const Utils::FilePath &path)
|
|||||||
// Meanwhile cache the Component UUIDs as well
|
// Meanwhile cache the Component UUIDs as well
|
||||||
std::unique_ptr<Model> model(Model::create("Item", 2, 7));
|
std::unique_ptr<Model> model(Model::create("Item", 2, 7));
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
if (!reader.fetch(path.toString())) {
|
if (!reader.fetch(path)) {
|
||||||
ExportNotification::addError(tr("Cannot preprocess file: %1. Error %2")
|
ExportNotification::addError(tr("Cannot preprocess file: %1. Error %2")
|
||||||
.arg(path.toString()).arg(reader.errorString()));
|
.arg(path.toUserOutput()).arg(reader.errorString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,11 +301,11 @@ void AssetExporter::preprocessQmlFile(const Utils::FilePath &path)
|
|||||||
// Some UUIDs were assigned. Rewrite the file.
|
// Some UUIDs were assigned. Rewrite the file.
|
||||||
rewriterView->writeAuxiliaryData();
|
rewriterView->writeAuxiliaryData();
|
||||||
const QByteArray data = textEdit.toPlainText().toUtf8();
|
const QByteArray data = textEdit.toPlainText().toUtf8();
|
||||||
Utils::FileSaver saver(path.toString(), QIODevice::Text);
|
Utils::FileSaver saver(path, QIODevice::Text);
|
||||||
saver.write(data);
|
saver.write(data);
|
||||||
if (!saver.finalize()) {
|
if (!saver.finalize()) {
|
||||||
ExportNotification::addError(tr("Cannot update %1.\n%2")
|
ExportNotification::addError(tr("Cannot update %1.\n%2")
|
||||||
.arg(path.toString()).arg(saver.errorString()));
|
.arg(path.toUserOutput()).arg(saver.errorString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,7 +414,7 @@ void AssetExporter::writeMetadata() const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FileSaver saver(path.toString(), QIODevice::Text);
|
Utils::FileSaver saver(path, QIODevice::Text);
|
||||||
saver.write(doc.toJson(QJsonDocument::Indented));
|
saver.write(doc.toJson(QJsonDocument::Indented));
|
||||||
if (!saver.finalize()) {
|
if (!saver.finalize()) {
|
||||||
ExportNotification::addError(tr("Writing metadata failed. %1").
|
ExportNotification::addError(tr("Writing metadata failed. %1").
|
||||||
|
@@ -1458,7 +1458,7 @@ void styleMerge(const SelectionContext &selectionContext, const QString &templat
|
|||||||
QPlainTextEdit textEditTemplate;
|
QPlainTextEdit textEditTemplate;
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
|
|
||||||
QTC_ASSERT(reader.fetch(templateFile), return);
|
QTC_ASSERT(reader.fetch(Utils::FilePath::fromString(templateFile)), return);
|
||||||
QString qmlTemplateString = QString::fromUtf8(reader.data());
|
QString qmlTemplateString = QString::fromUtf8(reader.data());
|
||||||
QString imports;
|
QString imports;
|
||||||
|
|
||||||
|
@@ -88,8 +88,8 @@ GraphicsView::GraphicsView(CurveEditorModel *model, QWidget *parent)
|
|||||||
applyZoom(m_zoomX, m_zoomY);
|
applyZoom(m_zoomX, m_zoomY);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
const QString css = Theme::replaceCssColors(QString::fromUtf8(
|
const QString css = Theme::replaceCssColors(
|
||||||
Utils::FileReader::fetchQrc(QLatin1String(":/qmldesigner/scrollbar.css"))));
|
QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css")));
|
||||||
horizontalScrollBar()->setStyleSheet(css);
|
horizontalScrollBar()->setStyleSheet(css);
|
||||||
verticalScrollBar()->setStyleSheet(css);
|
verticalScrollBar()->setStyleSheet(css);
|
||||||
}
|
}
|
||||||
|
@@ -199,8 +199,10 @@ ItemLibraryWidget::ItemLibraryWidget(AsynchronousImageCache &imageCache,
|
|||||||
updateSearch();
|
updateSearch();
|
||||||
|
|
||||||
/* style sheets */
|
/* style sheets */
|
||||||
setStyleSheet(Theme::replaceCssColors(QString::fromUtf8(Utils::FileReader::fetchQrc(QLatin1String(":/qmldesigner/stylesheet.css")))));
|
setStyleSheet(Theme::replaceCssColors(
|
||||||
m_resourcesView->setStyleSheet(Theme::replaceCssColors(QString::fromUtf8(Utils::FileReader::fetchQrc(QLatin1String(":/qmldesigner/scrollbar.css")))));
|
QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css"))));
|
||||||
|
m_resourcesView->setStyleSheet(Theme::replaceCssColors(
|
||||||
|
QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css"))));
|
||||||
|
|
||||||
m_qmlSourceUpdateShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F5), this);
|
m_qmlSourceUpdateShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F5), this);
|
||||||
connect(m_qmlSourceUpdateShortcut, &QShortcut::activated, this, &ItemLibraryWidget::reloadQmlSource);
|
connect(m_qmlSourceUpdateShortcut, &QShortcut::activated, this, &ItemLibraryWidget::reloadQmlSource);
|
||||||
|
@@ -88,7 +88,7 @@ PropertyEditorView::PropertyEditorView(QWidget *parent) :
|
|||||||
connect(m_updateShortcut, &QShortcut::activated, this, &PropertyEditorView::reloadQml);
|
connect(m_updateShortcut, &QShortcut::activated, this, &PropertyEditorView::reloadQml);
|
||||||
|
|
||||||
m_stackedWidget->setStyleSheet(Theme::replaceCssColors(
|
m_stackedWidget->setStyleSheet(Theme::replaceCssColors(
|
||||||
QString::fromUtf8(Utils::FileReader::fetchQrc(QStringLiteral(":/qmldesigner/stylesheet.css")))));
|
QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css"))));
|
||||||
m_stackedWidget->setMinimumWidth(340);
|
m_stackedWidget->setMinimumWidth(340);
|
||||||
m_stackedWidget->move(0, 0);
|
m_stackedWidget->move(0, 0);
|
||||||
connect(m_stackedWidget, &PropertyEditorWidget::resized, this, &PropertyEditorView::updateSize);
|
connect(m_stackedWidget, &PropertyEditorWidget::resized, this, &PropertyEditorView::updateSize);
|
||||||
|
@@ -85,7 +85,9 @@ void TextEditorWidget::setTextEditor(TextEditor::BaseTextEditor *textEditor)
|
|||||||
});
|
});
|
||||||
|
|
||||||
textEditor->editorWidget()->installEventFilter(this);
|
textEditor->editorWidget()->installEventFilter(this);
|
||||||
static QString styleSheet = Theme::replaceCssColors(QString::fromUtf8(Utils::FileReader::fetchQrc(QLatin1String(":/qmldesigner/scrollbar.css"))));
|
static QString styleSheet = Theme::replaceCssColors(
|
||||||
|
QString::fromUtf8(Utils::FileReader::fetchQrc(
|
||||||
|
":/qmldesigner/scrollbar.css")));
|
||||||
textEditor->editorWidget()->verticalScrollBar()->setStyleSheet(styleSheet);
|
textEditor->editorWidget()->verticalScrollBar()->setStyleSheet(styleSheet);
|
||||||
textEditor->editorWidget()->horizontalScrollBar()->setStyleSheet(styleSheet);
|
textEditor->editorWidget()->horizontalScrollBar()->setStyleSheet(styleSheet);
|
||||||
}
|
}
|
||||||
|
@@ -128,7 +128,7 @@ TimelineWidget::TimelineWidget(TimelineView *view)
|
|||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|
||||||
const QString css = Theme::replaceCssColors(QString::fromUtf8(
|
const QString css = Theme::replaceCssColors(QString::fromUtf8(
|
||||||
Utils::FileReader::fetchQrc(QLatin1String(":/qmldesigner/scrollbar.css"))));
|
Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css")));
|
||||||
|
|
||||||
m_scrollbar->setStyleSheet(css);
|
m_scrollbar->setStyleSheet(css);
|
||||||
m_scrollbar->setOrientation(Qt::Horizontal);
|
m_scrollbar->setOrientation(Qt::Horizontal);
|
||||||
|
@@ -100,8 +100,8 @@ TransitionEditorWidget::TransitionEditorWidget(TransitionEditorView *view)
|
|||||||
setWindowTitle(tr("Transition", "Title of transition view"));
|
setWindowTitle(tr("Transition", "Title of transition view"));
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|
||||||
const QString css = Theme::replaceCssColors(QString::fromUtf8(
|
const QString css = Theme::replaceCssColors(
|
||||||
Utils::FileReader::fetchQrc(QLatin1String(":/qmldesigner/scrollbar.css"))));
|
QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css")));
|
||||||
|
|
||||||
m_scrollbar->setStyleSheet(css);
|
m_scrollbar->setStyleSheet(css);
|
||||||
m_scrollbar->setOrientation(Qt::Horizontal);
|
m_scrollbar->setOrientation(Qt::Horizontal);
|
||||||
|
@@ -167,7 +167,7 @@ static QByteArray getSourceForUrl(const QString &fileURl)
|
|||||||
{
|
{
|
||||||
Utils::FileReader fileReader;
|
Utils::FileReader fileReader;
|
||||||
|
|
||||||
if (fileReader.fetch(fileURl))
|
if (fileReader.fetch(Utils::FilePath::fromString(fileURl)))
|
||||||
return fileReader.data();
|
return fileReader.data();
|
||||||
else
|
else
|
||||||
return Utils::FileReader::fetchQrc(fileURl);
|
return Utils::FileReader::fetchQrc(fileURl);
|
||||||
|
@@ -215,7 +215,7 @@ void QmlBuildSystem::parseProject(RefreshOptions options)
|
|||||||
= QDir(canonicalProjectDir().toString()).absoluteFilePath(mainFilePath);
|
= QDir(canonicalProjectDir().toString()).absoluteFilePath(mainFilePath);
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
if (!reader.fetch(mainFilePath, &errorMessage)) {
|
if (!reader.fetch(Utils::FilePath::fromString(mainFilePath), &errorMessage)) {
|
||||||
MessageManager::writeFlashing(tr("Warning while loading project file %1.")
|
MessageManager::writeFlashing(tr("Warning while loading project file %1.")
|
||||||
.arg(projectFilePath().toUserOutput()));
|
.arg(projectFilePath().toUserOutput()));
|
||||||
MessageManager::writeSilently(errorMessage);
|
MessageManager::writeSilently(errorMessage);
|
||||||
|
@@ -58,7 +58,7 @@ void SshKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams,
|
|||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
if (!reader.fetch(keyFilePath)) {
|
if (!reader.fetch(Utils::FilePath::fromString(keyFilePath))) {
|
||||||
emit error(tr("Public key error: %1").arg(reader.errorString()));
|
emit error(tr("Public key error: %1").arg(reader.errorString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -199,12 +199,12 @@ bool ResourceEditorDocument::setContents(const QByteArray &contents)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QString originalFileName = m_model->fileName();
|
const QString originalFileName = m_model->fileName();
|
||||||
m_model->setFileName(saver.fileName());
|
m_model->setFileName(saver.filePath().toString());
|
||||||
const bool success = (m_model->reload() == OpenResult::Success);
|
const bool success = (m_model->reload() == OpenResult::Success);
|
||||||
m_model->setFileName(originalFileName);
|
m_model->setFileName(originalFileName);
|
||||||
m_shouldAutoSave = false;
|
m_shouldAutoSave = false;
|
||||||
if (debugResourceEditorW)
|
if (debugResourceEditorW)
|
||||||
qDebug() << "ResourceEditorW::createNew: " << contents << " (" << saver.fileName() << ") returns " << success;
|
qDebug() << "ResourceEditorW::createNew: " << contents << " (" << saver.filePath() << ") returns " << success;
|
||||||
emit loaded(success);
|
emit loaded(success);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@@ -820,7 +820,7 @@ void SubversionPluginPrivate::startCommit(const QString &workingDir, const QStri
|
|||||||
VcsOutputWindow::appendError(saver.errorString());
|
VcsOutputWindow::appendError(saver.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_commitMessageFileName = saver.fileName();
|
m_commitMessageFileName = saver.filePath().toString();
|
||||||
// Create a submit editor and set file list
|
// Create a submit editor and set file list
|
||||||
SubversionSubmitEditor *editor = openSubversionSubmitEditor(m_commitMessageFileName);
|
SubversionSubmitEditor *editor = openSubversionSubmitEditor(m_commitMessageFileName);
|
||||||
QTC_ASSERT(editor, return);
|
QTC_ASSERT(editor, return);
|
||||||
|
@@ -238,7 +238,7 @@ void ColorScheme::clear()
|
|||||||
|
|
||||||
bool ColorScheme::save(const QString &fileName, QWidget *parent) const
|
bool ColorScheme::save(const QString &fileName, QWidget *parent) const
|
||||||
{
|
{
|
||||||
Utils::FileSaver saver(fileName);
|
Utils::FileSaver saver(Utils::FilePath::fromString(fileName));
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
QXmlStreamWriter w(saver.file());
|
QXmlStreamWriter w(saver.file());
|
||||||
w.setAutoFormatting(true);
|
w.setAutoFormatting(true);
|
||||||
|
@@ -81,13 +81,13 @@ static FormatTask format(FormatTask task)
|
|||||||
if (!sourceFile.finalize()) {
|
if (!sourceFile.finalize()) {
|
||||||
task.error = QString(QT_TRANSLATE_NOOP("TextEditor",
|
task.error = QString(QT_TRANSLATE_NOOP("TextEditor",
|
||||||
"Cannot create temporary file \"%1\": %2."))
|
"Cannot create temporary file \"%1\": %2."))
|
||||||
.arg(sourceFile.fileName(), sourceFile.errorString());
|
.arg(sourceFile.filePath().toUserOutput(), sourceFile.errorString());
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format temporary file
|
// Format temporary file
|
||||||
QStringList options = task.command.options();
|
QStringList options = task.command.options();
|
||||||
options.replaceInStrings(QLatin1String("%file"), sourceFile.fileName());
|
options.replaceInStrings(QLatin1String("%file"), sourceFile.filePath().toString());
|
||||||
SynchronousProcess process;
|
SynchronousProcess process;
|
||||||
process.setTimeoutS(5);
|
process.setTimeoutS(5);
|
||||||
process.runBlocking({executable, options});
|
process.runBlocking({executable, options});
|
||||||
@@ -102,9 +102,9 @@ static FormatTask format(FormatTask task)
|
|||||||
|
|
||||||
// Read text back
|
// Read text back
|
||||||
Utils::FileReader reader;
|
Utils::FileReader reader;
|
||||||
if (!reader.fetch(sourceFile.fileName(), QIODevice::Text)) {
|
if (!reader.fetch(sourceFile.filePath(), QIODevice::Text)) {
|
||||||
task.error = QString(QT_TRANSLATE_NOOP("TextEditor", "Cannot read file \"%1\": %2."))
|
task.error = QString(QT_TRANSLATE_NOOP("TextEditor", "Cannot read file \"%1\": %2."))
|
||||||
.arg(sourceFile.fileName(), reader.errorString());
|
.arg(sourceFile.filePath().toUserOutput(), reader.errorString());
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
task.formattedData = QString::fromUtf8(reader.data());
|
task.formattedData = QString::fromUtf8(reader.data());
|
||||||
|
@@ -306,7 +306,7 @@ bool SnippetsCollection::synchronize(QString *errorString)
|
|||||||
QDir::toNativeSeparators(m_userSnippetsPath));
|
QDir::toNativeSeparators(m_userSnippetsPath));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Utils::FileSaver saver(m_userSnippetsPath + m_userSnippetsFile);
|
Utils::FileSaver saver(Utils::FilePath::fromString(m_userSnippetsPath + m_userSnippetsFile));
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
using GroupIndexByIdConstIt = QHash<QString, int>::ConstIterator;
|
using GroupIndexByIdConstIt = QHash<QString, int>::ConstIterator;
|
||||||
|
|
||||||
|
@@ -193,7 +193,7 @@ void SuppressionDialog::maybeShow(MemcheckErrorView *view)
|
|||||||
|
|
||||||
void SuppressionDialog::accept()
|
void SuppressionDialog::accept()
|
||||||
{
|
{
|
||||||
const QString path = m_fileChooser->filePath().toString();
|
const Utils::FilePath path = m_fileChooser->filePath();
|
||||||
QTC_ASSERT(!path.isEmpty(), return);
|
QTC_ASSERT(!path.isEmpty(), return);
|
||||||
QTC_ASSERT(!m_suppressionEdit->toPlainText().trimmed().isEmpty(), return);
|
QTC_ASSERT(!m_suppressionEdit->toPlainText().trimmed().isEmpty(), return);
|
||||||
|
|
||||||
@@ -207,16 +207,16 @@ void SuppressionDialog::accept()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Add file to project if there is a project containing this file on the file system.
|
// Add file to project if there is a project containing this file on the file system.
|
||||||
if (!ProjectExplorer::SessionManager::projectForFile(Utils::FilePath::fromString(path))) {
|
if (!ProjectExplorer::SessionManager::projectForFile(path)) {
|
||||||
for (ProjectExplorer::Project *p : ProjectExplorer::SessionManager::projects()) {
|
for (ProjectExplorer::Project *p : ProjectExplorer::SessionManager::projects()) {
|
||||||
if (path.startsWith(p->projectDirectory().toString())) {
|
if (path.startsWith(p->projectDirectory().toString())) {
|
||||||
p->rootProjectNode()->addFiles(QStringList() << path);
|
p->rootProjectNode()->addFiles({path.toString()});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_settings->suppressions.addSuppressionFile(path);
|
m_settings->suppressions.addSuppressionFile(path.toString());
|
||||||
|
|
||||||
QModelIndexList indices = m_view->selectionModel()->selectedRows();
|
QModelIndexList indices = m_view->selectionModel()->selectedRows();
|
||||||
Utils::sort(indices, [](const QModelIndex &l, const QModelIndex &r) {
|
Utils::sort(indices, [](const QModelIndex &l, const QModelIndex &r) {
|
||||||
|
@@ -244,7 +244,7 @@ bool NickNameDialog::populateModelFromMailCapFile(const QString &fileName,
|
|||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (!reader.fetch(fileName, QIODevice::Text, errorMessage))
|
if (!reader.fetch(Utils::FilePath::fromString(fileName), QIODevice::Text, errorMessage))
|
||||||
return false;
|
return false;
|
||||||
// Split into lines and read
|
// Split into lines and read
|
||||||
NickNameEntry entry;
|
NickNameEntry entry;
|
||||||
|
@@ -58,7 +58,7 @@ Core::IDocument::OpenResult SubmitEditorFile::open(QString *errorString, const Q
|
|||||||
return OpenResult::ReadError;
|
return OpenResult::ReadError;
|
||||||
|
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (!reader.fetch(realFileName, QIODevice::Text, errorString))
|
if (!reader.fetch(Utils::FilePath::fromString(realFileName), QIODevice::Text, errorString))
|
||||||
return OpenResult::ReadError;
|
return OpenResult::ReadError;
|
||||||
|
|
||||||
const QString text = QString::fromLocal8Bit(reader.data());
|
const QString text = QString::fromLocal8Bit(reader.data());
|
||||||
@@ -91,8 +91,7 @@ void SubmitEditorFile::setModified(bool modified)
|
|||||||
bool SubmitEditorFile::save(QString *errorString, const QString &fileName, bool autoSave)
|
bool SubmitEditorFile::save(QString *errorString, const QString &fileName, bool autoSave)
|
||||||
{
|
{
|
||||||
const FilePath fName = fileName.isEmpty() ? filePath() : FilePath::fromString(fileName);
|
const FilePath fName = fileName.isEmpty() ? filePath() : FilePath::fromString(fileName);
|
||||||
FileSaver saver(fName.toString(),
|
FileSaver saver(fName, QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
|
||||||
QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
|
|
||||||
saver.write(m_editor->fileContents());
|
saver.write(m_editor->fileContents());
|
||||||
if (!saver.finalize(errorString))
|
if (!saver.finalize(errorString))
|
||||||
return false;
|
return false;
|
||||||
|
@@ -274,8 +274,11 @@ static inline QStringList fieldTexts(const QString &fileContents)
|
|||||||
void VcsBaseSubmitEditor::createUserFields(const QString &fieldConfigFile)
|
void VcsBaseSubmitEditor::createUserFields(const QString &fieldConfigFile)
|
||||||
{
|
{
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (!reader.fetch(fieldConfigFile, QIODevice::Text, Core::ICore::dialogParent()))
|
if (!reader.fetch(FilePath::fromString(fieldConfigFile),
|
||||||
|
QIODevice::Text,
|
||||||
|
Core::ICore::dialogParent())) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
// Parse into fields
|
// Parse into fields
|
||||||
const QStringList fields = fieldTexts(QString::fromUtf8(reader.data()));
|
const QStringList fields = fieldTexts(QString::fromUtf8(reader.data()));
|
||||||
if (fields.empty())
|
if (fields.empty())
|
||||||
@@ -657,7 +660,7 @@ bool VcsBaseSubmitEditor::runSubmitMessageCheckScript(const QString &checkScript
|
|||||||
QtcProcess checkProcess;
|
QtcProcess checkProcess;
|
||||||
if (!d->m_checkScriptWorkingDirectory.isEmpty())
|
if (!d->m_checkScriptWorkingDirectory.isEmpty())
|
||||||
checkProcess.setWorkingDirectory(d->m_checkScriptWorkingDirectory);
|
checkProcess.setWorkingDirectory(d->m_checkScriptWorkingDirectory);
|
||||||
checkProcess.setCommand({checkScript, {saver.fileName()}});
|
checkProcess.setCommand({checkScript, {saver.filePath().toString()}});
|
||||||
checkProcess.start();
|
checkProcess.start();
|
||||||
checkProcess.closeWriteChannel();
|
checkProcess.closeWriteChannel();
|
||||||
if (!checkProcess.waitForStarted()) {
|
if (!checkProcess.waitForStarted()) {
|
||||||
|
@@ -106,7 +106,7 @@ static bool generateEnvironmentSettings(Utils::Environment &env,
|
|||||||
const Utils::FilePath cmdPath
|
const Utils::FilePath cmdPath
|
||||||
= Utils::FilePath::fromString(QString::fromLocal8Bit(qgetenv("COMSPEC")));
|
= Utils::FilePath::fromString(QString::fromLocal8Bit(qgetenv("COMSPEC")));
|
||||||
// Windows SDK setup scripts require command line switches for environment expansion.
|
// Windows SDK setup scripts require command line switches for environment expansion.
|
||||||
QString cmdArguments = " /E:ON /V:ON /c \"" + QDir::toNativeSeparators(saver.fileName()) + '"';
|
QString cmdArguments = " /E:ON /V:ON /c \"" + saver.filePath().toUserOutput() + '"';
|
||||||
run.setCommand(Utils::CommandLine(cmdPath, cmdArguments, Utils::CommandLine::Raw));
|
run.setCommand(Utils::CommandLine(cmdPath, cmdArguments, Utils::CommandLine::Raw));
|
||||||
run.start();
|
run.start();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user