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 <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2013-12-04 15:13:40 +02:00
parent ecf483db46
commit 08cf1be212
2 changed files with 15 additions and 0 deletions

View file

@ -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:

View file

@ -34,11 +34,15 @@ private:
QList<unsigned int> 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