~launchpad-p-s/sofastatistics/main

« back to all changes in this revision

Viewing changes to dimtree.py

  • Committer: Grant Paton-Simpson
  • Date: 2009-05-22 09:17:43 UTC
  • Revision ID: g@ubuntu-20090522091743-c3pv1cgm110eekgf
Fixed raw table first column display, fixed item config on freq tables, changed misc text.

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
                tree.SelectItem(new_id)
149
149
                self.UpdateDemoDisplay()
150
150
    
151
 
    def setInitialConfig(self, tree, dim, new_id, var_name):
152
 
        "Set initial config for new item"
 
151
    def setInitialConfig(self, tree, dim, new_id, var_name=None):
 
152
        """
 
153
        Set initial config for new item.
 
154
        Variable name not applicable when a column config item rather than
 
155
            a normal column variable.
 
156
        """
153
157
        item_conf = make_table.ItemConfig()
154
158
        if (self.tab_type == make_table.COL_MEASURES \
155
159
                    and dim == dimtables.COLDIM):
159
163
                    and dim == dimtables.ROWDIM):
160
164
            item_conf.measures_lst = \
161
165
                [make_table.get_default_measure(make_table.ROW_SUMM)]
162
 
        item_conf.bolnumeric = self.flds[var_name][getdata.FLD_BOLNUMERIC]
 
166
        if var_name:
 
167
            item_conf.bolnumeric = self.flds[var_name][getdata.FLD_BOLNUMERIC]
 
168
        else:
 
169
            item_conf.bolnumeric = False
163
170
        tree.SetItemPyData(new_id, item_conf)
164
171
        tree.SetItemText(new_id, item_conf.getSummary(), 1)
165
172
    
380
387
        Configure column item e.g. measures, total.
381
388
        Either with columns vars or without.  If without, only filtering 
382
389
            by row vars.  Total doesn't make sense in this context.
 
390
        
383
391
        """
384
 
        empty_tree = not util.ItemHasChildren(tree=self.coltree, 
 
392
        empty_coltree = not util.ItemHasChildren(tree=self.coltree, 
385
393
                                              parent=self.colRoot)
386
394
        # empty_tree = not self.coltree.ItemHasChildren(self.colRoot) #buggy if root hidden
387
395
        # i.e. if there is only the root there
388
396
        # no col vars - just set measures (without total)
389
 
        if empty_tree and self.tab_type == make_table.COL_MEASURES:
 
397
        if empty_coltree and self.tab_type == make_table.COL_MEASURES:
 
398
            empty_rowtree = not util.ItemHasChildren(tree=self.rowtree, 
 
399
                                                     parent=self.rowRoot)
 
400
            if empty_rowtree:
 
401
                return
390
402
            #add special node before getting config
391
403
            self.col_no_vars_item = \
392
404
                self.coltree.AppendItem(self.colRoot, 
393
405
                                        make_table.COL_MEASURES_TREE_LBL)
394
 
            self.demo_tab.setInitialConfig(dimtables.COLDIM, 
395
 
                                           self.col_no_vars_item)
 
406
            self.setInitialConfig(self.coltree, dimtables.COLDIM, 
 
407
                                  self.col_no_vars_item)
396
408
            self.demo_tab.col_no_vars_item = self.col_no_vars_item
397
409
            self.coltree.ExpandAll(self.colRoot)
398
410
            self.coltree.SelectItem(self.col_no_vars_item)
401
413
            self.getColConfig(node_ids=[self.col_no_vars_item], 
402
414
                                  has_col_vars=False)
403
415
            self.UpdateDemoDisplay()
404
 
        elif empty_tree and self.tab_type == make_table.ROW_SUMM:
 
416
        elif empty_coltree and self.tab_type == make_table.ROW_SUMM:
405
417
            return
406
418
        else: # not an empty col_measures or row summ table
407
419
            selected_ids = self.coltree.GetSelections()
409
421
            # if one has children, they all must
410
422
            # if one has no children, none can
411
423
            config_ok = True
412
 
            if not empty_tree:
 
424
            if not empty_coltree:
413
425
                first_has_children = util.ItemHasChildren(tree=self.coltree,
414
426
                                                          parent=selected_ids[0])
415
427
                for selected_id in selected_ids[1:]: