Skip to content

Commit

Permalink
Merge pull request #842 from matty0ung/usability
Browse files Browse the repository at this point in the history
Various fixes
  • Loading branch information
matty0ung authored Sep 30, 2024
2 parents 57389f2 + 88bd8d2 commit 5843214
Show file tree
Hide file tree
Showing 87 changed files with 2,958 additions and 2,400 deletions.
16 changes: 14 additions & 2 deletions CHANGES.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,20 @@ happens, so I'm now setting it to a slightly arbitrary time early in the morning
* Additional methods for calculating IBU
* We'll list other new features here...

## v4.0.6
Bug fixes for the 4.0.5 release (ie bugs in 4.0.5 are fixed in this 4.0.6 release).

### New Features
* None

### Bug Fixes
* Ingredient inventory edits not saved [832](https://github.com/Brewtarget/brewtarget/issues/832)

### Release Timestamp
Mon, 30 Sep 2024 04:00:06 +0100

## v4.0.5
Minor bug fixes for the 4.0.4 release (ie bugs in 4.0.4 are fixed in this 4.0.5 release).
Bug fixes for the 4.0.4 release (ie bugs in 4.0.4 are fixed in this 4.0.5 release).

### New Features
* None
Expand All @@ -26,7 +38,7 @@ Minor bug fixes for the 4.0.4 release (ie bugs in 4.0.4 are fixed in this 4.0.5
* BeerXML/BeerJSON Recipe export does not match selected type [835](https://github.com/Brewtarget/brewtarget/issues/835)

### Release Timestamp
Sat, 28 Sep 2024 04:00:05 +0100
Sun, 29 Sep 2024 04:00:05 +0100

## v4.0.4
Minor bug fixes for the 4.0.3 release (ie bugs in 4.0.3 are fixed in this 4.0.4 release).
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ endif()
#=======================================================================================================================
# It's simplest to keep the project name all lower-case as it means we can use a lot more of the default settings for
# Linux packaging (where directory names etc are expected to be all lower-case).
project(brewtarget VERSION 4.0.5 LANGUAGES CXX)
project(brewtarget VERSION 4.0.6 LANGUAGES CXX)
message(STATUS "Building ${PROJECT_NAME} version ${PROJECT_VERSION}")
message(STATUS "PROJECT_SOURCE_DIR is ${PROJECT_SOURCE_DIR}")
# Sometimes we do need the capitalised version of the project name
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
#
#
project('brewtarget', 'cpp',
version: '4.0.5',
version: '4.0.6',
license: 'GPL-3.0-or-later',
meson_version: '>=0.60.0',
default_options : ['cpp_std=c++20',
Expand Down
2 changes: 1 addition & 1 deletion src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ void MainWindow::treeActivated(const QModelIndex &index) {
{
Water * w = active->getItem<Water>(index);
if (w) {
this->pimpl->m_waterEditor->setWater(ObjectStoreWrapper::getSharedFromRaw(w));
this->pimpl->m_waterEditor->setEditItem(ObjectStoreWrapper::getSharedFromRaw(w));
this->pimpl->m_waterEditor->show();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/WaterDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ void WaterDialog::setRecipe(Recipe *rec) {
spinBox_spargeRO->setValue( QVariant(m_spargeRO * 100).toInt());

baseProfileButton->setWater(this->m_base);
m_base_editor->setWater(this->m_base);
m_base_editor->setEditItem(this->m_base);
// all of the magic to set the sliders happens in newTotals(). So don't do it twice
}
if (this->m_target && this->m_target != this->m_base) {
targetProfileButton->setWater(this->m_target);
m_target_editor->setWater(this->m_target);
m_target_editor->setEditItem(this->m_target);

this->setDigits();
}
Expand Down Expand Up @@ -327,7 +327,7 @@ void WaterDialog::update_baseProfile(int selected) {
qDebug() << Q_FUNC_INFO << "Made base child" << *this->m_base << "from parent" << parent;

baseProfileButton->setWater(this->m_base);
m_base_editor->setWater(this->m_base);
m_base_editor->setEditItem(this->m_base);
newTotals();
}
return;
Expand All @@ -351,7 +351,7 @@ void WaterDialog::update_targetProfile(int selected) {
qDebug() << Q_FUNC_INFO << "Made target child" << *this->m_target << "from parent" << parent;

targetProfileButton->setWater(this->m_target);
m_target_editor->setWater(this->m_target);
m_target_editor->setEditItem(this->m_target);

this->setDigits();
}
Expand Down
3 changes: 2 additions & 1 deletion src/database/DatabaseSchemaHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ namespace {
{QString("ALTER TABLE water ADD COLUMN iron_ppm %1").arg(db.getDbNativeTypeName<double>())},
{QString("ALTER TABLE water ADD COLUMN nitrate_ppm %1").arg(db.getDbNativeTypeName<double>())},
{QString("ALTER TABLE water ADD COLUMN nitrite_ppm %1").arg(db.getDbNativeTypeName<double>())},
{QString("ALTER TABLE water ADD COLUMN flouride_ppm %1").arg(db.getDbNativeTypeName<double>())},
{QString("ALTER TABLE water ADD COLUMN flouride_ppm %1").arg(db.getDbNativeTypeName<double>())}, // Should have been fluoride_ppm!
//
// Equipment: Extended and additional fields for BeerJSON. This includes changing a lot of column names as
// BeerJSON essentially has a record per vessel ("HLT", "Mash Tun", etc)
Expand Down Expand Up @@ -2188,6 +2188,7 @@ namespace {
case 12:
ret &= migrate_to_13(database, sqlQuery);
break;
// TODO: On next DB update, correct water.flouride_ppm to water.fluoride_ppm
default:
qCritical() << QString("Unknown version %1").arg(oldVersion);
return false;
Expand Down
3 changes: 2 additions & 1 deletion src/database/ObjectStoreTyped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ namespace {
{ObjectStore::FieldType::Double, "iron_ppm" , PropertyNames::Water::iron_ppm },
{ObjectStore::FieldType::Double, "nitrate_ppm" , PropertyNames::Water::nitrate_ppm },
{ObjectStore::FieldType::Double, "nitrite_ppm" , PropertyNames::Water::nitrite_ppm },
{ObjectStore::FieldType::Double, "flouride_ppm" , PropertyNames::Water::flouride_ppm },
// .:TODO:. We should correct the typo in this column name (copy-and-paste from BeerJSON
{ObjectStore::FieldType::Double, "flouride_ppm" , PropertyNames::Water::fluoride_ppm },
}
};

Expand Down
37 changes: 8 additions & 29 deletions src/editors/BoilEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌*/
=====================================================================================================================*/
#include "editors/BoilEditor.h"

#include <QDebug>
Expand All @@ -22,44 +22,23 @@
#include "model/Boil.h"
#include "model/Recipe.h"

BoilEditor::BoilEditor(QWidget* parent) :
BoilEditor::BoilEditor(QWidget* parent, QString const editorName) :
QDialog(parent),
EditorWithRecipeBase<BoilEditor, Boil>() {
EditorBase<BoilEditor, Boil, BoilEditorOptions>(editorName) {
this->setupUi(this);
this->postSetupUiInit(
{
EDITOR_FIELD(Boil, label_name , lineEdit_name , PropertyNames::NamedEntity::name ),
EDITOR_FIELD(Boil, label_description, textEdit_description, PropertyNames::Boil::description ),
EDITOR_FIELD(Boil, label_preBoilSize, lineEdit_preBoilSize, PropertyNames::Boil::preBoilSize_l, 2),
EDITOR_FIELD(Boil, label_notes , textEdit_notes , PropertyNames::Boil::notes )
EDITOR_FIELD_NORM(Boil, label_name , lineEdit_name , NamedEntity::name ),
EDITOR_FIELD_NORM(Boil, label_description, textEdit_description, Boil::description ),
EDITOR_FIELD_NORM(Boil, label_preBoilSize, lineEdit_preBoilSize, Boil::preBoilSize_l, 2),
EDITOR_FIELD_NORM(Boil, label_notes , textEdit_notes , Boil::notes ),
}
);

// NB: label_description / textEdit_description don't need initialisation here as neither is a smart field
// NB: label_notes / textEdit_notes don't need initialisation here as neither is a smart field
/// SMART_FIELD_INIT(BoilEditor, label_name , lineEdit_name , Boil, PropertyNames::NamedEntity::name );
/// SMART_FIELD_INIT(BoilEditor, label_preBoilSize, lineEdit_preBoilSize, Boil, PropertyNames::Boil::preBoilSize_l, 2);

/// connect(this, &QDialog::accepted, this, &BoilEditor::saveAndClose);
/// connect(this, &QDialog::rejected, this, &BoilEditor::closeEditor );

/// this->connectSignalsAndSlots();
return;
}

BoilEditor::~BoilEditor() = default;

void BoilEditor::writeFieldsToEditItem() {
return;
}

void BoilEditor::writeLateFieldsToEditItem() {
return;
}

void BoilEditor::readFieldsFromEditItem([[maybe_unused]] std::optional<QString> propName) {
return;
}

// Insert the boilerplate stuff that we cannot do in EditorWithRecipeBase
EDITOR_WITH_RECIPE_COMMON_CODE(BoilEditor)
EDITOR_COMMON_CODE(Boil)
9 changes: 6 additions & 3 deletions src/editors/BoilEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,23 @@

#include "ui_boilEditor.h"

#include "editors/EditorWithRecipeBase.h"
#include "editors/EditorBase.h"
#include "model/Boil.h"

#define BoilEditorOptions EditorBaseOptions{ .recipe = true }
/*!
* \class BoilEditor
*
* \brief View/controller dialog for editing a boil.
*
* See also \c NamedBoilEditor
*/
class BoilEditor : public QDialog, public Ui::boilEditor, public EditorWithRecipeBase<BoilEditor, Boil> {
class BoilEditor : public QDialog,
public Ui::boilEditor,
public EditorBase<BoilEditor, Boil, BoilEditorOptions> {
Q_OBJECT

EDITOR_WITH_RECIPE_COMMON_DECL(Boil)
EDITOR_COMMON_DECL(Boil, BoilEditorOptions)
};

#endif
71 changes: 16 additions & 55 deletions src/editors/BoilStepEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,67 +18,28 @@
#include "MainWindow.h"
#include "measurement/Unit.h"

BoilStepEditor::BoilStepEditor(QWidget* parent) :
BoilStepEditor::BoilStepEditor(QWidget* parent, QString const editorName) :
QDialog{parent},
EditorBase<BoilStepEditor, BoilStep>() {
EditorBase<BoilStepEditor, BoilStep, BoilStepEditorOptions>(editorName) {
this->setupUi(this);

// NB: label_description / textEdit_description don't need initialisation here as neither is a smart field
SMART_FIELD_INIT(BoilStepEditor, label_name , lineEdit_name , BoilStep, PropertyNames:: NamedEntity::name );
SMART_FIELD_INIT(BoilStepEditor, label_startTemp , lineEdit_startTemp , BoilStep, PropertyNames:: Step::startTemp_c , 1);
SMART_FIELD_INIT(BoilStepEditor, label_stepTime , lineEdit_stepTime , BoilStep, PropertyNames:: Step::stepTime_mins , 0);
SMART_FIELD_INIT(BoilStepEditor, label_rampTime , lineEdit_rampTime , BoilStep, PropertyNames:: Step::rampTime_mins , 0);
SMART_FIELD_INIT(BoilStepEditor, label_endTemp , lineEdit_endTemp , BoilStep, PropertyNames:: Step::endTemp_c , 1);
SMART_FIELD_INIT(BoilStepEditor, label_startAcidity , lineEdit_startAcidity , BoilStep, PropertyNames:: Step::startAcidity_pH, 1);
SMART_FIELD_INIT(BoilStepEditor, label_endAcidity , lineEdit_endAcidity , BoilStep, PropertyNames:: Step::endAcidity_pH , 1);
SMART_FIELD_INIT(BoilStepEditor, label_startGravity , lineEdit_startGravity , BoilStep, PropertyNames::StepExtended::startGravity_sg, 3);
SMART_FIELD_INIT(BoilStepEditor, label_endGravity , lineEdit_endGravity , BoilStep, PropertyNames::StepExtended::endGravity_sg , 3);

BT_COMBO_BOX_INIT(BoilStepEditor, comboBox_boilStepChillingType, BoilStep, chillingType);

this->connectSignalsAndSlots();
this->postSetupUiInit({
EDITOR_FIELD_NORM(BoilStep, label_name , lineEdit_name , NamedEntity::name ),
EDITOR_FIELD_NORM(BoilStep, label_description , textEdit_description , Step::description ),
EDITOR_FIELD_NORM(BoilStep, label_startTemp , lineEdit_startTemp , Step::startTemp_c , 1),
EDITOR_FIELD_NORM(BoilStep, label_stepTime , lineEdit_stepTime , Step::stepTime_mins , 0),
EDITOR_FIELD_NORM(BoilStep, label_rampTime , lineEdit_rampTime , Step::rampTime_mins , 0),
EDITOR_FIELD_NORM(BoilStep, label_endTemp , lineEdit_endTemp , Step::endTemp_c , 1),
EDITOR_FIELD_NORM(BoilStep, label_startAcidity , lineEdit_startAcidity , Step::startAcidity_pH , 1),
EDITOR_FIELD_NORM(BoilStep, label_endAcidity , lineEdit_endAcidity , Step::endAcidity_pH , 1),
EDITOR_FIELD_NORM(BoilStep, label_startGravity , lineEdit_startGravity , StepExtended::startGravity_sg, 3),
EDITOR_FIELD_NORM(BoilStep, label_endGravity , lineEdit_endGravity , StepExtended::endGravity_sg , 3),
EDITOR_FIELD_ENUM(BoilStep, label_boilStepChillingType, comboBox_boilStepChillingType, BoilStep::chillingType ),
});

return;
}

BoilStepEditor::~BoilStepEditor() = default;

void BoilStepEditor::readFieldsFromEditItem(std::optional<QString> propName) {
if (!propName || *propName == PropertyNames:: NamedEntity::name ) { this->lineEdit_name ->setTextCursor(m_editItem->name ()); if (propName) { return; } }
if (!propName || *propName == PropertyNames:: Step::description ) { this->textEdit_description ->setPlainText (m_editItem->description ()); if (propName) { return; } }
if (!propName || *propName == PropertyNames:: Step::startTemp_c ) { this->lineEdit_startTemp ->setQuantity (m_editItem->startTemp_c ()); if (propName) { return; } }
if (!propName || *propName == PropertyNames:: Step::stepTime_mins ) { this->lineEdit_stepTime ->setQuantity (m_editItem->stepTime_mins ()); if (propName) { return; } }
if (!propName || *propName == PropertyNames:: Step::rampTime_mins ) { this->lineEdit_rampTime ->setQuantity (m_editItem->rampTime_mins ()); if (propName) { return; } }
if (!propName || *propName == PropertyNames:: Step::endTemp_c ) { this->lineEdit_endTemp ->setQuantity (m_editItem->endTemp_c ()); if (propName) { return; } }
if (!propName || *propName == PropertyNames:: Step::startAcidity_pH) { this->lineEdit_startAcidity->setQuantity (m_editItem->startAcidity_pH()); if (propName) { return; } }
if (!propName || *propName == PropertyNames:: Step::endAcidity_pH ) { this->lineEdit_endAcidity ->setQuantity (m_editItem->endAcidity_pH ()); if (propName) { return; } }
if (!propName || *propName == PropertyNames::StepExtended::startGravity_sg) { this->lineEdit_startGravity->setQuantity (m_editItem->startGravity_sg()); if (propName) { return; } }
if (!propName || *propName == PropertyNames::StepExtended::endGravity_sg ) { this->lineEdit_endGravity ->setQuantity (m_editItem->endGravity_sg ()); if (propName) { return; } }

if (!propName || *propName == PropertyNames::BoilStep::chillingType ) { this->comboBox_boilStepChillingType->setValue(m_editItem->chillingType()); if (propName) { return; } }
return;
}

void BoilStepEditor::writeFieldsToEditItem() {
this->m_editItem->setName (this->lineEdit_name ->text ());
this->m_editItem->setDescription (this->textEdit_description ->toPlainText ());
this->m_editItem->setStartTemp_c (this->lineEdit_startTemp ->getOptCanonicalQty());
this->m_editItem->setStepTime_mins (this->lineEdit_stepTime ->getOptCanonicalQty());
this->m_editItem->setRampTime_mins (this->lineEdit_rampTime ->getOptCanonicalQty());
this->m_editItem->setEndTemp_c (this->lineEdit_endTemp ->getOptCanonicalQty());
this->m_editItem->setStartAcidity_pH(this->lineEdit_startAcidity->getOptCanonicalQty());
this->m_editItem->setEndAcidity_pH (this->lineEdit_endAcidity ->getOptCanonicalQty());
this->m_editItem->setStartGravity_sg(this->lineEdit_startGravity->getOptCanonicalQty());
this->m_editItem->setEndGravity_sg (this->lineEdit_endGravity ->getOptCanonicalQty());

this->m_editItem->setChillingType(this->comboBox_boilStepChillingType->getOptValue<BoilStep::ChillingType>());
return;
}

void BoilStepEditor::writeLateFieldsToEditItem() {
// Nothing to do here
return;
}

// Insert the boiler-plate stuff that we cannot do in EditorBase
EDITOR_COMMON_CODE(BoilStepEditor)
EDITOR_COMMON_CODE(BoilStep)
8 changes: 5 additions & 3 deletions src/editors/BoilStepEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@
#include "editors/EditorBase.h"
#include "model/BoilStep.h"

#define BoilStepEditorOptions EditorBaseOptions{ }
/*!
* \class BoilStepEditor
*
* \brief View/controller dialog for editing boil steps.
*/
class BoilStepEditor : public QDialog, public Ui::boilStepEditor, public EditorBase<BoilStepEditor, BoilStep> {
class BoilStepEditor : public QDialog,
public Ui::boilStepEditor,
public EditorBase<BoilStepEditor, BoilStep, BoilStepEditorOptions> {
Q_OBJECT

EDITOR_COMMON_DECL(BoilStep)

EDITOR_COMMON_DECL(BoilStep, BoilStepEditorOptions)
};

#endif
Loading

0 comments on commit 5843214

Please sign in to comment.