This commit is contained in:
2017-02-06 16:04:25 +01:00
parent 43009935e8
commit 583b6ab4a1
19 changed files with 378 additions and 66 deletions
+6 -3
View File
@@ -24,7 +24,8 @@ SOURCES += main.cpp\
cimportingredientdialog.cpp \
cmessageanimatedialog.cpp \
cplugininfo.cpp \
csplashscreen.cpp
csplashscreen.cpp \
cingredientwindow.cpp
HEADERS += cmainwindow.h \
cimportinterface.h \
@@ -39,14 +40,16 @@ HEADERS += cmainwindow.h \
cmessageanimatedialog.h \
cplugininfo.h \
typedef.h \
csplashscreen.h
csplashscreen.h \
cingredientwindow.h
FORMS += cmainwindow.ui \
coptions.ui \
coptionsplugins.ui \
cimportingredientdialog.ui \
cmessageanimatedialog.ui \
cplugininfo.ui
cplugininfo.ui \
cingredientwindow.ui
DESTDIR = ../bin
+3
View File
@@ -83,6 +83,9 @@ public:
virtual qint32 create(const QString& szName, const QString& szGroup) = 0;
virtual qint32 createGroup(const QString& szGroup) = 0;
virtual bool set(qint32 id, qint16 ingredientNumber, qreal value) = 0;
virtual QString name(qint32 id) = 0;
virtual QString group(qint32 id) = 0;
virtual qreal get(qint32 id, qint16 ingredientNumber) = 0;
virtual INGREDIENT_LIST ingredients() = 0;
virtual QStringList groups() = 0;
virtual bool beginTransaction() = 0;
+26 -6
View File
@@ -51,7 +51,7 @@ void cImportIngredientDialog::initIngredientDetails()
m_lpIngredientDetailsModel->setHorizontalHeaderLabels(headerLabels);
}
void cImportIngredientDialog::setPluginList(const QList<cPlugin*> pluginList)
void cImportIngredientDialog::setPluginList(const QList<cPlugin*> pluginList, const QString& szPlugin)
{
m_pluginList = pluginList;
@@ -65,7 +65,27 @@ void cImportIngredientDialog::setPluginList(const QList<cPlugin*> pluginList)
ui->m_lpSource->addItem(lpPlugin->pluginName(), QVariant::fromValue(lpPlugin));
}
}
ui->m_lpSource->setCurrentIndex(0);
if(ui->m_lpSource->count())
{
int index = ui->m_lpSource->findText(szPlugin);
if(index != -1)
ui->m_lpSource->setCurrentIndex(index);
}
}
void cImportIngredientDialog::setIngredientGroupList(const QStringList ingredientGroupList)
{
ui->m_lpIngredientGroup->addItems(ingredientGroupList);
int index = ui->m_lpIngredientGroup->findText("default");
if(index == -1)
index = 0;
ui->m_lpIngredientGroup->setCurrentIndex(index);
}
QString cImportIngredientDialog::pluginSelected()
{
return(ui->m_lpSource->currentText());
}
void cImportIngredientDialog::on_m_lpSearchString_textChanged(const QString &/*arg1*/)
@@ -189,17 +209,17 @@ cIngredient cImportIngredientDialog::toIngredient()
cPlugin* lpPlugin = ui->m_lpSource->currentData().value<cPlugin*>();
if(!lpPlugin)
return(cIngredient(""));
return(cIngredient("", ""));
cImportInterface* lpImport = lpPlugin->importInterface();
if(!lpImport)
return(cIngredient(""));
return(cIngredient("", ""));
if(!lpImport->loaded())
return(cIngredient(""));
return(cIngredient("", ""));
cIngredient ingredient(lpImport->ingredientName());
cIngredient ingredient(lpImport->ingredientName(), ui->m_lpIngredientGroup->currentText());
for(int z = 0;z < cIngredient::iIngredientMax;z++)
{
if(lpImport->value((cIngredient::iIngredient)z) != -1)
+4 -1
View File
@@ -59,9 +59,12 @@ public:
*
* \param pluginList
*/
void setPluginList(const QList<cPlugin*> pluginList);
void setPluginList(const QList<cPlugin*> pluginList, const QString& szPlugin = QString(""));
cIngredient toIngredient();
QString pluginSelected();
void setIngredientGroupList(const QStringList ingredientGroupList);
private:
Ui::cImportIngredientDialog* ui; /*!< TODO: describe */
QStandardItemModel* m_lpIngredientListModel; /*!< TODO: describe */
+24 -10
View File
@@ -29,16 +29,6 @@
<widget class="QTreeView" name="m_lpIngredientDetails"/>
</widget>
</item>
<item row="3" column="1">
<widget class="QDialogButtonBox" name="m_lpButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
<item>
@@ -60,6 +50,16 @@
</item>
</layout>
</item>
<item row="4" column="1">
<widget class="QDialogButtonBox" name="m_lpButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@@ -77,6 +77,20 @@
</item>
</layout>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,1">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Ingredient Group:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_lpIngredientGroup"/>
</item>
</layout>
</item>
</layout>
</item>
</layout>
+37 -2
View File
@@ -180,14 +180,39 @@ static GROUPNAME g_groupname[] =
{ QString::fromUtf8("average consumption"), QString::fromUtf8("Others"), cIngredient::iIngredientaverageconsumption },
};
cIngredient::cIngredient(const QString &szIngredientName) :
cIngredient::cIngredient() :
m_szIngredientName(""),
m_szIngredientGroup(""),
m_iID(-1)
{
}
cIngredient::cIngredient(const QString &szIngredientName, const QString& szIngredientGroup) :
m_szIngredientName(szIngredientName),
m_szIngredientGroup(szIngredientGroup),
m_iID(0)
{
for(int z = 0;z < iIngredientMax;z++)
m_dValue[z] = -1;
}
bool cIngredient::load(qint32 iIngredient, cPlugin* lpDB)
{
if(!lpDB)
return(false);
cDBInterface* lpInterface = lpDB->dbInterface();
m_iID = iIngredient;
m_szIngredientName = lpInterface->name(iIngredient);
m_szIngredientGroup = lpInterface->group(iIngredient);
for(int z = 0;z < cIngredient::iIngredientMax;z++)
m_dValue[z] = lpInterface->get(iIngredient, z);
return(true);
}
bool cIngredient::reload(cPlugin* /*lpDB*/)
{
return(true);
@@ -202,7 +227,7 @@ bool cIngredient::save(cPlugin* lpDB)
lpInterface->beginTransaction();
qint32 id = lpInterface->create(m_szIngredientName, "default");
qint32 id = lpInterface->create(m_szIngredientName, m_szIngredientGroup);
if(id == -1)
return(false);
@@ -220,6 +245,16 @@ bool cIngredient::save(cPlugin* lpDB)
return(true);
}
QString cIngredient::ingredientName()
{
return(m_szIngredientName);
}
QString cIngredient::ingredientGroup()
{
return(m_szIngredientGroup);
}
QString cIngredient::group(cIngredient::iIngredient i)
{
for(int z = 0;z < (int)sizeof(g_groupname)/(int)sizeof(GROUPNAME);z++)
+11 -1
View File
@@ -201,7 +201,8 @@ public:
iIngredientMax,
};
cIngredient(const QString& szIngredientName);
cIngredient();
cIngredient(const QString& szIngredientName, const QString& szIngredientGroup);
void setValue(cIngredient::iIngredient i, qreal dValue);
/*!
@@ -209,6 +210,12 @@ public:
\return bool
*/
bool load(qint32 iIngredient, cPlugin* lpDB);
/*!
\brief
\return bool
*/
bool reload(cPlugin* lpDB);
/*!
\brief
@@ -217,6 +224,8 @@ public:
*/
bool save(cPlugin* lpDB);
QString ingredientName();
QString ingredientGroup();
/*!
\brief
@@ -242,6 +251,7 @@ public:
private:
QString m_szIngredientName;
QString m_szIngredientGroup;
qint32 m_iID;
qreal m_dValue[iIngredientMax];
};
+28
View File
@@ -0,0 +1,28 @@
#include "cingredientwindow.h"
#include "ui_cingredientwindow.h"
#include "cingredient.h"
cIngredientWindow::cIngredientWindow(QWidget *parent) :
QWidget(parent),
ui(new Ui::cIngredientWindow)
{
ui->setupUi(this);
}
cIngredientWindow::~cIngredientWindow()
{
delete ui;
}
void cIngredientWindow::setIngredient(qint32 iIngredient, cPlugin* lpPlugin)
{
m_iIngredient = iIngredient;
m_lpDBPlugin = lpPlugin;
cIngredient ingredient;
if(!ingredient.load(m_iIngredient, m_lpDBPlugin))
return;
setWindowTitle(ingredient.ingredientName());
}
+31
View File
@@ -0,0 +1,31 @@
#ifndef CINGREDIENTWINDOW_H
#define CINGREDIENTWINDOW_H
#include "cplugin.h"
#include <QWidget>
namespace Ui {
class cIngredientWindow;
}
class cIngredientWindow : public QWidget
{
Q_OBJECT
public:
explicit cIngredientWindow(QWidget *parent = 0);
~cIngredientWindow();
void setIngredient(qint32 iIngredient, cPlugin* lpPlugin);
private:
Ui::cIngredientWindow *ui;
cPlugin* m_lpDBPlugin;
qint32 m_iIngredient;
};
#endif // CINGREDIENTWINDOW_H
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cIngredientWindow</class>
<widget class="QWidget" name="cIngredientWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>791</width>
<height>599</height>
</rect>
</property>
<property name="windowTitle">
<string>Ingredient</string>
</property>
</widget>
<resources/>
<connections/>
</ui>
+55 -25
View File
@@ -3,6 +3,8 @@
#include "cimportinterface.h"
#include "cingredient.h"
#include "cingredientwindow.h"
#include "typedef.h"
#include "coptions.h"
@@ -19,6 +21,7 @@
#include <QImage>
#include <QContextMenuEvent>
#include <QThread>
#include <QMdiSubWindow>
cMainWindow::cMainWindow(QWidget *parent) :
@@ -30,7 +33,8 @@ cMainWindow::cMainWindow(QWidget *parent) :
m_lpIngredientsListDelete(0),
m_lpIngredientsListEdit(0),
m_lpIngredientsListMenu(0),
m_lpDB(0)
m_lpDB(0),
m_szLastImportPlugin("")
{
QThread::msleep(2000);
init();
@@ -56,11 +60,21 @@ void cMainWindow::init()
ui->setupUi(this);
ui->m_lpMDIArea->setViewMode(QMdiArea::TabbedView);
ui->m_lpMDIArea->setTabsClosable(true);
ui->m_lpMDIArea->setTabsMovable(true);
// loadPlugins(QString("%1%2%3").arg(QDir::currentPath()).arg(QDir::separator()).arg("plugins"));
loadPlugins(QString("%1%2%3").arg(qApp->applicationDirPath()).arg(QDir::separator()).arg("plugins"));
m_lpIngredientsListModel = new QStandardItemModel(0, 1);
m_lpIngredientsListModel = new QStandardItemModel(0, 3);
QStringList header;
ui->m_lpIngredientsList->setModel(m_lpIngredientsListModel);
header << tr("Ingredient") << tr("Calories") << tr("Carboh.");
m_lpIngredientsListModel->setHorizontalHeaderLabels(header);
ui->m_lpIngredientsList->header()->setStretchLastSection(false);
ui->m_lpIngredientsList->header()->setSectionResizeMode(0, QHeaderView::Stretch);
connect(ui->m_lpMenu_File_Exit, SIGNAL(triggered(bool)), this, SLOT(menuFileExitTriggered()));
connect(ui->m_lpMenu_Tools_Options, SIGNAL(triggered(bool)), this, SLOT(menuToolsOptionsTriggered()));
@@ -256,22 +270,26 @@ void cMainWindow::loadIngredients()
lpGroupItem = new QStandardItem(szOldGroup);
m_lpIngredientsListModel->appendRow(lpGroupItem);
}
QStandardItem* lpNew = new QStandardItem(ingredients.at(z).szIngredient);
lpGroupItem->appendRow(lpNew);
QStandardItem* lpNew = new QStandardItem(ingredients.at(z).szIngredient);
lpNew->setData(ingredients.at(z).iIngredient);
QStandardItem* lpCalories = new QStandardItem(QString("%1 kCal").arg(ingredients.at(z).dCalories));
QStandardItem* lpCarbos = new QStandardItem(QString("%1 g").arg(ingredients.at(z).dCarbohydrates, 0, 'f', 1));
lpCalories->setTextAlignment(Qt::AlignRight);
lpCarbos->setTextAlignment(Qt::AlignRight);
lpGroupItem->appendRow(QList<QStandardItem *>() << lpNew << lpCalories << lpCarbos);
}
}
}
ui->m_lpIngredientsList->expandAll();
ui->m_lpIngredientsList->resizeColumnToContents(0);
ui->m_lpIngredientsList->resizeColumnToContents(1);
ui->m_lpIngredientsList->resizeColumnToContents(2);
}
void cMainWindow::pluginImportTriggered()
{
/*
QSettings settings;
cIngredient ingredient(QString("%1/000001.ingredient").arg(settings.value("program/ingredientDir").toString()));
ingredient.save();
*/
QAction* lpAction = qobject_cast<QAction *>(sender());
if(lpAction)
{
@@ -316,20 +334,9 @@ void cMainWindow::pluginDBTriggered()
cPlugin* lpPlugin = plugin(lpAction);
if(lpPlugin)
{
if(!lpPlugin->pluginName().compare("MySQL DB"))
{
cDBInterface* lpDBInterface = lpPlugin->dbInterface();
QString str = lpDBInterface->pluginName();
if(lpDBInterface)
lpDBInterface->init();
}
else if(!lpPlugin->pluginName().compare("SQLite DB"))
{
cDBInterface* lpDBInterface = lpPlugin->dbInterface();
QString str = lpDBInterface->pluginName();
if(lpDBInterface)
lpDBInterface->init();
}
cDBInterface* lpDBInterface = lpPlugin->dbInterface();
if(lpDBInterface->config())
loadIngredients();
}
}
}
@@ -391,10 +398,16 @@ void cMainWindow::ingredientsListNewTriggered()
void cMainWindow::ingredientsListImportTriggered()
{
cImportIngredientDialog importIngredientDialog(this);
importIngredientDialog.setPluginList(m_pluginList);
importIngredientDialog.setPluginList(m_pluginList, m_szLastImportPlugin);
cDBInterface* lpInterface = m_lpDB->dbInterface();
if(lpInterface)
importIngredientDialog.setIngredientGroupList(lpInterface->groups());
if(importIngredientDialog.exec() == QDialog::Rejected)
return;
m_szLastImportPlugin = importIngredientDialog.pluginSelected();
cMessageAnimateDialog* lpDialog = new cMessageAnimateDialog(this);
lpDialog->setTitle("Import Ingredient");
lpDialog->setMessage("Saving");
@@ -413,4 +426,21 @@ void cMainWindow::ingredientsListDeleteTriggered()
void cMainWindow::ingredientsListEditTriggered()
{
QModelIndex index = ui->m_lpIngredientsList->currentIndex();
if(index.isValid())
{
QStandardItem* lpItem = m_lpIngredientsListModel->itemFromIndex(index);
if(!lpItem)
return;
QStandardItem* lpParent = lpItem->parent();
if(!lpParent)
return;
cIngredientWindow* lpIngredientWindow = new cIngredientWindow(this);
QMdiSubWindow* lpSubWindow = ui->m_lpMDIArea->addSubWindow(lpIngredientWindow);
lpSubWindow->setAttribute(Qt::WA_DeleteOnClose);
lpIngredientWindow->setIngredient(lpItem->data().toInt(), m_lpDB);
lpIngredientWindow->show();
}
}
+1 -1
View File
@@ -129,7 +129,7 @@ private:
QMenu* m_lpIngredientsListMenu; /**< Context menu for ingredients list */
cPlugin* m_lpDB;
QString m_szLastImportPlugin;
/**
* \brief Initialized main windows.
*
+14 -11
View File
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1124</width>
<width>776</width>
<height>624</height>
</rect>
</property>
@@ -37,8 +37,11 @@
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<attribute name="headerVisible">
<property name="headerHidden">
<bool>false</bool>
</property>
<attribute name="headerVisible">
<bool>true</bool>
</attribute>
</widget>
</item>
@@ -50,14 +53,14 @@
</attribute>
</widget>
</widget>
<widget class="cMdiArea" name="m_lpMDIArea">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
<widget class="cMdiArea" name="m_lpMDIArea">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</widget>
</item>
</layout>
@@ -67,7 +70,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1124</width>
<width>776</width>
<height>21</height>
</rect>
</property>
+3
View File
@@ -8,8 +8,11 @@
typedef struct tagINGREDIENT
{
qint32 iIngredient;
QString szGroup;
QString szIngredient;
double dCalories;
double dCarbohydrates;
} INGREDIENT, *LPINGREDIENT;
typedef QList<INGREDIENT> INGREDIENT_LIST;
+54 -3
View File
@@ -1,6 +1,8 @@
#include "cmysqlplugin.h"
#include "cconfigdialog.h"
#include "cingredient.h"
#include <QSqlError>
#include <QSettings>
#include <QSqlQuery>
@@ -267,13 +269,59 @@ bool cMySQLPlugin::set(qint32 id, qint16 ingredientNumber, qreal value)
return(existsIngredient(id, ingredientNumber));
}
QString cMySQLPlugin::name(qint32 id)
{
if(!m_bConnected)
return("");
QSqlQuery query(m_db);
if(!query.exec(QString("SELECT name FROM ingredient WHERE id=%1").arg(id).arg(id)))
{
m_szLastError = query.lastError().text();
return("");
}
query.first();
return(query.value("name").toString());
}
QString cMySQLPlugin::group(qint32 id)
{
if(!m_bConnected)
return("");
QSqlQuery query(m_db);
if(!query.exec(QString("SELECT name FROM ingredient, ingredient_group WHERE ingredient.ingredient_group_id=ingredient_group.id AND ingredient.id=%1").arg(id).arg(id)))
{
m_szLastError = query.lastError().text();
return("");
}
query.first();
return(query.value("name").toString());
}
qreal cMySQLPlugin::get(qint32 id, qint16 ingredientNumber)
{
if(!m_bConnected)
return(-1);
QSqlQuery query(m_db);
if(!query.exec(QString("SELECT value FROM ingredient_values WHERE ingredient_id=%1 AND ingredient_number=%2").arg(id).arg(ingredientNumber)))
{
m_szLastError = query.lastError().text();
return(-1);
}
query.first();
return(query.value("value").toReal());
}
INGREDIENT_LIST cMySQLPlugin::ingredients()
{
if(!m_bConnected)
return(INGREDIENT_LIST());
QSqlQuery query(m_db);
if(!query.exec(QString("SELECT ingredient.name, ingredient_group.name FROM ingredient, ingredient_group WHERE ingredient.ingredient_group_id = ingredient_group.id ORDER BY ingredient_group.name, ingredient.name")))
// if(!query.exec(QString("SELECT ingredient.name, ingredient_group.name FROM ingredient, ingredient_group WHERE ingredient.ingredient_group_id = ingredient_group.id ORDER BY ingredient_group.name, ingredient.name")))
if(!query.exec(QString(QString("SELECT ingredient.id, ingredient.name, ingredient_group.name, calories.value, carbohydrates.value FROM ingredient, ingredient_group, ingredient_values AS calories, ingredient_values AS carbohydrates WHERE ingredient.ingredient_group_id = ingredient_group.id AND calories.ingredient_id = ingredient.id AND calories.ingredient_number = %1 AND carbohydrates.ingredient_id = ingredient.id AND carbohydrates.ingredient_number = %2 ORDER BY ingredient_group.name, ingredient.name").arg(cIngredient::iIngredientCalories).arg(cIngredient::iIngredientCarbohydrates))))
{
m_szLastError = query.lastError().text();
return(INGREDIENT_LIST());
@@ -283,8 +331,11 @@ INGREDIENT_LIST cMySQLPlugin::ingredients()
while(query.next())
{
INGREDIENT i;
i.szGroup = query.value(1).toString();
i.szIngredient = query.value(0).toString();
i.iIngredient = query.value(0).toInt();
i.szIngredient = query.value(1).toString();
i.szGroup = query.value(2).toString();
i.dCalories = query.value(3).toDouble();
i.dCarbohydrates = query.value(4).toDouble();
list.append(i);
}
+3
View File
@@ -117,6 +117,9 @@ public:
qint32 create(const QString& szName, const QString& szGroup);
qint32 createGroup(const QString& szGroup);
bool set(qint32 id, qint16 ingredientNumber, qreal value);
QString name(qint32 id);
QString group(qint32 id);
qreal get(qint32 id, qint16 ingredientNumber);
INGREDIENT_LIST ingredients();
QStringList groups();
bool beginTransaction();
+53 -3
View File
@@ -1,6 +1,8 @@
#include "csqliteplugin.h"
#include "cconfigdialog.h"
#include "cingredient.h"
#include <QSqlError>
#include <QSettings>
#include <QSqlQuery>
@@ -253,13 +255,58 @@ bool cSQLitePlugin::set(qint32 id, qint16 ingredientNumber, qreal value)
return(existsIngredient(id, ingredientNumber));
}
QString cSQLitePlugin::name(qint32 id)
{
if(!m_bConnected)
return("");
QSqlQuery query(m_db);
if(!query.exec(QString("SELECT name FROM ingredient WHERE id=%1").arg(id)))
{
m_szLastError = query.lastError().text();
return("");
}
query.first();
return(query.value("name").toString());
}
QString cSQLitePlugin::group(qint32 id)
{
if(!m_bConnected)
return("");
QSqlQuery query(m_db);
if(!query.exec(QString("SELECT ingredient_group.name FROM ingredient, ingredient_group WHERE ingredient.ingredient_group_id=ingredient_group.id AND ingredient.id=%1").arg(id).arg(id)))
{
m_szLastError = query.lastError().text();
return("");
}
query.first();
return(query.value("name").toString());
}
qreal cSQLitePlugin::get(qint32 id, qint16 ingredientNumber)
{
if(!m_bConnected)
return(-1);
QSqlQuery query(m_db);
if(!query.exec(QString("SELECT value FROM ingredient_values WHERE ingredient_id=%1 AND ingredient_number=%2").arg(id).arg(ingredientNumber)))
{
m_szLastError = query.lastError().text();
return(-1);
}
query.first();
return(query.value("value").toReal());
}
INGREDIENT_LIST cSQLitePlugin::ingredients()
{
if(!m_bConnected)
return(INGREDIENT_LIST());
QSqlQuery query(m_db);
if(!query.exec(QString("SELECT ingredient.name, ingredient_group.name FROM ingredient, ingredient_group WHERE ingredient.ingredient_group_id = ingredient_group.id ORDER BY ingredient_group.name, ingredient.name")))
if(!query.exec(QString(QString("SELECT ingredient.id, ingredient.name, ingredient_group.name, calories.value, carbohydrates.value FROM ingredient, ingredient_group, ingredient_values AS calories, ingredient_values AS carbohydrates WHERE ingredient.ingredient_group_id = ingredient_group.id AND calories.ingredient_id = ingredient.id AND calories.ingredient_number = %1 AND carbohydrates.ingredient_id = ingredient.id AND carbohydrates.ingredient_number = %2 ORDER BY ingredient_group.name, ingredient.name").arg(cIngredient::iIngredientCalories).arg(cIngredient::iIngredientCarbohydrates))))
{
m_szLastError = query.lastError().text();
return(INGREDIENT_LIST());
@@ -269,8 +316,11 @@ INGREDIENT_LIST cSQLitePlugin::ingredients()
while(query.next())
{
INGREDIENT i;
i.szGroup = query.value(1).toString();
i.szIngredient = query.value(0).toString();
i.iIngredient = query.value(0).toInt();
i.szIngredient = query.value(1).toString();
i.szGroup = query.value(2).toString();
i.dCalories = query.value(3).toDouble();
i.dCarbohydrates = query.value(4).toDouble();
list.append(i);
}
+3
View File
@@ -78,6 +78,9 @@ public:
qint32 create(const QString& szName, const QString &szGroup);
qint32 createGroup(const QString& szGroup);
bool set(qint32 id, qint16 ingredientNumber, qreal value);
QString name(qint32 id);
QString group(qint32 id);
qreal get(qint32 id, qint16 ingredientNumber);
INGREDIENT_LIST ingredients();
QStringList groups();
bool beginTransaction();
+3
View File
@@ -167,6 +167,9 @@ bool cBleibFitPlugin::load(qint16 iIndex)
if(iIndex > m_szUrls.count())
return(false);
for(int i = 0;i < cIngredient::iIngredientMax;i++)
m_rValues[i] = -1;
QNetworkAccessManager networkManager;
QNetworkRequest request(QUrl(m_szUrls.at(iIndex)));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");