11# -*- coding: utf-8 -*-
22#-----------------------------------------------------------
3- #
3+ #
44# Join Attributes
55#
66# A QGIS plugin for performing an attribute join between vector layers.
1313# WEB : www.geog.uvic.ca/spar/carson
1414#
1515#-----------------------------------------------------------
16- #
16+ #
1717# licensed under the terms of GNU GPL 2
18- #
18+ #
1919# This program is free software; you can redistribute it and/or modify
2020# it under the terms of the GNU General Public License as published by
2121# the Free Software Foundation; either version 2 of the License, or
2222# (at your option) any later version.
23- #
23+ #
2424# This program is distributed in the hope that it will be useful,
2525# but WITHOUT ANY WARRANTY; without even the implied warranty of
2626# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2727# GNU General Public License for more details.
28- #
28+ #
2929# You should have received a copy of the GNU General Public License along
3030# with this program; if not, write to the Free Software Foundation, Inc.,
3131# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32- #
32+ #
3333#---------------------------------------------------------------------
3434
3535from PyQt4 .QtCore import *
@@ -53,6 +53,7 @@ def __init__(self, iface):
5353 QObject .connect (self .rdoTable , SIGNAL ("clicked()" ), self .updateTableFields )
5454 QObject .connect (self .rdoVector , SIGNAL ("clicked()" ), self .jupdate )
5555 self .setWindowTitle ( self .tr ("Join attributes" ) )
56+ self .buttonOk = self .buttonBox_2 .button ( QDialogButtonBox .Ok )
5657 # populate layer list
5758 self .progressBar .setValue (0 )
5859 mapCanvas = self .iface .mapCanvas ()
@@ -75,8 +76,9 @@ def jupdate(self):
7576 self .joinField .clear ()
7677 for i in changedField :
7778 self .joinField .addItem (unicode (changedField [i ].name ()))
78-
79+
7980 def accept (self ):
81+ self .buttonOk .setEnabled ( False )
8082 if self .inShape .currentText () == "" :
8183 QMessageBox .information (self , self .tr ("Join Attributes" ), self .tr ("Please specify target vector layer" ))
8284 elif self .outShape .text () == "" :
@@ -101,7 +103,7 @@ def accept(self):
101103 useTable = True
102104 joinField = self .joinField .currentText ()
103105 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 )
105107 self .outShape .clear ()
106108 if res :
107109 addToTOC = QMessageBox .question (self , self .tr ("Join Attributes" ),
@@ -112,6 +114,7 @@ def accept(self):
112114 QMessageBox .warning ( self , self .tr ("Geoprocessing" ), self .tr ( "Error loading output shapefile:\n %1" )
113115 .arg ( unicode ( outPath ) ))
114116 self .progressBar .setValue (0 )
117+ self .buttonOk .setEnabled ( True )
115118
116119 def outFile (self ):
117120 self .outShape .clear ()
@@ -171,7 +174,7 @@ def compute(self, inName, inField, joinName, joinField, outName, keep, useTable,
171174 provider2 .select (allAttrs , QgsRectangle (), False , False )
172175 fieldList2 = ftools_utils .getFieldList (layer2 )
173176 index2 = provider2 .fieldNameIndex (joinField )
174- fieldList2 = self .testForUniqueness (fieldList1 , fieldList2 .values ())
177+ fieldList2 = ftools_utils .testForUniqueness (fieldList1 , fieldList2 .values ())
175178 seq = range (0 , len (fieldList1 ) + len (fieldList2 ))
176179 fieldList1 .extend (fieldList2 )
177180 fieldList1 = dict (zip (seq , fieldList1 ))
0 commit comments