Auto Folio Numbering - Create specific number of new folios with a folio autonumbering or Auto Number selected Folios

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4488 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
dfochi
2016-05-17 19:19:11 +00:00
parent b5d12cc232
commit 2d3298fe41
14 changed files with 301 additions and 219 deletions

View File

@@ -20,23 +20,22 @@
#include <QMessageBox>
#include <QPushButton>
#include <QtWidgets>
#include "qdebug.h"
#include "qetproject.h"
#include "diagram.h"
/**
* Constructor
*/
FolioAutonumberingW::FolioAutonumberingW(QETProject *project, QWidget *parent) :
QWidget(parent),
project_(project),
ui(new Ui::FolioAutonumberingW)
QWidget(parent),
project_(project),
ui(new Ui::FolioAutonumberingW)
{
ui->setupUi(this);
applyEnable(false);
ui->m_from_cb->setEnabled(false);
ui->m_new_tabs_sb->setEnabled(false);
ui->m_to_cb->setEnabled(false);
ui->setupUi(this);
applyEnable(false);
ui->m_from_cb->setEnabled(false);
ui->m_new_tabs_sb->setEnabled(false);
ui->m_to_cb->setEnabled(false);
}
/**
@@ -52,7 +51,7 @@ FolioAutonumberingW::~FolioAutonumberingW()
* construct autonums in the comboBox selected in the @autonum_chooser QcomboBox
*/
void FolioAutonumberingW::setContext(QList <QString> autonums) {
foreach (QString str, autonums) { ui->m_autonums_cb->addItem(str);}
foreach (QString str, autonums) { ui->m_autonums_cb->addItem(str);}
}
/**
@@ -60,7 +59,7 @@ void FolioAutonumberingW::setContext(QList <QString> autonums) {
* returns the current autonum selected
*/
QString FolioAutonumberingW::autoNumSelected(){
return ui->m_autonums_cb->currentText();
return ui->m_autonums_cb->currentText();
}
/**
@@ -84,7 +83,7 @@ int FolioAutonumberingW::toFolio(){
* returns the number of folios to create
*/
int FolioAutonumberingW::newFoliosNumber(){
return ui->m_new_tabs_sb->value();
return ui->m_new_tabs_sb->value();
}
/**
@@ -92,9 +91,9 @@ int FolioAutonumberingW::newFoliosNumber(){
* update Folio List in From and To ComboBox
*/
void FolioAutonumberingW::updateFolioList(){
ui -> m_from_cb->clear();
ui -> m_to_cb->clear();
if (newFolios){
ui -> m_from_cb->clear();
ui -> m_to_cb->clear();
if (newFolios){
this -> on_m_create_new_tabs_rb_clicked();
} else {
this -> on_m_autonumber_tabs_rb_clicked();
@@ -106,11 +105,11 @@ void FolioAutonumberingW::updateFolioList(){
* Enable New Tabs SpinBox
*/
void FolioAutonumberingW::on_m_create_new_tabs_rb_clicked() {
ui->m_from_cb->setEnabled(false);
ui->m_to_cb->setEnabled(false);
ui->m_new_tabs_sb->setEnabled(true);
applyEnable();
newFolios = true;
ui->m_from_cb->setEnabled(false);
ui->m_to_cb->setEnabled(false);
ui->m_new_tabs_sb->setEnabled(true);
applyEnable();
newFolios = true;
}
/**
@@ -118,18 +117,18 @@ void FolioAutonumberingW::on_m_create_new_tabs_rb_clicked() {
* Enable From ComboBox, fill From ComboBox
*/
void FolioAutonumberingW::on_m_autonumber_tabs_rb_clicked() {
ui->m_new_tabs_sb->setEnabled(false);
ui->m_from_cb->setEnabled(true);
ui->m_to_cb->setEnabled(true);
if (ui->m_from_cb->count()<=0){
ui->m_from_cb->clear();
ui->m_from_cb->addItem("");
foreach (Diagram *diagram, project_->diagrams()){
ui->m_from_cb->addItem(diagram->title());
}
}
applyEnable();
newFolios = false;
ui->m_new_tabs_sb->setEnabled(false);
ui->m_from_cb->setEnabled(true);
ui->m_to_cb->setEnabled(true);
if (ui->m_from_cb->count()<=0){
ui->m_from_cb->clear();
ui->m_from_cb->addItem("");
foreach (Diagram *diagram, project_->diagrams()){
ui->m_from_cb->addItem(diagram->title());
}
}
applyEnable();
newFolios = false;
}
/**
@@ -137,8 +136,8 @@ void FolioAutonumberingW::on_m_autonumber_tabs_rb_clicked() {
* Enable Apply if any new folio is to be created
*/
void FolioAutonumberingW::on_m_new_tabs_sb_valueChanged(){
if (ui->m_new_tabs_sb->value()>0) applyEnable(true);
else applyEnable(false);
if (ui->m_new_tabs_sb->value()>0) applyEnable(true);
else applyEnable(false);
}
/**
@@ -146,17 +145,17 @@ void FolioAutonumberingW::on_m_new_tabs_sb_valueChanged(){
* Enable To ComboBox
*/
void FolioAutonumberingW::on_m_from_cb_currentIndexChanged(){
int index = ui->m_from_cb->currentIndex();
ui->m_to_cb->clear();
if (index > 0){
ui->m_to_cb->setEnabled(true);
for (int i=index;i<project_->diagrams().size();i++)
ui->m_to_cb->addItem(project_->diagrams().at(i)->title());
applyEnable(true);
}
else{
applyEnable();
}
int index = ui->m_from_cb->currentIndex();
ui->m_to_cb->clear();
if (index > 0){
ui->m_to_cb->setEnabled(true);
for (int i=index;i<project_->diagrams().size();i++)
ui->m_to_cb->addItem(project_->diagrams().at(i)->title());
applyEnable(true);
}
else{
applyEnable();
}
}
@@ -165,35 +164,34 @@ void FolioAutonumberingW::on_m_from_cb_currentIndexChanged(){
* Action on @buttonBox clicked
*/
void FolioAutonumberingW::on_buttonBox_clicked(QAbstractButton *button) {
//transform button to int
//transform button to int
int answer = ui -> buttonBox -> buttonRole(button);
switch (answer) {
switch (answer) {
//help dialog - not implemented yet -
case QDialogButtonBox::HelpRole:
break;
/*QMessageBox::information (this, tr("Folio Autonumbering", "title window"),
tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux conducteurs.\n"
QMessageBox::information (this, tr("Folio Autonumbering", "title window"),
tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux folios.\n"
"-Une numérotation est composée d'une variable minimum.\n"
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
"-Une variable de numérotation comprant: un type, une valeur et une incrémentation.\n"
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représente un type numérique définie dans le champs \"Valeur\", "
"qui s'incrémente à chaque nouveau conducteur de la valeur du champ \"Incrémentation\".\n"
"qui s'incrémente à chaque nouveau folio de la valeur du champ \"Incrémentation\".\n"
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représenté sur le schéma par deux et trois digits minimum.\n"
"Si le chiffre définie dans le champs Valeur posséde moins de digits que le type choisit,"
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
"\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n"
"\n-Le type \"N° folio\" représente le n° du folio en cours.\nLes autres champs ne sont pas utilisés.",
"help dialog about the autonumerotation")); */
case QDialogButtonBox::ApplyRole:
applyEnable(true);
emit applyPressed();
updateFolioList();
"\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n",
"help dialog about the folio autonumerotation"
));
break;
}
case QDialogButtonBox::ApplyRole:
applyEnable(true);
emit applyPressed();
updateFolioList();
break;
}
}
/**
@@ -201,18 +199,18 @@ void FolioAutonumberingW::on_buttonBox_clicked(QAbstractButton *button) {
* enable/disable the apply button
*/
void FolioAutonumberingW::applyEnable(bool b) {
if (b){
bool valid = true;
if (ui->m_create_new_tabs_rb->isChecked()){
if (ui->m_new_tabs_sb->value()==0) valid = false;
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(valid);
}
else{
if (ui->m_to_cb->currentText()=="") valid = false;
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(valid);
}
}
else{
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
}
if (b){
bool valid = true;
if (ui->m_create_new_tabs_rb->isChecked()){
if (ui->m_new_tabs_sb->value()==0) valid = false;
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(valid);
}
else{
if (ui->m_to_cb->currentText()=="") valid = false;
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(valid);
}
}
else{
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
}
}

View File

@@ -129,7 +129,7 @@
</sizepolicy>
</property>
<property name="text">
<string>New Tabs</string>
<string>New Folios</string>
</property>
</widget>
</item>
@@ -212,7 +212,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Create New Tabs</string>
<string>Create New Folios</string>
</property>
</widget>
</item>
@@ -225,7 +225,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Autonumber Selected Tabs</string>
<string>Autonumber Selected Folios</string>
</property>
</widget>
</item>
@@ -284,7 +284,7 @@
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Help|QDialogButtonBox::Reset</set>
<set>QDialogButtonBox::Apply</set>
</property>
</widget>
</item>

View File

@@ -28,6 +28,7 @@ NumPartEditorW::NumPartEditorW(QWidget *parent) :
intValidator (new QIntValidator(0,99999,this))
{
ui -> setupUi(this);
if (parentWidget()->parentWidget()->objectName()=="FolioTab") ui->type_combo->setMaxCount(4);
setType(NumPartEditorW::unit, true);
}
@@ -41,7 +42,7 @@ NumPartEditorW::NumPartEditorW (NumerotationContext &context, int i, QWidget *pa
intValidator (new QIntValidator(0,99999,this))
{
ui -> setupUi(this);
if (parentWidget()->parentWidget()->objectName()=="FolioTab") ui->type_combo->setMaxCount(5);
//if @context contains nothing build with default value
if(context.size()==0) setType(NumPartEditorW::unit, true);
@@ -51,7 +52,8 @@ NumPartEditorW::NumPartEditorW (NumerotationContext &context, int i, QWidget *pa
else if (strl.at(0)=="ten") setType(NumPartEditorW::ten, true);
else if (strl.at(0)=="hundred") setType(NumPartEditorW::hundred, true);
else if (strl.at(0)=="string") setType(NumPartEditorW::string);
else if (strl.at(0)== "folio") setType(NumPartEditorW::folio);
else if (strl.at(0)=="idfolio") setType(NumPartEditorW::idfolio);
else if (strl.at(0)=="folio") setType(NumPartEditorW::folio);
ui -> value_field -> setText(strl.at(1));
ui -> increase_spinBox -> setValue(strl.at(2).toInt());
}
@@ -86,6 +88,9 @@ NumerotationContext NumPartEditorW::toNumContext() {
case string:
type_str = "string";
break;
case idfolio:
type_str = "idfolio";
break;
case folio:
type_str = "folio";
break;
@@ -99,8 +104,9 @@ NumerotationContext NumPartEditorW::toNumContext() {
* @return true if value field isn't empty or if type is folio
*/
bool NumPartEditorW::isValid() {
if (type_ != folio && ui -> value_field -> text().isEmpty()) return false;
return true;
if (type_ == folio||type_ == idfolio) {return true;}
else if(ui -> value_field -> text().isEmpty()) {return false;}
else return true;
}
/**
@@ -121,6 +127,9 @@ void NumPartEditorW::on_type_combo_activated(int index) {
case string:
setType(string);
break;
case idfolio:
setType(idfolio);
break;
case folio:
setType(folio);
break;
@@ -155,7 +164,7 @@ void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
//if @t is a numeric type and preview type @type_ isn't a numeric type
//or @fnum is true, we set numeric behavior
if ( ((t==unit || t==ten || t==hundred) && (type_==string || type_==folio)) || fnum) {
if ( ((t==unit || t==ten || t==hundred) && (type_==string || type_==folio || type_==idfolio)) || fnum) {
ui -> value_field -> clear();
ui -> value_field -> setEnabled(true);
ui -> value_field -> setValidator(intValidator);
@@ -163,7 +172,7 @@ void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
ui -> increase_spinBox -> setValue(1);
}
//@t isn't a numeric type
else if (t==string || t==folio) {
else if (t==string || t==folio || t==idfolio) {
ui -> value_field -> clear();
ui -> increase_spinBox -> setDisabled(true);
if (t==string) {
@@ -174,6 +183,10 @@ void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==idfolio) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
}
type_= t;
}

View File

@@ -41,7 +41,7 @@ class NumPartEditorW : public QWidget
NumPartEditorW (NumerotationContext &, int, QWidget *parent=0);
~NumPartEditorW();
enum type {unit,ten,hundred,string,folio};
enum type {unit,ten,hundred,string,idfolio,folio};
NumerotationContext toNumContext();
bool isValid ();

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>259</width>
<height>42</height>
<width>308</width>
<height>45</height>
</rect>
</property>
<property name="windowTitle">
@@ -28,6 +28,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>Chiffre 1</string>
@@ -53,6 +56,11 @@
<string>N° folio</string>
</property>
</item>
<item>
<property name="text">
<string>Folio</string>
</property>
</item>
</widget>
</item>
<item>

View File

@@ -19,7 +19,6 @@
#include "ui_selectautonumw.h"
#include "numparteditorw.h"
#include <QMessageBox>
#include "qdebug.h"
#include "numerotationcontextcommands.h"
/**
@@ -125,7 +124,6 @@ void SelectAutonumW::on_remove_button_clicked() {
void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) {
//transform button to int
int answer = ui -> buttonBox -> buttonRole(button);
switch (answer) {
//Reset the curent context
case QDialogButtonBox::ResetRole:
@@ -133,23 +131,46 @@ void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) {
break;
//help dialog
case QDialogButtonBox::HelpRole:
QMessageBox::information (this, tr("Autonumérotation", "title window"),
tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux conducteurs.\n"
"-Une numérotation est composée d'une variable minimum.\n"
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
"-Une variable de numérotation comprant: un type, une valeur et une incrémentation.\n"
if (this->parentWidget() -> objectName()=="FolioTab"){
QMessageBox::information (this, tr("Folio Autonumérotation", "title window"),
tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux folios.\n"
"-Une numérotation est composée d'une variable minimum.\n"
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
"-Une variable de numérotation comprant: un type, une valeur et une incrémentation.\n"
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représente un type numérique définie dans le champs \"Valeur\", "
"qui s'incrémente à chaque nouveau conducteur de la valeur du champ \"Incrémentation\".\n"
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représenté sur le schéma par deux et trois digits minimum.\n"
"Si le chiffre définie dans le champs Valeur posséde moins de digits que le type choisit,"
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représente un type numérique définie dans le champs \"Valeur\", "
"qui s'incrémente à chaque nouveau folio de la valeur du champ \"Incrémentation\".\n"
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représenté sur le schéma par deux et trois digits minimum.\n"
"Si le chiffre définie dans le champs Valeur posséde moins de digits que le type choisit,"
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
"\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n"
"\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n",
"help dialog about the folio autonumerotation"
));
break;
}
else{
QMessageBox::information (this, tr("Conductor Autonumérotation", "title window"),
tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux conducteurs.\n"
"-Une numérotation est composée d'une variable minimum.\n"
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
"-Une variable de numérotation comprant: un type, une valeur et une incrémentation.\n"
"\n-Le type \"N° folio\" représente le n° du folio en cours.\nLes autres champs ne sont pas utilisés.",
"help dialog about the autonumerotation"));
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représente un type numérique définie dans le champs \"Valeur\", "
"qui s'incrémente à chaque nouveau conducteur de la valeur du champ \"Incrémentation\".\n"
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représenté sur le schéma par deux et trois digits minimum.\n"
"Si le chiffre définie dans le champs Valeur posséde moins de digits que le type choisit,"
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
"\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n"
"\n-Le type \"N° folio\" représente le n° du folio en cours.\nLes autres champs ne sont pas utilisés.\n"
"\n-Le type \"Folio\" représente le nom du folio en cours.\nLes autres champs ne sont pas utilisés.",
"help dialog about the conductor autonumerotation"
));
break;
}
//apply the context in the diagram displayed by @diagram_chooser.
case QDialogButtonBox::ApplyRole:
applyEnable(false);

View File

@@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>466</width>
<width>418</width>
<height>506</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -23,14 +23,14 @@
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>430</width>
<width>400</width>
<height>455</height>
</size>
</property>
@@ -66,19 +66,19 @@
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<width>400</width>
<height>453</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>460</width>
<width>400</width>
<height>450</height>
</size>
</property>
@@ -89,7 +89,7 @@
<item>
<widget class="QGroupBox" name="definition_groupe">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>