mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
config autonum widget: minor change about enable/disable apply button
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2351 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -59,12 +59,20 @@ NumerotationContext NumPartEditorW::toNumContext() {
|
||||
return nc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief NumPartEditorW::isValid
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief NumPartEditorW::on_type_combo_activated
|
||||
* Action when user change the type comboBox
|
||||
*/
|
||||
void NumPartEditorW::on_type_combo_activated(int index) {
|
||||
emit changed();
|
||||
switch (index) {
|
||||
case unit:
|
||||
setType(unit);
|
||||
@@ -82,13 +90,14 @@ void NumPartEditorW::on_type_combo_activated(int index) {
|
||||
setType(folio);
|
||||
break;
|
||||
};
|
||||
emit changed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief NumPartEditorW::on_value_field_textChanged
|
||||
* emit changed when @value_field text changed
|
||||
*/
|
||||
void NumPartEditorW::on_value_field_textChanged() {
|
||||
void NumPartEditorW::on_value_field_textEdited() {
|
||||
emit changed();
|
||||
}
|
||||
|
||||
@@ -97,7 +106,7 @@ void NumPartEditorW::on_value_field_textChanged() {
|
||||
*emit changed when @increase_spinBox value changed
|
||||
*/
|
||||
void NumPartEditorW::on_increase_spinBox_valueChanged() {
|
||||
emit changed();
|
||||
if (!ui -> value_field -> text().isEmpty()) emit changed();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,6 +117,7 @@ void NumPartEditorW::setType(NumPartEditorW::type t) {
|
||||
ui -> type_combo -> setCurrentIndex(t);
|
||||
ui -> value_field -> clear();
|
||||
ui -> increase_spinBox -> setValue(1);
|
||||
type_= t;
|
||||
switch (t) {
|
||||
case unit:
|
||||
ui -> value_field -> setEnabled(true);
|
||||
|
||||
@@ -21,10 +21,12 @@ class NumPartEditorW : public QWidget
|
||||
|
||||
enum type {unit,ten,hundred,string,folio};
|
||||
NumerotationContext toNumContext();
|
||||
bool isValid ();
|
||||
|
||||
|
||||
private slots:
|
||||
void on_type_combo_activated(int);
|
||||
void on_value_field_textChanged();
|
||||
void on_value_field_textEdited();
|
||||
void on_increase_spinBox_valueChanged();
|
||||
void setType (NumPartEditorW::type t);
|
||||
|
||||
@@ -35,6 +37,7 @@ class NumPartEditorW : public QWidget
|
||||
Ui::NumPartEditorW *ui;
|
||||
QValidator *intValidator;
|
||||
QString type_str;
|
||||
type type_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ NumerotationContext SelectAutonumW::toNumContext() const {
|
||||
* Action on add_button, add a @NumPartEditor
|
||||
*/
|
||||
void SelectAutonumW::on_add_button_clicked() {
|
||||
applyEnable();
|
||||
applyEnable(false);
|
||||
NumPartEditorW *part = new NumPartEditorW(this);
|
||||
connect (part, SIGNAL(changed()), this, SLOT(applyEnable()));
|
||||
num_part_list_ << part;
|
||||
@@ -84,13 +84,13 @@ void SelectAutonumW::on_add_button_clicked() {
|
||||
* Action on remove button, remove the last @NumPartEditor
|
||||
*/
|
||||
void SelectAutonumW::on_remove_button_clicked() {
|
||||
applyEnable();
|
||||
//remove if @num_part_list contains more than one item
|
||||
if (num_part_list_.size() > 1) {
|
||||
NumPartEditorW *part = num_part_list_.takeLast();
|
||||
disconnect(part, SIGNAL(changed()), this, SLOT(applyEnable()));
|
||||
delete part;
|
||||
}
|
||||
applyEnable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,5 +131,11 @@ void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) {
|
||||
* enable/disable the apply button
|
||||
*/
|
||||
void SelectAutonumW::applyEnable(bool b) {
|
||||
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
|
||||
if (b){
|
||||
bool valid= true;
|
||||
foreach (NumPartEditorW *npe, num_part_list_) if (!npe -> isValid()) valid= false;
|
||||
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
|
||||
}
|
||||
else
|
||||
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user