1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #include "formclasswizarddialog.h"
35 #include "formtemplatewizardpage.h"
36 #include "formclasswizardpage.h"
37 #include "formclasswizardparameters.h"
39 #include <coreplugin/basefilewizard.h>
41 #include <QtCore/QDebug>
42 #include <QtGui/QAbstractButton>
44 enum { FormPageId, ClassPageId };
49 // ----------------- FormClassWizardDialog
50 FormClassWizardDialog::FormClassWizardDialog(const WizardPageList &extensionPages,
52 Utils::Wizard(parent),
53 m_formPage(new FormTemplateWizardPage),
54 m_classPage(new FormClassWizardPage)
56 setWindowTitle(tr("Qt Designer Form Class"));
58 setPage(FormPageId, m_formPage);
59 wizardProgress()->item(FormPageId)->setTitle(tr("Form Template"));
60 connect(m_formPage, SIGNAL(templateActivated()),
61 button(QWizard::NextButton), SLOT(animateClick()));
63 setPage(ClassPageId, m_classPage);
64 wizardProgress()->item(ClassPageId)->setTitle(tr("Class Details"));
66 foreach (QWizardPage *p, extensionPages)
67 Core::BaseFileWizard::applyExtensionPageShortTitle(this, addPage(p));
70 QString FormClassWizardDialog::path() const
72 return m_classPage->path();
75 void FormClassWizardDialog::setPath(const QString &p)
77 m_classPage->setPath(p);
80 bool FormClassWizardDialog::validateCurrentPage()
82 return QWizard::validateCurrentPage();
85 void FormClassWizardDialog::initializePage(int id)
87 QWizard::initializePage(id);
88 // Switching from form to class page: store XML template and set a suitable
89 // class name in the class page based on the form base class
90 if (id == ClassPageId) {
91 QString formBaseClass;
93 m_rawFormTemplate = m_formPage->templateContents();
94 // Strip namespaces from the ui class and suggest it as a new class
96 if (FormTemplateWizardPage::getUIXmlData(m_rawFormTemplate, &formBaseClass, &uiClassName))
97 m_classPage->setClassName(FormTemplateWizardPage::stripNamespaces(uiClassName));
101 FormClassWizardParameters FormClassWizardDialog::parameters() const
103 FormClassWizardParameters rc;
104 m_classPage->getParameters(&rc);
105 // Name the ui class in the Ui namespace after the class specified
106 rc.uiTemplate = FormTemplateWizardPage::changeUiClassName(m_rawFormTemplate, rc.className);
110 } // namespace Internal
111 } // namespace Designer