Esempio n. 1
0
 def myqtablewidget_additional(self, wdg):
     for i, o in enumerate(wdg.objects()):
         wdg.table.item(i, 1).setIcon(o.product.qicon())
         wdg.table.item(i, 2).setIcon(o.product.risk_qicon())
     wdg.table.setRowCount(wdg.length() + 2)
     if self.mem.user.biometrics.last(
     ).height is not None:  #Without last_biometrics
         #Totals
         wdg.table.setItem(self.length(), 0, qcrossedout())
         wdg.table.setItem(self.length(), 1, qleft(self.tr("Total")))
         wdg.table.setItem(self.length(), 2, qcrossedout())
         wdg.table.setItem(self.length(), 3, qnumber(self.grams()))
         wdg.table.setItem(
             self.length(), 4,
             qnumber_limited(self.calories(),
                             self.mem.user.biometrics.last().bmr()))
         wdg.table.setItem(
             self.length(), 5,
             qnumber_limited(
                 self.carbohydrate(),
                 self.mem.user.biometrics.last().carbohydrate()))
         wdg.table.setItem(
             self.length(), 6,
             qnumber_limited(self.protein(),
                             self.mem.user.biometrics.last().protein()))
         wdg.table.setItem(
             self.length(), 7,
             qnumber_limited(self.fat(),
                             self.mem.user.biometrics.last().fat()))
         wdg.table.setItem(
             self.length(), 8,
             qnumber_limited(self.fiber(),
                             self.mem.user.biometrics.last().fiber(),
                             reverse=True))
         wdg.table.setItem(
             self.length(), 9,
             qnumber_limited(self.sugars(),
                             self.mem.user.biometrics.last().sugars()))
         #Recomendatios
         wdg.table.setItem(self.length() + 1, 0, qcrossedout())
         wdg.table.setItem(self.length() + 1, 1,
                           qleft(self.tr("Recomendations")))
         wdg.table.setItem(self.length() + 1, 2, qcrossedout())
         wdg.table.setItem(self.length() + 1, 3, qcrossedout())
         wdg.table.setItem(self.length() + 1, 4,
                           qnumber(self.mem.user.biometrics.last().bmr()))
         wdg.table.setItem(
             self.length() + 1, 5,
             qnumber(self.mem.user.biometrics.last().carbohydrate()))
         wdg.table.setItem(
             self.length() + 1, 6,
             qnumber(self.mem.user.biometrics.last().protein()))
         wdg.table.setItem(self.length() + 1, 7,
                           qnumber(self.mem.user.biometrics.last().fat()))
         wdg.table.setItem(self.length() + 1, 8,
                           qnumber(self.mem.user.biometrics.last().fiber()))
         wdg.table.setItem(
             self.length() + 1, 9,
             qnumber(self.mem.user.biometrics.last().sugars()))
Esempio n. 2
0
    def on_cmbPeriod_currentIndexChanged(self, index):
        if index == 0:
            datefrom = date.today() - timedelta(days=7)
        elif index == 1:
            datefrom = date.today() - timedelta(days=30)
        elif index == 2:
            datefrom = date.today() - timedelta(days=365)
        elif index == 3:
            datefrom = date.today() - timedelta(days=365 * 3)
        elif index == 4:
            datefrom = date(1900, 1, 1)
        self.mem.settings.setValue("wdgMealsMost/cmbPeriod_index",
                                   self.cmbPeriod.currentIndex())

        rows = self.mem.con.cursor_rows(
            """
            select 
                sum(meals.amount), 
                allproducts.id, 
                allproducts.system_product 
            from 
                meals, 
                allproducts 
            where 
                meals.datetime::date>%s and
                meals.products_id=allproducts.id and 
                meals.system_product=allproducts.system_product 
            group by 
                allproducts.id, 
                allproducts.system_product 
            order by 
                sum desc""", (datefrom, ))

        self.tblMeals.setColumnCount(2)
        self.tblMeals.setHorizontalHeaderItem(
            0, QTableWidgetItem(self.tr("Product")))
        self.tblMeals.setHorizontalHeaderItem(
            1, QTableWidgetItem(self.tr("Amount")))

        self.tblMeals.applySettings()
        self.tblMeals.clearContents()
        self.tblMeals.setRowCount(len(rows))
        for i, row in enumerate(rows):
            product = self.mem.data.products.find_by_id_system(
                row['id'], row['system_product'])
            self.tblMeals.setItem(i, 0, qleft(product.fullName()))
            self.tblMeals.setItem(i, 1, qnumber(row['sum']))
  def qtablewidget(self, wdg):        
      wdg.table.setColumnCount(7)
      wdg.table.setHorizontalHeaderItem(0, qcenter(self.tr("Name")))
      wdg.table.setHorizontalHeaderItem(1, qcenter(self.tr("Grams")))
      wdg.table.setHorizontalHeaderItem(2, qcenter(self.tr("Calories")))
      wdg.table.setHorizontalHeaderItem(3, qcenter(self.tr("Carbohydrates")))
      wdg.table.setHorizontalHeaderItem(4, qcenter(self.tr("Protein")))
      wdg.table.setHorizontalHeaderItem(5, qcenter(self.tr("Fat")))
      wdg.table.setHorizontalHeaderItem(6, qcenter(self.tr("Fiber")))
 
      wdg.applySettings()
      wdg.table.clearContents()
      wdg.table.setRowCount(self.length()+2)
      for i, o in enumerate(self.arr):
          wdg.table.setItem(i, 0, qleft(o.product.fullName()))
          wdg.table.item(i, 0).setIcon(o.product.qicon())
          wdg.table.setItem(i, 1, qright(o.amount))
          wdg.table.setItem(i, 2, qright(o.calories()))
          wdg.table.setItem(i, 3, qright(o.carbohydrate()))
          wdg.table.setItem(i, 4, qright(o.protein()))
          wdg.table.setItem(i, 5, qright(o.fat()))
          wdg.table.setItem(i, 6, qright(o.fiber()))
      #Totals
      wdg.table.setItem(self.length(), 0, qleft(self.tr("Total")))
      wdg.table.setItem(self.length(), 1, qnumber(self.grams()))
      wdg.table.setItem(self.length(), 2, qnumber(self.calories()))
      wdg.table.setItem(self.length(), 3, qnumber(self.carbohydrate()))
      wdg.table.setItem(self.length(), 4, qnumber(self.protein()))
      wdg.table.setItem(self.length(), 5, qnumber(self.fat()))
      wdg.table.setItem(self.length(), 6, qnumber(self.fiber()))
      #Amounts in 100 grams of elaboratedproduct
      product=self.mem.data.products.find_by_elaboratedproducts_id(self.elaboratedproduct.id)
      wdg.table.setItem(self.length()+1, 0, qleft(self.tr("Values in 100 g")))
      wdg.table.setItem(self.length()+1, 1, qnumber(100))
      wdg.table.setItem(self.length()+1, 2, qnumber(product.component_in_100g(eProductComponent.Calories)))
      wdg.table.setItem(self.length()+1, 3, qnumber(product.component_in_100g(eProductComponent.Carbohydrate)))
      wdg.table.setItem(self.length()+1, 4, qnumber(product.component_in_100g(eProductComponent.Protein)))
      wdg.table.setItem(self.length()+1, 5, qnumber(product.component_in_100g(eProductComponent.Fat)))
      wdg.table.setItem(self.length()+1, 6, qnumber(product.component_in_100g(eProductComponent.Fiber)))
Esempio n. 4
0
  def myqtablewidget(self, wdg):        
      wdg.table.setColumnCount(9)
      wdg.table.setHorizontalHeaderItem(0, qcenter(self.tr("Hour")))
      wdg.table.setHorizontalHeaderItem(1, qcenter(self.tr("Name")))
      wdg.table.setHorizontalHeaderItem(2, qcenter(self.tr("Foodtype")))
      wdg.table.setHorizontalHeaderItem(3, qcenter(self.tr("Grams")))
      wdg.table.setHorizontalHeaderItem(4, qcenter(self.tr("Calories")))
      wdg.table.setHorizontalHeaderItem(5, qcenter(self.tr("Carbohydrates")))
      wdg.table.setHorizontalHeaderItem(6, qcenter(self.tr("Protein")))
      wdg.table.setHorizontalHeaderItem(7, qcenter(self.tr("Fat")))
      wdg.table.setHorizontalHeaderItem(8, qcenter(self.tr("Fiber")))
 
      wdg.applySettings()
      wdg.table.clearContents()
      wdg.table.setRowCount(self.length()+2)
      for i, o in enumerate(self.arr):
          wdg.table.setItem(i, 0, qtime(o.datetime))
          wdg.table.setItem(i, 1, qleft(o.product.fullName()))
          wdg.table.item(i, 1).setIcon(o.product.qicon())
          if o.product.foodtype==None:
              wdg.table.setItem(i, 2, qleft(""))
          else:
              wdg.table.setItem(i, 2, qleft(o.product.foodtype.name))
          wdg.table.item(i, 2).setIcon(o.product.risk_qicon())
          wdg.table.setItem(i, 3, qnumber(o.amount))
          wdg.table.setItem(i, 4, qnumber(o.calories()))
          wdg.table.setItem(i, 5, qnumber(o.carbohydrate()))
          wdg.table.setItem(i, 6, qnumber(o.protein()))
          wdg.table.setItem(i, 7, qnumber(o.fat()))
          wdg.table.setItem(i, 8, qnumber(o.fiber()))
      if self.mem.user.last_biometrics.height!=None:#Without last_biometrics
          #Totals
          wdg.table.setItem(self.length(), 1, qleft(self.tr("Total")))
          wdg.table.setItem(self.length(), 3, qnumber(self.grams()))
          wdg.table.setItem(self.length(), 4, qnumber_limited(self.calories(), self.mem.user.last_biometrics.bmr()))
          wdg.table.setItem(self.length(), 5, qnumber_limited(self.carbohydrate(), self.mem.user.last_biometrics.carbohydrate()))
          wdg.table.setItem(self.length(), 6, qnumber_limited(self.protein(), self.mem.user.last_biometrics.protein()))
          wdg.table.setItem(self.length(), 7, qnumber_limited(self.fat(), self.mem.user.last_biometrics.fat()))
          wdg.table.setItem(self.length(), 8, qnumber_limited(self.fiber(), self.mem.user.last_biometrics.fiber(), reverse=True))
          #Recomendatios
          wdg.table.setItem(self.length()+1, 1, qleft(self.tr("Recomendations")))
          wdg.table.setItem(self.length()+1, 4, qnumber(self.mem.user.last_biometrics.bmr()))
          wdg.table.setItem(self.length()+1, 5, qnumber(self.mem.user.last_biometrics.carbohydrate()))
          wdg.table.setItem(self.length()+1, 6, qnumber(self.mem.user.last_biometrics.protein()))
          wdg.table.setItem(self.length()+1, 7, qnumber(self.mem.user.last_biometrics.fat()))
          wdg.table.setItem(self.length()+1, 8, qnumber(self.mem.user.last_biometrics.fiber()))