Skip to content

Commit

Permalink
Merge pull request #5 from Brewtarget/develop
Browse files Browse the repository at this point in the history
Update 3-10-2018
  • Loading branch information
rhoob committed Mar 10, 2018
2 parents ccdcdb9 + 5147543 commit 21c98dd
Show file tree
Hide file tree
Showing 19 changed files with 197 additions and 76 deletions.
27 changes: 6 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ ELSE()
ENDIF()

IF( APPLE AND NOT CMAKE_OSX_ARCHITECTURES )
SET( CMAKE_OSX_ARCHITECTURES x86_64 ) # Build intel 64-bit binary.
#SET( CMAKE_OSX_ARCHITECTURES i386 x86_64 ) # Build intel binary.
SET( CMAKE_OSX_ARCHITECTURES x86_64 ) # Build intel 64-bit binary.
#SET( CMAKE_OSX_ARCHITECTURES i386 x86_64 ) # Build intel binary.
#SET( CMAKE_OSX_ARCHITECTURES ppc i386 ppc64 x86_64 ) # Build universal binary.
ENDIF()

Expand Down Expand Up @@ -220,23 +220,13 @@ IF( GZIP_CMD )
ADD_CUSTOM_TARGET(changelog ALL DEPENDS ${CHANGELOG})
ENDIF()

#=========================Detect Debian========================================
IF( EXISTS "/etc/debian_version" )
MESSAGE( STATUS "Debian detected..." )

IF( NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" )
MESSAGE( WARNING "Debian system, but CMAKE_INSTALL_PREFIX != /usr" )
MESSAGE( WARNING "CMAKE_INSTALL_PREFIX = \"${CMAKE_INSTALL_PREFIX}\"" )
ENDIF()
ENDIF()

#========================Construct the directories=============================

# Debian standard directories.
IF( NOT EXEC_PREFIX )
SET( EXEC_PREFIX ${CMAKE_INSTALL_PREFIX} )
ENDIF()

SET( DATAROOTDIR "${EXEC_PREFIX}/share" )
SET( BINDIR "${EXEC_PREFIX}/bin" )
IF( NOT DOCDIR )
Expand All @@ -254,7 +244,7 @@ ELSEIF( WIN32 )
#SET( DATAPATH "brewtarget-${brewtarget_VERSION_STRING}" )
#SET( TARGETPATH "brewtarget-${brewtarget_VERSION_STRING}" )
#SET( DOCPATH "brewtarget-${brewtarget_VERSION_STRING}/doc" )

# For some damn reason, for the NSIS installer,
# the prefix needs to be empty. Also, seems that the .exe
# needs to be in bin/. Fucking piece of shit CPack...
Expand Down Expand Up @@ -402,8 +392,6 @@ IF( WIN32 )
GET_TARGET_PROPERTY(QtPrintSupport_location Qt5::PrintSupport LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtSql_location Qt5::Sql LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtSvg_location Qt5::Svg LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtWebKit_location Qt5::WebKit LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtWebKitWidgets_location Qt5::WebKitWidgets LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtWidgets_location Qt5::Widgets LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtXml_location Qt5::Xml LOCATION_${CMAKE_BUILD_TYPE})

Expand All @@ -412,7 +400,6 @@ IF( WIN32 )
GET_TARGET_PROPERTY(QtQgif_location Qt5::QGifPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQico_location Qt5::QICOPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQjpeg_location Qt5::QJpegPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQmng_location Qt5::QMngPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQsvg_location Qt5::QSvgPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQtiff_location Qt5::QTiffPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQWindows_location Qt5::QWindowsIntegrationPlugin LOCATION_${CMAKE_BUILD_TYPE})
Expand Down Expand Up @@ -489,7 +476,7 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
SET(CPACK_SET_DESTDIR "on")
SET(CPACK_PACKAGING_INSTALL_PREFIX "/tmp")
SET(CPACK_SOURCE_GENERATOR "TBZ2;")
SET(CPACK_SOURCE_IGNORE_FILES
SET(CPACK_SOURCE_IGNORE_FILES
"/.svn/"
"~$"
"/CMakeFiles/"
Expand Down Expand Up @@ -553,7 +540,7 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
ELSEIF(WIN32)
# http://www.thegigsite.com/cmake-2.6.0/CMakeCPackOptions.cmake
SET( CPACK_GENERATOR "NSIS" )

SET( CPACK_RESOURCE_FILE_LICENSE "${ROOTDIR}/COPYING.GPLv3" )

SET( CPACK_NSIS_PACKAGE_NAME "Brewtarget-${brewtarget_VERSION_STRING}" )
Expand Down Expand Up @@ -648,5 +635,3 @@ ELSE()
MESSAGE( STATUS "Building Brewtarget." )
ADD_SUBDIRECTORY(${SRCDIR})
ENDIF()


3 changes: 1 addition & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ On Debian systems like Ubuntu, the packages for dependencies are:
* qttools5-dev
* qttools5-dev-tools
* qtmultimedia5-dev
* libqt5webkit5-dev
* libqt5sql5-sqlite
* libqt5sql-psql
* libqt5sql5-psql
* libqt5svg5-dev
* libqt5multimedia5-plugins
* doxygen (optional, for source documentation)
Expand Down
9 changes: 8 additions & 1 deletion src/BrewNoteWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ void BrewNoteWidget::setBrewNote(BrewNote* bNote)
lcdnumber_abv->setLowLim( bNoteObs->projABV_pct() * low);
lcdnumber_abv->setHighLim( bNoteObs->projABV_pct() * high);

lcdnumber_atten->setLowLim( bNoteObs->projAtten() * low );
lcdnumber_atten->setHighLim( bNoteObs->projAtten() * high );

lcdnumber_projAtten->setLowLim( bNoteObs->projAtten() * low );
lcdnumber_projAtten->setHighLim( bNoteObs->projAtten() * high );

showChanges();
}
}
Expand Down Expand Up @@ -299,7 +305,8 @@ void BrewNoteWidget::showChanges(QString field)
lcdnumber_brewhouseEff->display(bNoteObs->brewhouseEff_pct(),2);
lcdnumber_projABV->display(bNoteObs->projABV_pct(),2);
lcdnumber_abv->display(bNoteObs->abv(),2);

lcdnumber_atten->display(bNoteObs->attenuation(),2);
lcdnumber_projAtten->display(bNoteObs->projAtten(),2);
}

void BrewNoteWidget::focusOutEvent(QFocusEvent *e)
Expand Down
6 changes: 3 additions & 3 deletions src/BtTextEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ BtTextEdit::BtTextEdit(QWidget *parent)
wasModified = false;

// We will see if this works...
connect(this, &BtTextEdit::textChanged, this, &BtTextEdit::textChanged);
connect(this, &BtTextEdit::textChanged, this, &BtTextEdit::setTextChanged);

}

Expand All @@ -39,7 +39,7 @@ BtTextEdit::BtTextEdit(const QString &text, QWidget *parent)
wasModified = false;

// We will see if this works...
connect(this, &BtTextEdit::textChanged, this, &BtTextEdit::textChanged);
connect(this, &BtTextEdit::textChanged, this, &BtTextEdit::setTextChanged);

}

Expand All @@ -62,4 +62,4 @@ void BtTextEdit::focusOutEvent(QFocusEvent *e)
}

bool BtTextEdit::isModified() { return wasModified; }
void BtTextEdit::textChanged() { wasModified = true; }
void BtTextEdit::setTextChanged() { wasModified = true; }
2 changes: 1 addition & 1 deletion src/BtTextEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BtTextEdit : public QPlainTextEdit
void setPlainText( const QString& text);

public slots:
void textChanged();
void setTextChanged();

signals:
void textModified();
Expand Down
19 changes: 18 additions & 1 deletion src/DatabaseSchemaHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <QDebug>
#include <QSqlError>

const int DatabaseSchemaHelper::dbVersion = 6;
const int DatabaseSchemaHelper::dbVersion = 7;

// Commands and keywords
QString DatabaseSchemaHelper::CREATETABLE("CREATE TABLE");
Expand Down Expand Up @@ -223,6 +223,7 @@ QString DatabaseSchemaHelper::colMashStepNumber("step_number");
// Brewnotes table
QString DatabaseSchemaHelper::tableBrewnote("brewnote");
QString DatabaseSchemaHelper::colBNoteBrewDate("brewDate");
QString DatabaseSchemaHelper::colBNoteAttenuation("attenuation");
QString DatabaseSchemaHelper::colBNoteFermentDate("fermentDate");
QString DatabaseSchemaHelper::colBNoteSg("sg");
QString DatabaseSchemaHelper::colBNoteBkVolume("volume_into_bk");
Expand Down Expand Up @@ -459,6 +460,9 @@ bool DatabaseSchemaHelper::migrateNext(int oldVersion, QSqlDatabase db)
case 5:
ret &= migrate_to_6(q);
break;
case 6:
ret &= migrate_to_7(q);
break;
default:
Brewtarget::logE(QString("Unknown version %1").arg(oldVersion));
return false;
Expand Down Expand Up @@ -1056,6 +1060,7 @@ bool DatabaseSchemaHelper::create_brewnote(QSqlQuery q)
colBNoteBrewDate + SEP + TYPEDATETIME + SEP + DEFAULT + SEP + THENOW + COMMA +
colBNoteFermentDate + SEP + TYPEDATETIME + SEP + DEFAULT + SEP + THENOW + COMMA +
colBNoteSg + SEP + TYPEREAL + SEP + DEFAULT + SEP + "1.0" + COMMA +
colBNoteAttenuation + SEP + TYPEREAL + SEP + DEFAULT + SEP + "0.0" + COMMA +
colBNoteBkVolume + SEP + TYPEREAL + SEP + DEFAULT + SEP + "0.0" + COMMA +
colBNoteStrikeTemp + SEP + TYPEREAL + SEP + DEFAULT + SEP + "70.0" + COMMA +
colBNoteFinalMashTemp + SEP + TYPEREAL + SEP + DEFAULT + SEP + "67.0" + COMMA +
Expand Down Expand Up @@ -1557,3 +1562,15 @@ bool DatabaseSchemaHelper::migrate_to_6(QSqlQuery q) {

return ret;
}

bool DatabaseSchemaHelper::migrate_to_7(QSqlQuery q) {
bool ret = true;

// Add "attenuation" to brewnote table
ret &= q.exec(
ALTERTABLE + SEP + tableBrewnote + SEP +
ADDCOLUMN + SEP + "attenuation" + SEP + TYPEREAL + SEP + DEFAULT + SEP + "0.0"
);

return ret;
}
3 changes: 2 additions & 1 deletion src/DatabaseSchemaHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class DatabaseSchemaHelper

// Brewnote table
static QString tableBrewnote;
static QString colBNoteAttenuation;
static QString colBNoteBrewDate;
static QString colBNoteFermentDate;
static QString colBNoteSg;
Expand Down Expand Up @@ -428,5 +429,5 @@ class DatabaseSchemaHelper
static bool migrate_to_4(QSqlQuery q);
static bool migrate_to_5(QSqlQuery q);
static bool migrate_to_6(QSqlQuery q);

static bool migrate_to_7(QSqlQuery q);
};
5 changes: 3 additions & 2 deletions src/FermentableSortFilterProxyModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bool FermentableSortFilterProxyModel::lessThan(const QModelIndex &left,
double leftDouble, rightDouble;

Unit* unit = Units::kilograms;
Unit* colorunit = Units::srm;

switch( left.column() )
{
Expand Down Expand Up @@ -67,8 +68,8 @@ bool FermentableSortFilterProxyModel::lessThan(const QModelIndex &left,
else
return leftDouble < rightDouble;
case FERMCOLORCOL:
leftDouble = toDouble(leftFermentable);
rightDouble = toDouble(rightFermentable);
leftDouble = Brewtarget::qStringToSI(leftFermentable.toString(),colorunit);
rightDouble = Brewtarget::qStringToSI(rightFermentable.toString(),colorunit);

if (leftDouble == rightDouble)
return getName(right) < getName(left);
Expand Down
27 changes: 21 additions & 6 deletions src/HydrometerTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
HydrometerTool::HydrometerTool(QWidget* parent) : QDialog(parent)
{
doLayout();

connect( pushButton_convert, &QAbstractButton::clicked, this, &HydrometerTool::convert );
connect(label_inputTemp, &BtLabel::labelChanged, lineEdit_inputTemp, &BtLineEdit::lineChanged);
connect(label_inputSg, &BtLabel::labelChanged, lineEdit_inputSg, &BtLineEdit::lineChanged);
connect(label_outputSg, &BtLabel::labelChanged, lineEdit_outputSg, &BtLineEdit::lineChanged);
connect(label_calibratedTemp, &BtLabel::labelChanged, lineEdit_calibratedTemp, &BtLineEdit::lineChanged);

QMetaObject::connectSlotsByName(this);

Expand All @@ -54,7 +55,6 @@ void HydrometerTool::doLayout()
lineEdit_inputSg->setMinimumSize(QSize(80, 0));
lineEdit_inputSg->setMaximumSize(QSize(80, 16777215));


label_inputTemp = new BtTemperatureLabel(groupBox_inputSg);
label_inputTemp ->setObjectName(QStringLiteral("label_inputTemp"));
label_inputTemp ->setContextMenuPolicy(Qt::CustomContextMenu);
Expand All @@ -64,6 +64,15 @@ void HydrometerTool::doLayout()
lineEdit_inputTemp->setMaximumSize(QSize(80, 16777215));
lineEdit_inputTemp->setObjectName(QStringLiteral("lineEdit_inputTemp"));

label_calibratedTemp = new BtTemperatureLabel(groupBox_inputSg);
label_calibratedTemp ->setObjectName(QStringLiteral("label_calibratedTemp"));
label_calibratedTemp ->setContextMenuPolicy(Qt::CustomContextMenu);

lineEdit_calibratedTemp = new BtTemperatureEdit(groupBox_inputSg);
lineEdit_calibratedTemp->setMinimumSize(QSize(80, 0));
lineEdit_calibratedTemp->setMaximumSize(QSize(80, 16777215));
lineEdit_calibratedTemp->setObjectName(QStringLiteral("lineEdit_calibratedTemp"));
lineEdit_calibratedTemp->setText(15.55555556,1);

label_outputSg = new BtDensityLabel(groupBox_inputSg);
label_outputSg ->setContextMenuPolicy(Qt::CustomContextMenu);
Expand All @@ -76,6 +85,8 @@ void HydrometerTool::doLayout()





#ifndef QT_NO_SHORTCUT
label_inputSg->setBuddy(lineEdit_inputSg);
label_inputTemp->setBuddy(lineEdit_inputTemp);
Expand All @@ -88,9 +99,10 @@ void HydrometerTool::doLayout()
formLayout->setWidget(0, QFormLayout::FieldRole, lineEdit_inputSg);
formLayout->setWidget(1, QFormLayout::LabelRole, label_inputTemp);
formLayout->setWidget(1, QFormLayout::FieldRole, lineEdit_inputTemp);
formLayout->setWidget(2, QFormLayout::LabelRole, label_outputSg);
formLayout->setWidget(2, QFormLayout::FieldRole, lineEdit_outputSg);

formLayout->setWidget(2, QFormLayout::LabelRole, label_calibratedTemp);
formLayout->setWidget(2, QFormLayout::FieldRole, lineEdit_calibratedTemp);
formLayout->setWidget(3, QFormLayout::LabelRole, label_outputSg);
formLayout->setWidget(3, QFormLayout::FieldRole, lineEdit_outputSg);

formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
QVBoxLayout* vLayout = new QVBoxLayout();
Expand Down Expand Up @@ -119,6 +131,7 @@ void HydrometerTool::retranslateUi()
setWindowTitle(tr("Hydrometer Tool"));
label_inputSg->setText(tr("SG Reading")); //TODO translation
label_inputTemp->setText(tr("Temperature")); //TODO translation
label_calibratedTemp->setText(tr("Hydrometer Calibration")); //TODO translation
label_outputSg->setText(tr("Adjust SG")); //TODO translation

pushButton_convert->setText(tr("Convert"));
Expand All @@ -142,10 +155,12 @@ void HydrometerTool::convert()
double cg;
double mg;
double tr;
double tc = 60;
double tc;

tc = lineEdit_calibratedTemp->toSI(); //does not always return C
tr = lineEdit_inputTemp->toSI(); //does not always return C
tr = tr * 1.8 + 32; //formula below uses Fahrenheit
tc = tc * 1.8 + 32; //formula below uses Fahrenheit
mg = lineEdit_inputSg->toSI();

//formula from http://www.straighttothepint.com/hydrometer-temperature-correction/
Expand Down
2 changes: 2 additions & 0 deletions src/HydrometerTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class HydrometerTool : public QDialog

BtTemperatureLabel *label_inputTemp;
BtTemperatureEdit *lineEdit_inputTemp;
BtTemperatureLabel *label_calibratedTemp;
BtTemperatureEdit *lineEdit_calibratedTemp;
QGroupBox *groupBox_inputSg;
//! @}

Expand Down
Loading

0 comments on commit 21c98dd

Please sign in to comment.