From 7b9f9fb220c868183947f97087202029df47201c Mon Sep 17 00:00:00 2001 From: gimick Date: Thu, 24 Feb 2011 20:59:44 +0000 Subject: [PATCH] filters: add CAP category, and alter all/none to recognise cap(cn) games --- pyfpdb/Filters.py | 49 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/pyfpdb/Filters.py b/pyfpdb/Filters.py index 557bb846..2e27ae96 100644 --- a/pyfpdb/Filters.py +++ b/pyfpdb/Filters.py @@ -57,7 +57,7 @@ class Filters(threading.Thread): ,'groupstitle':_('Grouping:'), 'posnshow':_('Show Position Stats') ,'datestitle':_('Date:') ,'groupsall':_('All Players') - ,'limitsFL':'FL', 'limitsNL':'NL', 'limitsPL':'PL', 'ring':_('Ring'), 'tour':_('Tourney') + ,'limitsFL':'FL', 'limitsNL':'NL', 'limitsPL':'PL', 'limitsCN':'CAP', 'ring':_('Ring'), 'tour':_('Tourney') } gen = self.conf.get_general_params() @@ -79,7 +79,7 @@ class Filters(threading.Thread): self.sw.show() print _("DEBUG: New packing box created!") - self.found = {'nl':False, 'fl':False, 'pl':False, 'ring':False, 'tour':False} + self.found = {'nl':False, 'fl':False, 'pl':False, 'cn':False, 'ring':False, 'tour':False} self.label = {} self.callback = {} @@ -154,6 +154,7 @@ class Filters(threading.Thread): self.cbFL = None self.cbNL = None self.cbPL = None + self.cbCN = None self.rb = {} # radio buttons for ring/tour self.type = None # ring/tour self.types = {} # list of all ring/tour values @@ -429,7 +430,7 @@ class Filters(threading.Thread): #print "__set_limit_select: limit =", limit, w.get_active() self.limits[limit] = w.get_active() log.debug(_("self.limit[%s] set to %s") %(limit, self.limits[limit])) - if limit.isdigit() or (len(limit) > 2 and (limit[-2:] == 'nl' or limit[-2:] == 'fl' or limit[-2:] == 'pl')): + if limit.isdigit() or (len(limit) > 2 and (limit[-2:] == 'nl' or limit[-2:] == 'fl' or limit[-2:] == 'pl' or limit[-2:] == 'cn')): # turning a leaf limit on with 'None' checked turns 'None' off if self.limits[limit]: if self.cbNoLimits is not None: @@ -438,7 +439,7 @@ class Filters(threading.Thread): else: if self.cbAllLimits is not None: self.cbAllLimits.set_active(False) - # turning off a leaf limit turns off the corresponding fl. nl, or pl + # turning off a leaf limit turns off the corresponding fl. nl, cn or pl if not self.limits[limit]: if limit.isdigit(): if self.cbFL is not None: @@ -446,6 +447,9 @@ class Filters(threading.Thread): elif (len(limit) > 2 and (limit[-2:] == 'nl')): if self.cbNL is not None: self.cbNL.set_active(False) + elif (len(limit) > 2 and (limit[-2:] == 'cn')): + if self.cbCN is not None: + self.cbCN.set_active(False) else: if self.cbPL is not None: self.cbPL.set_active(False) @@ -461,6 +465,8 @@ class Filters(threading.Thread): self.cbNL.set_active(True) if self.cbPL is not None: self.cbPL.set_active(True) + if self.cbCN is not None: + self.cbCN.set_active(True) elif limit == "none": if self.limits[limit]: if self.num_limit_types == 1: @@ -473,6 +479,8 @@ class Filters(threading.Thread): self.cbFL.set_active(False) if self.cbPL is not None: self.cbPL.set_active(False) + if self.cbCN is not None: + self.cbCN.set_active(False) elif limit == "fl": if not self.limits[limit]: # only toggle all fl limits off if they are all currently on @@ -552,6 +560,29 @@ class Filters(threading.Thread): elif self.type == 'tour': if 'ring' in self.rb: self.rb['ring'].set_active(True) + elif limit == "cn": + if not self.limits[limit]: + all_cn_on = True + for cb in self.cbLimits.values(): + t = cb.get_children()[0].get_text() + if "cn" in t and len(t) > 2: + if not cb.get_active(): + all_cn_on = False + found = {'ring':False, 'tour':False} + for cb in self.cbLimits.values(): + t = cb.get_children()[0].get_text() + if "cn" in t and len(t) > 2: + if self.limits[limit] or all_cn_on: + cb.set_active(self.limits[limit]) + found[self.types[t]] = True + if self.limits[limit]: + if not found[self.type]: + if self.type == 'ring': + if 'tour' in self.rb: + self.rb['tour'].set_active(True) + elif self.type == 'tour': + if 'ring' in self.rb: + self.rb['ring'].set_active(True) elif limit == "ring": log.debug("set", limit, "to", self.limits[limit]) if self.limits[limit]: @@ -733,7 +764,7 @@ class Filters(threading.Thread): self.cursor.execute(self.sql.query['getCashLimits']) # selects limitType, bigBlind result = self.db.cursor.fetchall() - self.found = {'nl':False, 'fl':False, 'pl':False, 'ring':False, 'tour':False} + self.found = {'nl':False, 'fl':False, 'pl':False, 'cn':False, 'ring':False, 'tour':False} if len(result) >= 1: hbox = gtk.HBox(True, 0) @@ -758,6 +789,9 @@ class Filters(threading.Thread): elif line[1] == 'pl': name = str(line[2])+line[1] self.found['pl'] = True + elif line[1] == 'cn': + name = str(line[2])+line[1] + self.found['cn'] = True else: name = str(line[2])+line[1] self.found['nl'] = True @@ -786,6 +820,7 @@ class Filters(threading.Thread): if self.found['fl']: self.num_limit_types = self.num_limit_types + 1 if self.found['pl']: self.num_limit_types = self.num_limit_types + 1 if self.found['nl']: self.num_limit_types = self.num_limit_types + 1 + if self.found['cn']: self.num_limit_types = self.num_limit_types + 1 if self.num_limit_types > 1: if self.found['fl']: hbox = gtk.HBox(False, 0) @@ -799,6 +834,10 @@ class Filters(threading.Thread): hbox = gtk.HBox(False, 0) vbox3.pack_start(hbox, False, False, 0) self.cbPL = self.createLimitLine(hbox, 'pl', self.filterText['limitsPL']) + if self.found['cn']: + hbox = gtk.HBox(False, 0) + vbox3.pack_start(hbox, False, False, 0) + self.cbCN = self.createLimitLine(hbox, 'cn', self.filterText['limitsCN']) dest = vbox2 # for ring/tour buttons else: print _("INFO: No games returned from database")