Ignore:
Timestamp:
Jul 10, 2018 6:21:02 AM (6 years ago)
Author:
Torin Cooper-Bennun <torin.cooper-bennun@…>
Branches:
ESS_GUI_iss959
Parents:
6052c02
Message:

improve S(Q) tab tree functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r6052c02 r085e3c9d  
    333333            QTreeView::item:hover { 
    334334                background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1); 
    335                 border: 1px solid #bfcde4; 
     335                /* border: 1px solid #bfcde4; */ 
    336336            } 
    337337 
     
    371371        # Structure factor options model (TEMPORARY EXAMPLE) 
    372372 
    373         header_list = ["Property", "Value"] 
     373        header_list = ["Property", "Option", "Custom value"] 
    374374        num_cols = len(header_list) 
    375375        self._structure_model.setHorizontalHeaderLabels(header_list) 
     
    381381        ] 
    382382 
    383         # these are just an example 
    384383        param_vals = [ 
    385             "P(Q)S(Q)", 
     384            "P(Q)*S(Q)", 
    386385            "ER_mean_curvature", 
    387             "VR_something_or_other" 
     386            "VR_something" 
    388387        ] 
    389388 
     
    402401                item2.setText(val) 
    403402 
    404                 item_toplevel.appendRow([item1, item2]) 
     403                item3 = QtGui.QStandardItem() 
     404                item3.setEditable(False) 
     405 
     406                item_toplevel.appendRow([item1, item2, item3]) 
    405407 
    406408            row_toplevel = [item_toplevel] 
     
    412414            self._structure_model.appendRow(row_toplevel) 
    413415 
    414         self.lstStructureOptions.setModel(self._structure_model) 
    415         self.lstStructureOptions.setItemDelegate(StructureViewDelegate(self)) 
    416         self.lstStructureOptions.setAlternatingRowColors(True) 
    417         self.lstStructureOptions.setStyleSheet(stylesheet) 
     416        self._structure_model.itemChanged.connect( 
     417           self.onStructureViewItemChanged 
     418        ) 
     419 
     420        view = self.lstStructureOptions 
     421 
     422        view.setModel(self._structure_model) 
     423        view.setItemDelegate(StructureViewDelegate(self)) 
     424 
     425        view.setAlternatingRowColors(True) 
     426        view.setSizePolicy( 
     427            QtWidgets.QSizePolicy.MinimumExpanding, 
     428            QtWidgets.QSizePolicy.Expanding 
     429        ) 
     430        view.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) 
     431 
     432        # resize all columns 
     433        for col in range(view.header().count()): 
     434            view.resizeColumnToContents(col) 
     435 
     436        view.setStyleSheet(stylesheet) 
     437 
     438        header = view.header() 
     439        #header.setSectionResizeMode(QtWidgets.QHeaderView.Interactive) 
     440        header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) 
     441        font = header.font() 
     442        font.setBold(True) 
     443        header.setFont(font) 
     444 
     445        view.expandAll() 
    418446 
    419447    def initializeCategoryCombo(self): 
     
    10601088                if func is not None: 
    10611089                    self.communicate.statusBarUpdateSignal.emit("Active constrain: "+func) 
     1090 
     1091    def onStructureViewItemChanged(self, item): 
     1092        """ 
     1093        Make changes as necessary when an item is modified in the structure 
     1094        factor options view. 
     1095        """ 
     1096        if -1 in [item.row(), item.column()]: 
     1097            # not a child item (ignore) 
     1098            return 
     1099 
     1100        # TODO: replace magic numbers, strings with stored params 
     1101        if item.column() == 1: 
     1102            custom_val_item = item.parent().child(item.row(), 2) 
     1103            if item.text() == "custom": 
     1104                custom_val_item.setEditable(True) 
     1105                custom_val_item.setText("type here") 
     1106            else: 
     1107                custom_val_item.setEditable(False) 
     1108                custom_val_item.setText("") 
    10621109 
    10631110    def replaceConstraintName(self, old_name, new_name=""): 
Note: See TracChangeset for help on using the changeset viewer.