Skip to content
Permalink
Browse files

Merge pull request #2761 from kernc/rm-plotutils

Remove dead orangeqt code; add gui.listView multiselection handling
  • Loading branch information...
janezd committed Dec 8, 2017
2 parents a09c807 + 0831eb1 commit 7e6f9e5bf03ad6b0efd55575ca1633190033e5c2
Showing with 88 additions and 11,684 deletions.
  1. +0 −1 MANIFEST.in
  2. +37 −26 Orange/widgets/gui.py
  3. +42 −5 Orange/widgets/tests/test_gui.py
  4. +0 −9 Orange/widgets/utils/__init__.py
  5. +3 −20 Orange/widgets/utils/plot/__init__.py
  6. +0 −96 Orange/widgets/utils/plot/generator.gs
  7. +0 −8 Orange/widgets/utils/plot/generator.vs
  8. +0 −372 Orange/widgets/utils/plot/owaxis.py
  9. +0 −267 Orange/widgets/utils/plot/owcurve.py
  10. +0 −363 Orange/widgets/utils/plot/owlegend.py
  11. +0 −391 Orange/widgets/utils/plot/owopenglrenderer.py
  12. +0 −1,878 Orange/widgets/utils/plot/owplot.py
  13. +0 −1,248 Orange/widgets/utils/plot/owplot3d.py
  14. +0 −79 Orange/widgets/utils/plot/owpoint.py
  15. +0 −48 Orange/widgets/utils/plot/owtheme.py
  16. +0 −522 Orange/widgets/utils/plot/owtools.py
  17. 0 Orange/widgets/utils/plot/primitives/__init__.py
  18. +0 −37 Orange/widgets/utils/plot/primitives/circle.obj
  19. +0 −35 Orange/widgets/utils/plot/primitives/circle_edges.obj
  20. +0 −136 Orange/widgets/utils/plot/primitives/cone_hq.obj
  21. +0 −72 Orange/widgets/utils/plot/primitives/cross.obj
  22. +0 −26 Orange/widgets/utils/plot/primitives/cross_2d.obj
  23. +0 −27 Orange/widgets/utils/plot/primitives/cross_2d_edges.obj
  24. +0 −26 Orange/widgets/utils/plot/primitives/cross_edges.obj
  25. +0 −24 Orange/widgets/utils/plot/primitives/cube.obj
  26. +0 −23 Orange/widgets/utils/plot/primitives/cube_edges.obj
  27. +0 −10 Orange/widgets/utils/plot/primitives/diamond.obj
  28. +0 −11 Orange/widgets/utils/plot/primitives/diamond_edges.obj
  29. +0 −15 Orange/widgets/utils/plot/primitives/dpyramid.obj
  30. +0 −16 Orange/widgets/utils/plot/primitives/dpyramid_edges.obj
  31. +0 −8 Orange/widgets/utils/plot/primitives/dtriangle.obj
  32. +0 −8 Orange/widgets/utils/plot/primitives/dtriangle_edges.obj
  33. +0 −15 Orange/widgets/utils/plot/primitives/lpyramid.obj
  34. +0 −16 Orange/widgets/utils/plot/primitives/lpyramid_edges.obj
  35. +0 −8 Orange/widgets/utils/plot/primitives/ltriangle.obj
  36. +0 −8 Orange/widgets/utils/plot/primitives/ltriangle_edges.obj
  37. +0 −18 Orange/widgets/utils/plot/primitives/lwedge.obj
  38. +0 −8 Orange/widgets/utils/plot/primitives/lwedge_2d.obj
  39. +0 −9 Orange/widgets/utils/plot/primitives/lwedge_2d_edges.obj
  40. +0 −19 Orange/widgets/utils/plot/primitives/lwedge_edges.obj
  41. +0 −26 Orange/widgets/utils/plot/primitives/octahedron.obj
  42. +0 −20 Orange/widgets/utils/plot/primitives/octahedron_edges.obj
  43. +0 −15 Orange/widgets/utils/plot/primitives/pyramid.obj
  44. +0 −16 Orange/widgets/utils/plot/primitives/pyramid_edges.obj
  45. +0 −10 Orange/widgets/utils/plot/primitives/rect.obj
  46. +0 −10 Orange/widgets/utils/plot/primitives/rect_edges.obj
  47. +0 −104 Orange/widgets/utils/plot/primitives/sphere.obj
  48. +0 −83 Orange/widgets/utils/plot/primitives/sphere_edges.obj
  49. +0 −3,976 Orange/widgets/utils/plot/primitives/sphere_hq.obj
  50. +0 −8 Orange/widgets/utils/plot/primitives/triangle.obj
  51. +0 −8 Orange/widgets/utils/plot/primitives/triangle_edges.obj
  52. +0 −18 Orange/widgets/utils/plot/primitives/wedge.obj
  53. +0 −8 Orange/widgets/utils/plot/primitives/wedge_2d.obj
  54. +0 −9 Orange/widgets/utils/plot/primitives/wedge_2d_edges.obj
  55. +0 −18 Orange/widgets/utils/plot/primitives/wedge_edges.obj
  56. +0 −72 Orange/widgets/utils/plot/primitives/xcross.obj
  57. +0 −26 Orange/widgets/utils/plot/primitives/xcross_2d.obj
  58. +0 −27 Orange/widgets/utils/plot/primitives/xcross_2d_edges.obj
  59. +0 −63 Orange/widgets/utils/plot/primitives/xcross_edges.obj
  60. +0 −6 Orange/widgets/utils/plot/symbol.fs
  61. +0 −94 Orange/widgets/utils/plot/symbol.vs
  62. +1 −4 Orange/widgets/utils/scaling.py
  63. +0 −159 Orange/widgets/utils/toolbar.py
  64. +5 −0 Orange/widgets/utils/webview.py
  65. +0 −227 Orange/widgets/visualize/owparallelcoordinates.py
  66. +0 −660 Orange/widgets/visualize/owparallelgraph.py
  67. +0 −107 Orange/widgets/visualize/owviswidget.py
  68. +0 −2 setup.py
@@ -11,7 +11,6 @@ recursive-include Orange/widgets *.png *.svg *.js *.css *.html
recursive-include Orange/widgets/tests *.tab
recursive-include Orange/widgets/data/tests *.tab
recursive-include Orange/widgets/tests/workflows *.ows
recursive-include Orange/widgets/utils/plot *.fs *.vs *.gs *.obj

recursive-include distribute *.svg *.desktop

@@ -9,12 +9,12 @@
import warnings
import logging
from types import LambdaType
from collections import defaultdict
from collections import defaultdict, Sequence

import pkg_resources

from AnyQt import QtWidgets, QtCore, QtGui
from AnyQt.QtCore import Qt, QSize, pyqtSignal as Signal
from AnyQt.QtCore import Qt, QSize, QItemSelection, pyqtSignal as Signal
from AnyQt.QtGui import QCursor, QColor
from AnyQt.QtWidgets import (
QApplication, QStyle, QSizePolicy, QWidget, QLabel, QGroupBox, QSlider,
@@ -1084,7 +1084,7 @@ def listView(widget, master, value=None, model=None, box=None, callback=None,
connectControl(master, value, callback,
view.selectionModel().selectionChanged,
CallFrontListView(view),
CallBackListView(model, master, value))
CallBackListView(model, view, master, value))
misc.setdefault('addSpace', True)
miscellanea(view, bg, widget, **misc)
return view
@@ -2270,20 +2270,25 @@ def __call__(self, *value):


class CallBackListView(ControlledCallback):
def __init__(self, model, widget, attribute):
def __init__(self, model, view, widget, attribute):
super().__init__(widget, attribute)
self.model = model
self.view = view

# triggered by selectionModel().selectionChanged()
def __call__(self, newSelection, _):
def __call__(self, *_):
# This must be imported locally to avoid circular imports
from Orange.widgets.utils.itemmodels import PyListModel
indexes = newSelection.indexes()
if indexes:
value = newSelection.indexes()[0].row()
values = [i.row()
for i in self.view.selectionModel().selection().indexes()]
if values:
# FIXME: irrespective of PyListModel check, this might/should always
# callback with values!
if isinstance(self.model, PyListModel):
value = self.model[value]
self.acyclic_setattr(value)
values = [self.model[i] for i in values]
if self.view.selectionMode() == self.view.SingleSelection:
values = values[0]
self.acyclic_setattr(values)


class CallBackListBox:
@@ -2467,22 +2472,28 @@ def action(self, value):


class CallFrontListView(ControlledCallFront):
def action(self, value):
model = self.control.model()
if not isinstance(value, int):
if isinstance(value, str):
search_role = Qt.DisplayRole
elif isinstance(value, Variable):
search_role = TableVariable
else:
search_role = Qt.DisplayRole
value = str(value)
for i in range(model.rowCount()):
if model.data(model.index(i), search_role) == value:
value = i
break
sel_model = self.control.selectionModel()
sel_model.select(model.index(value), sel_model.ClearAndSelect)
def action(self, values):
view = self.control
model = view.model()
sel_model = view.selectionModel()

if not isinstance(values, Sequence):
values = [values]

selection = QItemSelection()
for value in values:
if not isinstance(value, int):
if isinstance(value, Variable):
search_role = TableVariable
else:
search_role = Qt.DisplayRole
value = str(value)
for i in range(model.rowCount()):
if model.data(model.index(i), search_role) == value:
value = i
break
selection.select(model.index(value), model.index(value))
sel_model.select(selection, sel_model.ClearAndSelect)


class CallFrontListBox(ControlledCallFront):
@@ -17,25 +17,62 @@ def test_checked_extension(self):


class TestListModel(GuiTest):
def test_select(self):
widget = OWWidget()
widget.foo = None
def setUp(self):
self.widget = OWWidget()
self.widget.foo = None
self.attrs = VariableListModel()
view = gui.listView(widget.controlArea, widget, "foo", model=self.attrs)
self.view = gui.listView(
self.widget.controlArea, self.widget, "foo", model=self.attrs)

def test_select_callback(self):
widget = self.widget
view = self.view

self.assertIsNone(widget.foo)

a, b, c = (ContinuousVariable(x) for x in "abc")
self.attrs[:] = [a, b, c]

view.setCurrentIndex(self.attrs.index(0, 0))
self.assertIs(widget.foo, a)
view.setCurrentIndex(self.attrs.index(2, 0))
self.assertIs(widget.foo, c)

view.setSelectionMode(view.MultiSelection)
sel_model = view.selectionModel()
sel_model.clear()
view.setCurrentIndex(self.attrs.index(1, 0))
self.assertEqual(widget.foo, [b])

def test_select_callfront(self):
widget = self.widget
view = self.view

a, b, c = (ContinuousVariable(x) for x in "abc")
self.attrs[:] = [a, b, c]

widget.foo = b
selection = view.selectedIndexes()
self.assertEqual(len(selection), 1)
self.assertEqual(selection[0].row(), 1)

class ComboBoxText(GuiTest):
view.setSelectionMode(view.MultiSelection)
widget.foo = [a, c]
selection = view.selectedIndexes()
self.assertEqual(len(selection), 2)
self.assertEqual({selection[0].row(), selection[1].row()}, {0, 2})

widget.foo = []
selection = view.selectedIndexes()
self.assertEqual(len(selection), 0)

widget.foo = [2, "b"]
selection = view.selectedIndexes()
self.assertEqual(len(selection), 2)
self.assertEqual({selection[0].row(), selection[1].row()}, {1, 2})


class ComboBoxTest(GuiTest):
def test_set_initial_value(self):
widget = OWWidget()
variables = [ContinuousVariable(x) for x in "abc"]
@@ -37,15 +37,6 @@ def to_html(str):
getHtmlCompatibleString = to_html


def checksum(x):
if x is None:
return None
try:
return x.checksum()
except:
return float('nan')


def get_variable_values_sorted(variable):
"""
Return a list of sorted values for given attribute, if all its values can be
@@ -1,27 +1,10 @@
"""
Plot classes and tools that were once used in Orange widgets
*************************
Plot classes and tools for use in Orange widgets
*************************
The main class of this module is :obj:`.OWPlot`, from which all plots
in visualization widgets should inherit.
This module also contains plot elements, which are normally used by the :obj:`.OWPlot`,
but can also be used directly or subclassed
Due to lack of maintenance (non-functioning), the majority of it has been
stripped in this commit
"""

from .owplotgui import *
from .owpalette import *
from .owconstants import *

try:
from .owcurve import *
from .owpoint import *
from .owlegend import *
from .owaxis import *
from .owplot import *
from .owtools import *
except (ImportError, RuntimeError):
pass

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 7e6f9e5

Please sign in to comment.
You can’t perform that action at this time.