From 098fd05aae3bf1cc2a32b5a442b3aae24e475b5f Mon Sep 17 00:00:00 2001
From: astaric <anze.staric@gmail.com>
Date: Mon, 20 May 2013 16:37:18 +0200
Subject: [PATCH 3/7] PyQt api v2.

---
 Orange/canvas/__main__.py                          |  2 +-
 Orange/canvas/application/canvasmain.py            |  8 ++++----
 Orange/canvas/application/canvastooldock.py        | 12 ++++++------
 Orange/canvas/application/settings.py              |  4 +---
 Orange/canvas/application/widgettoolbox.py         | 16 ++++++++--------
 Orange/canvas/canvas/items/controlpoints.py        |  5 ++---
 Orange/canvas/canvas/items/graphicspathobject.py   |  2 +-
 Orange/canvas/canvas/items/nodeitem.py             |  4 ++--
 Orange/canvas/document/interactions.py             | 14 ++++++--------
 Orange/canvas/document/quickmenu.py                | 10 +++++-----
 Orange/canvas/document/schemeedit.py               |  4 ++--
 Orange/canvas/document/tests/test_quickmenu.py     |  2 +-
 Orange/canvas/gui/tests/test_tooltree.py           |  4 ++--
 Orange/canvas/gui/toolgrid.py                      |  2 +-
 Orange/canvas/gui/tooltree.py                      |  4 ++--
 Orange/canvas/preview/previewbrowser.py            |  8 ++++----
 Orange/canvas/preview/previewmodel.py              | 12 ++++++------
 Orange/canvas/registry/qt.py                       | 10 +++++-----
 Orange/canvas/resources.py                         |  4 ++--
 Orange/canvas/scheme/annotations.py                |  6 +++---
 Orange/canvas/utils/propertybindings.py            |  2 +-
 Orange/canvas/utils/qtcompat.py                    | 14 ++------------
 Orange/canvas/utils/settings.py                    | 10 +++++-----
 Orange/canvas/utils/tests/test_propertybindings.py | 10 +++++-----
 24 files changed, 77 insertions(+), 92 deletions(-)

diff --git a/Orange/canvas/__main__.py b/Orange/canvas/__main__.py
index 5cc6f29..c062082 100644
--- a/Orange/canvas/__main__.py
+++ b/Orange/canvas/__main__.py
@@ -178,7 +178,7 @@ def main(argv=None):
 
             if pkg_resources.resource_exists(pkg_name, resource):
                 stylesheet_string = \
-                    pkg_resources.resource_string(pkg_name, resource)
+                    pkg_resources.resource_string(pkg_name, resource).decode()
 
                 base = pkg_resources.resource_filename(pkg_name, "styles")
 
diff --git a/Orange/canvas/application/canvasmain.py b/Orange/canvas/application/canvasmain.py
index e83eb9c..8ee3365 100644
--- a/Orange/canvas/application/canvasmain.py
+++ b/Orange/canvas/application/canvasmain.py
@@ -775,7 +775,7 @@ class CanvasMainWindow(QMainWindow):
     def on_tool_box_widget_activated(self, action):
         """A widget action in the widget toolbox has been activated.
         """
-        widget_desc = action.data().toPyObject()
+        widget_desc = action.data()
         if widget_desc:
             scheme_widget = self.current_document()
             if scheme_widget:
@@ -1562,7 +1562,7 @@ class CanvasMainWindow(QMainWindow):
 
         actions_by_filename = {}
         for action in self.recent_scheme_action_group.actions():
-            path = str(action.data().toString())
+            path = str(action.data())
             actions_by_filename[path] = action
 
         if filename in actions_by_filename:
@@ -1604,7 +1604,7 @@ class CanvasMainWindow(QMainWindow):
 
         # Exclude permanent actions (Browse Recent, separators, Clear List)
         actions_to_remove = [action for action in actions \
-                             if str(action.data().toString())]
+                             if str(action.data())]
 
         for action in actions_to_remove:
             self.recent_menu.removeAction(action)
@@ -1621,7 +1621,7 @@ class CanvasMainWindow(QMainWindow):
             if self.ask_save_changes() == QDialog.Rejected:
                 return
 
-        filename = str(action.data().toString())
+        filename = str(action.data())
         self.load_scheme(filename)
 
     def _on_dock_location_changed(self, location):
diff --git a/Orange/canvas/application/canvastooldock.py b/Orange/canvas/application/canvastooldock.py
index 1139dcd..023ae45 100644
--- a/Orange/canvas/application/canvastooldock.py
+++ b/Orange/canvas/application/canvastooldock.py
@@ -301,11 +301,11 @@ class QuickCategoryToolbar(ToolGrid):
         """
         button = ToolGrid.createButtonForAction(self, action)
 
-        item = action.data().toPyObject()
-        if item.data(Qt.BackgroundRole).isValid():
+        item = action.data()
+        if item.data(Qt.BackgroundRole) is not None:
             brush = item.background()
-        elif item.data(QtWidgetRegistry.BACKGROUND_ROLE).isValid():
-            brush = item.data(QtWidgetRegistry.BACKGROUND_ROLE).toPyObject()
+        elif item.data(QtWidgetRegistry.BACKGROUND_ROLE) is not None:
+            brush = item.data(QtWidgetRegistry.BACKGROUND_ROLE)
         else:
             brush = self.palette().brush(QPalette.Button)
 
@@ -426,8 +426,8 @@ class CategoryPopupMenu(FramelessWindow):
             self.__loop.exit(0)
 
     def __onDragStarted(self, index):
-        desc = toPyObject(index.data(QtWidgetRegistry.WIDGET_DESC_ROLE))
-        icon = toPyObject(index.data(Qt.DecorationRole))
+        desc = index.data(QtWidgetRegistry.WIDGET_DESC_ROLE)
+        icon = index.data(Qt.DecorationRole)
 
         drag_data = QMimeData()
         drag_data.setData(
diff --git a/Orange/canvas/application/settings.py b/Orange/canvas/application/settings.py
index 840fa22..877ed53 100644
--- a/Orange/canvas/application/settings.py
+++ b/Orange/canvas/application/settings.py
@@ -134,7 +134,6 @@ class UserSettingsModel(QAbstractItemModel):
     def setData(self, index, value, role=Qt.EditRole):
         if self._valid(index) and index.column() == 3:
             key = self._keyFromIndex(index)
-            value = toPyObject(value)
             try:
                 self.__settings[key] = value
             except (TypeError, ValueError) as ex:
@@ -488,5 +487,4 @@ class UserSettingsDialog(QMainWindow):
             self.__loop = None
 
     def __macOnToolBarAction(self, action):
-        index, _ = action.data().toInt()
-        self.stack.setCurrentIndex(index)
+        self.stack.setCurrentIndex(action.data())
diff --git a/Orange/canvas/application/widgettoolbox.py b/Orange/canvas/application/widgettoolbox.py
index ccb59ed..4fa06c8 100644
--- a/Orange/canvas/application/widgettoolbox.py
+++ b/Orange/canvas/application/widgettoolbox.py
@@ -151,8 +151,8 @@ class WidgetToolGrid(ToolGrid):
         Insert a widget action (from a `QStandardItem`) at index.
         """
         value = item.data(self.__actionRole)
-        if value.isValid():
-            action = value.toPyObject()
+        if value is not None:
+            action = value
         else:
             action = QAction(item.text(), self)
             action.setIcon(item.icon())
@@ -188,7 +188,7 @@ class WidgetToolGrid(ToolGrid):
         Start a drag from button
         """
         action = button.defaultAction()
-        desc = action.data().toPyObject()  # Widget Description
+        desc = action.data()  # Widget Description
         icon = action.icon()
         drag_data = QMimeData()
         drag_data.setData(
@@ -382,10 +382,10 @@ class WidgetToolBox(ToolBox):
         button = self.tabButton(index)
 
         # Set the 'highlight' color
-        if item.data(Qt.BackgroundRole).isValid():
+        if item.data(Qt.BackgroundRole) is not None:
             brush = item.background()
-        elif item.data(QtWidgetRegistry.BACKGROUND_ROLE).isValid():
-            brush = item.data(QtWidgetRegistry.BACKGROUND_ROLE).toPyObject()
+        elif item.data(QtWidgetRegistry.BACKGROUND_ROLE) is not None:
+            brush = item.data(QtWidgetRegistry.BACKGROUND_ROLE)
         else:
             brush = self.palette().brush(QPalette.Button)
 
@@ -413,7 +413,7 @@ class WidgetToolBox(ToolBox):
         Items have been inserted in the model.
         """
         # Only the top level items (categories) are handled here.
-        if not parent.isValid():
+        if not parent is not None:
             root = self.__model.invisibleRootItem()
             for i in range(start, end + 1):
                 item = root.child(i)
@@ -424,6 +424,6 @@ class WidgetToolBox(ToolBox):
         Rows have been removed from the model.
         """
         # Only the top level items (categories) are handled here.
-        if not parent.isValid():
+        if not parent is not None:
             for i in range(end, start - 1, -1):
                 self.removeItem(i)
diff --git a/Orange/canvas/canvas/items/controlpoints.py b/Orange/canvas/canvas/items/controlpoints.py
index 434a3e5..9027058 100644
--- a/Orange/canvas/canvas/items/controlpoints.py
+++ b/Orange/canvas/canvas/items/controlpoints.py
@@ -1,8 +1,7 @@
 import logging
 
 from PyQt4.QtGui import QGraphicsItem, QGraphicsObject, QBrush, QPainterPath
-from PyQt4.QtCore import Qt, QPointF, QLineF, QRectF, QMargins, QVariant, \
-                         QEvent
+from PyQt4.QtCore import Qt, QPointF, QLineF, QRectF, QMargins, QEvent
 
 from PyQt4.QtCore import pyqtSignal as Signal, pyqtProperty as Property
 
@@ -66,7 +65,7 @@ class ControlPoint(GraphicsPathObject):
         if change == QGraphicsItem.ItemPositionChange:
             pos = value.toPointF()
             newpos = self.constrain(pos)
-            return QVariant(newpos)
+            return newpos
 
         return GraphicsPathObject.itemChange(self, change, value)
 
diff --git a/Orange/canvas/canvas/items/graphicspathobject.py b/Orange/canvas/canvas/items/graphicspathobject.py
index fb8a906..ea78cfd 100644
--- a/Orange/canvas/canvas/items/graphicspathobject.py
+++ b/Orange/canvas/canvas/items/graphicspathobject.py
@@ -96,7 +96,7 @@ class GraphicsPathObject(QGraphicsObject):
     def itemChange(self, change, value):
         if change == QGraphicsObject.ItemPositionHasChanged:
             self.positionChanged.emit()
-            self.positionChanged[QPointF].emit(value.toPyObject())
+            self.positionChanged[QPointF].emit(value)
 
         return QGraphicsObject.itemChange(self, change, value)
 
diff --git a/Orange/canvas/canvas/items/nodeitem.py b/Orange/canvas/canvas/items/nodeitem.py
index a611aa0..fd4788a 100644
--- a/Orange/canvas/canvas/items/nodeitem.py
+++ b/Orange/canvas/canvas/items/nodeitem.py
@@ -309,7 +309,7 @@ class AnchorPoint(QGraphicsObject):
 
     def itemChange(self, change, value):
         if change == QGraphicsItem.ItemScenePositionHasChanged:
-            self.scenePositionChanged.emit(value.toPointF())
+            self.scenePositionChanged.emit(value)
 
         return QGraphicsObject.itemChange(self, change, value)
 
@@ -1175,7 +1175,7 @@ class NodeItem(QGraphicsObject):
 
     def itemChange(self, change, value):
         if change == QGraphicsItem.ItemSelectedChange:
-            self.shapeItem.setSelected(value.toBool())
+            self.shapeItem.setSelected(value)
         elif change == QGraphicsItem.ItemPositionHasChanged:
             self.positionChanged.emit()
 
diff --git a/Orange/canvas/document/interactions.py b/Orange/canvas/document/interactions.py
index e021cbe..c3e7ac6 100644
--- a/Orange/canvas/document/interactions.py
+++ b/Orange/canvas/document/interactions.py
@@ -26,6 +26,7 @@ from PyQt4.QtCore import (
 
 from PyQt4.QtCore import pyqtSignal as Signal
 
+from ..registry.description import WidgetDescription
 from ..registry.qt import QtWidgetRegistry
 from .. import scheme
 from ..canvas import items
@@ -454,8 +455,7 @@ class NewLinkAction(UserInteraction):
 
         def filter(index):
             desc = index.data(QtWidgetRegistry.WIDGET_DESC_ROLE)
-            if desc.isValid():
-                desc = desc.toPyObject()
+            if isinstance(desc, WidgetDescription):
                 return is_compatible(from_desc, desc)
             else:
                 return False
@@ -467,8 +467,8 @@ class NewLinkAction(UserInteraction):
             menu.setFilterFunc(None)
 
         if action:
-            item = action.property("item").toPyObject()
-            desc = item.data(QtWidgetRegistry.WIDGET_DESC_ROLE).toPyObject()
+            item = action.property("item")
+            desc = item.data(QtWidgetRegistry.WIDGET_DESC_ROLE)
             pos = event.scenePos()
             # a new widget should be placed so that the connection
             # stays as it was
@@ -770,8 +770,8 @@ class NewNodeAction(UserInteraction):
 
         action = menu.exec_(pos, search_text)
         if action:
-            item = action.property("item").toPyObject()
-            desc = item.data(QtWidgetRegistry.WIDGET_DESC_ROLE).toPyObject()
+            item = action.property("item")
+            desc = item.data(QtWidgetRegistry.WIDGET_DESC_ROLE)
             # Get the scene position
             view = self.document.view()
             pos = view.mapToScene(view.mapFromGlobal(pos))
diff --git a/Orange/canvas/document/quickmenu.py b/Orange/canvas/document/quickmenu.py
index 0142bd2..0f649b2 100644
--- a/Orange/canvas/document/quickmenu.py
+++ b/Orange/canvas/document/quickmenu.py
@@ -20,7 +20,8 @@ from PyQt4.QtGui import (
     QButtonGroup, QStackedWidget, QHBoxLayout, QVBoxLayout, QSizePolicy,
     QStandardItemModel, QSortFilterProxyModel, QStyleOptionToolButton,
     QStylePainter, QStyle, QApplication, QStyledItemDelegate,
-    QStyleOptionViewItemV4, QSizeGrip, QPolygon, QRegion, QItemSelectionModel
+    QStyleOptionViewItemV4, QSizeGrip, QPolygon, QRegion, QItemSelectionModel,
+    QBrush
 )
 
 from PyQt4.QtCore import pyqtSignal as Signal
@@ -984,11 +985,11 @@ class QuickMenu(FramelessWindow):
         name = str(index.data(Qt.DisplayRole))
         page.setTitle(name)
 
-        icon = index.data(Qt.DecorationRole).toPyObject()
+        icon = index.data(Qt.DecorationRole)
         if isinstance(icon, QIcon):
             page.setIcon(icon)
 
-        page.setToolTip(index.data(Qt.ToolTipRole).toPyObject())
+        page.setToolTip(index.data(Qt.ToolTipRole))
         return page
 
     def setModel(self, model):
@@ -1005,8 +1006,7 @@ class QuickMenu(FramelessWindow):
 
             brush = index.data(QtWidgetRegistry.BACKGROUND_ROLE)
 
-            if brush.isValid():
-                brush = brush.toPyObject()
+            if isinstance(brush, QBrush):
                 base_color = brush.color()
                 button = self.__pages.tabButton(i)
                 button.setStyleSheet(
diff --git a/Orange/canvas/document/schemeedit.py b/Orange/canvas/document/schemeedit.py
index f5a0368..c4f5bf6 100644
--- a/Orange/canvas/document/schemeedit.py
+++ b/Orange/canvas/document/schemeedit.py
@@ -1339,7 +1339,7 @@ class SchemeEditWidget(QWidget):
         else:
             handler = interactions.NewArrowAnnotation(self)
             checked = self.__arrowColorActionGroup.checkedAction()
-            handler.setColor(checked.data().toPyObject())
+            handler.setColor(checked.data())
 
             handler.ended.connect(action.toggle)
 
@@ -1390,7 +1390,7 @@ class SchemeEditWidget(QWidget):
             # Update the preferred color on the interaction handler
             handler = self.__scene.user_interaction_handler
             if isinstance(handler, interactions.NewArrowAnnotation):
-                handler.setColor(action.data().toPyObject())
+                handler.setColor(action.data())
 
     def __onCustomContextMenuRequested(self, pos):
         scenePos = self.view().mapToScene(pos)
diff --git a/Orange/canvas/document/tests/test_quickmenu.py b/Orange/canvas/document/tests/test_quickmenu.py
index 5721127..64b706b 100644
--- a/Orange/canvas/document/tests/test_quickmenu.py
+++ b/Orange/canvas/document/tests/test_quickmenu.py
@@ -79,7 +79,7 @@ class TestMenu(QAppTestCase):
         flat.setSourceModel(model)
 
         def get(row):
-            return flat.index(row, 0).data().toPyObject()
+            return flat.index(row, 0).data()
 
         self.assertEqual(get(0), "0")
         self.assertEqual(get(1), "1")
diff --git a/Orange/canvas/gui/tests/test_tooltree.py b/Orange/canvas/gui/tests/test_tooltree.py
index 76658ab..745d878 100644
--- a/Orange/canvas/gui/tests/test_tooltree.py
+++ b/Orange/canvas/gui/tests/test_tooltree.py
@@ -80,10 +80,10 @@ class TestToolTree(QAppTestCase):
         item.setText("New text")
 
         self.assertTrue(len(changed) == 1)
-        self.assertEquals(changed[-1][0].data(Qt.DisplayRole).toString(),
+        self.assertEquals(changed[-1][0].data(Qt.DisplayRole),
                           "New text")
 
-        self.assertEquals(model.data(model.index(1)).toString(), "New text")
+        self.assertEquals(model.data(model.index(1)), "New text")
 
         model.setFlatteningMode(FlattenedTreeItemModel.InternalNodesDisabled)
 
diff --git a/Orange/canvas/gui/toolgrid.py b/Orange/canvas/gui/toolgrid.py
index 8af487f..94d6bda 100644
--- a/Orange/canvas/gui/toolgrid.py
+++ b/Orange/canvas/gui/toolgrid.py
@@ -287,7 +287,7 @@ class ToolGrid(QFrame):
             button.setIconSize(self.__iconSize)
 
         button.setToolButtonStyle(self.__toolButtonStyle)
-        button.setProperty("tool-grid-button", QVariant(True))
+        button.setProperty("tool-grid-button", True)
         return button
 
     def count(self):
diff --git a/Orange/canvas/gui/tooltree.py b/Orange/canvas/gui/tooltree.py
index c39d98a..d9c3ab4 100644
--- a/Orange/canvas/gui/tooltree.py
+++ b/Orange/canvas/gui/tooltree.py
@@ -124,8 +124,8 @@ class ToolTree(QWidget):
 
     def __actionForIndex(self, index):
         val = index.data(self.__actionRole)
-        if val.isValid():
-            action = val.toPyObject()
+        if val is not None:
+            action = val
             if isinstance(action, QAction):
                 return action
             else:
diff --git a/Orange/canvas/preview/previewbrowser.py b/Orange/canvas/preview/previewbrowser.py
index 6effd26..18dfc9e 100644
--- a/Orange/canvas/preview/previewbrowser.py
+++ b/Orange/canvas/preview/previewbrowser.py
@@ -314,21 +314,21 @@ class PreviewBrowser(QWidget):
             path = ""
             svg = NO_PREVIEW_SVG
         else:
-            description = str(index.data(Qt.WhatsThisRole).toString())
+            description = str(index.data(Qt.WhatsThisRole))
             if not description:
                 description = "No description."
 
             description = escape(description)
             description = description.replace("\n", "<br/>")
 
-            name = str(index.data(Qt.DisplayRole).toString())
+            name = str(index.data(Qt.DisplayRole))
             if not name:
                 name = "Untitled"
 
             name = escape(name)
-            path = str(index.data(Qt.StatusTipRole).toString())
+            path = str(index.data(Qt.StatusTipRole))
 
-            svg = str(index.data(previewmodel.ThumbnailSVGRole).toString())
+            svg = str(index.data(previewmodel.ThumbnailSVGRole))
 
         desc_text = self.__template.format(description=description, name=name)
 
diff --git a/Orange/canvas/preview/previewmodel.py b/Orange/canvas/preview/previewmodel.py
index f266b71..97dfb43 100644
--- a/Orange/canvas/preview/previewmodel.py
+++ b/Orange/canvas/preview/previewmodel.py
@@ -135,11 +135,11 @@ class PreviewItem(QStandardItem):
         """
         desc = self.data(DescriptionRole)
 
-        if desc.isValid():
-            return desc.toString()
+        if desc is not None:
+            return desc
 
         whatsthis = self.data(Qt.WhatsThisRole)
-        return whatsthis.toString()
+        return whatsthis
 
     def setDescription(self, description):
         self.setData(description, DescriptionRole)
@@ -151,8 +151,8 @@ class PreviewItem(QStandardItem):
         This is stored as `ThumbnailSVGRole`
         """
         thumb = self.data(ThumbnailSVGRole)
-        if thumb.isValid():
-            return thumb.toString()
+        if thumb is not None:
+            return thumb
 
     def setThumbnail(self, thumbnail):
         """Set the thumbnail SVG contents as a string.
@@ -176,7 +176,7 @@ class PreviewItem(QStandardItem):
     def path(self):
         """Return the path item data.
         """
-        return self.data(PathRole).toString()
+        return self.data(PathRole)
 
     def setPath(self, path):
         """Set the path data of the item.
diff --git a/Orange/canvas/registry/qt.py b/Orange/canvas/registry/qt.py
index c71faac..a5850ab 100644
--- a/Orange/canvas/registry/qt.py
+++ b/Orange/canvas/registry/qt.py
@@ -141,7 +141,7 @@ class QtWidgetRegistry(QObject, WidgetRegistry):
 
         """
         item = self.item_for_widget(widget)
-        return item.data(self.WIDGET_ACTION_ROLE).toPyObject()
+        return item.data(self.WIDGET_ACTION_ROLE)
 
     def create_action_for_item(self, item):
         """
@@ -162,7 +162,7 @@ class QtWidgetRegistry(QObject, WidgetRegistry):
 
         widget_desc = item.data(self.WIDGET_DESC_ROLE)
         action.setData(widget_desc)
-        action.setProperty("item", QVariant(item))
+        action.setProperty("item", item)
         return action
 
     def _insert_category(self, desc):
@@ -229,7 +229,7 @@ class QtWidgetRegistry(QObject, WidgetRegistry):
 
         item.setToolTip(tooltip)
         item.setFlags(Qt.ItemIsEnabled)
-        item.setData(QVariant(desc), self.CATEGORY_DESC_ROLE)
+        item.setData(desc, self.CATEGORY_DESC_ROLE)
         return item
 
     def _widget_desc_to_std_item(self, desc, category):
@@ -267,11 +267,11 @@ class QtWidgetRegistry(QObject, WidgetRegistry):
         item.setToolTip(tooltip)
         item.setWhatsThis(whats_this_helper(desc))
         item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
-        item.setData(QVariant(desc), self.WIDGET_DESC_ROLE)
+        item.setData(desc, self.WIDGET_DESC_ROLE)
 
         # Create the action for the widget_item
         action = self.create_action_for_item(item)
-        item.setData(QVariant(action), self.WIDGET_ACTION_ROLE)
+        item.setData(action, self.WIDGET_ACTION_ROLE)
         return item
 
 
diff --git a/Orange/canvas/resources.py b/Orange/canvas/resources.py
index b3f78c6..e14810a 100644
--- a/Orange/canvas/resources.py
+++ b/Orange/canvas/resources.py
@@ -79,7 +79,7 @@ def search_paths_from_description(desc):
 
 
 class resource_loader(object):
-    def __init__(self, search_paths=[]):
+    def __init__(self, search_paths=()):
         self._search_paths = []
         self.add_search_paths(search_paths)
 
@@ -171,7 +171,7 @@ class icon_loader(resource_loader):
         if not path:
             path = self.find(self.DEFAULT_ICON if default is None else default)
         if not path:
-            raise IOError(2, "Cannot find %r in %s" % \
+            raise IOError(2, "Cannot find %r in %s" %
                           (name, self.search_paths()))
         if self.is_icon_glob(path):
             icons = self.icon_glob(path)
diff --git a/Orange/canvas/scheme/annotations.py b/Orange/canvas/scheme/annotations.py
index b944070..734e416 100644
--- a/Orange/canvas/scheme/annotations.py
+++ b/Orange/canvas/scheme/annotations.py
@@ -5,7 +5,7 @@ Scheme Annotations
 
 """
 
-from PyQt4.QtCore import QObject, QString
+from PyQt4.QtCore import QObject
 from PyQt4.QtCore import pyqtSignal as Signal
 from PyQt4.QtCore import pyqtProperty as Property
 
@@ -84,7 +84,7 @@ class SchemeArrowAnnotation(BaseSchemeAnnotation):
         names).
 
         """
-        check_type(color, (str, QString))
+        check_type(color, str)
         color = str(color)
         if self.__color != color:
             self.__color = color
@@ -153,7 +153,7 @@ class SchemeTextAnnotation(BaseSchemeAnnotation):
         """
         Set the annotation text.
         """
-        check_type(text, (str, QString))
+        check_type(text, str)
         text = str(text)
         if self.__text != text:
             self.__text = text
diff --git a/Orange/canvas/utils/propertybindings.py b/Orange/canvas/utils/propertybindings.py
index c970b90..adf1df3 100644
--- a/Orange/canvas/utils/propertybindings.py
+++ b/Orange/canvas/utils/propertybindings.py
@@ -78,7 +78,7 @@ class AbstractBoundProperty(QObject):
         """
         Return the property value.
         """
-        return toPyObject(self.obj.property(self.propertyName))
+        return self.obj.property(self.propertyName)
 
     @Slot()
     def notifyChanged(self):
diff --git a/Orange/canvas/utils/qtcompat.py b/Orange/canvas/utils/qtcompat.py
index f46e80a..8457202 100644
--- a/Orange/canvas/utils/qtcompat.py
+++ b/Orange/canvas/utils/qtcompat.py
@@ -42,18 +42,8 @@ QSETTINGS_HAS_TYPE = PYQT_VERSION >= 0x40803
 
 
 def toPyObject(variant):
-    """
-    Return `variant` as a python object if it is wrapped in a `QVariant`
-    instance (using `variant.toPyObject()`). In case the sip API version
-    for QVariant does not export it just return the object unchanged.
-
-    """
-    if HAS_QVARIANT:
-        return variant
-    elif isinstance(variant, QVariant):
-        return variant.toPyObject()
-    else:
-        raise TypeError("Expected a 'QVariant'")
+    """Should not be needed with python 3. Please remove call to toPyObject"""
+    raise NotImplementedError
 
 
 if HAS_QVARIANT:
diff --git a/Orange/canvas/utils/settings.py b/Orange/canvas/utils/settings.py
index 06e5f81..2850eb7 100644
--- a/Orange/canvas/utils/settings.py
+++ b/Orange/canvas/utils/settings.py
@@ -11,7 +11,7 @@ import logging
 
 from collections import namedtuple, MutableMapping
 
-from PyQt4.QtCore import QObject, QString, QChar, QEvent, QCoreApplication
+from PyQt4.QtCore import QObject, QEvent, QCoreApplication
 
 from PyQt4.QtCore import pyqtSignal as Signal
 
@@ -76,9 +76,9 @@ def qt_to_mapped_type(value):
     (i.e. QString to unicode, etc.).
 
     """
-    if isinstance(value, QString):
+    if isinstance(value, str):
         return str(value)
-    elif isinstance(value, QChar):
+    elif isinstance(value, str):
         return str(value)
     else:
         return value
@@ -165,13 +165,13 @@ class Settings(QObject, MutableMapping, metaclass=QABCMeta):
         typesafe = value_type is not None
 
         if value_type is None:
-            value = toPyObject(self.__store.value(fullkey))
+            value = self.__store.value(fullkey)
         else:
             try:
                 value = self.__store.value(fullkey, type=value_type)
             except TypeError:
                 # In case the value was pickled in a type unsafe mode
-                value = toPyObject(self.__store.value(fullkey))
+                value = self.__store.value(fullkey)
                 typesafe = False
 
         if not typesafe:
diff --git a/Orange/canvas/utils/tests/test_propertybindings.py b/Orange/canvas/utils/tests/test_propertybindings.py
index c9f347e..e942bf7 100644
--- a/Orange/canvas/utils/tests/test_propertybindings.py
+++ b/Orange/canvas/utils/tests/test_propertybindings.py
@@ -74,19 +74,19 @@ class Test(test.QAppTestCase):
         source.setProperty("source", 1)
         self.assertEqual(len(schanged), 1)
 
-        self.assertEqual(toPyObject(target.property("target")), None)
+        self.assertEqual(target.property("target"), None)
 
         manager.commit()
 
-        self.assertEqual(toPyObject(target.property("target")), 1)
-        self.assertEqual(toPyObject(target.property("target_copy")), 1)
+        self.assertEqual(target.property("target"), 1)
+        self.assertEqual(target.property("target_copy"), 1)
 
         source.setProperty("source", 2)
 
         manager.setSubmitPolicy(BindingManager.AutoSubmit)
 
-        self.assertEqual(toPyObject(target.property("target")), 2)
-        self.assertEqual(toPyObject(target.property("target_copy")), 2)
+        self.assertEqual(target.property("target"), 2)
+        self.assertEqual(target.property("target_copy"), 2)
 
     def test_prop(self):
         w = QWidget()
-- 
1.8.4.3

