Changeset c4b23dd in sasview for src/sas


Ignore:
Timestamp:
Sep 8, 2018 4:16:44 AM (6 years ago)
Author:
Torin Cooper-Bennun <torin.cooper-bennun@…>
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:
bfb5d9e, 0cd98a1
Parents:
f07d8ab
git-author:
Torin Cooper-Bennun <torin.cooper-bennun@…> (09/08/18 04:16:39)
git-committer:
Torin Cooper-Bennun <torin.cooper-bennun@…> (09/08/18 04:16:44)
Message:

reduce nesting in some FittingWidget? methods

File:
1 edited

Legend:

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

    r50cafe7 rc4b23dd  
    800800    def getConstraintForRow(self, row): 
    801801        """ 
    802         For the given row, return its constraint, if any 
    803         """ 
    804         if self.isCheckable(row): 
    805             item = self._model_model.item(row, 1) 
    806             try: 
    807                 return item.child(0).data() 
    808             except AttributeError: 
    809                 # return none when no constraints 
    810                 pass 
    811         return None 
     802        For the given row, return its constraint, if any (otherwise None) 
     803        """ 
     804        if not self.isCheckable(row): 
     805            return None 
     806        item = self._model_model.item(row, 1) 
     807        try: 
     808            return item.child(0).data() 
     809        except AttributeError: 
     810            return None 
    812811 
    813812    def rowHasConstraint(self, row): 
     
    815814        Finds out if row of the main model has a constraint child 
    816815        """ 
    817         if self.isCheckable(row): 
    818             item = self._model_model.item(row, 1) 
    819             if item.hasChildren(): 
    820                 c = item.child(0).data() 
    821                 if isinstance(c, Constraint): 
    822                     return True 
     816        if not self.isCheckable(row): 
     817            return False 
     818        item = self._model_model.item(row, 1) 
     819        if not item.hasChildren(): 
     820            return False 
     821        c = item.child(0).data() 
     822        if isinstance(c, Constraint): 
     823            return True 
    823824        return False 
    824825 
     
    827828        Finds out if row of the main model has an active constraint child 
    828829        """ 
    829         if self.isCheckable(row): 
    830             item = self._model_model.item(row, 1) 
    831             if item.hasChildren(): 
    832                 c = item.child(0).data() 
    833                 if isinstance(c, Constraint) and c.active: 
    834                     return True 
     830        if not self.isCheckable(row): 
     831            return False 
     832        item = self._model_model.item(row, 1) 
     833        if not item.hasChildren(): 
     834            return False 
     835        c = item.child(0).data() 
     836        if isinstance(c, Constraint) and c.active: 
     837            return True 
    835838        return False 
    836839 
     
    839842        Finds out if row of the main model has an active, nontrivial constraint child 
    840843        """ 
    841         if self.isCheckable(row): 
    842             item = self._model_model.item(row, 1) 
    843             if item.hasChildren(): 
    844                 c = item.child(0).data() 
    845                 if isinstance(c, Constraint) and c.func and c.active: 
    846                     return True 
     844        if not self.isCheckable(row): 
     845            return False 
     846        item = self._model_model.item(row, 1) 
     847        if not item.hasChildren(): 
     848            return False 
     849        c = item.child(0).data() 
     850        if isinstance(c, Constraint) and c.func and c.active: 
     851            return True 
    847852        return False 
    848853 
     
    10541059            # Show constraint, if present 
    10551060            row = rows[0].row() 
    1056             if self.rowHasConstraint(row): 
    1057                 func = self.getConstraintForRow(row).func 
    1058                 if func is not None: 
    1059                     self.communicate.statusBarUpdateSignal.emit("Active constrain: "+func) 
     1061            if not self.rowHasConstraint(row): 
     1062                return 
     1063            func = self.getConstraintForRow(row).func 
     1064            if func is not None: 
     1065                self.communicate.statusBarUpdateSignal.emit("Active constrain: "+func) 
    10601066 
    10611067    def replaceConstraintName(self, old_name, new_name=""): 
Note: See TracChangeset for help on using the changeset viewer.