Commits

Steve Borho committed 8d357e3

pyqt: make workbench and commit tool work with PyQt 4.6 (CentOs 6.3)

This mainly involved removing some keyword arguments to Qt functions,
catching some missing Lexers, and a handful of missing methods. The
biggest loss is the XML reader for the registry is gone; so the registry
itself is mostly useless. On the grand scale of things, this isn't too
bad.

Comments (0)

Files changed (8)

tortoisehg/hgqt/cmdui.py

 class ProgressMonitor(QWidget):
     'Progress bar for use in workbench status bar'
     def __init__(self, topic, parent):
-        super(ProgressMonitor, self).__init__(parent=parent)
+        super(ProgressMonitor, self).__init__(parent)
 
         hbox = QHBoxLayout()
         hbox.setContentsMargins(*(0,)*4)
     linkActivated = pyqtSignal(QString)
 
     def __init__(self, parent=None):
-        QStatusBar.__init__(self, parent=parent)
+        QStatusBar.__init__(self, parent)
         self.topics = {}
         self.lbl = QLabel()
         self.lbl.linkActivated.connect(self.linkActivated)

tortoisehg/hgqt/commit.py

     endSuppressPrompt = pyqtSignal()
 
     def __init__(self, repo, pats, opts, embedded=False, parent=None, rev=None):
-        QWidget.__init__(self, parent=parent)
+        QWidget.__init__(self, parent)
 
         repo.configChanged.connect(self.configChanged)
         repo.repositoryChanged.connect(self.repositoryChanged)

tortoisehg/hgqt/csinfo.py

             self.revlabel = QLabel()
             self.revlabel.linkActivated.connect(
                  lambda s: self.linkActivated.emit(s))
-            self.layout().addWidget(self.revlabel, alignment=Qt.AlignTop)
+            self.layout().addWidget(self.revlabel, 0, Qt.AlignTop)
 
         if 'expandable' in self.csstyle and self.csstyle['expandable']:
             if self.expand_btn.parentWidget() is None:
                 self.expand_btn.clicked.connect(lambda: self.update())
                 margin = QHBoxLayout()
                 margin.setMargin(3)
-                margin.addWidget(self.expand_btn, alignment=Qt.AlignTop)
+                margin.addWidget(self.expand_btn, 0, Qt.AlignTop)
                 self.layout().insertLayout(0, margin)
             self.expand_btn.setShown(True)
         elif self.expand_btn.parentWidget() is not None:

tortoisehg/hgqt/lexers.py

     extensions = ('.yml',)
     _lexer = Qsci.QsciLexerYAML
 
-class VerilogLexerSelector(_FilenameLexerSelector):
-    extensions = ('.v', '.vh')
-    _lexer = Qsci.QsciLexerVerilog
-
 class VHDLLexerSelector(_FilenameLexerSelector):
     extensions = ('.vhd', '.vhdl')
     _lexer = Qsci.QsciLexerVHDL
 
 class SpiceLexerSelector(_FilenameLexerSelector):
     extensions = ('.cir', '.sp',)
-    _lexer = Qsci.QsciLexerSpice
+    try:
+        _lexer = Qsci.QsciLexerSpice
+    except AttributeError:
+        # is there a better fallback?
+        _lexer = Qsci.QsciLexerCPP
+
+class VerilogLexerSelector(_FilenameLexerSelector):
+    extensions = ('.v', '.vh')
+    try:
+        _lexer = Qsci.QsciLexerVerilog
+    except AttributeError:
+        # is there a better fallback?
+        _lexer = Qsci.QsciLexerCPP
 
 class PropertyLexerSelector(_FilenameLexerSelector):
     extensions = ('.ini', '.properties')

tortoisehg/hgqt/qtlib.py

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
-if PYQT_VERSION_STR.split('.') < ['4', '7'] or \
+if PYQT_VERSION_STR.split('.') < ['4', '6'] or \
    QT_VERSION_STR.split('.') < ['4', '6']:
     sys.stderr.write('TortoiseHg requires Qt 4.6 and PyQt 4.7\n')
     sys.stderr.write('You have Qt %s and PyQt %s\n' %
     This searches for the icon from theme, Qt resource or icons directory,
     named as 'name.(svg|png|ico)'.
     """
-    if QIcon.hasThemeIcon(name):
+    if hasattr(QIcon, 'hasThemeIcon') and QIcon.hasThemeIcon(name):
         return QIcon.fromTheme(name)
 
     try:

tortoisehg/hgqt/reporegistry.py

         self.setAcceptDrops(True)
         self.setAutoScroll(True)
         self.setDragDropMode(QAbstractItemView.DragDrop)
-        self.setDefaultDropAction(Qt.MoveAction)
+        if PYQT_VERSION_STR.split('.') >= ['4', '7']:
+            self.setDefaultDropAction(Qt.MoveAction)
         self.setDropIndicatorShown(True)
         self.setEditTriggers(QAbstractItemView.DoubleClicked
                              | QAbstractItemView.EditKeyPressed)

tortoisehg/hgqt/repotreemodel.py

     xw.writeEndDocument()
 
 def readXml(source, rootElementName):
+    if PYQT_VERSION_STR.split('.') < ['4', '7']:
+        return
     itemread = None
     xr = QXmlStreamReader(source)
     if xr.readNextStartElement():

tortoisehg/hgqt/repoview.py

         self.htmlDelegate = htmldelegate.HTMLDelegate(self)
 
         self.setAcceptDrops(True)
-        self.setDefaultDropAction(Qt.MoveAction)
+        if PYQT_VERSION_STR.split('.') >= ['4', '7']:
+            self.setDefaultDropAction(Qt.MoveAction)
         self.setDragEnabled(True)
         self.setDropIndicatorShown(True)
         self.setDragDropMode(QAbstractItemView.InternalMove)