libKipi
batchprogressdialog.cpp
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of kipi-plugins project
4 * http://www.kipi-plugins.org
5 *
6 * Date : 2004-05-04
7 * Description : Batch progress dialog
8 *
9 * Copyright (C) 2004-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 *
11 * This program is free software; you can redistribute it
12 * and/or modify it under the terms of the GNU General
13 * Public License as published by the Free Software Foundation;
14 * either version 2, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * ============================================================ */
22
23// Include files for Qt
24
25#include <qvbox.h>
26#include <qlayout.h>
27#include <qdir.h>
28#include <qwidget.h>
29#include <qgroupbox.h>
30#include <qwhatsthis.h>
31#include <qcolor.h>
32#include <qhgroupbox.h>
33#include <qvgroupbox.h>
34#include <qheader.h>
35#include <qlistview.h>
36#include <qframe.h>
37#include <qlabel.h>
38#include <qcolor.h>
39#include <qpixmap.h>
40#include <qpushbutton.h>
41
42// Include files for KDE
43
44#include <klocale.h>
45#include <kprogress.h>
46#include <kinstance.h>
47#include <kconfig.h>
48#include <kapplication.h>
49#include <kdebug.h>
50#include <kdialogbase.h>
51#include <kiconloader.h>
52#include <klistview.h>
53#include <kstandarddirs.h>
54#include <kapplication.h>
55#include <kaboutdata.h>
56#include <khelpmenu.h>
57#include <kiconloader.h>
58#include <kpopupmenu.h>
59
60// Include files for libKipi.
61
62#include "libkipi/version.h"
63
64// Local includes
65
66#include "batchprogressdialog.h"
67#include "batchprogressdialog.moc"
68
69namespace KIPI
70{
71
72class BatchProgressItem : public KListViewItem
73{
74public:
75 BatchProgressItem(KListView * parent, QListViewItem *after, const QString &message, int messageType)
76 : KListViewItem( parent, after), m_messagetype(messageType)
77 {
78 // Set the icon.
79
80 switch( m_messagetype )
81 {
83 setPixmap( 0, SmallIcon( "run" ) );
84 break;
86 setPixmap( 0, SmallIcon( "ok" ) );
87 break;
89 setPixmap( 0, SmallIcon( "flag" ) );
90 break;
92 setPixmap( 0, SmallIcon( "stop" ) );
93 break;
95 setPixmap( 0, SmallIcon( "info" ) );
96 break;
97 default:
98 setPixmap( 0, SmallIcon( "info" ) );
99 }
100
101 // Set the message text.
102
103 setText(1, message);
104 }
105
106private:
107 int m_messagetype;
108
109 void paintCell (QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
110 {
111 QColorGroup _cg( cg );
112
113 if ( m_messagetype == KIPI::ErrorMessage )
114 {
115 _cg.setColor( QColorGroup::Text, Qt::red );
116 KListViewItem::paintCell( p, _cg, column, width, alignment );
117 return;
118 }
119
120 if ( m_messagetype == KIPI::WarningMessage )
121 {
122 _cg.setColor( QColorGroup::Text, Qt::darkYellow );
123 KListViewItem::paintCell( p, _cg, column, width, alignment );
124 return;
125 }
126
127 KListViewItem::paintCell( p, cg, column, width, alignment );
128 }
129};
130
131
134
135
137
138BatchProgressDialog::BatchProgressDialog( QWidget *parent, const QString &caption )
139 : KDialogBase( parent, "KIPIBatchProgressDialog", true /* modal */,
140 caption, Cancel)
141{
142 d = new Private;
143 QWidget* box = makeVBoxMainWidget();
144
145 //---------------------------------------------
146
147 m_actionsList = new KListView( box );
148 m_actionsList->addColumn(i18n( "Status" ));
149 m_actionsList->addColumn(i18n( "Current Actions" ));
150 m_actionsList->setSorting(-1);
151 m_actionsList->setItemMargin(1);
152 m_actionsList->header()->hide();
153 m_actionsList->setResizeMode(QListView::LastColumn);
154 QWhatsThis::add( m_actionsList, i18n("<p>This is the current processing status.</p>" ) );
155
156 //---------------------------------------------
157
158 m_progress = new KProgress( box, "Progress" );
159 m_progress->setTotalSteps(100);
160 m_progress->setValue(0);
161 QWhatsThis::add( m_progress, i18n("<p>This is the batch job progress in percentage.</p>") );
162 resize( 600, 400 );
163}
164
165
167
172
173
175
176void BatchProgressDialog::addedAction(const QString &text, int type)
177{
179 m_actionsList->lastItem(),
180 text, type);
181
182 m_actionsList->ensureItemVisible(m_item);
183}
184
185
187{
188 m_actionsList->clear();
189 m_progress->setValue(0);
190}
191
192
193void BatchProgressDialog::setProgress(int current, int total)
194{
195 m_progress->setTotalSteps(total);
196 m_progress->setValue(current);
197}
198
199} // NameSpace KIPI
void reset()
Definition batchprogressdialog.cpp:186
void setProgress(int current, int total)
Definition batchprogressdialog.cpp:193
KListView * m_actionsList
Definition batchprogressdialog.h:70
void addedAction(const QString &text, int type)
Definition batchprogressdialog.cpp:176
KProgress * m_progress
Definition batchprogressdialog.h:71
~BatchProgressDialog()
Definition batchprogressdialog.cpp:168
KIPI::BatchProgressItem * m_item
Definition batchprogressdialog.h:69
BatchProgressDialog(QWidget *parent=0, const QString &caption=QString::null)
Definition batchprogressdialog.cpp:138
Definition batchprogressdialog.cpp:73
BatchProgressItem(KListView *parent, QListViewItem *after, const QString &message, int messageType)
Definition batchprogressdialog.cpp:75
Definition batchprogressdialog.cpp:70
@ StartingMessage
Definition batchprogressdialog.h:47
@ ProgressMessage
Definition batchprogressdialog.h:51
@ SuccessMessage
Definition batchprogressdialog.h:48
@ ErrorMessage
Definition batchprogressdialog.h:50
@ WarningMessage
Definition batchprogressdialog.h:49
Definition batchprogressdialog.cpp:132