mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-04-23 12:09:58 +02:00
autonum widget: if user change type (old type numeric to new type numeric) the value field isn't erase
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2353 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -11,7 +11,7 @@ NumPartEditorW::NumPartEditorW(QWidget *parent) :
|
|||||||
intValidator (new QIntValidator(0,99999,this))
|
intValidator (new QIntValidator(0,99999,this))
|
||||||
{
|
{
|
||||||
ui -> setupUi(this);
|
ui -> setupUi(this);
|
||||||
setType(NumPartEditorW::unit);
|
setType(NumPartEditorW::unit, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,13 +26,13 @@ NumPartEditorW::NumPartEditorW (NumerotationContext &context, int i, QWidget *pa
|
|||||||
ui -> setupUi(this);
|
ui -> setupUi(this);
|
||||||
|
|
||||||
//if @context contains nothing build with default value
|
//if @context contains nothing build with default value
|
||||||
if(context.size()==0) setType(NumPartEditorW::unit);
|
if(context.size()==0) setType(NumPartEditorW::unit, true);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
QStringList strl = context.itemAt(i);
|
QStringList strl = context.itemAt(i);
|
||||||
if (strl.at(0)=="unit") setType(NumPartEditorW::unit);
|
if (strl.at(0)=="unit") setType(NumPartEditorW::unit, true);
|
||||||
else if (strl.at(0)=="ten") setType(NumPartEditorW::ten);
|
else if (strl.at(0)=="ten") setType(NumPartEditorW::ten, true);
|
||||||
else if (strl.at(0)=="hundred") setType(NumPartEditorW::hundred);
|
else if (strl.at(0)=="hundred") setType(NumPartEditorW::hundred, true);
|
||||||
else if (strl.at(0)=="string") setType(NumPartEditorW::string);
|
else if (strl.at(0)=="string") setType(NumPartEditorW::string);
|
||||||
else if (strl.at(0)== "folio") setType(NumPartEditorW::folio);
|
else if (strl.at(0)== "folio") setType(NumPartEditorW::folio);
|
||||||
ui -> value_field -> setText(strl.at(1));
|
ui -> value_field -> setText(strl.at(1));
|
||||||
@@ -55,6 +55,24 @@ NumPartEditorW::~NumPartEditorW()
|
|||||||
*/
|
*/
|
||||||
NumerotationContext NumPartEditorW::toNumContext() {
|
NumerotationContext NumPartEditorW::toNumContext() {
|
||||||
NumerotationContext nc;
|
NumerotationContext nc;
|
||||||
|
QString type_str;
|
||||||
|
switch (type_) {
|
||||||
|
case unit:
|
||||||
|
type_str = "unit";
|
||||||
|
break;
|
||||||
|
case ten:
|
||||||
|
type_str = "ten";
|
||||||
|
break;
|
||||||
|
case hundred:
|
||||||
|
type_str = "hundred";
|
||||||
|
break;
|
||||||
|
case string:
|
||||||
|
type_str = "string";
|
||||||
|
break;
|
||||||
|
case folio:
|
||||||
|
type_str = "folio";
|
||||||
|
break;
|
||||||
|
}
|
||||||
nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value());
|
nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value());
|
||||||
return nc;
|
return nc;
|
||||||
}
|
}
|
||||||
@@ -103,7 +121,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() {
|
||||||
if (!ui -> value_field -> text().isEmpty()) emit changed();
|
if (!ui -> value_field -> text().isEmpty()) emit changed();
|
||||||
@@ -112,41 +130,33 @@ void NumPartEditorW::on_increase_spinBox_valueChanged() {
|
|||||||
/**
|
/**
|
||||||
* @brief NumPartEditorW::setType
|
* @brief NumPartEditorW::setType
|
||||||
* Set good behavior by type @t
|
* Set good behavior by type @t
|
||||||
|
* @param t, type used
|
||||||
|
* @param fnum, force the behavior of numeric type
|
||||||
*/
|
*/
|
||||||
void NumPartEditorW::setType(NumPartEditorW::type t) {
|
void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
|
||||||
ui -> type_combo -> setCurrentIndex(t);
|
ui -> type_combo -> setCurrentIndex(t);
|
||||||
ui -> value_field -> clear();
|
|
||||||
ui -> increase_spinBox -> setValue(1);
|
//if @t is a numeric type and preview type @type_ isn't a numeric type
|
||||||
type_= t;
|
//or @fnum is true, we set numeric behavior
|
||||||
switch (t) {
|
if ( ((t==unit || t==ten || t==hundred) && (type_==string || type_==folio)) || fnum) {
|
||||||
case unit:
|
ui -> value_field -> clear();
|
||||||
ui -> value_field -> setEnabled(true);
|
ui -> value_field -> setEnabled(true);
|
||||||
ui ->value_field -> setValidator(intValidator);
|
ui -> value_field -> setValidator(intValidator);
|
||||||
ui -> increase_spinBox -> setEnabled(true);
|
ui -> increase_spinBox -> setEnabled(true);
|
||||||
type_str = "unit";
|
ui -> increase_spinBox -> setValue(1);
|
||||||
break;
|
}
|
||||||
case ten:
|
//@t isn't a numeric type
|
||||||
ui -> value_field -> setEnabled(true);
|
else if (t==string || t==folio) {
|
||||||
ui ->value_field -> setValidator(intValidator);
|
ui -> value_field -> clear();
|
||||||
ui -> increase_spinBox -> setEnabled(true);
|
ui -> increase_spinBox -> setDisabled(true);
|
||||||
type_str = "ten";
|
if (t==string) {
|
||||||
break;
|
|
||||||
case hundred:
|
|
||||||
ui -> value_field -> setEnabled(true);
|
|
||||||
ui ->value_field -> setValidator(intValidator);
|
|
||||||
ui -> increase_spinBox -> setEnabled(true);
|
|
||||||
type_str = "hundred";
|
|
||||||
break;
|
|
||||||
case string:
|
|
||||||
ui -> value_field -> setValidator(0);
|
ui -> value_field -> setValidator(0);
|
||||||
ui -> value_field -> setEnabled(true);
|
ui -> value_field -> setEnabled(true);
|
||||||
ui -> increase_spinBox -> setDisabled(true);
|
}
|
||||||
type_str = "string";
|
else if (t==folio) {
|
||||||
break;
|
|
||||||
case folio:
|
|
||||||
ui -> value_field -> setDisabled(true);
|
ui -> value_field -> setDisabled(true);
|
||||||
ui -> increase_spinBox -> setDisabled(true);
|
ui -> increase_spinBox -> setDisabled(true);
|
||||||
type_str = "folio";
|
}
|
||||||
break;
|
}
|
||||||
};
|
type_= t;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,11 @@
|
|||||||
#include <QValidator>
|
#include <QValidator>
|
||||||
#include "numerotationcontext.h"
|
#include "numerotationcontext.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*This class represent a single part num widget. By this widget, we can define and edit
|
||||||
|
*how the num auto must work .
|
||||||
|
*This widget is called by selectautonumw.
|
||||||
|
*/
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class NumPartEditorW;
|
class NumPartEditorW;
|
||||||
}
|
}
|
||||||
@@ -28,7 +33,7 @@ class NumPartEditorW : public QWidget
|
|||||||
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();
|
||||||
void setType (NumPartEditorW::type t);
|
void setType (NumPartEditorW::type t, bool=false);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed ();
|
void changed ();
|
||||||
@@ -36,7 +41,6 @@ class NumPartEditorW : public QWidget
|
|||||||
private:
|
private:
|
||||||
Ui::NumPartEditorW *ui;
|
Ui::NumPartEditorW *ui;
|
||||||
QValidator *intValidator;
|
QValidator *intValidator;
|
||||||
QString type_str;
|
|
||||||
type type_;
|
type type_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user