]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiChanges.cpp
6375e793183a8fd21dd4f38ed1f5796a76673d98
[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 "qt_helpers.h"
16
17 #include "support/lstrings.h"
18
19 #include <QCloseEvent>
20 #include <QTextBrowser>
21
22 using lyx::support::bformat;
23
24
25 namespace lyx {
26 namespace frontend {
27
28 /////////////////////////////////////////////////////////////////////
29 //
30 // GuiChangesDialog
31 //
32 /////////////////////////////////////////////////////////////////////
33
34 GuiChangesDialog::GuiChangesDialog(GuiChanges * form)
35         : form_(form)
36 {
37         setupUi(this);
38         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
39         connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed()));
40         connect(rejectPB, SIGNAL(clicked()), this, SLOT(rejectPressed()));
41         connect(acceptPB, SIGNAL(clicked()), this, SLOT(acceptPressed()));
42 }
43
44
45 void GuiChangesDialog::nextPressed()
46 {
47         form_->next();
48 }
49
50
51 void GuiChangesDialog::acceptPressed()
52 {
53         form_->accept();
54 }
55
56
57 void GuiChangesDialog::rejectPressed()
58 {
59         form_->reject();
60 }
61
62
63 void GuiChangesDialog::closeEvent(QCloseEvent *e)
64 {
65         form_->slotWMHide();
66         e->accept();
67 }
68
69
70
71 /////////////////////////////////////////////////////////////////////
72 //
73 // GuiChanges
74 //
75 /////////////////////////////////////////////////////////////////////
76
77
78 GuiChanges::GuiChanges(GuiDialog & parent)
79         : GuiView<GuiChangesDialog>(parent, _("Merge Changes"))
80 {
81 }
82
83
84 void GuiChanges::build_dialog()
85 {
86         dialog_.reset(new GuiChangesDialog(this));
87
88         bc().setCancel(dialog_->closePB);
89         bc().addReadOnly(dialog_->acceptPB);
90         bc().addReadOnly(dialog_->rejectPB);
91 }
92
93
94 void GuiChanges::update_contents()
95 {
96         docstring text;
97         docstring author = controller().getChangeAuthor();
98         docstring date = controller().getChangeDate();
99
100         if (!author.empty())
101                 text += bformat(_("Change by %1$s\n\n"), author);
102         if (!date.empty())
103                 text += bformat(_("Change made at %1$s\n"), date);
104
105         dialog_->changeTB->setPlainText(toqstr(text));
106 }
107
108
109 void GuiChanges::next()
110 {
111         controller().next();
112 }
113
114
115 void GuiChanges::accept()
116 {
117         controller().accept();
118 }
119
120
121 void GuiChanges::reject()
122 {
123         controller().reject();
124 }
125
126 } // namespace frontend
127 } // namespace lyx
128
129 #include "GuiChanges_moc.cpp"