]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QFloat.C
No longer pass Controller & or Dialogs & to the View c-tors.
[lyx.git] / src / frontends / qt2 / QFloat.C
1 /**
2  * \file QFloat.C
3  * Copyright 2002 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Edwin Leuven <leuven@fee.uva.nl>
7  */
8
9 #include <config.h>
10
11 #ifdef __GNUG__
12 #pragma implementation
13 #endif
14
15 #include "ControlFloat.h"
16 #include "QFloatDialog.h"
17 #include "QFloat.h"
18 #include "Qt2BC.h"
19 #include "gettext.h"
20 #include "helper_funcs.h"
21
22 #include "support/lstrings.h"
23
24 #include <qradiobutton.h>
25 #include <qpushbutton.h>
26 #include <qcheckbox.h>
27
28 typedef Qt2CB<ControlFloat, Qt2DB<QFloatDialog> > base_class;
29
30 QFloat::QFloat()
31         : base_class(_("LaTeX Information"))
32 {
33 }
34
35
36 void QFloat::build_dialog()
37 {
38         dialog_.reset(new QFloatDialog(this));
39
40         bc().setCancel(dialog_->closePB);
41         bc().setApply(dialog_->applyPB);
42         bc().setOK(dialog_->okPB);
43         bc().setRestore(dialog_->restorePB);
44 }
45
46
47 void QFloat::update_contents()
48 {
49         bool top = false;
50         bool bottom = false;
51         bool page = false;
52         bool here = false;
53         bool forcehere = false;
54
55         string placement(controller().params().placement);
56
57         if (contains(placement, "H")) {
58                 forcehere = true;
59         } else {
60                 if (contains(placement, "t")) {
61                         top = true;
62                 }
63                 if (contains(placement, "b")) {
64                         bottom = true;
65                 }
66                 if (contains(placement, "p")) {
67                         page = true;
68                 }
69                 if (contains(placement, "h")) {
70                         here = true;
71                 }
72         }
73
74         dialog_->top->setChecked(top);
75         dialog_->bottom->setChecked(bottom);
76         dialog_->page->setChecked(page);
77         dialog_->here->setChecked(here);
78         dialog_->forcehere->setChecked(forcehere);
79 }
80
81 void QFloat::apply()
82 {
83         string placement;
84
85         if (dialog_->forcehere->isChecked()) {
86                 placement += "H";
87         } else {
88                 if (dialog_->top->isChecked()) {
89                         placement += "t";
90                 }
91                 if (dialog_->bottom->isChecked()) {
92                         placement += "b";
93                 }
94                 if (dialog_->page->isChecked()) {
95                         placement += "p";
96                 }
97                 if (dialog_->here->isChecked()) {
98                         placement += "h";
99                 }
100         }
101         controller().params().placement = placement;
102 }