summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-07-11 00:48:38 +0300
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-07-11 00:52:39 +0300
commiteab31855f51623d1e816f557792860fb10430be8 (patch)
treefa0699372a356beced55317cb151c9ae2791ef9a /qt-ui
parentaf1c55c29d55ff697b2a20440c7177fd7e364655 (diff)
downloadsubsurface-eab31855f51623d1e816f557792860fb10430be8.tar.gz
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>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/printlayout.cpp66
-rw-r--r--qt-ui/printlayout.h7
2 files changed, 65 insertions, 8 deletions
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;" \
"}" \
"</style>"
);
@@ -132,10 +150,44 @@ void PrintLayout::printTable()
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)
{
- 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>";
}
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