Changeset a24eacf in sasview for src/sas/qtgui/MainWindow/DataExplorer.py
- Timestamp:
- Sep 3, 2018 8:12:41 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 8274471e
- Parents:
- f4a6f2c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/MainWindow/DataExplorer.py
rfacf4ca ra24eacf 826 826 return wlist 827 827 828 def setItemsCheckability(self, model, dimension=None, checked=False): 829 """ 830 For a given model, check or uncheck all items of given dimension 831 """ 832 mode = QtCore.Qt.Checked if checked else QtCore.Qt.Unchecked 833 834 assert isinstance(checked, bool) 835 836 types = (None, Data1D, Data2D) 837 assert dimension in types 838 839 for index in range(model.rowCount()): 840 item = model.item(index) 841 if dimension is not None and not isinstance(GuiUtils.dataFromItem(item), dimension): 842 continue 843 if item.isCheckable() and item.checkState() != mode: 844 item.setCheckState(mode) 845 # look for all children 846 for inner_index in range(item.rowCount()): 847 child = item.child(inner_index) 848 if child.isCheckable() and child.checkState() != mode: 849 child.setCheckState(mode) 850 828 851 def selectData(self, index): 829 852 """ … … 836 859 # Respond appropriately 837 860 if index == 0: 838 # Select All 839 for index in range(self.model.rowCount()): 840 item = self.model.item(index) 841 if item.isCheckable() and item.checkState() == QtCore.Qt.Unchecked: 842 item.setCheckState(QtCore.Qt.Checked) 861 self.setItemsCheckability(self.model, checked=True) 862 843 863 elif index == 1: 844 864 # De-select All 845 for index in range(self.model.rowCount()): 846 item = self.model.item(index) 847 if item.isCheckable() and item.checkState() == QtCore.Qt.Checked: 848 item.setCheckState(QtCore.Qt.Unchecked) 865 self.setItemsCheckability(self.model, checked=False) 849 866 850 867 elif index == 2: 851 868 # Select All 1-D 852 for index in range(self.model.rowCount()): 853 item = self.model.item(index) 854 item.setCheckState(QtCore.Qt.Unchecked) 855 856 try: 857 is1D = isinstance(GuiUtils.dataFromItem(item), Data1D) 858 except AttributeError: 859 msg = "Bad structure of the data model." 860 raise RuntimeError(msg) 861 862 if is1D: 863 item.setCheckState(QtCore.Qt.Checked) 869 self.setItemsCheckability(self.model, dimension=Data1D, checked=True) 864 870 865 871 elif index == 3: 866 872 # Unselect All 1-D 867 for index in range(self.model.rowCount()): 868 item = self.model.item(index) 869 870 try: 871 is1D = isinstance(GuiUtils.dataFromItem(item), Data1D) 872 except AttributeError: 873 msg = "Bad structure of the data model." 874 raise RuntimeError(msg) 875 876 if item.isCheckable() and item.checkState() == QtCore.Qt.Checked and is1D: 877 item.setCheckState(QtCore.Qt.Unchecked) 873 self.setItemsCheckability(self.model, dimension=Data1D, checked=False) 878 874 879 875 elif index == 4: 880 876 # Select All 2-D 881 for index in range(self.model.rowCount()): 882 item = self.model.item(index) 883 item.setCheckState(QtCore.Qt.Unchecked) 884 try: 885 is2D = isinstance(GuiUtils.dataFromItem(item), Data2D) 886 except AttributeError: 887 msg = "Bad structure of the data model." 888 raise RuntimeError(msg) 889 890 if is2D: 891 item.setCheckState(QtCore.Qt.Checked) 877 self.setItemsCheckability(self.model, dimension=Data2D, checked=True) 892 878 893 879 elif index == 5: 894 880 # Unselect All 2-D 895 for index in range(self.model.rowCount()): 896 item = self.model.item(index) 897 898 try: 899 is2D = isinstance(GuiUtils.dataFromItem(item), Data2D) 900 except AttributeError: 901 msg = "Bad structure of the data model." 902 raise RuntimeError(msg) 903 904 if item.isCheckable() and item.checkState() == QtCore.Qt.Checked and is2D: 905 item.setCheckState(QtCore.Qt.Unchecked) 881 self.setItemsCheckability(self.model, dimension=Data2D, checked=False) 906 882 907 883 else:
Note: See TracChangeset
for help on using the changeset viewer.