forked from qt-creator/qt-creator
CorePlugin: Use FilePath istead of QString
Task-number: QTCREATORBUG-2616 Change-Id: Iaa5bc7946a7bddfd8adffe51906d90b2e76f5837 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -254,7 +254,7 @@ BaseFileWizardFactory::OverwriteResult BaseFileWizardFactory::promptOverwrite(Ge
|
|||||||
|
|
||||||
if (oddStuffFound) {
|
if (oddStuffFound) {
|
||||||
*errorMessage = tr("The project directory %1 contains files which cannot be overwritten:\n%2.")
|
*errorMessage = tr("The project directory %1 contains files which cannot be overwritten:\n%2.")
|
||||||
.arg(QDir::toNativeSeparators(commonExistingPath)).arg(fileNamesMsgPart);
|
.arg(QDir::toNativeSeparators(commonExistingPath), fileNamesMsgPart);
|
||||||
return OverwriteError;
|
return OverwriteError;
|
||||||
}
|
}
|
||||||
// Prompt to overwrite existing files.
|
// Prompt to overwrite existing files.
|
||||||
|
@@ -404,11 +404,11 @@ void CorePlugin::warnAboutCrashReporing()
|
|||||||
"To enable this feature go to %2.");
|
"To enable this feature go to %2.");
|
||||||
|
|
||||||
if (Utils::HostOsInfo::isMacHost()) {
|
if (Utils::HostOsInfo::isMacHost()) {
|
||||||
warnStr = warnStr.arg(Core::Constants::IDE_DISPLAY_NAME)
|
warnStr = warnStr.arg(Core::Constants::IDE_DISPLAY_NAME,
|
||||||
.arg(Core::Constants::IDE_DISPLAY_NAME + tr(" > Preferences > Environment > System"));
|
Core::Constants::IDE_DISPLAY_NAME + tr(" > Preferences > Environment > System"));
|
||||||
} else {
|
} else {
|
||||||
warnStr = warnStr.arg(Core::Constants::IDE_DISPLAY_NAME)
|
warnStr = warnStr.arg(Core::Constants::IDE_DISPLAY_NAME,
|
||||||
.arg(tr("Tools > Options > Environment > System"));
|
tr("Tools > Options > Environment > System"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::InfoBarEntry info(kWarnCrashReportingSetting, warnStr,
|
Utils::InfoBarEntry info(kWarnCrashReportingSetting, warnStr,
|
||||||
|
@@ -630,7 +630,7 @@ void ExternalToolConfig::showInfoForItem(const QModelIndex &index)
|
|||||||
updateEffectiveArguments();
|
updateEffectiveArguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString getUserFilePath(const QString &proposalFileName)
|
static FilePath getUserFilePath(const QString &proposalFileName)
|
||||||
{
|
{
|
||||||
const QDir resourceDir(ICore::userResourcePath().toDir());
|
const QDir resourceDir(ICore::userResourcePath().toDir());
|
||||||
if (!resourceDir.exists(QLatin1String("externaltools")))
|
if (!resourceDir.exists(QLatin1String("externaltools")))
|
||||||
@@ -642,12 +642,12 @@ static QString getUserFilePath(const QString &proposalFileName)
|
|||||||
FilePath tryPath = newFilePath + suffix;
|
FilePath tryPath = newFilePath + suffix;
|
||||||
while (tryPath.exists()) {
|
while (tryPath.exists()) {
|
||||||
if (++count > 15)
|
if (++count > 15)
|
||||||
return QString();
|
return {};
|
||||||
// add random number
|
// add random number
|
||||||
const int number = QRandomGenerator::global()->generate() % 1000;
|
const int number = QRandomGenerator::global()->generate() % 1000;
|
||||||
tryPath = newFilePath + QString::number(number) + suffix;
|
tryPath = newFilePath + QString::number(number) + suffix;
|
||||||
}
|
}
|
||||||
return tryPath.toString();
|
return tryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString idFromDisplayName(const QString &displayName)
|
static QString idFromDisplayName(const QString &displayName)
|
||||||
@@ -709,8 +709,8 @@ void ExternalToolConfig::apply()
|
|||||||
if (tool->preset() && (*tool) != (*(tool->preset()))) {
|
if (tool->preset() && (*tool) != (*(tool->preset()))) {
|
||||||
// check if we need to choose a new file name
|
// check if we need to choose a new file name
|
||||||
if (tool->preset()->fileName() == tool->fileName()) {
|
if (tool->preset()->fileName() == tool->fileName()) {
|
||||||
const QString &fileName = FilePath::fromString(tool->preset()->fileName()).fileName();
|
const QString &fileName = tool->preset()->fileName().fileName();
|
||||||
const QString &newFilePath = getUserFilePath(fileName);
|
const FilePath &newFilePath = getUserFilePath(fileName);
|
||||||
// TODO error handling if newFilePath.isEmpty() (i.e. failed to find a unused name)
|
// TODO error handling if newFilePath.isEmpty() (i.e. failed to find a unused name)
|
||||||
tool->setFileName(newFilePath);
|
tool->setFileName(newFilePath);
|
||||||
}
|
}
|
||||||
@@ -720,9 +720,9 @@ void ExternalToolConfig::apply()
|
|||||||
} else if (tool->preset() && (*tool) == (*(tool->preset()))) {
|
} else if (tool->preset() && (*tool) == (*(tool->preset()))) {
|
||||||
// check if we need to delete the changed description
|
// check if we need to delete the changed description
|
||||||
if (originalTool->fileName() != tool->preset()->fileName()
|
if (originalTool->fileName() != tool->preset()->fileName()
|
||||||
&& QFile::exists(originalTool->fileName())) {
|
&& originalTool->fileName().exists()) {
|
||||||
// TODO error handling
|
// TODO error handling
|
||||||
QFile::remove(originalTool->fileName());
|
originalTool->fileName().removeFile();
|
||||||
}
|
}
|
||||||
tool->setFileName(tool->preset()->fileName());
|
tool->setFileName(tool->preset()->fileName());
|
||||||
// no need to save, it's the same as the preset
|
// no need to save, it's the same as the preset
|
||||||
@@ -755,7 +755,7 @@ void ExternalToolConfig::apply()
|
|||||||
foreach (ExternalTool *tool, originalTools) {
|
foreach (ExternalTool *tool, originalTools) {
|
||||||
QTC_ASSERT(!tool->preset(), continue);
|
QTC_ASSERT(!tool->preset(), continue);
|
||||||
// TODO error handling
|
// TODO error handling
|
||||||
QFile::remove(tool->fileName());
|
tool->fileName().removeFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalToolManager::setToolsByCategory(resultMap);
|
ExternalToolManager::setToolsByCategory(resultMap);
|
||||||
|
@@ -32,11 +32,11 @@
|
|||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
|
||||||
OpenWithDialog::OpenWithDialog(const QString &fileName, QWidget *parent)
|
OpenWithDialog::OpenWithDialog(const Utils::FilePath &filePath, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
label->setText(tr("Open file \"%1\" with:").arg(Utils::FilePath::fromString(fileName).fileName()));
|
label->setText(tr("Open file \"%1\" with:").arg(filePath.fileName()));
|
||||||
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
|
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
|
||||||
|
|
||||||
connect(buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked,
|
connect(buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked,
|
||||||
|
@@ -28,6 +28,8 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "ui_openwithdialog.h"
|
#include "ui_openwithdialog.h"
|
||||||
|
|
||||||
|
namespace Utils { class FilePath; }
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -38,7 +40,7 @@ class OpenWithDialog : public QDialog, public Ui::OpenWithDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OpenWithDialog(const QString &fileName, QWidget *parent);
|
OpenWithDialog(const Utils::FilePath &filePath, QWidget *parent);
|
||||||
|
|
||||||
void setEditors(const QStringList &);
|
void setEditors(const QStringList &);
|
||||||
int editor() const;
|
int editor() const;
|
||||||
|
@@ -1146,14 +1146,14 @@ void EditorManagerPrivate::showPopupOrSelectDocument()
|
|||||||
|
|
||||||
// Run the OpenWithDialog and return the editor id
|
// Run the OpenWithDialog and return the editor id
|
||||||
// selected by the user.
|
// selected by the user.
|
||||||
Id EditorManagerPrivate::getOpenWithEditorId(const QString &fileName, bool *isExternalEditor)
|
Id EditorManagerPrivate::getOpenWithEditorId(const Utils::FilePath &fileName, bool *isExternalEditor)
|
||||||
{
|
{
|
||||||
// Collect editors that can open the file
|
// Collect editors that can open the file
|
||||||
QList<Id> allEditorIds;
|
QList<Id> allEditorIds;
|
||||||
QStringList allEditorDisplayNames;
|
QStringList allEditorDisplayNames;
|
||||||
QList<Id> externalEditorIds;
|
QList<Id> externalEditorIds;
|
||||||
// Built-in
|
// Built-in
|
||||||
const EditorFactoryList editors = IEditorFactory::preferredEditorFactories(FilePath::fromString(fileName));
|
const EditorFactoryList editors = IEditorFactory::preferredEditorFactories(fileName);
|
||||||
const int size = editors.size();
|
const int size = editors.size();
|
||||||
allEditorDisplayNames.reserve(size);
|
allEditorDisplayNames.reserve(size);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
@@ -3073,7 +3073,6 @@ IEditor *EditorManager::openEditor(const FilePath &filePath, Id editorId,
|
|||||||
IEditor *EditorManager::openEditor(const QString &fileName, Id editorId,
|
IEditor *EditorManager::openEditor(const QString &fileName, Id editorId,
|
||||||
OpenEditorFlags flags, bool *newEditor)
|
OpenEditorFlags flags, bool *newEditor)
|
||||||
{
|
{
|
||||||
QFileInfo fi(fileName);
|
|
||||||
return openEditor(FilePath::fromString(fileName), editorId, flags, newEditor);
|
return openEditor(FilePath::fromString(fileName), editorId, flags, newEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,7 +108,7 @@ public:
|
|||||||
static MakeWritableResult makeFileWritable(IDocument *document);
|
static MakeWritableResult makeFileWritable(IDocument *document);
|
||||||
static void doEscapeKeyFocusMoveMagic();
|
static void doEscapeKeyFocusMoveMagic();
|
||||||
|
|
||||||
static Utils::Id getOpenWithEditorId(const QString &fileName, bool *isExternalEditor = nullptr);
|
static Utils::Id getOpenWithEditorId(const Utils::FilePath &fileName, bool *isExternalEditor = nullptr);
|
||||||
|
|
||||||
static void saveSettings();
|
static void saveSettings();
|
||||||
static void readSettings();
|
static void readSettings();
|
||||||
|
@@ -101,7 +101,7 @@ ExternalTool::ExternalTool(const ExternalTool *other)
|
|||||||
m_outputHandling(other->m_outputHandling),
|
m_outputHandling(other->m_outputHandling),
|
||||||
m_errorHandling(other->m_errorHandling),
|
m_errorHandling(other->m_errorHandling),
|
||||||
m_modifiesCurrentDocument(other->m_modifiesCurrentDocument),
|
m_modifiesCurrentDocument(other->m_modifiesCurrentDocument),
|
||||||
m_fileName(other->m_fileName),
|
m_filePath(other->m_filePath),
|
||||||
m_presetTool(other->m_presetTool)
|
m_presetTool(other->m_presetTool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ ExternalTool &ExternalTool::operator=(const ExternalTool &other)
|
|||||||
m_outputHandling = other.m_outputHandling;
|
m_outputHandling = other.m_outputHandling;
|
||||||
m_errorHandling = other.m_errorHandling;
|
m_errorHandling = other.m_errorHandling;
|
||||||
m_modifiesCurrentDocument = other.m_modifiesCurrentDocument;
|
m_modifiesCurrentDocument = other.m_modifiesCurrentDocument;
|
||||||
m_fileName = other.m_fileName;
|
m_filePath = other.m_filePath;
|
||||||
m_presetFileName = other.m_presetFileName;
|
m_presetFileName = other.m_presetFileName;
|
||||||
m_presetTool = other.m_presetTool;
|
m_presetTool = other.m_presetTool;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -210,9 +210,9 @@ bool ExternalTool::modifiesCurrentDocument() const
|
|||||||
return m_modifiesCurrentDocument;
|
return m_modifiesCurrentDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalTool::setFileName(const QString &fileName)
|
void ExternalTool::setFileName(const Utils::FilePath &fileName)
|
||||||
{
|
{
|
||||||
m_fileName = fileName;
|
m_filePath = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalTool::setPreset(QSharedPointer<ExternalTool> preset)
|
void ExternalTool::setPreset(QSharedPointer<ExternalTool> preset)
|
||||||
@@ -220,9 +220,9 @@ void ExternalTool::setPreset(QSharedPointer<ExternalTool> preset)
|
|||||||
m_presetTool = preset;
|
m_presetTool = preset;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ExternalTool::fileName() const
|
Utils::FilePath ExternalTool::fileName() const
|
||||||
{
|
{
|
||||||
return m_fileName;
|
return m_filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<ExternalTool> ExternalTool::preset() const
|
QSharedPointer<ExternalTool> ExternalTool::preset() const
|
||||||
@@ -470,16 +470,16 @@ ExternalTool * ExternalTool::createFromXml(const QByteArray &xml, QString *error
|
|||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalTool * ExternalTool::createFromFile(const QString &fileName, QString *errorMessage, const QString &locale)
|
ExternalTool * ExternalTool::createFromFile(const Utils::FilePath &fileName, QString *errorMessage, const QString &locale)
|
||||||
{
|
{
|
||||||
QString absFileName = QFileInfo(fileName).absoluteFilePath();
|
Utils::FilePath absFileName = fileName.absoluteFilePath();
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (!reader.fetch(FilePath::fromString(absFileName), errorMessage))
|
if (!reader.fetch(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)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
tool->m_fileName = absFileName;
|
tool->m_filePath = absFileName;
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,9 +498,9 @@ static QString stringForOutputHandling(ExternalTool::OutputHandling handling)
|
|||||||
|
|
||||||
bool ExternalTool::save(QString *errorMessage) const
|
bool ExternalTool::save(QString *errorMessage) const
|
||||||
{
|
{
|
||||||
if (m_fileName.isEmpty())
|
if (m_filePath.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
FileSaver saver(FilePath::fromString(m_fileName));
|
FileSaver saver(m_filePath);
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
QXmlStreamWriter out(saver.file());
|
QXmlStreamWriter out(saver.file());
|
||||||
out.setAutoFormatting(true);
|
out.setAutoFormatting(true);
|
||||||
@@ -560,7 +560,7 @@ bool ExternalTool::operator==(const ExternalTool &other) const
|
|||||||
&& m_outputHandling == other.m_outputHandling
|
&& m_outputHandling == other.m_outputHandling
|
||||||
&& m_modifiesCurrentDocument == other.m_modifiesCurrentDocument
|
&& m_modifiesCurrentDocument == other.m_modifiesCurrentDocument
|
||||||
&& m_errorHandling == other.m_errorHandling
|
&& m_errorHandling == other.m_errorHandling
|
||||||
&& m_fileName == other.m_fileName;
|
&& m_filePath == other.m_filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #pragma mark -- ExternalToolRunner
|
// #pragma mark -- ExternalToolRunner
|
||||||
|
@@ -72,14 +72,14 @@ public:
|
|||||||
Utils::Environment baseEnvironment() const;
|
Utils::Environment baseEnvironment() const;
|
||||||
Utils::EnvironmentItems environmentUserChanges() const;
|
Utils::EnvironmentItems environmentUserChanges() const;
|
||||||
|
|
||||||
void setFileName(const QString &fileName);
|
void setFileName(const Utils::FilePath &fileName);
|
||||||
void setPreset(QSharedPointer<ExternalTool> preset);
|
void setPreset(QSharedPointer<ExternalTool> preset);
|
||||||
QString fileName() const;
|
Utils::FilePath fileName() const;
|
||||||
// all tools that are preset (changed or unchanged) have the original value here:
|
// all tools that are preset (changed or unchanged) have the original value here:
|
||||||
QSharedPointer<ExternalTool> preset() const;
|
QSharedPointer<ExternalTool> preset() const;
|
||||||
|
|
||||||
static ExternalTool *createFromXml(const QByteArray &xml, QString *errorMessage = nullptr, const QString &locale = QString());
|
static ExternalTool *createFromXml(const QByteArray &xml, QString *errorMessage = nullptr, const QString &locale = QString());
|
||||||
static ExternalTool *createFromFile(const QString &fileName, QString *errorMessage = nullptr,
|
static ExternalTool *createFromFile(const Utils::FilePath &fileName, QString *errorMessage = nullptr,
|
||||||
const QString &locale = QString());
|
const QString &locale = QString());
|
||||||
|
|
||||||
bool save(QString *errorMessage = nullptr) const;
|
bool save(QString *errorMessage = nullptr) const;
|
||||||
@@ -118,8 +118,8 @@ private:
|
|||||||
OutputHandling m_errorHandling = ShowInPane;
|
OutputHandling m_errorHandling = ShowInPane;
|
||||||
bool m_modifiesCurrentDocument = false;
|
bool m_modifiesCurrentDocument = false;
|
||||||
|
|
||||||
QString m_fileName;
|
Utils::FilePath m_filePath;
|
||||||
QString m_presetFileName;
|
Utils::FilePath m_presetFileName;
|
||||||
QSharedPointer<ExternalTool> m_presetTool;
|
QSharedPointer<ExternalTool> m_presetTool;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -131,7 +131,7 @@ static void parseDirectory(const QString &directory,
|
|||||||
foreach (const QFileInfo &info, dir.entryInfoList()) {
|
foreach (const QFileInfo &info, dir.entryInfoList()) {
|
||||||
const QString &fileName = info.absoluteFilePath();
|
const QString &fileName = info.absoluteFilePath();
|
||||||
QString error;
|
QString error;
|
||||||
ExternalTool *tool = ExternalTool::createFromFile(fileName, &error, ICore::userInterfaceLanguage());
|
ExternalTool *tool = ExternalTool::createFromFile(Utils::FilePath::fromString(fileName), &error, ICore::userInterfaceLanguage());
|
||||||
if (!tool) {
|
if (!tool) {
|
||||||
qWarning() << ExternalTool::tr("Error while parsing external tool %1: %2").arg(fileName, error);
|
qWarning() << ExternalTool::tr("Error while parsing external tool %1: %2").arg(fileName, error);
|
||||||
continue;
|
continue;
|
||||||
|
@@ -55,16 +55,23 @@ class GeneratedFilePrivate : public QSharedData
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GeneratedFilePrivate() = default;
|
GeneratedFilePrivate() = default;
|
||||||
explicit GeneratedFilePrivate(const QString &p);
|
explicit GeneratedFilePrivate(const Utils::FilePath &path);
|
||||||
QString path;
|
explicit GeneratedFilePrivate(const QString &path);
|
||||||
|
Utils::FilePath path;
|
||||||
QByteArray contents;
|
QByteArray contents;
|
||||||
Id editorId;
|
Id editorId;
|
||||||
bool binary = false;
|
bool binary = false;
|
||||||
GeneratedFile::Attributes attributes;
|
GeneratedFile::Attributes attributes;
|
||||||
};
|
};
|
||||||
|
|
||||||
GeneratedFilePrivate::GeneratedFilePrivate(const QString &p) :
|
GeneratedFilePrivate::GeneratedFilePrivate(const QString &path) : // FIXME Don't use - Remove when possible
|
||||||
path(QDir::cleanPath(p)),
|
path(FilePath::fromString(path).cleanPath()),
|
||||||
|
attributes({})
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GeneratedFilePrivate::GeneratedFilePrivate(const Utils::FilePath &path) :
|
||||||
|
path(path.cleanPath()),
|
||||||
attributes({})
|
attributes({})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -74,8 +81,13 @@ GeneratedFile::GeneratedFile() :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneratedFile::GeneratedFile(const QString &p) :
|
GeneratedFile::GeneratedFile(const QString &path) : // FIXME Don't use - Remove when possible
|
||||||
m_d(new GeneratedFilePrivate(p))
|
m_d(new GeneratedFilePrivate(path))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GeneratedFile::GeneratedFile(const Utils::FilePath &path) :
|
||||||
|
m_d(new GeneratedFilePrivate(path))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,17 +104,23 @@ GeneratedFile::~GeneratedFile() = default;
|
|||||||
|
|
||||||
QString GeneratedFile::path() const
|
QString GeneratedFile::path() const
|
||||||
{
|
{
|
||||||
return m_d->path;
|
return m_d->path.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath GeneratedFile::filePath() const
|
FilePath GeneratedFile::filePath() const
|
||||||
{
|
{
|
||||||
return FilePath::fromString(m_d->path);
|
return m_d->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneratedFile::setPath(const QString &p)
|
void GeneratedFile::setPath(const QString &p)
|
||||||
{
|
{
|
||||||
m_d->path = QDir::cleanPath(p);
|
m_d->path = Utils::FilePath::fromString(p).cleanPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GeneratedFile::setFilePath(const Utils::FilePath &p)
|
||||||
|
{
|
||||||
|
m_d->path = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GeneratedFile::contents() const
|
QString GeneratedFile::contents() const
|
||||||
@@ -148,8 +166,7 @@ void GeneratedFile::setEditorId(Id id)
|
|||||||
bool GeneratedFile::write(QString *errorMessage) const
|
bool GeneratedFile::write(QString *errorMessage) const
|
||||||
{
|
{
|
||||||
// Ensure the directory
|
// Ensure the directory
|
||||||
const QFileInfo info(m_d->path);
|
const QDir dir = m_d->path.parentDir().toDir();
|
||||||
const QDir dir = info.absoluteDir();
|
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
if (!dir.mkpath(dir.absolutePath())) {
|
if (!dir.mkpath(dir.absolutePath())) {
|
||||||
*errorMessage = QCoreApplication::translate("BaseFileWizard",
|
*errorMessage = QCoreApplication::translate("BaseFileWizard",
|
||||||
@@ -162,7 +179,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(FilePath::fromString(m_d->path), flags);
|
Utils::FileSaver saver(m_d->path, flags);
|
||||||
saver.write(m_d->contents);
|
saver.write(m_d->contents);
|
||||||
return saver.finalize(errorMessage);
|
return saver.finalize(errorMessage);
|
||||||
}
|
}
|
||||||
@@ -170,7 +187,7 @@ bool GeneratedFile::write(QString *errorMessage) const
|
|||||||
Utils::TextFileFormat format;
|
Utils::TextFileFormat format;
|
||||||
format.codec = EditorManager::defaultTextCodec();
|
format.codec = EditorManager::defaultTextCodec();
|
||||||
format.lineTerminationMode = EditorManager::defaultLineEnding();
|
format.lineTerminationMode = EditorManager::defaultLineEnding();
|
||||||
return format.writeFile(Utils::FilePath::fromString(m_d->path), contents(), errorMessage);
|
return format.writeFile(m_d->path, contents(), errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneratedFile::Attributes GeneratedFile::attributes() const
|
GeneratedFile::Attributes GeneratedFile::attributes() const
|
||||||
|
@@ -57,6 +57,7 @@ public:
|
|||||||
Q_DECLARE_FLAGS(Attributes, Attribute)
|
Q_DECLARE_FLAGS(Attributes, Attribute)
|
||||||
|
|
||||||
GeneratedFile();
|
GeneratedFile();
|
||||||
|
explicit GeneratedFile(const Utils::FilePath &path);
|
||||||
explicit GeneratedFile(const QString &path);
|
explicit GeneratedFile(const QString &path);
|
||||||
GeneratedFile(const GeneratedFile &);
|
GeneratedFile(const GeneratedFile &);
|
||||||
GeneratedFile &operator=(const GeneratedFile &);
|
GeneratedFile &operator=(const GeneratedFile &);
|
||||||
@@ -65,6 +66,7 @@ public:
|
|||||||
// Full path of the file should be created, or the suggested file name
|
// Full path of the file should be created, or the suggested file name
|
||||||
QString path() const;
|
QString path() const;
|
||||||
void setPath(const QString &p);
|
void setPath(const QString &p);
|
||||||
|
void setFilePath(const Utils::FilePath &p);
|
||||||
Utils::FilePath filePath() const;
|
Utils::FilePath filePath() const;
|
||||||
|
|
||||||
// Contents of the file (UTF8)
|
// Contents of the file (UTF8)
|
||||||
|
@@ -954,7 +954,7 @@ void MainWindow::openFileWith()
|
|||||||
const FilePaths filePaths = EditorManager::getOpenFilePaths();
|
const FilePaths filePaths = EditorManager::getOpenFilePaths();
|
||||||
for (const FilePath &filePath : filePaths) {
|
for (const FilePath &filePath : filePaths) {
|
||||||
bool isExternal;
|
bool isExternal;
|
||||||
const Id editorId = EditorManagerPrivate::getOpenWithEditorId(filePath.toString(), &isExternal);
|
const Id editorId = EditorManagerPrivate::getOpenWithEditorId(filePath, &isExternal);
|
||||||
if (!editorId.isValid())
|
if (!editorId.isValid())
|
||||||
continue;
|
continue;
|
||||||
if (isExternal)
|
if (isExternal)
|
||||||
|
@@ -201,7 +201,7 @@ GeneratedFiles generateQmakeFiles(const SimpleProjectWizardDialog *wizard,
|
|||||||
const QString projectPath = wizard->path();
|
const QString projectPath = wizard->path();
|
||||||
const QDir dir(projectPath);
|
const QDir dir(projectPath);
|
||||||
const QString projectName = wizard->projectName();
|
const QString projectName = wizard->projectName();
|
||||||
const QString proFileName = QFileInfo(dir, projectName + ".pro").absoluteFilePath();
|
const FilePath proFileName = Utils::FilePath::fromFileInfo(QFileInfo(dir, projectName + ".pro").absoluteFilePath());
|
||||||
const QStringList paths = Utils::transform(wizard->selectedPaths(), &FilePath::toString);
|
const QStringList paths = Utils::transform(wizard->selectedPaths(), &FilePath::toString);
|
||||||
|
|
||||||
MimeType headerType = Utils::mimeTypeForName("text/x-chdr");
|
MimeType headerType = Utils::mimeTypeForName("text/x-chdr");
|
||||||
@@ -259,7 +259,7 @@ GeneratedFiles generateCmakeFiles(const SimpleProjectWizardDialog *wizard,
|
|||||||
const QString projectPath = wizard->path();
|
const QString projectPath = wizard->path();
|
||||||
const QDir dir(projectPath);
|
const QDir dir(projectPath);
|
||||||
const QString projectName = wizard->projectName();
|
const QString projectName = wizard->projectName();
|
||||||
const QString projectFileName = QFileInfo(dir, "CMakeLists.txt").absoluteFilePath();
|
const FilePath projectFileName = Utils::FilePath::fromFileInfo(QFileInfo(dir, "CMakeLists.txt").absoluteFilePath());
|
||||||
const QStringList paths = Utils::transform(wizard->selectedPaths(), &FilePath::toString);
|
const QStringList paths = Utils::transform(wizard->selectedPaths(), &FilePath::toString);
|
||||||
|
|
||||||
MimeType headerType = Utils::mimeTypeForName("text/x-chdr");
|
MimeType headerType = Utils::mimeTypeForName("text/x-chdr");
|
||||||
|
Reference in New Issue
Block a user