]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/qt2BC.C
First attempt at converting copyright dialog to MVC architecture
[lyx.git] / src / frontends / qt2 / qt2BC.C
1 /**
2  * \file xformsBC.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Allan Rae <rae@lyx.org>
7  * \author Angus Leeming <a.leeming@ic.ac.uk>
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "qt2BC.h"
17
18 #include <qbutton.h>
19
20 qt2BC::qt2BC(string const & cancel, string const & close)
21         : ButtonControllerBase(cancel, close),
22           okay_(0), apply_(0), cancel_(0), undo_all_(0), read_only_()
23 {}
24
25
26 void qt2BC::refresh()
27 {
28         if (okay_) {
29                 if (bp().buttonStatus(ButtonPolicy::OKAY)) {
30                     okay_->setEnabled( true );
31                 } else {
32                     okay_->setEnabled( false );
33                 }
34         }
35         if (apply_) {
36                 if (bp().buttonStatus(ButtonPolicy::APPLY)) {
37                     apply_->setEnabled( true );
38                 } else {
39                     apply_->setEnabled( false );
40                 }
41         }
42         if (undo_all_) {
43                 if (bp().buttonStatus(ButtonPolicy::UNDO_ALL)) {
44                     undo_all_->setEnabled( true );
45                 } else {
46                     undo_all_->setEnabled( false );
47                 }
48         }
49         if (cancel_) {
50                 if (bp().buttonStatus(ButtonPolicy::CANCEL)) {
51                     cancel_->setText( cancel_label.c_str() );
52                 } else {
53                     cancel_->setText( close_label.c_str() );
54                 }
55         }
56         if (!read_only_.empty()) {
57                 bool enable = true;
58                 if (bp().isReadOnly()) enable = false;
59
60                 for (std::list<QButton *>::iterator iter = read_only_.begin();
61                      iter != read_only_.end(); ++iter) {
62                     (*iter)->setEnabled( enable );
63                 }
64         }
65 }