summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-07-10 15:34:57 +0300
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-07-10 15:34:57 +0300
commit41bad7695ee40571062a370610e6ca518295e3c7 (patch)
tree6c3d960f36440edb3e5532a84400811004853d0a
parent74f989bc46a06c124283fa851a06dd093f817c96 (diff)
downloadsubsurface-41bad7695ee40571062a370610e6ca518295e3c7.tar.gz
Print: add a class for print layouting
PrintLayout is a class that will handle the layouting part of dive profiles, text, tables depending on the settings of a QPrinter and the PrinterDialog and PrintOptions instances. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
-rw-r--r--Makefile2
-rw-r--r--qt-ui/printdialog.cpp5
-rw-r--r--qt-ui/printdialog.h4
-rw-r--r--qt-ui/printlayout.cpp50
-rw-r--r--qt-ui/printlayout.h29
-rw-r--r--qt-ui/printoptions.cpp2
6 files changed, 91 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index a9f61058a..3496c327b 100644
--- a/Makefile
+++ b/Makefile
@@ -55,6 +55,7 @@ HEADERS = \
qt-ui/graphicsview-common.h \
qt-ui/printdialog.h \
qt-ui/printoptions.h \
+ qt-ui/printlayout.h \
SOURCES = \
@@ -98,6 +99,7 @@ SOURCES = \
qt-ui/graphicsview-common.cpp \
qt-ui/printdialog.cpp \
qt-ui/printoptions.cpp \
+ qt-ui/printlayout.cpp \
$(RESFILE)
diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp
index e62cd718d..9774a79f6 100644
--- a/qt-ui/printdialog.cpp
+++ b/qt-ui/printdialog.cpp
@@ -16,6 +16,10 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f)
// options template (are we storing these in the settings?)
struct options tempOptions = {options::PRETTY, 0, 2, false, 65, 15, 12};
printOptions = tempOptions;
+
+ // 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. */
optionsWidget = new PrintOptions(this, &printOptions);
@@ -40,4 +44,5 @@ void PrintDialog::runDialog()
void PrintDialog::printClicked(void)
{
// nop for now
+ printLayout->print();
}
diff --git a/qt-ui/printdialog.h b/qt-ui/printdialog.h
index b3dcfa826..b97a318c5 100644
--- a/qt-ui/printdialog.h
+++ b/qt-ui/printdialog.h
@@ -2,8 +2,10 @@
#define PRINTDIALOG_H
#include <QDialog>
+#include <QPrinter>
#include "../display.h"
#include "printoptions.h"
+#include "printlayout.h"
// should be based on a custom QPrintDialog class
class PrintDialog : public QDialog {
@@ -17,6 +19,8 @@ public:
private:
explicit PrintDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
PrintOptions *optionsWidget;
+ PrintLayout *printLayout;
+ QPrinter printer;
private slots:
void printClicked();
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
new file mode 100644
index 000000000..7716883e8
--- /dev/null
+++ b/qt-ui/printlayout.cpp
@@ -0,0 +1,50 @@
+#include <QPainter>
+#include "mainwindow.h"
+#include "printlayout.h"
+
+/*
+struct options {
+ enum { PRETTY, TABLE, TWOPERPAGE } type;
+ int print_selected;
+ int color_selected;
+ bool notes_up;
+ int profile_height, notes_height, tanks_height;
+};
+*/
+
+PrintLayout::PrintLayout(PrintDialog *dialogPtr, QPrinter *printerPtr, struct options *optionsPtr)
+{
+ dialog = dialogPtr;
+ printer = printerPtr;
+ printOptions = optionsPtr;
+}
+
+void PrintLayout::print()
+{
+ switch (printOptions->type) {
+ case options::PRETTY:
+ printSixDives();
+ break;
+ case options::TWOPERPAGE:
+ printTwoDives();
+ break;
+ case options::TABLE:
+ printTable();
+ break;
+ }
+}
+
+void PrintLayout::printSixDives()
+{
+ // nop
+}
+
+void PrintLayout::printTwoDives()
+{
+ // nop
+}
+
+void PrintLayout::printTable()
+{
+ // nop
+}
diff --git a/qt-ui/printlayout.h b/qt-ui/printlayout.h
new file mode 100644
index 000000000..e9129bff6
--- /dev/null
+++ b/qt-ui/printlayout.h
@@ -0,0 +1,29 @@
+#ifndef PRINTLAYOUT_H
+#define PRINTLAYOUT_H
+
+#include <QPrinter>
+#include <QPainter>
+#include "../display.h"
+
+class PrintDialog;
+
+class PrintLayout : public QObject {
+ Q_OBJECT
+
+public:
+ PrintLayout(PrintDialog *, QPrinter *, struct options *);
+ void print();
+
+private:
+ PrintDialog *dialog;
+ QPrinter *printer;
+ struct options *printOptions;
+
+ QPainter painter;
+
+ void printSixDives();
+ void printTwoDives();
+ void printTable();
+};
+
+#endif
diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp
index 005c4dc84..a0d5b80cf 100644
--- a/qt-ui/printoptions.cpp
+++ b/qt-ui/printoptions.cpp
@@ -21,7 +21,7 @@ void PrintOptions::setup(struct options *printOpt)
initSliderWithLabel(ui->sliderOHeight, ui->valueOHeight, printOptions->notes_height);
initSliderWithLabel(ui->sliderNHeight, ui->valueNHeight, printOptions->tanks_height);
// print type radio buttons
- switch (printOptions->type) {
+ switch (printOptions->type) {
case options::PRETTY:
ui->radioSixDives->setChecked(true);
break;