Move file

This commit is contained in:
joshua
2021-05-14 19:33:21 +02:00
parent 21c35bc744
commit 3220a58b96
5 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
/*
Copyright 2006-2021 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 CONFIGPAGE_H
#define CONFIGPAGE_H
#include <QWidget>
/**
This abstract class specifies methods all derived classes should
implement.
*/
class ConfigPage : public QWidget {
Q_OBJECT
public:
/**
Constructor
@param parent Parent QWidget
*/
ConfigPage(QWidget *parent) : QWidget(parent) {};
/// Destructor
~ConfigPage() override {};
/// Apply the configuration after user input
virtual void applyConf() = 0;
/// @return the configuration page title
virtual QString title() const = 0;
/// @return the configuration page icon
virtual QIcon icon() const = 0;
};
#endif

View File

@@ -0,0 +1,357 @@
/*
Copyright 2006-2021 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 "configpages.h"
#include "NameList/nameslist.h"
#include "bordertitleblock.h"
#include "exportpropertieswidget.h"
#include "properties/reportproperties.h"
#include "qetapp.h"
#include "qeticons.h"
#include "qetproject.h"
#include "ui/borderpropertieswidget.h"
#include "ui/conductorpropertieswidget.h"
#include "ui/reportpropertiewidget.h"
#include "ui/titleblockpropertieswidget.h"
#include "ui/xrefpropertieswidget.h"
#include <QFont>
#include <QFontDialog>
#include <QSizePolicy>
#include <utility>
/**
@brief NewDiagramPage::NewDiagramPage
Default constructor
@param project : QETProject
@param parent : QWidget
@param ppd : ProjectPropertiesDialog
*/
NewDiagramPage::NewDiagramPage(QETProject *project,
QWidget *parent,
ProjectPropertiesDialog *ppd) :
ConfigPage (parent),
ppd_ (ppd),
m_project (project)
{
//By default we set the global default properties
// dimensions by default for diagram
bpw = new BorderPropertiesWidget(BorderProperties::defaultProperties());
// default titleblock properties
QList <TitleBlockTemplatesCollection *> c;
c << QETApp::commonTitleBlockTemplatesCollection()
<< QETApp::customTitleBlockTemplatesCollection();
if (m_project) c << m_project->embeddedTitleBlockTemplatesCollection();
ipw = new TitleBlockPropertiesWidget(
c,
TitleBlockProperties::defaultProperties(),
true,
project,
parent);
// default conductor properties
m_cpw = new ConductorPropertiesWidget(ConductorProperties::defaultProperties());
m_cpw->setHiddenAvailableAutonum(true);
// default propertie of report label
rpw = new ReportPropertieWidget(ReportProperties::defaultProperties());
// default properties of xref
xrefpw = new XRefPropertiesWidget(XRefProperties::defaultProperties(), this);
//If there is a project, we edit his properties
if (m_project) {
bpw -> setProperties (m_project -> defaultBorderProperties());
m_cpw -> setProperties (m_project -> defaultConductorProperties());
ipw -> setProperties (m_project -> defaultTitleBlockProperties());
rpw -> setReportProperties (m_project -> defaultReportProperties());
xrefpw -> setProperties (m_project -> defaultXRefProperties());
}
connect(ipw,SIGNAL(openAutoNumFolioEditor(QString)),this,SLOT(changeToAutoFolioTab()));
// main tab widget
QTabWidget *tab_widget = new QTabWidget(this);
QWidget *diagram_widget = new QWidget();
QVBoxLayout *diagram_layout = new QVBoxLayout(diagram_widget);
diagram_layout -> addWidget(bpw);
diagram_layout -> addWidget(ipw);
tab_widget->setMinimumSize(800, 650);
tab_widget -> addTab (diagram_widget, tr("Folio"));
tab_widget -> addTab (m_cpw, tr("Conducteur"));
tab_widget -> addTab (rpw, tr("Reports de folio"));
tab_widget -> addTab (xrefpw, tr("Références croisées"));
QVBoxLayout *vlayout1 = new QVBoxLayout();
vlayout1->addWidget(tab_widget);
setLayout(vlayout1);
}
/**
@brief NewDiagramPage::~NewDiagramPage
*/
NewDiagramPage::~NewDiagramPage()
{
disconnect(ipw,SIGNAL(openAutoNumFolioEditor(QString)),this,SLOT(changeToAutoFolioTab()));
}
/**
@brief NewDiagramPage::applyConf
Apply conf for this page.
If there is a project, save in the project,
else save to the default conf of QElectroTech
*/
void NewDiagramPage::applyConf()
{
if (m_project) { //If project we save to the project
if (m_project -> isReadOnly()) return;
bool modified_project = false;
BorderProperties new_border_prop = bpw -> properties();
if (m_project -> defaultBorderProperties() != new_border_prop) {
m_project -> setDefaultBorderProperties(bpw -> properties());
modified_project = true;
}
TitleBlockProperties new_tbt_prop = ipw -> properties();
if (m_project -> defaultTitleBlockProperties() != new_tbt_prop) {
m_project -> setDefaultTitleBlockProperties(ipw -> properties());
modified_project = true;
}
ConductorProperties new_conductor_prop = m_cpw -> properties();
if (m_project -> defaultConductorProperties() != new_conductor_prop) {
m_project -> setDefaultConductorProperties(m_cpw -> properties());
modified_project = true;
}
QString new_report_prop = rpw -> ReportProperties();
if (m_project -> defaultReportProperties() != new_report_prop) {
m_project -> setDefaultReportProperties(new_report_prop);
modified_project = true;
}
QHash<QString, XRefProperties> new_xref_properties = xrefpw -> properties();
if (m_project -> defaultXRefProperties() != new_xref_properties) {
m_project -> setDefaultXRefProperties(new_xref_properties);
modified_project = true;
}
if (modified_project) {
m_project -> setModified(modified_project);
}
} else { //Else we save to the default value
QSettings settings;
// dimensions des nouveaux schemas
bpw -> properties().toSettings(settings, "diagrameditor/default");
// proprietes du cartouche
ipw-> properties().toSettings(settings, "diagrameditor/default");
// proprietes par defaut des conducteurs
m_cpw -> properties().toSettings(settings, "diagrameditor/defaultconductor");
// default report propertie
rpw->toSettings(settings, "diagrameditor/defaultreport");
// default xref properties
QHash <QString, XRefProperties> hash_xrp = xrefpw -> properties();
foreach (QString key, hash_xrp.keys()) {
XRefProperties xrp = hash_xrp[key];
QString str("diagrameditor/defaultxref");
xrp.toSettings(settings, str += key);
}
}
}
/**
@brief NewDiagramPage::icon
@return icon of this page
*/
QIcon NewDiagramPage::icon() const
{
if (m_project) return(QET::Icons::NewDiagram);
return(QET::Icons::Projects);
}
/**
@brief NewDiagramPage::title
@return title of this page
*/
QString NewDiagramPage::title() const
{
if (m_project) return(tr("Nouveau folio", "configuration page title"));
return(tr("Nouveau projet", "configuration page title"));
}
/**
@brief NewDiagramPage::changeToAutoFolioTab
Set the current tab to Autonum
*/
void NewDiagramPage::changeToAutoFolioTab()
{
if (m_project){
ppd_->setCurrentPage(ProjectPropertiesDialog::Autonum);
ppd_->changeToFolio();
ppd_->exec();
}
}
/**
@brief NewDiagramPage::setFolioAutonum
Set temporary TBP to use in auto folio num
*/
void NewDiagramPage::setFolioAutonum(QString autoNum){
TitleBlockProperties tbptemp = ipw->propertiesAutoNum(std::move(autoNum));
ipw->setProperties(tbptemp);
applyConf();
}
/**
@brief NewDiagramPage::saveCurrentTbp
Save current TBP to retrieve after auto folio num
*/
void NewDiagramPage::saveCurrentTbp()
{
savedTbp = ipw->properties();
}
/**
@brief NewDiagramPage::loadSavedTbp
Retrieve saved auto folio num
*/
void NewDiagramPage::loadSavedTbp()
{
ipw->setProperties(savedTbp);
applyConf();
}
/**
Constructeur
@param parent QWidget parent
*/
ExportConfigPage::ExportConfigPage(QWidget *parent) : ConfigPage(parent) {
// epw contient les options d'export
epw = new ExportPropertiesWidget(ExportProperties::defaultExportProperties());
// layout vertical contenant le titre, une ligne horizontale et epw
QVBoxLayout *vlayout1 = new QVBoxLayout();
QLabel *title = new QLabel(this -> title());
vlayout1 -> addWidget(title);
QFrame *horiz_line = new QFrame();
horiz_line -> setFrameShape(QFrame::HLine);
vlayout1 -> addWidget(horiz_line);
vlayout1 -> addWidget(epw);
vlayout1 -> addStretch();
// activation du layout
setLayout(vlayout1);
}
/// Destructeur
ExportConfigPage::~ExportConfigPage()
{
}
/**
Applique la configuration de cette page
*/
void ExportConfigPage::applyConf()
{
QSettings settings;
epw -> exportProperties().toSettings(settings, "export/default");
}
/// @return l'icone de cette page
QIcon ExportConfigPage::icon() const
{
return(QET::Icons::DocumentExport);
}
/// @return le titre de cette page
QString ExportConfigPage::title() const
{
return(tr("Export", "configuration page title"));
}
/**
Constructeur
@param parent QWidget parent
*/
PrintConfigPage::PrintConfigPage(QWidget *parent) : ConfigPage(parent) {
// epw contient les options d'export
epw = new ExportPropertiesWidget(ExportProperties::defaultPrintProperties());
epw -> setPrintingMode(true);
// layout vertical contenant le titre, une ligne horizontale et epw
QVBoxLayout *vlayout1 = new QVBoxLayout();
QLabel *title = new QLabel(this -> title());
vlayout1 -> addWidget(title);
QFrame *horiz_line = new QFrame();
horiz_line -> setFrameShape(QFrame::HLine);
vlayout1 -> addWidget(horiz_line);
vlayout1 -> addWidget(epw);
vlayout1 -> addStretch();
// activation du layout
setLayout(vlayout1);
}
/// Destructeur
PrintConfigPage::~PrintConfigPage()
{
}
/**
@brief PrintConfigPage::applyConf
Apply the config of this page
*/
void PrintConfigPage::applyConf()
{
QString prefix = "print/default";
QSettings settings;
epw -> exportProperties().toSettings(settings, prefix);
// annule l'enregistrement de certaines proprietes non pertinentes
settings.remove(prefix + "path");
settings.remove(prefix + "format");
settings.remove(prefix + "area");
}
/// @return l'icone de cette page
QIcon PrintConfigPage::icon() const
{
return(QET::Icons::Printer);
}
/// @return le titre de cette page
QString PrintConfigPage::title() const
{
return(tr("Impression", "configuration page title"));
}

View File

@@ -0,0 +1,123 @@
/*
Copyright 2006-2021 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 CONFIG_PAGES_H
#define CONFIG_PAGES_H
#include "configpage.h"
#include "ui/projectpropertiesdialog.h"
#include "ui/titleblockpropertieswidget.h"
#include <QDialog>
#include <QtWidgets>
class BorderPropertiesWidget;
class ConductorPropertiesWidget;
class TitleBlockPropertiesWidget;
class ExportPropertiesWidget;
class ReportPropertieWidget;
class XRefPropertiesWidget;
class QETProject;
class TitleBlockProperties;
/**
@brief The NewDiagramPage class
This configuration page enables users to define the properties of new
diagrams to come.
*/
class NewDiagramPage : public ConfigPage {
Q_OBJECT
// constructors, destructor
public:
NewDiagramPage(QETProject *project = nullptr,
QWidget * = nullptr,
ProjectPropertiesDialog *teste = nullptr);
~NewDiagramPage() override;
private:
NewDiagramPage(const NewDiagramPage &);
public slots:
void changeToAutoFolioTab();
void setFolioAutonum(QString);
void saveCurrentTbp();
void loadSavedTbp();
// methods
public:
void applyConf() override;
QString title() const override;
QIcon icon() const override;
// attributes
private:
ProjectPropertiesDialog *ppd_;
QETProject *m_project; ///< Project to edit propertie
BorderPropertiesWidget *bpw; ///< Widget to edit default diagram dimensions
TitleBlockPropertiesWidget *ipw; ///< Widget to edit default title block properties
ConductorPropertiesWidget *m_cpw; ///< Widget to edit default conductor properties
ReportPropertieWidget *rpw; ///< Widget to edit default report label
XRefPropertiesWidget *xrefpw; ///< Widget to edit default xref properties
TitleBlockProperties savedTbp; ///< Used to save current TBP and retrieve later
};
/**
@brief The ExportConfigPage class
This configuration page enables users to set default export options.
*/
class ExportConfigPage : public ConfigPage {
Q_OBJECT
// constructors, destructor
public:
ExportConfigPage(QWidget * = nullptr);
~ExportConfigPage() override;
private:
ExportConfigPage(const ExportConfigPage &);
// methods
public:
void applyConf() override;
QString title() const override;
QIcon icon() const override;
// attributes
public:
ExportPropertiesWidget *epw;
};
/**
@brief The PrintConfigPage class
This configuration page enables users to set default printing options.
*/
class PrintConfigPage : public ConfigPage {
Q_OBJECT
// constructors, destructor
public:
PrintConfigPage(QWidget * = nullptr);
~PrintConfigPage() override;
private:
PrintConfigPage(const PrintConfigPage &);
// methods
public:
void applyConf() override;
QString title() const override;
QIcon icon() const override;
// attributes
public:
ExportPropertiesWidget *epw;
};
#endif

View File

@@ -0,0 +1,658 @@
/*
Copyright 2006-2021 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 "projectconfigpages.h"
#include "autoNum/numerotationcontext.h"
#include "autoNum/ui/autonumberingmanagementw.h"
#include "autoNum/ui/folioautonumbering.h"
#include "autoNum/ui/formulaautonumberingw.h"
#include "autoNum/ui/selectautonumw.h"
#include "qeticons.h"
#include "qetproject.h"
#include "ui/borderpropertieswidget.h"
#include "ui/conductorpropertieswidget.h"
#include "ui/diagramcontextwidget.h"
#include "ui/reportpropertiewidget.h"
#include "ui/titleblockpropertieswidget.h"
#include "ui/xrefpropertieswidget.h"
//#include "ui_autonumberingmanagementw.h"
#include <QtWidgets>
/**
Constructor
@param project Project this page is editing.
@param parent Parent QWidget
*/
ProjectConfigPage::ProjectConfigPage(QETProject *project, QWidget *parent) :
ConfigPage(parent),
m_project(project)
{
}
/**
Destructor
*/
ProjectConfigPage::~ProjectConfigPage()
{
}
/**
@return the project being edited by this page
*/
QETProject *ProjectConfigPage::project() const
{
return(m_project);
}
/**
@brief ProjectConfigPage::setProject
Set \a new_project as the project being edited by this page.
@param new_project : True to read values from the project
into widgets before setting them read only accordingly,
false otherwise. Defaults to true.
@param read_values
@return the former project
*/
QETProject *ProjectConfigPage::setProject(QETProject *new_project,
bool read_values) {
if (new_project == m_project) return(m_project);
QETProject *former_project = m_project;
m_project = new_project;
if (m_project && read_values) {
readValuesFromProject();
adjustReadOnly();
}
return(former_project);
}
/**
Apply the configuration after user input
*/
void ProjectConfigPage::applyConf()
{
if (!m_project || m_project -> isReadOnly()) return;
applyProjectConf();
}
/**
Initialize the page by calling initWidgets() and initLayout(). Also call
readValuesFromProject() and adjustReadOnly() if a non-zero project has been
set. Typically, you should call this function in your subclass constructor.
*/
void ProjectConfigPage::init()
{
initWidgets();
initLayout();
if (m_project) {
readValuesFromProject();
adjustReadOnly();
}
}
//######################################################################################//
/**
Constructor
@param project Project this page is editing.
@param parent Parent QWidget
*/
ProjectMainConfigPage::ProjectMainConfigPage(QETProject *project, QWidget *parent) :
ProjectConfigPage(project, parent)
{
init();
}
/**
Destructor
*/
ProjectMainConfigPage::~ProjectMainConfigPage()
{
}
/**
@return the title for this page
*/
QString ProjectMainConfigPage::title() const
{
return(tr("Général", "configuration page title"));
}
/**
@return the icon for this page
*/
QIcon ProjectMainConfigPage::icon() const
{
return(QET::Icons::Settings);
}
/**
Apply the configuration after user input
*/
void ProjectMainConfigPage::applyProjectConf()
{
bool modified_project = false;
QString new_title = title_value_ -> text();
if (m_project -> title() != new_title) {
m_project -> setTitle(new_title);
modified_project = true;
}
DiagramContext new_properties = project_variables_ -> context();
if (m_project -> projectProperties() != new_properties) {
m_project -> setProjectProperties(new_properties);
modified_project = true;
}
if (modified_project) {
m_project -> setModified(true);
}
}
/**
@return the project title entered by the user
*/
QString ProjectMainConfigPage::projectTitle() const
{
return(title_value_ -> text());
}
/**
Initialize widgets displayed by the page.
*/
void ProjectMainConfigPage::initWidgets()
{
title_label_ = new QLabel(tr("Titre du projet :", "label when configuring"));
title_value_ = new QLineEdit();
title_information_ = new QLabel(tr("Ce titre sera disponible pour tous les folios de ce projet en tant que %projecttitle.", "informative label"));
project_variables_label_ = new QLabel(
tr(
"Vous pouvez définir ci-dessous des propriétés personnalisées qui seront disponibles pour tous les folios de ce projet (typiquement pour les cartouches).",
"informative label"
)
);
project_variables_label_ -> setWordWrap(true);
project_variables_ = new DiagramContextWidget();
project_variables_ -> setContext(DiagramContext());
}
/**
Initialize the layout of this page.
*/
void ProjectMainConfigPage::initLayout()
{
QVBoxLayout *main_layout0 = new QVBoxLayout();
QHBoxLayout *title_layout0 = new QHBoxLayout();
title_layout0 -> addWidget(title_label_);
title_layout0 -> addWidget(title_value_);
main_layout0 -> addLayout(title_layout0);
main_layout0 -> addWidget(title_information_);
main_layout0 -> addSpacing(10);
main_layout0 -> addWidget(project_variables_label_);
main_layout0 -> addWidget(project_variables_);
setLayout(main_layout0);
this -> setMinimumWidth(680);
}
/**
Read properties from the edited project then fill widgets with them.
*/
void ProjectMainConfigPage::readValuesFromProject()
{
title_value_ -> setText(m_project -> title());
project_variables_ -> setContext(m_project -> projectProperties());
}
/**
Set the content of this page read only if the project is read only,
editable if the project is editable.
*/
void ProjectMainConfigPage::adjustReadOnly()
{
bool is_read_only = m_project -> isReadOnly();
title_value_ -> setReadOnly(is_read_only);
}
//######################################################################################//
/**
@brief ProjectAutoNumConfigPage::ProjectAutoNumConfigPage
Default constructor
@param project : project to edit
@param parent : parent widget
*/
ProjectAutoNumConfigPage::ProjectAutoNumConfigPage (QETProject *project,
QWidget *parent) :
ProjectConfigPage(project, parent)
{
initWidgets();
buildConnections();
readValuesFromProject();
}
/**
@brief ProjectAutoNumConfigPage::title
Title of this config page
@return
*/
QString ProjectAutoNumConfigPage::title() const
{
return tr("Numérotation auto");
}
/**
@brief ProjectAutoNumConfigPage::icon
Icon of this config pafe
@return
*/
QIcon ProjectAutoNumConfigPage::icon() const
{
return QIcon (QET::Icons::AutoNum);
}
/**
@brief ProjectAutoNumConfigPage::applyProjectConf
*/
void ProjectAutoNumConfigPage::applyProjectConf()
{}
/**
@brief ProjectAutoNumConfigPage::initWidgets
Init some widget of this page
*/
void ProjectAutoNumConfigPage::initWidgets()
{
QTabWidget *tab_widget = new QTabWidget(this);
//Management tab
m_amw = new AutoNumberingManagementW(project());
tab_widget->addTab(m_amw, tr("Management"));
//Conductor tab
m_saw_conductor = new SelectAutonumW(1);
tab_widget->addTab(m_saw_conductor, tr("Conducteurs"));
//Element tab
m_saw_element = new SelectAutonumW(0);
tab_widget->addTab(m_saw_element, tr("Eléments"));
//Folio Tab
m_saw_folio = new SelectAutonumW(2);
tab_widget->addTab(m_saw_folio, tr("Folios"));
//AutoNumbering Tab
m_faw = new FolioAutonumberingW(project());
tab_widget->addTab(m_faw, tr("Numérotation auto des folios"));
QHBoxLayout *main_layout = new QHBoxLayout();
main_layout->addWidget(tab_widget);
setLayout(main_layout);
}
/**
@brief ProjectAutoNumConfigPage::readValuesFromProject
Read value stored on project, and update display
*/
void ProjectAutoNumConfigPage::readValuesFromProject()
{
//Conductor Tab
const QStringList strlc(m_project->conductorAutoNum().keys());
m_saw_conductor->contextComboBox()->addItems(strlc);
//Element Tab
const QStringList strle(m_project->elementAutoNum().keys());
m_saw_element->contextComboBox()->addItems(strle);
//Folio Tab
const QStringList strlf(m_project->folioAutoNum().keys());
m_saw_folio->contextComboBox()->addItems(strlf);
//Folio AutoNumbering Tab
m_faw->setContext(m_project->folioAutoNum().keys());
}
/**
@brief ProjectAutoNumConfigPage::adjustReadOnly
set this config page disable if project is read only
*/
void ProjectAutoNumConfigPage::adjustReadOnly()
{
}
/**
@brief ProjectAutoNumConfigPage::buildConnections
setup some connections
*/
void ProjectAutoNumConfigPage::buildConnections()
{
//Management Tab
connect (m_amw, SIGNAL(applyPressed()), this, SLOT(applyManagement()));
//Conductor Tab
connect(m_saw_conductor, &SelectAutonumW::applyPressed, this, &ProjectAutoNumConfigPage::saveContextConductor);
connect(m_saw_conductor, &SelectAutonumW::removeClicked, this, &ProjectAutoNumConfigPage::removeContextConductor);
connect(m_saw_conductor->contextComboBox(), SIGNAL(currentIndexChanged(QString)), this, SLOT(updateContextConductor(QString)));
//Element Tab
connect(m_saw_element, &SelectAutonumW::applyPressed, this, &ProjectAutoNumConfigPage::saveContextElement);
connect(m_saw_element, &SelectAutonumW::removeClicked, this, &ProjectAutoNumConfigPage::removeContextElement);
connect(m_saw_element->contextComboBox(), SIGNAL(currentIndexChanged(QString)), this, SLOT(updateContextElement(QString)));
//Folio Tab
connect(m_saw_folio, &SelectAutonumW::applyPressed, this, &ProjectAutoNumConfigPage::saveContextFolio);
connect(m_saw_folio, &SelectAutonumW::removeClicked, this, &ProjectAutoNumConfigPage::removeContextFolio);
connect(m_saw_folio->contextComboBox(), SIGNAL(currentIndexChanged(QString)), this, SLOT(updateContextFolio(QString)));
// Auto Folio Numbering
connect (m_faw, SIGNAL (applyPressed()), this, SLOT (applyAutoNum()));
}
/**
@brief ProjectAutoNumConfigPage::updateContext_conductor
Display the current selected context for conductor
@param str : key of context stored in project
*/
void ProjectAutoNumConfigPage::updateContextConductor(const QString& str) {
if (str == tr("Nom de la nouvelle numérotation")) m_saw_conductor -> setContext(NumerotationContext());
else m_saw_conductor ->setContext(m_project->conductorAutoNum(str));
}
/**
@brief ProjectAutoNumConfigPage::updateContext_folio
Display the current selected context for folio
@param str : key of context stored in project
*/
void ProjectAutoNumConfigPage::updateContextFolio(const QString& str) {
if (str == tr("Nom de la nouvelle numérotation")) m_saw_folio -> setContext(NumerotationContext());
else m_saw_folio ->setContext(m_project->folioAutoNum(str));
}
/**
@brief ProjectAutoNumConfigPage::updateContextElement
Display the current selected context for element
@param str : key of context stored in project
*/
void ProjectAutoNumConfigPage::updateContextElement(const QString& str)
{
if (str == tr("Nom de la nouvelle numérotation"))
{
m_saw_element->setContext(NumerotationContext());
}
else
{
m_saw_element->setContext(m_project->elementAutoNum(str));
}
}
/**
@brief ProjectAutoNumConfigPage::saveContextElement
Save the current displayed Element formula in project
*/
void ProjectAutoNumConfigPage::saveContextElement()
{
// If the text is the default text "Name of new numerotation" save the edited context
// With the the name "No name"
if (m_saw_element->contextComboBox()->currentText() == tr("Nom de la nouvelle numérotation"))
{
QString title(tr("Sans nom"));
m_project->addElementAutoNum (title, m_saw_element -> toNumContext());
m_project->setCurrrentElementAutonum(title);
m_saw_element->contextComboBox()->addItem(tr("Sans nom"));
}
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
else if ( !m_project -> elementAutoNum().keys().contains( m_saw_element->contextComboBox()->currentText()))
{
m_project->addElementAutoNum(m_saw_element->contextComboBox()->currentText(), m_saw_element->toNumContext());
m_project->setCurrrentElementAutonum(m_saw_element->contextComboBox()->currentText());
m_saw_element->contextComboBox()->addItem(m_saw_element->contextComboBox()->currentText());
}
// Else, the text already exist in the autonum of the project, just update the context
else
{
m_project->addElementAutoNum (m_saw_element->contextComboBox() -> currentText(), m_saw_element -> toNumContext());
m_project->setCurrrentElementAutonum(m_saw_element->contextComboBox()->currentText());
}
}
/**
@brief ProjectAutoNumConfigPage::removeContextElement
Remove from project the current element numerotation context
*/
void ProjectAutoNumConfigPage::removeContextElement()
{
//if default text, return
if (m_saw_element->contextComboBox()->currentText() == tr("Nom de la nouvelle numérotation"))
return;
m_project->removeElementAutoNum (m_saw_element->contextComboBox()->currentText());
m_saw_element->contextComboBox()->removeItem (m_saw_element->contextComboBox()->currentIndex());
}
/**
@brief ProjectAutoNumConfigPage::saveContext_conductor
Save the current displayed conductor context in project
*/
void ProjectAutoNumConfigPage::saveContextConductor()
{
// If the text is the default text "Name of new numerotation" save the edited context
// With the the name "No name"
if (m_saw_conductor->contextComboBox()-> currentText() == tr("Nom de la nouvelle numérotation"))
{
m_project->addConductorAutoNum (tr("Sans nom"), m_saw_conductor -> toNumContext());
project()->setCurrentConductorAutoNum(tr("Sans nom"));
m_saw_conductor->contextComboBox()-> addItem(tr("Sans nom"));
}
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
else if ( !m_project -> conductorAutoNum().keys().contains( m_saw_conductor->contextComboBox()->currentText()))
{
project()->addConductorAutoNum(m_saw_conductor->contextComboBox()->currentText(), m_saw_conductor->toNumContext());
project()->setCurrentConductorAutoNum(m_saw_conductor->contextComboBox()->currentText());
m_saw_conductor->contextComboBox()-> addItem(m_saw_conductor->contextComboBox()->currentText());
}
// Else, the text already exist in the autonum of the project, just update the context
else
{
project()->setCurrentConductorAutoNum(m_saw_conductor->contextComboBox()->currentText());
m_project->addConductorAutoNum (m_saw_conductor->contextComboBox()-> currentText(), m_saw_conductor -> toNumContext());
}
project()->conductorAutoNumAdded();
}
/**
@brief ProjectAutoNumConfigPage::saveContext_folio
Save the current displayed folio context in project
*/
void ProjectAutoNumConfigPage::saveContextFolio()
{
// If the text is the default text "Name of new numerotation" save the edited context
// With the the name "No name"
if (m_saw_folio->contextComboBox() -> currentText() == tr("Nom de la nouvelle numérotation")) {
m_project->addFolioAutoNum (tr("Sans nom"), m_saw_folio -> toNumContext());
m_saw_folio->contextComboBox() -> addItem(tr("Sans nom"));
}
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
else if ( !m_project -> folioAutoNum().keys().contains( m_saw_folio->contextComboBox()->currentText())) {
project()->addFolioAutoNum(m_saw_folio->contextComboBox()->currentText(), m_saw_folio->toNumContext());
m_saw_folio->contextComboBox() -> addItem(m_saw_folio->contextComboBox()->currentText());
}
// Else, the text already exist in the autonum of the project, just update the context
else {
m_project->addFolioAutoNum (m_saw_folio->contextComboBox() -> currentText(), m_saw_folio -> toNumContext());
}
project()->folioAutoNumAdded();
}
/**
@brief ProjectAutoNumConfigPage::applyAutoNum
Apply auto folio numbering, New Folios or Selected Folios
*/
void ProjectAutoNumConfigPage::applyAutoNum()
{
if (m_faw->newFolios){
int foliosRemaining = m_faw->newFoliosNumber();
emit (saveCurrentTbp());
emit (setAutoNum(m_faw->autoNumSelected()));
while (foliosRemaining > 0){
project()->autoFolioNumberingNewFolios();
foliosRemaining = foliosRemaining-1;
}
emit (loadSavedTbp());
}
else{
QString autoNum = m_faw->autoNumSelected();
int fromFolio = m_faw->fromFolio();
int toFolio = m_faw->toFolio();
m_project->autoFolioNumberingSelectedFolios(fromFolio,toFolio,autoNum);
}
}
/**
@brief ProjectAutoNumConfigPage::applyAutoManagement
Apply Management Options in Selected Folios
*/
void ProjectAutoNumConfigPage::applyManagement()
{
// int from;
// int to;
// //Apply to Entire Project
// if (m_amw->ui->m_apply_project_rb->isChecked()) {
// from = 0;
// to = project()->diagrams().size() - 1;
// }
// //Apply to selected Folios
// else {
// from =
//m_amw->ui->m_from_folios_cb->itemData(m_amw->ui->m_from_folios_cb->currentIndex()).toInt();
// to =
//m_amw->ui->m_to_folios_cb->itemData(m_amw->ui->m_to_folios_cb->currentIndex()).toInt();
// }
// //Conductor Autonumbering Update Policy
// //Allow Both Existent and New Conductors
// if (m_amw->ui->m_both_conductor_rb->isChecked()) {
// //Unfreeze Existent and New Conductors
// project()->freezeExistentConductorLabel(false, from,to);
// project()->freezeNewConductorLabel(false, from,to);
// project()->setFreezeNewConductors(false);
// }
// //Allow Only New
// else if (m_amw->ui->m_new_conductor_rb->isChecked()) {
// //Freeze Existent and Unfreeze New Conductors
// project()->freezeExistentConductorLabel(true, from,to);
// project()->freezeNewConductorLabel(false, from,to);
// project()->setFreezeNewConductors(false);
// }
// //Allow Only Existent
// else if (m_amw->ui->m_existent_conductor_rb->isChecked()) {
// //Freeze Existent and Unfreeze New Conductors
// project()->freezeExistentConductorLabel(false, from,to);
// project()->freezeNewConductorLabel(true, from,to);
// project()->setFreezeNewConductors(true);
// }
// //Disable
// else if (m_amw->ui->m_disable_conductor_rb->isChecked()) {
// //Freeze Existent and New Elements, Set Freeze Element Project Wide
// project()->freezeExistentConductorLabel(true, from,to);
// project()->freezeNewConductorLabel(true, from,to);
// project()->setFreezeNewConductors(true);
// }
// //Element Autonumbering Update Policy
// //Allow Both Existent and New Elements
// if (m_amw->ui->m_both_element_rb->isChecked()) {
// //Unfreeze Existent and New Elements
// project()->freezeExistentElementLabel(false, from,to);
// project()->freezeNewElementLabel(false, from,to);
// project()->setFreezeNewElements(false);
// }
// //Allow Only New
// else if (m_amw->ui->m_new_element_rb->isChecked()) {
// //Freeze Existent and Unfreeze New Elements
// project()->freezeExistentElementLabel(true, from,to);
// project()->freezeNewElementLabel(false, from,to);
// project()->setFreezeNewElements(false);
// }
// //Allow Only Existent
// else if (m_amw->ui->m_existent_element_rb->isChecked()) {
// //Freeze New and Unfreeze Existent Elements, Set Freeze Element
//Project Wide project()->freezeExistentElementLabel(false, from,to);
// project()->freezeNewElementLabel(true, from,to);
// project()->setFreezeNewElements(true);
// }
// //Disable
// else if (m_amw->ui->m_disable_element_rb->isChecked()) {
// //Freeze Existent and New Elements, Set Freeze Element Project Wide
// project()->freezeExistentElementLabel(true, from,to);
// project()->freezeNewElementLabel(true, from,to);
// project()->setFreezeNewElements(true);
// }
// //Folio Autonumbering Status
// if (m_amw->ui->m_both_folio_rb->isChecked()) {
// }
// else if (m_amw->ui->m_new_folio_rb->isChecked()) {
// }
// else if (m_amw->ui->m_existent_folio_rb->isChecked()) {
// }
// else if (m_amw->ui->m_disable_folio_rb->isChecked()) {
// }
}
/**
@brief ProjectAutoNumConfigPage::removeContext
Remove from project the current conductor numerotation context
*/
void ProjectAutoNumConfigPage::removeContextConductor()
{
//if default text, return
if ( m_saw_conductor->contextComboBox()-> currentText() == tr("Nom de la nouvelle numérotation") ) return;
m_project -> removeConductorAutoNum (m_saw_conductor->contextComboBox()-> currentText() );
m_saw_conductor->contextComboBox()-> removeItem (m_saw_conductor->contextComboBox()-> currentIndex() );
project()->conductorAutoNumRemoved();
}
/**
@brief ProjectAutoNumConfigPage::removeContext_folio
Remove from project the current folio numerotation context
*/
void ProjectAutoNumConfigPage::removeContextFolio()
{
//if default text, return
if ( m_saw_folio->contextComboBox() -> currentText() == tr("Nom de la nouvelle numérotation") ) return;
m_project -> removeFolioAutoNum (m_saw_folio->contextComboBox() -> currentText() );
m_saw_folio->contextComboBox() -> removeItem (m_saw_folio->contextComboBox() -> currentIndex() );
project()->folioAutoNumRemoved();
}
/**
@brief ProjectAutoNumConfigPage::changeToTab
@param i index
Change to Selected Tab
*/
void ProjectAutoNumConfigPage::changeToTab(int i)
{
qDebug()<<"Q_UNUSED"<<i;
}

View File

@@ -0,0 +1,170 @@
/*
Copyright 2006-2021 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 PROJECTCONFIGPAGES_H
#define PROJECTCONFIGPAGES_H
#include "configpage.h"
class QLabel;
class QLineEdit;
class QETProject;
class BorderPropertiesWidget;
class ConductorPropertiesWidget;
class DiagramContextWidget;
class ReportPropertieWidget;
class XRefPropertiesWidget;
class SelectAutonumW;
class FolioAutonumberingW;
class FormulaAutonumberingW;
class AutoNumberingManagementW;
/**
@brief The ProjectConfigPage class
This class, derived from ConfigPage,
aims at providing the basic skeleton for a project configuration page.
*/
class ProjectConfigPage : public ConfigPage {
Q_OBJECT
// Constructor, destructor
public:
ProjectConfigPage(QETProject *, QWidget * = nullptr);
~ProjectConfigPage() override;
private:
ProjectConfigPage(const ProjectConfigPage &);
// methods
public:
virtual QETProject *project() const;
virtual QETProject *setProject(QETProject *project, bool = true);
void applyConf() override;
/**
Apply configuration to the project after user input. This method is
automatically called when the ConfigDialog is validated, and only if the
project is both non-zero and not read-only.
*/
virtual void applyProjectConf() = 0;
protected:
virtual void init();
/**
Use this pure virtual method to initialize your page widgets.
*/
virtual void initWidgets() = 0;
/**
Use this pure virtual method to initialize your page layout. This method is
always called after initWidgets().
*/
virtual void initLayout() = 0;
/**
Use this pure virtual method to fill widgets with project values.
*/
virtual void readValuesFromProject() = 0;
/**
Use this pure virtual method to adjust the "read only" state of your page
widgets according to the currently edited project.
*/
virtual void adjustReadOnly() = 0;
// attributes
protected:
QETProject *m_project; ///< Currently edited project
};
/**
This page enables users to configure the main properties of a project.
*/
class ProjectMainConfigPage : public ProjectConfigPage {
Q_OBJECT
// Constructor, destructor
public:
ProjectMainConfigPage(QETProject *, QWidget * = nullptr);
~ProjectMainConfigPage() override;
private:
ProjectMainConfigPage(const ProjectMainConfigPage &);
// methods
public:
QString title() const override;
QIcon icon() const override;
void applyProjectConf() override;
QString projectTitle() const;
protected:
void initWidgets() override;
void initLayout() override;
void readValuesFromProject() override;
void adjustReadOnly() override;
// attributes
protected:
QLabel *title_label_;
QLineEdit *title_value_;
QLabel *title_information_;
QLabel *project_variables_label_;
DiagramContextWidget *project_variables_;
};
class ProjectAutoNumConfigPage : public ProjectConfigPage {
Q_OBJECT
//Methods
public:
ProjectAutoNumConfigPage (QETProject *project,
QWidget *parent = nullptr);
QString title() const override;
QIcon icon() const override;
void applyProjectConf() override;
virtual void changeToTab(int);
protected:
void initWidgets() override;
void initLayout() override {}
void readValuesFromProject() override;
void adjustReadOnly() override;
private:
void buildConnections();
private slots:
void updateContextConductor(const QString&);//conductor
void saveContextConductor();
void removeContextConductor();
void updateContextFolio(const QString&);//folio
void saveContextFolio();
void removeContextFolio();
void updateContextElement(const QString&);//element
void saveContextElement();
void removeContextElement();
void applyAutoNum();
void applyManagement();
signals:
void setAutoNum(QString);
void setAutoNum(int,int);
void saveCurrentTbp();
void loadSavedTbp();
//Attributes
private:
SelectAutonumW *m_saw_conductor;
SelectAutonumW *m_saw_folio;
SelectAutonumW *m_saw_element;
FolioAutonumberingW *m_faw;
AutoNumberingManagementW *m_amw;
};
#endif