Skip to content

Commit

Permalink
Final touches before releasing v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gacarrillor committed Apr 21, 2017
1 parent cb0d8db commit d13bc37
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
from PyQt4.QtGui import ( QApplication, QDialog, QDialogButtonBox,
QTableWidgetItem, QFileDialog, QMessageBox )

from Ui_Set_AutoField_on_Layer import Ui_SetAutoFieldOnLayerDialog
from Ui_Assign_AutoField_to_Layer import Ui_AssignAutoFieldToLayerDialog

class SetAutoFieldOnLayerDialog( QDialog, Ui_SetAutoFieldOnLayerDialog ):
class AssignAutoFieldToLayerDialog( QDialog, Ui_AssignAutoFieldToLayerDialog ):

def __init__( self, parent, autoFieldManager, autoFieldId, bCalculateOnExisting ):
QDialog.__init__( self, parent )
Expand Down
17 changes: 15 additions & 2 deletions AutoFieldsDockWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import resources_rc
from Ui_AutoFields_dock import Ui_AutoFieldsDockWidget
from ExpressionBuilderDialog import ExpressionBuilderDialog
from SetAutoFieldOnLayerDialog import SetAutoFieldOnLayerDialog
from AssignAutoFieldToLayerDialog import AssignAutoFieldToLayerDialog


class AutoFieldsDockWidget( QDockWidget, Ui_AutoFieldsDockWidget ):
Expand Down Expand Up @@ -575,6 +575,14 @@ def addAutoFieldToAutoFieldsTable( self, autoFieldId, autoField, freezeSorting=T


def openAutoFieldContextMenu( self, position ):
bLayers = False
layers = QgsMapLayerRegistry.instance().mapLayers().values()
for layer in layers:
if layer.type() == QgsMapLayer.VectorLayer:
if layer.dataProvider().capabilities() & QgsVectorDataProvider.AddFeatures:
bLayers = True
break

item = self.tblAutoFields.itemAt( position )
if item:
row = item.row()
Expand All @@ -586,9 +594,14 @@ def openAutoFieldContextMenu( self, position ):
self.menu.addAction( self.action )
action = self.menu.exec_(self.tblAutoFields.mapToGlobal(position))
if action and action.objectName() == 'action':
if not bLayers:
self.msg.show( QApplication.translate( "AutoFieldsDockWidgetPy",
"First load some vector layers to QGIS to be able to assign disabled AutoFields." ), 'warning' )
return

autoFieldId = self.tblAutoFields.item( row, 0 ).data( Qt.UserRole )
bCalculateOnExisting = self.chkCalculateOnExisting.isChecked()
dlg = SetAutoFieldOnLayerDialog( self.iface.mainWindow(), self.autoFieldManager, autoFieldId, bCalculateOnExisting )
dlg = AssignAutoFieldToLayerDialog( self.iface.mainWindow(), self.autoFieldManager, autoFieldId, bCalculateOnExisting )
dlg.show()


Expand Down
4 changes: 2 additions & 2 deletions ImportAutoFieldsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ def getLabelWithArrow( self, indexLayerCombo, indexFieldCombo, layer, fieldName
if indexLayerCombo != 0 and indexFieldCombo != 0:
if self.autoFieldManager.isFieldAnAutoField( layer, fieldName ):
label.setPixmap( QPixmap( ":/plugins/AutoFields/icons/orange_arrow.png" ) )
label.setToolTip( u'By clicking OK, this AutoField will overwrite an existing AutoField in {}/{}'.format(layer.name(),fieldName) )
label.setToolTip( u'This AutoField will overwrite an existing AutoField in {}/{}'.format(layer.name(),fieldName) )
else:
label.setPixmap( QPixmap( ":/plugins/AutoFields/icons/green_arrow.png" ) )
label.setToolTip( 'AutoField correctly assigned' )
else:
label.setPixmap( QPixmap( ":/plugins/AutoFields/icons/gray_arrow.png" ) )
label.setToolTip( 'This AutoField will not be set on any layer/field' )
label.setToolTip( 'This AutoField will not be assigned to any layer/field' )
label.setAlignment( Qt.AlignCenter )
return label

Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

all: Ui_AutoFields_dock.py Ui_ExpressionBuilder.py Ui_Export_AutoFields.py Ui_Import_AutoFields.py Ui_Set_AutoField_on_Layer.py resources_rc.py i18n/AutoFields_es.qm
all: Ui_AutoFields_dock.py Ui_ExpressionBuilder.py Ui_Export_AutoFields.py Ui_Import_AutoFields.py Ui_Assign_AutoField_to_Layer.py resources_rc.py i18n/AutoFields_es.qm

clean:
rm -f Ui_AutoFields_dock.py Ui_ExpressionBuilder.py Ui_Export_AutoFields.py Ui_Import_AutoFields.py Ui_Set_AutoField_on_Layer.py
rm -f Ui_AutoFields_dock.py Ui_ExpressionBuilder.py Ui_Export_AutoFields.py Ui_Import_AutoFields.py Ui_Assign_AutoField_to_Layer.py
rm -f resources_rc.py
rm -f i18n/AutoFields_es.qm
rm -f *.pyc *~
Expand All @@ -22,8 +22,8 @@ Ui_Export_AutoFields.py: Ui_Export_AutoFields.ui
Ui_Import_AutoFields.py: Ui_Import_AutoFields.ui
pyuic4 -o Ui_Import_AutoFields.py Ui_Import_AutoFields.ui

Ui_Set_AutoField_on_Layer.py: Ui_Set_AutoField_on_Layer.ui
pyuic4 -o Ui_Set_AutoField_on_Layer.py Ui_Set_AutoField_on_Layer.ui
Ui_Assign_AutoField_to_Layer.py: Ui_Assign_AutoField_to_Layer.ui
pyuic4 -o Ui_Assign_AutoField_to_Layer.py Ui_Assign_AutoField_to_Layer.ui

i18n/AutoFields_es.qm: i18n/AutoFields_es.ts
lrelease i18n/AutoFields.pro
14 changes: 7 additions & 7 deletions Ui_Set_AutoField_on_Layer.ui → Ui_Assign_AutoField_to_Layer.ui
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SetAutoFieldOnLayerDialog</class>
<widget class="QDialog" name="SetAutoFieldOnLayerDialog">
<class>AssignAutoFieldToLayerDialog</class>
<widget class="QDialog" name="AssignAutoFieldToLayerDialog">
<property name="geometry">
<rect>
<x>0</x>
Expand All @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Set AutoField on layer</string>
<string>Assign AutoField to layer</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
Expand Down Expand Up @@ -43,7 +43,7 @@
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Choose a layer to set on it the AutoField you have selected:</string>
<string>Choose a layer to assign the AutoField you have selected to it:</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -81,7 +81,7 @@
</font>
</property>
<property name="text">
<string>Note: Only editable vector layers having a field with the same name as the AutoField definition are shown. After clicking OK, the original AutoField will be removed.</string>
<string>Only editable vector layers having a field with the same name as the AutoField configuration are shown. After clicking OK, the original AutoField will be removed.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand All @@ -95,7 +95,7 @@
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SetAutoFieldOnLayerDialog</receiver>
<receiver>AssignAutoFieldToLayerDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
Expand All @@ -111,7 +111,7 @@
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SetAutoFieldOnLayerDialog</receiver>
<receiver>AssignAutoFieldToLayerDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
Expand Down
2 changes: 1 addition & 1 deletion Ui_Import_AutoFields.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Select, at the right hand side, layer and field for each AutoField loaded from file:</string>
<string>Select, on the right hand side, layer and field for each AutoField loaded from file:</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit d13bc37

Please sign in to comment.