Skip to content
Permalink
Browse files

[dbmanager] messagebox => messagebar

  • Loading branch information
slarosa authored and nyalldawson committed Sep 17, 2014
1 parent 2427546 commit 5fc78bfe59ce0d4802b2880462605911d4f395ab
Showing with 40 additions and 11 deletions.
  1. +15 −3 python/plugins/db_manager/db_manager.py
  2. +25 −8 python/plugins/db_manager/db_plugins/plugin.py
@@ -25,6 +25,7 @@
from PyQt4.QtCore import *
from PyQt4.QtGui import *

from qgis.gui import QgsMessageBar
from .info_viewer import InfoViewer
from .table_viewer import TableViewer
from .layer_preview import LayerPreview
@@ -147,7 +148,7 @@ def refreshActionSlot(self):
def importActionSlot(self):
db = self.tree.currentDatabase()
if db is None:
QMessageBox.information(self, self.tr("Sorry"), self.tr("No database selected or you are not connected to it."))
self.infoBar.pushMessage(self.tr("Sorry"), self.tr("No database selected or you are not connected to it."), QgsMessageBar.INFO, self.iface.messageTimeout())
return

outUri = db.uri()
@@ -162,7 +163,7 @@ def importActionSlot(self):
def exportActionSlot(self):
table = self.tree.currentTable()
if table is None:
QMessageBox.information(self, self.tr("Sorry"), self.tr("Select the table you want export to file."))
self.infoBar.pushMessage(self.tr("Sorry"), self.tr("Select the table you want export to file."), QgsMessageBar.INFO, self.iface.messageTimeout())
return

inLayer = table.toMapLayer()
@@ -176,7 +177,7 @@ def exportActionSlot(self):
def runSqlWindow(self):
db = self.tree.currentDatabase()
if db == None:
QMessageBox.information(self, self.tr("Sorry"), self.tr("No database selected or you are not connected to it."))
self.infoBar.pushMessage(self.tr("No database selected or you are not connected to it."), QgsMessageBar.INFO, self.iface.messageTimeout())
return

from dlg_sql_window import DlgSqlWindow
@@ -347,6 +348,17 @@ def setupUi(self):
self.tabs.addTab(self.preview, self.tr("Preview"))
self.setCentralWidget(self.tabs)

# Creates layout for message bar
self.layout = QGridLayout(self.info)
self.layout.setContentsMargins(0, 0, 0, 0)
spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.layout.addItem(spacerItem, 1, 0, 1, 1)
# init messageBar instance
self.infoBar = QgsMessageBar(self.info)
sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
self.infoBar.setSizePolicy(sizePolicy)
self.layout.addWidget(self.infoBar, 0, 0, 1, 1)

# create database tree
self.dock = QDockWidget("Tree", self)
self.dock.setObjectName("DB_Manager_DBView")
@@ -23,6 +23,7 @@
from PyQt4.QtCore import *
from PyQt4.QtGui import *

from qgis.gui import QgsMessageBar
from ..db_plugins import createDbPlugin
from .html_elems import HtmlParagraph, HtmlTable

@@ -269,15 +270,19 @@ def deleteActionSlot(self, item, action, parent):
self.deleteTableActionSlot(item, action, parent)
else:
QApplication.restoreOverrideCursor()
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Cannot delete the selected item."))
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Cannot delete the selected item."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
QApplication.setOverrideCursor(Qt.WaitCursor)


def createSchemaActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, (DBPlugin, Schema, Table)) or item.database() == None:
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "No database selected or you are not connected to it."))
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "No database selected or you are not connected to it."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
return
(schema, ok) = QInputDialog.getText(parent, QApplication.translate("DBManagerPlugin", "New schema"), QApplication.translate("DBManagerPlugin", "Enter new schema name"))
if not ok:
@@ -291,7 +296,9 @@ def deleteSchemaActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Schema):
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Select an empty SCHEMA for deletion."))
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Select an empty SCHEMA for deletion."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
return
res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"), QApplication.translate("DBManagerPlugin", "Really delete schema %s?") % item.name, QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
@@ -318,7 +325,9 @@ def createSchema(self, name):
def createTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
if not hasattr(item, 'database') or item.database() == None:
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "No database selected or you are not connected to it."))
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "No database selected or you are not connected to it."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
return
from ..dlg_create_table import DlgCreateTable
DlgCreateTable(item, parent).exec_()
@@ -328,7 +337,9 @@ def editTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table) or item.isView:
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Select a TABLE for editation."))
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Select a TABLE for editation."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
return
from ..dlg_table_properties import DlgTableProperties
DlgTableProperties(item, parent).exec_()
@@ -339,7 +350,9 @@ def deleteTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table):
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Select a TABLE/VIEW for deletion."))
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Select a TABLE/VIEW for deletion."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
return
res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"), QApplication.translate("DBManagerPlugin", "Really delete table/view %s?") % item.name, QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
@@ -353,7 +366,9 @@ def emptyTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table) or item.isView:
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Select a TABLE to empty it."))
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Select a TABLE to empty it."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
return
res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"), QApplication.translate("DBManagerPlugin", "Really delete all items from table %s?") % item.name, QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
@@ -375,7 +390,9 @@ def moveTableToSchemaActionSlot(self, item, action, parent, new_schema):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table):
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Select a TABLE/VIEW."))
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Select a TABLE/VIEW."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
return
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)

0 comments on commit 5fc78bf

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