mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Fix deprecated QRegExp
Use QRegularExpression instead. https://doc.qt.io/qt-5/qregularexpression.html#notes-for-qregexp-users This function was introduced in Qt 5
This commit is contained in:
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
@@ -38,7 +38,7 @@ DiagramPrintDialog::DiagramPrintDialog(QETProject *project, QWidget *parent) :
|
|||||||
{
|
{
|
||||||
// initialise l'imprimante
|
// initialise l'imprimante
|
||||||
printer_ = new QPrinter();
|
printer_ = new QPrinter();
|
||||||
|
|
||||||
// orientation paysage par defaut
|
// orientation paysage par defaut
|
||||||
printer_ -> setOrientation(QPrinter::Landscape);
|
printer_ -> setOrientation(QPrinter::Landscape);
|
||||||
backup_diagram_background_color = Diagram::background_color;
|
backup_diagram_background_color = Diagram::background_color;
|
||||||
@@ -95,16 +95,16 @@ QRect DiagramPrintDialog::diagramRect(Diagram *diagram,
|
|||||||
const ExportProperties &options) const
|
const ExportProperties &options) const
|
||||||
{
|
{
|
||||||
if (!diagram) return(QRect());
|
if (!diagram) return(QRect());
|
||||||
|
|
||||||
QRectF diagram_rect = diagram -> border_and_titleblock.borderAndTitleBlockRect();
|
QRectF diagram_rect = diagram -> border_and_titleblock.borderAndTitleBlockRect();
|
||||||
if (!options.draw_titleblock) {
|
if (!options.draw_titleblock) {
|
||||||
qreal titleblock_height = diagram -> border_and_titleblock.titleBlockRect().height();
|
qreal titleblock_height = diagram -> border_and_titleblock.titleBlockRect().height();
|
||||||
diagram_rect.setHeight(diagram_rect.height() - titleblock_height);
|
diagram_rect.setHeight(diagram_rect.height() - titleblock_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ajuste la bordure du schema d'un pixel (epaisseur du trait)
|
// ajuste la bordure du schema d'un pixel (epaisseur du trait)
|
||||||
diagram_rect = diagram_rect.adjusted(0.0, 0.0, 1.0, 1.0);
|
diagram_rect = diagram_rect.adjusted(0.0, 0.0, 1.0, 1.0);
|
||||||
|
|
||||||
return(diagram_rect.toAlignedRect());
|
return(diagram_rect.toAlignedRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,16 +113,16 @@ QRect DiagramPrintDialog::diagramRect(Diagram *diagram,
|
|||||||
*/
|
*/
|
||||||
void DiagramPrintDialog::exec()
|
void DiagramPrintDialog::exec()
|
||||||
{
|
{
|
||||||
|
|
||||||
// prise en compte du nom du document
|
// prise en compte du nom du document
|
||||||
if (!doc_name_.isEmpty()) printer_ -> setDocName(doc_name_);
|
if (!doc_name_.isEmpty()) printer_ -> setDocName(doc_name_);
|
||||||
printer_ -> setCreator(QString("QElectroTech %1").arg(QET::displayedVersion));
|
printer_ -> setCreator(QString("QElectroTech %1").arg(QET::displayedVersion));
|
||||||
|
|
||||||
// affichage d'un premier dialogue demandant a l'utilisateur le type
|
// affichage d'un premier dialogue demandant a l'utilisateur le type
|
||||||
// d'impression qu'il souhaite effectuer
|
// d'impression qu'il souhaite effectuer
|
||||||
buildPrintTypeDialog();
|
buildPrintTypeDialog();
|
||||||
if (dialog_ -> exec() == QDialog::Rejected) return;
|
if (dialog_ -> exec() == QDialog::Rejected) return;
|
||||||
|
|
||||||
// parametrage de l'imprimante en fonction du type d'impression choisi
|
// parametrage de l'imprimante en fonction du type d'impression choisi
|
||||||
if (printer_choice_ -> isChecked()) {
|
if (printer_choice_ -> isChecked()) {
|
||||||
// affichage du dialogue d'impression standard pour parametrer l'imprimante
|
// affichage du dialogue d'impression standard pour parametrer l'imprimante
|
||||||
@@ -141,7 +141,7 @@ void DiagramPrintDialog::exec()
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadPageSetupForCurrentPrinter();
|
loadPageSetupForCurrentPrinter();
|
||||||
|
|
||||||
//Preview before print
|
//Preview before print
|
||||||
#if defined Q_OS_LINUX
|
#if defined Q_OS_LINUX
|
||||||
//Due to some bug with xfwm, we display this dialog has a windows on linux os (X11)
|
//Due to some bug with xfwm, we display this dialog has a windows on linux os (X11)
|
||||||
@@ -159,9 +159,9 @@ void DiagramPrintDialog::exec()
|
|||||||
DiagramsChooser *dc = preview_dialog.diagramsChooser();
|
DiagramsChooser *dc = preview_dialog.diagramsChooser();
|
||||||
dc -> setSelectedAllDiagrams();
|
dc -> setSelectedAllDiagrams();
|
||||||
if (preview_dialog.exec() == QDialog::Rejected) return;
|
if (preview_dialog.exec() == QDialog::Rejected) return;
|
||||||
|
|
||||||
savePageSetupForCurrentPrinter();
|
savePageSetupForCurrentPrinter();
|
||||||
|
|
||||||
// effectue l'impression en elle-meme
|
// effectue l'impression en elle-meme
|
||||||
print(
|
print(
|
||||||
dc -> selectedDiagrams(),
|
dc -> selectedDiagrams(),
|
||||||
@@ -194,7 +194,7 @@ int DiagramPrintDialog::horizontalPagesCount(Diagram *diagram, const ExportPrope
|
|||||||
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
||||||
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
|
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
|
||||||
QRect diagram_rect = diagramRect(diagram, options);
|
QRect diagram_rect = diagramRect(diagram, options);
|
||||||
|
|
||||||
int h_pages_count = int(ceil(qreal(diagram_rect.width()) / qreal(printable_area.width())));
|
int h_pages_count = int(ceil(qreal(diagram_rect.width()) / qreal(printable_area.width())));
|
||||||
return(h_pages_count);
|
return(h_pages_count);
|
||||||
}
|
}
|
||||||
@@ -211,7 +211,7 @@ int DiagramPrintDialog::verticalPagesCount(Diagram *diagram, const ExportPropert
|
|||||||
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
||||||
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
|
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
|
||||||
QRect diagram_rect = diagramRect(diagram, options);
|
QRect diagram_rect = diagramRect(diagram, options);
|
||||||
|
|
||||||
int v_pages_count = int(ceil(qreal(diagram_rect.height()) / qreal(printable_area.height())));
|
int v_pages_count = int(ceil(qreal(diagram_rect.height()) / qreal(printable_area.height())));
|
||||||
return(v_pages_count);
|
return(v_pages_count);
|
||||||
}
|
}
|
||||||
@@ -227,7 +227,7 @@ void DiagramPrintDialog::buildPrintTypeDialog()
|
|||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
dialog_ -> setWindowFlags(Qt::Sheet);
|
dialog_ -> setWindowFlags(Qt::Sheet);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printtype_label_ = new QLabel(tr("Quel type d'impression désirez-vous effectuer ?"));
|
printtype_label_ = new QLabel(tr("Quel type d'impression désirez-vous effectuer ?"));
|
||||||
printer_icon_ = new QLabel();
|
printer_icon_ = new QLabel();
|
||||||
pdf_icon_ = new QLabel();
|
pdf_icon_ = new QLabel();
|
||||||
@@ -239,7 +239,7 @@ void DiagramPrintDialog::buildPrintTypeDialog()
|
|||||||
filepath_field_ = new QLineEdit();
|
filepath_field_ = new QLineEdit();
|
||||||
browse_button_ = new QPushButton("...");
|
browse_button_ = new QPushButton("...");
|
||||||
buttons_ = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
buttons_ = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
dialog_ -> setWindowTitle(tr("Choix du type d'impression"));
|
dialog_ -> setWindowTitle(tr("Choix du type d'impression"));
|
||||||
printer_icon_ -> setPixmap(QET::Icons::Printer.pixmap(32, 32));
|
printer_icon_ -> setPixmap(QET::Icons::Printer.pixmap(32, 32));
|
||||||
pdf_icon_ -> setPixmap(QET::Icons::PDF.pixmap(32, 32));
|
pdf_icon_ -> setPixmap(QET::Icons::PDF.pixmap(32, 32));
|
||||||
@@ -249,19 +249,19 @@ void DiagramPrintDialog::buildPrintTypeDialog()
|
|||||||
|
|
||||||
printer_choice_ -> setChecked(true);
|
printer_choice_ -> setChecked(true);
|
||||||
if (!file_name_.isEmpty()) filepath_field_ -> setText(file_name_ + ".pdf");
|
if (!file_name_.isEmpty()) filepath_field_ -> setText(file_name_ + ".pdf");
|
||||||
|
|
||||||
// connexions signaux / slots
|
// connexions signaux / slots
|
||||||
connect(printer_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
|
connect(printer_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
|
||||||
connect(pdf_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
|
connect(pdf_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
|
||||||
connect(browse_button_, SIGNAL(clicked(bool)), this, SLOT(browseFilePrintTypeDialog()));
|
connect(browse_button_, SIGNAL(clicked(bool)), this, SLOT(browseFilePrintTypeDialog()));
|
||||||
connect(buttons_, SIGNAL(accepted()), this, SLOT(acceptPrintTypeDialog()));
|
connect(buttons_, SIGNAL(accepted()), this, SLOT(acceptPrintTypeDialog()));
|
||||||
connect(buttons_, SIGNAL(rejected()), dialog_, SLOT(reject()));
|
connect(buttons_, SIGNAL(rejected()), dialog_, SLOT(reject()));
|
||||||
|
|
||||||
// organisation graphique
|
// organisation graphique
|
||||||
glayout0_ = new QGridLayout();
|
glayout0_ = new QGridLayout();
|
||||||
hlayout0_ = new QHBoxLayout();
|
hlayout0_ = new QHBoxLayout();
|
||||||
vlayout0_ = new QVBoxLayout();
|
vlayout0_ = new QVBoxLayout();
|
||||||
|
|
||||||
hlayout0_ -> addWidget(filepath_field_);
|
hlayout0_ -> addWidget(filepath_field_);
|
||||||
hlayout0_ -> addWidget(browse_button_);
|
hlayout0_ -> addWidget(browse_button_);
|
||||||
glayout0_ -> addWidget(printer_icon_, 0, 0);
|
glayout0_ -> addWidget(printer_icon_, 0, 0);
|
||||||
@@ -269,13 +269,13 @@ void DiagramPrintDialog::buildPrintTypeDialog()
|
|||||||
glayout0_ -> addWidget(pdf_icon_, 1, 0);
|
glayout0_ -> addWidget(pdf_icon_, 1, 0);
|
||||||
glayout0_ -> addWidget(pdf_choice_, 1, 1);
|
glayout0_ -> addWidget(pdf_choice_, 1, 1);
|
||||||
glayout0_ -> addLayout(hlayout0_, 3, 1);
|
glayout0_ -> addLayout(hlayout0_, 3, 1);
|
||||||
|
|
||||||
vlayout0_ -> addWidget(printtype_label_);
|
vlayout0_ -> addWidget(printtype_label_);
|
||||||
vlayout0_ -> addLayout(glayout0_);
|
vlayout0_ -> addLayout(glayout0_);
|
||||||
vlayout0_ -> addWidget(buttons_);
|
vlayout0_ -> addWidget(buttons_);
|
||||||
|
|
||||||
dialog_ -> setLayout(vlayout0_);
|
dialog_ -> setLayout(vlayout0_);
|
||||||
|
|
||||||
updatePrintTypeDialog();
|
updatePrintTypeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,11 +286,11 @@ void DiagramPrintDialog::updatePrintTypeDialog()
|
|||||||
{
|
{
|
||||||
// imprime-t-on vers un fichier ?
|
// imprime-t-on vers un fichier ?
|
||||||
bool file_print = !(printer_choice_ -> isChecked());
|
bool file_print = !(printer_choice_ -> isChecked());
|
||||||
|
|
||||||
// on n'active le champ fichier que pour les impressions vers un fichier
|
// on n'active le champ fichier que pour les impressions vers un fichier
|
||||||
filepath_field_ -> setEnabled(file_print);
|
filepath_field_ -> setEnabled(file_print);
|
||||||
browse_button_ -> setEnabled(file_print);
|
browse_button_ -> setEnabled(file_print);
|
||||||
|
|
||||||
// on corrige eventuellement l'extension du fichier deja selectionne
|
// on corrige eventuellement l'extension du fichier deja selectionne
|
||||||
if (file_print)
|
if (file_print)
|
||||||
{
|
{
|
||||||
@@ -299,7 +299,9 @@ void DiagramPrintDialog::updatePrintTypeDialog()
|
|||||||
{
|
{
|
||||||
if (pdf_choice_ -> isChecked() && filepath.endsWith(".ps"))
|
if (pdf_choice_ -> isChecked() && filepath.endsWith(".ps"))
|
||||||
{
|
{
|
||||||
QRegExp re("\\.ps$", Qt::CaseInsensitive);
|
QRegularExpression re
|
||||||
|
("\\.ps$",
|
||||||
|
QRegularExpression::CaseInsensitiveOption);
|
||||||
filepath.replace(re, ".pdf");
|
filepath.replace(re, ".pdf");
|
||||||
filepath_field_ -> setText(filepath);
|
filepath_field_ -> setText(filepath);
|
||||||
}
|
}
|
||||||
@@ -331,7 +333,7 @@ void DiagramPrintDialog::acceptPrintTypeDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet a l'utilisateur de choisir un fichier
|
Permet a l'utilisateur de choisir un fichier
|
||||||
*/
|
*/
|
||||||
void DiagramPrintDialog::browseFilePrintTypeDialog()
|
void DiagramPrintDialog::browseFilePrintTypeDialog()
|
||||||
{
|
{
|
||||||
@@ -343,14 +345,14 @@ void DiagramPrintDialog::browseFilePrintTypeDialog()
|
|||||||
extension = ".pdf";
|
extension = ".pdf";
|
||||||
filter = tr("Fichiers PDF (*.pdf)", "file filter");
|
filter = tr("Fichiers PDF (*.pdf)", "file filter");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString filepath = QFileDialog::getSaveFileName(
|
QString filepath = QFileDialog::getSaveFileName(
|
||||||
parentWidget(),
|
parentWidget(),
|
||||||
QString(),
|
QString(),
|
||||||
filepath_field_ -> text(),
|
filepath_field_ -> text(),
|
||||||
filter
|
filter
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
if (!filepath.endsWith(extension)) filepath += extension;
|
if (!filepath.endsWith(extension)) filepath += extension;
|
||||||
filepath = QDir::toNativeSeparators(QDir::cleanPath(filepath));
|
filepath = QDir::toNativeSeparators(QDir::cleanPath(filepath));
|
||||||
@@ -390,13 +392,13 @@ void DiagramPrintDialog::print(const QList<Diagram *> &diagrams,
|
|||||||
#endif
|
#endif
|
||||||
// QPainter utiliser pour effectuer le rendu
|
// QPainter utiliser pour effectuer le rendu
|
||||||
QPainter qp(printer_);
|
QPainter qp(printer_);
|
||||||
|
|
||||||
// cas special : il n'y a aucun schema a imprimer
|
// cas special : il n'y a aucun schema a imprimer
|
||||||
if (!diagrams.count()) {
|
if (!diagrams.count()) {
|
||||||
qp.end();
|
qp.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// imprime les schemas
|
// imprime les schemas
|
||||||
for (int i = 0 ; i < diagrams.count() ; ++ i) {
|
for (int i = 0 ; i < diagrams.count() ; ++ i) {
|
||||||
printDiagram(diagrams[i], fit_page, options, &qp, printer_);
|
printDiagram(diagrams[i], fit_page, options, &qp, printer_);
|
||||||
@@ -422,18 +424,18 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
//qDebug() << printer -> paperSize() << printer -> paperRect() << diagram -> title();
|
//qDebug() << printer -> paperSize() << printer -> paperRect() << diagram -> title();
|
||||||
// l'imprimante utilise-t-elle toute la feuille ?
|
// l'imprimante utilise-t-elle toute la feuille ?
|
||||||
bool full_page = printer -> fullPage();
|
bool full_page = printer -> fullPage();
|
||||||
|
|
||||||
// impression physique (!= fichier PDF)
|
// impression physique (!= fichier PDF)
|
||||||
if (printer -> outputFileName().isEmpty()) {
|
if (printer -> outputFileName().isEmpty()) {
|
||||||
// utiliser cette condition pour agir differemment en cas d'impression physique
|
// utiliser cette condition pour agir differemment en cas d'impression physique
|
||||||
}
|
}
|
||||||
|
|
||||||
saveReloadDiagramParameters(diagram, options, true);
|
saveReloadDiagramParameters(diagram, options, true);
|
||||||
|
|
||||||
// deselectionne tous les elements
|
// deselectionne tous les elements
|
||||||
QList<QGraphicsItem *> selected_elmts = diagram -> selectedItems();
|
QList<QGraphicsItem *> selected_elmts = diagram -> selectedItems();
|
||||||
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(false);
|
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(false);
|
||||||
|
|
||||||
// enleve le flag focusable de tous les elements concernes pour eviter toute reprise de focus par un champ de texte editable
|
// enleve le flag focusable de tous les elements concernes pour eviter toute reprise de focus par un champ de texte editable
|
||||||
QList<QGraphicsItem *> focusable_items;
|
QList<QGraphicsItem *> focusable_items;
|
||||||
foreach (QGraphicsItem *qgi, diagram -> items()) {
|
foreach (QGraphicsItem *qgi, diagram -> items()) {
|
||||||
@@ -442,12 +444,12 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
qgi -> setFlag(QGraphicsItem::ItemIsFocusable, false);
|
qgi -> setFlag(QGraphicsItem::ItemIsFocusable, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// evite toute autre forme d'interaction
|
// evite toute autre forme d'interaction
|
||||||
foreach (QGraphicsView *view, diagram -> views()) {
|
foreach (QGraphicsView *view, diagram -> views()) {
|
||||||
view -> setInteractive(false);
|
view -> setInteractive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect diagram_rect = diagramRect(diagram, options);
|
QRect diagram_rect = diagramRect(diagram, options);
|
||||||
if (fit_page) {
|
if (fit_page) {
|
||||||
// impression adaptee sur une seule page
|
// impression adaptee sur une seule page
|
||||||
@@ -458,19 +460,19 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
//qDebug() << "impression sur une ou plusieurs pages";
|
//qDebug() << "impression sur une ou plusieurs pages";
|
||||||
//qDebug() << " schema :" << diagram_rect;
|
//qDebug() << " schema :" << diagram_rect;
|
||||||
//qDebug() << " page :" << printed_area;
|
//qDebug() << " page :" << printed_area;
|
||||||
|
|
||||||
int used_width = printed_area.width();
|
int used_width = printed_area.width();
|
||||||
int used_height = printed_area.height();
|
int used_height = printed_area.height();
|
||||||
int h_pages_count = horizontalPagesCount(diagram, options, full_page);
|
int h_pages_count = horizontalPagesCount(diagram, options, full_page);
|
||||||
int v_pages_count = verticalPagesCount(diagram, options, full_page);
|
int v_pages_count = verticalPagesCount(diagram, options, full_page);
|
||||||
|
|
||||||
QVector< QVector< QRect > > pages_grid;
|
QVector< QVector< QRect > > pages_grid;
|
||||||
// le schema est imprime sur une matrice de feuilles
|
// le schema est imprime sur une matrice de feuilles
|
||||||
// parcourt les lignes de la matrice
|
// parcourt les lignes de la matrice
|
||||||
int y_offset = 0;
|
int y_offset = 0;
|
||||||
for (int i = 0 ; i < v_pages_count ; ++ i) {
|
for (int i = 0 ; i < v_pages_count ; ++ i) {
|
||||||
pages_grid << QVector< QRect >();
|
pages_grid << QVector< QRect >();
|
||||||
|
|
||||||
// parcourt les feuilles de la ligne
|
// parcourt les feuilles de la ligne
|
||||||
int x_offset = 0;
|
int x_offset = 0;
|
||||||
for (int j = 0 ; j < h_pages_count ; ++ j) {
|
for (int j = 0 ; j < h_pages_count ; ++ j) {
|
||||||
@@ -483,10 +485,10 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
);
|
);
|
||||||
x_offset += used_width;
|
x_offset += used_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
y_offset += used_height;
|
y_offset += used_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ne retient que les pages a imprimer
|
// ne retient que les pages a imprimer
|
||||||
QVector<QRect> pages_to_print;
|
QVector<QRect> pages_to_print;
|
||||||
for (int i = 0 ; i < v_pages_count ; ++ i) {
|
for (int i = 0 ; i < v_pages_count ; ++ i) {
|
||||||
@@ -495,7 +497,7 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//qDebug() << " " << pages_to_print.count() << " pages a imprimer :";
|
//qDebug() << " " << pages_to_print.count() << " pages a imprimer :";
|
||||||
|
|
||||||
// parcourt les pages pour impression
|
// parcourt les pages pour impression
|
||||||
for (int i = 0 ; i < pages_to_print.count() ; ++ i) {
|
for (int i = 0 ; i < pages_to_print.count() ; ++ i) {
|
||||||
QRect current_rect(pages_to_print.at(i));
|
QRect current_rect(pages_to_print.at(i));
|
||||||
@@ -511,20 +513,20 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remet en place les interactions
|
// remet en place les interactions
|
||||||
foreach (QGraphicsView *view, diagram -> views()) {
|
foreach (QGraphicsView *view, diagram -> views()) {
|
||||||
view -> setInteractive(true);
|
view -> setInteractive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// restaure les flags focusable
|
// restaure les flags focusable
|
||||||
foreach (QGraphicsItem *qgi, focusable_items) {
|
foreach (QGraphicsItem *qgi, focusable_items) {
|
||||||
qgi -> setFlag(QGraphicsItem::ItemIsFocusable, true);
|
qgi -> setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// restaure les elements selectionnes
|
// restaure les elements selectionnes
|
||||||
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(true);
|
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(true);
|
||||||
|
|
||||||
saveReloadDiagramParameters(diagram, options, false);
|
saveReloadDiagramParameters(diagram, options, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,7 +539,7 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
|
|||||||
*/
|
*/
|
||||||
void DiagramPrintDialog::saveReloadDiagramParameters(Diagram *diagram, const ExportProperties& options, bool save) {
|
void DiagramPrintDialog::saveReloadDiagramParameters(Diagram *diagram, const ExportProperties& options, bool save) {
|
||||||
static ExportProperties state_exportProperties;
|
static ExportProperties state_exportProperties;
|
||||||
|
|
||||||
if (save) {
|
if (save) {
|
||||||
// memorise les parametres relatifs au schema tout en appliquant les nouveaux
|
// memorise les parametres relatifs au schema tout en appliquant les nouveaux
|
||||||
state_exportProperties = diagram -> applyProperties(options);
|
state_exportProperties = diagram -> applyProperties(options);
|
||||||
@@ -556,11 +558,11 @@ void DiagramPrintDialog::savePageSetupForCurrentPrinter()
|
|||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString printer_section = settingsSectionName(printer_);
|
QString printer_section = settingsSectionName(printer_);
|
||||||
|
|
||||||
while (!settings.group().isEmpty()) settings.endGroup();
|
while (!settings.group().isEmpty()) settings.endGroup();
|
||||||
settings.beginGroup("printers");
|
settings.beginGroup("printers");
|
||||||
settings.beginGroup(printer_section);
|
settings.beginGroup(printer_section);
|
||||||
|
|
||||||
settings.setValue("orientation", printer_ -> orientation() == QPrinter::Portrait ? "portrait" : "landscape");
|
settings.setValue("orientation", printer_ -> orientation() == QPrinter::Portrait ? "portrait" : "landscape");
|
||||||
settings.setValue("papersize", int(printer_ -> paperSize()));
|
settings.setValue("papersize", int(printer_ -> paperSize()));
|
||||||
if (printer_ -> paperSize() == QPrinter::Custom) {
|
if (printer_ -> paperSize() == QPrinter::Custom) {
|
||||||
@@ -592,14 +594,14 @@ void DiagramPrintDialog::loadPageSetupForCurrentPrinter()
|
|||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString printer_section = settingsSectionName(printer_);
|
QString printer_section = settingsSectionName(printer_);
|
||||||
|
|
||||||
while (!settings.group().isEmpty()) settings.endGroup();
|
while (!settings.group().isEmpty()) settings.endGroup();
|
||||||
settings.beginGroup("printers");
|
settings.beginGroup("printers");
|
||||||
if (!settings.childGroups().contains(printer_section)) {
|
if (!settings.childGroups().contains(printer_section)) {
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.beginGroup(printer_section);
|
settings.beginGroup(printer_section);
|
||||||
if (settings.contains("orientation")) {
|
if (settings.contains("orientation")) {
|
||||||
QString value = settings.value("orientation", "landscape").toString();
|
QString value = settings.value("orientation", "landscape").toString();
|
||||||
@@ -618,7 +620,7 @@ void DiagramPrintDialog::loadPageSetupForCurrentPrinter()
|
|||||||
printer_ -> setPaperSize(static_cast<QPrinter::PaperSize>(value));
|
printer_ -> setPaperSize(static_cast<QPrinter::PaperSize>(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal margins[4];
|
qreal margins[4];
|
||||||
printer_ -> getPageMargins(&margins[0], &margins[1], &margins[2], &margins[3], QPrinter::Millimeter);
|
printer_ -> getPageMargins(&margins[0], &margins[1], &margins[2], &margins[3], QPrinter::Millimeter);
|
||||||
QStringList margins_names(QStringList() << "left" << "top" << "right" << "bottom");
|
QStringList margins_names(QStringList() << "left" << "top" << "right" << "bottom");
|
||||||
@@ -629,7 +631,7 @@ void DiagramPrintDialog::loadPageSetupForCurrentPrinter()
|
|||||||
}
|
}
|
||||||
printer_ -> setPageMargins(margins[0], margins[1], margins[2], margins[3], QPrinter::Millimeter);
|
printer_ -> setPageMargins(margins[0], margins[1], margins[2], margins[3], QPrinter::Millimeter);
|
||||||
printer_ -> setFullPage(settings.value("fullpage", "false").toString() == "true");
|
printer_ -> setFullPage(settings.value("fullpage", "false").toString() == "true");
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user