From 08cf1be2123e38541e83eb159a3580e2354c4c47 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Wed, 4 Dec 2013 15:13:40 +0200 Subject: PrintLayout: add estimateTotalDives() estimateTotalDives() is used to calculate the total dives to be printed, it requires a 'struct dive' pointer and a couple of 'int' pointers for the iterator 'i' and 'total' return. Signed-off-by: Lubomir I. Ivanov --- qt-ui/printlayout.cpp | 11 +++++++++++ qt-ui/printlayout.h | 4 ++++ 2 files changed, 15 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index afc6dd036..7e5e57533 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -91,6 +91,17 @@ void PrintLayout::setup() scaledPageH = pageRect.height() / scaleY; } +// go trought the dive table and find how many dives we are a going to print +void PrintLayout::estimateTotalDives(struct dive *dive, int *i, int *total) const +{ + *total = 0; + for_each_dive(*i, dive) { + if (!dive->selected && printOptions->print_selected) + continue; + (*total)++; + } +} + /* the used formula here is: * s = (S - (n - 1) * p) / n * where: diff --git a/qt-ui/printlayout.h b/qt-ui/printlayout.h index 1ed19e271..f21940a83 100644 --- a/qt-ui/printlayout.h +++ b/qt-ui/printlayout.h @@ -34,11 +34,15 @@ private: QList profilePrintColumnWidths, profilePrintRowHeights; void setup(); + void estimateTotalDives(struct dive *dive, int *i, int *total) const; void printProfileDives(int divesPerRow, int divesPerColumn); QTableView *createProfileTable(ProfilePrintModel *model, const int tableW); void printTable(); void addTablePrintDataRow(TablePrintModel *model, int row, struct dive *dive) const; void addTablePrintHeadingRow(TablePrintModel *model, int row) const; + +signals: + void signalProgress(int); }; #endif -- cgit v1.2.3-70-g09d2