1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #include "projectwizardpage.h"
34 #include "ui_projectwizardpage.h"
36 #include <QtCore/QDir>
37 #include <QtCore/QTextStream>
39 using namespace ProjectExplorer;
40 using namespace Internal;
42 ProjectWizardPage::ProjectWizardPage(QWidget *parent) :
44 m_ui(new Ui::WizardPage)
47 connect(m_ui->projectComboBox, SIGNAL(currentIndexChanged(int)),
48 this, SLOT(slotProjectChanged(int)));
49 setProperty("shortTitle", tr("Summary"));
52 ProjectWizardPage::~ProjectWizardPage()
57 void ProjectWizardPage::setProjects(const QStringList &p)
59 m_ui->projectComboBox->clear();
60 m_ui->projectComboBox->addItems(p);
61 m_ui->projectComboBox->setEnabled(p.size() > 1);
62 m_ui->projectLabel->setEnabled(p.size() > 1);
65 void ProjectWizardPage::setProjectToolTips(const QStringList &t)
67 m_projectToolTips = t;
70 int ProjectWizardPage::currentProjectIndex() const
72 return m_ui->projectComboBox->currentIndex();
75 void ProjectWizardPage::setCurrentProjectIndex(int idx)
77 m_ui->projectComboBox->setCurrentIndex(idx);
80 void ProjectWizardPage::setNoneLabel(const QString &label)
82 m_ui->projectComboBox->setItemText(0, label);
85 void ProjectWizardPage::setAdditionalInfo(const QString &text)
87 m_ui->additionalInfo->setText(text);
88 m_ui->additionalInfo->setVisible(!text.isEmpty());
91 void ProjectWizardPage::setVersionControls(const QStringList &vcs)
93 m_ui->addToVersionControlComboBox->clear();
94 m_ui->addToVersionControlComboBox->addItems(vcs);
97 int ProjectWizardPage::versionControlIndex() const
99 return m_ui->addToVersionControlComboBox->currentIndex();
102 void ProjectWizardPage::setVersionControlIndex(int idx)
104 m_ui->addToVersionControlComboBox->setCurrentIndex(idx);
107 void ProjectWizardPage::changeEvent(QEvent *e)
109 QWizardPage::changeEvent(e);
111 case QEvent::LanguageChange:
112 m_ui->retranslateUi(this);
119 void ProjectWizardPage::setFilesDisplay(const QString &commonPath, const QStringList &files)
123 QTextStream str(&fileMessage);
125 << (commonPath.isEmpty() ? tr("Files to be added:") : tr("Files to be added in"))
127 if (commonPath.isEmpty()) {
128 foreach(const QString &f, files)
129 str << QDir::toNativeSeparators(f) << '\n';
131 str << QDir::toNativeSeparators(commonPath) << ":\n\n";
132 const int prefixSize = commonPath.size() + 1;
133 foreach(const QString &f, files)
134 str << QDir::toNativeSeparators(f.right(f.size() - prefixSize)) << '\n';
138 m_ui->filesLabel->setText(fileMessage);
141 void ProjectWizardPage::setProjectToolTip(const QString &tt)
143 m_ui->projectComboBox->setToolTip(tt);
144 m_ui->projectLabel->setToolTip(tt);
147 void ProjectWizardPage::slotProjectChanged(int index)
149 setProjectToolTip(index >= 0 && index < m_projectToolTips.size() ?
150 m_projectToolTips.at(index) : QString());