OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / projectexplorer / projectwizardpage.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #include "projectwizardpage.h"
34 #include "ui_projectwizardpage.h"
35
36 #include <QtCore/QDir>
37 #include <QtCore/QTextStream>
38
39 using namespace ProjectExplorer;
40 using namespace Internal;
41
42 ProjectWizardPage::ProjectWizardPage(QWidget *parent) :
43     QWizardPage(parent),
44     m_ui(new Ui::WizardPage)
45 {
46     m_ui->setupUi(this);
47     connect(m_ui->projectComboBox, SIGNAL(currentIndexChanged(int)),
48             this, SLOT(slotProjectChanged(int)));
49     setProperty("shortTitle", tr("Summary"));
50 }
51
52 ProjectWizardPage::~ProjectWizardPage()
53 {
54     delete m_ui;
55 }
56
57 void ProjectWizardPage::setProjects(const QStringList &p)
58 {
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);
63 }
64
65 void ProjectWizardPage::setProjectToolTips(const QStringList &t)
66 {
67     m_projectToolTips = t;
68 }
69
70 int ProjectWizardPage::currentProjectIndex() const
71 {
72     return m_ui->projectComboBox->currentIndex();
73 }
74
75 void ProjectWizardPage::setCurrentProjectIndex(int idx)
76 {
77     m_ui->projectComboBox->setCurrentIndex(idx);
78 }
79
80 void ProjectWizardPage::setNoneLabel(const QString &label)
81 {
82     m_ui->projectComboBox->setItemText(0, label);
83 }
84
85 void ProjectWizardPage::setAdditionalInfo(const QString &text)
86 {
87     m_ui->additionalInfo->setText(text);
88     m_ui->additionalInfo->setVisible(!text.isEmpty());
89 }
90
91 void ProjectWizardPage::setVersionControls(const QStringList &vcs)
92 {
93     m_ui->addToVersionControlComboBox->clear();
94     m_ui->addToVersionControlComboBox->addItems(vcs);
95 }
96
97 int ProjectWizardPage::versionControlIndex() const
98 {
99     return m_ui->addToVersionControlComboBox->currentIndex();
100 }
101
102 void ProjectWizardPage::setVersionControlIndex(int idx)
103 {
104     m_ui->addToVersionControlComboBox->setCurrentIndex(idx);
105 }
106
107 void ProjectWizardPage::changeEvent(QEvent *e)
108 {
109     QWizardPage::changeEvent(e);
110     switch (e->type()) {
111     case QEvent::LanguageChange:
112         m_ui->retranslateUi(this);
113         break;
114     default:
115         break;
116     }
117 }
118
119 void ProjectWizardPage::setFilesDisplay(const QString &commonPath, const QStringList &files)
120 {
121     QString fileMessage;
122     {
123         QTextStream str(&fileMessage);
124         str << "<qt>"
125             << (commonPath.isEmpty() ? tr("Files to be added:") : tr("Files to be added in"))
126             << "<pre>";
127         if (commonPath.isEmpty()) {
128             foreach(const QString &f, files)
129                 str << QDir::toNativeSeparators(f) << '\n';
130         } else {
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';
135         }
136         str << "</pre>";
137     }
138     m_ui->filesLabel->setText(fileMessage);
139 }
140
141 void ProjectWizardPage::setProjectToolTip(const QString &tt)
142 {
143     m_ui->projectComboBox->setToolTip(tt);
144     m_ui->projectLabel->setToolTip(tt);
145 }
146
147 void ProjectWizardPage::slotProjectChanged(int index)
148 {
149     setProjectToolTip(index >= 0 && index < m_projectToolTips.size() ?
150                       m_projectToolTips.at(index) : QString());
151 }