-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from tangkong/gui_top_tree
GUI: add top level tree to main window
- Loading branch information
Showing
10 changed files
with
188 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
69 gui_top_tree | ||
############### | ||
|
||
API Breaks | ||
---------- | ||
- N/A | ||
|
||
Features | ||
-------- | ||
- Adds top-level tree to main window | ||
- Adds icons to the TreeModel | ||
- Adds fill_uuid method to TreeModel, which grabs data from client if possible | ||
- Adds context menu on tree view for accessing custom actions. | ||
|
||
Bugfixes | ||
-------- | ||
- N/A | ||
|
||
Maintenance | ||
----------- | ||
- N/A | ||
|
||
Contributors | ||
------------ | ||
- tangkong |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,54 @@ | ||
from uuid import UUID | ||
|
||
from pytestqt.qtbot import QtBot | ||
|
||
from superscore.client import Client | ||
from superscore.widgets.window import Window | ||
|
||
|
||
def count_visible_items(tree_view): | ||
count = 0 | ||
index = tree_view.model().index(0, 0) | ||
while index.isValid(): | ||
count += 1 | ||
print(type(index.internalPointer()._data).__name__) | ||
index = tree_view.indexBelow(index) | ||
return count | ||
|
||
|
||
def test_main_window(qtbot: QtBot, mock_client: Client): | ||
"""Pass if main window opens successfully""" | ||
window = Window(client=mock_client) | ||
qtbot.addWidget(window) | ||
|
||
|
||
def test_sample_window(qtbot: QtBot, sample_client: Client): | ||
window = Window(client=sample_client) | ||
qtbot.addWidget(window) | ||
|
||
assert count_visible_items(window.tree_view) == 4 | ||
|
||
def get_last_index(index): | ||
curr_index = index | ||
while curr_index.isValid(): | ||
new_index = window.tree_view.indexBelow(curr_index) | ||
if not new_index.isValid(): | ||
break | ||
curr_index = new_index | ||
return curr_index | ||
|
||
first_index = window.tree_view.model().index(0, 0) | ||
last_index = get_last_index(first_index) | ||
window.tree_view.expand(last_index) | ||
|
||
assert count_visible_items(window.tree_view) == 7 | ||
|
||
# get new last index after expansion, and signal view has been updated | ||
new_last_index = get_last_index(first_index) | ||
window.tree_view.dataChanged(first_index, new_last_index) | ||
|
||
# check that all exposed entries have been filled | ||
index = first_index | ||
while index.isValid(): | ||
assert not isinstance(index.internalPointer()._data, UUID) | ||
index = window.tree_view.indexBelow(index) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def _get_icon_map(): | ||
# do not pollute namespace | ||
from superscore.model import Collection, Readback, Setpoint, Snapshot | ||
|
||
# a list of qtawesome icon names | ||
icon_map = { | ||
Collection: 'mdi.file-document-multiple', | ||
Snapshot: 'mdi.camera', | ||
Setpoint: 'mdi.target', | ||
Readback: 'mdi.book-open-variant', | ||
} | ||
|
||
return icon_map | ||
|
||
|
||
ICON_MAP = _get_icon_map() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
def get_page_icon_map(): | ||
def get_page_map(): | ||
# Don't pollute the namespace | ||
from superscore.model import Collection, Readback, Setpoint, Snapshot | ||
from superscore.model import Collection | ||
from superscore.widgets.page.entry import CollectionPage | ||
|
||
page_map = { | ||
Collection: CollectionPage | ||
} | ||
|
||
# a list of qtawesome icon names | ||
icon_map = { | ||
Collection: 'mdi.file-document-multiple', | ||
Snapshot: 'mdi.camera', | ||
Setpoint: 'mdi.target', | ||
Readback: 'mdi.book-open-variant', | ||
} | ||
|
||
return page_map, icon_map | ||
return page_map | ||
|
||
|
||
PAGE_MAP, ICON_MAP = get_page_icon_map() | ||
PAGE_MAP = get_page_map() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters