]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QChanges.C
more dialog merging
[lyx.git] / src / frontends / qt4 / QChanges.C
1 /**
2  * \file QChanges.C
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 "QChanges.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 // QChangesDialog
35 //
36 /////////////////////////////////////////////////////////////////////
37
38 QChangesDialog::QChangesDialog(QChanges * 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 QChangesDialog::nextPressed()
50 {
51         form_->next();
52 }
53
54
55 void QChangesDialog::acceptPressed()
56 {
57         form_->accept();
58 }
59
60
61 void QChangesDialog::rejectPressed()
62 {
63         form_->reject();
64 }
65
66
67 void QChangesDialog::closeEvent(QCloseEvent *e)
68 {
69         form_->slotWMHide();
70         e->accept();
71 }
72
73
74
75 /////////////////////////////////////////////////////////////////////
76 //
77 // QChanges
78 //
79 /////////////////////////////////////////////////////////////////////
80
81 typedef QController<ControlChanges, QView<QChangesDialog> > ChangesBase;
82
83
84 QChanges::QChanges(Dialog & parent)
85         : ChangesBase(parent, _("Merge Changes"))
86 {
87 }
88
89
90 void QChanges::build_dialog()
91 {
92         dialog_.reset(new QChangesDialog(this));
93
94         bcview().setCancel(dialog_->closePB);
95         bcview().addReadOnly(dialog_->acceptPB);
96         bcview().addReadOnly(dialog_->rejectPB);
97 }
98
99
100 void QChanges::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 QChanges::next()
116 {
117         controller().next();
118 }
119
120
121 void QChanges::accept()
122 {
123         controller().accept();
124 }
125
126
127 void QChanges::reject()
128 {
129         controller().reject();
130 }
131
132 } // namespace frontend
133 } // namespace lyx
134
135 #include "QChanges_moc.cpp"