summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-12-04 15:18:56 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-12-04 15:35:07 +0200
commit95e00b0acd28117bbc3aded76f8079c08449bc17 (patch)
treebaa599be1ae671ccdcd64a9727822e0e88301e66 /qt-ui
parentac7126b84a3bc573342abcc2e042ba58f8e1f0cd (diff)
downloadsubsurface-95e00b0acd28117bbc3aded76f8079c08449bc17.tar.gz
PrintLayout: emit progress from printTable()
printTable() now emits a 'signalProgress' to the PrintDialog's progress bar, but it has 3 stages (loops): - pupulate a model - process all rows - render the table in pages This requires that we also separate the progress in 3 stages of 33%. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/printlayout.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
index 3e7408702..aa703698a 100644
--- a/qt-ui/printlayout.cpp
+++ b/qt-ui/printlayout.cpp
@@ -270,6 +270,13 @@ QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int
void PrintLayout::printTable()
{
+ struct dive *dive;
+ const int stage = 33; // there are 3 stages in this routine: 100% / 3 ~= 33%
+ int i, row = 0, total, progress;
+ estimateTotalDives(dive, &i, &total);
+ if (!total)
+ return;
+
// create and setup a table
QTableView table;
table.setAttribute(Qt::WA_DontShowOnScreen);
@@ -291,15 +298,16 @@ void PrintLayout::printTable()
// create and fill a table model
TablePrintModel model;
- struct dive *dive;
- int i, row = 0;
addTablePrintHeadingRow(&model, row); // add one heading row
row++;
+ progress = 0;
for_each_dive(i, dive) {
if (!dive->selected && printOptions->print_selected)
continue;
addTablePrintDataRow(&model, row, dive);
row++;
+ progress++;
+ emit signalProgress((progress * stage) / total);
}
table.setModel(&model); // set model to table
// resize columns to percentages from page width
@@ -322,7 +330,9 @@ void PrintLayout::printTable()
int tableHeight = 0, rowH = 0, accH = 0;
// process all rows
- for (int i = 0; i < model.rows; i++) {
+ progress = 0;
+ total = model.rows;
+ for (int i = 0; i < total; i++) {
rowH = table.rowHeight(i);
accH += rowH;
if (accH > scaledPageH) { // push a new page index and add a heading
@@ -332,6 +342,8 @@ void PrintLayout::printTable()
i--;
}
tableHeight += rowH;
+ progress++;
+ emit signalProgress(stage + (progress * stage) / total);
}
pageIndexes.append(pageIndexes.last() + accH);
// resize the whole widget so that it can be rendered
@@ -342,13 +354,17 @@ void PrintLayout::printTable()
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
painter.scale(scaleX, scaleY);
- for (int i = 0; i < pageIndexes.size() - 1; i++) {
+ total = pageIndexes.size() - 1;
+ progress = 0;
+ for (int i = 0; i < total; i++) {
if (i > 0)
printer->newPage();
QRegion region(0, pageIndexes.at(i) - 1,
table.width(),
pageIndexes.at(i + 1) - pageIndexes.at(i) + 1);
table.render(&painter, QPoint(0, 0), region);
+ progress++;
+ emit signalProgress((stage << 1) + (progress * (stage + 1)) / total);
}
}