forked from Brewtarget/brewtarget
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt Young
committed
Nov 26, 2022
1 parent
cda185c
commit 045eaac
Showing
14 changed files
with
128 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* FermentableTableModel.cpp is part of Brewtarget, and is Copyright the following | ||
* authors 2009-2021 | ||
* authors 2009-2022 | ||
* - Matt Young <[email protected]> | ||
* - Mik Firestone <[email protected]> | ||
* - Philip Greggory Lee <[email protected]> | ||
|
@@ -44,7 +44,6 @@ | |
#include "MainWindow.h" | ||
#include "measurement/Measurement.h" | ||
#include "measurement/Unit.h" | ||
#include "model/Fermentable.h" | ||
#include "model/Inventory.h" | ||
#include "model/Recipe.h" | ||
#include "PersistentSettings.h" | ||
|
@@ -172,7 +171,8 @@ void FermentableTableModel::addFermentables(QList<std::shared_ptr<Fermentable> > | |
} | ||
} | ||
|
||
void FermentableTableModel::removeFermentable(int fermId, std::shared_ptr<QObject> object) { | ||
void FermentableTableModel::removeFermentable([[maybe_unused]] int fermId, | ||
std::shared_ptr<QObject> object) { | ||
this->remove(std::static_pointer_cast<Fermentable>(object)); | ||
return; | ||
} | ||
|
@@ -235,14 +235,13 @@ void FermentableTableModel::changedInventory(int invKey, BtStringConst const & p | |
return; | ||
} | ||
|
||
void FermentableTableModel::changed(QMetaProperty prop, QVariant /*val*/) { | ||
void FermentableTableModel::changed(QMetaProperty prop, [[maybe_unused]] QVariant val) { | ||
qDebug() << Q_FUNC_INFO << prop.name(); | ||
|
||
// Is sender one of our fermentables? | ||
Fermentable* fermSender = qobject_cast<Fermentable*>(sender()); | ||
if (fermSender) { | ||
auto spFermSender = ObjectStoreWrapper::getSharedFromRaw(fermSender); | ||
int ii = this->rows.indexOf(spFermSender); | ||
int ii = this->findIndexOf(fermSender); | ||
if (ii < 0) { | ||
return; | ||
} | ||
|
@@ -295,7 +294,7 @@ QVariant FermentableTableModel::data(QModelIndex const & index, int role) const | |
return QVariant(row->typeStringTr()); | ||
} | ||
if (role == Qt::UserRole) { | ||
return QVariant(row->type()); | ||
return QVariant(static_cast<int>(row->type())); | ||
} | ||
break; | ||
case FERMINVENTORYCOL: | ||
|
@@ -325,15 +324,15 @@ QVariant FermentableTableModel::data(QModelIndex const & index, int role) const | |
return QVariant(row->additionMethodStringTr()); | ||
} | ||
if (role == Qt::UserRole) { | ||
return QVariant(row->additionMethod()); | ||
return QVariant(static_cast<int>(row->additionMethod())); | ||
} | ||
break; | ||
case FERMAFTERBOIL: | ||
if (role == Qt::DisplayRole) { | ||
return QVariant(row->additionTimeStringTr()); | ||
} | ||
if (role == Qt::UserRole) { | ||
return QVariant(row->additionTime()); | ||
return QVariant(static_cast<int>(row->additionTime())); | ||
} | ||
break; | ||
case FERMYIELDCOL: | ||
|
@@ -402,7 +401,9 @@ Qt::ItemFlags FermentableTableModel::flags(const QModelIndex& index ) const { | |
} | ||
|
||
|
||
bool FermentableTableModel::setData(QModelIndex const & index, QVariant const & value, int role) { | ||
bool FermentableTableModel::setData(QModelIndex const & index, | ||
QVariant const & value, | ||
[[maybe_unused]] int role) { | ||
if (index.row() >= static_cast<int>(this->rows.size())) { | ||
return false; | ||
} | ||
|
@@ -525,7 +526,7 @@ FermentableItemDelegate::FermentableItemDelegate(QObject* parent) : QItemDelegat | |
} | ||
|
||
QWidget* FermentableItemDelegate::createEditor(QWidget *parent, | ||
QStyleOptionViewItem const & option, | ||
[[maybe_unused]] QStyleOptionViewItem const & option, | ||
QModelIndex const & index) const { | ||
if (index.column() == FERMTYPECOL ) | ||
{ | ||
|
@@ -564,13 +565,10 @@ QWidget* FermentableItemDelegate::createEditor(QWidget *parent, | |
int type = index.model()->index(index.row(), FERMTYPECOL).data(Qt::UserRole).toInt(); | ||
|
||
// Hide the unsuitable item keeping the same enumeration | ||
if(type == Fermentable::Grain) | ||
{ | ||
list->item(Fermentable::Not_Mashed)->setHidden(true); | ||
} | ||
else | ||
{ | ||
list->item(Fermentable::Steeped)->setHidden(true); | ||
if (type == static_cast<int>(Fermentable::Type::Grain)) { | ||
list->item(static_cast<int>(Fermentable::AdditionMethod::Not_Mashed))->setHidden(true); | ||
} else { | ||
list->item(static_cast<int>(Fermentable::AdditionMethod::Steeped))->setHidden(true); | ||
} | ||
|
||
return box; | ||
|
@@ -645,7 +643,8 @@ void FermentableItemDelegate::setModelData(QWidget *editor, QAbstractItemModel * | |
} | ||
} | ||
|
||
void FermentableItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const | ||
{ | ||
void FermentableItemDelegate::updateEditorGeometry(QWidget * editor, | ||
QStyleOptionViewItem const & option, | ||
[[maybe_unused]] QModelIndex const & index) const { | ||
editor->setGeometry(option.rect); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* HopTableModel.cpp is part of Brewtarget, and is Copyright the following | ||
* authors 2009-2021 | ||
* authors 2009-2022 | ||
* - Luke Vincent <[email protected]> | ||
* - Matt Young <[email protected]> | ||
* - Mik Firestone <[email protected]> | ||
|
@@ -189,7 +189,8 @@ bool HopTableModel::remove(std::shared_ptr<Hop> hop) { | |
return false; | ||
} | ||
|
||
void HopTableModel::removeHop(int hopId, std::shared_ptr<QObject> object) { | ||
void HopTableModel::removeHop([[maybe_unused]] int hopId, | ||
std::shared_ptr<QObject> object) { | ||
this->remove(std::static_pointer_cast<Hop>(object)); | ||
return; | ||
} | ||
|
@@ -220,13 +221,12 @@ void HopTableModel::changedInventory(int invKey, BtStringConst const & propertyN | |
return; | ||
} | ||
|
||
void HopTableModel::changed(QMetaProperty prop, QVariant /*val*/) { | ||
void HopTableModel::changed(QMetaProperty prop, [[maybe_unused]] QVariant val) { | ||
|
||
// Find the notifier in the list | ||
Hop * hopSender = qobject_cast<Hop *>(sender()); | ||
if (hopSender) { | ||
auto spHopSender = ObjectStoreWrapper::getSharedFromRaw(hopSender); | ||
int ii = this->rows.indexOf(spHopSender); | ||
int ii = this->findIndexOf(hopSender); | ||
if (ii < 0) { | ||
return; | ||
} | ||
|
@@ -299,7 +299,7 @@ QVariant HopTableModel::data(const QModelIndex & index, int role) const { | |
return QVariant(row->useStringTr()); | ||
} | ||
if (role == Qt::UserRole) { | ||
return QVariant(row->use()); | ||
return QVariant(static_cast<int>(row->use())); | ||
} | ||
break; | ||
case HOPTIMECOL: | ||
|
@@ -314,7 +314,7 @@ QVariant HopTableModel::data(const QModelIndex & index, int role) const { | |
if (role == Qt::DisplayRole) { | ||
return QVariant(row->formStringTr()); | ||
} else if (role == Qt::UserRole) { | ||
return QVariant(row->form()); | ||
return QVariant(static_cast<int>(row->form())); | ||
} | ||
break; | ||
default : | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* MashStepTableModel.cpp is part of Brewtarget, and is Copyright the following | ||
* authors 2009-2021 | ||
* authors 2009-2022 | ||
* - Matt Young <[email protected]> | ||
* - Maxime Lavigne <[email protected]> | ||
* - Mik Firestone <[email protected]> | ||
|
@@ -200,12 +200,12 @@ void MashStepTableModel::mashChanged() { | |
return; | ||
} | ||
|
||
void MashStepTableModel::mashStepChanged(QMetaProperty prop, QVariant val) { | ||
void MashStepTableModel::mashStepChanged(QMetaProperty prop, | ||
[[maybe_unused]] QVariant val) { | ||
qDebug() << Q_FUNC_INFO; | ||
|
||
MashStep* stepSenderRaw = qobject_cast<MashStep*>(sender()); | ||
if (stepSenderRaw) { | ||
auto stepSender = ObjectStoreWrapper::getSharedFromRaw(stepSenderRaw); | ||
MashStep* stepSender = qobject_cast<MashStep*>(sender()); | ||
if (stepSender) { | ||
if (stepSender->getMashId() != this->mashObs->key()) { | ||
// It really shouldn't happen that we get a notification for a MashStep that's not in the Mash we're watching, | ||
// but, if we do, then stop trying to process the update. | ||
|
@@ -216,10 +216,10 @@ void MashStepTableModel::mashStepChanged(QMetaProperty prop, QVariant val) { | |
return; | ||
} | ||
|
||
int ii = this->rows.indexOf(stepSender); | ||
int ii = this->findIndexOf(stepSender); | ||
if (ii >= 0) { | ||
if (prop.name() == PropertyNames::MashStep::stepNumber) { | ||
this->reorderMashStep(stepSender, ii); | ||
this->reorderMashStep(this->rows.at(ii), ii); | ||
} | ||
|
||
emit dataChanged( QAbstractItemModel::createIndex(ii, 0), | ||
|
@@ -267,7 +267,7 @@ QVariant MashStepTableModel::data(QModelIndex const & index, int role) const { | |
return QVariant( | ||
Measurement::displayAmount( | ||
Measurement::Amount{ | ||
row->type() == MashStep::Decoction ? row->decoctionAmount_l() : row->infuseAmount_l(), | ||
row->type() == MashStep::Type::Decoction ? row->decoctionAmount_l() : row->infuseAmount_l(), | ||
Measurement::Units::liters | ||
}, | ||
3, | ||
|
@@ -276,7 +276,7 @@ QVariant MashStepTableModel::data(QModelIndex const & index, int role) const { | |
) | ||
); | ||
case MASHSTEPTEMPCOL: | ||
if (row->type() == MashStep::Decoction) { | ||
if (row->type() == MashStep::Type::Decoction) { | ||
return QVariant("---"); | ||
} | ||
return QVariant( | ||
|
@@ -361,7 +361,7 @@ bool MashStepTableModel::setData(QModelIndex const & index, QVariant const & val | |
|
||
case MASHSTEPAMOUNTCOL: | ||
if (value.canConvert(QVariant::String)) { | ||
if (row->type() == MashStep::Decoction ) { | ||
if (row->type() == MashStep::Type::Decoction ) { | ||
MainWindow::instance().doOrRedoUpdate( | ||
*row, | ||
PropertyNames::MashStep::decoctionAmount_l, | ||
|
@@ -387,7 +387,7 @@ bool MashStepTableModel::setData(QModelIndex const & index, QVariant const & val | |
return false; | ||
|
||
case MASHSTEPTEMPCOL: | ||
if (value.canConvert(QVariant::String) && row->type() != MashStep::Decoction) { | ||
if (value.canConvert(QVariant::String) && row->type() != MashStep::Type::Decoction) { | ||
MainWindow::instance().doOrRedoUpdate( | ||
*row, | ||
PropertyNames::MashStep::infuseTemp_c, | ||
|
Oops, something went wrong.