[qet] [2351] config autonum widget: minor change about enable/ disable apply button |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2351
Author: blacksun
Date: 2013-06-27 16:02:59 +0200 (Thu, 27 Jun 2013)
Log Message:
-----------
config autonum widget: minor change about enable/disable apply button
Modified Paths:
--------------
trunk/sources/ui/numparteditorw.cpp
trunk/sources/ui/numparteditorw.h
trunk/sources/ui/selectautonumw.cpp
Modified: trunk/sources/ui/numparteditorw.cpp
===================================================================
--- trunk/sources/ui/numparteditorw.cpp 2013-06-26 19:43:47 UTC (rev 2350)
+++ trunk/sources/ui/numparteditorw.cpp 2013-06-27 14:02:59 UTC (rev 2351)
@@ -60,11 +60,19 @@
}
/**
+ * @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 @@
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 @@
*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 @@
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);
Modified: trunk/sources/ui/numparteditorw.h
===================================================================
--- trunk/sources/ui/numparteditorw.h 2013-06-26 19:43:47 UTC (rev 2350)
+++ trunk/sources/ui/numparteditorw.h 2013-06-27 14:02:59 UTC (rev 2351)
@@ -21,10 +21,12 @@
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 @@
Ui::NumPartEditorW *ui;
QValidator *intValidator;
QString type_str;
+ type type_;
};
Modified: trunk/sources/ui/selectautonumw.cpp
===================================================================
--- trunk/sources/ui/selectautonumw.cpp 2013-06-26 19:43:47 UTC (rev 2350)
+++ trunk/sources/ui/selectautonumw.cpp 2013-06-27 14:02:59 UTC (rev 2351)
@@ -72,7 +72,7 @@
* 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 @@
* 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 @@
* 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);
}