From eab31855f51623d1e816f557792860fb10430be8 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Thu, 11 Jul 2013 00:48:38 +0300 Subject: 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 --- qt-ui/printlayout.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++------ qt-ui/printlayout.h | 7 +++++- 2 files changed, 65 insertions(+), 8 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index af68383dd..6321caff2 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -18,12 +18,30 @@ struct options { }; */ +#define TABLE_PRINT_COL 7 + PrintLayout::PrintLayout(PrintDialog *dialogPtr, QPrinter *printerPtr, struct options *optionsPtr) { dialog = dialogPtr; printer = printerPtr; printOptions = optionsPtr; // 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() @@ -84,16 +102,16 @@ void PrintLayout::printTable() "table {" \ " border-width: 1px;" \ " border-style: solid;" \ - " border-color: black;" \ + " border-color: #999999;" \ "}" \ "th {" \ " background-color: #eeeeee;" \ - " font-weight: bold;" \ - " font-size: large;" \ - " padding: 6px 10px 6px 10px;" \ + " font-size: small;" \ + " padding: 3px 5px 3px 5px;" \ "}" \ "td {" \ - " padding: 3px 10px 3px 10px;" \ + " font-size: small;" \ + " padding: 3px 5px 3px 5px;" \ "}" \ "" ); @@ -132,10 +150,44 @@ void PrintLayout::printTable() QString PrintLayout::insertTableHeadingRow() { - return "TITLETITLE 2"; + int i; + QString ret(""); + for (i = 0; i < TABLE_PRINT_COL; i++) + ret += insertTableHeadingCol(i); + ret += ""; + return ret; +} + +QString PrintLayout::insertTableHeadingCol(int col) +{ + QString ret(""; + ret += tableColumnNames.at(col); + ret += ""; + return ret; } QString PrintLayout::insertTableDataRow(struct dive *dive) { - return "" + QString::number(dive->number) + "hello2"; + /* + // 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(""); + ret += insertTableDataCol(QString::number(dive->number)); + ret += ""; + return ret; +} + +QString PrintLayout::insertTableDataCol(QString data) +{ + return "" + data + ""; } diff --git a/qt-ui/printlayout.h b/qt-ui/printlayout.h index bf34892bf..c55778dd8 100644 --- a/qt-ui/printlayout.h +++ b/qt-ui/printlayout.h @@ -23,12 +23,17 @@ private: qreal scaleX, scaleY; QRect pageRect; + QStringList tableColumnNames; + QStringList tableColumnWidths; + void setup(); void printSixDives(); void printTwoDives(); void printTable(); QString insertTableHeadingRow(); - QString insertTableDataRow(struct dive *dive); + QString insertTableHeadingCol(int); + QString insertTableDataRow(struct dive *); + QString insertTableDataCol(QString); }; #endif -- cgit v1.2.3-70-g09d2