mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
74f989bc46
commit
41bad7695e
6 changed files with 91 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -55,6 +55,7 @@ HEADERS = \
|
||||||
qt-ui/graphicsview-common.h \
|
qt-ui/graphicsview-common.h \
|
||||||
qt-ui/printdialog.h \
|
qt-ui/printdialog.h \
|
||||||
qt-ui/printoptions.h \
|
qt-ui/printoptions.h \
|
||||||
|
qt-ui/printlayout.h \
|
||||||
|
|
||||||
|
|
||||||
SOURCES = \
|
SOURCES = \
|
||||||
|
@ -98,6 +99,7 @@ SOURCES = \
|
||||||
qt-ui/graphicsview-common.cpp \
|
qt-ui/graphicsview-common.cpp \
|
||||||
qt-ui/printdialog.cpp \
|
qt-ui/printdialog.cpp \
|
||||||
qt-ui/printoptions.cpp \
|
qt-ui/printoptions.cpp \
|
||||||
|
qt-ui/printlayout.cpp \
|
||||||
$(RESFILE)
|
$(RESFILE)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,10 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f)
|
||||||
// options template (are we storing these in the settings?)
|
// options template (are we storing these in the settings?)
|
||||||
struct options tempOptions = {options::PRETTY, 0, 2, false, 65, 15, 12};
|
struct options tempOptions = {options::PRETTY, 0, 2, false, 65, 15, 12};
|
||||||
printOptions = tempOptions;
|
printOptions = tempOptions;
|
||||||
|
|
||||||
|
// create a print layout and pass the printer and options
|
||||||
|
printLayout = new PrintLayout(this, &printer, &printOptions);
|
||||||
|
|
||||||
/* temporary.
|
/* temporary.
|
||||||
* add the PrintOptions widget and a Print button for testing purposes. */
|
* add the PrintOptions widget and a Print button for testing purposes. */
|
||||||
optionsWidget = new PrintOptions(this, &printOptions);
|
optionsWidget = new PrintOptions(this, &printOptions);
|
||||||
|
@ -40,4 +44,5 @@ void PrintDialog::runDialog()
|
||||||
void PrintDialog::printClicked(void)
|
void PrintDialog::printClicked(void)
|
||||||
{
|
{
|
||||||
// nop for now
|
// nop for now
|
||||||
|
printLayout->print();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
#define PRINTDIALOG_H
|
#define PRINTDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QPrinter>
|
||||||
#include "../display.h"
|
#include "../display.h"
|
||||||
#include "printoptions.h"
|
#include "printoptions.h"
|
||||||
|
#include "printlayout.h"
|
||||||
|
|
||||||
// should be based on a custom QPrintDialog class
|
// should be based on a custom QPrintDialog class
|
||||||
class PrintDialog : public QDialog {
|
class PrintDialog : public QDialog {
|
||||||
|
@ -17,6 +19,8 @@ public:
|
||||||
private:
|
private:
|
||||||
explicit PrintDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
explicit PrintDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||||
PrintOptions *optionsWidget;
|
PrintOptions *optionsWidget;
|
||||||
|
PrintLayout *printLayout;
|
||||||
|
QPrinter printer;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void printClicked();
|
void printClicked();
|
||||||
|
|
50
qt-ui/printlayout.cpp
Normal file
50
qt-ui/printlayout.cpp
Normal file
|
@ -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
|
||||||
|
}
|
29
qt-ui/printlayout.h
Normal file
29
qt-ui/printlayout.h
Normal file
|
@ -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
|
|
@ -21,7 +21,7 @@ void PrintOptions::setup(struct options *printOpt)
|
||||||
initSliderWithLabel(ui->sliderOHeight, ui->valueOHeight, printOptions->notes_height);
|
initSliderWithLabel(ui->sliderOHeight, ui->valueOHeight, printOptions->notes_height);
|
||||||
initSliderWithLabel(ui->sliderNHeight, ui->valueNHeight, printOptions->tanks_height);
|
initSliderWithLabel(ui->sliderNHeight, ui->valueNHeight, printOptions->tanks_height);
|
||||||
// print type radio buttons
|
// print type radio buttons
|
||||||
switch (printOptions->type) {
|
switch (printOptions->type) {
|
||||||
case options::PRETTY:
|
case options::PRETTY:
|
||||||
ui->radioSixDives->setChecked(true);
|
ui->radioSixDives->setChecked(true);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue