mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 22:00:35 +01:00
Le dialogue d'impression presente desormais les memes options que le dialogue d'export.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@759 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "qetprintpreviewdialog.h"
|
||||
#include <math.h>
|
||||
#include "diagramschooser.h"
|
||||
#include "exportproperties.h"
|
||||
#include "qeticons.h"
|
||||
#include "qetmessagebox.h"
|
||||
|
||||
@@ -122,13 +123,23 @@ void DiagramPrintDialog::exec() {
|
||||
|
||||
// Apercu avant impression
|
||||
QETPrintPreviewDialog preview_dialog(project_, printer_, parentWidget());
|
||||
connect(&preview_dialog, SIGNAL(paintRequested(const QList<Diagram *> &, bool, QPrinter *)), this, SLOT(print(const QList<Diagram *> &, bool, QPrinter *)));
|
||||
connect(
|
||||
&preview_dialog,
|
||||
SIGNAL(paintRequested(const QList<Diagram *> &, bool, const ExportProperties, QPrinter *)),
|
||||
this,
|
||||
SLOT(print(const QList<Diagram *> &, bool, const ExportProperties, QPrinter *))
|
||||
);
|
||||
DiagramsChooser *dc = preview_dialog.diagramsChooser();
|
||||
dc -> setSelectedAllDiagrams();
|
||||
if (preview_dialog.exec() == QDialog::Rejected) return;
|
||||
|
||||
// effectue l'impression en elle-meme
|
||||
print(dc -> selectedDiagrams(), preview_dialog.fitDiagramsToPages(), printer_);
|
||||
print(
|
||||
dc -> selectedDiagrams(),
|
||||
preview_dialog.fitDiagramsToPages(),
|
||||
preview_dialog.exportProperties(),
|
||||
printer_
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,9 +328,10 @@ void DiagramPrintDialog::browseFilePrintTypeDialog() {
|
||||
@param diagrams Schemas a imprimer
|
||||
@param fit_page Booleen indiquant s'il faut adapter les schemas aux pages
|
||||
ou non
|
||||
@param options Options de rendu
|
||||
@param printer L'imprimante a utiliser
|
||||
*/
|
||||
void DiagramPrintDialog::print(const QList<Diagram *> &diagrams, bool fit_page, QPrinter */*printer*/) {
|
||||
void DiagramPrintDialog::print(const QList<Diagram *> &diagrams, bool fit_page, const ExportProperties options, QPrinter */*printer*/) {
|
||||
//qDebug() << "Demande d'impression de " << diagrams.count() << "schemas.";
|
||||
|
||||
// QPainter utiliser pour effectuer le rendu
|
||||
@@ -333,7 +345,7 @@ void DiagramPrintDialog::print(const QList<Diagram *> &diagrams, bool fit_page,
|
||||
|
||||
// imprime les schemas
|
||||
for (int i = 0 ; i < diagrams.count() ; ++ i) {
|
||||
printDiagram(diagrams[i], fit_page, &qp, printer_);
|
||||
printDiagram(diagrams[i], fit_page, options, &qp, printer_);
|
||||
if (i != diagrams.count() - 1) {
|
||||
printer_ -> newPage();
|
||||
}
|
||||
@@ -347,7 +359,7 @@ void DiagramPrintDialog::print(const QList<Diagram *> &diagrams, bool fit_page,
|
||||
@param qp QPainter a utiliser (deja initialise sur printer)
|
||||
@param printer Imprimante a utiliser
|
||||
*/
|
||||
void DiagramPrintDialog::printDiagram(Diagram *diagram, bool fit_page, QPainter *qp, QPrinter *printer) {
|
||||
void DiagramPrintDialog::printDiagram(Diagram *diagram, bool fit_page, const ExportProperties options, QPainter *qp, QPrinter *printer) {
|
||||
//qDebug() << printer -> paperSize() << printer -> paperRect() << diagram -> title();
|
||||
// l'imprimante utilise-t-elle toute la feuille ?
|
||||
bool full_page = printer -> fullPage ();
|
||||
@@ -357,8 +369,7 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram, bool fit_page, QPainter
|
||||
// utiliser cette condition pour agir differemment en cas d'impression physique
|
||||
}
|
||||
|
||||
diagram -> setDisplayGrid(false);
|
||||
diagram -> setDrawTerminals(false);
|
||||
saveReloadDiagramParameters(diagram, options, true);
|
||||
|
||||
if (fit_page) {
|
||||
// impression adaptee sur une seule page
|
||||
@@ -426,6 +437,24 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram, bool fit_page, QPainter
|
||||
}
|
||||
}
|
||||
}
|
||||
diagram -> setDrawTerminals(true);
|
||||
diagram -> setDisplayGrid(true);
|
||||
saveReloadDiagramParameters(diagram, options, false);
|
||||
}
|
||||
|
||||
/**
|
||||
Sauve ou restaure les parametres du schema
|
||||
@param diagram Schema dont on sauve ou restaure les parametres
|
||||
@param options Parametres a appliquer
|
||||
@param save true pour memoriser les parametres du schema et appliquer ceux
|
||||
definis dans options, false pour restaurer les parametres
|
||||
*/
|
||||
void DiagramPrintDialog::saveReloadDiagramParameters(Diagram *diagram, const ExportProperties options, bool save) {
|
||||
static ExportProperties state_exportProperties;
|
||||
|
||||
if (save) {
|
||||
// memorise les parametres relatifs au schema tout en appliquant les nouveaux
|
||||
state_exportProperties = diagram -> applyProperties(options);
|
||||
} else {
|
||||
// restaure les parametres relatifs au schema
|
||||
diagram -> applyProperties(state_exportProperties);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <QtGui>
|
||||
#include "qetproject.h"
|
||||
#include "diagram.h"
|
||||
#include "exportproperties.h"
|
||||
/**
|
||||
Cette classe represente le dialogue de configuration de l'impression d'un
|
||||
schema electrique.
|
||||
@@ -49,10 +50,11 @@ class DiagramPrintDialog : public QWidget {
|
||||
private:
|
||||
void buildPrintTypeDialog();
|
||||
void buildDialog();
|
||||
void saveReloadDiagramParameters(Diagram *, const ExportProperties, bool);
|
||||
|
||||
private slots:
|
||||
void print(const QList<Diagram *> &, bool, QPrinter *);
|
||||
void printDiagram(Diagram *, bool, QPainter *, QPrinter * = 0);
|
||||
void print(const QList<Diagram *> &, bool, const ExportProperties, QPrinter *);
|
||||
void printDiagram(Diagram *, bool, const ExportProperties, QPainter *, QPrinter * = 0);
|
||||
void updatePrintTypeDialog();
|
||||
void acceptPrintTypeDialog();
|
||||
void browseFilePrintTypeDialog();
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
#include "qetprintpreviewdialog.h"
|
||||
#include "diagramschooser.h"
|
||||
#include "exportproperties.h"
|
||||
#include "exportpropertieswidget.h"
|
||||
#include "qeticons.h"
|
||||
|
||||
/**
|
||||
@@ -59,6 +61,13 @@ bool QETPrintPreviewDialog::fitDiagramsToPages() const {
|
||||
return(fit_diagram_to_page_ -> isChecked());
|
||||
}
|
||||
|
||||
/**
|
||||
@return les options de rendu definies par l'utilisateur
|
||||
*/
|
||||
ExportProperties QETPrintPreviewDialog::exportProperties() const {
|
||||
return(render_properties_ -> exportProperties());
|
||||
}
|
||||
|
||||
/**
|
||||
Passe a la premiere page
|
||||
*/
|
||||
@@ -222,6 +231,9 @@ void QETPrintPreviewDialog::build() {
|
||||
fit_diagram_to_page_label_ -> setContentsMargins(20, 0, 0, 0);
|
||||
fit_diagram_to_page_ -> setChecked(true);
|
||||
|
||||
render_properties_ = new ExportPropertiesWidget();
|
||||
render_properties_ -> setPrintingMode(true);
|
||||
|
||||
buttons_ = new QDialogButtonBox();
|
||||
buttons_ -> addButton(new QPushButton(QET::Icons::DocumentPrint, tr("Imprimer")), QDialogButtonBox::AcceptRole);
|
||||
buttons_ -> addButton(QDialogButtonBox::Cancel);
|
||||
@@ -246,6 +258,8 @@ void QETPrintPreviewDialog::build() {
|
||||
connect(use_full_page_, SIGNAL(toggled(bool)), this, SLOT(useFullPage(bool)));
|
||||
connect(fit_diagram_to_page_, SIGNAL(toggled(bool)), this, SLOT(fitDiagramToPage(bool)));
|
||||
|
||||
connect(render_properties_, SIGNAL(optionChanged()), preview_, SLOT(updatePreview()));
|
||||
|
||||
connect(preview_, SIGNAL(previewChanged()), this, SLOT(updateZoomList()));
|
||||
connect(zoom_box_, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePreviewZoom()));
|
||||
|
||||
@@ -271,6 +285,7 @@ void QETPrintPreviewDialog::build() {
|
||||
|
||||
vlayout0_ -> addWidget(toolbar_);
|
||||
vlayout0_ -> addLayout(hlayout0_);
|
||||
vlayout0_ -> addWidget(render_properties_);
|
||||
vlayout0_ -> addWidget(print_options_box_);
|
||||
vlayout0_ -> addWidget(buttons_);
|
||||
|
||||
@@ -289,6 +304,7 @@ void QETPrintPreviewDialog::requestPaint(QPrinter *printer) {
|
||||
paintRequested(
|
||||
diagrams_list_ -> selectedDiagrams(),
|
||||
fit_diagram_to_page_ -> isChecked(),
|
||||
render_properties_ -> exportProperties(),
|
||||
printer
|
||||
)
|
||||
);
|
||||
@@ -328,6 +344,7 @@ void QETPrintPreviewDialog::setDiagramsListVisible(bool display) {
|
||||
*/
|
||||
void QETPrintPreviewDialog::setPrintOptionsVisible(bool display) {
|
||||
print_options_box_ -> setVisible(display);
|
||||
render_properties_ -> setVisible(display);
|
||||
|
||||
if (display) {
|
||||
toggle_print_options_ -> setText(tr("Cacher les options d'impression"));
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
#ifndef QET_PRINT_PREVIEW_DIALOG
|
||||
#define QET_PRINT_PREVIEW_DIALOG
|
||||
#include <QtGui>
|
||||
#include "exportproperties.h"
|
||||
class Diagram;
|
||||
class DiagramsChooser;
|
||||
class ExportPropertiesWidget;
|
||||
class QETProject;
|
||||
/**
|
||||
Cette classe represente un dialogue permettant d'affiner les options
|
||||
@@ -40,10 +42,11 @@ class QETPrintPreviewDialog : public QDialog {
|
||||
public:
|
||||
DiagramsChooser *diagramsChooser();
|
||||
bool fitDiagramsToPages() const;
|
||||
ExportProperties exportProperties() const;
|
||||
|
||||
// signaux
|
||||
signals:
|
||||
void paintRequested(const QList<Diagram *> &, bool, QPrinter *);
|
||||
void paintRequested(const QList<Diagram *> &, bool, const ExportProperties, QPrinter *);
|
||||
|
||||
public slots:
|
||||
void firstPage();
|
||||
@@ -91,6 +94,7 @@ class QETPrintPreviewDialog : public QDialog {
|
||||
QLabel *use_full_page_label_;
|
||||
QCheckBox *fit_diagram_to_page_;
|
||||
QLabel *fit_diagram_to_page_label_;
|
||||
ExportPropertiesWidget *render_properties_;
|
||||
|
||||
// methodes
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user