#include "export_to_pdf.h"


#define ADD_PAGE_SIZE(n, i, s_w, s_h) comboPageSize->addItem(#n, i); page_sizes[i] = QSizeF(s_w, s_h);

ExportToPDF::ExportToPDF(QWidget * parent): QDialog(parent), Ui::ExportToPDF() {
	setupUi(this);
	ADD_PAGE_SIZE(A0, 5, 841, 1189)
	ADD_PAGE_SIZE(A1, 6, 594, 841)
	ADD_PAGE_SIZE(A2, 7, 420, 594)
	ADD_PAGE_SIZE(A3, 8, 297, 420)
	ADD_PAGE_SIZE(A4, 0, 210, 297)
	ADD_PAGE_SIZE(A5, 9, 148, 210)
	ADD_PAGE_SIZE(A6, 10, 105, 148)
	ADD_PAGE_SIZE(A7, 11, 74, 105)
	ADD_PAGE_SIZE(A8, 12, 52, 74)
	ADD_PAGE_SIZE(A9, 13, 37, 52)
	ADD_PAGE_SIZE(B0, 14, 1000, 1414)
	ADD_PAGE_SIZE(B1, 15, 707, 1000)
	ADD_PAGE_SIZE(B2, 17, 500, 707)
	ADD_PAGE_SIZE(B3, 18, 353, 500)
	ADD_PAGE_SIZE(B4, 19, 250, 353)
	ADD_PAGE_SIZE(B5, 1, 176, 250)
	ADD_PAGE_SIZE(B6, 20, 125, 176)
	ADD_PAGE_SIZE(B7, 21, 88, 125)
	ADD_PAGE_SIZE(B8, 22, 62, 88)
	ADD_PAGE_SIZE(B9, 23, 33, 62)
	ADD_PAGE_SIZE(B10, 16, 31, 44)
	ADD_PAGE_SIZE(C5E, 24, 163, 229)
	ADD_PAGE_SIZE(Comm10E, 25, 105, 241)
	ADD_PAGE_SIZE(DLE, 26, 110, 220)
	ADD_PAGE_SIZE(Executive, 4, 190.5, 254)
	ADD_PAGE_SIZE(Folio, 27, 210, 330)
	ADD_PAGE_SIZE(Ledger, 28, 431.8, 279.4)
	ADD_PAGE_SIZE(Legal, 3, 215.9, 355.6)
	ADD_PAGE_SIZE(Letter, 2, 215.9, 279.4)
	ADD_PAGE_SIZE(Tabloid, 29, 279.4, 431.8)
	comboPageSize->setCurrentIndex(4);
}

#undef ADD_PAGE_SIZE


ExportToPDF::~ExportToPDF() {
}


void ExportToPDF::accept() {
	page_size = QPageSize((QPageSize::PageSizeId)(comboPageSize->itemData(comboPageSize->currentIndex()).toInt()));
	if (comboOrientation->currentIndex() == 1)
		page_size = QPageSize(page_size.definitionSize().transposed(), page_size.definitionUnits());
	//orientation = (QPrinter::Orientation)();
	dpi = comboDPI->currentText().toInt();
	QDialog::accept();
}


void ExportToPDF::reject() {
	QDialog::reject();
}
