Element autonumbering. New tab inside autonumbering menu to assign formulas to element label. XML containing elements labels according ISO/IEC 81346 (./elements/10_electric/qet_labels.xml

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4563 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
dfochi
2016-07-05 20:14:14 +00:00
parent 7a1fec591a
commit 522759e8b3
27 changed files with 1214 additions and 119 deletions

View File

@@ -0,0 +1,576 @@
<?xml version="1.0" encoding="utf-8"?>
<!--This xml is used for retrieving elements default labels according to ISO/IEC 81346-12
A prefix is assigned for each directory. Every element inside that directory
will be assigned the directory prefix unless it has a text with tag "label"
different than "_" inside its .elmt file. If a directory does not have a prefix the
element will assign its parent directory prefix and so on.
Prefix tag MUST be located AFTER its child categorys
Example:
<category name="310_relays_contactors&amp;contacts">
<category name="01_coils">
<prefix>K</prefix>
</category>
<category name="02_contacts_cross_referencing">
<category name="01_auxiliary_contacts"></category>
<category name="02_power_contacts"></category>
<category name="11_delayed_contacts"></category>
<category name="15_protection_contacts"></category>
<prefix>S</prefix>
</category>
Every Coil will be assigned "K" as a label
Auxiliary, power, delayed and protection contacts will be assigned "S" as a label.
-->
<labels>
<category name="10_allpole">
<category name="100_sheet_referencing"></category>
<category name="110_network_supplies"></category>
<category name="114_connections"></category>
<category name="120_cables&amp;wiring"></category>
<category name="130_terminals&amp;terminal_strips">
<category name="90_terminal_strips_diagram"></category>
<prefix>X</prefix>
</category>
<category name="140_connectors&amp;plugs">
<category name="01_connectors_pins"></category>
<category name="10_connectors_circular"></category>
<category name="15_connectors_dsub"></category>
<category name="20_socket_outlets"></category>
<category name="60_connectors_electronics"></category>
<prefix>X</prefix>
</category>
<category name="200_fuses&amp;protective_gears">
<category name="10_fuses">
<prefix>F</prefix>
</category>
<category name="11_circuit_breakers">
<prefix>F</prefix>
</category>
<category name="12_magneto_thermal_circuit_breakers">
<prefix>Q</prefix>
</category>
<category name="20_disconnecting_switches">
<prefix>Q</prefix>
</category>
<category name="30_thermal_relays">
<prefix>F</prefix>
</category>
<category name="50_residual_current_circuit_breaker">
<prefix>Q</prefix>
</category>
<category name="90_overvoltage_protections">
<prefix>F</prefix>
</category>
</category>
<category name="310_relays_contactors&amp;contacts">
<category name="01_coils">
<prefix>K</prefix>
</category>
<category name="02_contacts_cross_referencing">
<category name="01_auxiliary_contacts"></category>
<category name="02_power_contacts"></category>
<category name="11_delayed_contacts"></category>
<category name="15_protection_contacts"></category>
<prefix>S</prefix>
</category>
<category name="03_contacts">
<prefix>S</prefix>
</category>
</category>
<category name="330_transformers&amp;power_supplies">
<category name="10_transformers">
<prefix>T</prefix>
</category>
<category name="30_power_supplies">
<prefix>G</prefix>
</category>
<category name="40_uninterruptible_power_supply">
<prefix>RB</prefix>
</category>
</category>
<category name="340_converters&amp;inverters">
<category name="10_converters">
<prefix>T</prefix>
</category>
<category name="15_measuring_transducers"></category>
<category name="20_current_tansformers">
<prefix>L</prefix>
</category>
<category name="90_filters">
<prefix>KF</prefix>
</category>
</category>
<category name="380_signaling&amp;operating">
<category name="01_human_machine_interface"></category>
<category name="11_optical_signaling">
<prefix>H</prefix>
</category>
<category name="12_acoustic_signaling">
<prefix>H</prefix>
</category>
<category name="20_push_buttons">
<prefix>S</prefix>
</category>
<category name="21_selector_switches">
<prefix>S</prefix>
</category>
<category name="25_lever_switches">
<prefix>S</prefix>
</category>
</category>
<category name="390_sensors&amp;instruments">
<category name="01_sensors_capacitive"></category>
<category name="02_sensors_inductive"></category>
<category name="03_sensors_magnetic"></category>
<category name="04_sensors_optical"></category>
<category name="11_sensors_flow"></category>
<category name="12_sensors_level"></category>
<category name="13_sensors_pressure"></category>
<category name="14_sensors_humidity"></category>
<category name="15_sensors_temperature"></category>
<category name="16_sensors_ultrasonic"></category>
<category name="41_limit_switches">
<prefix>S</prefix>
</category>
<category name="60_timers">
<prefix>H</prefix>
</category>
<category name="70_meters&amp;measuring_indicators"></category>
<prefix>P</prefix>
</category>
<category name="391_consumers&amp;actuators">
<category name="10_engines">
<prefix>M</prefix>
</category>
<category name="20_valves">
<prefix>Y</prefix>
</category>
<category name="30_brakes">
<prefix>YB</prefix>
</category>
<category name="50_heatings">
<prefix>R</prefix>
</category>
<category name="60_lightings">
<prefix>EH</prefix>
</category>
</category>
<category name="392_generators&amp;sources">
<category name="10_generators">
<prefix>B</prefix>
</category>
<category name="20_power_units"></category>
<category name="30_batteries"></category>
<category name="70_voltage_current_sources">
<prefix>B</prefix>
</category>
</category>
<category name="395_electronics&amp;semiconductors">
<category name="01_resistors">
<prefix>R</prefix>
</category>
<category name="02_capacitors">
<prefix>C</prefix>
</category>
<category name="03_inductors">
<prefix>L</prefix>
</category>
<category name="09_disturbances"></category>
<category name="11_diodes">
<prefix>V</prefix>
</category>
<category name="12_transistors"></category>
<category name="13_thyristors"></category>
<category name="24piezo"></category>
<category name="31_integrated_circuits"></category>
<category name="41_PLC&amp;controllers"></category>
<category name="91_computer_science"></category>
</category>
<category name="450_high_voltage"></category>
</category>
<category name="11_singlepole">
<category name="140_connectors&amp;plugs">
<prefix>X</prefix>
</category>
<category name="200_fuses&amp;protective_gears">
<category name="10_fuses">
<prefix>F</prefix>
</category>
<category name="11_circuit_breakers">
<prefix>F</prefix>
</category>
<category name="12_magneto_thermal_circuit_breakers">
<prefix>Q</prefix>
</category>
<category name="20_disconnecting_switches">
<prefix>Q</prefix>
</category>
<category name="30_thermal_relays">
<prefix>F</prefix>
</category>
<category name="50_residual_current_circuit_breaker">
<prefix>Q</prefix>
</category>
</category>
<category name="330_transformers&amp;power_supplies">
<category name="10_transformers">
<prefix>T</prefix>
</category>
<category name="20_current_tansformers">
<prefix>L</prefix>
</category>
</category>
<category name="340_converters&amp;inverters">
<category name="10_converters">
<prefix>T</prefix>
</category>
</category>
<category name="392_generators&amp;sources">
<category name="10_generators"></category>
</category>
<category name="395_electronics&amp;semiconductors">
<category name="10_resistors">
<prefix>R</prefix>
</category>
<category name="20_capacitors">
<prefix>C</prefix>
</category>
<category name="30_inductors">
<prefix>L</prefix>
</category>
</category>
<category name="500_home_installation">
<category name="20_home_appliances"></category>
<category name="30_architectural"></category>
<category name="40_meters"></category>
</category>
</category>
<category name="20_manufacturers_articles">
<category name="abb">
<category name="20_frequency_drives"></category>
</category>
<category name="allen_bradley">
<category name="01_PLC&amp;controllers"></category>
<category name="09_safety_modules">
<category name="10_delayed_outputs"></category>
</category>
<category name="11_safety_switches"></category>
<category name="20_frequency_drives"></category>
</category>
<category name="april">
<category name="5000"></category>
</category>
<category name="arduino"></category>
<category name="aucom">
<category name="10_softstarter"></category>
</category>
<category name="balluff">
<category name="02_sensors_inductive"></category>
<category name="04_sensors_optical"></category>
<category name="51_transformers&amp;power_supply"></category>
</category>
<category name="bamo"></category>
<category name="becker"></category>
<category name="beckhoff">
<category name="80building_management"></category>
</category>
<category name="beka"></category>
<category name="bosch_rexroth"></category>
<category name="bti">
<category name="11_safety_switches"></category>
</category>
<category name="bwo">
<category name="09_vektor_c"></category>
<category name="10_vio64"></category>
</category>
<category name="campbell"></category>
<category name="chauvin_arnoux"></category>
<category name="citec">
<category name="06_sensors_pressure"></category>
</category>
<category name="crouzet">
<category name="01_PLC&amp;controllers"></category>
</category>
<category name="danfoss">
<category name="10_softstarter"></category>
<category name="20_frequency_drives"></category>
</category>
<category name="dold"></category>
<category name="eaton_moeller">
<category name="01_PLC&amp;controllers"></category>
<category name="200_fuses&amp;protective_gears">
<category name="11_circuit_breakers"></category>
<category name="12_magneto_thermal_circuit_breakers"></category>
<category name="20_disconnecting_switches"></category>
</category>
</category>
<category name="eliwel"></category>
<category name="endress_hauser"></category>
<category name="euchner">
<category name="09_safety_modules"></category>
<category name="11_safety_switches"></category>
</category>
<category name="eurotherm">
<category name="10_softstarters"></category>
</category>
<category name="festo"></category>
<category name="finder">
<category name="99_assembly_plan"></category>
</category>
<category name="fuji_electric">
<category name="20_frequency_drives"></category>
</category>
<category name="gce"></category>
<category name="geindustrial">
<category name="10_sofstarters"></category>
</category>
<category name="guitar">
<category name="capacitors"></category>
<category name="ouputjacks"></category>
<category name="pickups"></category>
<category name="potentiometers"></category>
<category name="special_purpose"></category>
<category name="switches"></category>
</category>
<category name="hiquel">
<category name="99_assembly_plan"></category>
</category>
<category name="ifm">
<category name="06_sensors_pressure"></category>
<category name="10_connection_technology"></category>
</category>
<category name="johnson_controls">
<category name="dx">
<category name="modules_extension"></category>
</category>
</category>
<category name="jumo"></category>
<category name="keyence">
<category name="100_safety_light_curtain"></category>
</category>
<category name="knx">
<category name="actionneur"></category>
<category name="capteurs"></category>
<category name="divers"></category>
<category name="poussoirs"></category>
<category name="powersupplies"></category>
<category name="recepteurs"></category>
<category name="transmetteurs"></category>
</category>
<category name="leroy_somer">
<category name="20_frequency_drives"></category>
</category>
<category name="leuze">
<category name="09_safety_modules"></category>
</category>
<category name="litecom"></category>
<category name="murr_elektronik">
<category name="370_fuses&amp;protective_gears"></category>
</category>
<category name="national_instrument">
<category name="01_PLC&amp;controllers">
<category name="crio"></category>
</category>
</category>
<category name="network"></category>
<category name="omron">
<category name="01_PLC&amp;controllers">
<category name="cj1">
<category name="taille1"></category>
<category name="taille2"></category>
</category>
<category name="cj2"></category>
<category name="cqm1">
<category name="taille1"></category>
<category name="taille2"></category>
</category>
</category>
<category name="03_relays"></category>
<category name="09_safety_modules"></category>
<category name="20_frequency_drives"></category>
<category name="99_assembly_plan"></category>
</category>
<category name="parker"></category>
<category name="perske"></category>
<category name="phoenix_contact"></category>
<category name="pic"></category>
<category name="pilz">
<category name="09_safety_modules">
<category name="pnoz"></category>
</category>
<category name="15_safety_switches">
<category name="psen"></category>
</category>
</category>
<category name="pro-face"></category>
<category name="raspberry"></category>
<category name="rittal"></category>
<category name="rockwell">
<category name="10_softstarters"></category>
</category>
<category name="satchwell"></category>
<category name="schaffner">
<category name="99_assembly_plan"></category>
</category>
<category name="schmersal"></category>
<category name="schneider_electric">
<category name="01_PLC&amp;controllers">
<category name="241"></category>
<category name="extension_tm3">
<category name="ana"></category>
<category name="tor"></category>
</category>
<category name="m221"></category>
<category name="m251"></category>
<category name="m340"></category>
<category name="magelis"></category>
<category name="telefast"></category>
<category name="tsx">
<category name="config"></category>
<category name="input"></category>
<category name="output"></category>
</category>
<category name="twido">
<category name="e-s_ana"></category>
</category>
<category name="zelio"></category>
</category>
<category name="08_control_relays"></category>
<category name="09_motor_starters"></category>
<category name="10_softstarter"></category>
<category name="20_frequency_drives"></category>
<category name="81_safety_switches"></category>
<category name="90_TAC_Xenta">
<category name="boitier_mural"></category>
<category name="ecran"></category>
<category name="module_ai"></category>
<category name="module_ao"></category>
<category name="module_di"></category>
<category name="module_repetiteur"></category>
<category name="module_serveur_web"></category>
<category name="module_ui_ao"></category>
<category name="module_ui_tor"></category>
<category name="peripheriques"></category>
<category name="regulateurs"></category>
</category>
<category name="99_assembly_plan"></category>
<category name="preventa">
<category name="09_safety_modules"></category>
</category>
</category>
<category name="sew">
<category name="20_frequency_drives"></category>
</category>
<category name="sfere"></category>
<category name="sick">
<category name="008_safety_controllers"></category>
<category name="009_safety_modules"></category>
<category name="100_safety_light_curtain"></category>
<category name="101_safety_switches"></category>
</category>
<category name="siemens">
<category name="01_PLC&amp;controllers">
<category name="6es5">
<category name="6es5_95"></category>
<category name="carte_entree"></category>
<category name="carte_sortie"></category>
<category name="cpu"></category>
</category>
<category name="6es7">
<category name="alimentations"></category>
<category name="cartes_ana_entree"></category>
<category name="cartes_ana_entree_sortie"></category>
<category name="cartes_ana_sortie"></category>
<category name="cartes_entree"></category>
<category name="cartes_sortie"></category>
</category>
<category name="6es7-1200">
<category name="communication_cards"></category>
<category name="cpu"></category>
<category name="digital_inputs_cards"></category>
<category name="digital_inputs-outputs_cards"></category>
</category>
<category name="6es7-200"></category>
<category name="6es7-312"></category>
<category name="6es7-313"></category>
<category name="6se7-300"></category>
<category name="config"></category>
<category name="cp_343-2"></category>
<category name="et200s">
<category name="cards_and_modules"></category>
<category name="channels"></category>
<category name="io_overviews"></category>
<category name="power_supply"></category>
</category>
<category name="interface_modules"></category>
<category name="logo"></category>
<category name="s7_300">
<category name="cards_and_modules"></category>
<category name="channels"></category>
<category name="io_overviews"></category>
</category>
<category name="sinumerik"></category>
</category>
<category name="02_human_machine_interface">
<category name="terminal_operateur"></category>
</category>
<category name="10_softstarter"></category>
<category name="20_frequency_drives"></category>
<category name="23_sinamics_drives"></category>
<category name="71_asynchronous_motors"></category>
<category name="73_servo_motors"></category>
<category name="80_building_management"></category>
</category>
<category name="sofrel">
<category name="01_PLC&amp;controllers">
<category name="s500"></category>
</category>
</category>
<category name="telemecanique">
<category name="20_frequency_drives"></category>
</category>
<category name="unitronics_plc"></category>
<category name="vega"></category>
<category name="vipa"></category>
<category name="wago">
<category name="01_PLC&amp;controllers"></category>
</category>
<category name="west"></category>
<category name="wit"></category>
</category>
<category name="90_american_standards">
<category name="15_allpole">
<category name="140_connectors&amp;plugs">
<category name="01_connectors_pins"></category>
</category>
<category name="200_fuses&amp;protective_gears">
<category name="11_circuit_breakers"></category>
</category>
</category>
<category name="16_singlepole"></category>
</category>
<category name="98_graphics">
<category name="01_auxiliary_symbols">
<category name="01_cross_ref_symbols">
<category name="01_with_linking_function">
<category name="01_parents"></category>
<category name="02_children"></category>
</category>
<category name="02_without_linking_function"></category>
</category>
<category name="20_switch_positions"></category>
</category>
<category name="11_tags&amp;comments"></category>
<category name="21_forms&amp;tabs"></category>
<category name="99_assembly_plan">
<category name="01_thumbnails_mounting_plate"></category>
<category name="21_signaling&amp;operating">
<category name="21_size_2x2"></category>
<category name="31_size_4x4"></category>
</category>
</category>
</category>
<category name="99_miscellaneous&amp;unsorted"></category>
<report>
<directories>361</directories>
</report>
</labels>

View File

@@ -124,6 +124,16 @@ QString ElementsLocation::baseName() const {
return(QString()); return(QString());
} }
/**
* @brief ElementsLocation::projectId
* This method is used to know if an element belongs to
* a project or not.
* @return Element Project Id
*/
int ElementsLocation::projectId() const {
return QETApp::projectId(m_project);
}
/** /**
* @brief ElementsLocation::collectionPath * @brief ElementsLocation::collectionPath
* Return the path of the represented element relative to collection * Return the path of the represented element relative to collection

View File

@@ -44,6 +44,7 @@ class ElementsLocation
public: public:
QString baseName() const; QString baseName() const;
int projectId() const;
QString collectionPath(bool protocol = true) const; QString collectionPath(bool protocol = true) const;
QString projectCollectionPath() const; QString projectCollectionPath() const;

View File

@@ -101,7 +101,9 @@ class BorderTitleBlock : public QObject
DiagramContext additionalFields() const { return (additional_fields_); } DiagramContext additionalFields() const { return (additional_fields_); }
/// @return the value of the title block /// @return the value of the title block
QString autoPageNum() const { return(btb_auto_page_num_); } QString autoPageNum() const { return(btb_auto_page_num_); }
/// @return the value of the total number of folios
int folioTotal() const { return(folio_total_);}
// methods to get display options // methods to get display options
/// @return true si le cartouche est affiche, false sinon /// @return true si le cartouche est affiche, false sinon
bool titleBlockIsDisplayed() const { return(display_titleblock_); } bool titleBlockIsDisplayed() const { return(display_titleblock_); }

View File

@@ -855,9 +855,19 @@ void Diagram::addItem(QGraphicsItem *item)
{ {
case Element::Type: case Element::Type:
{ {
const Element *elmt = static_cast<const Element*>(item); Element *elmt = static_cast<Element*>(item);
foreach(ElementTextItem *eti, elmt->texts()) foreach(ElementTextItem *eti, elmt->texts())
connect (eti, &ElementTextItem::diagramTextChanged, this, &Diagram::diagramTextChanged); connect (eti, &ElementTextItem::diagramTextChanged, this, &Diagram::diagramTextChanged);
Element::kind linkType = elmt->linkType();
if ((linkType == Element::Simple) ||
(linkType == Element::Master) ||
(linkType == Element::Slave) ||
(linkType == Element::Terminale)) {
CustomElement *celmt = static_cast<CustomElement*>(item);
celmt->parseLabels();
}
elmt->updateLabel();
} }
break; break;

View File

@@ -190,7 +190,7 @@ void PasteDiagramCommand::redo()
//Reset the text field tagged "label //Reset the text field tagged "label
if (ElementTextItem *eti = e ->taggedText("label")) if (ElementTextItem *eti = e ->taggedText("label"))
eti -> setPlainText("_"); eti -> setPlainText("_");
} }
} }

View File

@@ -28,6 +28,7 @@
#include "selectautonumw.h" #include "selectautonumw.h"
#include "numerotationcontext.h" #include "numerotationcontext.h"
#include "folioautonumbering.h" #include "folioautonumbering.h"
#include "elementautonumberingw.h"
/** /**
Constructor Constructor
@param project Project this page is editing. @param project Project this page is editing.
@@ -269,6 +270,10 @@ void ProjectAutoNumConfigPage::initWidgets() {
m_saw = new SelectAutonumW(conductor_tab_widget); m_saw = new SelectAutonumW(conductor_tab_widget);
//Element Tab
element_tab_widget = new QWidget(this);
m_eaw = new ElementAutonumberingW(element_tab_widget);
//Folio Tab //Folio Tab
folio_tab_widget = new QWidget(this); folio_tab_widget = new QWidget(this);
folio_tab_widget->setObjectName("FolioTab"); folio_tab_widget->setObjectName("FolioTab");
@@ -296,7 +301,7 @@ void ProjectAutoNumConfigPage::initWidgets() {
*/ */
void ProjectAutoNumConfigPage::initLayout() { void ProjectAutoNumConfigPage::initLayout() {
//Conductor tab //Conductor Tab
tab_widget->addTab(conductor_tab_widget, tr("Conductor")); tab_widget->addTab(conductor_tab_widget, tr("Conductor"));
QHBoxLayout *context_layout = new QHBoxLayout(); QHBoxLayout *context_layout = new QHBoxLayout();
@@ -312,6 +317,9 @@ void ProjectAutoNumConfigPage::initLayout() {
main_layout->addLayout(aux_layout); main_layout->addLayout(aux_layout);
conductor_tab_widget -> setLayout (main_layout); conductor_tab_widget -> setLayout (main_layout);
//Element Tab
tab_widget->addTab(element_tab_widget,tr ("Element"));
// Folio Tab // Folio Tab
tab_widget->addTab(folio_tab_widget, tr("Folio")); tab_widget->addTab(folio_tab_widget, tr("Folio"));
@@ -345,6 +353,10 @@ void ProjectAutoNumConfigPage::readValuesFromProject() {
foreach (QString str, keys) { m_context_cb -> addItem(str); } foreach (QString str, keys) { m_context_cb -> addItem(str); }
} }
//Element Tab
if (!project_->elementAutoNum().isEmpty())
m_eaw->setContext(project_->elementAutoNum());
//Folio Tab //Folio Tab
QList <QString> keys_2 = project_->folioAutoNum().keys(); QList <QString> keys_2 = project_->folioAutoNum().keys();
if (!keys_2.isEmpty()){ if (!keys_2.isEmpty()){
@@ -375,6 +387,9 @@ void ProjectAutoNumConfigPage::buildConnections() {
connect (m_saw, SIGNAL (applyPressed()), this, SLOT (saveContext())); connect (m_saw, SIGNAL (applyPressed()), this, SLOT (saveContext()));
connect (m_remove_pb, SIGNAL (clicked()), this, SLOT(removeContext())); connect (m_remove_pb, SIGNAL (clicked()), this, SLOT(removeContext()));
//Element Tab
connect (m_eaw, SIGNAL (applyPressed()), this, SLOT (saveContext_3()));
//Folio Tab //Folio Tab
connect (m_context_cb_2, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_2(QString))); connect (m_context_cb_2, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_2(QString)));
connect (m_saw_2, SIGNAL (applyPressed()), this, SLOT (saveContext_2())); connect (m_saw_2, SIGNAL (applyPressed()), this, SLOT (saveContext_2()));
@@ -448,6 +463,14 @@ void ProjectAutoNumConfigPage::saveContext_2() {
} }
} }
/**
* @brief ProjectAutoNumConfigPage::saveContext_3
* Save the current displayed Element formula in project
*/
void ProjectAutoNumConfigPage::saveContext_3() {
project()->addElementAutoNum (m_eaw->formula());
}
/** /**
* @brief ProjectAutoNumConfigPage::applyAutoNum * @brief ProjectAutoNumConfigPage::applyAutoNum
* Apply auto folio numbering, New Folios or Selected Folios * Apply auto folio numbering, New Folios or Selected Folios
@@ -508,7 +531,7 @@ void ProjectAutoNumConfigPage::changeToTab(int i){
*/ */
void ProjectAutoNumConfigPage::tabChanged(int i){ void ProjectAutoNumConfigPage::tabChanged(int i){
if (i>0){ if (i>0){
if (tab_widget->currentIndex()==2){ if (tab_widget->currentIndex()==3){
tab_widget->resize(470,tab_widget->height()); tab_widget->resize(470,tab_widget->height());
} }
else { else {

View File

@@ -35,6 +35,7 @@ class SelectAutonumW;
class QComboBox; class QComboBox;
class QPushButton; class QPushButton;
class FolioAutonumberingW; class FolioAutonumberingW;
class ElementAutonumberingW;
/** /**
This class, derived from ConfigPage, aims at providing the basic skeleton This class, derived from ConfigPage, aims at providing the basic skeleton
@@ -142,10 +143,11 @@ class ProjectAutoNumConfigPage : public ProjectConfigPage {
private slots: private slots:
void updateContext(QString); void updateContext(QString);
void saveContext(); void saveContext();
void removeContext(); void removeContext(); //conductor
void updateContext_2(QString); void updateContext_2(QString);
void saveContext_2(); void saveContext_2(); //folio
void removeContext_2(); void removeContext_2();
void saveContext_3(); //element
void applyAutoNum(); void applyAutoNum();
@@ -159,21 +161,22 @@ class ProjectAutoNumConfigPage : public ProjectConfigPage {
//Attributes //Attributes
private: private:
QTabWidget *tab_widget; QTabWidget *tab_widget;
QWidget *element_widget; QWidget *conductor_tab_widget;
QWidget *conductor_tab_widget; QWidget *element_tab_widget;
QWidget *folio_tab_widget; QWidget *folio_tab_widget;
QWidget *autoNumbering_tab_widget; QWidget *autoNumbering_tab_widget;
QScrollArea *scrollArea; QScrollArea *scrollArea;
QLabel *m_label; QLabel *m_label;
QLabel *m_label_2; QLabel *m_label_2;
QComboBox *m_context_cb; QComboBox *m_context_cb;
QComboBox *m_context_cb_2; QComboBox *m_context_cb_2;
QPushButton *m_remove_pb; QPushButton *m_remove_pb;
QPushButton *m_remove_pb_2; QPushButton *m_remove_pb_2;
SelectAutonumW *m_saw; SelectAutonumW *m_saw;
SelectAutonumW *m_saw_2; SelectAutonumW *m_saw_2;
FolioAutonumberingW *m_faw; FolioAutonumberingW *m_faw;
ElementAutonumberingW *m_eaw;
}; };

View File

@@ -1,17 +1,17 @@
/* /*
Copyright 2006-2016 The QElectroTech Team Copyright 2006-2016 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/>.
*/ */
@@ -23,6 +23,7 @@
#include <iostream> #include <iostream>
#include "terminal.h" #include "terminal.h"
#include "diagramposition.h" #include "diagramposition.h"
#include "diagramcontent.h"
/** /**
Constructeur de la classe CustomElement. Permet d'instancier un element Constructeur de la classe CustomElement. Permet d'instancier un element
@@ -67,7 +68,7 @@ CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qg
buildFromXml(location.xml(), &elmt_state); buildFromXml(location.xml(), &elmt_state);
if (state) *state = elmt_state; if (state) *state = elmt_state;
if (elmt_state) return; if (elmt_state) return;
if (state) *state = 0; if (state) *state = 0;
} }
@@ -86,13 +87,13 @@ CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qg
@return true si le chargement a reussi, false sinon @return true si le chargement a reussi, false sinon
*/ */
bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) { bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
if (xml_def_elmt.tagName() != "definition" || xml_def_elmt.attribute("type") != "element") if (xml_def_elmt.tagName() != "definition" || xml_def_elmt.attribute("type") != "element")
{ {
if (state) *state = 4; if (state) *state = 4;
return(false); return(false);
} }
// verifie basiquement que la version actuelle est capable de lire ce fichier // verifie basiquement que la version actuelle est capable de lire ce fichier
if (xml_def_elmt.hasAttribute("version")) { if (xml_def_elmt.hasAttribute("version")) {
bool conv_ok; bool conv_ok;
@@ -105,7 +106,7 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
) << std::endl; ) << std::endl;
} }
} }
// ces attributs doivent etre presents et valides // ces attributs doivent etre presents et valides
int w, h, hot_x, hot_y; int w, h, hot_x, hot_y;
if ( if (
@@ -118,35 +119,35 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
if (state) *state = 5; if (state) *state = 5;
return(false); return(false);
} }
setSize(w, h); setSize(w, h);
setHotspot(QPoint(hot_x, hot_y)); setHotspot(QPoint(hot_x, hot_y));
//the definition must have childs //the definition must have childs
if (xml_def_elmt.firstChild().isNull()) if (xml_def_elmt.firstChild().isNull())
{ {
if (state) *state = 6; if (state) *state = 6;
return(false); return(false);
} }
// initialisation du QPainter (pour dessiner l'element) // initialisation du QPainter (pour dessiner l'element)
QPainter qp; QPainter qp;
qp.begin(&drawing); qp.begin(&drawing);
QPainter low_zoom_qp; QPainter low_zoom_qp;
low_zoom_qp.begin(&low_zoom_drawing); low_zoom_qp.begin(&low_zoom_drawing);
QPen tmp; QPen tmp;
tmp.setWidthF(1.0); // ligne vaudou pour prise en compte du setCosmetic - ne pas enlever tmp.setWidthF(1.0); // ligne vaudou pour prise en compte du setCosmetic - ne pas enlever
tmp.setCosmetic(true); tmp.setCosmetic(true);
low_zoom_qp.setPen(tmp); low_zoom_qp.setPen(tmp);
// extrait les noms de la definition XML // extrait les noms de la definition XML
names.fromXml(xml_def_elmt); names.fromXml(xml_def_elmt);
setToolTip(name()); setToolTip(name());
//load kind informations //load kind informations
kind_informations_.fromXml(xml_def_elmt.firstChildElement("kindInformations"), "kindInformation"); kind_informations_.fromXml(xml_def_elmt.firstChildElement("kindInformations"), "kindInformation");
// parcours des enfants de la definition : parties du dessin // parcours des enfants de la definition : parties du dessin
int parsed_elements_count = 0; int parsed_elements_count = 0;
for (QDomNode node = xml_def_elmt.firstChild() ; !node.isNull() ; node = node.nextSibling()) { for (QDomNode node = xml_def_elmt.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
@@ -173,11 +174,11 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
} }
} }
} }
// fin du dessin // fin du dessin
qp.end(); qp.end();
low_zoom_qp.end(); low_zoom_qp.end();
// il doit y avoir au moins un element charge // il doit y avoir au moins un element charge
if (!parsed_elements_count) { if (!parsed_elements_count) {
if (state) *state = 8; if (state) *state = 8;
@@ -263,6 +264,89 @@ void CustomElement::paint(QPainter *qp, const QStyleOptionGraphicsItem *options)
} }
} }
/**
Retrieves the element label stored in file ./elements/ * /qet_labels.xml
The labels are applied to all elements inside a folder. If an element
has a specific label, it will be applied. See qet_labels.xml for more
instructions.
*/
void CustomElement::parseLabels() {
if ((this->taggedText("label")!= NULL) && (location().projectId()!=-1) && (this->taggedText("label")->toPlainText()=="_")) { //element is being added
QXmlStreamReader rxml;
QString path[10];
QString prefix;
int i = -1;
ElementsLocation current_location = location();
int dirLevel = -1;
//Add location name to path array
while(current_location.parent().name()!="Imported elements" ) {
i++;
path[i]=current_location.fileName();
current_location = current_location.parent();
dirLevel++;
}
// Only Electric labels created so far
if (current_location.name()!= "Electric") return;
QString qet_labels = "10_electric/qet_labels.xml";
QString filepath = QETApp::commonElementsDir().append(qet_labels);
QFile file(filepath);
file.isReadable();
if (!file.open(QFile::ReadOnly | QFile::Text)) return;
rxml.setDevice(&file);
rxml.readNext();
while(!rxml.atEnd()) {
if (rxml.attributes().value("name").toString() == path[i]) {
rxml.readNext();
i=i-1;
//reached element directory
if (i==0) {
for (int j=i; j<= dirLevel; j = j +1){
//if there is a prefix available apply prefix
if(rxml.name()=="prefix") {
prefix = rxml.readElementText();
DiagramContext &dc = this->rElementInformations();
//if there is a formula to assign, assign it
if (!location().project()->elementAutoNum().isEmpty() && this->linkType()!=Element::Slave) {
QString formula = location().project()->elementAutoNum();
formula.replace("%prefix", prefix);
dc.addValue("label", formula);
this->setTaggedText("label",formula);
} else { //assign only prefix
dc.addValue("label", prefix);
this->setTaggedText("label", prefix);
}
this->setElementInformations(dc);
return;
}
//if there isn't a prefix available, find parent prefix in parent folder
else {
while (rxml.readNextStartElement() && rxml.name()!="prefix") {
rxml.skipCurrentElement();
rxml.readNext();
}
}
}
}
}
rxml.readNext();
}
}
//apply formula to specific label
else if ((this->taggedText("label")!= NULL) && (location().projectId()!=-1) &&
(!location().project()->elementAutoNum().isEmpty()) && (this->linkType()!=Element::Slave)) {
QString formula = location().project()->elementAutoNum();
DiagramContext &dc = this->rElementInformations();
QString prefix = this->taggedText("label")->toPlainText();
formula.replace("%prefix", prefix);
dc.addValue("label", formula);
this->setTaggedText("label",formula);
this->setElementInformations(dc);
}
}
/** /**
Analyse et prend en compte un element XML decrivant une partie du dessin Analyse et prend en compte un element XML decrivant une partie du dessin
de l'element perso. Si l'analyse reussit, la partie est ajoutee au dessin. de l'element perso. Si l'analyse reussit, la partie est ajoutee au dessin.
@@ -294,7 +378,7 @@ bool CustomElement::parseElement(QDomElement &e, QPainter &qp) {
La ligne est definie par les attributs suivants : La ligne est definie par les attributs suivants :
- x1, y1 : reels, coordonnees d'une extremite de la ligne - x1, y1 : reels, coordonnees d'une extremite de la ligne
- x2, y2 : reels, coordonnees de l'autre extremite de la ligne - x2, y2 : reels, coordonnees de l'autre extremite de la ligne
@param e L'element XML a analyser @param e L'element XML a analyser
@param qp Le QPainter a utiliser pour dessiner l'element perso @param qp Le QPainter a utiliser pour dessiner l'element perso
@return true si l'analyse reussit, false sinon @return true si l'analyse reussit, false sinon
@@ -306,19 +390,19 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
if (!QET::attributeIsAReal(e, QString("y1"), &y1)) return(false); if (!QET::attributeIsAReal(e, QString("y1"), &y1)) return(false);
if (!QET::attributeIsAReal(e, QString("x2"), &x2)) return(false); if (!QET::attributeIsAReal(e, QString("x2"), &x2)) return(false);
if (!QET::attributeIsAReal(e, QString("y2"), &y2)) return(false); if (!QET::attributeIsAReal(e, QString("y2"), &y2)) return(false);
Qet::EndType first_end = Qet::endTypeFromString(e.attribute("end1")); Qet::EndType first_end = Qet::endTypeFromString(e.attribute("end1"));
Qet::EndType second_end = Qet::endTypeFromString(e.attribute("end2")); Qet::EndType second_end = Qet::endTypeFromString(e.attribute("end2"));
qreal length1, length2; qreal length1, length2;
if (!QET::attributeIsAReal(e, QString("length1"), &length1)) length1 = 1.5; if (!QET::attributeIsAReal(e, QString("length1"), &length1)) length1 = 1.5;
if (!QET::attributeIsAReal(e, QString("length2"), &length2)) length2 = 1.5; if (!QET::attributeIsAReal(e, QString("length2"), &length2)) length2 = 1.5;
qp.save(); qp.save();
setPainterStyle(e, qp); setPainterStyle(e, qp);
QPen t = qp.pen(); QPen t = qp.pen();
t.setJoinStyle(Qt::MiterJoin); t.setJoinStyle(Qt::MiterJoin);
qp.setPen(t); qp.setPen(t);
QLineF line(x1, y1, x2, y2); QLineF line(x1, y1, x2, y2);
//Add line to the list //Add line to the list
@@ -327,10 +411,10 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
QPointF point1(line.p1()); QPointF point1(line.p1());
QPointF point2(line.p2()); QPointF point2(line.p2());
qreal line_length(line.length()); qreal line_length(line.length());
qreal pen_width = qp.pen().widthF(); qreal pen_width = qp.pen().widthF();
// determine s'il faut dessiner les extremites // determine s'il faut dessiner les extremites
bool draw_1st_end, draw_2nd_end; bool draw_1st_end, draw_2nd_end;
qreal reduced_line_length = line_length - (length1 * PartLine::requiredLengthForEndType(first_end)); qreal reduced_line_length = line_length - (length1 * PartLine::requiredLengthForEndType(first_end));
@@ -341,7 +425,7 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
reduced_line_length = line_length - (length2 * PartLine::requiredLengthForEndType(second_end)); reduced_line_length = line_length - (length2 * PartLine::requiredLengthForEndType(second_end));
} }
draw_2nd_end = second_end && reduced_line_length >= 0; draw_2nd_end = second_end && reduced_line_length >= 0;
// dessine la premiere extremite // dessine la premiere extremite
QPointF start_point, stop_point; QPointF start_point, stop_point;
if (draw_1st_end) { if (draw_1st_end) {
@@ -355,12 +439,12 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
} else if (first_end == Qet::Simple) { } else if (first_end == Qet::Simple) {
qp.drawPolyline(QPolygonF() << four_points1[3] << point1 << four_points1[2]); qp.drawPolyline(QPolygonF() << four_points1[3] << point1 << four_points1[2]);
start_point = point1; start_point = point1;
} else if (first_end == Qet::Triangle) { } else if (first_end == Qet::Triangle) {
qp.drawPolygon(QPolygonF() << four_points1[0] << four_points1[2] << point1 << four_points1[3]); qp.drawPolygon(QPolygonF() << four_points1[0] << four_points1[2] << point1 << four_points1[3]);
start_point = four_points1[0]; start_point = four_points1[0];
} }
// ajuste le depart selon l'epaisseur du trait // ajuste le depart selon l'epaisseur du trait
if (pen_width && (first_end == Qet::Simple || first_end == Qet::Circle)) { if (pen_width && (first_end == Qet::Simple || first_end == Qet::Circle)) {
start_point = QLineF(start_point, point2).pointAt(pen_width / 2.0 / line_length); start_point = QLineF(start_point, point2).pointAt(pen_width / 2.0 / line_length);
@@ -368,7 +452,7 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
} else { } else {
start_point = point1; start_point = point1;
} }
// dessine la seconde extremite // dessine la seconde extremite
if (draw_2nd_end) { if (draw_2nd_end) {
QList<QPointF> four_points2(PartLine::fourEndPoints(point2, point1, length2)); QList<QPointF> four_points2(PartLine::fourEndPoints(point2, point1, length2));
@@ -385,7 +469,7 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
qp.drawPolygon(QPolygonF() << four_points2[0] << four_points2[2] << point2 << four_points2[3] << four_points2[0]); qp.drawPolygon(QPolygonF() << four_points2[0] << four_points2[2] << point2 << four_points2[3] << four_points2[0]);
stop_point = four_points2[0]; stop_point = four_points2[0];
} }
// ajuste l'arrivee selon l'epaisseur du trait // ajuste l'arrivee selon l'epaisseur du trait
if (pen_width && (second_end == Qet::Simple || second_end == Qet::Circle)) { if (pen_width && (second_end == Qet::Simple || second_end == Qet::Circle)) {
stop_point = QLineF(point1, stop_point).pointAt((line_length - (pen_width / 2.0)) / line_length); stop_point = QLineF(point1, stop_point).pointAt((line_length - (pen_width / 2.0)) / line_length);
@@ -393,9 +477,9 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
} else { } else {
stop_point = point2; stop_point = point2;
} }
qp.drawLine(start_point, stop_point); qp.drawLine(start_point, stop_point);
qp.restore(); qp.restore();
return(true); return(true);
} }
@@ -408,7 +492,7 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
- y : ordonnee du coin superieur gauche du rectangle - y : ordonnee du coin superieur gauche du rectangle
- width : largeur du rectangle - width : largeur du rectangle
- height : hauteur du rectangle - height : hauteur du rectangle
@param e L'element XML a analyser @param e L'element XML a analyser
@param qp Le QPainter a utiliser pour dessiner l'element perso @param qp Le QPainter a utiliser pour dessiner l'element perso
@return true si l'analyse reussit, false sinon @return true si l'analyse reussit, false sinon
@@ -427,12 +511,12 @@ bool CustomElement::parseRect(QDomElement &e, QPainter &qp) {
qp.save(); qp.save();
setPainterStyle(e, qp); setPainterStyle(e, qp);
// force le type de jointures pour les rectangles // force le type de jointures pour les rectangles
QPen p = qp.pen(); QPen p = qp.pen();
p.setJoinStyle(Qt::MiterJoin); p.setJoinStyle(Qt::MiterJoin);
qp.setPen(p); qp.setPen(p);
qp.drawRect(QRectF(rect_x, rect_y, rect_w, rect_h)); qp.drawRect(QRectF(rect_x, rect_y, rect_w, rect_h));
qp.restore(); qp.restore();
return(true); return(true);
@@ -445,7 +529,7 @@ bool CustomElement::parseRect(QDomElement &e, QPainter &qp) {
- x : abscisse du coin superieur gauche de la quadrature du cercle - x : abscisse du coin superieur gauche de la quadrature du cercle
- y : ordonnee du coin superieur gauche de la quadrature du cercle - y : ordonnee du coin superieur gauche de la quadrature du cercle
- diameter : diametre du cercle - diameter : diametre du cercle
@param e L'element XML a analyser @param e L'element XML a analyser
@param qp Le QPainter a utiliser pour dessiner l'element perso @param qp Le QPainter a utiliser pour dessiner l'element perso
@return true si l'analyse reussit, false sinon @return true si l'analyse reussit, false sinon
@@ -477,7 +561,7 @@ bool CustomElement::parseCircle(QDomElement &e, QPainter &qp) {
- y : ordonnee du coin superieur gauche du rectangle dans lequel s'inscrit l'ellipse - y : ordonnee du coin superieur gauche du rectangle dans lequel s'inscrit l'ellipse
- width : dimension de la diagonale horizontale de l'ellipse - width : dimension de la diagonale horizontale de l'ellipse
- height : dimension de la diagonale verticale de l'ellipse - height : dimension de la diagonale verticale de l'ellipse
@param e L'element XML a analyser @param e L'element XML a analyser
@param qp Le QPainter a utiliser pour dessiner l'element perso @param qp Le QPainter a utiliser pour dessiner l'element perso
@return true si l'analyse reussit, false sinon @return true si l'analyse reussit, false sinon
@@ -515,7 +599,7 @@ bool CustomElement::parseEllipse(QDomElement &e, QPainter &qp) {
- start : angle de depart : l'angle "0 degre" est a trois heures - start : angle de depart : l'angle "0 degre" est a trois heures
- angle : etendue (en degres) de l'arc de cercle ; une valeur positive - angle : etendue (en degres) de l'arc de cercle ; une valeur positive
va dans le sens contraire des aiguilles d'une montre va dans le sens contraire des aiguilles d'une montre
@param e L'element XML a analyser @param e L'element XML a analyser
@param qp Le QPainter a utiliser pour dessiner l'element perso @param qp Le QPainter a utiliser pour dessiner l'element perso
@return true si l'analyse reussit, false sinon @return true si l'analyse reussit, false sinon
@@ -529,7 +613,7 @@ bool CustomElement::parseArc(QDomElement &e, QPainter &qp) {
if (!QET::attributeIsAReal(e, QString("height"), &arc_h)) return(false); if (!QET::attributeIsAReal(e, QString("height"), &arc_h)) return(false);
if (!QET::attributeIsAReal(e, QString("start"), &arc_s)) return(false); if (!QET::attributeIsAReal(e, QString("start"), &arc_s)) return(false);
if (!QET::attributeIsAReal(e, QString("angle"), &arc_a)) return(false); if (!QET::attributeIsAReal(e, QString("angle"), &arc_a)) return(false);
qp.save(); qp.save();
setPainterStyle(e, qp); setPainterStyle(e, qp);
@@ -612,15 +696,15 @@ bool CustomElement::parseText(QDomElement &e, QPainter &qp) {
!QET::attributeIsAnInteger(e, "size", &size) ||\ !QET::attributeIsAnInteger(e, "size", &size) ||\
!e.hasAttribute("text") !e.hasAttribute("text")
) return(false); ) return(false);
qp.save(); qp.save();
setPainterStyle(e, qp); setPainterStyle(e, qp);
// determine la police a utiliser et en recupere les metriques associees // determine la police a utiliser et en recupere les metriques associees
QFont used_font = QETApp::diagramTextsFont(size); QFont used_font = QETApp::diagramTextsFont(size);
QFontMetrics qfm(used_font); QFontMetrics qfm(used_font);
QColor text_color = (e.attribute("color") != "white"? Qt::black : Qt::white); QColor text_color = (e.attribute("color") != "white"? Qt::black : Qt::white);
// instancie un QTextDocument (comme la classe QGraphicsTextItem) pour // instancie un QTextDocument (comme la classe QGraphicsTextItem) pour
// generer le rendu graphique du texte // generer le rendu graphique du texte
QTextDocument text_document; QTextDocument text_document;
@@ -638,18 +722,18 @@ bool CustomElement::parseText(QDomElement &e, QPainter &qp) {
eti -> setRotationAngle(original_rotation_angle); eti -> setRotationAngle(original_rotation_angle);
eti -> setFollowParentRotations(e.attribute("rotate") == "true"); eti -> setFollowParentRotations(e.attribute("rotate") == "true");
list_texts_ << eti; list_texts_ << eti;
// Se positionne aux coordonnees indiquees dans la description du texte // Se positionne aux coordonnees indiquees dans la description du texte
qp.setTransform(QTransform(), false); qp.setTransform(QTransform(), false);
qp.translate(pos_x, pos_y); qp.translate(pos_x, pos_y);
// Pivote le systeme de coordonnees du QPainter pour effectuer le rendu // Pivote le systeme de coordonnees du QPainter pour effectuer le rendu
// dans le bon sens // dans le bon sens
qreal default_rotation_angle = 0.0; qreal default_rotation_angle = 0.0;
if (QET::attributeIsAReal(e, "rotation", &default_rotation_angle)) { if (QET::attributeIsAReal(e, "rotation", &default_rotation_angle)) {
qp.rotate(default_rotation_angle); qp.rotate(default_rotation_angle);
} }
/* /*
Deplace le systeme de coordonnees du QPainter pour effectuer le rendu au Deplace le systeme de coordonnees du QPainter pour effectuer le rendu au
bon endroit ; note : on soustrait l'ascent() de la police pour bon endroit ; note : on soustrait l'ascent() de la police pour
@@ -657,12 +741,12 @@ bool CustomElement::parseText(QDomElement &e, QPainter &qp) {
indiquee correspond a la baseline. indiquee correspond a la baseline.
*/ */
QPointF qpainter_offset(0.0, -qfm.ascent()); QPointF qpainter_offset(0.0, -qfm.ascent());
//adjusts the offset by the margin of the text document //adjusts the offset by the margin of the text document
text_document.setDocumentMargin(0.0); text_document.setDocumentMargin(0.0);
qp.translate(qpainter_offset); qp.translate(qpainter_offset);
// force the palette used to render the QTextDocument // force the palette used to render the QTextDocument
QAbstractTextDocumentLayout::PaintContext ctx; QAbstractTextDocumentLayout::PaintContext ctx;
ctx.palette.setColor(QPalette::Text, text_color); ctx.palette.setColor(QPalette::Text, text_color);
@@ -691,26 +775,38 @@ ElementTextItem *CustomElement::parseInput(QDomElement &e) {
!QET::attributeIsAReal(e, "y", &pos_y) ||\ !QET::attributeIsAReal(e, "y", &pos_y) ||\
!QET::attributeIsAnInteger(e, "size", &size) !QET::attributeIsAnInteger(e, "size", &size)
) return(0); ) return(0);
ElementTextItem *eti = new ElementTextItem(e.attribute("text"), this); ElementTextItem *eti = new ElementTextItem(e.attribute("text"), this);
eti -> setFont(QETApp::diagramTextsFont(size)); eti -> setFont(QETApp::diagramTextsFont(size));
eti -> setTagg(e.attribute("tagg", "other")); eti -> setTagg(e.attribute("tagg", "other"));
if (e.attribute("tagg")=="label") {
DiagramContext &dc = this->rElementInformations();
dc.addValue("label", e.attribute("text"));
this->setElementInformations(dc);
this->setTaggedText("label", e.attribute("text"));
}
else if (e.attribute("tagg")=="function") {
DiagramContext &dc = this->rElementInformations();
dc.addValue("function", e.attribute("text"));
this->setElementInformations(dc);
}
// position the text field // position the text field
eti -> setOriginalPos(QPointF(pos_x, pos_y)); eti -> setOriginalPos(QPointF(pos_x, pos_y));
eti -> setPos(pos_x, pos_y); eti -> setPos(pos_x, pos_y);
// rotation of the text field // rotation of the text field
qreal original_rotation_angle = 0.0; qreal original_rotation_angle = 0.0;
QET::attributeIsAReal(e, "rotation", &original_rotation_angle); QET::attributeIsAReal(e, "rotation", &original_rotation_angle);
eti -> setOriginalRotationAngle(original_rotation_angle); eti -> setOriginalRotationAngle(original_rotation_angle);
eti -> setRotationAngle(original_rotation_angle); eti -> setRotationAngle(original_rotation_angle);
// behavior when the parent element is rotated // behavior when the parent element is rotated
eti -> setFollowParentRotations(e.attribute("rotate") == "true"); eti -> setFollowParentRotations(e.attribute("rotate") == "true");
list_texts_ << eti; list_texts_ << eti;
return(eti); return(eti);
} }
@@ -720,7 +816,7 @@ ElementTextItem *CustomElement::parseInput(QDomElement &e) {
Une borne est definie par les attributs suivants : Une borne est definie par les attributs suivants :
- x, y : coordonnees de la borne - x, y : coordonnees de la borne
- orientation : orientation de la borne = Nord (n), Sud (s), Est (e) ou Ouest (w) - orientation : orientation de la borne = Nord (n), Sud (s), Est (e) ou Ouest (w)
@param e L'element XML a analyser @param e L'element XML a analyser
@return Un pointeur vers l'objet Terminal ainsi cree, 0 sinon @return Un pointeur vers l'objet Terminal ainsi cree, 0 sinon
*/ */
@@ -762,12 +858,12 @@ void CustomElement::setQPainterAntiAliasing(QPainter &qp, bool aa) {
- une pour l'Est - une pour l'Est
- une pour le Sud - une pour le Sud
- une pour l'Ouest - une pour l'Ouest
Pour chaque orientation, on indique si elle est : Pour chaque orientation, on indique si elle est :
- l'orientation par defaut : d - l'orientation par defaut : d
- une orientation autorisee : y - une orientation autorisee : y
- une orientation interdire : n - une orientation interdire : n
Exemple : "dnny" represente un element par defaut oriente vers le nord et qui Exemple : "dnny" represente un element par defaut oriente vers le nord et qui
peut etre oriente vers l'ouest mais pas vers le sud ou vers l'est. peut etre oriente vers l'ouest mais pas vers le sud ou vers l'est.
@param e Element XML @param e Element XML
@@ -826,7 +922,7 @@ bool CustomElement::validOrientationAttribute(const QDomElement &e) {
- hachures gauche - hachures gauche
- hachures droite - hachures droite
- none : pas de contour - none : pas de contour
Les autres valeurs ne sont pas prises en compte. Les autres valeurs ne sont pas prises en compte.
@param e L'element XML a parser @param e L'element XML a parser
@param qp Le QPainter a modifier en fonction des styles @param qp Le QPainter a modifier en fonction des styles
@@ -835,14 +931,14 @@ void CustomElement::setPainterStyle(QDomElement &e, QPainter &qp) {
// recupere le QPen et la QBrush du QPainter // recupere le QPen et la QBrush du QPainter
QPen pen = qp.pen(); QPen pen = qp.pen();
QBrush brush = qp.brush(); QBrush brush = qp.brush();
// attributs par defaut // attributs par defaut
pen.setJoinStyle(Qt::BevelJoin); pen.setJoinStyle(Qt::BevelJoin);
pen.setCapStyle(Qt::SquareCap); pen.setCapStyle(Qt::SquareCap);
// recupere la liste des couples style / valeur // recupere la liste des couples style / valeur
QStringList styles = e.attribute("style").split(";", QString::SkipEmptyParts); QStringList styles = e.attribute("style").split(";", QString::SkipEmptyParts);
// agit sur le QPen et la QBrush en fonction des valeurs rencontrees // agit sur le QPen et la QBrush en fonction des valeurs rencontrees
QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*$"); QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*$");
foreach (QString style, styles) { foreach (QString style, styles) {
@@ -949,11 +1045,11 @@ void CustomElement::setPainterStyle(QDomElement &e, QPainter &qp) {
} }
} }
} }
// affectation du QPen et de la QBrush modifies au QPainter // affectation du QPen et de la QBrush modifies au QPainter
qp.setPen(pen); qp.setPen(pen);
qp.setBrush(brush); qp.setBrush(brush);
// mise en place (ou non) de l'antialiasing // mise en place (ou non) de l'antialiasing
setQPainterAntiAliasing(qp, e.attribute("antialias") == "true"); setQPainterAntiAliasing(qp, e.attribute("antialias") == "true");
} }

View File

@@ -72,6 +72,7 @@ class CustomElement : public FixedElement
virtual QList<QVector<qreal> *> arcs() const; virtual QList<QVector<qreal> *> arcs() const;
virtual int terminalsCount() const; virtual int terminalsCount() const;
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *); virtual void paint(QPainter *, const QStyleOptionGraphicsItem *);
virtual void parseLabels();
QString typeId() const; QString typeId() const;
ElementsLocation location() const; ElementsLocation location() const;
QString name() const; QString name() const;
@@ -93,6 +94,7 @@ class CustomElement : public FixedElement
virtual bool validOrientationAttribute(const QDomElement &); virtual bool validOrientationAttribute(const QDomElement &);
virtual void setPainterStyle(QDomElement &, QPainter &); virtual void setPainterStyle(QDomElement &, QPainter &);
ElementTextItem* setTaggedText(const QString &tagg, const QString &newstr, const bool noeditable=false); ElementTextItem* setTaggedText(const QString &tagg, const QString &newstr, const bool noeditable=false);
}; };
/** /**

View File

@@ -659,5 +659,7 @@ QString Element::assignVariables(QString label, Element *elmt){
label.replace("%F", elmt->diagram() -> border_and_titleblock.folio()); label.replace("%F", elmt->diagram() -> border_and_titleblock.folio());
label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number())); label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter()); label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
label.replace("%id", QString::number(elmt->diagram()->folioIndex()+1));
label.replace("%total", QString::number(elmt->diagram()->border_and_titleblock.folioTotal()));
return label; return label;
} }

View File

@@ -120,8 +120,9 @@ class Element : public QetGraphicsItem {
kind link_type_; kind link_type_;
signals: signals:
void linkedElementChanged(); //This signal is emtied when the linked elements with this element change void linkedElementChanged(); //This signal is emited when the linked elements with this element change
void elementInfoChange(DiagramContext old_info, DiagramContext new_info); void elementInfoChange(DiagramContext old_info, DiagramContext new_info);
void updateLabel(); //This signal is emited to update element's label
//METHODS related to information //METHODS related to information
public: public:
@@ -162,7 +163,7 @@ class Element : public QetGraphicsItem {
// selection-related methods // selection-related methods
void select(); void select();
void deselect(); void deselect();
virtual void rotateBy(const qreal &); virtual void rotateBy(const qreal &);
virtual void editProperty(); virtual void editProperty();

View File

@@ -254,6 +254,7 @@ void ElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
if (m_first_move) { if (m_first_move) {
//We signal the beginning of movement to the parent diagram //We signal the beginning of movement to the parent diagram
int moved_texts_count = diagram_ptr -> beginMoveElementTexts(this); int moved_texts_count = diagram_ptr -> beginMoveElementTexts(this);
parent_element_ -> setHighlighted(true);
//If there is one texte to move, we highlight the parent element. //If there is one texte to move, we highlight the parent element.
if (moved_texts_count == 1 && parent_element_) { if (moved_texts_count == 1 && parent_element_) {

View File

@@ -33,8 +33,9 @@ MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qg
{ {
link_type_ = Master; link_type_ = Master;
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext))); connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
connect(this, SIGNAL(xChanged()),this, SLOT(changeElementInfo())); connect(this, SIGNAL(xChanged()), this, SLOT(changeElementInfo()));
connect(this, SIGNAL(yChanged()),this, SLOT(changeElementInfo())); connect(this, SIGNAL(yChanged()), this, SLOT(changeElementInfo()));
connect(this, SIGNAL(updateLabel()), this, SLOT(changeElementInfo()));
} }
/** /**
@@ -61,8 +62,9 @@ void MasterElement::linkToElement(Element *elmt)
if (!cri_) cri_ = new CrossRefItem(this); //create cross ref item if not yet if (!cri_) cri_ = new CrossRefItem(this); //create cross ref item if not yet
connect(elmt, SIGNAL(xChanged()), cri_, SLOT(updateLabel())); connect(elmt, SIGNAL(xChanged()), cri_, SLOT(updateLabel()));
connect(elmt, SIGNAL(yChanged()), cri_, SLOT(updateLabel())); connect(elmt, SIGNAL(yChanged()), cri_, SLOT(updateLabel()));
connect(elmt, SIGNAL(updateLabel()), cri_, SLOT(updateLabel()));
cri_ -> updateLabel(); cri_ -> updateLabel();
emit linkedElementChanged(); emit linkedElementChanged();
} }
@@ -98,8 +100,9 @@ void MasterElement::unlinkElement(Element *elmt)
elmt -> setHighlighted (false); elmt -> setHighlighted (false);
//update the graphics cross ref //update the graphics cross ref
disconnect(elmt, SIGNAL(xChanged()), cri_, SLOT(updateLabel())); disconnect(elmt, SIGNAL(xChanged()), cri_, SLOT(updateLabel()));
disconnect(elmt, SIGNAL(yChanged()), cri_, SLOT(updateLabel())); disconnect(elmt, SIGNAL(yChanged()), cri_, SLOT(updateLabel()));
disconnect(elmt, SIGNAL(updateLabel()), cri_, SLOT(updateLabel()));
cri_ -> updateLabel(); cri_ -> updateLabel();
aboutDeleteXref(); aboutDeleteXref();

View File

@@ -219,10 +219,7 @@ void ReportElement::updateLabel()
{ {
Element *elmt = connected_elements.at(0); Element *elmt = connected_elements.at(0);
QString label = label_; QString label = label_;
label.replace("%f", QString::number(elmt->diagram()->folioIndex()+1)); label = assignVariables(label,elmt);
label.replace("%F", elmt->diagram() -> border_and_titleblock.folio());
label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
m_text_field -> setPlainText(label); m_text_field -> setPlainText(label);
} }
else else

View File

@@ -35,6 +35,7 @@ SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qg
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext))); connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
connect(this, SIGNAL(xChanged()),this, SLOT(changeElementInfo())); connect(this, SIGNAL(xChanged()),this, SLOT(changeElementInfo()));
connect(this, SIGNAL(yChanged()),this, SLOT(changeElementInfo())); connect(this, SIGNAL(yChanged()),this, SLOT(changeElementInfo()));
connect(this, SIGNAL(updateLabel()),this,SLOT(changeElementInfo()));
} }
/** /**

View File

@@ -64,6 +64,7 @@ void SlaveElement::linkToElement(Element *elmt)
connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel())); connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
connect(diagram()->project(), SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(updateLabel())); connect(diagram()->project(), SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(updateLabel()));
connect(elmt -> diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateLabel())); connect(elmt -> diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateLabel()));
connect(elmt, SIGNAL(updateLabel()), this, SLOT(updateLabel()));
updateLabel(); updateLabel();
elmt -> linkToElement(this); elmt -> linkToElement(this);
@@ -104,6 +105,7 @@ void SlaveElement::unlinkElement(Element *elmt)
disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel())); disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
disconnect(diagram()->project(), SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(updateLabel())); disconnect(diagram()->project(), SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(updateLabel()));
disconnect(elmt -> diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateLabel())); disconnect(elmt -> diagram(), SIGNAL(XRefPropertiesChanged()), this, SLOT(updateLabel()));
disconnect(elmt, SIGNAL(updateLabel()), this, SLOT(updateLabel()));
delete Xref_item; Xref_item = NULL; delete Xref_item; Xref_item = NULL;

View File

@@ -408,6 +408,14 @@ QHash <QString, NumerotationContext> QETProject::conductorAutoNum() const {
return m_conductor_autonum; return m_conductor_autonum;
} }
/**
* @brief QETProject::elementAutoNum
* @return Formula of element autonum stored in project
*/
QString QETProject::elementAutoNum() const {
return m_element_autonum;
}
/** /**
* @brief QETProject::folioAutoNum * @brief QETProject::folioAutoNum
* @return All value of conductor autonum stored in project * @return All value of conductor autonum stored in project
@@ -427,6 +435,15 @@ void QETProject::addConductorAutoNum(QString key, NumerotationContext context) {
m_conductor_autonum.insert(key, context); m_conductor_autonum.insert(key, context);
} }
/**
* @brief QETProject::addElementAutoNum
* Add the new formula
* @param formula
*/
void QETProject::addElementAutoNum(QString formula) {
m_element_autonum = formula;
}
/** /**
* @brief QETProject::addFolioAutoNum * @brief QETProject::addFolioAutoNum
* Add a new folio numerotation context. If key already exist, * Add a new folio numerotation context. If key already exist,
@@ -1176,7 +1193,7 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
m_default_xref_properties = XRefProperties:: defaultProperties(); m_default_xref_properties = XRefProperties:: defaultProperties();
//Read values indicate in project //Read values indicate in project
QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums, folio_autonums; QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums, folio_autonums, element_autonums;
for (QDomNode child = newdiagrams_elmt.firstChild() ; !child.isNull() ; child = child.nextSibling()) for (QDomNode child = newdiagrams_elmt.firstChild() ; !child.isNull() ; child = child.nextSibling())
{ {
@@ -1197,9 +1214,11 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
conds_autonums = child_elmt; conds_autonums = child_elmt;
else if (child_elmt.tagName()== "folio_autonums") else if (child_elmt.tagName()== "folio_autonums")
folio_autonums = child_elmt; folio_autonums = child_elmt;
else if (child_elmt.tagName()== "element_autonums")
element_autonums = child_elmt;
} }
// size, titleblock, conductor, report, conductor autonum // size, titleblock, conductor, report, conductor autonum, folio autonum, element autonum
if (!border_elmt.isNull()) default_border_properties_.fromXml(border_elmt); if (!border_elmt.isNull()) default_border_properties_.fromXml(border_elmt);
if (!titleblock_elmt.isNull()) default_titleblock_properties_.fromXml(titleblock_elmt); if (!titleblock_elmt.isNull()) default_titleblock_properties_.fromXml(titleblock_elmt);
if (!conductors_elmt.isNull()) default_conductor_properties_.fromXml(conductors_elmt); if (!conductors_elmt.isNull()) default_conductor_properties_.fromXml(conductors_elmt);
@@ -1231,6 +1250,10 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
m_folio_autonum.insert(elmt.attribute("title"), nc); m_folio_autonum.insert(elmt.attribute("title"), nc);
} }
} }
if (!element_autonums.isNull())
{
m_element_autonum = element_autonums.attribute("formula");
}
} }
/** /**
@@ -1300,6 +1323,11 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) {
folio_autonums.appendChild(folio_autonum); folio_autonums.appendChild(folio_autonum);
} }
xml_element.appendChild(folio_autonums); xml_element.appendChild(folio_autonums);
//Export Element Autonums
QDomElement element_autonums = xml_document.createElement("element_autonums");
element_autonums.setAttribute("formula", m_element_autonum);
xml_element.appendChild(element_autonums);
} }
/** /**

View File

@@ -109,11 +109,13 @@ class QETProject : public QObject
QHash <QString, NumerotationContext> conductorAutoNum() const; QHash <QString, NumerotationContext> conductorAutoNum() const;
QHash <QString, NumerotationContext> folioAutoNum() const; QHash <QString, NumerotationContext> folioAutoNum() const;
void addConductorAutoNum (QString key, NumerotationContext context); void addConductorAutoNum (QString key, NumerotationContext context);
void addFolioAutoNum (QString key, NumerotationContext context); void addElementAutoNum (QString formula);
void addFolioAutoNum (QString key, NumerotationContext context);
void removeConductorAutonum (QString key); void removeConductorAutonum (QString key);
void removeFolioAutoNum (QString key); void removeFolioAutoNum (QString key);
NumerotationContext conductorAutoNum(const QString &key) const; NumerotationContext conductorAutoNum(const QString &key) const;
NumerotationContext folioAutoNum(const QString &key) const; NumerotationContext folioAutoNum(const QString &key) const;
QString elementAutoNum() const;
bool autoConductor () const; bool autoConductor () const;
bool autoFolio () const; bool autoFolio () const;
@@ -218,7 +220,10 @@ class QETProject : public QObject
QUndoStack *undo_stack_; QUndoStack *undo_stack_;
/// Conductor auto numerotation /// Conductor auto numerotation
QHash <QString, NumerotationContext> m_conductor_autonum; QHash <QString, NumerotationContext> m_conductor_autonum;
/// Folio auto numbering
QHash <QString, NumerotationContext> m_folio_autonum; QHash <QString, NumerotationContext> m_folio_autonum;
/// Element Auto Numbering
QString m_element_autonum;
/// Folio List Sheets quantity for this project. /// Folio List Sheets quantity for this project.
int folioSheetsQuantity; int folioSheetsQuantity;
bool m_auto_conductor; bool m_auto_conductor;

View File

@@ -0,0 +1,92 @@
/*
Copyright 2006-2016 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 "elementautonumberingw.h"
#include "ui_elementautonumberingw.h"
#include <QMessageBox>
#include <QPushButton>
#include <QtWidgets>
/**
* Constructor
*/
ElementAutonumberingW::ElementAutonumberingW(QWidget *parent) :
QWidget(parent),
ui(new Ui::ElementAutonumberingW)
{
ui->setupUi(this);
applyEnable(false);
}
/**
* Destructor
*/
ElementAutonumberingW::~ElementAutonumberingW()
{
delete ui;
}
/**
* @brief ElementAutonumberingW::setContext
* @param formula to be inserted into context
*/
void ElementAutonumberingW::setContext(QString formula) {
ui->m_formula_le->insert(formula);
}
/**
* @brief ElementAutonumberingW::formula
* @return formula to be stored into project
*/
QString ElementAutonumberingW::formula() {
return ui->m_formula_le->text();
}
/**
* @brief ElementAutonumberingW::on_m_formula_le_textChanged
* Update Apply Button
*/
void ElementAutonumberingW::on_m_formula_le_textChanged() {
if (!ui->m_formula_le->text().isEmpty())
applyEnable(true);
else applyEnable(false);
}
/**
* @brief ElementAutonumberingW::on_buttonBox_clicked
* Action on @buttonBox clicked
*/
void ElementAutonumberingW::on_buttonBox_clicked(QAbstractButton *button) {
//transform button to int
int answer = ui -> buttonBox -> buttonRole(button);
switch (answer) {
case QDialogButtonBox::ApplyRole:
applyEnable(true);
emit applyPressed();
break;
}
}
/**
* @brief ElementAutonumberingW::applyEnable
* enable/disable the apply button
*/
void ElementAutonumberingW::applyEnable(bool b) {
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
}

View File

@@ -0,0 +1,64 @@
/*
Copyright 2006-2016 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 ELEMENTAUTONUMBERINGW_H
#define ELEMENTAUTONUMBERINGW_H
#include <QWidget>
class QAbstractButton;
namespace Ui {
class ElementAutonumberingW;
}
/**
This class implements the element autonumbering widget.
It loads the current formula applied to new elements and allows
the user to overwrite it with a new formula. Formula is added
while parsing label in customelement.cpp
*/
class ElementAutonumberingW : public QWidget
{
Q_OBJECT
//METHODS
public:
explicit ElementAutonumberingW(QWidget *parent = 0);
~ElementAutonumberingW();
QString formula();
void setContext(QString);
private:
// SIGNALS
signals:
void applyPressed();
//SLOTS
private slots:
void on_m_formula_le_textChanged();
void on_buttonBox_clicked(QAbstractButton *);
void applyEnable (bool = true);
//ATTRIBUTES
private:
Ui::ElementAutonumberingW *ui;
};
#endif // ELEMENTAUTONUMBERINGW_H

View File

@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ElementAutonumberingW</class>
<widget class="QWidget" name="ElementAutonumberingW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<height>550</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>460</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>50</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>440</width>
<height>495</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item row="4" column="1" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" rowspan="2" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Auto Naming Pattern:</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="1">
<widget class="QLineEdit" name="m_formula_le">
<property name="inputMask">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="placeholderText">
<string>Insert Formula Here e.g.: %prefix%l%c</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Formula:</string>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="2" colspan="3">
<widget class="QLabel" name="label">
<property name="text">
<string>You can use the following variables to your formula:
-%prefix: Default Element Prefix
-%l: Element Line
-%c: Element Column
-%F: Folio Name
-%f or %id: Folio ID
-%total: Total of folios
You can also assign any other titleblock variable
that you create. Text and number inputs are also available</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -135,7 +135,7 @@ void FolioAutonumberingW::on_m_autonumber_tabs_rb_clicked() {
* @brief FolioAutonumberingW::on_m_new_tabs_sb_valueChanged * @brief FolioAutonumberingW::on_m_new_tabs_sb_valueChanged
* Enable Apply if any new folio is to be created * Enable Apply if any new folio is to be created
*/ */
void FolioAutonumberingW::on_m_new_tabs_sb_valueChanged(){ void FolioAutonumberingW::on_m_new_tabs_sb_valueChanged(int){
if (ui->m_new_tabs_sb->value()>0) applyEnable(true); if (ui->m_new_tabs_sb->value()>0) applyEnable(true);
else applyEnable(false); else applyEnable(false);
} }
@@ -144,7 +144,7 @@ void FolioAutonumberingW::on_m_new_tabs_sb_valueChanged(){
* @brief FolioAutonumberingW::on_m_from_cb_currentIndexChanged * @brief FolioAutonumberingW::on_m_from_cb_currentIndexChanged
* Enable To ComboBox * Enable To ComboBox
*/ */
void FolioAutonumberingW::on_m_from_cb_currentIndexChanged(){ void FolioAutonumberingW::on_m_from_cb_currentIndexChanged(int){
int index = ui->m_from_cb->currentIndex(); int index = ui->m_from_cb->currentIndex();
ui->m_to_cb->clear(); ui->m_to_cb->clear();
if (index > 0){ if (index > 0){

View File

@@ -26,7 +26,7 @@ class QAbstractButton;
class QETProject; class QETProject;
namespace Ui { namespace Ui {
class FolioAutonumberingW; class FolioAutonumberingW;
} }
class FolioAutonumberingW : public QWidget class FolioAutonumberingW : public QWidget
@@ -35,16 +35,16 @@ class FolioAutonumberingW : public QWidget
//METHODS //METHODS
public: public:
explicit FolioAutonumberingW(QETProject *project, QWidget *parent = 0); explicit FolioAutonumberingW(QETProject *project, QWidget *parent = 0);
~FolioAutonumberingW(); ~FolioAutonumberingW();
void setContext (QList <QString> autonums); void setContext (QList <QString> autonums);
NumerotationContext toNumContext() const; NumerotationContext toNumContext() const;
QString autoNumSelected(); QString autoNumSelected();
int newFoliosNumber(); int newFoliosNumber();
bool newFolios; bool newFolios;
int fromFolio(); int fromFolio();
int toFolio(); int toFolio();
// SIGNALS // SIGNALS
signals: signals:
@@ -53,20 +53,20 @@ class FolioAutonumberingW : public QWidget
//SLOTS //SLOTS
private slots: private slots:
void on_m_create_new_tabs_rb_clicked(); void on_m_create_new_tabs_rb_clicked();
void on_m_autonumber_tabs_rb_clicked(); void on_m_autonumber_tabs_rb_clicked();
void on_m_new_tabs_sb_valueChanged(); void on_m_new_tabs_sb_valueChanged(int);
void on_buttonBox_clicked(QAbstractButton *); void on_buttonBox_clicked(QAbstractButton *);
void on_m_from_cb_currentIndexChanged(); void on_m_from_cb_currentIndexChanged(int);
void applyEnable (bool = true); void applyEnable (bool = true);
//ATTRIBUTES //ATTRIBUTES
private: private:
QETProject *project_; QETProject *project_;
Ui::FolioAutonumberingW *ui; Ui::FolioAutonumberingW *ui;
QList <NumPartEditorW *> num_part_list_; QList <NumPartEditorW *> num_part_list_;
NumerotationContext m_context; NumerotationContext m_context;
void updateFolioList(); void updateFolioList();
}; };
#endif // FOLIOAUTONUMBERING_H #endif // FOLIOAUTONUMBERING_H

View File

@@ -149,7 +149,7 @@ void NumPartEditorW::on_value_field_textEdited() {
* @brief NumPartEditorW::on_increase_spinBox_valueChanged * @brief NumPartEditorW::on_increase_spinBox_valueChanged
* emit changed when @increase_spinBox value changed * emit changed when @increase_spinBox value changed
*/ */
void NumPartEditorW::on_increase_spinBox_valueChanged() { void NumPartEditorW::on_increase_spinBox_valueChanged(int) {
if (!ui -> value_field -> text().isEmpty()) emit changed(); if (!ui -> value_field -> text().isEmpty()) emit changed();
} }

View File

@@ -49,7 +49,7 @@ class NumPartEditorW : public QWidget
private slots: private slots:
void on_type_combo_activated(int); void on_type_combo_activated(int);
void on_value_field_textEdited(); void on_value_field_textEdited();
void on_increase_spinBox_valueChanged(); void on_increase_spinBox_valueChanged(int);
void setType (NumPartEditorW::type t, bool=false); void setType (NumPartEditorW::type t, bool=false);
signals: signals:

View File

@@ -72,5 +72,5 @@ void ProjectPropertiesDialog::setCurrentPage(ProjectPropertiesDialog::Page p) {
*/ */
void ProjectPropertiesDialog::changeToFolio() { void ProjectPropertiesDialog::changeToFolio() {
ProjectAutoNumConfigPage *autoNumPage = static_cast <ProjectAutoNumConfigPage*>(m_properties_dialog->pages.at(2)); ProjectAutoNumConfigPage *autoNumPage = static_cast <ProjectAutoNumConfigPage*>(m_properties_dialog->pages.at(2));
autoNumPage->changeToTab(1); autoNumPage->changeToTab(2);
} }