Changeset c6fb57c in sasview
- Timestamp:
- Nov 22, 2017 5:49:06 AM (7 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- cb4d219
- Parents:
- 0580c77
- Location:
- src/sas/qtgui/MainWindow
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/MainWindow/DataExplorer.py
r6a3e1fe rc6fb57c 858 858 self.context_menu.addAction(self.actionQuick3DPlot) 859 859 self.context_menu.addAction(self.actionEditMask) 860 self.context_menu.addSeparator() 861 self.context_menu.addAction(self.actionDelete) 862 860 863 861 864 # Define the callbacks … … 865 868 self.actionQuick3DPlot.triggered.connect(self.quickData3DPlot) 866 869 self.actionEditMask.triggered.connect(self.showEditDataMask) 870 self.actionDelete.triggered.connect(self.deleteItem) 867 871 868 872 def onCustomContextMenu(self, position): … … 996 1000 mask_editor.exec_() 997 1001 1002 def deleteItem(self): 1003 """ 1004 Delete the current item 1005 """ 1006 # Assure this is indeed wanted 1007 delete_msg = "This operation will delete the selected data sets." +\ 1008 "\nDo you want to continue?" 1009 reply = QtWidgets.QMessageBox.question(self, 1010 'Warning', 1011 delete_msg, 1012 QtWidgets.QMessageBox.Yes, 1013 QtWidgets.QMessageBox.No) 1014 1015 if reply == QtWidgets.QMessageBox.No: 1016 return 1017 1018 indices = self.current_view.selectedIndexes() 1019 proxy = self.current_view.model() 1020 model = proxy.sourceModel() 1021 1022 for index in indices: 1023 row_index = proxy.mapToSource(index) 1024 item_to_delete = model.itemFromIndex(row_index) 1025 if item_to_delete.isCheckable(): 1026 row = row_index.row() 1027 if item_to_delete.parent(): 1028 # We have a child item - delete from it 1029 item_to_delete.parent().removeRow(row) 1030 else: 1031 # delete directly from model 1032 model.removeRow(row) 1033 pass 1034 998 1035 def loadComplete(self, output): 999 1036 """ -
src/sas/qtgui/MainWindow/UI/DataExplorerUI.ui
r61a92d4 rc6fb57c 499 499 </property> 500 500 </action> 501 <action name="actionDelete"> 502 <property name="text"> 503 <string>Delete</string> 504 </property> 505 </action> 501 506 </widget> 502 507 <resources/> -
src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py
- Property mode changed from 100755 to 100644
r53c771e rc6fb57c 26 26 import sas.qtgui.Plotting.PlotHelper as PlotHelper 27 27 28 if not QApplication.instance():29 28 #if not QApplication.instance(): 29 app = QApplication(sys.argv) 30 30 31 31 class DataExplorerTest(unittest.TestCase): … … 684 684 self.form.treeView.customContextMenuRequested.emit(rect) 685 685 686 # app.exec_() # debug687 688 686 # See that the menu has been shown 689 687 self.form.context_menu.exec_.assert_called_once() … … 805 803 pass 806 804 805 def notestDeleteItem(self): 806 """ 807 Delete selected item from data explorer 808 """ 809 810 # Mock the confirmation dialog with return=No 811 QMessageBox.question = MagicMock(return_value=QMessageBox.No) 812 813 # Populate the model 814 filename = ["cyl_400_20.txt", "cyl_400_20.txt", "cyl_400_20.txt"] 815 self.form.readData(filename) 816 817 # Assure the model contains three items 818 self.assertEqual(self.form.model.rowCount(), 3) 819 820 # Add an item to first file item 821 item1 = QtGui.QStandardItem("test") 822 item1.setCheckable(True) 823 self.form.model.item(0).appendRow(item1) 824 825 # Check the new item is in 826 827 self.assertTrue(self.form.model.item(0).hasChildren()) 828 829 #select_item = self.form.model.item(0).child(3) 830 select_item = self.form.model.item(0) 831 select_index = self.form.model.indexFromItem(select_item) 832 833 # Open up items 834 self.form.current_view.expandAll() 835 836 # Select the newly created item 837 self.form.current_view.selectionModel().select(select_index, QtCore.QItemSelectionModel.Rows) 838 839 # Attempt at deleting 840 self.form.deleteItem() 841 842 # Test the warning dialog called once 843 self.assertTrue(QMessageBox.question.called) 844 845 # Assure the model still contains the items 846 self.assertEqual(self.form.model.rowCount(), 3) 847 848 # Now, mock the confirmation dialog with return=Yes 849 QMessageBox.question = MagicMock(return_value=QMessageBox.Yes) 850 851 # Select the newly created item 852 self.form.current_view.selectionModel().select(select_index, QtCore.QItemSelectionModel.Rows) 853 # delete it. now for good 854 self.form.deleteItem() 855 856 # Test the warning dialog called once 857 self.assertTrue(QMessageBox.question.called) 858 859 # Assure the model contains no items 860 self.assertEqual(self.form.model.rowCount(), 3) 861 807 862 808 863 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.