1 /***************************************************************************
2 * KSystemLog, a system log viewer tool *
3 * Copyright (C) 2007 by Nicolas Ternisien *
4 * nicolas.ternisien@gmail.com *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 ***************************************************************************/
22 #include "loadingBar.h"
25 #include <QPushButton>
27 #include <QProgressBar>
28 #include <QVBoxLayout>
29 #include <QHBoxLayout>
32 #include <kapplication.h>
33 #include <kiconloader.h>
35 class LoadingBarPrivate
{
37 //Attributes managing the position in the files loading of each log
45 QProgressBar
* progressBar
;
49 LoadingBar::LoadingBar(QWidget
* parent
) :
51 d(new LoadingBarPrivate())
54 d
->firstLoading
= true;
56 QHBoxLayout
* widgetLayout
= new QHBoxLayout();
57 setLayout(widgetLayout
);
59 widgetLayout
->addStretch();
61 QVBoxLayout
* layout
= new QVBoxLayout();
62 widgetLayout
->addLayout(layout
);
64 widgetLayout
->addStretch();
66 d
->label
= new QLabel(i18n("Loading Progress..."));
67 d
->label
->setMinimumWidth(250);
68 layout
->addWidget(d
->label
, 1, Qt::AlignBottom
);
70 d
->progressBar
= new QProgressBar();
71 d
->progressBar
->setRange(0, 100);
72 d
->progressBar
->setMinimumWidth(250);
73 layout
->addWidget(d
->progressBar
, 1, Qt::AlignCenter
| Qt::AlignTop
);
77 LoadingBar::~LoadingBar() {
82 QProgressBar
* LoadingBar::progressBar() {
83 return d
->progressBar
;
86 void LoadingBar::startLoading(const LogMode
& logMode
, const LogFile
& logFile
, int fileIndex
, int fileCount
) {
89 d
->progressBar
->setValue(0);
91 //Several files to load
92 if (fileCount
>1 && fileIndex
>=1) {
94 d
->label
->setText(i18np("Loading <b>%2</b>...<br /><i>%3</i>",
95 "Loading <b>%2</b>...<br /><i>%3</i> - (<b>%4</b>/%1 files)",
96 fileCount
, logMode
.name(), logFile
.url().path(), fileIndex
));
98 d
->label
->setText(i18np("Reloading <b>%2</b>...<br /><i>%3</i>",
99 "Reloading <b>%2</b>...<br /><i>%3</i> - (<b>%4</b>/%1 files)",
100 fileCount
, logMode
.name(), logFile
.url().path(), fileIndex
));
105 d
->label
->setText(i18n("Loading <b>%1</b>...<br /><i>%2</i>", logMode
.name(), logFile
.url().path()));
107 d
->label
->setText(i18n("Reloading <b>%1</b>...<br /><i>%2</i>", logMode
.name(), logFile
.url().path()));
112 void LoadingBar::endLoading() {
113 emit
displayed(false);
115 d
->progressBar
->setValue(100);
117 //If the endLoading has been called one time, it means it has already been loaded
118 d
->firstLoading
=false;
122 void LoadingBar::progressLoading() {
123 d
->progressBar
->setValue( d
->progressBar
->value() + 1 );
125 kapp
->processEvents();
128 #include "loadingBar.moc"