source: orange/Orange/OrangeCanvas/gui/tests/test_tooltree.py @ 11131:984471b6fa6e

Revision 11131:984471b6fa6e, 1.4 KB checked in by Ales Erjavec <ales.erjavec@…>, 18 months ago (diff)

Improved keyboard control and styling in quick menu.

Line 
1"""
2Test for tooltree
3
4"""
5
6from PyQt4.QtGui import QStandardItemModel, QStandardItem, QAction
7
8from ..tooltree import ToolTree
9
10from ...registry.qt import QtWidgetRegistry
11from ...registry.tests import small_testing_registry
12
13from ..test import QAppTestCase
14
15
16class TestToolTree(QAppTestCase):
17    def test_tooltree(self):
18        tree = ToolTree()
19        role = tree.actionRole()
20        model = QStandardItemModel()
21        tree.setModel(model)
22        item = QStandardItem("One")
23        item.setData(QAction("One", tree), role)
24        model.appendRow([item])
25
26        cat = QStandardItem("A Category")
27        item = QStandardItem("Two")
28        item.setData(QAction("Two", tree), role)
29        cat.appendRow([item])
30        item = QStandardItem("Three")
31        item.setData(QAction("Three", tree), role)
32        cat.appendRow([item])
33
34        model.appendRow([cat])
35
36        def p(action):
37            print "triggered", action.text()
38
39        tree.triggered.connect(p)
40
41        tree.show()
42
43        self.app.exec_()
44
45    def test_tooltree_registry(self):
46        reg = QtWidgetRegistry(small_testing_registry())
47
48        tree = ToolTree()
49        tree.setModel(reg.model())
50        tree.setActionRole(reg.WIDGET_ACTION_ROLE)
51        tree.show()
52
53        def p(action):
54            print "triggered", action.text()
55        tree.triggered.connect(p)
56
57        self.app.exec_()
Note: See TracBrowser for help on using the repository browser.