/**************************************************************************** ** ** Copyright (C) 2013 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 "formclasswizardpage.h" #include "ui_formclasswizardpage.h" #include "formclasswizardparameters.h" #include #include #include #include #include #include #include #include namespace Designer { namespace Internal { // ----------------- FormClassWizardPage FormClassWizardPage::FormClassWizardPage(QWidget * parent) : QWizardPage(parent), m_ui(new Ui::FormClassWizardPage), m_isValid(false) { m_ui->setupUi(this); m_ui->newClassWidget->setBaseClassInputVisible(false); m_ui->newClassWidget->setNamespacesEnabled(true); m_ui->newClassWidget->setAllowDirectories(true); m_ui->newClassWidget->setClassTypeComboVisible(false); connect(m_ui->newClassWidget, SIGNAL(validChanged()), this, SLOT(slotValidChanged())); initFileGenerationSettings(); } FormClassWizardPage::~FormClassWizardPage() { delete m_ui; } // Retrieve settings of CppTools plugin. bool FormClassWizardPage::lowercaseHeaderFiles() { QString lowerCaseSettingsKey = QLatin1String(CppTools::Constants::CPPTOOLS_SETTINGSGROUP); lowerCaseSettingsKey += QLatin1Char('/'); lowerCaseSettingsKey += QLatin1String(CppTools::Constants::LOWERCASE_CPPFILES_KEY); const bool lowerCaseDefault = CppTools::Constants::lowerCaseFilesDefault; return Core::ICore::settings()->value(lowerCaseSettingsKey, QVariant(lowerCaseDefault)).toBool(); } // Set up new class widget from settings void FormClassWizardPage::initFileGenerationSettings() { const Core::MimeDatabase *mdb = Core::ICore::mimeDatabase(); m_ui->newClassWidget->setHeaderExtension(mdb->preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE))); m_ui->newClassWidget->setSourceExtension(mdb->preferredSuffixByType(QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE))); m_ui->newClassWidget->setLowerCaseFiles(lowercaseHeaderFiles()); } void FormClassWizardPage::setClassName(const QString &suggestedClassName) { // Is it valid, now? m_ui->newClassWidget->setClassName(suggestedClassName); slotValidChanged(); } QString FormClassWizardPage::path() const { return m_ui->newClassWidget->path(); } void FormClassWizardPage::setPath(const QString &p) { m_ui->newClassWidget->setPath(p); } void FormClassWizardPage::getParameters(FormClassWizardParameters *p) const { p->className = m_ui->newClassWidget->className(); p->path = path(); p->sourceFile = m_ui->newClassWidget->sourceFileName(); p->headerFile = m_ui->newClassWidget->headerFileName(); p->uiFile = m_ui->newClassWidget-> formFileName(); } void FormClassWizardPage::slotValidChanged() { const bool validNow = m_ui->newClassWidget->isValid(); if (m_isValid != validNow) { m_isValid = validNow; emit completeChanged(); } } bool FormClassWizardPage::isComplete() const { return m_isValid; } bool FormClassWizardPage::validatePage() { QString errorMessage; const bool rc = m_ui->newClassWidget->isValid(&errorMessage); if (!rc) { QMessageBox::warning(this, tr("%1 - Error").arg(title()), errorMessage); } return rc; } } // namespace Internal } // namespace Designer