mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-21 16:50:53 +01:00
Adaptation de l'impression pour Qt >= 4.4
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@376 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -31,6 +31,9 @@ DiagramPrintDialog::DiagramPrintDialog(Diagram *dia, QWidget *parent) :
|
|||||||
{
|
{
|
||||||
// initialise l'imprimante
|
// initialise l'imprimante
|
||||||
printer = new QPrinter();
|
printer = new QPrinter();
|
||||||
|
|
||||||
|
// orientation paysage par defaut
|
||||||
|
printer -> setOrientation(QPrinter::Landscape);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,6 +58,20 @@ QString DiagramPrintDialog::PDFName() const {
|
|||||||
return(pdf_name);
|
return(pdf_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Definit le nom du document
|
||||||
|
*/
|
||||||
|
void DiagramPrintDialog::setDocName(const QString &name) {
|
||||||
|
doc_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return le nom du document
|
||||||
|
*/
|
||||||
|
QString DiagramPrintDialog::docName() const {
|
||||||
|
return(doc_name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Execute le dialogue d'impression
|
Execute le dialogue d'impression
|
||||||
*/
|
*/
|
||||||
@@ -62,9 +79,10 @@ void DiagramPrintDialog::exec() {
|
|||||||
|
|
||||||
// affichage du dialogue d'impression standard
|
// affichage du dialogue d'impression standard
|
||||||
QPrintDialog print_dialog(printer);
|
QPrintDialog print_dialog(printer);
|
||||||
print_dialog.setEnabledOptions(QAbstractPrintDialog::PrintToFile);
|
print_dialog.setEnabledOptions(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintShowPageSize);
|
||||||
#ifndef Q_OS_WIN32
|
#ifndef Q_OS_WIN32
|
||||||
if (!pdf_name.isEmpty()) printer -> setOutputFileName(pdf_name);
|
if (!pdf_name.isEmpty()) printer -> setOutputFileName(pdf_name);
|
||||||
|
if (!doc_name.isEmpty()) printer -> setDocName(doc_name);
|
||||||
#endif
|
#endif
|
||||||
if (print_dialog.exec() == QDialog::Rejected) return;
|
if (print_dialog.exec() == QDialog::Rejected) return;
|
||||||
|
|
||||||
@@ -227,11 +245,7 @@ void DiagramPrintDialog::print() {
|
|||||||
|
|
||||||
// impression physique (!= fichier PDF)
|
// impression physique (!= fichier PDF)
|
||||||
if (printer -> outputFileName().isEmpty()) {
|
if (printer -> outputFileName().isEmpty()) {
|
||||||
// lorsqu'on imprime en paysage sur imprimante reelle, il faut pivoter soi-meme le rendu
|
// utiliser cette condition pour agir differemment en cas d'impression physique
|
||||||
if (printer -> orientation() == QPrinter::Landscape) {
|
|
||||||
qp.rotate(90.0);
|
|
||||||
qp.translate(0.0, -printer -> pageRect().height());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
diagram -> setDisplayGrid(false);
|
diagram -> setDisplayGrid(false);
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class DiagramPrintDialog : public QWidget {
|
|||||||
public:
|
public:
|
||||||
void setPDFName(const QString &);
|
void setPDFName(const QString &);
|
||||||
QString PDFName() const;
|
QString PDFName() const;
|
||||||
|
void setDocName(const QString &);
|
||||||
|
QString docName() const;
|
||||||
int pagesCount(bool = false) const;
|
int pagesCount(bool = false) const;
|
||||||
int horizontalPagesCount(bool = false) const;
|
int horizontalPagesCount(bool = false) const;
|
||||||
int verticalPagesCount(bool = false) const;
|
int verticalPagesCount(bool = false) const;
|
||||||
@@ -57,6 +59,7 @@ class DiagramPrintDialog : public QWidget {
|
|||||||
private:
|
private:
|
||||||
Diagram *diagram;
|
Diagram *diagram;
|
||||||
QPrinter *printer;
|
QPrinter *printer;
|
||||||
|
QString doc_name;
|
||||||
QString pdf_name;
|
QString pdf_name;
|
||||||
QDialog *dialog;
|
QDialog *dialog;
|
||||||
QLabel *options_label;
|
QLabel *options_label;
|
||||||
|
|||||||
@@ -530,17 +530,21 @@ void DiagramView::dialogExport() {
|
|||||||
*/
|
*/
|
||||||
void DiagramView::dialogPrint() {
|
void DiagramView::dialogPrint() {
|
||||||
|
|
||||||
// determine un nom possible pour le pdf
|
// determine un nom possible pour le document et le pdf
|
||||||
|
QString doc_name;
|
||||||
QString pdf_file_name;
|
QString pdf_file_name;
|
||||||
if (!file_name.isEmpty()) {
|
if (!file_name.isEmpty()) {
|
||||||
|
doc_name = QFileInfo(file_name).fileName();
|
||||||
pdf_file_name = file_name;
|
pdf_file_name = file_name;
|
||||||
pdf_file_name.replace(QRegExp("\\.qet$", Qt::CaseInsensitive), "");
|
pdf_file_name.replace(QRegExp("\\.qet$", Qt::CaseInsensitive), "");
|
||||||
} else {
|
} else {
|
||||||
|
doc_name = tr("schema");
|
||||||
pdf_file_name = QDir::toNativeSeparators(QDir::homePath() + "/" + tr("schema"));
|
pdf_file_name = QDir::toNativeSeparators(QDir::homePath() + "/" + tr("schema"));
|
||||||
}
|
}
|
||||||
pdf_file_name += ".pdf";
|
pdf_file_name += ".pdf";
|
||||||
|
|
||||||
DiagramPrintDialog print_dialog(scene, this);
|
DiagramPrintDialog print_dialog(scene, this);
|
||||||
|
print_dialog.setDocName(doc_name);
|
||||||
print_dialog.setPDFName(pdf_file_name);
|
print_dialog.setPDFName(pdf_file_name);
|
||||||
print_dialog.exec();
|
print_dialog.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user