Added selection listener.
This commit is contained in:
parent
844c558726
commit
019e0e3cde
|
@ -10,6 +10,11 @@ OpenRecipeDialog::OpenRecipeDialog(QWidget *parent) :
|
||||||
ui->recipeTableView->setModel(&this->recipeTableModel);
|
ui->recipeTableView->setModel(&this->recipeTableModel);
|
||||||
ui->ingredientsListView->setModel(&this->ingredientsModel);
|
ui->ingredientsListView->setModel(&this->ingredientsModel);
|
||||||
ui->tagsListView->setModel(&this->tagsModel);
|
ui->tagsListView->setModel(&this->tagsModel);
|
||||||
|
|
||||||
|
connect(ui->ingredientsListView->selectionModel(),
|
||||||
|
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||||
|
this,
|
||||||
|
SLOT(on_ingredientsListView_selectionChanged(QItemSelection)));
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenRecipeDialog::OpenRecipeDialog(RecipeDatabase *recipeDB, QWidget *parent) : OpenRecipeDialog(parent){
|
OpenRecipeDialog::OpenRecipeDialog(RecipeDatabase *recipeDB, QWidget *parent) : OpenRecipeDialog(parent){
|
||||||
|
@ -74,3 +79,14 @@ void OpenRecipeDialog::on_recipeTableView_doubleClicked(const QModelIndex &index
|
||||||
this->selectedRecipe = this->recipeTableModel.getRecipeAt(index.row());
|
this->selectedRecipe = this->recipeTableModel.getRecipeAt(index.row());
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenRecipeDialog::on_ingredientsListView_selectionChanged(const QItemSelection &selection){
|
||||||
|
printf("Selection changed!\n");
|
||||||
|
vector<Ingredient> ingredients;
|
||||||
|
for (QModelIndex index : selection.indexes()){
|
||||||
|
Ingredient i = this->ingredientsModel.getIngredients().at(index.row());
|
||||||
|
ingredients.push_back(i);
|
||||||
|
printf("Selected: %s\n", i.getName().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QItemSelection>
|
||||||
|
|
||||||
#include "model/database/recipedatabase.h"
|
#include "model/database/recipedatabase.h"
|
||||||
#include "model/recipe/recipetablemodel.h"
|
#include "model/recipe/recipetablemodel.h"
|
||||||
|
@ -29,6 +30,8 @@ class OpenRecipeDialog : public QDialog
|
||||||
|
|
||||||
void on_recipeTableView_doubleClicked(const QModelIndex &index);
|
void on_recipeTableView_doubleClicked(const QModelIndex &index);
|
||||||
|
|
||||||
|
void on_ingredientsListView_selectionChanged(const QItemSelection &selection);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::OpenRecipeDialog *ui;
|
Ui::OpenRecipeDialog *ui;
|
||||||
RecipeDatabase *recipeDB;
|
RecipeDatabase *recipeDB;
|
||||||
|
|
Loading…
Reference in New Issue