Skip to content

Commit

Permalink
DBManager: remove empty line from sql editor
Browse files Browse the repository at this point in the history
  • Loading branch information
brushtyler committed Jun 4, 2013
1 parent 80b5a07 commit ae3abcc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
15 changes: 6 additions & 9 deletions python/plugins/db_manager/dlg_sql_window.py
Expand Up @@ -62,11 +62,11 @@ def __init__(self, iface, db, parent=None):
self.connect(self.btnClear, SIGNAL("clicked()"), self.clearSql)
self.connect(self.buttonBox.button(QDialogButtonBox.Close), SIGNAL("clicked()"), self.close)


self.connect(self.presetStore, SIGNAL("clicked()"), self.storePreset)
self.connect(self.presetDelete, SIGNAL("clicked()"), self.deletePreset)
self.connect(self.presetCombo, SIGNAL("activated(QString)"), self.loadPreset)
self.connect(self.presetCombo, SIGNAL("activated(QString)"), self.presetName.setText)
self.updatePresetsCombobox()

# hide the load query as layer if feature is not supported
self._loadAsLayerAvailable = self.db.connector.hasCustomQuerySupport()
Expand All @@ -78,22 +78,18 @@ def __init__(self, iface, db, parent=None):
self.connect(self.loadAsLayerGroup, SIGNAL("toggled(bool)"), self.loadAsLayerToggled)
self.loadAsLayerToggled(False)

def showEvent(self, event):
QDialog.showEvent(self, event)
self.updatePresetsCombobox()

def updatePresetsCombobox(self):
entries = QgsProject.instance().subkeyList('DBManager','savedQueries')
self.presetCombo.clear()

names = []
entries = QgsProject.instance().subkeyList('DBManager','savedQueries')
for entry in entries:
name = QgsProject.instance().readEntry('DBManager','savedQueries/'+entry+'/name' )[0]
names.append( name )

names.sort()

for name in names:
for name in sorted(names):
self.presetCombo.addItem(name)
self.presetCombo.setCurrentIndex(-1)

def storePreset(self):
query = self.editSql.toPlainText()
Expand All @@ -112,6 +108,7 @@ def deletePreset(self):
QgsProject.instance().removeEntry('DBManager','savedQueries/q'+str(name.__hash__()) )
self.presetCombo.removeItem( self.presetCombo.findText(name) )
self.presetCombo.setCurrentIndex(-1)

def loadPreset(self, name):
query = QgsProject.instance().readEntry('DBManager','savedQueries/q'+str(name.__hash__())+'/query' )[0]
name = QgsProject.instance().readEntry('DBManager','savedQueries/q'+str(name.__hash__())+'/name' )[0]
Expand Down
10 changes: 7 additions & 3 deletions python/plugins/db_manager/ui/DlgSqlWindow.ui
Expand Up @@ -44,7 +44,11 @@
</spacer>
</item>
<item>
<widget class="QLineEdit" name="presetName"/>
<widget class="QLineEdit" name="presetName">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="presetCombo"/>
Expand Down Expand Up @@ -77,8 +81,8 @@
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit ae3abcc

Please sign in to comment.