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