2013-07-10 15:34:57 +03:00
|
|
|
#include <QPainter>
|
2013-07-10 16:04:00 +03:00
|
|
|
#include <QDesktopWidget>
|
|
|
|
#include <QApplication>
|
2013-07-10 15:34:57 +03:00
|
|
|
#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()
|
|
|
|
{
|
2013-07-10 16:04:00 +03:00
|
|
|
// we call setup each time to check if the printer properties have changed
|
|
|
|
setup();
|
2013-07-10 15:34:57 +03:00
|
|
|
switch (printOptions->type) {
|
|
|
|
case options::PRETTY:
|
|
|
|
printSixDives();
|
|
|
|
break;
|
|
|
|
case options::TWOPERPAGE:
|
|
|
|
printTwoDives();
|
|
|
|
break;
|
|
|
|
case options::TABLE:
|
|
|
|
printTable();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-10 16:04:00 +03:00
|
|
|
void PrintLayout::setup()
|
|
|
|
{
|
|
|
|
QDesktopWidget *desktop = QApplication::desktop();
|
|
|
|
screenDpiX = desktop->physicalDpiX();
|
|
|
|
screenDpiY = desktop->physicalDpiX();
|
|
|
|
|
|
|
|
printerDpi = printer->resolution();
|
|
|
|
pageRect = printer->pageRect();
|
|
|
|
|
|
|
|
scaleX = (qreal)printerDpi/(qreal)screenDpiX;
|
|
|
|
scaleY = (qreal)printerDpi/(qreal)screenDpiY;
|
|
|
|
}
|
|
|
|
|
2013-07-10 15:34:57 +03:00
|
|
|
void PrintLayout::printSixDives()
|
|
|
|
{
|
|
|
|
// nop
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintLayout::printTwoDives()
|
|
|
|
{
|
|
|
|
// nop
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintLayout::printTable()
|
|
|
|
{
|
|
|
|
// nop
|
|
|
|
}
|