Remove unused class

This commit is contained in:
Claveau Joshua
2020-10-12 21:02:48 +02:00
parent 30f8989e3d
commit 9b0e659300
3 changed files with 2 additions and 259 deletions

View File

@@ -1,194 +0,0 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "diagramschooser.h"
#include "qetproject.h"
#include "diagram.h"
/**
Constructeur
@param project Projet dont il faut afficher les schemas
@param parent QWidget parent de ce widget
*/
DiagramsChooser::DiagramsChooser(QETProject *project, QWidget *parent) :
QScrollArea(parent),
project_(project),
widget0_(nullptr),
vlayout0_(nullptr)
{
setFrameShadow(QFrame::Sunken);
setFrameShape(QFrame::StyledPanel);
setLineWidth(3);
setMidLineWidth(3);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding));
updateList();
setWidget(widget0_);
}
/**
Destructeur
*/
DiagramsChooser::~DiagramsChooser()
{
}
/**
@return le projet dont ce widget affiche les schemas
*/
QETProject *DiagramsChooser::project() const
{
return(project_);
}
/**
@return la liste des schemas selectionnes
*/
QList<Diagram *> DiagramsChooser::selectedDiagrams() const
{
QList<Diagram *> selected_diagrams;
foreach(Diagram *diagram, project_ -> diagrams()) {
QCheckBox *check_box = diagrams_[diagram];
if (check_box && check_box -> isChecked()) {
selected_diagrams << diagram;
}
}
return(selected_diagrams);
}
/**
@return la liste des schemas qui ne sont pas selectionnes
*/
QList<Diagram *> DiagramsChooser::nonSelectedDiagrams() const
{
QList<Diagram *> selected_diagrams;
foreach(Diagram *diagram, diagrams_.keys()) {
if (!(diagrams_[diagram] -> isChecked())) {
selected_diagrams << diagram;
}
}
return(selected_diagrams);
}
/**
@param diagram Un schema cense etre present dans ce widget
*/
bool DiagramsChooser::diagramIsSelected(Diagram *const diagram) const
{
QCheckBox *checkbox = diagrams_.value(diagram);
if (!checkbox) return(false);
return(checkbox -> isChecked());
}
/**
Selectionne les schemas contenus dans la liste diagrams_list
@param diagrams_list Liste de schemas a selectionner
@param select true pour selectionne les schemas de la liste, false pour les
deselectionner
@param reset true pour deselectionner tous les schemas avant de
selectionner ceux de la liste
*/
void DiagramsChooser::setSelectedDiagrams(const QList<Diagram *> &diagrams_list, bool select, bool reset) {
// evite d'emettre une rafale de signaux pour cette operation
blockSignals(true);
// deselectionne tous les schemas si demande
if (reset) {
foreach(QCheckBox *check_box, diagrams_.values()) {
check_box -> setChecked(false);
}
}
int changes = 0;
QCheckBox *check_box;
foreach(Diagram *diagram, diagrams_list) {
if ((check_box = diagrams_[diagram])) {
if (check_box -> isChecked() != select) {
check_box -> setChecked(select);
++ changes;
}
}
}
blockSignals(false);
if (reset || changes) {
emit(selectionChanged());
}
}
/**
Selectionne ou deselectionne tous les schemas
@param select true pour selectionne les schemas de la liste, false pour les
deselectionner
*/
void DiagramsChooser::setSelectedAllDiagrams(bool select) {
blockSignals(true);
foreach(QCheckBox *check_box, diagrams_.values()) {
check_box -> setChecked(select);
}
blockSignals(false);
emit(selectionChanged());
}
/**
Met a jour la liste des schemas du projet
*/
void DiagramsChooser::updateList()
{
if (!project_) return;
// retient la liste des schemas deja selectionnes
QList<Diagram *> selected_diagrams = selectedDiagrams();
// detruit les checkbox existantes
QList<QCheckBox *> checkboxes = diagrams_.values();
qDeleteAll(checkboxes.begin(), checkboxes.end());
buildLayout();
// recree les checkbox necessaires
foreach(Diagram *diagram, project_ -> diagrams()) {
// titre du schema
QString diagram_title = diagram -> title();
if (diagram_title.isEmpty()) diagram_title = tr("Folio sans titre");
QCheckBox *checkbox = new QCheckBox(diagram_title);
checkbox -> setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum));
checkbox -> setChecked(selected_diagrams.contains(diagram));
connect(checkbox, SIGNAL(toggled(bool)), this, SIGNAL(selectionChanged()));
diagrams_.insert(diagram, checkbox);
vlayout0_ -> addWidget(checkbox, 0, Qt::AlignLeft | Qt::AlignTop);
}
}
/**
Met en place la disposition du widget
*/
void DiagramsChooser::buildLayout()
{
if (vlayout0_) return;
vlayout0_ = new QVBoxLayout();
widget0_ = new QWidget();
widget0_ -> setLayout(vlayout0_);
widget0_ -> setMinimumSize(170, 0);
widget0_ -> setMaximumSize(470, 10000);
widget0_ -> setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
}

View File

@@ -1,62 +0,0 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DIAGRAMS_CHOOSER_H
#define DIAGRAMS_CHOOSER_H
#include <QtWidgets>
class QETProject;
class Diagram;
/**
This class provides a widget which allows users to select 0 to n diagrams
among those of a particular project.
*/
class DiagramsChooser : public QScrollArea {
Q_OBJECT
// constructors, destructor
public:
DiagramsChooser(QETProject *, QWidget * = nullptr);
~DiagramsChooser() override;
private:
DiagramsChooser(const DiagramsChooser &);
// methods
public:
QETProject *project() const;
QList<Diagram *> selectedDiagrams() const;
QList<Diagram *> nonSelectedDiagrams() const;
bool diagramIsSelected(Diagram * const) const;
void setSelectedDiagrams(const QList<Diagram *> &, bool = true, bool = true);
void setSelectedAllDiagrams(bool = true);
public slots:
void updateList();
signals:
void selectionChanged();
private:
void buildLayout();
// attributes
private:
QETProject *project_;
QWidget *widget0_;
QVBoxLayout *vlayout0_;
QHash<Diagram *, QCheckBox *> diagrams_;
};
#endif

View File

@@ -45,6 +45,7 @@
void ProjectPrintWindow::launchDialog(QETProject *project, QPrinter::OutputFormat format, QWidget *parent) void ProjectPrintWindow::launchDialog(QETProject *project, QPrinter::OutputFormat format, QWidget *parent)
{ {
auto printer_ = new QPrinter(); auto printer_ = new QPrinter();
printer_->setDocName(ProjectPrintWindow::docName(project));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
printer_->setOrientation(QPrinter::Landscape); printer_->setOrientation(QPrinter::Landscape);
#else #else
@@ -77,12 +78,10 @@ void ProjectPrintWindow::launchDialog(QETProject *project, QPrinter::OutputForma
else //To pdf file else //To pdf file
{ {
auto dir_path = project->currentDir(); auto dir_path = project->currentDir();
auto doc_name = ProjectPrintWindow::docName(project); QString file_name = QDir::toNativeSeparators(QDir::cleanPath(dir_path + "/" + printer_->docName()));
QString file_name = QDir::toNativeSeparators(QDir::cleanPath(dir_path + "/" + doc_name));
if (!file_name.endsWith(".pdf")) { if (!file_name.endsWith(".pdf")) {
file_name.append(".pdf"); file_name.append(".pdf");
} }
printer_->setDocName(doc_name);
printer_->setCreator(QString("QElectroTech %1").arg(QET::displayedVersion)); printer_->setCreator(QString("QElectroTech %1").arg(QET::displayedVersion));
printer_->setOutputFileName(file_name); printer_->setOutputFileName(file_name);
printer_->setOutputFormat(QPrinter::PdfFormat); printer_->setOutputFormat(QPrinter::PdfFormat);