]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiParagraph.h
pimpl not needed here
[lyx.git] / src / frontends / qt4 / GuiParagraph.h
1 // -*- C++ -*-
2 /**
3  * \file GuiParagraph.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  * \author John Levon
9  * \author Abdelrazak Younes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef GUIPARAGRAPH_H
15 #define GUIPARAGRAPH_H
16
17 // Uncomment this if you prefer dock widget
18 //#define USE_DOCK_WIDGET
19
20 #include "Layout.h"
21 #include "ui_ParagraphUi.h"
22 #include "Dialog.h"
23 #include "ParagraphParameters.h"
24 #include "GuiView.h"
25 #include "qt_helpers.h"
26 #include "debug.h"
27
28 #include <QCloseEvent>
29 #include <QDialog>
30 #include <QSettings>
31 #include <QShowEvent>
32 #include <QGridLayout>
33
34 #include <map>
35 #include <string>
36
37 namespace lyx {
38 namespace frontend {
39
40 class GuiParagraph
41         : public QDialog, public Ui::ParagraphUi, public Dialog
42 {
43         Q_OBJECT
44 public:
45         GuiParagraph(LyXView & lv);
46
47         /// update
48         void updateView();
49
50 private:
51         ///
52         void checkAlignmentRadioButtons();
53         ///
54         void alignmentToRadioButtons(LyXAlignment align = LYX_ALIGN_LAYOUT);
55         ///
56         LyXAlignment getAlignmentFromDialog();
57         ///
58         typedef std::map<LyXAlignment, QRadioButton *> RadioMap;
59         RadioMap radioMap;
60         typedef std::map<LyXAlignment, docstring> AlignmentLabels;
61         AlignmentLabels labelMap;
62
63         QString const alignDefaultLabel;
64
65         void applyView() {}
66         void hideView()
67         {
68                 clearParams();
69                 QDialog::hide();
70         }
71         void showData(std::string const & data)
72         {
73                 initialiseParams(data);
74                 showView();
75         }
76         void showView()
77         {
78                 updateView();  // make sure its up-to-date
79                 QDialog::show();
80                 raise();
81                 activateWindow();
82         }
83         bool isVisibleView() const { return QDialog::isVisible(); }
84         void checkStatus() { updateView(); }
85         void redraw() { redrawView(); }
86         void redrawView() {}
87         void updateData(std::string const & data)
88         {
89                 initialiseParams(data);
90                 updateView();
91         }
92         void partialUpdateView(int /*id*/) {}
93         std::string name() const { return "paragraph"; }
94
95 private:
96         std::string name_;
97
98         void showEvent(QShowEvent * e)
99         {
100 #if (QT_VERSION >= 0x040200)
101                 QSettings settings;
102                 std::string key = name_ + "/geometry";
103                 QDialog::restoreGeometry(settings.value(key.c_str()).toByteArray());
104 #endif
105             QDialog::showEvent(e);
106         }
107
108         void closeEvent(QCloseEvent * e)
109         {
110 #if (QT_VERSION >= 0x040200)
111                 QSettings settings;
112                 std::string key = name_ + "/geometry";
113                 settings.setValue(key.c_str(), QDialog::saveGeometry());
114 #endif
115                 QDialog::closeEvent(e);
116         }
117
118 private Q_SLOTS:
119         ///
120         void changed();
121         ///
122         void on_synchronizedViewCB_toggled();
123         ///
124         void on_restorePB_clicked();
125         ///
126         void on_linespacing_activated(int);
127         /// Apply changes
128         void on_applyPB_clicked();
129
130 private:
131         ///
132         bool initialiseParams(std::string const & /*data*/) { return true; }
133         /// clean-up on hide.
134         void clearParams() {}
135         ///
136         void dispatchParams();
137         ///
138         bool isBufferDependent() const { return true; }
139         ///
140         ParagraphParameters & params();
141         ///
142         ParagraphParameters const & params() const;
143         ///
144         bool haveMulitParSelection();
145         ///
146         bool canIndent() const;
147         ///
148         LyXAlignment alignPossible() const;
149         ///
150         LyXAlignment alignDefault() const;
151
152 private:
153         ParagraphParameters multiparsel_;
154 };
155
156 } // namespace frontend
157 } // namespace lyx
158
159 #endif // QPARAGRAPH_H