OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / qt-maemo / maemopublishingbuildsettingspagefremantlefree.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 #include "maemopublishingbuildsettingspagefremantlefree.h"
33 #include "ui_maemopublishingbuildsettingspagefremantlefree.h"
34
35 #include "maemoglobal.h"
36 #include "maemopublisherfremantlefree.h"
37
38 #include <projectexplorer/project.h>
39 #include <projectexplorer/target.h>
40 #include <qt4projectmanager/qt4buildconfiguration.h>
41 #include <qt4projectmanager/qt4projectmanagerconstants.h>
42 #include <utils/qtcassert.h>
43
44 using namespace ProjectExplorer;
45
46 namespace Qt4ProjectManager {
47 namespace Internal {
48
49 MaemoPublishingBuildSettingsPageFremantleFree::MaemoPublishingBuildSettingsPageFremantleFree(const Project *project,
50     MaemoPublisherFremantleFree *publisher, QWidget *parent) :
51     QWizardPage(parent),
52     m_publisher(publisher),
53     ui(new Ui::MaemoPublishingWizardPageFremantleFree)
54 {
55     ui->setupUi(this);
56     collectBuildConfigurations(project);
57     QTC_ASSERT(!m_buildConfigs.isEmpty(), return);
58     foreach (const Qt4BuildConfiguration * const bc, m_buildConfigs) {
59         ui->buildConfigComboBox->addItem(bc->displayName());
60     }
61     ui->buildConfigComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow);
62     ui->buildConfigComboBox->setCurrentIndex(0);
63     connect(ui->skipUploadCheckBox, SIGNAL(toggled(bool)),
64         SLOT(handleNoUploadSettingChanged()));
65 }
66
67 MaemoPublishingBuildSettingsPageFremantleFree::~MaemoPublishingBuildSettingsPageFremantleFree()
68 {
69     delete ui;
70 }
71
72 void MaemoPublishingBuildSettingsPageFremantleFree::collectBuildConfigurations(const Project *project)
73 {
74     foreach (const Target *const target, project->targets()) {
75         if (target->id() != QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID))
76             continue;
77         foreach (BuildConfiguration * const bc, target->buildConfigurations()) {
78             Qt4BuildConfiguration * const qt4Bc
79                 = qobject_cast<Qt4BuildConfiguration *>(bc);
80             if (!qt4Bc)
81                 continue;
82             if (MaemoGlobal::version(qt4Bc->qtVersion()) == MaemoGlobal::Maemo5)
83                 m_buildConfigs << qt4Bc;
84         }
85         break;
86     }
87 }
88
89 void MaemoPublishingBuildSettingsPageFremantleFree::initializePage()
90 {
91     ui->skipUploadCheckBox->setChecked(true);
92 }
93
94 bool MaemoPublishingBuildSettingsPageFremantleFree::validatePage()
95 {
96     m_publisher->setBuildConfiguration(m_buildConfigs.at(ui->buildConfigComboBox->currentIndex()));
97     m_publisher->setDoUpload(!skipUpload());
98     return true;
99 }
100
101 void MaemoPublishingBuildSettingsPageFremantleFree::handleNoUploadSettingChanged()
102 {
103     setCommitPage(skipUpload());
104 }
105
106 bool MaemoPublishingBuildSettingsPageFremantleFree::skipUpload() const
107 {
108     return ui->skipUploadCheckBox->isChecked();
109 }
110
111 } // namespace Internal
112 } // namespace Qt4ProjectManager