Improve/redesign ingredients #13

Merged
andrewlalis merged 13 commits from improve/redesignIngredients into development 2018-05-22 21:29:25 +00:00
3 changed files with 2 additions and 126 deletions
Showing only changes of commit 17797eeb5f - Show all commits

View File

@ -8,13 +8,8 @@ OpenRecipeDialog::OpenRecipeDialog(QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
ui->recipeTableView->setModel(&this->recipeTableModel); ui->recipeTableView->setModel(&this->recipeTableModel);
ui->ingredientsListView->setModel(&this->ingredientsModel);
ui->tagsListView->setModel(&this->tagsModel); ui->tagsListView->setModel(&this->tagsModel);
QObject::connect(ui->ingredientsListView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this,
SLOT(onIngredientsListViewSelectionChanged(QItemSelection)));
QObject::connect(ui->tagsListView->selectionModel(), QObject::connect(ui->tagsListView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, this,
@ -23,9 +18,7 @@ OpenRecipeDialog::OpenRecipeDialog(QWidget *parent) :
OpenRecipeDialog::OpenRecipeDialog(RecipeDatabase *recipeDB, QWidget *parent) : OpenRecipeDialog(parent){ OpenRecipeDialog::OpenRecipeDialog(RecipeDatabase *recipeDB, QWidget *parent) : OpenRecipeDialog(parent){
this->recipeDB = recipeDB; this->recipeDB = recipeDB;
this->populateIngredientsList();
this->populateTagsList(); this->populateTagsList();
this->populateFoodGroupsList();
this->populateRecipesTable(this->recipeDB->retrieveAllRecipes()); this->populateRecipesTable(this->recipeDB->retrieveAllRecipes());
} }
@ -45,21 +38,10 @@ void OpenRecipeDialog::populateRecipesTable(vector<Recipe> recipes){
ui->recipeTableView->show(); ui->recipeTableView->show();
} }
void OpenRecipeDialog::populateIngredientsList(){
this->ingredientsModel.setIngredients(this->recipeDB->retrieveAllIngredients());
}
void OpenRecipeDialog::populateTagsList(){ void OpenRecipeDialog::populateTagsList(){
this->tagsModel.setTags(this->recipeDB->retrieveAllTags()); this->tagsModel.setTags(this->recipeDB->retrieveAllTags());
} }
void OpenRecipeDialog::populateFoodGroupsList(){
for (string s : this->recipeDB->retrieveAllFoodGroups()){
ui->foodGroupsListWidget->addItem(QString::fromStdString(s));
}
//ui->foodGroupsListWidget->show();
}
void OpenRecipeDialog::on_deleteRecipeButton_clicked(){ void OpenRecipeDialog::on_deleteRecipeButton_clicked(){
QItemSelectionModel *selectModel = ui->recipeTableView->selectionModel(); QItemSelectionModel *selectModel = ui->recipeTableView->selectionModel();
if (!selectModel->hasSelection()){ if (!selectModel->hasSelection()){

View File

@ -30,14 +30,10 @@ class OpenRecipeDialog : public QDialog
void on_recipeTableView_doubleClicked(const QModelIndex &index); void on_recipeTableView_doubleClicked(const QModelIndex &index);
void onIngredientsListViewSelectionChanged(const QItemSelection &selection);
void onTagsListViewSelectionChanged(const QItemSelection &selection); void onTagsListViewSelectionChanged(const QItemSelection &selection);
void on_nameEdit_textChanged(const QString &arg1); void on_nameEdit_textChanged(const QString &arg1);
void on_foodGroupsListWidget_itemSelectionChanged();
void on_clearSearchButton_clicked(); void on_clearSearchButton_clicked();
void on_exitButton_clicked(); void on_exitButton_clicked();
@ -48,13 +44,10 @@ class OpenRecipeDialog : public QDialog
RecipeTableModel recipeTableModel; RecipeTableModel recipeTableModel;
Recipe selectedRecipe; Recipe selectedRecipe;
IngredientListModel ingredientsModel;
TagListModel tagsModel; TagListModel tagsModel;
void populateRecipesTable(vector<Recipe> recipes); void populateRecipesTable(vector<Recipe> recipes);
void populateIngredientsList();
void populateTagsList(); void populateTagsList();
void populateFoodGroupsList();
}; };
#endif // OPENRECIPEDIALOG_H #endif // OPENRECIPEDIALOG_H

View File

@ -48,7 +48,7 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<item alignment="Qt::AlignLeft"> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@ -63,7 +63,7 @@
<enum>QTabWidget::Rounded</enum> <enum>QTabWidget::Rounded</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="Tags"> <widget class="QWidget" name="Tags">
<attribute name="icon"> <attribute name="icon">
@ -119,105 +119,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="ingredientsTab">
<attribute name="icon">
<iconset resource="../res.qrc">
<normaloff>:/images/images/ingredients.png</normaloff>:/images/images/ingredients.png</iconset>
</attribute>
<attribute name="title">
<string/>
</attribute>
<attribute name="toolTip">
<string>Ingredients</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QListView" name="ingredientsListView">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="foodGroups">
<attribute name="icon">
<iconset resource="../res.qrc">
<normaloff>:/images/images/foodPyramid.png</normaloff>:/images/images/foodPyramid.png</iconset>
</attribute>
<attribute name="title">
<string/>
</attribute>
<attribute name="toolTip">
<string>Food Groups</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QListWidget" name="foodGroupsListWidget">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
<item> <item>