-
Notifications
You must be signed in to change notification settings - Fork 0
/
guided_offline_editing_progress_dialog.py
64 lines (53 loc) · 2.52 KB
/
guided_offline_editing_progress_dialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
"""
/***************************************************************************
GuidedOfflineEditingPluginDialog
A QGIS plugin
Extend the built-in Offline Editing Plugin providing automated processes
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2019-06-08
git sha : $Format:%H$
copyright : (C) 2019 by Yann Voté
email : ygversil@lilo.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
import os
from PyQt5 import uic
from PyQt5 import QtWidgets
# This loads your .ui file so that PyQt can populate your plugin with the
# elements from Qt Designer
UI_CLASS, _ = uic.loadUiType(os.path.join(
os.path.dirname(__file__), 'guided_offline_editing_progress_dialog_base.ui'
), resource_suffix='')
class GuidedOfflineEditingPluginProgressDialog(QtWidgets.QDialog, UI_CLASS):
"""Progress dialog showing current progress when offline layers are
being synchronized back online."""
def __init__(self, parent=None):
super().__init__(parent)
self.setupUi(self)
def setup_progress_bar(self, format_, layer_count):
"""Initialize progress bar."""
self.progress_bar.setFormat(format_)
self.progress_bar.setRange(0, layer_count)
self.progress_bar.reset()
def set_progress_bar(self, value):
"""Update progress bar."""
self.progress_bar.setValue(value)
def set_progress_label(self, current_layer_idx, layer_count):
"""Update text label."""
self.progress_label.setText(
self.tr('Layer {} of {}').format(current_layer_idx, layer_count)
)
self.progress_bar.reset()
def set_title(self, title):
"""Update the dialog title."""
self.setWindowTitle(title)