2014-01-29 19:31:34 +00:00
/*
2020-06-15 17:42:37 +02:00
Copyright 2006 - 2020 The QElectroTech Team
2014-01-29 19:31:34 +00:00
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/>.
*/
2012-06-29 05:21:41 +00:00
# include "projectconfigpages.h"
2020-12-08 19:57:35 +01:00
# include "autoNum/numerotationcontext.h"
# include "autoNum/ui/autonumberingmanagementw.h"
# include "autoNum/ui/folioautonumbering.h"
# include "autoNum/ui/formulaautonumberingw.h"
# include "autoNum/ui/selectautonumw.h"
2012-06-29 05:21:41 +00:00
# include "qeticons.h"
# include "qetproject.h"
2020-12-08 19:57:35 +01:00
# include "ui/borderpropertieswidget.h"
# include "ui/conductorpropertieswidget.h"
# include "ui/diagramcontextwidget.h"
2014-01-18 19:04:39 +00:00
# include "ui/reportpropertiewidget.h"
2020-12-08 19:57:35 +01:00
# include "ui/titleblockpropertieswidget.h"
2014-04-11 09:51:21 +00:00
# include "ui/xrefpropertieswidget.h"
2020-12-10 18:44:03 +01:00
//#include "ui_autonumberingmanagementw.h"
2016-07-20 15:07:21 +00:00
2020-12-08 19:57:35 +01:00
# include <QtWidgets>
2012-06-29 05:21:41 +00:00
/**
Constructor
@ param project Project this page is editing .
@ param parent Parent QWidget
*/
ProjectConfigPage : : ProjectConfigPage ( QETProject * project , QWidget * parent ) :
ConfigPage ( parent ) ,
2016-11-26 17:12:31 +00:00
m_project ( project )
2012-06-29 05:21:41 +00:00
{
}
/**
Destructor
*/
2020-09-07 22:03:40 +02:00
ProjectConfigPage : : ~ ProjectConfigPage ( )
{
2012-06-29 05:21:41 +00:00
}
/**
@ return the project being edited by this page
*/
2020-09-07 22:03:40 +02:00
QETProject * ProjectConfigPage : : project ( ) const
{
2016-11-26 17:12:31 +00:00
return ( m_project ) ;
2012-06-29 05:21:41 +00:00
}
/**
2020-08-20 21:57:35 +02:00
@ brief ProjectConfigPage : : setProject
2012-06-29 05:21:41 +00:00
Set \ a new_project as the project being edited by this page .
2020-08-20 21:57:35 +02:00
@ 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
2012-06-29 05:21:41 +00:00
@ return the former project
*/
2020-08-20 21:58:23 +02:00
QETProject * ProjectConfigPage : : setProject ( QETProject * new_project ,
bool read_values ) {
2016-11-26 17:12:31 +00:00
if ( new_project = = m_project ) return ( m_project ) ;
2012-06-29 05:21:41 +00:00
2016-11-26 17:12:31 +00:00
QETProject * former_project = m_project ;
m_project = new_project ;
if ( m_project & & read_values ) {
2012-06-29 05:21:41 +00:00
readValuesFromProject ( ) ;
adjustReadOnly ( ) ;
}
return ( former_project ) ;
}
/**
Apply the configuration after user input
*/
2020-09-07 22:03:40 +02:00
void ProjectConfigPage : : applyConf ( )
{
2016-11-26 17:12:31 +00:00
if ( ! m_project | | m_project - > isReadOnly ( ) ) return ;
2012-06-29 05:21:41 +00:00
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 .
*/
2020-09-07 22:03:40 +02:00
void ProjectConfigPage : : init ( )
{
2012-06-29 05:21:41 +00:00
initWidgets ( ) ;
initLayout ( ) ;
2016-11-26 17:12:31 +00:00
if ( m_project ) {
2012-06-29 05:21:41 +00:00
readValuesFromProject ( ) ;
adjustReadOnly ( ) ;
}
}
2014-07-31 10:02:33 +00:00
//######################################################################################//
2012-06-29 05:21:41 +00:00
/**
Constructor
@ param project Project this page is editing .
@ param parent Parent QWidget
*/
ProjectMainConfigPage : : ProjectMainConfigPage ( QETProject * project , QWidget * parent ) :
ProjectConfigPage ( project , parent )
{
init ( ) ;
}
/**
Destructor
*/
2020-09-07 22:03:40 +02:00
ProjectMainConfigPage : : ~ ProjectMainConfigPage ( )
{
2012-06-29 05:21:41 +00:00
}
/**
@ return the title for this page
*/
2020-09-07 22:03:40 +02:00
QString ProjectMainConfigPage : : title ( ) const
{
2015-03-02 20:14:56 +00:00
return ( tr ( " Général " , " configuration page title " ) ) ;
2012-06-29 05:21:41 +00:00
}
/**
@ return the icon for this page
*/
2020-09-07 22:03:40 +02:00
QIcon ProjectMainConfigPage : : icon ( ) const
{
2012-06-29 05:21:41 +00:00
return ( QET : : Icons : : Settings ) ;
}
/**
Apply the configuration after user input
*/
2020-09-07 22:03:40 +02:00
void ProjectMainConfigPage : : applyProjectConf ( )
{
2012-07-07 19:45:32 +00:00
bool modified_project = false ;
QString new_title = title_value_ - > text ( ) ;
2016-11-26 17:12:31 +00:00
if ( m_project - > title ( ) ! = new_title ) {
m_project - > setTitle ( new_title ) ;
2012-07-07 19:45:32 +00:00
modified_project = true ;
}
DiagramContext new_properties = project_variables_ - > context ( ) ;
2016-11-26 17:12:31 +00:00
if ( m_project - > projectProperties ( ) ! = new_properties ) {
m_project - > setProjectProperties ( new_properties ) ;
2012-07-07 19:45:32 +00:00
modified_project = true ;
}
if ( modified_project ) {
2016-11-26 17:12:31 +00:00
m_project - > setModified ( true ) ;
2012-07-07 19:45:32 +00:00
}
2012-06-29 05:21:41 +00:00
}
/**
@ return the project title entered by the user
*/
2020-09-07 22:03:40 +02:00
QString ProjectMainConfigPage : : projectTitle ( ) const
{
2012-06-29 05:21:41 +00:00
return ( title_value_ - > text ( ) ) ;
}
/**
Initialize widgets displayed by the page .
*/
2020-09-07 22:03:40 +02:00
void ProjectMainConfigPage : : initWidgets ( )
{
2015-03-02 20:14:56 +00:00
title_label_ = new QLabel ( tr ( " Titre du projet : " , " label when configuring " ) ) ;
2012-06-29 05:21:41 +00:00
title_value_ = new QLineEdit ( ) ;
2016-05-17 19:19:11 +00:00
title_information_ = new QLabel ( tr ( " Ce titre sera disponible pour tous les folios de ce projet en tant que %projecttitle. " , " informative label " ) ) ;
2012-07-01 21:54:07 +00:00
project_variables_label_ = new QLabel (
tr (
2016-05-17 19:19:11 +00:00
" 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). " ,
2012-07-01 21:54:07 +00:00
" informative label "
)
) ;
2012-07-02 06:34:40 +00:00
project_variables_label_ - > setWordWrap ( true ) ;
2012-07-01 21:54:07 +00:00
project_variables_ = new DiagramContextWidget ( ) ;
project_variables_ - > setContext ( DiagramContext ( ) ) ;
2012-06-29 05:21:41 +00:00
}
/**
Initialize the layout of this page .
*/
2020-09-07 22:03:40 +02:00
void ProjectMainConfigPage : : initLayout ( )
{
2018-07-30 15:24:29 +00:00
QVBoxLayout * main_layout0 = new QVBoxLayout ( ) ;
QHBoxLayout * title_layout0 = new QHBoxLayout ( ) ;
2012-06-29 05:21:41 +00:00
title_layout0 - > addWidget ( title_label_ ) ;
title_layout0 - > addWidget ( title_value_ ) ;
main_layout0 - > addLayout ( title_layout0 ) ;
2012-07-02 06:34:40 +00:00
main_layout0 - > addWidget ( title_information_ ) ;
main_layout0 - > addSpacing ( 10 ) ;
2012-07-01 21:54:07 +00:00
main_layout0 - > addWidget ( project_variables_label_ ) ;
main_layout0 - > addWidget ( project_variables_ ) ;
2012-06-29 05:21:41 +00:00
setLayout ( main_layout0 ) ;
2017-12-05 22:27:46 +00:00
this - > setMinimumWidth ( 680 ) ;
2016-05-13 15:00:22 +00:00
2012-06-29 05:21:41 +00:00
}
/**
Read properties from the edited project then fill widgets with them .
*/
2020-09-07 22:03:40 +02:00
void ProjectMainConfigPage : : readValuesFromProject ( )
{
2016-11-26 17:12:31 +00:00
title_value_ - > setText ( m_project - > title ( ) ) ;
project_variables_ - > setContext ( m_project - > projectProperties ( ) ) ;
2012-06-29 05:21:41 +00:00
}
/**
Set the content of this page read only if the project is read only ,
editable if the project is editable .
2020-08-16 11:19:36 +02:00
*/
2020-09-07 22:03:40 +02:00
void ProjectMainConfigPage : : adjustReadOnly ( )
{
2016-11-26 17:12:31 +00:00
bool is_read_only = m_project - > isReadOnly ( ) ;
2012-06-29 05:21:41 +00:00
title_value_ - > setReadOnly ( is_read_only ) ;
}
2014-07-31 10:02:33 +00:00
//######################################################################################//
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : ProjectAutoNumConfigPage
Default constructor
2020-08-20 21:57:35 +02:00
@ param project : project to edit
@ param parent : parent widget
2020-08-16 11:19:36 +02:00
*/
2020-08-20 21:58:23 +02:00
ProjectAutoNumConfigPage : : ProjectAutoNumConfigPage ( QETProject * project ,
QWidget * parent ) :
2014-07-31 10:02:33 +00:00
ProjectConfigPage ( project , parent )
{
initWidgets ( ) ;
buildConnections ( ) ;
readValuesFromProject ( ) ;
}
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : title
Title of this config page
@ return
*/
2020-09-07 22:03:40 +02:00
QString ProjectAutoNumConfigPage : : title ( ) const
{
2020-08-16 14:26:40 +02:00
return tr ( " Numérotation auto " ) ;
2014-07-31 10:02:33 +00:00
}
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : icon
Icon of this config pafe
@ return
*/
2020-09-07 22:03:40 +02:00
QIcon ProjectAutoNumConfigPage : : icon ( ) const
{
2014-08-02 14:53:12 +00:00
return QIcon ( QET : : Icons : : AutoNum ) ;
2014-07-31 10:02:33 +00:00
}
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : applyProjectConf
*/
2020-09-07 22:03:40 +02:00
void ProjectAutoNumConfigPage : : applyProjectConf ( )
{ }
2014-07-31 10:02:33 +00:00
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : initWidgets
Init some widget of this page
*/
2017-02-26 18:30:34 +00:00
void ProjectAutoNumConfigPage : : initWidgets ( )
{
2018-07-30 15:24:29 +00:00
QTabWidget * tab_widget = new QTabWidget ( this ) ;
2017-02-26 18:30:34 +00:00
//Management tab
m_amw = new AutoNumberingManagementW ( project ( ) ) ;
tab_widget - > addTab ( m_amw , tr ( " Management " ) ) ;
//Conductor tab
m_saw_conductor = new SelectAutonumW ( 1 ) ;
2020-08-16 14:26:40 +02:00
tab_widget - > addTab ( m_saw_conductor , tr ( " Conducteurs " ) ) ;
2017-02-26 18:30:34 +00:00
//Element tab
m_saw_element = new SelectAutonumW ( 0 ) ;
2020-08-16 14:26:40 +02:00
tab_widget - > addTab ( m_saw_element , tr ( " Eléments " ) ) ;
2017-02-26 18:30:34 +00:00
//Folio Tab
m_saw_folio = new SelectAutonumW ( 2 ) ;
2020-08-16 14:26:40 +02:00
tab_widget - > addTab ( m_saw_folio , tr ( " Folios " ) ) ;
2017-02-26 18:30:34 +00:00
//AutoNumbering Tab
m_faw = new FolioAutonumberingW ( project ( ) ) ;
2020-08-16 14:26:40 +02:00
tab_widget - > addTab ( m_faw , tr ( " Numérotation auto des folios " ) ) ;
2017-02-26 18:30:34 +00:00
2018-07-30 15:24:29 +00:00
QHBoxLayout * main_layout = new QHBoxLayout ( ) ;
2017-02-26 19:39:36 +00:00
main_layout - > addWidget ( tab_widget ) ;
setLayout ( main_layout ) ;
2014-07-31 10:02:33 +00:00
}
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : readValuesFromProject
Read value stored on project , and update display
*/
2017-02-26 19:39:36 +00:00
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 ( ) ) ;
2014-07-31 10:02:33 +00:00
}
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : adjustReadOnly
set this config page disable if project is read only
*/
2020-09-07 22:03:40 +02:00
void ProjectAutoNumConfigPage : : adjustReadOnly ( )
{
2014-07-31 10:02:33 +00:00
}
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : buildConnections
setup some connections
*/
2017-02-26 19:39:36 +00:00
void ProjectAutoNumConfigPage : : buildConnections ( )
{
//Management Tab
2016-07-20 15:07:21 +00:00
connect ( m_amw , SIGNAL ( applyPressed ( ) ) , this , SLOT ( applyManagement ( ) ) ) ;
2017-02-26 19:39:36 +00:00
//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 ) ) ) ;
2016-05-13 15:00:22 +00:00
2016-11-26 17:12:31 +00:00
//Element Tab
2017-02-26 19:39:36 +00:00
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
2016-05-17 19:19:11 +00:00
connect ( m_faw , SIGNAL ( applyPressed ( ) ) , this , SLOT ( applyAutoNum ( ) ) ) ;
2014-07-31 10:02:33 +00:00
}
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : updateContext_conductor
Display the current selected context for conductor
2020-08-20 21:57:35 +02:00
@ param str : key of context stored in project
2020-08-16 11:19:36 +02:00
*/
2018-07-19 14:14:31 +00:00
void ProjectAutoNumConfigPage : : updateContextConductor ( const QString & str ) {
2016-07-10 01:33:49 +00:00
if ( str = = tr ( " Nom de la nouvelle numérotation " ) ) m_saw_conductor - > setContext ( NumerotationContext ( ) ) ;
2016-11-26 17:12:31 +00:00
else m_saw_conductor - > setContext ( m_project - > conductorAutoNum ( str ) ) ;
2014-07-31 10:02:33 +00:00
}
2016-05-13 15:00:22 +00:00
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : updateContext_folio
Display the current selected context for folio
2020-08-20 21:57:35 +02:00
@ param str : key of context stored in project
2020-08-16 11:19:36 +02:00
*/
2018-07-19 14:14:31 +00:00
void ProjectAutoNumConfigPage : : updateContextFolio ( const QString & str ) {
2016-07-10 01:33:49 +00:00
if ( str = = tr ( " Nom de la nouvelle numérotation " ) ) m_saw_folio - > setContext ( NumerotationContext ( ) ) ;
2016-11-26 17:12:31 +00:00
else m_saw_folio - > setContext ( m_project - > folioAutoNum ( str ) ) ;
2016-05-13 15:00:22 +00:00
}
2014-07-31 10:02:33 +00:00
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : updateContextElement
Display the current selected context for element
2020-08-20 21:57:35 +02:00
@ param str : key of context stored in project
2020-08-16 11:19:36 +02:00
*/
2018-07-19 14:14:31 +00:00
void ProjectAutoNumConfigPage : : updateContextElement ( const QString & str )
2016-11-26 17:12:31 +00:00
{
if ( str = = tr ( " Nom de la nouvelle numérotation " ) )
{
m_saw_element - > setContext ( NumerotationContext ( ) ) ;
}
else
{
m_saw_element - > setContext ( m_project - > elementAutoNum ( str ) ) ;
}
}
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : saveContextElement
Save the current displayed Element formula in project
*/
2016-11-26 17:12:31 +00:00
void ProjectAutoNumConfigPage : : saveContextElement ( )
{
// If the text is the default text "Name of new numerotation" save the edited context
// With the the name "No name"
2017-02-26 19:39:36 +00:00
if ( m_saw_element - > contextComboBox ( ) - > currentText ( ) = = tr ( " Nom de la nouvelle numérotation " ) )
2016-11-26 17:12:31 +00:00
{
QString title ( tr ( " Sans nom " ) ) ;
m_project - > addElementAutoNum ( title , m_saw_element - > toNumContext ( ) ) ;
m_project - > setCurrrentElementAutonum ( title ) ;
2017-02-26 19:39:36 +00:00
m_saw_element - > contextComboBox ( ) - > addItem ( tr ( " Sans nom " ) ) ;
2016-11-26 17:12:31 +00:00
}
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
2017-02-26 19:39:36 +00:00
else if ( ! m_project - > elementAutoNum ( ) . keys ( ) . contains ( m_saw_element - > contextComboBox ( ) - > currentText ( ) ) )
2016-11-26 17:12:31 +00:00
{
2017-02-26 19:39:36 +00:00
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 ( ) ) ;
2016-11-26 17:12:31 +00:00
}
// Else, the text already exist in the autonum of the project, just update the context
else
{
2017-02-26 19:39:36 +00:00
m_project - > addElementAutoNum ( m_saw_element - > contextComboBox ( ) - > currentText ( ) , m_saw_element - > toNumContext ( ) ) ;
m_project - > setCurrrentElementAutonum ( m_saw_element - > contextComboBox ( ) - > currentText ( ) ) ;
2016-11-26 17:12:31 +00:00
}
}
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : removeContextElement
Remove from project the current element numerotation context
*/
2016-11-26 17:12:31 +00:00
void ProjectAutoNumConfigPage : : removeContextElement ( )
{
//if default text, return
2017-02-26 19:39:36 +00:00
if ( m_saw_element - > contextComboBox ( ) - > currentText ( ) = = tr ( " Nom de la nouvelle numérotation " ) )
2016-11-26 17:12:31 +00:00
return ;
2017-02-26 19:39:36 +00:00
m_project - > removeElementAutoNum ( m_saw_element - > contextComboBox ( ) - > currentText ( ) ) ;
m_saw_element - > contextComboBox ( ) - > removeItem ( m_saw_element - > contextComboBox ( ) - > currentIndex ( ) ) ;
2016-07-10 01:33:49 +00:00
}
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : saveContext_conductor
Save the current displayed conductor context in project
*/
2017-02-26 19:39:36 +00:00
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 " ) )
2016-12-06 19:49:18 +00:00
{
2016-11-26 17:12:31 +00:00
m_project - > addConductorAutoNum ( tr ( " Sans nom " ) , m_saw_conductor - > toNumContext ( ) ) ;
2016-12-06 19:49:18 +00:00
project ( ) - > setCurrentConductorAutoNum ( tr ( " Sans nom " ) ) ;
2017-02-26 19:39:36 +00:00
m_saw_conductor - > contextComboBox ( ) - > addItem ( tr ( " Sans nom " ) ) ;
2014-07-31 10:02:33 +00:00
}
2014-08-12 09:41:33 +00:00
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
2017-02-26 19:39:36 +00:00
else if ( ! m_project - > conductorAutoNum ( ) . keys ( ) . contains ( m_saw_conductor - > contextComboBox ( ) - > currentText ( ) ) )
2016-12-06 19:49:18 +00:00
{
2017-02-26 19:39:36 +00:00
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 ( ) ) ;
2014-08-12 09:41:33 +00:00
}
// Else, the text already exist in the autonum of the project, just update the context
2016-12-06 19:49:18 +00:00
else
{
2017-02-26 19:39:36 +00:00
project ( ) - > setCurrentConductorAutoNum ( m_saw_conductor - > contextComboBox ( ) - > currentText ( ) ) ;
m_project - > addConductorAutoNum ( m_saw_conductor - > contextComboBox ( ) - > currentText ( ) , m_saw_conductor - > toNumContext ( ) ) ;
2014-07-31 10:02:33 +00:00
}
2016-07-13 14:57:27 +00:00
project ( ) - > conductorAutoNumAdded ( ) ;
2014-07-31 10:02:33 +00:00
}
2014-08-12 09:41:33 +00:00
2016-05-13 15:00:22 +00:00
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : saveContext_folio
Save the current displayed folio context in project
*/
2020-09-07 22:03:40 +02:00
void ProjectAutoNumConfigPage : : saveContextFolio ( )
{
2016-05-17 19:19:11 +00:00
// If the text is the default text "Name of new numerotation" save the edited context
// With the the name "No name"
2017-02-26 19:39:36 +00:00
if ( m_saw_folio - > contextComboBox ( ) - > currentText ( ) = = tr ( " Nom de la nouvelle numérotation " ) ) {
2016-11-26 17:12:31 +00:00
m_project - > addFolioAutoNum ( tr ( " Sans nom " ) , m_saw_folio - > toNumContext ( ) ) ;
2017-02-26 19:39:36 +00:00
m_saw_folio - > contextComboBox ( ) - > addItem ( tr ( " Sans nom " ) ) ;
2016-05-17 19:19:11 +00:00
}
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
2017-02-26 19:39:36 +00:00
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 ( ) ) ;
2016-05-17 19:19:11 +00:00
}
// Else, the text already exist in the autonum of the project, just update the context
else {
2017-02-26 19:39:36 +00:00
m_project - > addFolioAutoNum ( m_saw_folio - > contextComboBox ( ) - > currentText ( ) , m_saw_folio - > toNumContext ( ) ) ;
2016-05-17 19:19:11 +00:00
}
2016-07-13 14:57:27 +00:00
project ( ) - > folioAutoNumAdded ( ) ;
2016-05-13 15:00:22 +00:00
}
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : applyAutoNum
Apply auto folio numbering , New Folios or Selected Folios
*/
2020-09-07 22:03:40 +02:00
void ProjectAutoNumConfigPage : : applyAutoNum ( )
{
2016-05-13 15:00:22 +00:00
2016-05-17 19:19:11 +00:00
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 {
2016-05-13 15:00:22 +00:00
QString autoNum = m_faw - > autoNumSelected ( ) ;
int fromFolio = m_faw - > fromFolio ( ) ;
int toFolio = m_faw - > toFolio ( ) ;
2016-11-26 17:12:31 +00:00
m_project - > autoFolioNumberingSelectedFolios ( fromFolio , toFolio , autoNum ) ;
2016-05-17 19:19:11 +00:00
}
2016-05-13 15:00:22 +00:00
}
2016-07-20 15:07:21 +00:00
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : applyAutoManagement
Apply Management Options in Selected Folios
*/
2020-09-07 22:03:40 +02:00
void ProjectAutoNumConfigPage : : applyManagement ( )
{
2020-12-10 18:44:03 +01:00
// 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()) {
// }
2016-07-20 15:07:21 +00:00
}
2014-08-12 09:41:33 +00:00
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : removeContext
Remove from project the current conductor numerotation context
*/
2020-09-07 22:03:40 +02:00
void ProjectAutoNumConfigPage : : removeContextConductor ( )
{
2014-08-12 09:41:33 +00:00
//if default text, return
2017-02-26 19:39:36 +00:00
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 ( ) ) ;
2016-07-13 14:57:27 +00:00
project ( ) - > conductorAutoNumRemoved ( ) ;
2014-08-12 09:41:33 +00:00
}
2016-07-10 01:33:49 +00:00
2016-05-13 15:00:22 +00:00
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : removeContext_folio
Remove from project the current folio numerotation context
*/
2020-09-07 22:03:40 +02:00
void ProjectAutoNumConfigPage : : removeContextFolio ( )
{
2016-05-17 19:19:11 +00:00
//if default text, return
2017-02-26 19:39:36 +00:00
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 ( ) ) ;
2016-07-13 14:57:27 +00:00
project ( ) - > folioAutoNumRemoved ( ) ;
2016-05-13 15:00:22 +00:00
}
2016-07-10 01:33:49 +00:00
2016-05-13 15:00:22 +00:00
/**
2020-08-16 11:19:36 +02:00
@ brief ProjectAutoNumConfigPage : : changeToTab
2020-08-20 21:57:35 +02:00
@ param i index
2020-08-16 11:19:36 +02:00
Change to Selected Tab
*/
2017-02-26 18:30:34 +00:00
void ProjectAutoNumConfigPage : : changeToTab ( int i )
{
2020-08-20 21:58:23 +02:00
qDebug ( ) < < " Q_UNUSED " < < i ;
2016-05-13 15:00:22 +00:00
}