]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiChanges.cpp
move our stuff off the Q* namespace
[lyx.git] / src / frontends / qt4 / GuiChanges.cpp
1 /**
2  * \file GuiChanges.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Michael Gerz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiChanges.h"
15 #include "Qt2BC.h"
16 #include "qt_helpers.h"
17
18 #include "support/lstrings.h"
19
20 #include "controllers/ControlChanges.h"
21
22 #include <QPushButton>
23 #include <QCloseEvent>
24 #include <QTextBrowser>
25
26 using lyx::support::bformat;
27
28
29 namespace lyx {
30 namespace frontend {
31
32 /////////////////////////////////////////////////////////////////////
33 //
34 // GuiChangesDialog
35 //
36 /////////////////////////////////////////////////////////////////////
37
38 GuiChangesDialog::GuiChangesDialog(GuiChanges * form)
39         : form_(form)
40 {
41         setupUi(this);
42         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
43         connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed()));
44         connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectPressed()));
45         connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptPressed()));
46 }
47
48
49 void GuiChangesDialog::nextPressed()
50 {
51         form_->next();
52 }
53
54
55 void GuiChangesDialog::acceptPressed()
56 {
57         form_->accept();
58 }
59
60
61 void GuiChangesDialog::rejectPressed()
62 {
63         form_->reject();
64 }
65
66
67 void GuiChangesDialog::closeEvent(QCloseEvent *e)
68 {
69         form_->slotWMHide();
70         e->accept();
71 }
72
73
74
75 /////////////////////////////////////////////////////////////////////
76 //
77 // GuiChanges
78 //
79 /////////////////////////////////////////////////////////////////////
80
81 typedef QController<ControlChanges, GuiView<GuiChangesDialog> > ChangesBase;
82
83
84 GuiChanges::GuiChanges(Dialog & parent)
85         : ChangesBase(parent, _("Merge Changes"))
86 {
87 }
88
89
90 void GuiChanges::build_dialog()
91 {
92         dialog_.reset(new GuiChangesDialog(this));
93
94         bcview().setCancel(dialog_->closePB);
95         bcview().addReadOnly(dialog_->acceptPB);
96         bcview().addReadOnly(dialog_->rejectPB);
97 }
98
99
100 void GuiChanges::update_contents()
101 {
102         docstring text;
103         docstring author = controller().getChangeAuthor();
104         docstring date = controller().getChangeDate();
105
106         if (!author.empty())
107                 text += bformat(_("Change by %1$s\n\n"), author);
108         if (!date.empty())
109                 text += bformat(_("Change made at %1$s\n"), date);
110
111         dialog_->changeTB->setPlainText(toqstr(text));
112 }
113
114
115 void GuiChanges::next()
116 {
117         controller().next();
118 }
119
120
121 void GuiChanges::accept()
122 {
123         controller().accept();
124 }
125
126
127 void GuiChanges::reject()
128 {
129         controller().reject();
130 }
131
132 } // namespace frontend
133 } // namespace lyx
134
135 #include "GuiChanges_moc.cpp"