ESS_GUI_ordering
Last change
on this file since 8aa3c4d was
8aa3c4d,
checked in by Piotr Rozyczko <piotr.rozyczko@…>, 5 years ago
|
Initial commit of the dataset ordering functionality TRAC#933
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | """ |
---|
2 | Widget/logic for dataset ordering. |
---|
3 | """ |
---|
4 | from PyQt5 import QtWidgets |
---|
5 | |
---|
6 | import sas.qtgui.Utilities.GuiUtils as GuiUtils |
---|
7 | |
---|
8 | # Local UI |
---|
9 | from sas.qtgui.Perspectives.Fitting.UI.OrderWidgetUI import Ui_OrderWidgetUI |
---|
10 | |
---|
11 | class OrderWidget(QtWidgets.QWidget, Ui_OrderWidgetUI): |
---|
12 | def __init__(self, parent=None, all_data=None): |
---|
13 | super(OrderWidget, self).__init__() |
---|
14 | |
---|
15 | self.setupUi(self) |
---|
16 | self.all_data = all_data |
---|
17 | self.order = {} |
---|
18 | |
---|
19 | self.setupTable() |
---|
20 | |
---|
21 | def updateData(self, all_data): |
---|
22 | """ |
---|
23 | Read in new datasets and update the view |
---|
24 | """ |
---|
25 | self.all_data = all_data |
---|
26 | self.lstOrder.clear() |
---|
27 | self.setupTable() |
---|
28 | |
---|
29 | def setupTable(self): |
---|
30 | """ |
---|
31 | Populate the widget with dataset names in original order |
---|
32 | """ |
---|
33 | if self.all_data is None: return |
---|
34 | for item in self.all_data: |
---|
35 | if not hasattr(item, 'data'): continue |
---|
36 | dataset = GuiUtils.dataFromItem(item) |
---|
37 | if dataset is None: continue |
---|
38 | dataset_name = dataset.filename |
---|
39 | self.order[dataset_name] = item |
---|
40 | self.lstOrder.addItem(dataset_name) |
---|
41 | |
---|
42 | def ordering(self): |
---|
43 | """ |
---|
44 | Returns the current ordering of the datasets |
---|
45 | """ |
---|
46 | order = [] |
---|
47 | for row in range(self.lstOrder.count()): |
---|
48 | item_name = self.lstOrder.item(row).text() |
---|
49 | order.append(self.order[item_name]) |
---|
50 | return order |
---|
51 | |
---|
Note: See
TracBrowser
for help on using the repository browser.