forked from qt-creator/qt-creator
Use FilePath in several file wizards
Change-Id: I9bab9d602096a3872f73fb16d901b8aedcd82516 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -80,6 +80,16 @@ QString FileWizardPage::fileName() const
|
||||
return d->m_ui.nameLineEdit->text();
|
||||
}
|
||||
|
||||
FilePath FileWizardPage::filePath() const
|
||||
{
|
||||
return d->m_ui.pathChooser->filePath();
|
||||
}
|
||||
|
||||
void FileWizardPage::setFilePath(const FilePath &filePath)
|
||||
{
|
||||
d->m_ui.pathChooser->setFilePath(filePath);
|
||||
}
|
||||
|
||||
QString FileWizardPage::path() const
|
||||
{
|
||||
return d->m_ui.pathChooser->filePath().toString();
|
||||
@@ -87,7 +97,7 @@ QString FileWizardPage::path() const
|
||||
|
||||
void FileWizardPage::setPath(const QString &path)
|
||||
{
|
||||
d->m_ui.pathChooser->setPath(path);
|
||||
d->m_ui.pathChooser->setFilePath(FilePath::fromString(path));
|
||||
}
|
||||
|
||||
void FileWizardPage::setFileName(const QString &name)
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
#include "filepath.h"
|
||||
#include "wizardpage.h"
|
||||
|
||||
namespace Utils {
|
||||
@@ -44,7 +45,9 @@ public:
|
||||
~FileWizardPage() override;
|
||||
|
||||
QString fileName() const;
|
||||
QString path() const;
|
||||
QString path() const; // Deprecated: Use filePath()
|
||||
|
||||
Utils::FilePath filePath() const;
|
||||
|
||||
bool isComplete() const override;
|
||||
|
||||
@@ -64,8 +67,9 @@ signals:
|
||||
void pathChanged();
|
||||
|
||||
public slots:
|
||||
void setPath(const QString &path);
|
||||
void setPath(const QString &path); // Deprecated: Use setFilePath
|
||||
void setFileName(const QString &name);
|
||||
void setFilePath(const Utils::FilePath &filePath);
|
||||
|
||||
private:
|
||||
void slotValidChanged();
|
||||
|
@@ -86,7 +86,7 @@ Utils::Wizard *BaseFileWizardFactory::runWizardImpl(const FilePath &path, QWidge
|
||||
if (flags().testFlag(ForceCapitalLetterForFileName))
|
||||
dialogParameterFlags |= WizardDialogParameters::ForceCapitalLetterForFileName;
|
||||
|
||||
Utils::Wizard *wizard = create(parent, WizardDialogParameters(path.toString(),
|
||||
Wizard *wizard = create(parent, WizardDialogParameters(path,
|
||||
platform,
|
||||
requiredFeatures(),
|
||||
dialogParameterFlags,
|
||||
@@ -287,21 +287,17 @@ BaseFileWizardFactory::OverwriteResult BaseFileWizardFactory::promptOverwrite(Ge
|
||||
\a baseName already has one.
|
||||
*/
|
||||
|
||||
QString BaseFileWizardFactory::buildFileName(const QString &path,
|
||||
FilePath BaseFileWizardFactory::buildFileName(const FilePath &path,
|
||||
const QString &baseName,
|
||||
const QString &extension)
|
||||
{
|
||||
QString rc = path;
|
||||
const QChar slash = QLatin1Char('/');
|
||||
if (!rc.isEmpty() && !rc.endsWith(slash))
|
||||
rc += slash;
|
||||
rc += baseName;
|
||||
FilePath rc = path.pathAppended(baseName);
|
||||
// Add extension unless user specified something else
|
||||
const QChar dot = QLatin1Char('.');
|
||||
const QChar dot = '.';
|
||||
if (!extension.isEmpty() && !baseName.contains(dot)) {
|
||||
if (!extension.startsWith(dot))
|
||||
rc += dot;
|
||||
rc += extension;
|
||||
rc = rc.stringAppended(dot);
|
||||
rc = rc.stringAppended(extension);
|
||||
}
|
||||
if (debugWizard)
|
||||
qDebug() << Q_FUNC_INFO << rc;
|
||||
|
@@ -30,6 +30,8 @@
|
||||
|
||||
#include <coreplugin/iwizardfactory.h>
|
||||
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QVariantMap>
|
||||
|
||||
@@ -54,7 +56,7 @@ public:
|
||||
};
|
||||
Q_DECLARE_FLAGS(DialogParameterFlags, DialogParameterEnum)
|
||||
|
||||
explicit WizardDialogParameters(const QString &defaultPath, Utils::Id platform,
|
||||
explicit WizardDialogParameters(const Utils::FilePath &defaultPath, Utils::Id platform,
|
||||
const QSet<Utils::Id> &requiredFeatures, DialogParameterFlags flags,
|
||||
const QVariantMap &extraValues)
|
||||
: m_defaultPath(defaultPath),
|
||||
@@ -64,23 +66,14 @@ public:
|
||||
m_extraValues(extraValues)
|
||||
{}
|
||||
|
||||
QString defaultPath() const
|
||||
{ return m_defaultPath; }
|
||||
|
||||
Utils::Id selectedPlatform() const
|
||||
{ return m_selectedPlatform; }
|
||||
|
||||
QSet<Utils::Id> requiredFeatures() const
|
||||
{ return m_requiredFeatures; }
|
||||
|
||||
DialogParameterFlags flags() const
|
||||
{ return m_parameterFlags; }
|
||||
|
||||
QVariantMap extraValues() const
|
||||
{ return m_extraValues; }
|
||||
Utils::FilePath defaultPath() const { return m_defaultPath; }
|
||||
Utils::Id selectedPlatform() const { return m_selectedPlatform; }
|
||||
QSet<Utils::Id> requiredFeatures() const { return m_requiredFeatures; }
|
||||
DialogParameterFlags flags() const { return m_parameterFlags; }
|
||||
QVariantMap extraValues() const { return m_extraValues; }
|
||||
|
||||
private:
|
||||
QString m_defaultPath;
|
||||
Utils::FilePath m_defaultPath;
|
||||
Utils::Id m_selectedPlatform;
|
||||
QSet<Utils::Id> m_requiredFeatures;
|
||||
DialogParameterFlags m_parameterFlags;
|
||||
@@ -94,7 +87,7 @@ class CORE_EXPORT BaseFileWizardFactory : public IWizardFactory
|
||||
friend class BaseFileWizard;
|
||||
|
||||
public:
|
||||
static QString buildFileName(const QString &path, const QString &baseName, const QString &extension);
|
||||
static Utils::FilePath buildFileName(const Utils::FilePath &path, const QString &baseName, const QString &extension);
|
||||
|
||||
protected:
|
||||
virtual BaseFileWizard *create(QWidget *parent, const WizardDialogParameters ¶meters) const = 0;
|
||||
|
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Designer {
|
||||
namespace Internal {
|
||||
|
||||
@@ -58,7 +60,7 @@ QString FormClassWizard::formSuffix() const
|
||||
Core::BaseFileWizard *FormClassWizard::create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const
|
||||
{
|
||||
auto wizardDialog = new FormClassWizardDialog(this, parent);
|
||||
wizardDialog->setPath(parameters.defaultPath());
|
||||
wizardDialog->setFilePath(parameters.defaultPath());
|
||||
return wizardDialog;
|
||||
}
|
||||
|
||||
@@ -73,9 +75,9 @@ Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *e
|
||||
}
|
||||
|
||||
// header
|
||||
const QString formFileName = buildFileName(params.path, params.uiFile, formSuffix());
|
||||
const QString headerFileName = buildFileName(params.path, params.headerFile, headerSuffix());
|
||||
const QString sourceFileName = buildFileName(params.path, params.sourceFile, sourceSuffix());
|
||||
const FilePath formFileName = buildFileName(params.path, params.uiFile, formSuffix());
|
||||
const FilePath headerFileName = buildFileName(params.path, params.headerFile, headerSuffix());
|
||||
const FilePath sourceFileName = buildFileName(params.path, params.sourceFile, sourceSuffix());
|
||||
|
||||
Core::GeneratedFile headerFile(headerFileName);
|
||||
headerFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
@@ -102,5 +104,5 @@ Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *e
|
||||
return Core::GeneratedFiles() << headerFile << sourceFile << uiFile;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // Internal
|
||||
} // Designer
|
||||
|
@@ -26,9 +26,13 @@
|
||||
#include "formclasswizarddialog.h"
|
||||
#include "formclasswizardpage.h"
|
||||
#include "formclasswizardparameters.h"
|
||||
|
||||
#include <cppeditor/abstracteditorsupport.h>
|
||||
#include <designer/formtemplatewizardpage.h>
|
||||
#include <qtsupport/codegenerator.h>
|
||||
#include <utils/filepath.h>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
enum { FormPageId, ClassPageId };
|
||||
|
||||
@@ -52,14 +56,14 @@ FormClassWizardDialog::FormClassWizardDialog(const Core::BaseFileWizardFactory *
|
||||
addPage(p);
|
||||
}
|
||||
|
||||
QString FormClassWizardDialog::path() const
|
||||
FilePath FormClassWizardDialog::filePath() const
|
||||
{
|
||||
return m_classPage->path();
|
||||
return m_classPage->filePath();
|
||||
}
|
||||
|
||||
void FormClassWizardDialog::setPath(const QString &p)
|
||||
void FormClassWizardDialog::setFilePath(const FilePath &p)
|
||||
{
|
||||
m_classPage->setPath(p);
|
||||
m_classPage->setFilePath(p);
|
||||
}
|
||||
|
||||
void FormClassWizardDialog::initializePage(int id)
|
||||
|
@@ -45,8 +45,8 @@ public:
|
||||
|
||||
explicit FormClassWizardDialog(const Core::BaseFileWizardFactory *factory, QWidget *parent = nullptr);
|
||||
|
||||
QString path() const;
|
||||
void setPath(const QString &);
|
||||
Utils::FilePath filePath() const;
|
||||
void setFilePath(const Utils::FilePath &);
|
||||
|
||||
Designer::FormClassWizardParameters parameters() const;
|
||||
|
||||
|
@@ -32,9 +32,8 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <cppeditor/cppeditorconstants.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#
|
||||
#include <QDebug>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace Designer {
|
||||
@@ -88,20 +87,20 @@ void FormClassWizardPage::setClassName(const QString &suggestedClassName)
|
||||
slotValidChanged();
|
||||
}
|
||||
|
||||
QString FormClassWizardPage::path() const
|
||||
Utils::FilePath FormClassWizardPage::filePath() const
|
||||
{
|
||||
return m_ui->newClassWidget->path();
|
||||
return m_ui->newClassWidget->filePath();
|
||||
}
|
||||
|
||||
void FormClassWizardPage::setPath(const QString &p)
|
||||
void FormClassWizardPage::setFilePath(const Utils::FilePath &p)
|
||||
{
|
||||
m_ui->newClassWidget->setPath(p);
|
||||
m_ui->newClassWidget->setFilePath(p);
|
||||
}
|
||||
|
||||
void FormClassWizardPage::getParameters(FormClassWizardParameters *p) const
|
||||
{
|
||||
p->className = m_ui->newClassWidget->className();
|
||||
p->path = path();
|
||||
p->path = filePath();
|
||||
p->sourceFile = m_ui->newClassWidget->sourceFileName();
|
||||
p->headerFile = m_ui->newClassWidget->headerFileName();
|
||||
p->uiFile = m_ui->newClassWidget-> formFileName();
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
#include <QWizardPage>
|
||||
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace Designer {
|
||||
|
||||
class FormClassWizardParameters;
|
||||
@@ -49,8 +51,8 @@ public:
|
||||
bool validatePage() override;
|
||||
|
||||
void setClassName(const QString &suggestedClassName);
|
||||
void setPath(const QString &);
|
||||
QString path() const;
|
||||
void setFilePath(const Utils::FilePath &);
|
||||
Utils::FilePath filePath() const;
|
||||
|
||||
// Fill out applicable parameters
|
||||
void getParameters(FormClassWizardParameters *) const;
|
||||
|
@@ -25,7 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
namespace Designer {
|
||||
@@ -39,7 +40,7 @@ class FormClassWizardParameters
|
||||
public:
|
||||
QString uiTemplate;
|
||||
QString className;
|
||||
QString path;
|
||||
Utils::FilePath path;
|
||||
QString sourceFile;
|
||||
QString headerFile;
|
||||
QString uiFile;
|
||||
|
@@ -29,6 +29,8 @@
|
||||
#include <QFileDialog>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
enum { debugNewClassWidget = 0 };
|
||||
|
||||
/*! \class Utils::NewClassWidget
|
||||
@@ -171,14 +173,14 @@ QString NewClassWidget::formFileName() const
|
||||
return d->m_ui.formFileLineEdit->text();
|
||||
}
|
||||
|
||||
QString NewClassWidget::path() const
|
||||
FilePath NewClassWidget::filePath() const
|
||||
{
|
||||
return d->m_ui.pathChooser->filePath().toString();
|
||||
return d->m_ui.pathChooser->filePath();
|
||||
}
|
||||
|
||||
void NewClassWidget::setPath(const QString &path)
|
||||
void NewClassWidget::setFilePath(const FilePath &path)
|
||||
{
|
||||
d->m_ui.pathChooser->setPath(path);
|
||||
d->m_ui.pathChooser->setFilePath(path);
|
||||
}
|
||||
|
||||
QString NewClassWidget::sourceExtension() const
|
||||
@@ -305,21 +307,21 @@ static QString ensureSuffix(QString f, const QString &extension)
|
||||
}
|
||||
|
||||
// If a non-empty name was passed, expand to directory and suffix
|
||||
static QString expandFileName(const QDir &dir, const QString &name, const QString &extension)
|
||||
static FilePath expandFileName(const FilePath &dir, const QString &name, const QString &extension)
|
||||
{
|
||||
if (name.isEmpty())
|
||||
return QString();
|
||||
return dir.absoluteFilePath(ensureSuffix(name, extension));
|
||||
return {};
|
||||
return dir / ensureSuffix(name, extension);
|
||||
}
|
||||
|
||||
QStringList NewClassWidget::files() const
|
||||
Utils::FilePaths NewClassWidget::files() const
|
||||
{
|
||||
QStringList rc;
|
||||
const QDir dir = QDir(path());
|
||||
rc.push_back(expandFileName(dir, headerFileName(), headerExtension()));
|
||||
rc.push_back(expandFileName(dir, sourceFileName(), sourceExtension()));
|
||||
rc.push_back(expandFileName(dir, formFileName(), formExtension()));
|
||||
return rc;
|
||||
const FilePath dir = filePath();
|
||||
return {
|
||||
expandFileName(dir, headerFileName(), headerExtension()),
|
||||
expandFileName(dir, sourceFileName(), sourceExtension()),
|
||||
expandFileName(dir, formFileName(), formExtension()),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Designer {
|
||||
@@ -52,14 +54,14 @@ public:
|
||||
QString sourceFileName() const;
|
||||
QString headerFileName() const;
|
||||
QString formFileName() const;
|
||||
QString path() const;
|
||||
Utils::FilePath filePath() const;
|
||||
QString sourceExtension() const;
|
||||
QString headerExtension() const;
|
||||
QString formExtension() const;
|
||||
|
||||
bool isValid(QString *error = nullptr) const;
|
||||
|
||||
QStringList files() const;
|
||||
Utils::FilePaths files() const;
|
||||
|
||||
signals:
|
||||
void validChanged();
|
||||
@@ -72,7 +74,7 @@ public slots:
|
||||
* valid class name.
|
||||
*/
|
||||
void setClassName(const QString &suggestedName);
|
||||
void setPath(const QString &path);
|
||||
void setFilePath(const Utils::FilePath &filePath);
|
||||
void setSourceExtension(const QString &e);
|
||||
void setHeaderExtension(const QString &e);
|
||||
void setLowerCaseFiles(bool v);
|
||||
|
@@ -59,8 +59,7 @@ FilesSelectionWizardPage::FilesSelectionWizardPage(GenericProjectWizardDialog *g
|
||||
|
||||
void FilesSelectionWizardPage::initializePage()
|
||||
{
|
||||
m_filesWidget->resetModel(Utils::FilePath::fromString(m_genericProjectWizardDialog->path()),
|
||||
Utils::FilePaths());
|
||||
m_filesWidget->resetModel(m_genericProjectWizardDialog->filePath(), Utils::FilePaths());
|
||||
}
|
||||
|
||||
void FilesSelectionWizardPage::cleanupPage()
|
||||
|
@@ -46,13 +46,14 @@
|
||||
#include <QPixmap>
|
||||
#include <QStyle>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace GenericProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
static const char *const ConfigFileTemplate =
|
||||
const char ConfigFileTemplate[] =
|
||||
"// Add predefined macros for your project here. For example:\n"
|
||||
"// #define THE_ANSWER 42\n"
|
||||
;
|
||||
"// #define THE_ANSWER 42\n";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -79,24 +80,24 @@ GenericProjectWizardDialog::GenericProjectWizardDialog(const Core::BaseFileWizar
|
||||
addPage(m_secondPage);
|
||||
}
|
||||
|
||||
QString GenericProjectWizardDialog::path() const
|
||||
FilePath GenericProjectWizardDialog::filePath() const
|
||||
{
|
||||
return m_firstPage->path();
|
||||
return m_firstPage->filePath();
|
||||
}
|
||||
|
||||
Utils::FilePaths GenericProjectWizardDialog::selectedPaths() const
|
||||
FilePaths GenericProjectWizardDialog::selectedPaths() const
|
||||
{
|
||||
return m_secondPage->selectedPaths();
|
||||
}
|
||||
|
||||
Utils::FilePaths GenericProjectWizardDialog::selectedFiles() const
|
||||
FilePaths GenericProjectWizardDialog::selectedFiles() const
|
||||
{
|
||||
return m_secondPage->selectedFiles();
|
||||
}
|
||||
|
||||
void GenericProjectWizardDialog::setPath(const QString &path)
|
||||
void GenericProjectWizardDialog::setFilePath(const FilePath &path)
|
||||
{
|
||||
m_firstPage->setPath(path);
|
||||
m_firstPage->setFilePath(path);
|
||||
}
|
||||
|
||||
QString GenericProjectWizardDialog::projectName() const
|
||||
@@ -129,7 +130,7 @@ Core::BaseFileWizard *GenericProjectWizard::create(QWidget *parent,
|
||||
{
|
||||
auto wizard = new GenericProjectWizardDialog(this, parent);
|
||||
|
||||
wizard->setPath(parameters.defaultPath());
|
||||
wizard->setFilePath(parameters.defaultPath());
|
||||
|
||||
foreach (QWizardPage *p, wizard->extensionPages())
|
||||
wizard->addPage(p);
|
||||
@@ -143,15 +144,14 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
auto wizard = qobject_cast<const GenericProjectWizardDialog *>(w);
|
||||
const QString projectPath = wizard->path();
|
||||
const QDir dir(projectPath);
|
||||
const FilePath projectPath = wizard->filePath();
|
||||
const QString projectName = wizard->projectName();
|
||||
const QString creatorFileName = QFileInfo(dir, projectName + QLatin1String(".creator")).absoluteFilePath();
|
||||
const QString filesFileName = QFileInfo(dir, projectName + QLatin1String(".files")).absoluteFilePath();
|
||||
const QString includesFileName = QFileInfo(dir, projectName + QLatin1String(".includes")).absoluteFilePath();
|
||||
const QString configFileName = QFileInfo(dir, projectName + QLatin1String(".config")).absoluteFilePath();
|
||||
const QString cxxflagsFileName = QFileInfo(dir, projectName + QLatin1String(".cxxflags")).absoluteFilePath();
|
||||
const QString cflagsFileName = QFileInfo(dir, projectName + QLatin1String(".cflags")).absoluteFilePath();
|
||||
const FilePath creatorFileName = projectPath.pathAppended(projectName + ".creator");
|
||||
const FilePath filesFileName = projectPath.pathAppended(projectName + ".files");
|
||||
const FilePath includesFileName = projectPath.pathAppended(projectName + ".includes");
|
||||
const FilePath configFileName = projectPath.pathAppended(projectName + ".config");
|
||||
const FilePath cxxflagsFileName = projectPath.pathAppended(projectName + ".cxxflags");
|
||||
const FilePath cflagsFileName = projectPath.pathAppended(projectName + ".cflags");
|
||||
const QStringList paths = Utils::transform(wizard->selectedPaths(), &Utils::FilePath::toString);
|
||||
|
||||
Utils::MimeType headerTy = Utils::mimeTypeForName(QLatin1String("text/x-chdr"));
|
||||
@@ -159,6 +159,7 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
|
||||
QStringList nameFilters = headerTy.globPatterns();
|
||||
|
||||
QStringList includePaths;
|
||||
const QDir dir(projectPath.toString());
|
||||
foreach (const QString &path, paths) {
|
||||
QFileInfo fileInfo(path);
|
||||
QDir thisDir(fileInfo.absoluteFilePath());
|
||||
|
@@ -44,8 +44,8 @@ class GenericProjectWizardDialog : public Core::BaseFileWizard
|
||||
public:
|
||||
explicit GenericProjectWizardDialog(const Core::BaseFileWizardFactory *factory, QWidget *parent = nullptr);
|
||||
|
||||
QString path() const;
|
||||
void setPath(const QString &path);
|
||||
Utils::FilePath filePath() const;
|
||||
void setFilePath(const Utils::FilePath &path);
|
||||
Utils::FilePaths selectedFiles() const;
|
||||
Utils::FilePaths selectedPaths() const;
|
||||
|
||||
|
@@ -68,7 +68,7 @@ BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFacto
|
||||
Core::BaseFileWizard(factory, parameters.extraValues(), parent),
|
||||
d(std::make_unique<BaseProjectWizardDialogPrivate>(new Utils::ProjectIntroPage))
|
||||
{
|
||||
setFilePath(FilePath::fromString(parameters.defaultPath()));
|
||||
setFilePath(parameters.defaultPath());
|
||||
setSelectedPlatform(parameters.selectedPlatform());
|
||||
setRequiredFeatures(parameters.requiredFeatures());
|
||||
init();
|
||||
@@ -81,7 +81,7 @@ BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFacto
|
||||
Core::BaseFileWizard(factory, parameters.extraValues(), parent),
|
||||
d(std::make_unique<BaseProjectWizardDialogPrivate>(introPage, introId))
|
||||
{
|
||||
setFilePath(FilePath::fromString(parameters.defaultPath()));
|
||||
setFilePath(parameters.defaultPath());
|
||||
setSelectedPlatform(parameters.selectedPlatform());
|
||||
setRequiredFeatures(parameters.requiredFeatures());
|
||||
init();
|
||||
@@ -161,9 +161,9 @@ Utils::ProjectIntroPage *BaseProjectWizardDialog::introPage() const
|
||||
return d->introPage;
|
||||
}
|
||||
|
||||
QString BaseProjectWizardDialog::uniqueProjectName(const QString &path)
|
||||
QString BaseProjectWizardDialog::uniqueProjectName(const FilePath &path)
|
||||
{
|
||||
const QDir pathDir(path);
|
||||
const QDir pathDir(path.toString());
|
||||
//: File path suggestion for a new project. If you choose
|
||||
//: to translate it, make sure it is a valid path name without blanks
|
||||
//: and using only ascii chars.
|
||||
|
@@ -61,7 +61,7 @@ public:
|
||||
Utils::FilePath filePath() const;
|
||||
|
||||
// Generate a new project name (untitled<n>) in path.
|
||||
static QString uniqueProjectName(const QString &path);
|
||||
static QString uniqueProjectName(const Utils::FilePath &path);
|
||||
void addExtensionPages(const QList<QWizardPage *> &wizardPageList);
|
||||
|
||||
void setIntroDescription(const QString &d);
|
||||
|
@@ -166,7 +166,7 @@ BaseFileWizard *CustomWizard::create(QWidget *parent, const WizardDialogParamete
|
||||
|
||||
d->m_context->reset();
|
||||
auto customPage = new CustomWizardPage(d->m_context, parameters());
|
||||
customPage->setPath(p.defaultPath());
|
||||
customPage->setFilePath(p.defaultPath());
|
||||
if (parameters()->firstPageId >= 0)
|
||||
wizard->setPage(parameters()->firstPageId, customPage);
|
||||
else
|
||||
@@ -506,7 +506,7 @@ BaseFileWizard *CustomProjectWizard::create(QWidget *parent,
|
||||
}
|
||||
|
||||
void CustomProjectWizard::initProjectWizardDialog(BaseProjectWizardDialog *w,
|
||||
const QString &defaultPath,
|
||||
const FilePath &defaultPath,
|
||||
const QList<QWizardPage *> &extensionPages) const
|
||||
{
|
||||
const CustomWizardParametersPtr pa = parameters();
|
||||
@@ -526,7 +526,7 @@ void CustomProjectWizard::initProjectWizardDialog(BaseProjectWizardDialog *w,
|
||||
}
|
||||
for (QWizardPage *ep : extensionPages)
|
||||
w->addPage(ep);
|
||||
w->setFilePath(FilePath::fromString(defaultPath));
|
||||
w->setFilePath(defaultPath);
|
||||
w->setProjectName(BaseProjectWizardDialog::uniqueProjectName(defaultPath));
|
||||
|
||||
connect(w, &BaseProjectWizardDialog::projectParametersChanged,
|
||||
|
@@ -141,7 +141,7 @@ protected:
|
||||
|
||||
bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage) const override;
|
||||
|
||||
void initProjectWizardDialog(BaseProjectWizardDialog *w, const QString &defaultPath,
|
||||
void initProjectWizardDialog(BaseProjectWizardDialog *w, const Utils::FilePath &defaultPath,
|
||||
const QList<QWizardPage *> &extensionPages) const;
|
||||
|
||||
private:
|
||||
|
@@ -437,9 +437,9 @@ FilePath CustomWizardPage::filePath() const
|
||||
return m_pathChooser->filePath();
|
||||
}
|
||||
|
||||
void CustomWizardPage::setPath(const QString &path)
|
||||
void CustomWizardPage::setFilePath(const FilePath &path)
|
||||
{
|
||||
m_pathChooser->setPath(path);
|
||||
m_pathChooser->setFilePath(path);
|
||||
}
|
||||
|
||||
bool CustomWizardPage::isComplete() const
|
||||
|
@@ -127,7 +127,7 @@ public:
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
Utils::FilePath filePath() const;
|
||||
void setPath(const QString &path);
|
||||
void setFilePath(const Utils::FilePath &path);
|
||||
|
||||
bool isComplete() const override;
|
||||
|
||||
|
@@ -47,17 +47,17 @@ void JsonFilePage::initializePage()
|
||||
|
||||
if (fileName().isEmpty())
|
||||
setFileName(wiz->stringValue(QLatin1String("InitialFileName")));
|
||||
if (path().isEmpty())
|
||||
if (filePath().isEmpty())
|
||||
setPath(wiz->stringValue(QLatin1String("InitialPath")));
|
||||
setDefaultSuffix(wiz->stringValue("DefaultSuffix"));
|
||||
}
|
||||
|
||||
bool JsonFilePage::validatePage()
|
||||
{
|
||||
if (path().isEmpty() || fileName().isEmpty())
|
||||
if (filePath().isEmpty() || fileName().isEmpty())
|
||||
return false;
|
||||
|
||||
const FilePath dir = FilePath::fromString(path());
|
||||
const FilePath dir = filePath();
|
||||
if (!dir.isDir())
|
||||
return false;
|
||||
|
||||
|
@@ -148,8 +148,8 @@ public:
|
||||
addPage(m_secondPage);
|
||||
}
|
||||
|
||||
QString path() const { return m_firstPage->path(); }
|
||||
void setPath(const QString &path) { m_firstPage->setPath(path); }
|
||||
Utils::FilePath projectDir() const { return m_firstPage->filePath(); }
|
||||
void setProjectDir(const Utils::FilePath &path) { m_firstPage->setFilePath(path); }
|
||||
FilePaths selectedFiles() const { return m_secondPage->selectedFiles(); }
|
||||
FilePaths selectedPaths() const { return m_secondPage->selectedPaths(); }
|
||||
QString qtModules() const { return m_secondPage->qtModules(); }
|
||||
@@ -162,8 +162,7 @@ public:
|
||||
|
||||
void FilesSelectionWizardPage::initializePage()
|
||||
{
|
||||
m_filesWidget->resetModel(FilePath::fromString(m_simpleProjectWizardDialog->path()),
|
||||
FilePaths());
|
||||
m_filesWidget->resetModel(m_simpleProjectWizardDialog->projectDir(), FilePaths());
|
||||
}
|
||||
|
||||
SimpleProjectWizard::SimpleProjectWizard()
|
||||
@@ -187,7 +186,7 @@ BaseFileWizard *SimpleProjectWizard::create(QWidget *parent,
|
||||
const WizardDialogParameters ¶meters) const
|
||||
{
|
||||
auto wizard = new SimpleProjectWizardDialog(this, parent);
|
||||
wizard->setPath(parameters.defaultPath());
|
||||
wizard->setProjectDir(parameters.defaultPath());
|
||||
|
||||
for (QWizardPage *p : wizard->extensionPages())
|
||||
wizard->addPage(p);
|
||||
@@ -199,7 +198,7 @@ GeneratedFiles generateQmakeFiles(const SimpleProjectWizardDialog *wizard,
|
||||
QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
const QString projectPath = wizard->path();
|
||||
const QString projectPath = wizard->projectDir().toString();
|
||||
const QDir dir(projectPath);
|
||||
const QString projectName = wizard->projectName();
|
||||
const FilePath proFileName = Utils::FilePath::fromString(QFileInfo(dir, projectName + ".pro").absoluteFilePath());
|
||||
@@ -257,8 +256,7 @@ GeneratedFiles generateCmakeFiles(const SimpleProjectWizardDialog *wizard,
|
||||
QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
const QString projectPath = wizard->path();
|
||||
const QDir dir(projectPath);
|
||||
const QDir dir(wizard->projectDir().toString());
|
||||
const QString projectName = wizard->projectName();
|
||||
const FilePath projectFileName = Utils::FilePath::fromString(QFileInfo(dir, "CMakeLists.txt").absoluteFilePath());
|
||||
const QStringList paths = Utils::transform(wizard->selectedPaths(), &FilePath::toString);
|
||||
|
@@ -32,19 +32,17 @@
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
// ----------- QtProjectParameters
|
||||
QtProjectParameters::QtProjectParameters() = default;
|
||||
|
||||
QString QtProjectParameters::projectPath() const
|
||||
FilePath QtProjectParameters::projectPath() const
|
||||
{
|
||||
QString rc = path;
|
||||
if (!rc.isEmpty())
|
||||
rc += QLatin1Char('/');
|
||||
rc += fileName;
|
||||
return rc;
|
||||
return path / fileName;
|
||||
}
|
||||
|
||||
// Write out a QT module line.
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -41,14 +43,15 @@ QString createMacro(const QString &name, const QString &suffix);
|
||||
// Base parameters for application project generation with functionality to
|
||||
// write a .pro-file section.
|
||||
|
||||
struct QtProjectParameters {
|
||||
struct QtProjectParameters
|
||||
{
|
||||
enum Type { ConsoleApp, GuiApp, StaticLibrary, SharedLibrary, QtPlugin, EmptyProject };
|
||||
enum QtVersionSupport { SupportQt4And5, SupportQt4Only, SupportQt5Only };
|
||||
enum Flags { WidgetsRequiredFlag = 0x1 };
|
||||
|
||||
QtProjectParameters();
|
||||
// Return project path as "path/name"
|
||||
QString projectPath() const;
|
||||
Utils::FilePath projectPath() const;
|
||||
void writeProFile(QTextStream &) const;
|
||||
static void writeProFileHeader(QTextStream &);
|
||||
|
||||
@@ -62,7 +65,7 @@ struct QtProjectParameters {
|
||||
QtVersionSupport qtVersionSupport = SupportQt4And5;
|
||||
QString fileName;
|
||||
QString target;
|
||||
QString path;
|
||||
Utils::FilePath path;
|
||||
QStringList selectedModules;
|
||||
QStringList deselectedModules;
|
||||
QString targetDirectory;
|
||||
|
@@ -36,6 +36,8 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -70,8 +72,8 @@ Core::GeneratedFiles SubdirsProjectWizard::generateFiles(const QWizard *w,
|
||||
{
|
||||
const auto *wizard = qobject_cast< const SubdirsProjectWizardDialog *>(w);
|
||||
const QtProjectParameters params = wizard->parameters();
|
||||
const QString projectPath = params.projectPath();
|
||||
const QString profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, params.fileName, profileSuffix());
|
||||
const FilePath projectPath = params.projectPath();
|
||||
const FilePath profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, params.fileName, profileSuffix());
|
||||
|
||||
Core::GeneratedFile profile(profileName);
|
||||
profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute | Core::GeneratedFile::OpenEditorAttribute);
|
||||
@@ -85,10 +87,10 @@ bool SubdirsProjectWizard::postGenerateFiles(const QWizard *w, const Core::Gener
|
||||
const auto *wizard = qobject_cast< const SubdirsProjectWizardDialog *>(w);
|
||||
if (QtWizard::qt4ProjectPostGenerateFiles(wizard, files, errorMessage)) {
|
||||
const QtProjectParameters params = wizard->parameters();
|
||||
const QString projectPath = params.projectPath();
|
||||
const QString profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, params.fileName, profileSuffix());
|
||||
const FilePath projectPath = params.projectPath();
|
||||
const FilePath profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, params.fileName, profileSuffix());
|
||||
QVariantMap map;
|
||||
map.insert(QLatin1String(ProjectExplorer::Constants::PREFERRED_PROJECT_NODE), profileName);
|
||||
map.insert(QLatin1String(ProjectExplorer::Constants::PREFERRED_PROJECT_NODE), profileName.toVariant());
|
||||
map.insert(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS),
|
||||
Utils::transform<QStringList>(wizard->selectedKits(), &Utils::Id::toString));
|
||||
IWizardFactory::requestNewItemDialog(tr("New Subproject", "Title of dialog"),
|
||||
@@ -96,7 +98,7 @@ bool SubdirsProjectWizard::postGenerateFiles(const QWizard *w, const Core::Gener
|
||||
[](Core::IWizardFactory *f) {
|
||||
return f->supportedProjectTypes().contains(Constants::QMAKEPROJECT_ID);
|
||||
}),
|
||||
Utils::FilePath::fromString(wizard->parameters().projectPath()),
|
||||
wizard->parameters().projectPath(),
|
||||
map);
|
||||
} else {
|
||||
return false;
|
||||
|
@@ -55,7 +55,7 @@ QtProjectParameters SubdirsProjectWizardDialog::parameters() const
|
||||
QtProjectParameters rc;
|
||||
rc.type = QtProjectParameters::EmptyProject;
|
||||
rc.fileName = projectName();
|
||||
rc.path = filePath().toString();
|
||||
rc.path = filePath();
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user