1
1
# -*- coding: utf-8 -*-
2
2
#-----------------------------------------------------------
3
- #
3
+ #
4
4
# Join Attributes
5
5
#
6
6
# A QGIS plugin for performing an attribute join between vector layers.
13
13
# WEB : www.geog.uvic.ca/spar/carson
14
14
#
15
15
#-----------------------------------------------------------
16
- #
16
+ #
17
17
# licensed under the terms of GNU GPL 2
18
- #
18
+ #
19
19
# This program is free software; you can redistribute it and/or modify
20
20
# it under the terms of the GNU General Public License as published by
21
21
# the Free Software Foundation; either version 2 of the License, or
22
22
# (at your option) any later version.
23
- #
23
+ #
24
24
# This program is distributed in the hope that it will be useful,
25
25
# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
26
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
27
# GNU General Public License for more details.
28
- #
28
+ #
29
29
# You should have received a copy of the GNU General Public License along
30
30
# with this program; if not, write to the Free Software Foundation, Inc.,
31
31
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32
- #
32
+ #
33
33
#---------------------------------------------------------------------
34
34
35
35
from PyQt4 .QtCore import *
@@ -53,6 +53,7 @@ def __init__(self, iface):
53
53
QObject .connect (self .rdoTable , SIGNAL ("clicked()" ), self .updateTableFields )
54
54
QObject .connect (self .rdoVector , SIGNAL ("clicked()" ), self .jupdate )
55
55
self .setWindowTitle ( self .tr ("Join attributes" ) )
56
+ self .buttonOk = self .buttonBox_2 .button ( QDialogButtonBox .Ok )
56
57
# populate layer list
57
58
self .progressBar .setValue (0 )
58
59
mapCanvas = self .iface .mapCanvas ()
@@ -75,8 +76,9 @@ def jupdate(self):
75
76
self .joinField .clear ()
76
77
for i in changedField :
77
78
self .joinField .addItem (unicode (changedField [i ].name ()))
78
-
79
+
79
80
def accept (self ):
81
+ self .buttonOk .setEnabled ( False )
80
82
if self .inShape .currentText () == "" :
81
83
QMessageBox .information (self , self .tr ("Join Attributes" ), self .tr ("Please specify target vector layer" ))
82
84
elif self .outShape .text () == "" :
@@ -101,7 +103,7 @@ def accept(self):
101
103
useTable = True
102
104
joinField = self .joinField .currentText ()
103
105
outPath = self .outShape .text ()
104
- self .compute (inName , inField , joinName , joinField , outPath , keep , useTable , self .progressBar )
106
+ res = self .compute (inName , inField , joinName , joinField , outPath , keep , useTable , self .progressBar )
105
107
self .outShape .clear ()
106
108
if res :
107
109
addToTOC = QMessageBox .question (self , self .tr ("Join Attributes" ),
@@ -112,6 +114,7 @@ def accept(self):
112
114
QMessageBox .warning ( self , self .tr ("Geoprocessing" ), self .tr ( "Error loading output shapefile:\n %1" )
113
115
.arg ( unicode ( outPath ) ))
114
116
self .progressBar .setValue (0 )
117
+ self .buttonOk .setEnabled ( True )
115
118
116
119
def outFile (self ):
117
120
self .outShape .clear ()
@@ -171,7 +174,7 @@ def compute(self, inName, inField, joinName, joinField, outName, keep, useTable,
171
174
provider2 .select (allAttrs , QgsRectangle (), False , False )
172
175
fieldList2 = ftools_utils .getFieldList (layer2 )
173
176
index2 = provider2 .fieldNameIndex (joinField )
174
- fieldList2 = self .testForUniqueness (fieldList1 , fieldList2 .values ())
177
+ fieldList2 = ftools_utils .testForUniqueness (fieldList1 , fieldList2 .values ())
175
178
seq = range (0 , len (fieldList1 ) + len (fieldList2 ))
176
179
fieldList1 .extend (fieldList2 )
177
180
fieldList1 = dict (zip (seq , fieldList1 ))
0 commit comments