-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathExpressionBuilderDialog.py
More file actions
54 lines (44 loc) · 2.19 KB
/
Copy pathExpressionBuilderDialog.py
File metadata and controls
54 lines (44 loc) · 2.19 KB
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
# -*- coding:utf-8 -*-
"""
/***************************************************************************
AutoFields
A QGIS plugin
Automatic attribute updates when creating or modifying vector features
-------------------
begin : 2016-05-22
copyright : (C) 2016 by Germán Carrillo (GeoTux)
email : gcarrillo@linuxmail.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. *
* *
***************************************************************************/
"""
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QDialog, QDialogButtonBox
from Ui_ExpressionBuilder import Ui_ExpressionDialog
class ExpressionBuilderDialog( QDialog, Ui_ExpressionDialog ):
def __init__( self, parent ):
QDialog.__init__( self, parent )
self.setupUi( self )
self.setModal( True )
self.expressionBuilderWidget.loadRecent( 'fieldcalc' )
self.buttonBox.button( QDialogButtonBox.Ok ).setEnabled( False )
self.expression = ''
self.expressionBuilderWidget.expressionParsed.connect( self.expressionChanged )
def expressionChanged( self, valid ):
self.buttonBox.button( QDialogButtonBox.Ok ).setEnabled( valid )
def keyPressEvent( self, event ):
if event.key() == Qt.Key_Escape:
self.reject()
def accept( self ):
self.expression = self.expressionBuilderWidget.expressionText().strip()
self.expressionBuilderWidget.saveToRecent( 'fieldcalc' )
self.done( 1 )
def reject( self ):
self.expressionBuilderWidget.setExpressionText( self.expression )
self.done( 0 )