equal
deleted
inserted
replaced
83 } |
83 } |
84 detailsInHtml.append("</ul> </body> </html> "); |
84 detailsInHtml.append("</ul> </body> </html> "); |
85 return detailsInHtml; |
85 return detailsInHtml; |
86 } |
86 } |
87 |
87 |
88 void Fishes::getNutrition(QString name) |
88 QMap<Fishes::TNUTRITION, QString> Fishes::getNutrition(QString name) |
89 { |
89 { |
90 QSqlQuery query; |
90 QSqlQuery query; |
91 QMap<QString, QString> nutrition; |
91 QMap<TNUTRITION, QString> nutrition; |
92 |
92 |
93 query.prepare("select calories,fat,protein,omega3,cholesterol,sodium from fish where name = :name "); |
93 query.prepare("select calories,fat,protein,omega3,cholesterol,sodium from fish where name = :name "); |
94 query.bindValue(":name",name); |
94 query.bindValue(":name",name); |
95 |
95 |
96 if (!query.exec()) |
96 if (!query.exec()) |
98 QString errCode = "failed to get nutrition information " + query.lastError().text(); |
98 QString errCode = "failed to get nutrition information " + query.lastError().text(); |
99 qWarning(errCode.toStdString().c_str()); |
99 qWarning(errCode.toStdString().c_str()); |
100 } |
100 } |
101 |
101 |
102 query.next(); |
102 query.next(); |
103 nutrition["Calories"] = query.value(0).toString(); |
103 nutrition[ECalories] = query.value(0).toString(); |
104 nutrition["Total Fat"] = query.value(1).toString(); |
104 nutrition[ETotalFat] = query.value(1).toString(); |
105 nutrition["Total Protein"] = query.value(2).toString(); |
105 nutrition[ETotalProtein] = query.value(2).toString(); |
106 nutrition["Omega-3"] = query.value(3).toString(); |
106 nutrition[EOmega3] = query.value(3).toString(); |
107 nutrition["Cholesterol"] = query.value(4).toString(); |
107 nutrition[ECholesterol] = query.value(4).toString(); |
108 nutrition["Sodium"] = query.value(5).toString(); |
108 nutrition[ESodium] = query.value(5).toString(); |
109 |
109 |
110 QMapIterator<QString, QString> i(nutrition); |
110 return nutrition; |
111 while (i.hasNext()) |
|
112 { |
|
113 i.next(); |
|
114 qDebug() << i.key() << ": " << i.value() << endl; |
|
115 } |
|
116 } |
111 } |
117 |
112 |
118 void Fishes::populate(TCATEGORIES cat) |
113 void Fishes::populate(TCATEGORIES cat) |
119 { |
114 { |
120 QSqlQuery query; |
115 QSqlQuery query; |