Пример #1
0
 def add_result(self, data, key):
     racedata = {
         "pindex": self.pigeon.pindex,
         "date": data["date"],
         "point": data["point"]
     }
     # The result is added to the database before this function is called.
     if len(database.get_results_for_data(racedata)) > 1:
         for row in self.race_ls:
             if row[self.LS_COL_DATE] == data["date"] and \
                row[self.LS_COL_RACEPOINT] == data["point"]:
                 self.race_sel.select_iter(row.iter)
                 self.race_tv.scroll_to_cell(row.path)
                 break
         self.race_ls.set(row.iter, self.LS_COL_TYPE, data["type"],
                          self.LS_COL_WIND, data["wind"],
                          self.LS_COL_WINDSPEED, data["windspeed"],
                          self.LS_COL_WEATHER, data["weather"],
                          self.LS_COL_TEMPERATURE, data["temperature"])
     else:
         rowiter = self.race_ls.insert(0, [
             data["date"], data["point"], data["type"], data["wind"],
             data["windspeed"], data["weather"], data["temperature"]
         ])
         self.race_ls.set_sort_column_id(0, gtk.SORT_ASCENDING)
         self.race_sel.select_iter(rowiter)
         path = self.race_ls.get_path(rowiter)
         self.race_tv.scroll_to_cell(path)
Пример #2
0
    def fill_treeview(self):
        self.clear()
        counter = 0
        for race in database.get_all_races():
            self.results_cache[counter] = {"results": [], "filtered": []}
            resultstmp = database.get_results_for_data({
                "date": race["date"],
                "point": race["point"]
            })
            for result in resultstmp:
                result = dict(result)
                band, year = common.get_band_from_pindex(result["pindex"])
                result["band"] = band
                result["year"] = year
                result["ring"] = "%s / %s" % (band, year[2:])

                placestr, coef, coefstr = common.format_place_coef(
                    result["place"], result["out"])
                result["speedstr"] = common.format_speed(result["speed"])
                result["coef"] = coef
                result["coefstr"] = coefstr
                result["placestr"] = placestr

                self.results_cache[counter]["results"].append(result)
                self.results_cache[counter]["filtered"].append(result)

            self.race_ls.append([
                counter, race["date"], race["point"], race["type"],
                race["wind"], race["windspeed"], race["weather"],
                race["temperature"]
            ])
            counter += 1
Пример #3
0
    def set_pigeon(self, pigeon):
        self.pigeon = pigeon

        self.liststore.clear()
        for result in database.get_results_for_data({"pindex": pigeon.pindex}):
            placestr, coef, coefstr = common.format_place_coef(
                result["place"], result["out"])
            speed = common.format_speed(result["speed"])

            self.liststore.append([
                result["Resultkey"], result["date"], result["point"], placestr,
                result["out"], coefstr, speed, result["sector"],
                result["type"], result["category"], result["wind"],
                result["windspeed"], result["weather"], result["temperature"],
                result["comment"], result["place"], coef, result["speed"]
            ])
Пример #4
0
    def on_race_sel_changed(self, selection):
        model, rowiter = selection.get_selected()
        if rowiter is None:
            return

        date = model.get_value(rowiter, 0)
        racepoint = model.get_value(rowiter, 1)
        self.liststore.clear()
        data = {"pindex": self.pigeon.pindex, "date": date, "point": racepoint}
        for result in database.get_results_for_data(data):
            placestr, coef, coefstr = common.format_place_coef(
                result["place"], result["out"])
            speed = common.format_speed(result["speed"])
            self.liststore.append([
                result["Resultkey"], placestr, result["out"], coefstr, speed,
                result["sector"], result["category"], result["comment"],
                result["place"], coef, result["speed"]
            ])
Пример #5
0
    def update_result(self, data):
        # Get the key of the selected result now, it might become invalid due to race changes
        model, node = self.selection.get_selected()
        key = self.liststore.get_value(node, self.LS_COL_ID)

        model, racenode = self.race_sel.get_selected()
        date = self.race_ls.get_value(racenode, self.LS_COL_DATE)
        point = self.race_ls.get_value(racenode, self.LS_COL_RACEPOINT)
        if date != data["date"] or point != data["point"]:
            if len(self.liststore) == 1:
                # This is the only result for this race
                self.race_ls.remove(racenode)
            # The date or point is changed, this means that the result should
            # be handled as a different race. Add a new one in this case.
            racedata = {
                "pindex": self.pigeon.pindex,
                "date": data["date"],
                "point": data["point"]
            }
            if len(database.get_results_for_data(racedata)) > 0:
                # This race already exists for this pigeon
                for row in self.race_ls:
                    if row[self.LS_COL_DATE] == data["date"] and \
                       row[self.LS_COL_RACEPOINT] == data["point"]:
                        self.race_sel.select_iter(row.iter)
                        self.race_tv.scroll_to_cell(row.path)
                        break
            else:
                rowiter = self.race_ls.append([
                    data["date"], data["point"], data["type"], data["wind"],
                    data["windspeed"], data["weather"], data["temperature"]
                ])
                self.race_sel.select_iter(rowiter)
                path = self.race_ls.get_path(rowiter)
                self.race_tv.scroll_to_cell(path)
        else:
            self.race_ls.set(racenode, self.LS_COL_TYPE, data["type"],
                             self.LS_COL_WIND, data["wind"],
                             self.LS_COL_WINDSPEED, data["windspeed"],
                             self.LS_COL_WEATHER, data["weather"],
                             self.LS_COL_TEMPERATURE, data["temperature"])
        return key