OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / qt-maemo / maemopublishingresultpagefremantlefree.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 "maemopublishingresultpagefremantlefree.h"
33 #include "ui_maemopublishingresultpagefremantlefree.h"
34
35 #include <QtGui/QAbstractButton>
36
37 namespace Qt4ProjectManager {
38 namespace Internal {
39 typedef MaemoPublisherFremantleFree MPFF;
40
41 MaemoPublishingResultPageFremantleFree::MaemoPublishingResultPageFremantleFree(MPFF *publisher,
42     QWidget *parent) : QWizardPage(parent), m_publisher(publisher),
43     ui(new Ui::MaemoPublishingResultPageFremantleFree)
44 {
45     m_lastOutputType = MPFF::StatusOutput;
46     ui->setupUi(this);
47 }
48
49 MaemoPublishingResultPageFremantleFree::~MaemoPublishingResultPageFremantleFree()
50 {
51     delete ui;
52 }
53
54 void MaemoPublishingResultPageFremantleFree::initializePage()
55 {
56     cancelButton()->disconnect();
57     connect(cancelButton(), SIGNAL(clicked()), SLOT(handleCancelRequest()));
58     connect(m_publisher, SIGNAL(finished()), SLOT(handleFinished()));
59     connect(m_publisher,
60         SIGNAL(progressReport(QString, MaemoPublisherFremantleFree::OutputType)),
61         SLOT(handleProgress(QString, MaemoPublisherFremantleFree::OutputType)));
62     m_publisher->publish();
63 }
64
65 void MaemoPublishingResultPageFremantleFree::handleFinished()
66 {
67     handleProgress(m_publisher->resultString(), MPFF::StatusOutput);
68     m_isComplete = true;
69     cancelButton()->setEnabled(false);
70     emit completeChanged();
71 }
72
73 void MaemoPublishingResultPageFremantleFree::handleProgress(const QString &text,
74     MPFF::OutputType type)
75 {
76     const QString color = QLatin1String(type == MPFF::StatusOutput
77         || type == MPFF::ToolStatusOutput ? "blue" : "red");
78     ui->progressTextEdit->setTextColor(QColor(color));
79     const bool bold = type == MPFF::StatusOutput
80             || type == MPFF::ErrorOutput ? true : false;
81     QFont font = ui->progressTextEdit->currentFont();
82     font.setBold(bold);
83     ui->progressTextEdit->setCurrentFont(font);
84
85     if (type == MPFF::StatusOutput || type == MPFF::ErrorOutput
86             || m_lastOutputType == MPFF::StatusOutput
87             || m_lastOutputType == MPFF::ErrorOutput) {
88         ui->progressTextEdit->append(text);
89     } else {
90         ui->progressTextEdit->insertPlainText(text);
91     }
92     ui->progressTextEdit->moveCursor(QTextCursor::End);
93     m_lastOutputType = type;
94 }
95
96 void MaemoPublishingResultPageFremantleFree::handleCancelRequest()
97 {
98     cancelButton()->setEnabled(false);
99     m_publisher->cancel();
100 }
101
102 QAbstractButton *MaemoPublishingResultPageFremantleFree::cancelButton() const
103 {
104     return wizard()->button(QWizard::CancelButton);
105 }
106
107 } // namespace Internal
108 } // namespace Qt4ProjectManager