1
1
/***************************************************************************
2
2
* This file is part of KDevelop *
3
* Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
3
* Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
4
* Copyright 2010 Aleix Pol Gonzalez <aleixpol@kde.org> *
5
6
* This program is free software; you can redistribute it and/or modify *
6
7
* it under the terms of the GNU Library General Public License as *
21
22
#include "outputmodel.h"
23
24
#include <QtCore/QStringList>
25
#include <QtCore/QTimer>
25
27
#include <kglobalsettings.h>
32
struct OutputModelPrivate
35
QVector<QStandardItem*> pending;
37
static const int MAX_SIZE;
38
static const int INTERVAL_MS;
41
const int OutputModelPrivate::MAX_SIZE=10000;
42
const int OutputModelPrivate::INTERVAL_MS=50;
30
44
OutputModel::OutputModel( QObject* parent )
31
: QStandardItemModel( parent ), d(0)
45
: QStandardItemModel( parent ), d(new OutputModelPrivate)
47
d->timer = new QTimer(this);
48
d->timer->setInterval(OutputModelPrivate::INTERVAL_MS);
49
d->timer->setSingleShot(true);
51
d->pending.reserve(OutputModelPrivate::MAX_SIZE);
53
connect(d->timer, SIGNAL(timeout()), SLOT(addPending()));
56
OutputModel::~OutputModel()
36
62
void OutputModel::appendLine( const QString& line )
38
64
QStandardItem* item = new QStandardItem( line );
39
65
item->setFont( KGlobalSettings::fixedFont() );
67
d->pending.append(item);
68
if(d->pending.size()<OutputModelPrivate::MAX_SIZE)
43
74
void OutputModel::appendLines( const QStringList& lines)