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 "cppsettingspage.h"
35 #include "designerconstants.h"
37 #include <QtCore/QCoreApplication>
38 #include <QtCore/QTextStream>
39 #include <coreplugin/icore.h>
44 // ---------- CppSettingsPageWidget
46 CppSettingsPageWidget::CppSettingsPageWidget(QWidget *parent) :
52 FormClassWizardGenerationParameters CppSettingsPageWidget::parameters() const
54 FormClassWizardGenerationParameters rc;
55 rc.embedding = static_cast<UiClassEmbedding>(uiEmbedding());
56 rc.retranslationSupport =m_ui.retranslateCheckBox->isChecked();
57 rc.includeQtModule = m_ui.includeQtModuleCheckBox->isChecked();
61 void CppSettingsPageWidget::setParameters(const FormClassWizardGenerationParameters &p)
63 m_ui.retranslateCheckBox->setChecked(p.retranslationSupport);
64 m_ui.includeQtModuleCheckBox->setChecked(p.includeQtModule);
65 setUiEmbedding(p.embedding);
68 int CppSettingsPageWidget::uiEmbedding() const
70 if (m_ui.ptrAggregationRadioButton->isChecked())
71 return PointerAggregatedUiClass;
72 if (m_ui.aggregationButton->isChecked())
73 return AggregatedUiClass;
74 return InheritedUiClass;
77 void CppSettingsPageWidget::setUiEmbedding(int v)
80 case PointerAggregatedUiClass:
81 m_ui.ptrAggregationRadioButton->setChecked(true);
83 case AggregatedUiClass:
84 m_ui.aggregationButton->setChecked(true);
86 case InheritedUiClass:
87 m_ui.multipleInheritanceButton->setChecked(true);
92 QString CppSettingsPageWidget::searchKeywords() const
95 QTextStream(&rc) << m_ui.ptrAggregationRadioButton->text()
96 << ' ' << m_ui.aggregationButton->text()
97 << ' ' << m_ui.multipleInheritanceButton->text()
98 << ' ' << m_ui.retranslateCheckBox->text()
99 << ' ' << m_ui.includeQtModuleCheckBox->text();
100 rc.remove(QLatin1Char('&'));
104 // ---------- CppSettingsPage
105 CppSettingsPage::CppSettingsPage(QObject *parent) : Core::IOptionsPage(parent)
107 m_parameters.fromSettings(Core::ICore::instance()->settings());
110 QString CppSettingsPage::id() const
112 return QLatin1String(Designer::Constants::SETTINGS_CPP_SETTINGS_ID);
115 QString CppSettingsPage::displayName() const
117 return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_CPP_SETTINGS_NAME);
120 QString CppSettingsPage::category() const
122 return QLatin1String(Designer::Constants::SETTINGS_CATEGORY);
125 QString CppSettingsPage::displayCategory() const
127 return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_TR_CATEGORY);
130 QIcon CppSettingsPage::categoryIcon() const
132 return QIcon(QLatin1String(Designer::Constants::SETTINGS_CATEGORY_ICON));
135 QWidget *CppSettingsPage::createPage(QWidget *parent)
137 m_widget = new CppSettingsPageWidget(parent);
138 m_widget->setParameters(m_parameters);
139 if (m_searchKeywords.isEmpty())
140 m_searchKeywords = m_widget->searchKeywords();
144 void CppSettingsPage::apply()
147 const FormClassWizardGenerationParameters newParameters = m_widget->parameters();
148 if (newParameters != m_parameters) {
149 m_parameters = newParameters;
150 m_parameters.toSettings(Core::ICore::instance()->settings());
155 void CppSettingsPage::finish()
159 bool CppSettingsPage::matches(const QString &s) const
161 return m_searchKeywords.contains(s, Qt::CaseInsensitive);
164 } // namespace Internal
165 } // namespace Designer