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 \ ...@@ -24,7 +24,6 @@ SOURCES += $$PWD/environment.cpp \
$$PWD/pathlisteditor.cpp \ $$PWD/pathlisteditor.cpp \
$$PWD/wizard.cpp \ $$PWD/wizard.cpp \
$$PWD/filewizardpage.cpp \ $$PWD/filewizardpage.cpp \
$$PWD/filewizarddialog.cpp \
$$PWD/filesystemwatcher.cpp \ $$PWD/filesystemwatcher.cpp \
$$PWD/projectintropage.cpp \ $$PWD/projectintropage.cpp \
$$PWD/filenamevalidatinglineedit.cpp \ $$PWD/filenamevalidatinglineedit.cpp \
...@@ -108,7 +107,6 @@ HEADERS += \ ...@@ -108,7 +107,6 @@ HEADERS += \
$$PWD/pathlisteditor.h \ $$PWD/pathlisteditor.h \
$$PWD/wizard.h \ $$PWD/wizard.h \
$$PWD/filewizardpage.h \ $$PWD/filewizardpage.h \
$$PWD/filewizarddialog.h \
$$PWD/filesystemwatcher.h \ $$PWD/filesystemwatcher.h \
$$PWD/projectintropage.h \ $$PWD/projectintropage.h \
$$PWD/filenamevalidatinglineedit.h \ $$PWD/filenamevalidatinglineedit.h \
......
...@@ -83,8 +83,6 @@ QtcLibrary { ...@@ -83,8 +83,6 @@ QtcLibrary {
"filesystemwatcher.h", "filesystemwatcher.h",
"fileutils.cpp", "fileutils.cpp",
"fileutils.h", "fileutils.h",
"filewizarddialog.cpp",
"filewizarddialog.h",
"filewizardpage.cpp", "filewizardpage.cpp",
"filewizardpage.h", "filewizardpage.h",
"filewizardpage.ui", "filewizardpage.ui",
......
...@@ -30,5 +30,5 @@ ...@@ -30,5 +30,5 @@
#include "basefilewizard.h" #include "basefilewizard.h"
Core::BaseFileWizard::BaseFileWizard(QWidget *parent) : Core::BaseFileWizard::BaseFileWizard(QWidget *parent) :
Utils::FileWizardDialog(parent) Utils::Wizard(parent)
{ } { }
...@@ -32,11 +32,11 @@ ...@@ -32,11 +32,11 @@
#include "core_global.h" #include "core_global.h"
#include <utils/filewizarddialog.h> #include <utils/wizard.h>
namespace Core { namespace Core {
class CORE_EXPORT BaseFileWizard : public Utils::FileWizardDialog class CORE_EXPORT BaseFileWizard : public Utils::Wizard
{ {
Q_OBJECT Q_OBJECT
......
...@@ -36,7 +36,8 @@ ...@@ -36,7 +36,8 @@
#include "editormanager/editormanager.h" #include "editormanager/editormanager.h"
#include "dialogs/promptoverwritedialog.h" #include "dialogs/promptoverwritedialog.h"
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <utils/filewizarddialog.h> #include <utils/filewizardpage.h>
#include <utils/wizard.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/stringutils.h> #include <utils/stringutils.h>
...@@ -504,10 +505,14 @@ QString BaseFileWizardFactory::preferredSuffix(const QString &mimeType) ...@@ -504,10 +505,14 @@ QString BaseFileWizardFactory::preferredSuffix(const QString &mimeType)
BaseFileWizard *StandardFileWizardFactory::create(QWidget *parent, const WizardDialogParameters &parameters) const BaseFileWizard *StandardFileWizardFactory::create(QWidget *parent, const WizardDialogParameters &parameters) const
{ {
BaseFileWizard *wizard = new BaseFileWizard(parent); BaseFileWizard *wizard = new BaseFileWizard(parent);
if (parameters.flags().testFlag(WizardDialogParameters::ForceCapitalLetterForFileName))
wizard->setForceFirstCapitalLetterForFileName(true);
wizard->setWindowTitle(tr("New %1").arg(displayName())); 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()) foreach (QWizardPage *p, parameters.extensionPages())
wizard->addPage(p); wizard->addPage(p);
return wizard; return wizard;
...@@ -520,10 +525,11 @@ BaseFileWizard *StandardFileWizardFactory::create(QWidget *parent, const WizardD ...@@ -520,10 +525,11 @@ BaseFileWizard *StandardFileWizardFactory::create(QWidget *parent, const WizardD
GeneratedFiles StandardFileWizardFactory::generateFiles(const QWizard *w, GeneratedFiles StandardFileWizardFactory::generateFiles(const QWizard *w,
QString *errorMessage) const QString *errorMessage) const
{ {
const Utils::FileWizardDialog *standardWizardDialog = qobject_cast<const Utils::FileWizardDialog *>(w); const Utils::Wizard *wizard = qobject_cast<const Utils::Wizard *>(w);
return generateFilesFromPath(standardWizardDialog->path(), Utils::FileWizardPage *page = wizard->find<Utils::FileWizardPage>();
standardWizardDialog->fileName(), QTC_ASSERT(page, return GeneratedFiles());
errorMessage);
return generateFilesFromPath(page->path(), page->fileName(), errorMessage);
} }
} // namespace Core } // namespace Core
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <coreplugin/basefilewizardfactory.h> #include <coreplugin/basefilewizardfactory.h>
#include <utils/wizard.h> #include <utils/wizard.h>
namespace Utils { class FileWizardPage; }
namespace GenericProjectManager { namespace GenericProjectManager {
namespace Internal { namespace Internal {
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <coreplugin/basefilewizard.h> #include <coreplugin/basefilewizard.h>
#include <utils/filewizardpage.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QFileInfo> #include <QFileInfo>
...@@ -51,8 +52,11 @@ Core::GeneratedFiles GLSLFileWizard::generateFiles(const QWizard *w, ...@@ -51,8 +52,11 @@ Core::GeneratedFiles GLSLFileWizard::generateFiles(const QWizard *w,
QString * /*errorMessage*/) const QString * /*errorMessage*/) const
{ {
const Core::BaseFileWizard *wizard = qobject_cast<const Core::BaseFileWizard *>(w); const Core::BaseFileWizard *wizard = qobject_cast<const Core::BaseFileWizard *>(w);
const QString path = wizard->path(); Utils::FileWizardPage *page = wizard->find<Utils::FileWizardPage>();
const QString name = wizard->fileName(); 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)); const QString fileName = Core::BaseFileWizardFactory::buildFileName(path, name, preferredSuffix(m_shaderType));
...@@ -120,7 +124,10 @@ Core::BaseFileWizard *GLSLFileWizard::create(QWidget *parent, const Core::Wizard ...@@ -120,7 +124,10 @@ Core::BaseFileWizard *GLSLFileWizard::create(QWidget *parent, const Core::Wizard
{ {
Core::BaseFileWizard *wizard = new Core::BaseFileWizard(parent); Core::BaseFileWizard *wizard = new Core::BaseFileWizard(parent);
wizard->setWindowTitle(tr("New %1").arg(displayName())); 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()) foreach (QWizardPage *p, parameters.extensionPages())
wizard->addPage(p); wizard->addPage(p);
return wizard; return wizard;
......
...@@ -37,6 +37,9 @@ ...@@ -37,6 +37,9 @@
#include <coreplugin/basefilewizard.h> #include <coreplugin/basefilewizard.h>
#include <texteditor/textfilewizard.h> #include <texteditor/textfilewizard.h>
#include <utils/filewizardpage.h>
#include <utils/qtcassert.h>
#include <QWizard> #include <QWizard>
namespace PythonEditor { namespace PythonEditor {
...@@ -65,7 +68,11 @@ Core::BaseFileWizard *FileWizard::create(QWidget *parent, const Core::WizardDial ...@@ -65,7 +68,11 @@ Core::BaseFileWizard *FileWizard::create(QWidget *parent, const Core::WizardDial
{ {
Core::BaseFileWizard *wizard = new Core::BaseFileWizard(parent); Core::BaseFileWizard *wizard = new Core::BaseFileWizard(parent);
wizard->setWindowTitle(tr("New %1").arg(displayName())); 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()) foreach (QWizardPage *p, parameters.extensionPages())
wizard->addPage(p); wizard->addPage(p);
...@@ -77,11 +84,14 @@ Core::GeneratedFiles FileWizard::generateFiles(const QWizard *dialog, ...@@ -77,11 +84,14 @@ Core::GeneratedFiles FileWizard::generateFiles(const QWizard *dialog,
{ {
Q_UNUSED(errorMessage) Q_UNUSED(errorMessage)
const Utils::FileWizardDialog *pWizard = const Core::BaseFileWizard *wizard =
qobject_cast<const Utils::FileWizardDialog *>(dialog); qobject_cast<const Core::BaseFileWizard *>(dialog);
Utils::FileWizardPage *page = wizard->find<Utils::FileWizardPage>();
QTC_ASSERT(page, return Core::GeneratedFiles());
QString folder = pWizard->path(); QString folder = page->path();
QString name = pWizard->fileName(); QString name = page->fileName();
name = Core::BaseFileWizardFactory::buildFileName( name = Core::BaseFileWizardFactory::buildFileName(
folder, name, QLatin1String(Constants::C_PY_EXTENSION)); folder, name, QLatin1String(Constants::C_PY_EXTENSION));
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <coreplugin/basefilewizard.h> #include <coreplugin/basefilewizard.h>
#include <utils/filewizardpage.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QFileInfo> #include <QFileInfo>
...@@ -77,13 +78,11 @@ class JsFileWizardDialog : public Core::BaseFileWizard ...@@ -77,13 +78,11 @@ class JsFileWizardDialog : public Core::BaseFileWizard
Q_OBJECT Q_OBJECT
public: public:
JsFileWizardDialog(QWidget *parent = 0) : JsFileWizardDialog(QWidget *parent = 0) :
Core::BaseFileWizard(parent), Core::BaseFileWizard(parent)
m_optionsPage(new JsFileOptionsPage)
{ {
addPage(m_optionsPage); addPage(new Utils::FileWizardPage);
addPage(new JsFileOptionsPage);
} }
JsFileOptionsPage *m_optionsPage;
}; };
} // anonymous namespace } // anonymous namespace
...@@ -96,15 +95,21 @@ JsFileWizard::JsFileWizard() ...@@ -96,15 +95,21 @@ JsFileWizard::JsFileWizard()
Core::GeneratedFiles JsFileWizard::generateFiles(const QWizard *w, Core::GeneratedFiles JsFileWizard::generateFiles(const QWizard *w,
QString * /*errorMessage*/) const QString * /*errorMessage*/) const
{ {
const JsFileWizardDialog *wizardDialog = qobject_cast<const JsFileWizardDialog *>(w); const Core::BaseFileWizard *wizard = qobject_cast<const Core::BaseFileWizard *>(w);
const QString path = wizardDialog->path(); Utils::FileWizardPage *filePage = wizard->find<Utils::FileWizardPage>();
const QString name = wizardDialog->fileName(); 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 mimeType = QLatin1String(QmlJSTools::Constants::JS_MIMETYPE);
const QString fileName = Core::BaseFileWizardFactory::buildFileName(path, name, preferredSuffix(mimeType)); const QString fileName = Core::BaseFileWizardFactory::buildFileName(path, name, preferredSuffix(mimeType));
Core::GeneratedFile file(fileName); Core::GeneratedFile file(fileName);
file.setContents(fileContents(fileName, wizardDialog->m_optionsPage->statelessLibrary())); file.setContents(fileContents(fileName, optionPage->statelessLibrary()));
file.setAttributes(Core::GeneratedFile::OpenEditorAttribute); file.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
return Core::GeneratedFiles() << file; return Core::GeneratedFiles() << file;
} }
...@@ -125,12 +130,15 @@ QString JsFileWizard::fileContents(const QString &, bool statelessLibrary) const ...@@ -125,12 +130,15 @@ QString JsFileWizard::fileContents(const QString &, bool statelessLibrary) const
Core::BaseFileWizard *JsFileWizard::create(QWidget *parent, const Core::WizardDialogParameters &parameters) const Core::BaseFileWizard *JsFileWizard::create(QWidget *parent, const Core::WizardDialogParameters &parameters) const
{ {
JsFileWizardDialog *wizardDialog = new JsFileWizardDialog(parent); JsFileWizardDialog *wizard = new JsFileWizardDialog(parent);
wizardDialog->setWindowTitle(tr("New %1").arg(displayName())); wizard->setWindowTitle(tr("New %1").arg(displayName()));
wizardDialog->setPath(parameters.defaultPath());
Utils::FileWizardPage *page = wizard->find<Utils::FileWizardPage>();
page->setPath(parameters.defaultPath());
foreach (QWizardPage *p, parameters.extensionPages()) foreach (QWizardPage *p, parameters.extensionPages())
wizardDialog->addPage(p); wizard->addPage(p);
return wizardDialog; return wizard;
} }
#include "jsfilewizard.moc" #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