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:
blacksun
2013-06-27 14:02:59 +00:00
parent 5151fb9d1f
commit 238115df84
3 changed files with 26 additions and 7 deletions

View File

@@ -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);
}