Example #1
0
// mash step methods:
int Mash::setStepType(int i, QString t){
    if (steps.size() < i || steps.empty())
        return -1;
    MashStep *ms = &steps[i];
    ms->setType(t);
    ms->setStartTemp(calcStepTemp(t));
    ms->setEndTemp(calcStepTemp(t));
    return 0;
}
Example #2
0
void Mash::setStepStartTempF(int i, double t){
    if (tempUnits == "C"){
        t = BrewCalcs::cToF(t);
    }
    MashStep *ms = &steps[i];
    ms->setStartTemp(t);
    double tLoss = getTunLoss() * (ms->getMinutes()/60);
    ms->setEndTemp(t - tLoss);
    ms->setType(calcStepType(t));

    calcMashSchedule();
}
Example #3
0
int Mash::addStep(){
    MashStep step;
    // calcStepType(temp);
    if (!steps.empty()) {
        MashStep *lastStep = &steps[steps.size() -1];
        step.setStartTemp(lastStep->getEndTemp() + 1);
        step.setEndTemp(step.getStartTemp());
        step.setType(calcStepType(step.getStartTemp()));
    }

    steps.append(step);
    int i = steps.size();
    calcMashSchedule();
    // return the index of the last added step:
    return i-1;

}
bool MashStepTableModel::setData( const QModelIndex& index, const QVariant& value, int role )
{
   MashStep *row;
   unitDisplay unit;

   if( mashObs == 0 )
      return false;

   if( index.row() >= (int)(steps.size()) || role != Qt::EditRole )
      return false;
   else
      row = steps[index.row()];

   switch( index.column() )
   {
      case MASHSTEPNAMECOL:
         if( value.canConvert(QVariant::String))
         {
            row->setName(value.toString());
            return true;
         }
         else
            return false;
      case MASHSTEPTYPECOL:
         if( value.canConvert(QVariant::Int) )
         {
            row->setType(static_cast<MashStep::Type>(value.toInt()));
            return true;
         }
         else
            return false;
      case MASHSTEPAMOUNTCOL:
         if( value.canConvert(QVariant::String) )
         {
            unit = displayUnit(MASHSTEPAMOUNTCOL);
            if( row->type() == MashStep::Decoction )
               row->setDecoctionAmount_l( Brewtarget::qStringToSI(value.toString(),Units::liters,unit) );
            else
               row->setInfuseAmount_l( Brewtarget::qStringToSI(value.toString(),Units::liters,unit) );
            return true;
         }
         else
            return false;
      case MASHSTEPTEMPCOL:
         if( value.canConvert(QVariant::String) && row->type() != MashStep::Decoction )
         {
            unit = displayUnit(MASHSTEPTEMPCOL);
            row->setInfuseTemp_c( Brewtarget::qStringToSI(value.toString(),Units::celsius,unit) );
            return true;
         }
         else
            return false;
      case MASHSTEPTARGETTEMPCOL:
         if( value.canConvert(QVariant::String) )
         {
            unit = displayUnit(MASHSTEPTARGETTEMPCOL);
            row->setStepTemp_c( Brewtarget::qStringToSI(value.toString(),Units::celsius,unit) );
            row->setEndTemp_c( Brewtarget::qStringToSI(value.toString(),Units::celsius,unit) );
            return true;
         }
         else
            return false;
      case MASHSTEPTIMECOL:
         if( value.canConvert(QVariant::String) )
         {
            row->setStepTime_min( Brewtarget::qStringToSI(value.toString(),Units::minutes) );
            return true;
         }
         else
            return false;
      default:
         return false;
   }
}