diff --git a/SleepLib/session.cpp b/SleepLib/session.cpp
index a5a8571d..76385c60 100644
--- a/SleepLib/session.cpp
+++ b/SleepLib/session.cpp
@@ -97,8 +97,8 @@ bool Session::Store(QString path)
if (eventlist.size()>0) {
s_eventfile=base+".001";
StoreEvents(s_eventfile);
- } else {
- qDebug() << "Trying to save empty events file";
+ } else { // who cares..
+ //qDebug() << "Trying to save empty events file";
}
//qDebug() << " Events done";
s_changed=false;
diff --git a/daily.cpp b/daily.cpp
index 03fff294..3b063b50 100644
--- a/daily.cpp
+++ b/daily.cpp
@@ -38,6 +38,7 @@
const int min_height=150;
const float ounce_convert=28.3495231;
+const float pound_convert=ounce_convert*16;
Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw)
:QWidget(parent),mainwin(mw), ui(new Ui::Daily)
@@ -834,6 +835,10 @@ void Daily::Load(QDate date)
ui->weightSpinBox->setValue(0);
ui->ouncesSpinBox->setValue(0);
ui->ZombieMeter->setValue(50);
+ ui->BMI->display(0);
+ ui->BMI->setVisible(false);
+ ui->BMIlabel->setVisible(false);
+
BookmarksChanged=false;
Session *journal=GetJournalSession(date);
if (journal) {
@@ -862,6 +867,13 @@ void Daily::Load(QDate date)
ui->ouncesSpinBox->setVisible(true);
ui->ouncesSpinBox->setSuffix("oz");
}
+ double height=PROFILE["Height"].toDouble(&ok)/100.0;
+ if (height>0 && kg>0) {
+ //double bmi=kg/(height*height);
+ ui->BMI->setVisible(true);
+ ui->BMIlabel->setVisible(true);
+ //ui->BMI->display(bmi);
+ }
}
if (journal->settings.contains("ZombieMeter"))
@@ -938,8 +950,22 @@ void Daily::Unload(QDate date)
kg=(ui->weightSpinBox->value()*(ounce_convert*16.0))+(ui->ouncesSpinBox->value()*ounce_convert);
kg/=1000.0;
}
- journal->settings["Weight"]=kg;
- journal->SetChanged(true);
+ double height=PROFILE["Height"].toDouble(&ok);
+ double bmi=(height*height)/kg;
+ if (kg>0) {
+ journal->settings["Weight"]=kg;
+ journal->settings["BMI"]=kg;
+ journal->SetChanged(true);
+ } else {
+ if (journal->settings.contains("Weight")) {
+ journal->settings.erase(journal->settings.find("Weight"));
+ journal->SetChanged(true);
+ }
+ if (journal->settings.contains("BMI")) {
+ journal->settings.erase(journal->settings.find("BMI"));
+ journal->SetChanged(true);
+ }
+ }
}
if ((!journal->settings.contains("ZombieMeter") && (ui->ZombieMeter->value()!=50)) || (journal->settings["ZombieMeter"].toDouble(&ok)!=ui->ZombieMeter->value())) {
journal->settings["ZombieMeter"]=ui->ZombieMeter->value();
@@ -979,8 +1005,13 @@ void Daily::Unload(QDate date)
kg=(ui->weightSpinBox->value()*(ounce_convert*16))+(ui->ouncesSpinBox->value()*ounce_convert);
kg/=1000.0;
}
- journal->settings["Weight"]=kg;
- journal->SetChanged(true);
+ double height=PROFILE["Height"].toDouble(&ok);
+ double bmi=(height*height)/kg;
+ if (kg>0) {
+ journal->settings["Weight"]=kg;
+ journal->settings["BMI"]=bmi;
+ journal->SetChanged(true);
+ }
}
if (BookmarksChanged) {
QVariantList start;
@@ -1365,3 +1396,32 @@ void Daily::on_bookmarkTable_itemChanged(QTableWidgetItem *item)
Q_UNUSED(item);
BookmarksChanged=true;
}
+void Daily::on_weightSpinBox_valueChanged(double arg1)
+{
+ bool ok;
+ double height=PROFILE["Height"].toDouble(&ok)/100.0;
+ double kg;
+ if (PROFILE["Units"].toString()=="metric")
+ kg=arg1;
+ else {
+ kg=(arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert);
+ }
+ if ((height>0) && (kg>0)) {
+ double bmi=kg/(height * height);
+ ui->BMI->display(bmi);
+ //ui->BMI->setDigitCount(5);
+ //ui->BMI->setSmallDecimalPoint(true);
+ }
+}
+void Daily::on_ouncesSpinBox_valueChanged(int arg1)
+{
+ bool ok;
+ double height=PROFILE["Height"].toDouble(&ok)/100.0;
+ double kg=(ui->weightSpinBox->value()*pound_convert) + (arg1*ounce_convert);
+ if ((height>0) && (kg>0)) {
+ double bmi=kg/(height * height);
+ ui->BMI->display(bmi);
+ //ui->BMI->setDigitCount(5);
+ //ui->BMI->setSmallDecimalPoint(true);
+ }
+}
diff --git a/daily.h b/daily.h
index 4ef8c8c6..ec390dc6 100644
--- a/daily.h
+++ b/daily.h
@@ -86,6 +86,10 @@ private slots:
void on_bookmarkTable_itemChanged(QTableWidgetItem *item);
+ void on_weightSpinBox_valueChanged(double arg1);
+
+ void on_ouncesSpinBox_valueChanged(int arg1);
+
protected:
private:
@@ -126,3 +130,4 @@ private:
};
#endif // DAILY_H
+
diff --git a/daily.ui b/daily.ui
index 228f6f01..8016e52c 100644
--- a/daily.ui
+++ b/daily.ui
@@ -248,7 +248,7 @@
- 3
+ 2
true
@@ -531,29 +531,7 @@
- -
-
-
-
- 0
- 0
-
-
-
-
- 75
- true
-
-
-
- Awesome
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
+
-
@@ -582,14 +560,14 @@
- -
+
-
399.990000000000009
- -
+
-
50
@@ -605,13 +583,86 @@
- -
+
-
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 75
+ true
+
+
+
+ Awesome
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ B.M.I.
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ QFrame::NoFrame
+
+
+ true
+
+
+ 5
+
+
+ QLCDNumber::Flat
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+