1 /***************************************************************************
2     progress_dialog.h
3 
4     Offline Editing Plugin
5     a QGIS plugin
6      --------------------------------------
7     Date                 : 08-Jul-2010
8     Copyright            : (C) 2010 by Sourcepole
9     Email                : info at sourcepole.ch
10  ***************************************************************************
11  *                                                                         *
12  *   This program is free software; you can redistribute it and/or modify  *
13  *   it under the terms of the GNU General Public License as published by  *
14  *   the Free Software Foundation; either version 2 of the License, or     *
15  *   (at your option) any later version.                                   *
16  *                                                                         *
17  ***************************************************************************/
18 
19 #include "offline_editing_progress_dialog.h"
20 
QgsOfflineEditingProgressDialog(QWidget * parent,Qt::WindowFlags fl)21 QgsOfflineEditingProgressDialog::QgsOfflineEditingProgressDialog( QWidget *parent, Qt::WindowFlags fl )
22   : QDialog( parent, fl )
23 {
24   setupUi( this );
25 }
26 
setTitle(const QString & title)27 void QgsOfflineEditingProgressDialog::setTitle( const QString &title )
28 {
29   setWindowTitle( title );
30 }
31 
setCurrentLayer(int layer,int numLayers)32 void QgsOfflineEditingProgressDialog::setCurrentLayer( int layer, int numLayers )
33 {
34   label->setText( tr( "Layer %1 of %2.." ).arg( layer ).arg( numLayers ) );
35   progressBar->reset();
36 }
37 
setupProgressBar(const QString & format,int maximum)38 void QgsOfflineEditingProgressDialog::setupProgressBar( const QString &format, int maximum )
39 {
40   progressBar->setFormat( format );
41   progressBar->setRange( 0, maximum );
42   progressBar->reset();
43 
44   mProgressUpdate = maximum / 100;
45   if ( mProgressUpdate == 0 )
46   {
47     mProgressUpdate = 1;
48   }
49 }
50 
setProgressValue(int value)51 void QgsOfflineEditingProgressDialog::setProgressValue( int value )
52 {
53   // update progress every nth feature for faster processing
54   if ( value == progressBar->maximum() || value % mProgressUpdate == 0 )
55   {
56     progressBar->setValue( value );
57   }
58 }
59