summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--display.h3
-rw-r--r--qt-ui/printlayout.cpp14
-rw-r--r--qt-ui/printlayout.h2
-rw-r--r--qt-ui/printoptions.cpp9
-rw-r--r--qt-ui/printoptions.h1
-rw-r--r--qt-ui/printoptions.ui13
6 files changed, 36 insertions, 6 deletions
diff --git a/display.h b/display.h
index b728b8b70..7775dcf7a 100644
--- a/display.h
+++ b/display.h
@@ -39,7 +39,8 @@ struct options {
enum {
PRETTY,
TABLE,
- TWOPERPAGE
+ TWOPERPAGE,
+ ONEPERPAGE
} type;
int print_selected;
int color_selected;
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
index 6aaff0256..4b368db14 100644
--- a/qt-ui/printlayout.cpp
+++ b/qt-ui/printlayout.cpp
@@ -68,6 +68,9 @@ void PrintLayout::print()
case options::PRETTY:
printProfileDives(3, 2);
break;
+ case options::ONEPERPAGE:
+ printProfileDives(1, 1);
+ break;
case options::TWOPERPAGE:
printProfileDives(2, 1);
break;
@@ -167,7 +170,8 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
// create a model and table
ProfilePrintModel model;
model.setFontsize(divesPerColumn == 1 ? 6.5 : 4.5);
- QPointer<QTableView> table(createProfileTable(&model, scaledW));
+ // if there is only one dive per page row we pass fitNotesToHeight to be almost half the page height
+ QPointer<QTableView> table(createProfileTable(&model, scaledW, (divesPerRow == 1) ? scaledH * 0.45 : 0.0));
// profilePrintTableMaxH updates after the table is created
const int tableH = profilePrintTableMaxH;
// resize the profile widget
@@ -227,7 +231,7 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
}
/* we create a table that has a fixed height, but can stretch to fit certain width */
-QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int tableW)
+QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int tableW, const qreal fitNotesToHeight)
{
// setup a new table
QTableView *table = new QTableView();
@@ -266,14 +270,16 @@ QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int
table->setSpan(6, 0, 1, 5);
table->setSpan(7, 0, 5, 5);
/* resize row heights to the 'profilePrintRowHeights' indexes.
- * profilePrintTableMaxH will then hold the table height. */
+ * profilePrintTableMaxH will then hold the table height.
+ * what fitNotesToHeight does it to expand the notes section to fit a special height */
int i;
profilePrintTableMaxH = 0;
for (i = 0; i < rows; i++) {
- int h = profilePrintRowHeights.at(i);
+ int h = (i == rows - 1 && fitNotesToHeight != 0.0) ? fitNotesToHeight : profilePrintRowHeights.at(i);
profilePrintTableMaxH += h;
vHeader->resizeSection(i, h);
}
+
// resize columns. columns widths are percentages from the table width.
int accW = 0;
for (i = 0; i < cols; i++) {
diff --git a/qt-ui/printlayout.h b/qt-ui/printlayout.h
index 8a907902c..efd3159a8 100644
--- a/qt-ui/printlayout.h
+++ b/qt-ui/printlayout.h
@@ -38,7 +38,7 @@ private:
void setup();
int estimateTotalDives() const;
void printProfileDives(int divesPerRow, int divesPerColumn);
- QTableView *createProfileTable(ProfilePrintModel *model, const int tableW);
+ QTableView *createProfileTable(ProfilePrintModel *model, const int tableW, const qreal fitNotesToHeight = 0.0);
void printTable();
void addTablePrintDataRow(TablePrintModel *model, int row, struct dive *dive) const;
void addTablePrintHeadingRow(TablePrintModel *model, int row) const;
diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp
index ac5f6550c..818e89c33 100644
--- a/qt-ui/printoptions.cpp
+++ b/qt-ui/printoptions.cpp
@@ -23,6 +23,9 @@ void PrintOptions::setup(struct options *printOpt)
case options::TWOPERPAGE:
ui.radioTwoDives->setChecked(true);
break;
+ case options::ONEPERPAGE:
+ ui.radioOneDive->setChecked(true);
+ break;
case options::TABLE:
ui.radioTablePrint->setChecked(true);
break;
@@ -44,6 +47,7 @@ void PrintOptions::setup(struct options *printOpt)
connect(ui.radioSixDives, SIGNAL(clicked(bool)), this, SLOT(radioSixDivesClicked(bool)));
connect(ui.radioTwoDives, SIGNAL(clicked(bool)), this, SLOT(radioTwoDivesClicked(bool)));
+ connect(ui.radioOneDive, SIGNAL(clicked(bool)), this, SLOT(radioOneDiveClicked(bool)));
connect(ui.radioTablePrint, SIGNAL(clicked(bool)), this, SLOT(radioTablePrintClicked(bool)));
connect(ui.printInColor, SIGNAL(clicked(bool)), this, SLOT(printInColorClicked(bool)));
@@ -65,6 +69,11 @@ void PrintOptions::radioTwoDivesClicked(bool check)
printOptions->type = options::TWOPERPAGE;
}
+void PrintOptions::radioOneDiveClicked(bool check)
+{
+ printOptions->type = options::ONEPERPAGE;
+}
+
void PrintOptions::radioTablePrintClicked(bool check)
{
printOptions->type = options::TABLE;
diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h
index 66d3d7424..e14ae46a1 100644
--- a/qt-ui/printoptions.h
+++ b/qt-ui/printoptions.h
@@ -22,6 +22,7 @@ private
slots:
void radioSixDivesClicked(bool check);
void radioTwoDivesClicked(bool check);
+ void radioOneDiveClicked(bool check);
void radioTablePrintClicked(bool check);
void printInColorClicked(bool check);
void printSelectedClicked(bool check);
diff --git a/qt-ui/printoptions.ui b/qt-ui/printoptions.ui
index c108315d0..e7bdbf683 100644
--- a/qt-ui/printoptions.ui
+++ b/qt-ui/printoptions.ui
@@ -134,6 +134,19 @@
</widget>
</item>
<item>
+ <widget class="QRadioButton" name="radioOneDive">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>1 dive per page</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QRadioButton" name="radioTablePrint">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">