Changeset cbcdd2c in sasview for src/sas/qtgui/DataExplorer.py


Ignore:
Timestamp:
Mar 10, 2017 9:44:44 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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:
cd31251
Parents:
5236449
Message:

QModel items conversion into SasModel? parameters + data display SASVIEW-535

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/DataExplorer.py

    r5236449 rcbcdd2c  
    7373        self.contextMenu() 
    7474 
     75        # Same menus for the theory view 
     76        self.freezeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) 
     77        self.freezeView.customContextMenuRequested.connect(self.onCustomContextMenu) 
     78 
    7579        # Connect the comboboxes 
    7680        self.cbSelect.currentIndexChanged.connect(self.selectData) 
    7781 
    7882        #self.closeEvent.connect(self.closeEvent) 
    79         # self.aboutToQuit.connect(self.closeEvent) 
     83        self.currentChanged.connect(self.onTabSwitch) 
    8084        self.communicator = self.parent.communicator() 
    8185        self.communicator.fileReadSignal.connect(self.loadFromURL) 
    8286        self.communicator.activeGraphsSignal.connect(self.updateGraphCombo) 
    8387        self.communicator.activeGraphName.connect(self.updatePlotName) 
    84         #self.communicator.updateTheoryFromPerspectiveSignal.connect(self.updateTheoryFromPerspective) 
    8588        self.cbgraph.editTextChanged.connect(self.enableGraphCombo) 
    8689        self.cbgraph.currentIndexChanged.connect(self.enableGraphCombo) 
    8790 
    8891        self._perspective = self.parent.perspective() 
    89         self._perspective.updateTheoryFromPerspectiveSignal.connect(self.updateTheoryFromPerspective) 
    9092 
    9193        # Proxy model for showing a subset of Data1D/Data2D content 
     
    111113        self.enableGraphCombo(None) 
    112114 
     115        # Current view on model 
     116        self.current_view = self.treeView 
     117 
    113118    def closeEvent(self, event): 
    114119        """ 
     
    116121        """ 
    117122        event.ignore() 
     123 
     124    def onTabSwitch(self, index): 
     125        """ Callback for tab switching signal """ 
     126        if index == 0: 
     127            self.current_view = self.treeView 
     128        else: 
     129            self.current_view = self.freezeView 
    118130 
    119131    def displayHelp(self): 
     
    725737        Show the right-click context menu in the data treeview 
    726738        """ 
    727         index = self.treeView.indexAt(position) 
     739        index = self.current_view.indexAt(position) 
     740        proxy = self.current_view.model() 
     741        model = proxy.sourceModel() 
     742 
    728743        if index.isValid(): 
    729             model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 
     744            model_item = model.itemFromIndex(proxy.mapToSource(index)) 
    730745            # Find the mapped index 
    731746            orig_index = model_item.isCheckable() 
     
    736751                self.actionEditMask.setEnabled(is_2D) 
    737752                # Fire up the menu 
    738                 self.context_menu.exec_(self.treeView.mapToGlobal(position)) 
     753                self.context_menu.exec_(self.current_view.mapToGlobal(position)) 
    739754 
    740755    def showDataInfo(self): 
     
    742757        Show a simple read-only text edit with data information. 
    743758        """ 
    744         index = self.treeView.selectedIndexes()[0] 
    745         model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 
     759        index = self.current_view.selectedIndexes()[0] 
     760        proxy = self.current_view.model() 
     761        model = proxy.sourceModel() 
     762        model_item = model.itemFromIndex(proxy.mapToSource(index)) 
     763 
    746764        data = GuiUtils.dataFromItem(model_item) 
    747765        if isinstance(data, Data1D): 
     
    769787        Save the data points as either txt or xml 
    770788        """ 
    771         index = self.treeView.selectedIndexes()[0] 
    772         model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 
     789        index = self.current_view.selectedIndexes()[0] 
     790        proxy = self.current_view.model() 
     791        model = proxy.sourceModel() 
     792        model_item = model.itemFromIndex(proxy.mapToSource(index)) 
     793 
    773794        data = GuiUtils.dataFromItem(model_item) 
    774795        if isinstance(data, Data1D): 
     
    781802        Frozen plot - display an image of the plot 
    782803        """ 
    783         index = self.treeView.selectedIndexes()[0] 
    784         model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 
     804        index = self.current_view.selectedIndexes()[0] 
     805        proxy = self.current_view.model() 
     806        model = proxy.sourceModel() 
     807        model_item = model.itemFromIndex(proxy.mapToSource(index)) 
     808 
    785809        data = GuiUtils.dataFromItem(model_item) 
    786810 
     
    805829        Slowish 3D plot 
    806830        """ 
    807         index = self.treeView.selectedIndexes()[0] 
    808         model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 
     831        index = self.current_view.selectedIndexes()[0] 
     832        proxy = self.current_view.model() 
     833        model = proxy.sourceModel() 
     834        model_item = model.itemFromIndex(proxy.mapToSource(index)) 
     835 
    809836        data = GuiUtils.dataFromItem(model_item) 
    810837 
     
    824851        Mask Editor for 2D plots 
    825852        """ 
    826         index = self.treeView.selectedIndexes()[0] 
    827         model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 
     853        index = self.current_view.selectedIndexes()[0] 
     854        proxy = self.current_view.model() 
     855        model = proxy.sourceModel() 
     856        model_item = model.itemFromIndex(proxy.mapToSource(index)) 
     857 
    828858        data = GuiUtils.dataFromItem(model_item) 
    829859 
Note: See TracChangeset for help on using the changeset viewer.