-
Notifications
You must be signed in to change notification settings - Fork 0
/
metadata_dock.py
66 lines (52 loc) · 2.41 KB
/
metadata_dock.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
65
66
# -*- coding: utf-8 -*-
"""
/***************************************************************************
FormationDialog
A QGIS plugin
Formation au développement de plugins
-------------------
begin : 2014-02-27
copyright : (C) 2014 by Arnaud Morvan
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
"""
from PyQt4 import QtCore, QtGui
from ui_metadata import Ui_Metadata
# create the dialog for zoom to point
from qgis.core import QgsMapLayer, QgsVectorLayer
class MetadataDock(QtGui.QDockWidget, Ui_Metadata):
iface = None
layer = None
def __init__(self, iface):
QtGui.QDockWidget.__init__(self, iface.mainWindow())
# Set up the user interface from Designer.
# After setupUI you can access any designer object by doing
# self.<objectname>, and you can use autoconnect slots - see
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
self.setupUi(self)
self.iface = iface
self.update()
self.iface.currentLayerChanged.connect(self.update)
def update(self, layer=None):
self.clear()
layer = self.iface.activeLayer()
if layer is None:
return
if isinstance(layer, QgsVectorLayer):
self.rowCount.setText(str(layer.pendingFeatureCount()))
self.colCount.setText(str(len(layer.dataProvider().fields())))
if isinstance(layer, QgsMapLayer):
self.crsName.setText(layer.crs().description())
def clear(self):
self.rowCount.setText('')
self.colCount.setText('')
self.crsName.setText('')