Diffstat (limited to 'noncore/apps/opie-bartender/bac.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-bartender/bac.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/apps/opie-bartender/bac.cpp b/noncore/apps/opie-bartender/bac.cpp index 2e74029..8dc7e88 100644 --- a/noncore/apps/opie-bartender/bac.cpp +++ b/noncore/apps/opie-bartender/bac.cpp | |||
@@ -89,96 +89,95 @@ BacDialog::BacDialog( QWidget* parent, const char* name, bool modal, WFlags fl | |||
89 | TextLabel4->setText( tr( "Gender" ) ); | 89 | TextLabel4->setText( tr( "Gender" ) ); |
90 | Layout4->addWidget( TextLabel4 ); | 90 | Layout4->addWidget( TextLabel4 ); |
91 | Layout7->addLayout( Layout4 ); | 91 | Layout7->addLayout( Layout4 ); |
92 | 92 | ||
93 | Layout6 = new QHBoxLayout; | 93 | Layout6 = new QHBoxLayout; |
94 | Layout6->setSpacing( 6 ); | 94 | Layout6->setSpacing( 6 ); |
95 | Layout6->setMargin( 0 ); | 95 | Layout6->setMargin( 0 ); |
96 | 96 | ||
97 | TypeDrinkComboBox = new QComboBox( FALSE,this, "TypeDrinkComboBox" ); | 97 | TypeDrinkComboBox = new QComboBox( FALSE,this, "TypeDrinkComboBox" ); |
98 | TypeDrinkComboBox->insertItem( tr( "Beer" ) ); | 98 | TypeDrinkComboBox->insertItem( tr( "Beer" ) ); |
99 | TypeDrinkComboBox->insertItem( tr( "Wine" ) ); | 99 | TypeDrinkComboBox->insertItem( tr( "Wine" ) ); |
100 | TypeDrinkComboBox->insertItem( tr( "Shot" ) ); | 100 | TypeDrinkComboBox->insertItem( tr( "Shot" ) ); |
101 | Layout6->addWidget( TypeDrinkComboBox ); | 101 | Layout6->addWidget( TypeDrinkComboBox ); |
102 | 102 | ||
103 | TextLabel1_2 = new QLabel( this, "TextLabel1_2" ); | 103 | TextLabel1_2 = new QLabel( this, "TextLabel1_2" ); |
104 | TextLabel1_2->setText( tr( "Type of drink" ) ); | 104 | TextLabel1_2->setText( tr( "Type of drink" ) ); |
105 | Layout6->addWidget( TextLabel1_2 ); | 105 | Layout6->addWidget( TextLabel1_2 ); |
106 | Layout7->addLayout( Layout6 ); | 106 | Layout7->addLayout( Layout6 ); |
107 | 107 | ||
108 | PushButton1 = new QPushButton( this, "PushButton1" ); | 108 | PushButton1 = new QPushButton( this, "PushButton1" ); |
109 | PushButton1->setText( tr( "Calculate" ) ); | 109 | PushButton1->setText( tr( "Calculate" ) ); |
110 | Layout7->addWidget( PushButton1 ); | 110 | Layout7->addWidget( PushButton1 ); |
111 | connect(PushButton1,SIGNAL( clicked()), this, SLOT( calculate())); | 111 | connect(PushButton1,SIGNAL( clicked()), this, SLOT( calculate())); |
112 | 112 | ||
113 | LCDNumber1 = new QLCDNumber( this, "LCDNumber1" ); | 113 | LCDNumber1 = new QLCDNumber( this, "LCDNumber1" ); |
114 | LCDNumber1->setMaximumHeight( 50); | 114 | LCDNumber1->setMaximumHeight( 50); |
115 | LCDNumber1->setNumDigits(6); | 115 | LCDNumber1->setNumDigits(6); |
116 | LCDNumber1->setSmallDecimalPoint(TRUE); | 116 | LCDNumber1->setSmallDecimalPoint(TRUE); |
117 | LCDNumber1->setFrameStyle(QFrame::Box); | 117 | LCDNumber1->setFrameStyle(QFrame::Box); |
118 | LCDNumber1->setLineWidth(2); | 118 | LCDNumber1->setLineWidth(2); |
119 | LCDNumber1->setSegmentStyle( QLCDNumber::Filled); | 119 | LCDNumber1->setSegmentStyle( QLCDNumber::Filled); |
120 | QPalette palette = LCDNumber1->palette(); | 120 | QPalette palette = LCDNumber1->palette(); |
121 | palette.setColor(QPalette::Normal, QColorGroup::Foreground, Qt::red); | 121 | palette.setColor(QPalette::Normal, QColorGroup::Foreground, Qt::red); |
122 | palette.setColor(QPalette::Normal, QColorGroup::Light, Qt::black); | 122 | palette.setColor(QPalette::Normal, QColorGroup::Light, Qt::black); |
123 | palette.setColor(QPalette::Normal, QColorGroup::Dark, Qt::darkGreen); | 123 | palette.setColor(QPalette::Normal, QColorGroup::Dark, Qt::darkGreen); |
124 | LCDNumber1->setPalette(palette); | 124 | LCDNumber1->setPalette(palette); |
125 | 125 | ||
126 | Layout7->addWidget( LCDNumber1 ); | 126 | Layout7->addWidget( LCDNumber1 ); |
127 | NumberSpinBox->setFocus(); | 127 | NumberSpinBox->setFocus(); |
128 | } | 128 | } |
129 | 129 | ||
130 | BacDialog::~BacDialog() | 130 | BacDialog::~BacDialog() |
131 | {} | 131 | {} |
132 | 132 | ||
133 | void BacDialog::calculate() | 133 | void BacDialog::calculate() |
134 | { | 134 | { |
135 | 135 | ||
136 | float weight,genderDiff, bac, typeDrink=0, drinkOz=0, bodyWater, milliliters, oz, gram, gramsMil, alc, metab, bac1; | 136 | float weight,genderDiff, bac, typeDrink=0, drinkOz=0, bodyWater, milliliters, oz, gram, gramsMil, alc, metab, bac1; |
137 | float weightunitDifference, massunitdiff; | ||
138 | QString estBac; | 137 | QString estBac; |
139 | 138 | ||
140 | if( GenderComboBox->currentItem()==0) | 139 | if( GenderComboBox->currentItem()==0) |
141 | genderDiff = .58; | 140 | genderDiff = .58; |
142 | else | 141 | else |
143 | genderDiff = .49; | 142 | genderDiff = .49; |
144 | 143 | ||
145 | switch(TypeDrinkComboBox->currentItem()) { | 144 | switch(TypeDrinkComboBox->currentItem()) { |
146 | case 0: { //beer | 145 | case 0: { //beer |
147 | typeDrink = .045; | 146 | typeDrink = .045; |
148 | drinkOz = 12; | 147 | drinkOz = 12; |
149 | } | 148 | } |
150 | break; | 149 | break; |
151 | case 1: { | 150 | case 1: { |
152 | typeDrink = .2; | 151 | typeDrink = .2; |
153 | drinkOz = 4; | 152 | drinkOz = 4; |
154 | } | 153 | } |
155 | break; | 154 | break; |
156 | case 2: { | 155 | case 2: { |
157 | typeDrink = .5; | 156 | typeDrink = .5; |
158 | drinkOz = 1.5; | 157 | drinkOz = 1.5; |
159 | } | 158 | } |
160 | break; | 159 | break; |
161 | }; | 160 | }; |
162 | 161 | ||
163 | if( weightUnitsCombo->currentItem() == 0 ) { | 162 | if( weightUnitsCombo->currentItem() == 0 ) { |
164 | weight = WeightSpinBox->value(); // kilos | 163 | weight = WeightSpinBox->value(); // kilos |
165 | } else { | 164 | } else { |
166 | weight = WeightSpinBox->value() / 2.2046; // convert to kilograms | 165 | weight = WeightSpinBox->value() / 2.2046; // convert to kilograms |
167 | } | 166 | } |
168 | bodyWater = weight * genderDiff; | 167 | bodyWater = weight * genderDiff; |
169 | milliliters = bodyWater * 1000; | 168 | milliliters = bodyWater * 1000; |
170 | oz = 23.36/milliliters; | 169 | oz = 23.36/milliliters; |
171 | gram = oz * .806; | 170 | gram = oz * .806; |
172 | gramsMil = gram * 100; | 171 | gramsMil = gram * 100; |
173 | alc = drinkOz*NumberSpinBox->value() * typeDrink; | 172 | alc = drinkOz*NumberSpinBox->value() * typeDrink; |
174 | metab = TimeSpinBox->value() * .012; | 173 | metab = TimeSpinBox->value() * .012; |
175 | bac1 = gramsMil * alc; | 174 | bac1 = gramsMil * alc; |
176 | bac = bac1 - metab; | 175 | bac = bac1 - metab; |
177 | 176 | ||
178 | // weightDrink= (nDrinks * .79) / (weight * genderDiff*1000); | 177 | // weightDrink= (nDrinks * .79) / (weight * genderDiff*1000); |
179 | // (ounces * percent * 0.075 / weight) - (hours * 0.015); | 178 | // (ounces * percent * 0.075 / weight) - (hours * 0.015); |
180 | // bac = (((weightDrink * .806) * 100) * .54);// - (time * .012); // assuming beer of 4.5% | 179 | // bac = (((weightDrink * .806) * 100) * .54);// - (time * .012); // assuming beer of 4.5% |
181 | estBac.sprintf("%f",bac); | 180 | estBac.sprintf("%f",bac); |
182 | LCDNumber1->display(bac); | 181 | LCDNumber1->display(bac); |
183 | // BACTextLabel->setText(estBac ); | 182 | // BACTextLabel->setText(estBac ); |
184 | } | 183 | } |