OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / projectexplorer / publishing / publishingwizardselectiondialog.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 "publishingwizardselectiondialog.h"
33 #include "ui_publishingwizardselectiondialog.h"
34
35 #include "ipublishingwizardfactory.h"
36
37 #include <extensionsystem/pluginmanager.h>
38 #include <projectexplorer/project.h>
39 #include <utils/qtcassert.h>
40
41 #include <QtGui/QPushButton>
42
43 namespace ProjectExplorer {
44 namespace Internal {
45
46 PublishingWizardSelectionDialog::PublishingWizardSelectionDialog(const Project *project,
47         QWidget *parent) :
48     QDialog(parent),
49     ui(new Ui::PublishingWizardSelectionDialog),
50     m_project(project)
51 {
52     ui->setupUi(this);
53     ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Start Wizard"));
54     const QList<IPublishingWizardFactory *> &factories
55         = ExtensionSystem::PluginManager::instance()->getObjects<IPublishingWizardFactory>();
56     foreach (const IPublishingWizardFactory * const factory, factories) {
57         if (factory->canCreateWizard(project)) {
58             m_factories << factory;
59             ui->serviceComboBox->addItem(factory->displayName());
60         }
61     }
62     if (!m_factories.isEmpty()) {
63         connect(ui->serviceComboBox, SIGNAL(currentIndexChanged(int)),
64             SLOT(handleWizardIndexChanged(int)));
65         ui->serviceComboBox->setCurrentIndex(0);
66         handleWizardIndexChanged(ui->serviceComboBox->currentIndex());
67     } else {
68         ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
69         ui->descriptionTextArea->appendHtml(QLatin1String("<font color=\"red\">")
70             + tr("Publishing is currently not possible for project '%1'.")
71                   .arg(project->displayName())
72             + QLatin1String("</font>"));
73     }
74 }
75
76 PublishingWizardSelectionDialog::~PublishingWizardSelectionDialog()
77 {
78     delete ui;
79 }
80
81 QWizard *PublishingWizardSelectionDialog::createSelectedWizard() const
82 {
83     return m_factories.at(ui->serviceComboBox->currentIndex())->createWizard(m_project);
84 }
85
86 void PublishingWizardSelectionDialog::handleWizardIndexChanged(int index)
87 {
88     ui->descriptionTextArea->setPlainText(m_factories.at(index)->description());
89 }
90
91 } // namespace Internal
92 } // namespace ProjectExplorer