Skip to content
Permalink
Browse files

Add translation ; add button 'load file'

  • Loading branch information
lbartoletti committed Nov 12, 2018
1 parent 74f7cb5 commit 5eecbf2d4cdbd6946ddbbb87ceb01c1e6e11641a
Showing with 24 additions and 1 deletion.
  1. +14 −1 python/plugins/db_manager/dlg_sql_window.py
  2. +10 −0 python/plugins/db_manager/ui/DlgSqlWindow.ui
@@ -121,6 +121,7 @@ def __init__(self, iface, db, parent=None):

self.presetStore.clicked.connect(self.storePreset)
self.presetSaveAsFile.clicked.connect(self.saveAsFilePreset)
self.presetLoadFile.clicked.connect(self.loadFilePreset)
self.presetDelete.clicked.connect(self.deletePreset)
self.presetCombo.activated[str].connect(self.loadPreset)
self.presetCombo.activated[str].connect(self.presetName.setText)
@@ -236,14 +237,26 @@ def saveAsFilePreset(self):

filename, ext = QFileDialog.getSaveFileName(
self,
'Save SQL Query',
self.tr('Save SQL Query'),
QDir.homePath(),
"SQL File (*.sql)")

if filename:
with open(filename, 'w') as f:
f.write(query)

def loadFilePreset(self):
filename = QFileDialog.getOpenFileName(
self,
self.tr("Load SQL Query"),
QDir.homePath(),
"SQL File (*.sql)");
if filename:
with open(filename[0], 'r') as f:
self.editSql.clear()
for line in f:
self.editSql.insertText(line)

def deletePreset(self):
name = self.presetCombo.currentText()
QgsProject.instance().removeEntry('DBManager', 'savedQueries/' + self.getQueryHash(name))
@@ -100,6 +100,16 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="presetLoadFile">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Load SQL file&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Load File</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="presetSaveAsFile">
<property name="toolTip">

0 comments on commit 5eecbf2

Please sign in to comment.
You can’t perform that action at this time.