2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-07-17 17:19:23 +02:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2009-07-17 17:19:23 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-07-17 17:19:23 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2009-07-17 17:19:23 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-07-17 17:19:23 +02:00
|
|
|
|
|
|
|
|
#include "checkoutprogresswizardpage.h"
|
|
|
|
|
#include "ui_checkoutprogresswizardpage.h"
|
2013-08-28 21:27:47 +03:00
|
|
|
#include "command.h"
|
|
|
|
|
#include "vcsbaseplugin.h"
|
2009-07-17 17:19:23 +02:00
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QApplication>
|
2009-07-17 17:19:23 +02:00
|
|
|
|
2011-03-28 14:19:17 +02:00
|
|
|
/*!
|
2013-05-23 16:13:55 +02:00
|
|
|
\class VcsBase::Internal::CheckoutProgressWizardPage
|
2011-03-28 14:19:17 +02:00
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The CheckoutProgressWizardPage implements a page showing the
|
|
|
|
|
progress of an initial project checkout.
|
|
|
|
|
|
|
|
|
|
Turns complete when the job succeeds.
|
2011-03-28 14:19:17 +02:00
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
\sa VcsBase::BaseCheckoutWizard
|
2011-03-28 14:19:17 +02:00
|
|
|
*/
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
namespace VcsBase {
|
2009-07-17 17:19:23 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) :
|
|
|
|
|
QWizardPage(parent),
|
|
|
|
|
ui(new Ui::CheckoutProgressWizardPage),
|
|
|
|
|
m_state(Idle)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
2010-03-31 14:48:08 +02:00
|
|
|
setTitle(tr("Checkout"));
|
2009-07-17 17:19:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CheckoutProgressWizardPage::~CheckoutProgressWizardPage()
|
|
|
|
|
{
|
|
|
|
|
if (m_state == Running) // Paranoia!
|
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-28 21:27:47 +03:00
|
|
|
void CheckoutProgressWizardPage::start(Command *command)
|
2009-07-17 17:19:23 +02:00
|
|
|
{
|
2013-08-28 21:27:47 +03:00
|
|
|
if (!command) {
|
2012-03-13 11:26:36 +01:00
|
|
|
ui->logPlainTextEdit->setPlainText(tr("No job running, please abort."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(m_state != Running, return);
|
2013-08-28 21:27:47 +03:00
|
|
|
m_command = command;
|
|
|
|
|
command->setProgressiveOutput(true);
|
|
|
|
|
connect(command, SIGNAL(output(QString)), this, SLOT(slotOutput(QString)));
|
|
|
|
|
connect(command, SIGNAL(finished(bool,int,QVariant)), this, SLOT(slotFinished(bool,int,QVariant)));
|
2009-07-17 17:19:23 +02:00
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
|
|
|
ui->logPlainTextEdit->clear();
|
2010-03-31 14:48:08 +02:00
|
|
|
ui->statusLabel->setText(tr("Checkout started..."));
|
|
|
|
|
ui->statusLabel->setPalette(QPalette());
|
2009-07-17 17:19:23 +02:00
|
|
|
m_state = Running;
|
2013-08-28 21:27:47 +03:00
|
|
|
command->execute();
|
2009-07-17 17:19:23 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-28 21:27:47 +03:00
|
|
|
void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVariant &)
|
2009-07-17 17:19:23 +02:00
|
|
|
{
|
2013-08-28 21:27:47 +03:00
|
|
|
if (ok && exitCode == 0) {
|
|
|
|
|
if (m_state == Running) {
|
|
|
|
|
m_state = Succeeded;
|
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
|
ui->statusLabel->setText(tr("Succeeded."));
|
|
|
|
|
QPalette palette = ui->statusLabel->palette();
|
|
|
|
|
palette.setColor(QPalette::Active, QPalette::Text, Qt::green);
|
|
|
|
|
ui->statusLabel->setPalette(palette);
|
|
|
|
|
emit completeChanged();
|
|
|
|
|
emit terminated(true);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ui->logPlainTextEdit->appendPlainText(m_error);
|
|
|
|
|
if (m_state == Running) {
|
|
|
|
|
m_state = Failed;
|
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
|
ui->statusLabel->setText(tr("Failed."));
|
|
|
|
|
QPalette palette = ui->statusLabel->palette();
|
|
|
|
|
palette.setColor(QPalette::Active, QPalette::Text, Qt::red);
|
|
|
|
|
ui->statusLabel->setPalette(palette);
|
|
|
|
|
emit terminated(false);
|
|
|
|
|
}
|
2009-07-17 17:19:23 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-28 21:27:47 +03:00
|
|
|
void CheckoutProgressWizardPage::slotOutput(const QString &text)
|
2009-07-17 17:19:23 +02:00
|
|
|
{
|
2013-08-28 21:27:47 +03:00
|
|
|
ui->logPlainTextEdit->appendPlainText(text.trimmed());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CheckoutProgressWizardPage::slotError(const QString &text)
|
|
|
|
|
{
|
|
|
|
|
m_error.append(text);
|
2009-07-17 17:19:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CheckoutProgressWizardPage::terminate()
|
|
|
|
|
{
|
2013-08-28 21:27:47 +03:00
|
|
|
if (m_command)
|
|
|
|
|
m_command->terminate();
|
2009-07-17 17:19:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CheckoutProgressWizardPage::isComplete() const
|
|
|
|
|
{
|
|
|
|
|
return m_state == Succeeded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2012-01-07 12:31:48 +01:00
|
|
|
} // namespace VcsBase
|