Mon, 07 Oct 2013 19:57:08 +0200
Continued to shorten the code lines to max. 79 characters.
--- a/Snapshot/SnapWidget.py Mon Oct 07 19:10:11 2013 +0200 +++ b/Snapshot/SnapWidget.py Mon Oct 07 19:57:08 2013 +0200 @@ -13,10 +13,10 @@ import os -from PyQt4.QtCore import pyqtSlot, QFile, QFileInfo, QTimer, QPoint, QMimeData, Qt, \ - QEvent, QRegExp, qVersion -from PyQt4.QtGui import QWidget, QImageWriter, QApplication, QPixmap, QCursor, QDrag, \ - QShortcut, QKeySequence, QDesktopServices +from PyQt4.QtCore import pyqtSlot, QFile, QFileInfo, QTimer, QPoint, \ + QMimeData, Qt, QEvent, QRegExp, qVersion +from PyQt4.QtGui import QWidget, QImageWriter, QApplication, QPixmap, \ + QCursor, QDrag, QShortcut, QKeySequence, QDesktopServices from E5Gui import E5FileDialog, E5MessageBox @@ -68,12 +68,14 @@ index = 0 self.modeCombo.setCurrentIndex(index) - self.__delay = int(Preferences.Prefs.settings.value("Snapshot/Delay", 0)) + self.__delay = int( + Preferences.Prefs.settings.value("Snapshot/Delay", 0)) self.delaySpin.setValue(self.__delay) self.__filename = Preferences.Prefs.settings.value("Snapshot/Filename", os.path.join( - QDesktopServices.storageLocation(QDesktopServices.PicturesLocation), + QDesktopServices.storageLocation( + QDesktopServices.PicturesLocation), self.trUtf8("snapshot") + "1.png")) self.__grabber = None @@ -140,7 +142,8 @@ """ Private method to initialize the keyboard shortcuts. """ - self.__quitShortcut = QShortcut(QKeySequence(QKeySequence.Quit), self, self.close) + self.__quitShortcut = QShortcut( + QKeySequence(QKeySequence.Quit), self, self.close) self.__copyShortcut = QShortcut(QKeySequence(QKeySequence.Copy), self, self.copyButton.animateClick) @@ -245,9 +248,9 @@ name = os.path.basename(self.__filename) # If the name contains a number, then increment it. - numSearch = QRegExp("(^|[^\\d])(\\d+)") # We want to match as far left as - # possible, and when the number is - # at the start of the name. + numSearch = QRegExp("(^|[^\\d])(\\d+)") + # We want to match as far left as possible, and when the number is + # at the start of the name. # Does it have a number? start = numSearch.lastIndexIn(name) @@ -255,7 +258,8 @@ # It has a number, increment it. start = numSearch.pos(2) # Only the second group is of interest. numAsStr = numSearch.capturedTexts()[2] - number = "{0:0{width}d}".format(int(numAsStr) + 1, width=len(numAsStr)) + number = "{0:0{width}d}".format( + int(numAsStr) + 1, width=len(numAsStr)) name = name[:start] + number + name[start + len(numAsStr):] else: # no number @@ -321,7 +325,8 @@ Private method to grab a rectangular screen region. """ from .SnapshotRegionGrabber import SnapshotRegionGrabber - self.__grabber = SnapshotRegionGrabber(mode=SnapshotRegionGrabber.Rectangle) + self.__grabber = SnapshotRegionGrabber( + mode=SnapshotRegionGrabber.Rectangle) self.__grabber.grabbed.connect(self.__captured) def __grabEllipse(self): @@ -329,7 +334,8 @@ Private method to grab an elliptical screen region. """ from .SnapshotRegionGrabber import SnapshotRegionGrabber - self.__grabber = SnapshotRegionGrabber(mode=SnapshotRegionGrabber.Ellipse) + self.__grabber = SnapshotRegionGrabber( + mode=SnapshotRegionGrabber.Ellipse) self.__grabber.grabbed.connect(self.__captured) def __grabFreehand(self): @@ -351,11 +357,13 @@ if self.__mode == SnapWidget.ModeFullscreen: desktop = QApplication.desktop() if qVersion() >= "5.0.0": - self.__snapshot = QApplication.screens()[0].grabWindow(desktop.winId(), - desktop.x(), desktop.y(), desktop.width(), desktop.height()) + self.__snapshot = QApplication.screens()[0].grabWindow( + desktop.winId(), desktop.x(), desktop.y(), + desktop.width(), desktop.height()) else: - self.__snapshot = QPixmap.grabWindow(desktop.winId(), - desktop.x(), desktop.y(), desktop.width(), desktop.height()) + self.__snapshot = QPixmap.grabWindow( + desktop.winId(), desktop.x(), desktop.y(), + desktop.width(), desktop.height()) elif self.__mode == SnapWidget.ModeScreen: desktop = QApplication.desktop() screenId = desktop.screenNumber(QCursor.pos()) @@ -416,8 +424,8 @@ """ Private slot to update the preview picture. """ - self.preview.setToolTip( - self.trUtf8("Preview of the snapshot image ({0:n} x {1:n})").format( + self.preview.setToolTip(self.trUtf8( + "Preview of the snapshot image ({0:n} x {1:n})").format( self.__snapshot.width(), self.__snapshot.height())) self.preview.setPreview(self.__snapshot) self.preview.adjustSize() @@ -449,7 +457,8 @@ @param evt reference to the event (QEvent) @return flag indicating that the event should be filtered out (boolean) """ - if obj == self.__grabberWidget and evt.type() == QEvent.MouseButtonPress: + if obj == self.__grabberWidget and \ + evt.type() == QEvent.MouseButtonPress: if QWidget.mouseGrabber() != self.__grabberWidget: return False if evt.button() == Qt.LeftButton: @@ -466,7 +475,8 @@ if self.__modified: res = E5MessageBox.question(self, self.trUtf8("eric5 Snapshot"), - self.trUtf8("""The application contains an unsaved snapshot."""), + self.trUtf8( + """The application contains an unsaved snapshot."""), E5MessageBox.StandardButtons( E5MessageBox.Abort | \ E5MessageBox.Discard | \ @@ -477,10 +487,13 @@ elif res == E5MessageBox.Save: self.on_saveButton_clicked() - Preferences.Prefs.settings.setValue("Snapshot/Delay", self.delaySpin.value()) - Preferences.Prefs.settings.setValue("Snapshot/Mode", + Preferences.Prefs.settings.setValue( + "Snapshot/Delay", self.delaySpin.value()) + Preferences.Prefs.settings.setValue( + "Snapshot/Mode", self.modeCombo.itemData(self.modeCombo.currentIndex())) - Preferences.Prefs.settings.setValue("Snapshot/Filename", self.__filename) + Preferences.Prefs.settings.setValue( + "Snapshot/Filename", self.__filename) Preferences.Prefs.settings.sync() def __updateCaption(self):
--- a/Snapshot/SnapshotFreehandGrabber.py Mon Oct 07 19:10:11 2013 +0200 +++ b/Snapshot/SnapshotFreehandGrabber.py Mon Oct 07 19:57:08 2013 +0200 @@ -8,8 +8,8 @@ """ from PyQt4.QtCore import pyqtSignal, Qt, QRect, QPoint, QTimer, qVersion -from PyQt4.QtGui import QWidget, QPixmap, QColor, QRegion, QApplication, QPainter, \ - QPalette, QToolTip, QPolygon, QPen, QBrush, QPaintEngine +from PyQt4.QtGui import QWidget, QPixmap, QColor, QRegion, QApplication, \ + QPainter, QPalette, QToolTip, QPolygon, QPen, QBrush, QPaintEngine def drawPolygon(painter, polygon, outline, fill=QColor()): @@ -63,8 +63,8 @@ self.__helpTextRect = QRect() self.__helpText = self.trUtf8( - "Select a region using the mouse. To take the snapshot, press the Enter key" - " or double click. Press Esc to quit.") + "Select a region using the mouse. To take the snapshot," + " press the Enter key or double click. Press Esc to quit.") self.__pixmap = QPixmap() self.__pBefore = QPoint() @@ -119,7 +119,8 @@ pol = QPolygon(self.__selection) if not self.__selection.boundingRect().isNull(): # Draw outline around selection. - # Important: the 1px-wide outline is *also* part of the captured free-region + # Important: the 1px-wide outline is *also* part of the + # captured free-region pen = QPen(handleColor, 1, Qt.SolidLine, Qt.SquareCap, Qt.BevelJoin) painter.setPen(pen) painter.drawPolygon(pol) @@ -137,11 +138,13 @@ if self.__showHelp: painter.setPen(textColor) painter.setBrush(textBackgroundColor) - self.__helpTextRect = painter.boundingRect(self.rect().adjusted(2, 2, -2, -2), + self.__helpTextRect = painter.boundingRect( + self.rect().adjusted(2, 2, -2, -2), Qt.TextWordWrap, self.__helpText).translated( -self.__desktop.x(), -self.__desktop.y()) self.__helpTextRect.adjust(-2, -2, 4, 2) - drawPolygon(painter, self.__helpTextRect, textColor, textBackgroundColor) + drawPolygon(painter, self.__helpTextRect, textColor, + textBackgroundColor) painter.drawText(self.__helpTextRect.adjusted(3, 3, -3, -3), Qt.TextWordWrap, self.__helpText) @@ -152,14 +155,17 @@ # rectangles (border included). This means that there is no 0px # selection, since a 0px wide rectangle will always be drawn as a line. boundingRect = self.__selection.boundingRect() - txt = "{0:n}, {1:n} ({2:n} x {3:n})".format(boundingRect.x(), boundingRect.y(), + txt = "{0:n}, {1:n} ({2:n} x {3:n})".format( + boundingRect.x(), boundingRect.y(), boundingRect.width(), boundingRect.height()) textRect = painter.boundingRect(self.rect(), Qt.AlignLeft, txt) boundingRect = textRect.adjusted(-4, 0, 0, 0) polBoundingRect = pol.boundingRect() - if textRect.width() < polBoundingRect.width() - 2 * self.__handleSize and \ - textRect.height() < polBoundingRect.height() - 2 * self.__handleSize and \ + if (textRect.width() < + polBoundingRect.width() - 2 * self.__handleSize) and \ + (textRect.height() < + polBoundingRect.height() - 2 * self.__handleSize) and \ polBoundingRect.width() > 100 and \ polBoundingRect.height() > 100: # center, unsuitable for small selections @@ -178,21 +184,25 @@ QPoint(polBoundingRect.x() - 3, polBoundingRect.y())) textRect.moveTopRight( QPoint(polBoundingRect.x() - 5, polBoundingRect.y())) - elif polBoundingRect.bottom() + 3 + textRect.height() < self.rect().bottom() and \ + elif (polBoundingRect.bottom() + 3 + textRect.height() < + self.rect().bottom()) and \ polBoundingRect.right() > textRect.width(): # at bottom, right aligned boundingRect.moveTopRight( QPoint(polBoundingRect.right(), polBoundingRect.bottom() + 3)) textRect.moveTopRight( - QPoint(polBoundingRect.right() - 2, polBoundingRect.bottom() + 3)) - elif polBoundingRect.right() + textRect.width() + 3 < self.rect().width(): + QPoint(polBoundingRect.right() - 2, + polBoundingRect.bottom() + 3)) + elif polBoundingRect.right() + textRect.width() + 3 < \ + self.rect().width(): # right, bottom aligned boundingRect.moveBottomLeft( QPoint(polBoundingRect.right() + 3, polBoundingRect.bottom())) textRect.moveBottomLeft( QPoint(polBoundingRect.right() + 5, polBoundingRect.bottom())) - # If the above didn't catch it, you are running on a very tiny screen... + # If the above didn't catch it, you are running on a very + # tiny screen... drawPolygon(painter, boundingRect, textColor, textBackgroundColor) painter.drawText(textRect, Qt.AlignHCenter, txt) @@ -245,7 +255,8 @@ else: # moving the whole selection p = evt.pos() - self.__pBefore # Offset - self.__pBefore = evt.pos() # save position for next iteration + self.__pBefore = evt.pos() # save position for + # next iteration self.__selection.translate(p) self.update() @@ -309,8 +320,10 @@ pt = QPainter() pt.begin(pixmap2) if pt.paintEngine().hasFeature(QPaintEngine.PorterDuff): - pt.setRenderHints(QPainter.Antialiasing | \ - QPainter.HighQualityAntialiasing | QPainter.SmoothPixmapTransform, + pt.setRenderHints( + QPainter.Antialiasing | \ + QPainter.HighQualityAntialiasing | \ + QPainter.SmoothPixmapTransform, True) pt.setBrush(Qt.black) pt.setPen(QPen(QBrush(Qt.black), 0.5))
--- a/Snapshot/SnapshotPreview.py Mon Oct 07 19:10:11 2013 +0200 +++ b/Snapshot/SnapshotPreview.py Mon Oct 07 19:57:08 2013 +0200 @@ -40,7 +40,8 @@ """ if not preview.isNull(): pixmap = preview.scaled( - self.width(), self.height(), Qt.KeepAspectRatio, Qt.SmoothTransformation) + self.width(), self.height(), + Qt.KeepAspectRatio, Qt.SmoothTransformation) else: pixmap = preview self.setPixmap(pixmap)
--- a/Snapshot/SnapshotRegionGrabber.py Mon Oct 07 19:10:11 2013 +0200 +++ b/Snapshot/SnapshotRegionGrabber.py Mon Oct 07 19:57:08 2013 +0200 @@ -8,8 +8,8 @@ """ from PyQt4.QtCore import pyqtSignal, Qt, QRect, QPoint, QTimer, qVersion -from PyQt4.QtGui import QWidget, QPixmap, QColor, QRegion, QApplication, QPainter, \ - QPalette, QToolTip, QPaintEngine, QPen, QBrush +from PyQt4.QtGui import QWidget, QPixmap, QColor, QRegion, QApplication, \ + QPainter, QPalette, QToolTip, QPaintEngine, QPen, QBrush def drawRect(painter, rect, outline, fill=QColor()): @@ -92,8 +92,8 @@ self.__RHandle, self.__BHandle] self.__helpTextRect = QRect() self.__helpText = self.trUtf8( - "Select a region using the mouse. To take the snapshot, press the Enter key" - " or double click. Press Esc to quit.") + "Select a region using the mouse. To take the snapshot, press" + " the Enter key or double click. Press Esc to quit.") self.__pixmap = QPixmap() @@ -162,11 +162,13 @@ if self.__showHelp: painter.setPen(textColor) painter.setBrush(textBackgroundColor) - self.__helpTextRect = painter.boundingRect(self.rect().adjusted(2, 2, -2, -2), + self.__helpTextRect = painter.boundingRect( + self.rect().adjusted(2, 2, -2, -2), Qt.TextWordWrap, self.__helpText).translated( -self.__desktop.x(), -self.__desktop.y()) self.__helpTextRect.adjust(-2, -2, 4, 2) - drawRect(painter, self.__helpTextRect, textColor, textBackgroundColor) + drawRect(painter, self.__helpTextRect, textColor, + textBackgroundColor) painter.drawText(self.__helpTextRect.adjusted(3, 3, -3, -3), Qt.TextWordWrap, self.__helpText) @@ -208,7 +210,8 @@ boundingRect.moveBottomLeft(QPoint(r.right() + 3, r.bottom())) textRect.moveBottomLeft(QPoint(r.right() + 5, r.bottom())) - # If the above didn't catch it, you are running on a very tiny screen... + # If the above didn't catch it, you are running on a very + # tiny screen... drawRect(painter, boundingRect, textColor, textBackgroundColor) painter.drawText(textRect, Qt.AlignHCenter, txt) @@ -218,11 +221,13 @@ self.__updateHandles() painter.setPen(Qt.NoPen) painter.setBrush(handleColor) - painter.setClipRegion(self.__handleMask(SnapshotRegionGrabber.StrokeMask)) + painter.setClipRegion( + self.__handleMask(SnapshotRegionGrabber.StrokeMask)) painter.drawRect(self.rect()) handleColor.setAlpha(60) painter.setBrush(handleColor) - painter.setClipRegion(self.__handleMask(SnapshotRegionGrabber.FillMask)) + painter.setClipRegion( + self.__handleMask(SnapshotRegionGrabber.FillMask)) painter.drawRect(self.rect()) def resizeEvent(self, evt): @@ -281,14 +286,16 @@ p = evt.pos() r = self.rect() self.__selection = self.__normalizeSelection( - QRect(self.__dragStartPoint, self.__limitPointToRect(p, r))) + QRect(self.__dragStartPoint, + self.__limitPointToRect(p, r))) elif self.__mouseOverHandle is None: # moving the whole selection r = self.rect().normalized() s = self.__selectionBeforeDrag.normalized() p = s.topLeft() + evt.pos() - self.__dragStartPoint r.setBottomRight( - r.bottomRight() - QPoint(s.width(), s.height()) + QPoint(1, 1)) + r.bottomRight() - QPoint(s.width(), + s.height()) + QPoint(1, 1)) if not r.isNull() and r.isValid(): self.__selection.moveTo(self.__limitPointToRect(p, r)) else: @@ -313,7 +320,8 @@ r.setRight(r.right() + offset.x()) r.setTopLeft(self.__limitPointToRect(r.topLeft(), self.rect())) - r.setBottomRight(self.__limitPointToRect(r.bottomRight(), self.rect())) + r.setBottomRight( + self.__limitPointToRect(r.bottomRight(), self.rect())) self.__selection = self.__normalizeSelection(r) self.update() @@ -335,13 +343,17 @@ else: self.setCursor(Qt.CrossCursor) else: - if self.__mouseOverHandle in [self.__TLHandle, self.__BRHandle]: + if self.__mouseOverHandle in [self.__TLHandle, + self.__BRHandle]: self.setCursor(Qt.SizeFDiagCursor) - elif self.__mouseOverHandle in [self.__TRHandle, self.__BLHandle]: + elif self.__mouseOverHandle in [self.__TRHandle, + self.__BLHandle]: self.setCursor(Qt.SizeBDiagCursor) - elif self.__mouseOverHandle in [self.__LHandle, self.__RHandle]: + elif self.__mouseOverHandle in [self.__LHandle, + self.__RHandle]: self.setCursor(Qt.SizeHorCursor) - elif self.__mouseOverHandle in [self.__THandle, self.__BHandle]: + elif self.__mouseOverHandle in [self.__THandle, + self.__BHandle]: self.setCursor(Qt.SizeVerCursor) def mouseReleaseEvent(self, evt): @@ -392,14 +404,17 @@ self.__LHandle.moveTopLeft(QPoint(r.x(), r.y() + r.height() // 2 - s2)) self.__THandle.moveTopLeft(QPoint(r.x() + r.width() // 2 - s2, r.y())) - self.__RHandle.moveTopRight(QPoint(r.right(), r.y() + r.height() // 2 - s2)) - self.__BHandle.moveBottomLeft(QPoint(r.x() + r.width() // 2 - s2, r.bottom())) + self.__RHandle.moveTopRight( + QPoint(r.right(), r.y() + r.height() // 2 - s2)) + self.__BHandle.moveBottomLeft( + QPoint(r.x() + r.width() // 2 - s2, r.bottom())) def __handleMask(self, maskType): """ Private method to calculate the handle mask. - @param maskType type of the mask to be used (SnapshotRegionGrabber.FillMask or + @param maskType type of the mask to be used + (SnapshotRegionGrabber.FillMask or SnapshotRegionGrabber.StrokeMask) @return calculated mask (QRegion) """ @@ -474,8 +489,10 @@ pt = QPainter() pt.begin(pixmap2) if pt.paintEngine().hasFeature(QPaintEngine.PorterDuff): - pt.setRenderHints(QPainter.Antialiasing | \ - QPainter.HighQualityAntialiasing | QPainter.SmoothPixmapTransform, + pt.setRenderHints( + QPainter.Antialiasing | \ + QPainter.HighQualityAntialiasing | \ + QPainter.SmoothPixmapTransform, True) pt.setBrush(Qt.black) pt.setPen(QPen(QBrush(Qt.black), 0.5)) @@ -485,7 +502,8 @@ pt.setClipRegion(translatedEll) pt.setCompositionMode(QPainter.CompositionMode_Source) - pt.drawPixmap(pixmap2.rect(), self.__pixmap, ell.boundingRect()) + pt.drawPixmap(pixmap2.rect(), self.__pixmap, + ell.boundingRect()) pt.end() self.grabbed.emit(pixmap2)
--- a/Snapshot/SnapshotTimer.py Mon Oct 07 19:10:11 2013 +0200 +++ b/Snapshot/SnapshotTimer.py Mon Oct 07 19:57:08 2013 +0200 @@ -36,8 +36,8 @@ # text is taken from paintEvent with maximum number plus some margin self.resize( - self.fontMetrics().width( - self.trUtf8("Snapshot will be taken in %n seconds", "", 99)) + 6, + self.fontMetrics().width(self.trUtf8( + "Snapshot will be taken in %n seconds", "", 99)) + 6, self.fontMetrics().height() + 4) self.__timer.timeout.connect(self.__bell) @@ -49,7 +49,8 @@ @param seconds timeout value (integer) """ screenGeom = QApplication.desktop().screenGeometry() - self.move(screenGeom.width() // 2 - self.size().width() // 2, screenGeom.top()) + self.move(screenGeom.width() // 2 - self.size().width() // 2, + screenGeom.top()) self.__toggle = True self.__time = 0 self.__length = seconds @@ -100,7 +101,8 @@ self.__length - self.__time) textRect = painter.boundingRect(self.rect().adjusted(2, 2, -2, -2), Qt.AlignHCenter | Qt.TextSingleLine, helpText) - painter.drawText(textRect, Qt.AlignHCenter | Qt.TextSingleLine, helpText) + painter.drawText(textRect, Qt.AlignHCenter | Qt.TextSingleLine, + helpText) def enterEvent(self, evt): """ @@ -111,7 +113,8 @@ screenGeom = QApplication.desktop().screenGeometry() if self.x() == screenGeom.left(): self.move( - screenGeom.x() + (screenGeom.width() // 2 - self.size().width() // 2), + screenGeom.x() + (screenGeom.width() // 2 - \ + self.size().width() // 2), screenGeom.top()) else: self.move(screenGeom.topLeft())
--- a/SqlBrowser/SqlBrowser.py Mon Oct 07 19:10:11 2013 +0200 +++ b/SqlBrowser/SqlBrowser.py Mon Oct 07 19:57:08 2013 +0200 @@ -29,7 +29,8 @@ """ Constructor - @param connections list of database connections to add (list of strings) + @param connections list of database connections to add + (list of strings) @param parent reference to the parent widget (QWidget) """ super().__init__(parent) @@ -38,7 +39,8 @@ self.setWindowTitle(self.trUtf8("SQL Browser")) self.setWindowIcon(UI.PixmapCache.getIcon("eric.png")) - self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) + self.setStyle(Preferences.getUI("Style"), + Preferences.getUI("StyleSheet")) from .SqlBrowserWidget import SqlBrowserWidget self.__browser = SqlBrowserWidget(self) @@ -57,7 +59,8 @@ for connection in connections: url = QUrl(connection, QUrl.TolerantMode) if not url.isValid(): - self.__warnings.append(self.trUtf8("Invalid URL: {0}").format(connection)) + self.__warnings.append( + self.trUtf8("Invalid URL: {0}").format(connection)) continue err = self.__browser.addConnection(url.scheme(), url.path(), @@ -65,13 +68,15 @@ url.host(), url.port(-1)) if err.type() != QSqlError.NoError: self.__warnings.append( - self.trUtf8("Unable to open connection: {0}".format(err.text()))) + self.trUtf8("Unable to open connection: {0}".format( + err.text()))) QTimer.singleShot(0, self.__uiStartUp) def __uiStartUp(self): """ - Private slot to do some actions after the UI has started and the main loop is up. + Private slot to do some actions after the UI has started and the main + loop is up. """ for warning in self.__warnings: E5MessageBox.warning(self, @@ -96,9 +101,11 @@ 'Open a dialog to add a new database connection')) self.addConnectionAct.setWhatsThis(self.trUtf8( """<b>Add Connection</b>""" - """<p>This opens a dialog to add a new database connection.</p>""" + """<p>This opens a dialog to add a new database""" + """ connection.</p>""" )) - self.addConnectionAct.triggered[()].connect(self.__browser.addConnectionByDialog) + self.addConnectionAct.triggered[()].connect( + self.__browser.addConnectionByDialog) self.__actions.append(self.addConnectionAct) self.exitAct = E5Action(self.trUtf8('Quit'), @@ -116,7 +123,8 @@ self.aboutAct = E5Action(self.trUtf8('About'), self.trUtf8('&About'), 0, 0, self, 'sql_help_about') - self.aboutAct.setStatusTip(self.trUtf8('Display information about this software')) + self.aboutAct.setStatusTip(self.trUtf8( + 'Display information about this software')) self.aboutAct.setWhatsThis(self.trUtf8( """<b>About</b>""" """<p>Display some information about this software.</p>"""
--- a/SqlBrowser/SqlBrowserWidget.py Mon Oct 07 19:10:11 2013 +0200 +++ b/SqlBrowser/SqlBrowserWidget.py Mon Oct 07 19:57:08 2013 +0200 @@ -9,7 +9,8 @@ from PyQt4.QtCore import pyqtSignal, QVariant, Qt, pyqtSlot from PyQt4.QtGui import QWidget, QStandardItemModel, QDialog, QAbstractItemView -from PyQt4.QtSql import QSqlDatabase, QSqlError, QSqlTableModel, QSqlQueryModel, QSqlQuery +from PyQt4.QtSql import QSqlDatabase, QSqlError, QSqlTableModel, \ + QSqlQueryModel, QSqlQuery from E5Gui import E5MessageBox @@ -41,12 +42,15 @@ if len(QSqlDatabase.drivers()) == 0: E5MessageBox.information(self, self.trUtf8("No database drivers found"), - self.trUtf8("""This tool requires at least one Qt database driver. """ - """Please check the Qt documentation how to build the """ - """Qt SQL plugins.""")) + self.trUtf8( + """This tool requires at least one Qt database driver. """ + """Please check the Qt documentation how to build the """ + """Qt SQL plugins.""")) - self.connections.tableActivated.connect(self.on_connections_tableActivated) - self.connections.schemaRequested.connect(self.on_connections_schemaRequested) + self.connections.tableActivated.connect( + self.on_connections_tableActivated) + self.connections.schemaRequested.connect( + self.on_connections_schemaRequested) self.connections.cleared.connect(self.on_connections_cleared) self.statusMessage.emit(self.trUtf8("Ready")) @@ -125,15 +129,16 @@ err = QSqlError() self.__class__.cCount += 1 - db = QSqlDatabase.addDatabase(driver.upper(), - "Browser{0:d}".format(self.__class__.cCount)) + db = QSqlDatabase.addDatabase( + driver.upper(), "Browser{0:d}".format(self.__class__.cCount)) db.setDatabaseName(dbName) db.setHostName(host) db.setPort(port) if not db.open(user, password): err = db.lastError() db = QSqlDatabase() - QSqlDatabase.removeDatabase("Browser{0:d}".format(self.__class__.cCount)) + QSqlDatabase.removeDatabase( + "Browser{0:d}".format(self.__class__.cCount)) self.connections.refresh() @@ -147,12 +152,14 @@ dlg = SqlConnectionDialog(self) if dlg.exec_() == QDialog.Accepted: driver, dbName, user, password, host, port = dlg.getData() - err = self.addConnection(driver, dbName, user, password, host, port) + err = self.addConnection( + driver, dbName, user, password, host, port) if err.type() != QSqlError.NoError: E5MessageBox.warning(self, self.trUtf8("Unable to open database"), - self.trUtf8("""An error occurred while opening the connection.""")) + self.trUtf8( + """An error occurred while opening the connection.""")) def showTable(self, table): """ @@ -172,7 +179,8 @@ self.table.resizeColumnsToContents() - self.table.selectionModel().currentRowChanged.connect(self.updateActions) + self.table.selectionModel().currentRowChanged.connect( + self.updateActions) self.updateActions() @@ -203,9 +211,9 @@ model.setData(model.index(i, 1), QVariant.typeToName(fld.type())) else: - model.setData(model.index(i, 1), "{0} ({1})".format( - QVariant.typeToName(fld.type()), - fld.typeID())) + model.setData( + model.index(i, 1), "{0} ({1})".format( + QVariant.typeToName(fld.type()), fld.typeID())) if fld.length() < 0: model.setData(model.index(i, 2), "?") else: @@ -282,8 +290,8 @@ Public slot to execute the entered query. """ model = QSqlQueryModel(self.table) - model.setQuery( - QSqlQuery(self.sqlEdit.toPlainText(), self.connections.currentDatabase())) + model.setQuery(QSqlQuery( + self.sqlEdit.toPlainText(), self.connections.currentDatabase())) self.table.setModel(model) if model.lastError().type() != QSqlError.NoError:
--- a/SqlBrowser/SqlConnectionWidget.py Mon Oct 07 19:10:11 2013 +0200 +++ b/SqlBrowser/SqlConnectionWidget.py Mon Oct 07 19:57:08 2013 +0200 @@ -17,7 +17,8 @@ """ Class implementing a widget showing the SQL connections. - @signal tableActivated(str) emitted after the entry for a table has been activated + @signal tableActivated(str) emitted after the entry for a table has been + activated @signal schemaRequested(str) emitted when the schema display is requested @signal cleared() emitted after the connection tree has been cleared """ @@ -40,11 +41,13 @@ self.__connectionTree.setObjectName("connectionTree") self.__connectionTree.setHeaderLabels([self.trUtf8("Database")]) if qVersion() >= "5.0.0": - self.__connectionTree.header().setSectionResizeMode(QHeaderView.Stretch) + self.__connectionTree.header().setSectionResizeMode( + QHeaderView.Stretch) else: self.__connectionTree.header().setResizeMode(QHeaderView.Stretch) refreshAction = QAction(self.trUtf8("Refresh"), self.__connectionTree) - self.__schemaAction = QAction(self.trUtf8("Show Schema"), self.__connectionTree) + self.__schemaAction = QAction( + self.trUtf8("Show Schema"), self.__connectionTree) refreshAction.triggered[()].connect(self.refresh) self.__schemaAction.triggered[()].connect(self.showSchema) @@ -58,7 +61,8 @@ self.__activating = False self.__connectionTree.itemActivated.connect(self.__itemActivated) - self.__connectionTree.currentItemChanged.connect(self.__currentItemChanged) + self.__connectionTree.currentItemChanged.connect( + self.__currentItemChanged) self.__activeDb = "" @@ -123,7 +127,8 @@ Private slot handling a change of the current item. @param current reference to the new current item (QTreeWidgetItem) - @param previous reference to the previous current item (QTreeWidgetItem) + @param previous reference to the previous current item + (QTreeWidgetItem) """ self.__schemaAction.setEnabled( current is not None and current.parent() is not None) @@ -166,11 +171,13 @@ """ Private slot to set an item to active. - @param itm reference to the item to set as the active item (QTreeWidgetItem) + @param itm reference to the item to set as the active item + (QTreeWidgetItem) """ for index in range(self.__connectionTree.topLevelItemCount()): if self.__connectionTree.topLevelItem(index).font(0).bold(): - self.__setBold(self.__connectionTree.topLevelItem(index), False) + self.__setBold( + self.__connectionTree.topLevelItem(index), False) if itm is None: return