~ubuntu-branches/ubuntu/quantal/kdevplatform/quantal-proposed

« back to all changes in this revision

Viewing changes to plugins/git/gitclonejob.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-24 00:06:18 UTC
  • mfrom: (0.3.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101024000618-7otebin77mfcmt3b
Tags: 1.1.0-0ubuntu1
* New upstream release
  - Bump build-dependencies
  - Build against libboost-serialization1.42-dev
  - Update kdevplatform1-libs.install
  - Update kdevplatform-dev.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright 2010 Aleix Pol Gonzalez <aleixpol@kde.org>                  *
 
3
 *                                                                         *
 
4
 *   This program is free software; you can redistribute it and/or         *
 
5
 *   modify it under the terms of the GNU General Public License as        *
 
6
 *   published by the Free Software Foundation; either version 2 of        *
 
7
 *   the License or (at your option) version 3 or any later version        *
 
8
 *   accepted by the membership of KDE e.V. (or its successor approved     *
 
9
 *   by the membership of KDE e.V.), which shall act as a proxy            *
 
10
 *   defined in Section 14 of version 3 of the license.                    *
 
11
 *                                                                         *
 
12
 *   This program is distributed in the hope that it will be useful,       *
 
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
15
 *   GNU General Public License for more details.                          *
 
16
 *                                                                         *
 
17
 *   You should have received a copy of the GNU General Public License     *
 
18
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 
19
 ***************************************************************************/
 
20
 
 
21
#include "gitclonejob.h"
 
22
#include <QDebug>
 
23
 
 
24
GitCloneJob::GitCloneJob(const QDir& d, KDevelop::IPlugin* parent, OutputJobVerbosity verbosity)
 
25
    : DVcsJob(d, parent, verbosity)
 
26
    , m_steps(0)
 
27
{
 
28
    connect(process(), SIGNAL(readyReadStandardError()), SLOT(receivedStderr()));
 
29
}
 
30
void GitCloneJob::receivedStderr()
 
31
{
 
32
    QByteArray out=process()->readAllStandardError();
 
33
    if (out.contains('\n')) {
 
34
        m_steps+=out.count('\n');
 
35
        emitPercent(m_steps, 6); //I'm counting 6 lines so it's a way to provide some progress, probably not the best
 
36
    }
 
37
 
 
38
    int end = qMax(out.lastIndexOf('\n'), out.lastIndexOf('\r'));
 
39
    int start = qMax(qMax(out.lastIndexOf('\n', end-1), out.lastIndexOf('\r', end-1)), 0);
 
40
 
 
41
    QByteArray info=out.mid(start, end-start-1);
 
42
    emit infoMessage(this, info);
 
43
}