Commit 9ba80402 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Utils: Remove FileWizard class altogether



This fixes the regression where two Location pages were added
before.

Change-Id: Ic3241d707ad8dcf6fc3063bb4613dce49001e196
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent b2292312
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "filewizarddialog.h"
#include "filewizardpage.h"
#include <QAbstractButton>
/*!
\class Utils::FileWizardDialog
\brief The FileWizardDialog class is a standard wizard for a single file
letting the user choose name and path.
Custom pages can be added via Core::IWizardExtension.
*/
namespace Utils {
FileWizardDialog::FileWizardDialog(QWidget *parent) :
Wizard(parent),
m_filePage(new FileWizardPage)
{
addPage(m_filePage);
connect(m_filePage, SIGNAL(activated()), button(QWizard::FinishButton), SLOT(animateClick()));
}
QString FileWizardDialog::fileName() const
{
return m_filePage->fileName();
}
QString FileWizardDialog::path() const
{
return m_filePage->path();
}
bool FileWizardDialog::forceFirstCapitalLetterForFileName() const
{
return m_filePage->forceFirstCapitalLetterForFileName();
}
void FileWizardDialog::setForceFirstCapitalLetterForFileName(bool b)
{
m_filePage->setForceFirstCapitalLetterForFileName(b);
}
void FileWizardDialog::setPath(const QString &path)
{
m_filePage->setPath(path);
}
void FileWizardDialog::setFileName(const QString &name)
{
m_filePage->setFileName(name);
}
} // namespace Utils
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef FILEWIZARDDIALOG_H
#define FILEWIZARDDIALOG_H
#include "wizard.h"
namespace Utils {
class FileWizardPage;
class QTCREATOR_UTILS_EXPORT FileWizardDialog : public Wizard
{
Q_OBJECT
public:
explicit FileWizardDialog(QWidget *parent = 0);
QString fileName() const;
QString path() const;
bool forceFirstCapitalLetterForFileName() const;
void setForceFirstCapitalLetterForFileName(bool b);
public slots:
void setPath(const QString &path);
void setFileName(const QString &name);
private:
FileWizardPage *m_filePage;
};
} // namespace Utils
#endif // FILEWIZARDDIALOG_H
......@@ -24,7 +24,6 @@ SOURCES += $$PWD/environment.cpp \
$$PWD/pathlisteditor.cpp \
$$PWD/wizard.cpp \
$$PWD/filewizardpage.cpp \
$$PWD/filewizarddialog.cpp \
$$PWD/filesystemwatcher.cpp \
$$PWD/projectintropage.cpp \
$$PWD/filenamevalidatinglineedit.cpp \
......@@ -108,7 +107,6 @@ HEADERS += \
$$PWD/pathlisteditor.h \
$$PWD/wizard.h \
$$PWD/filewizardpage.h \
$$PWD/filewizarddialog.h \
$$PWD/filesystemwatcher.h \
$$PWD/projectintropage.h \
$$PWD/filenamevalidatinglineedit.h \
......
......@@ -83,8 +83,6 @@ QtcLibrary {
"filesystemwatcher.h",
"fileutils.cpp",
"fileutils.h",
"filewizarddialog.cpp",
"filewizarddialog.h",
"filewizardpage.cpp",
"filewizardpage.h",
"filewizardpage.ui",
......
......@@ -30,5 +30,5 @@
#include "basefilewizard.h"
Core::BaseFileWizard::BaseFileWizard(QWidget *parent) :
Utils::FileWizardDialog(parent)
Utils::Wizard(parent)
{ }
......@@ -32,11 +32,11 @@
#include "core_global.h"
#include <utils/filewizarddialog.h>
#include <utils/wizard.h>
namespace Core {
class CORE_EXPORT BaseFileWizard : public Utils::FileWizardDialog
class CORE_EXPORT BaseFileWizard : public Utils::Wizard
{
Q_OBJECT
......
......@@ -36,7 +36,8 @@
#include "editormanager/editormanager.h"
#include "dialogs/promptoverwritedialog.h"
#include <extensionsystem/pluginmanager.h>
#include <utils/filewizarddialog.h>
#include <utils/filewizardpage.h>
#include <utils/wizard.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
......@@ -504,10 +505,14 @@ QString BaseFileWizardFactory::preferredSuffix(const QString &mimeType)
BaseFileWizard *StandardFileWizardFactory::create(QWidget *parent, const WizardDialogParameters &parameters) const
{
BaseFileWizard *wizard = new BaseFileWizard(parent);
if (parameters.flags().testFlag(WizardDialogParameters::ForceCapitalLetterForFileName))
wizard->setForceFirstCapitalLetterForFileName(true);
wizard->setWindowTitle(tr("New %1").arg(displayName()));
wizard->setPath(parameters.defaultPath());
Utils::FileWizardPage *page = new Utils::FileWizardPage;
if (parameters.flags().testFlag(WizardDialogParameters::ForceCapitalLetterForFileName))
page->setForceFirstCapitalLetterForFileName(true);
page->setPath(parameters.defaultPath());
wizard->addPage(page);
foreach (QWizardPage *p, parameters.extensionPages())
wizard->addPage(p);
return wizard;
......@@ -520,10 +525,11 @@ BaseFileWizard *StandardFileWizardFactory::create(QWidget *parent, const WizardD
GeneratedFiles StandardFileWizardFactory::generateFiles(const QWizard *w,
QString *errorMessage) const
{
const Utils::FileWizardDialog *standardWizardDialog = qobject_cast<const Utils::FileWizardDialog *>(w);
return generateFilesFromPath(standardWizardDialog->path(),
standardWizardDialog->fileName(),
errorMessage);
const Utils::Wizard *wizard = qobject_cast<const Utils::Wizard *>(w);
Utils::FileWizardPage *page = wizard->find<Utils::FileWizardPage>();
QTC_ASSERT(page, return GeneratedFiles());
return generateFilesFromPath(page->path(), page->fileName(), errorMessage);
}
} // namespace Core
......
......@@ -34,6 +34,8 @@
#include <coreplugin/basefilewizardfactory.h>
#include <utils/wizard.h>
namespace Utils { class FileWizardPage; }
namespace GenericProjectManager {
namespace Internal {
......
......@@ -32,6 +32,7 @@
#include <coreplugin/basefilewizard.h>
#include <utils/filewizardpage.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
......@@ -51,8 +52,11 @@ Core::GeneratedFiles GLSLFileWizard::generateFiles(const QWizard *w,
QString * /*errorMessage*/) const
{
const Core::BaseFileWizard *wizard = qobject_cast<const Core::BaseFileWizard *>(w);
const QString path = wizard->path();
const QString name = wizard->fileName();
Utils::FileWizardPage *page = wizard->find<Utils::FileWizardPage>();
QTC_ASSERT(page, return Core::GeneratedFiles());
const QString path = page->path();
const QString name = page->fileName();
const QString fileName = Core::BaseFileWizardFactory::buildFileName(path, name, preferredSuffix(m_shaderType));
......@@ -120,7 +124,10 @@ Core::BaseFileWizard *GLSLFileWizard::create(QWidget *parent, const Core::Wizard
{
Core::BaseFileWizard *wizard = new Core::BaseFileWizard(parent);
wizard->setWindowTitle(tr("New %1").arg(displayName()));
wizard->setPath(parameters.defaultPath());
Utils::FileWizardPage *page = new Utils::FileWizardPage;
page->setPath(parameters.defaultPath());
wizard->addPage(page);
foreach (QWizardPage *p, parameters.extensionPages())
wizard->addPage(p);
return wizard;
......
......@@ -37,6 +37,9 @@
#include <coreplugin/basefilewizard.h>
#include <texteditor/textfilewizard.h>
#include <utils/filewizardpage.h>
#include <utils/qtcassert.h>
#include <QWizard>
namespace PythonEditor {
......@@ -65,7 +68,11 @@ Core::BaseFileWizard *FileWizard::create(QWidget *parent, const Core::WizardDial
{
Core::BaseFileWizard *wizard = new Core::BaseFileWizard(parent);
wizard->setWindowTitle(tr("New %1").arg(displayName()));
wizard->setPath(parameters.defaultPath());
Utils::FileWizardPage *page = new Utils::FileWizardPage;
page->setPath(parameters.defaultPath());
wizard->addPage(page);
foreach (QWizardPage *p, parameters.extensionPages())
wizard->addPage(p);
......@@ -77,11 +84,14 @@ Core::GeneratedFiles FileWizard::generateFiles(const QWizard *dialog,
{
Q_UNUSED(errorMessage)
const Utils::FileWizardDialog *pWizard =
qobject_cast<const Utils::FileWizardDialog *>(dialog);
const Core::BaseFileWizard *wizard =
qobject_cast<const Core::BaseFileWizard *>(dialog);
Utils::FileWizardPage *page = wizard->find<Utils::FileWizardPage>();
QTC_ASSERT(page, return Core::GeneratedFiles());
QString folder = pWizard->path();
QString name = pWizard->fileName();
QString folder = page->path();
QString name = page->fileName();
name = Core::BaseFileWizardFactory::buildFileName(
folder, name, QLatin1String(Constants::C_PY_EXTENSION));
......
......@@ -33,6 +33,7 @@
#include <coreplugin/basefilewizard.h>
#include <utils/filewizardpage.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
......@@ -77,13 +78,11 @@ class JsFileWizardDialog : public Core::BaseFileWizard
Q_OBJECT
public:
JsFileWizardDialog(QWidget *parent = 0) :
Core::BaseFileWizard(parent),
m_optionsPage(new JsFileOptionsPage)
Core::BaseFileWizard(parent)
{
addPage(m_optionsPage);
addPage(new Utils::FileWizardPage);
addPage(new JsFileOptionsPage);
}
JsFileOptionsPage *m_optionsPage;
};
} // anonymous namespace
......@@ -96,15 +95,21 @@ JsFileWizard::JsFileWizard()
Core::GeneratedFiles JsFileWizard::generateFiles(const QWizard *w,
QString * /*errorMessage*/) const
{
const JsFileWizardDialog *wizardDialog = qobject_cast<const JsFileWizardDialog *>(w);
const QString path = wizardDialog->path();
const QString name = wizardDialog->fileName();
const Core::BaseFileWizard *wizard = qobject_cast<const Core::BaseFileWizard *>(w);
Utils::FileWizardPage *filePage = wizard->find<Utils::FileWizardPage>();
QTC_ASSERT(filePage, Core::GeneratedFiles());
JsFileOptionsPage *optionPage = wizard->find<JsFileOptionsPage>();
QTC_ASSERT(optionPage, Core::GeneratedFiles());
const QString path = filePage->path();
const QString name = filePage->fileName();
const QString mimeType = QLatin1String(QmlJSTools::Constants::JS_MIMETYPE);
const QString fileName = Core::BaseFileWizardFactory::buildFileName(path, name, preferredSuffix(mimeType));
Core::GeneratedFile file(fileName);
file.setContents(fileContents(fileName, wizardDialog->m_optionsPage->statelessLibrary()));
file.setContents(fileContents(fileName, optionPage->statelessLibrary()));
file.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
return Core::GeneratedFiles() << file;
}
......@@ -125,12 +130,15 @@ QString JsFileWizard::fileContents(const QString &, bool statelessLibrary) const
Core::BaseFileWizard *JsFileWizard::create(QWidget *parent, const Core::WizardDialogParameters &parameters) const
{
JsFileWizardDialog *wizardDialog = new JsFileWizardDialog(parent);
wizardDialog->setWindowTitle(tr("New %1").arg(displayName()));
wizardDialog->setPath(parameters.defaultPath());
JsFileWizardDialog *wizard = new JsFileWizardDialog(parent);
wizard->setWindowTitle(tr("New %1").arg(displayName()));
Utils::FileWizardPage *page = wizard->find<Utils::FileWizardPage>();
page->setPath(parameters.defaultPath());
foreach (QWizardPage *p, parameters.extensionPages())
wizardDialog->addPage(p);
return wizardDialog;
wizard->addPage(p);
return wizard;
}
#include "jsfilewizard.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment