Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[dbmanager] followp 1646f67: fixes some string and changes more messa…
…geboxes
  • Loading branch information
slarosa authored and nyalldawson committed Sep 25, 2014
1 parent 5fc78bf commit a778e26
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
4 changes: 2 additions & 2 deletions python/plugins/db_manager/db_manager.py
Expand Up @@ -148,7 +148,7 @@ def refreshActionSlot(self):
def importActionSlot(self):
db = self.tree.currentDatabase()
if db is None:
self.infoBar.pushMessage(self.tr("Sorry"), self.tr("No database selected or you are not connected to it."), QgsMessageBar.INFO, self.iface.messageTimeout())
self.infoBar.pushMessage(self.tr("No database selected or you are not connected to it."), QgsMessageBar.INFO, self.iface.messageTimeout())
return

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

inLayer = table.toMapLayer()
Expand Down
24 changes: 8 additions & 16 deletions python/plugins/db_manager/db_plugins/plugin.py
Expand Up @@ -270,8 +270,7 @@ def deleteActionSlot(self, item, action, parent):
self.deleteTableActionSlot(item, action, parent)
else:
QApplication.restoreOverrideCursor()
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Cannot delete the selected item."),
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Cannot delete the selected item."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
QApplication.setOverrideCursor(Qt.WaitCursor)

Expand All @@ -280,8 +279,7 @@ def createSchemaActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, (DBPlugin, Schema, Table)) or item.database() == None:
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "No database selected or you are not connected to it."),
parent.infoBar.pushMessage(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"))
Expand All @@ -296,8 +294,7 @@ def deleteSchemaActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Schema):
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Select an empty SCHEMA for deletion."),
parent.infoBar.pushMessage(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)
Expand Down Expand Up @@ -325,8 +322,7 @@ def createSchema(self, name):
def createTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
if not hasattr(item, 'database') or item.database() == None:
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "No database selected or you are not connected to it."),
parent.infoBar.pushMessage(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
Expand All @@ -337,8 +333,7 @@ def editTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table) or item.isView:
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Select a TABLE for editation."),
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Select a table for editation."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
return
from ..dlg_table_properties import DlgTableProperties
Expand All @@ -350,8 +345,7 @@ def deleteTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table):
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Select a TABLE/VIEW for deletion."),
parent.infoBar.pushMessage(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)
Expand All @@ -366,8 +360,7 @@ def emptyTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table) or item.isView:
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Select a TABLE to empty it."),
parent.infoBar.pushMessage(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)
Expand All @@ -390,8 +383,7 @@ def moveTableToSchemaActionSlot(self, item, action, parent, new_schema):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table):
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Sorry"),
QApplication.translate("DBManagerPlugin", "Select a TABLE/VIEW."),
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Select a table/view."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
return
finally:
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/db_manager/db_plugins/postgis/plugin.py
Expand Up @@ -25,6 +25,7 @@

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.gui import QgsMessageBar

from ..plugin import ConnectionError, InvalidDataException, DBPlugin, Database, Schema, Table, VectorTable, RasterTable, TableField, TableConstraint, TableIndex, TableTrigger, TableRule

Expand Down Expand Up @@ -168,7 +169,7 @@ def runVacuumAnalyzeActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table) or item.isView:
QMessageBox.information(parent, self.tr("Sorry"), self.tr("Select a TABLE for vacuum analyze."))
parent.infoBar().pushMessage(self.tr("Select a table for vacuum analyze."), QgsMessageBar.INFO, parent.iface.messageTimeout())
return
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down
Expand Up @@ -24,6 +24,7 @@
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import QgsMessageBar

import os
current_path = os.path.dirname(__file__)
Expand Down Expand Up @@ -68,19 +69,19 @@ def run(item, action, mainwindow):
isTopoSchema = False

if not hasattr(item, 'schema'):
QMessageBox.critical(mainwindow, "Invalid topology", u'Select a topology schema to continue.')
return False
mainwindow.infoBar.pushMessage("Invalid topology", u'Select a topology schema to continue.', QgsMessageBar.INFO, mainwindow.iface.messageTimeout())
return False

if item.schema() != None:
sql = u"SELECT srid FROM topology.topology WHERE name = %s" % quoteStr(item.schema().name)
c = db.connector._get_cursor()
db.connector._execute( c, sql )
res = db.connector._fetchone( c )
isTopoSchema = res != None
sql = u"SELECT srid FROM topology.topology WHERE name = %s" % quoteStr(item.schema().name)
c = db.connector._get_cursor()
db.connector._execute( c, sql )
res = db.connector._fetchone( c )
isTopoSchema = res != None

if not isTopoSchema:
QMessageBox.critical(mainwindow, "Invalid topology", u'Schema "%s" is not registered in topology.topology.' % item.schema().name)
return False
mainwindow.infoBar.pushMessage("Invalid topology", u'Schema "{0}" is not registered in topology.topology.'.format(item.schema().name), QgsMessageBar.WARNING, mainwindow.iface.messageTimeout())
return False

toposrid = str(res[0])

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/db_plugins/spatialite/plugin.py
Expand Up @@ -116,7 +116,7 @@ def runVacuumActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, (DBPlugin, Table)) or item.database() == None:
QMessageBox.information(parent, self.tr("Sorry"), self.tr("No database selected or you are not connected to it."))
parent.infoBar.pushMessage(self.tr("No database selected or you are not connected to it."), QgsMessageBar.INFO, parent.iface.messageTimeout())
return
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down

0 comments on commit a778e26

Please sign in to comment.