Skip to content
Browse files

DBManager: fix minor issues due to Query dialogs repleaced with Query…

… tabs (ref commit 5fb52fa)

In detail:
* hide close button from Info, Table and Preview tabs (it should work on Mac as well),
* always display dbtype icon into query tab
* show database name in tab text (otherwise we dunno which db the query is executed against)
* restore original tab text when query name becomes empty
  • Loading branch information
brushtyler committed Aug 22, 2015
1 parent 03cf0ce commit 4dc7eba107bfce0f2fc4958318da1ea79b8cd663
Showing with 23 additions and 13 deletions.
  1. +23 −13 python/plugins/db_manager/
@@ -26,7 +26,7 @@

from PyQt4.QtCore import QObject, Qt, QSettings, QByteArray, SIGNAL, QSize
from PyQt4.QtGui import QMainWindow, QApplication, QMenu, QIcon, QTabWidget, QGridLayout, QSpacerItem, QSizePolicy, \
QDockWidget, QStatusBar, QMenuBar, QToolBar, QKeySequence
QDockWidget, QStatusBar, QMenuBar, QToolBar, QKeySequence, QTabBar

from qgis.gui import QgsMessageBar
from .info_viewer import InfoViewer
@@ -186,22 +186,24 @@ def runSqlWindow(self):
if db is None:
self.infoBar.pushMessage("No database selected or you are not connected to it."),
QgsMessageBar.INFO, self.iface.messageTimeout())
# force displaying of the message, it appears on the first tab (i.e. Info)

from dlg_sql_window import DlgSqlWindow

query = DlgSqlWindow(self.iface, db, self)
index = self.tabs.addTab(query,"Query"))
dbname = db.connection().connectionName()
tabname ="Query") + u" (%s)" % dbname
index = self.tabs.addTab(query, tabname)
self.tabs.setTabIcon(index, db.connection().icon())
self.tabs.setTabIcon(index, self.tree.currentItem().icon())
except AttributeError:
query.nameChanged.connect(functools.partial(self.update_tab_name, index))
query.nameChanged.connect(functools.partial(self.update_query_tab_name, index, dbname))

def update_tab_name(self, index, name):
name = name + "(query)"
self.tabs.setTabText(index, name)
def update_query_tab_name(self, index, dbname, queryname):
if not queryname: queryname ="Query")
tabname = u"%s (%s)" % (queryname, dbname)
self.tabs.setTabText(index, tabname)

def showSystemTables(self):
@@ -358,10 +360,8 @@ def setupUi(self):
self.resize(QSize(700, 500).expandedTo(self.minimumSizeHint()))

# create central tab widget
# create central tab widget and add the first 3 tabs: info, table and preview
self.tabs = QTabWidget()
self.tabs.tabCloseRequested.connect(self.close_tab) = InfoViewer(self)
self.table = TableViewer(self)
@@ -370,6 +370,16 @@ def setupUi(self):

# display close button for all tabs but the first 3 ones, i.e.
# HACK: just hide the close button where not needed (GS)
tabbar = self.tabs.tabBar()
for i in range(3):
btn = tabbar.tabButton(i, QTabBar.RightSide) if tabbar.tabButton(i, QTabBar.RightSide) else tabbar.tabButton(i, QTabBar.LeftSide)

# Creates layout for message bar
self.layout = QGridLayout(
self.layout.setContentsMargins(0, 0, 0, 0)

0 comments on commit 4dc7eba

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