mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Print: show column titles for table print
Patch does: - set individual column width and name (held in tableColumnNames, tableColumnWidths) - reduce font size in the table - more small tweaks in the style sheet TODO: finish printing all dive data Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
af1c55c29d
commit
eab31855f5
2 changed files with 65 additions and 8 deletions
|
@ -18,12 +18,30 @@ struct options {
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define TABLE_PRINT_COL 7
|
||||||
|
|
||||||
PrintLayout::PrintLayout(PrintDialog *dialogPtr, QPrinter *printerPtr, struct options *optionsPtr)
|
PrintLayout::PrintLayout(PrintDialog *dialogPtr, QPrinter *printerPtr, struct options *optionsPtr)
|
||||||
{
|
{
|
||||||
dialog = dialogPtr;
|
dialog = dialogPtr;
|
||||||
printer = printerPtr;
|
printer = printerPtr;
|
||||||
printOptions = optionsPtr;
|
printOptions = optionsPtr;
|
||||||
// painter = new QPainter(printer);
|
// painter = new QPainter(printer);
|
||||||
|
|
||||||
|
// table print settings
|
||||||
|
tableColumnNames.append(tr("Dive#"));
|
||||||
|
tableColumnNames.append(tr("Date"));
|
||||||
|
tableColumnNames.append(tr("Depth"));
|
||||||
|
tableColumnNames.append(tr("Duration"));
|
||||||
|
tableColumnNames.append(tr("Master"));
|
||||||
|
tableColumnNames.append(tr("Buddy"));
|
||||||
|
tableColumnNames.append(tr("Location"));
|
||||||
|
tableColumnWidths.append("7");
|
||||||
|
tableColumnWidths.append("10");
|
||||||
|
tableColumnWidths.append("10");
|
||||||
|
tableColumnWidths.append("10");
|
||||||
|
tableColumnWidths.append("15");
|
||||||
|
tableColumnWidths.append("15");
|
||||||
|
tableColumnWidths.append("100");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintLayout::print()
|
void PrintLayout::print()
|
||||||
|
@ -84,16 +102,16 @@ void PrintLayout::printTable()
|
||||||
"table {" \
|
"table {" \
|
||||||
" border-width: 1px;" \
|
" border-width: 1px;" \
|
||||||
" border-style: solid;" \
|
" border-style: solid;" \
|
||||||
" border-color: black;" \
|
" border-color: #999999;" \
|
||||||
"}" \
|
"}" \
|
||||||
"th {" \
|
"th {" \
|
||||||
" background-color: #eeeeee;" \
|
" background-color: #eeeeee;" \
|
||||||
" font-weight: bold;" \
|
" font-size: small;" \
|
||||||
" font-size: large;" \
|
" padding: 3px 5px 3px 5px;" \
|
||||||
" padding: 6px 10px 6px 10px;" \
|
|
||||||
"}" \
|
"}" \
|
||||||
"td {" \
|
"td {" \
|
||||||
" padding: 3px 10px 3px 10px;" \
|
" font-size: small;" \
|
||||||
|
" padding: 3px 5px 3px 5px;" \
|
||||||
"}" \
|
"}" \
|
||||||
"</style>"
|
"</style>"
|
||||||
);
|
);
|
||||||
|
@ -132,10 +150,44 @@ void PrintLayout::printTable()
|
||||||
|
|
||||||
QString PrintLayout::insertTableHeadingRow()
|
QString PrintLayout::insertTableHeadingRow()
|
||||||
{
|
{
|
||||||
return "<tr><th align='left'>TITLE</th><th align='left'>TITLE 2</th></tr>";
|
int i;
|
||||||
|
QString ret("<tr>");
|
||||||
|
for (i = 0; i < TABLE_PRINT_COL; i++)
|
||||||
|
ret += insertTableHeadingCol(i);
|
||||||
|
ret += "</tr>";
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PrintLayout::insertTableHeadingCol(int col)
|
||||||
|
{
|
||||||
|
QString ret("<th align='left' width='");
|
||||||
|
ret += tableColumnWidths.at(col);
|
||||||
|
ret += "%'>";
|
||||||
|
ret += tableColumnNames.at(col);
|
||||||
|
ret += "</th>";
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PrintLayout::insertTableDataRow(struct dive *dive)
|
QString PrintLayout::insertTableDataRow(struct dive *dive)
|
||||||
{
|
{
|
||||||
return "<tr><td>" + QString::number(dive->number) + "</td><td>hello2</td></tr>";
|
/*
|
||||||
|
// TODO date format
|
||||||
|
// struct tm tm;
|
||||||
|
len = snprintf(buffer, sizeof(buffer),
|
||||||
|
_("%1$s, %2$s %3$d, %4$d %5$dh%6$02d"),
|
||||||
|
weekday(tm.tm_wday),
|
||||||
|
monthname(tm.tm_mon),
|
||||||
|
tm.tm_mday, tm.tm_year + 1900,
|
||||||
|
tm.tm_hour, tm.tm_min
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
QString ret("<tr>");
|
||||||
|
ret += insertTableDataCol(QString::number(dive->number));
|
||||||
|
ret += "</tr>";
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PrintLayout::insertTableDataCol(QString data)
|
||||||
|
{
|
||||||
|
return "<td>" + data + "</td>";
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,17 @@ private:
|
||||||
qreal scaleX, scaleY;
|
qreal scaleX, scaleY;
|
||||||
QRect pageRect;
|
QRect pageRect;
|
||||||
|
|
||||||
|
QStringList tableColumnNames;
|
||||||
|
QStringList tableColumnWidths;
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
void printSixDives();
|
void printSixDives();
|
||||||
void printTwoDives();
|
void printTwoDives();
|
||||||
void printTable();
|
void printTable();
|
||||||
QString insertTableHeadingRow();
|
QString insertTableHeadingRow();
|
||||||
QString insertTableDataRow(struct dive *dive);
|
QString insertTableHeadingCol(int);
|
||||||
|
QString insertTableDataRow(struct dive *);
|
||||||
|
QString insertTableDataCol(QString);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue