changeset 225:f6dcc85cd8ca

use SIP API v2
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 22 May 2014 05:49:46 +0200
parents 218c2b376169
children 016c89dfd488
files DisplayModel.py FeedEntryTableModel.py feedworm.py
diffstat 3 files changed, 25 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/DisplayModel.py	Thu May 22 05:49:14 2014 +0200
+++ b/DisplayModel.py	Thu May 22 05:49:46 2014 +0200
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-from PyQt4.QtCore import QAbstractListModel, QModelIndex, QVariant, Qt
+from PyQt4.QtCore import QAbstractListModel, QModelIndex, Qt
 
 class DisplayModel(QAbstractListModel):
     def __init__(self, parent=None, list=None, displayAttribute=None, **args):
@@ -15,9 +15,9 @@
             row = index.row()
             item = self.list[row]
             displayString = self._stringToDisplay(item)
-            return QVariant(displayString)
+            return displayString
         else:
-            return QVariant()
+            return None
 
     def _stringToDisplay(self, item):
         if hasattr(item, self.displayAttribute):
--- a/FeedEntryTableModel.py	Thu May 22 05:49:14 2014 +0200
+++ b/FeedEntryTableModel.py	Thu May 22 05:49:46 2014 +0200
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt
+from PyQt4.QtCore import QAbstractTableModel, Qt
 
 class TableModel(QAbstractTableModel):
     '''
@@ -12,18 +12,18 @@
     def headerData(self, section, orientation, role):
         if orientation == Qt.Horizontal and role == Qt.DisplayRole:
             value = self.headerDataForColumn(section)
-            return QVariant(value)
+            value
         else:
-            return QVariant()
+            return None
 
     def data(self, index, role):
         if not index.isValid():
-            return QVariant()
+            return None
         elif role != Qt.DisplayRole:
-            return QVariant()
+            return None
         else:
             value = self.dataForRowAndColumn(index.row(), index.column())
-            return QVariant(value)
+            return value
 
 
 class FeedEntryTableModel(TableModel):
--- a/feedworm.py	Thu May 22 05:49:14 2014 +0200
+++ b/feedworm.py	Thu May 22 05:49:46 2014 +0200
@@ -1,4 +1,10 @@
 # -*- coding: utf-8 -*-
+
+# see http://stackoverflow.com/questions/6238193/pyqt-new-api-with-python-2
+import sip
+sip.setapi('QString', 2)
+sip.setapi('QVariant', 2)
+
 from MainWindow import MainWindow
 from PyQt4 import QtGui
 from PyQt4.QtNetwork import QNetworkProxy
@@ -7,6 +13,13 @@
 import sys
 import warnings
 
+def filterWarnings():
+    # filter out the warnings about duplicate inclusion of argparse
+    warnings.filterwarnings("ignore", category=UserWarning)
+
+def configureLogging():
+    logging.basicConfig(level=logging.DEBUG)
+    
 def setupProxy(preferences):
     if preferences.isProxyConfigured() and preferences.useProxy():
         proxyHost = preferences.proxyHost()
@@ -15,10 +28,9 @@
         QNetworkProxy.setApplicationProxy(proxy)
 
 if __name__ == '__main__':
-    # filter out the warnings about duplicate inclusion of argparse
-    warnings.filterwarnings("ignore", category=UserWarning)
-
-    logging.basicConfig(level=logging.DEBUG)
+    filterWarnings()
+    configureLogging()
+    
     backend = BackendFactory.createBackend()
     preferences = backend.preferences()
     setupProxy(preferences)