summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/csvimportdialog.cpp2
-rw-r--r--qt-ui/divelistview.cpp3
-rw-r--r--qt-ui/diveplanner.cpp18
-rw-r--r--qt-ui/diveplanner.h2
-rw-r--r--qt-ui/diveplanner.ui11
-rw-r--r--qt-ui/globe.cpp15
-rw-r--r--qt-ui/maintab.cpp59
-rw-r--r--qt-ui/mainwindow.cpp5
-rw-r--r--qt-ui/preferences.cpp18
-rw-r--r--qt-ui/preferences.h3
-rw-r--r--qt-ui/preferences.ui18
-rw-r--r--qt-ui/printdialog.cpp51
-rw-r--r--qt-ui/printdialog.h9
-rw-r--r--qt-ui/printlayout.cpp48
-rw-r--r--qt-ui/printlayout.h4
-rw-r--r--qt-ui/profilegraphics.cpp11
16 files changed, 209 insertions, 68 deletions
diff --git a/qt-ui/csvimportdialog.cpp b/qt-ui/csvimportdialog.cpp
index 91b9ddd40..b3392f421 100644
--- a/qt-ui/csvimportdialog.cpp
+++ b/qt-ui/csvimportdialog.cpp
@@ -22,6 +22,7 @@ CSVImportDialog::CSVImportDialog(QWidget *parent) :
ui->knownImports->addItem(CSVApps[i].name);
ui->CSVSeparator->addItem("Tab");
+ ui->CSVSeparator->addItem(",");
ui->knownImports->setCurrentIndex(1);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
@@ -52,6 +53,7 @@ void CSVImportDialog::on_buttonBox_accepted()
VALUE_IF_CHECKED(CSVpo2),
VALUE_IF_CHECKED(CSVcns),
VALUE_IF_CHECKED(CSVstopdepth),
+ ui->CSVSeparator->currentIndex(),
&error);
if (error != NULL) {
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 27027c84b..dc1420f64 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -391,10 +391,9 @@ void DiveListView::reloadHeaderActions()
}
s.endGroup();
} else {
- // Skip first QAction item ( static text Visible )
for(int i = 0; i < model()->columnCount(); i++) {
QString title = QString("%1").arg(model()->headerData(i, Qt::Horizontal).toString());
- header()->actions()[i+1]->setText( title );
+ header()->actions()[i]->setText(title);
}
}
}
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index a80ae68ae..5efb7aaed 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -438,7 +438,7 @@ void DivePlannerPointsModel::loadFromDive(dive* d)
// we start with the first gas and see if it was changed
int o2 = backupDive.cylinder[0].gasmix.o2.permille;
int he = backupDive.cylinder[0].gasmix.he.permille;
- for (int i = 0; i < backupDive.dc.samples; i++) {
+ for (int i = 0; i < backupDive.dc.samples - 1; i++) {
const sample &s = backupDive.dc.sample[i];
if (s.time.seconds == 0)
continue;
@@ -1176,17 +1176,17 @@ bool DivePlannerPointsModel::addGas(int o2, int he)
return false;
}
-int DivePlannerPointsModel::addStop(int milimeters, int minutes, int o2, int he, int ccpoint)
+int DivePlannerPointsModel::addStop(int milimeters, int seconds, int o2, int he, int ccpoint)
{
int row = divepoints.count();
- if (minutes == 0 && milimeters == 0 && row != 0){
+ if (seconds == 0 && milimeters == 0 && row != 0){
/* this is only possible if the user clicked on the 'plus' sign on the DivePoints Table */
struct divedatapoint& t = divepoints.last();
milimeters = t.depth;
- minutes = t.time + 600; // 10 minutes.
- } else if (minutes == 0 && milimeters == 0 && row == 0) {
+ seconds = t.time + 600; // 10 minutes.
+ } else if (seconds == 0 && milimeters == 0 && row == 0) {
milimeters = M_OR_FT(5, 15); // 5m / 15ft
- minutes = 600; // 10 min
+ seconds = 600; // 10 min
}
if (o2 != -1)
if (!addGas(o2, he))
@@ -1195,14 +1195,14 @@ int DivePlannerPointsModel::addStop(int milimeters, int minutes, int o2, int he,
// check if there's already a new stop before this one:
for (int i = 0; i < row; i++) {
const divedatapoint& dp = divepoints.at(i);
- if (dp.time == minutes) {
+ if (dp.time == seconds) {
row = i;
beginRemoveRows(QModelIndex(), row, row);
divepoints.remove(row);
endRemoveRows();
break;
}
- if (dp.time > minutes ) {
+ if (dp.time > seconds ) {
row = i;
break;
}
@@ -1230,7 +1230,7 @@ int DivePlannerPointsModel::addStop(int milimeters, int minutes, int o2, int he,
beginInsertRows(QModelIndex(), row, row);
divedatapoint point;
point.depth = milimeters;
- point.time = minutes;
+ point.time = seconds;
point.o2 = o2;
point.he = he;
point.po2 = ccpoint;
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index bc6f696ad..b5c78a93c 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -46,7 +46,7 @@ public:
QList<QPair<int, int> > collectGases(dive *d);
public slots:
- int addStop(int meters = 0, int minutes = 0, int o2 = 0, int he = 0, int ccpoint = 0 );
+ int addStop(int millimeters = 0, int seconds = 0, int o2 = 0, int he = 0, int ccpoint = 0 );
void addCylinder_clicked();
void setGFHigh(const int gfhigh);
void setGFLow(const int ghflow);
diff --git a/qt-ui/diveplanner.ui b/qt-ui/diveplanner.ui
index 55208abb3..558be069d 100644
--- a/qt-ui/diveplanner.ui
+++ b/qt-ui/diveplanner.ui
@@ -101,25 +101,22 @@
</item>
<item row="5" column="0">
<widget class="QSpinBox" name="gflow">
- <property name="suffix">
- <string>%</string>
- </property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
- <number>100</number>
+ <number>150</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="gfhigh">
- <property name="suffix">
- <string>%</string>
- </property>
<property name="minimum">
<number>1</number>
</property>
+ <property name="maximum">
+ <number>150</number>
+ </property>
</widget>
</item>
<item row="6" column="0">
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index 10ce7058b..e0f94bbd5 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -197,23 +197,21 @@ void GlobeGPS::reload()
{
editingDiveLocation = false;
if (messageWidget->isVisible())
- messageWidget->animatedHide();
+ messageWidget->hide();
repopulateLabels();
}
void GlobeGPS::centerOn(dive* dive)
{
// dive has changed, if we had the 'editingDive', hide it.
- if (messageWidget->isVisible() && (!dive || dive_has_gps_location(dive))) {
- messageWidget->animatedHide();
- }
+ if (messageWidget->isVisible() && (!dive || dive_has_gps_location(dive)))
+ messageWidget->hide();
if (!dive)
return;
-
qreal longitude = dive->longitude.udeg / 1000000.0;
qreal latitude = dive->latitude.udeg / 1000000.0;
- if (!longitude || !latitude) {
+ if (!longitude || !latitude || mainWindow()->information()->isEditing()) {
prepareForGetDiveCoordinates();
return;
}
@@ -241,7 +239,7 @@ void GlobeGPS::prepareForGetDiveCoordinates()
{
if (!messageWidget->isVisible()) {
messageWidget->setMessageType(KMessageWidget::Warning);
- messageWidget->setText(QObject::tr("No location data - move the map and double-click to set the dive location"));
+ messageWidget->setText(QObject::tr("Move the map and double-click to set the dive location"));
messageWidget->setWordWrap(true);
messageWidget->animatedShow();
editingDiveLocation = true;
@@ -250,6 +248,8 @@ void GlobeGPS::prepareForGetDiveCoordinates()
void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
{
+ messageWidget->hide();
+
if (mainWindow()->dive_list()->selectionModel()->selection().isEmpty())
return;
@@ -271,7 +271,6 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U
centerOn(lon, lat, true);
editingDiveLocation = false;
mark_divelist_changed(TRUE);
- messageWidget->animatedHide();
mainWindow()->refreshDisplay();
}
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index dad1e8ec6..81c8a0724 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -108,6 +108,27 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
ui.scrollArea_2->viewport()->setPalette(p);
ui.scrollArea_3->viewport()->setPalette(p);
ui.scrollArea_4->viewport()->setPalette(p);
+
+ // GroupBoxes in Gnome3 looks like I'v drawn them...
+ static const QString gnomeCss(
+ "QGroupBox {"
+ " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
+ " stop: 0 #E0E0E0, stop: 1 #FFFFFF);"
+ " border: 2px solid gray;"
+ " border-radius: 5px;"
+ " margin-top: 1ex;"
+ "}"
+ "QGroupBox::title {"
+ " subcontrol-origin: margin;"
+ " subcontrol-position: top center;"
+ " padding: 0 3px;"
+ " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
+ " stop: 0 #0E0E0, stop: 1 #FFFFFF);"
+ "}");
+ Q_FOREACH(QGroupBox *box, findChildren<QGroupBox*>()){
+ box->setStyleSheet(gnomeCss);
+ }
+
}
ui.cylinders->view()->horizontalHeader()->setContextMenuPolicy(Qt::ActionsContextMenu);
@@ -602,11 +623,6 @@ void MainTab::acceptChanges()
else if (selected_dive == dive_table.nr - 1 && get_dive(dive_table.nr - 2)->number)
current_dive->number = get_dive(dive_table.nr - 2)->number + 1;
DivePlannerPointsModel::instance()->cancelPlan();
- // now make sure the selection logic is in a sane state
- // it's ok to hold on to the dive pointer for this short stretch of code
- // unselectDives() doesn't mess with the dive_table at all
- mainWindow()->dive_list()->unselectDives();
- mainWindow()->dive_list()->selectDive(selected_dive, true, true);
mainWindow()->showProfile();
mark_divelist_changed(TRUE);
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
@@ -614,19 +630,32 @@ void MainTab::acceptChanges()
// each dive that was selected might have had the temperatures in its active divecomputer changed
// so re-populate the temperatures - easiest way to do this is by calling fixup_dive
Q_FOREACH(dive *d, notesBackup.keys()) {
- fixup_dive(d);
+ if (d)
+ fixup_dive(d);
}
- editMode = NONE;
-
resetPallete();
- // now comes the scary moment... we need to re-sort dive table in case this dive wasn't the last
- // so now all pointers become invalid
- // fingers crossed that we aren't holding on to anything here
- mainWindow()->dive_list()->rememberSelection();
- sort_table(&dive_table);
- mainWindow()->refreshDisplay();
- mainWindow()->dive_list()->restoreSelection();
+ if(editMode == ADD || editMode == MANUALLY_ADDED_DIVE){
+ mainWindow()->dive_list()->unselectDives();
+ struct dive *d = get_dive(dive_table.nr -1 );
+ // HACK. this shouldn't be here. but apparently it's
+ // how we can know what was the newly added dive.
+ d->selected = true;
+ sort_table(&dive_table);
+ int i = 0;
+ for_each_dive(i,d){
+ if (d->selected) break;
+ }
+ editMode = NONE;
+ mainWindow()->refreshDisplay();
+ mainWindow()->dive_list()->selectDive( i, true );
+ }else{
+ editMode = NONE;
+ mainWindow()->dive_list()->rememberSelection();
+ sort_table(&dive_table);
+ mainWindow()->refreshDisplay();
+ mainWindow()->dive_list()->restoreSelection();
+ }
}
void MainTab::resetPallete()
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index b216240fa..e049179e8 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -295,6 +295,9 @@ void MainWindow::on_actionAddDive_triggered()
struct dive *dive = alloc_dive();
dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset();
dive->dc.model = "manually added dive"; // don't translate! this is stored in the XML file
+
+ dive->latitude.udeg = 0;
+ dive->longitude.udeg = 0;
record_dive(dive);
// this isn't in the UI yet, so let's call the C helper function - we'll fix this up when
// accepting the dive
@@ -306,7 +309,7 @@ void MainWindow::on_actionAddDive_triggered()
ui.infoPane->setCurrentIndex(MAINTAB);
DivePlannerPointsModel::instance()->clear();
DivePlannerPointsModel::instance()->createSimpleDive();
- refreshDisplay();
+ ui.ListWidget->reload(DiveTripModel::CURRENT);
}
void MainWindow::on_actionRenumber_triggered()
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 5a1a2a5e2..f8b24da42 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -15,10 +15,28 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial
{
ui.setupUi(this);
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
+ connect(ui.gflow, SIGNAL(valueChanged(int)), this, SLOT(gflowChanged(int)));
+ connect(ui.gfhigh, SIGNAL(valueChanged(int)), this, SLOT(gfhighChanged(int)));
setUiFromPrefs();
rememberPrefs();
}
+void PreferencesDialog::gflowChanged(int gf)
+{
+ if (gf > 100)
+ ui.gflow->setStyleSheet("* { color: red; }");
+ else
+ ui.gflow->setStyleSheet("");
+}
+
+void PreferencesDialog::gfhighChanged(int gf)
+{
+ if (gf > 100)
+ ui.gfhigh->setStyleSheet("* { color: red; }");
+ else
+ ui.gfhigh->setStyleSheet("");
+}
+
void PreferencesDialog::showEvent(QShowEvent *event)
{
setUiFromPrefs();
diff --git a/qt-ui/preferences.h b/qt-ui/preferences.h
index fb0fcbc94..dbc17cb9f 100644
--- a/qt-ui/preferences.h
+++ b/qt-ui/preferences.h
@@ -22,6 +22,9 @@ public slots:
void syncSettings();
void restorePrefs();
void rememberPrefs();
+ void gflowChanged(int gf);
+ void gfhighChanged(int gf);
+
private:
explicit PreferencesDialog(QWidget* parent = 0, Qt::WindowFlags f = 0);
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index e80cc8493..7b6f3e596 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -779,7 +779,14 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="QSpinBox" name="gflow"/>
+ <widget class="QSpinBox" name="gflow">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>150</number>
+ </property>
+ </widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_20">
@@ -789,7 +796,14 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="QSpinBox" name="gfhigh"/>
+ <widget class="QSpinBox" name="gfhigh">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>150</number>
+ </property>
+ </widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="gf_low_at_maxdepth">
diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp
index 8bf602c34..e029ff09b 100644
--- a/qt-ui/printdialog.cpp
+++ b/qt-ui/printdialog.cpp
@@ -1,10 +1,15 @@
#include "printdialog.h"
+#include "printoptions.h"
+#include "printlayout.h"
#include "mainwindow.h"
#include <QDebug>
#include <QPushButton>
+#include <QProgressBar>
#include <QVBoxLayout>
+#include <QHBoxLayout>
#include <QPrintPreviewDialog>
+#include <QPrintDialog>
PrintDialog *PrintDialog::instance()
{
@@ -22,34 +27,64 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f)
// create a print layout and pass the printer and options
printLayout = new PrintLayout(this, &printer, &printOptions);
- /* temporary.
- * add the PrintOptions widget and a Print button for testing purposes. */
+ // create a print options object and pass our options struct
optionsWidget = new PrintOptions(this, &printOptions);
QVBoxLayout *layout = new QVBoxLayout(this);
setLayout(layout);
- QPushButton *printButton = new QPushButton(tr("&Print"));
+ QHBoxLayout *hLayout = new QHBoxLayout();
+ layout->addLayout(hLayout);
+
+ QPushButton *previewButton = new QPushButton(tr("&Preview"));
+ connect(previewButton, SIGNAL(clicked(bool)), this, SLOT(previewClicked()));
+ hLayout->addWidget(previewButton);
+
+ QPushButton *printButton = new QPushButton(tr("P&rint"));
connect(printButton, SIGNAL(clicked(bool)), this, SLOT(printClicked()));
- layout->addWidget(printButton);
+ hLayout->addWidget(printButton);
+
+ QPushButton *closeButton = new QPushButton(tr("&Close"));
+ connect(closeButton, SIGNAL(clicked(bool)), this, SLOT(closeClicked()));
+ hLayout->addWidget(closeButton);
+
+ progressBar = new QProgressBar();
+ connect(printLayout, SIGNAL(signalProgress(int)), progressBar, SLOT(setValue(int)));
+ progressBar->setMinimum(0);
+ progressBar->setMaximum(100);
+ progressBar->setTextVisible(false);
+ layout->addWidget(progressBar);
layout->addWidget(optionsWidget);
- setFixedSize(520, 320);
+ setFixedSize(520, 350);
setWindowTitle(tr("Print"));
setWindowIcon(QIcon(":subsurface-icon"));
}
void PrintDialog::runDialog()
{
+ progressBar->setValue(0);
exec();
}
-void PrintDialog::printClicked(void)
+void PrintDialog::previewClicked(void)
{
QPrintPreviewDialog previewDialog(&printer, this);
- QObject::connect(&previewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(onPaintRequested(QPrinter *)));
- previewDialog.exec();
+ QObject::connect(&previewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(onPaintRequested(QPrinter *)));
+ previewDialog.exec();
+}
+
+void PrintDialog::printClicked(void)
+{
+ QPrintDialog printDialog(&printer, this);
+ if (printDialog.exec() == QDialog::Accepted)
+ printLayout->print();
+}
+
+void PrintDialog::closeClicked(void)
+{
+ close();
}
void PrintDialog::onPaintRequested(QPrinter *printerPtr)
diff --git a/qt-ui/printdialog.h b/qt-ui/printdialog.h
index 097de9531..44bb94669 100644
--- a/qt-ui/printdialog.h
+++ b/qt-ui/printdialog.h
@@ -4,8 +4,10 @@
#include <QDialog>
#include <QPrinter>
#include "../display.h"
-#include "printoptions.h"
-#include "printlayout.h"
+
+class QProgressBar;
+class PrintOptions;
+class PrintLayout;
// should be based on a custom QPrintDialog class
class PrintDialog : public QDialog {
@@ -20,10 +22,13 @@ private:
explicit PrintDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
PrintOptions *optionsWidget;
PrintLayout *printLayout;
+ QProgressBar *progressBar;
QPrinter printer;
private slots:
+ void previewClicked();
void printClicked();
+ void closeClicked();
void onPaintRequested(QPrinter *);
};
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
index afc6dd036..556bf139b 100644
--- a/qt-ui/printlayout.cpp
+++ b/qt-ui/printlayout.cpp
@@ -7,9 +7,10 @@
#include <QHeaderView>
#include "mainwindow.h"
#include "profilegraphics.h"
-#include "printlayout.h"
#include "../dive.h"
#include "../display.h"
+#include "printdialog.h"
+#include "printlayout.h"
#include "models.h"
#include "modeldelegates.h"
@@ -91,6 +92,19 @@ void PrintLayout::setup()
scaledPageH = pageRect.height() / scaleY;
}
+// go trought the dive table and find how many dives we are a going to print
+int PrintLayout::estimateTotalDives() const
+{
+ int total = 0, i = 0;
+ struct dive *dive;
+ for_each_dive(i, dive) {
+ if (!dive->selected && printOptions->print_selected)
+ continue;
+ total++;
+ }
+ return total;
+}
+
/* the used formula here is:
* s = (S - (n - 1) * p) / n
* where:
@@ -104,6 +118,11 @@ void PrintLayout::setup()
void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
{
+ int i, row = 0, col = 0, printed = 0, total = estimateTotalDives();
+ struct dive *dive;
+ if (!total)
+ return;
+
// setup a painter
QPainter painter;
painter.begin(printer);
@@ -148,8 +167,6 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
yOffsetTable = scaledH - tableH;
// plot the dives at specific rows and columns on the page
- int i, row = 0, col = 0;
- struct dive *dive;
for_each_dive(i, dive) {
if (!dive->selected && printOptions->print_selected)
continue;
@@ -175,6 +192,8 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
table->render(&painter);
painter.setTransform(origTransform);
col++;
+ printed++;
+ emit signalProgress((printed * 100) / total);
}
// cleanup
@@ -253,6 +272,12 @@ 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, progress, total = estimateTotalDives();
+ if (!total)
+ return;
+
// create and setup a table
QTableView table;
table.setAttribute(Qt::WA_DontShowOnScreen);
@@ -274,15 +299,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
@@ -305,7 +331,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
@@ -315,6 +343,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
@@ -325,13 +355,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);
}
}
diff --git a/qt-ui/printlayout.h b/qt-ui/printlayout.h
index 1ed19e271..077d7ac14 100644
--- a/qt-ui/printlayout.h
+++ b/qt-ui/printlayout.h
@@ -34,11 +34,15 @@ private:
QList<unsigned int> profilePrintColumnWidths, profilePrintRowHeights;
void setup();
+ int estimateTotalDives() 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
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 0d38a89f9..00eb9edbe 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -403,7 +403,7 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
gc.maxy = (profile_grid_area.height() - 2 * profile_grid_area.y());
/* This is per-dive-computer */
- gc.pi = *create_plot_info(dive, dc, &gc);
+ gc.pi = *create_plot_info(dive, dc, &gc, printMode);
/* Bounding box */
QPen pen = defaultPen;
@@ -540,16 +540,16 @@ void ProfileGraphicsView::plot_pp_text()
{
double pp, dpp, m;
int hpos;
- static text_render_options_t tro = {PP_TEXT_SIZE, PP_LINES, LEFT, MIDDLE};
+ static text_render_options_t tro = {PP_TEXT_SIZE, PP_LINES, LEFT, -0.75};
QGraphicsRectItem *pressureMarkers = new QGraphicsRectItem();
setup_pp_limits(&gc);
pp = floor(gc.pi.maxpp * 10.0) / 10.0 + 0.2;
- dpp = pp > 4 ? 0.5 : 0.2;
+ dpp = pp > 4 ? 0.5 : 0.25;
hpos = gc.pi.entry[gc.pi.nr - 1].sec;
QColor c = getColor(PP_LINES);
- bool alt = false;
+ bool alt = true;
for (m = 0.0; m <= pp; m += dpp) {
QGraphicsLineItem *item = new QGraphicsLineItem(SCALEGC(0, m), SCALEGC(hpos, m));
QPen pen(defaultPen);
@@ -562,9 +562,8 @@ void ProfileGraphicsView::plot_pp_text()
scene()->addItem(item);
qreal textPos = hpos;
if (alt)
- textPos += 30;
+ plot_text(&tro, QPointF(textPos, m), QString::number(m), pressureMarkers);
alt = !alt;
- plot_text(&tro, QPointF(textPos, m), QString::number(m), pressureMarkers);
}
scene()->addItem(pressureMarkers);
pressureMarkers->setPos(pressureMarkers->pos().x() + 10, 0);