39
44
connect( pushButton_remove, SIGNAL(clicked()), this, SLOT(removeSelectedInstruction()) );
40
45
connect( pushButton_up, SIGNAL(clicked()), this, SLOT(pushInstructionUp()) );
41
46
connect( pushButton_down, SIGNAL(clicked()), this, SLOT(pushInstructionDown()) );
47
connect( pushButton_print, SIGNAL(clicked()), this, SLOT(pushInstructionPrint()) );
49
/* Instantiate the Webview and then connect its signal */
51
connect( doc, SIGNAL(loadFinished(bool)), this, SLOT(loadComplete(bool)) );
53
printer = new QPrinter;
54
printer->setPageSize(QPrinter::Letter);
44
57
QSize BrewDayWidget::sizeHint() const
83
96
listWidget->setCurrentRow(row+1);
99
QString BrewDayWidget::getCSS()
101
QFile cssInput(":/css/brewday.css");
104
if (cssInput.open(QFile::ReadOnly)) {
105
QTextStream inStream(&cssInput);
106
while ( ! inStream.atEnd() )
108
css += inStream.readLine();
114
QString BrewDayWidget::buildTitleTable()
119
// Do the style sheet first
120
header = "<html><head><style type=\"text/css\">";
122
header += "</style></head>";
125
body += tr("<h1>%1</h1>").arg(recObs->getName().c_str());
126
body += tr("<img src=\"%1\" />").arg("qrc:/images/title.svg");
128
// Build the top table
129
// Build the first row: Style and Date
130
body += "<table id=\"title\">";
131
body += tr("<tr><td class=\"left\">Style</td>");
132
body += tr("<td class=\"value\">%1</td>")
133
.arg(recObs->getStyle()->getName().c_str());
134
body += tr("<td class=\"right\">Date</td>");
135
body += tr("<td class=\"value\">%1</td></tr>")
136
.arg(QDate::currentDate().toString());
138
body += tr("<tr><td class=\"left\">Boil Volume</td><td class=\"value\">%1</td><td class=\"right\">Preboil Gravity</td><td class=\"value\">%2</td></tr>")
139
.arg(Brewtarget::displayAmount(recObs->getBatchSize_l(), Units::liters))
140
.arg(Brewtarget::displayOG(recObs->getBoilGrav()));
142
body += tr("<tr><td class=\"left\">Final Volume</td><td class=\"value\">%1</td><td class=\"right\">Final Gravity</td><td class=\"value\">%2</td></tr>")
143
.arg(Brewtarget::displayAmount(recObs->getBoilSize_l(),Units::liters))
144
.arg(Brewtarget::displayOG(recObs->getOg()));
146
body += tr("<tr><td class=\"left\">Boil Time</td><td class=\"value\">%1</td><td class=\"right\">IBU</td><td class=\"value\">%2</td></tr>")
147
.arg(Brewtarget::displayAmount(recObs->getBoilTime_min(),Units::minutes))
148
.arg(recObs->getIBU(),0,'f',1);
150
body += tr("<tr><td class=\"left\">Predicted Efficiency</td><td class=\"value\">%1</td></tr>")
151
.arg(Brewtarget::displayAmount(recObs->getEfficiency_pct(),0));
155
return header + body;
159
bool BrewDayWidget::loadComplete(bool ok)
165
void BrewDayWidget::pushInstructionPrint()
171
QPrintDialog *dialog = new QPrintDialog(printer, this);
172
dialog->setWindowTitle(tr("Print Document"));
173
if (dialog->exec() != QDialog::Accepted)
179
// Start building the document to be printed. I think.
180
size = recObs->getNumInstructions();
181
pDoc = buildTitleTable();
183
// Start the instructions header
184
pDoc += "<h2>Instructions</h2>";
185
pDoc += "<table id=\"steps\">";
186
pDoc += tr("<tr><th class=\"check\">Completed</th><th class=\"time\">Time</th><th class=\"step\">Step</th></tr>");
187
for( i = 0; i < size; ++i )
189
QString stepTime, tmp;
190
QVector<QString> reagents;
192
if (recObs->getInstruction(i)->getInterval())
193
stepTime = Brewtarget::displayAmount(recObs->getInstruction(i)->getInterval(), Units::minutes, 0);
198
reagents = recObs->getInstruction(i)->getReagents();
199
if ( reagents.size() > 1 ) {
201
for ( j = 0; j < reagents.size(); j++ )
203
tmp += tr("<li>%1</li>")
212
QString altTag = i % 2 ? "alt" : "norm";
214
pDoc += tr("<tr class=\"%1\"><td class=\"check\"></td><td class=\"time\">%2</td><td align=\"step\">%3 : %4</td></tr>")
217
.arg(recObs->getInstruction(i)->getName())
220
pDoc += "</table></body></html>";
86
225
void BrewDayWidget::setRecipe(Recipe* rec)