author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 18 | 2f34d5167611 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt Linguist of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef MESSAGEEDITORWIDGETS_H |
|
43 |
#define MESSAGEEDITORWIDGETS_H |
|
44 |
||
45 |
#include <QIcon> |
|
46 |
#include <QImage> |
|
47 |
#include <QLabel> |
|
48 |
#include <QMap> |
|
49 |
#include <QTextEdit> |
|
50 |
#include <QUrl> |
|
51 |
#include <QWidget> |
|
52 |
||
53 |
QT_BEGIN_NAMESPACE |
|
54 |
||
55 |
class QAbstractButton; |
|
56 |
class QAction; |
|
57 |
class QContextMenuEvent; |
|
58 |
class QKeyEvent; |
|
59 |
class QMenu; |
|
60 |
class QSizeF; |
|
61 |
class QString; |
|
62 |
class QVariant; |
|
63 |
||
64 |
class MessageHighlighter; |
|
65 |
||
66 |
/* |
|
67 |
Automatically adapt height to document contents |
|
68 |
*/ |
|
69 |
class ExpandingTextEdit : public QTextEdit |
|
70 |
{ |
|
71 |
Q_OBJECT |
|
72 |
||
73 |
public: |
|
74 |
ExpandingTextEdit(QWidget *parent = 0); |
|
75 |
QSize sizeHint() const; |
|
76 |
QSize minimumSizeHint() const; |
|
77 |
||
78 |
private slots: |
|
79 |
void updateHeight(const QSizeF &documentSize); |
|
80 |
void reallyEnsureCursorVisible(); |
|
81 |
||
82 |
private: |
|
83 |
int m_minimumHeight; |
|
84 |
}; |
|
85 |
||
86 |
/* |
|
87 |
Format markup & control characters |
|
88 |
*/ |
|
89 |
class FormatTextEdit : public ExpandingTextEdit |
|
90 |
{ |
|
91 |
Q_OBJECT |
|
92 |
public: |
|
93 |
FormatTextEdit(QWidget *parent = 0); |
|
94 |
void setEditable(bool editable); |
|
95 |
||
96 |
public slots: |
|
97 |
void setPlainText(const QString & text, bool userAction); |
|
98 |
||
99 |
private: |
|
100 |
MessageHighlighter *m_highlighter; |
|
101 |
}; |
|
102 |
||
103 |
/* |
|
104 |
Displays text field & associated label |
|
105 |
*/ |
|
106 |
class FormWidget : public QWidget |
|
107 |
{ |
|
108 |
Q_OBJECT |
|
109 |
public: |
|
110 |
FormWidget(const QString &label, bool isEditable, QWidget *parent = 0); |
|
111 |
void setLabel(const QString &label) { m_label->setText(label); } |
|
112 |
void setTranslation(const QString &text, bool userAction = false); |
|
113 |
void clearTranslation() { setTranslation(QString(), false); } |
|
114 |
QString getTranslation() { return m_editor->toPlainText(); } |
|
115 |
void setEditingEnabled(bool enable); |
|
116 |
void setHideWhenEmpty(bool optional) { m_hideWhenEmpty = optional; } |
|
117 |
FormatTextEdit *getEditor() { return m_editor; } |
|
118 |
||
119 |
signals: |
|
120 |
void textChanged(QTextEdit *); |
|
121 |
void selectionChanged(QTextEdit *); |
|
122 |
void cursorPositionChanged(); |
|
123 |
||
124 |
private slots: |
|
125 |
void slotSelectionChanged(); |
|
126 |
void slotTextChanged(); |
|
127 |
||
128 |
private: |
|
129 |
QLabel *m_label; |
|
130 |
FormatTextEdit *m_editor; |
|
131 |
bool m_hideWhenEmpty; |
|
132 |
}; |
|
133 |
||
134 |
/* |
|
135 |
Displays text fields & associated label |
|
136 |
*/ |
|
137 |
class FormMultiWidget : public QWidget |
|
138 |
{ |
|
139 |
Q_OBJECT |
|
140 |
public: |
|
141 |
FormMultiWidget(const QString &label, QWidget *parent = 0); |
|
142 |
void setLabel(const QString &label) { m_label->setText(label); } |
|
143 |
void setTranslation(const QString &text, bool userAction = false); |
|
144 |
void clearTranslation() { setTranslation(QString(), false); } |
|
145 |
QString getTranslation() const; |
|
146 |
void setEditingEnabled(bool enable); |
|
147 |
void setMultiEnabled(bool enable); |
|
148 |
void setHideWhenEmpty(bool optional) { m_hideWhenEmpty = optional; } |
|
149 |
const QList<FormatTextEdit *> &getEditors() const { return m_editors; } |
|
150 |
||
151 |
signals: |
|
152 |
void editorCreated(QTextEdit *); |
|
153 |
void textChanged(QTextEdit *); |
|
154 |
void selectionChanged(QTextEdit *); |
|
155 |
void cursorPositionChanged(); |
|
156 |
||
157 |
protected: |
|
158 |
bool eventFilter(QObject *watched, QEvent *event); |
|
159 |
||
160 |
private slots: |
|
161 |
void slotTextChanged(); |
|
162 |
void slotSelectionChanged(); |
|
163 |
void minusButtonClicked(); |
|
164 |
void plusButtonClicked(); |
|
165 |
||
166 |
private: |
|
167 |
void addEditor(int idx); |
|
168 |
void updateLayout(); |
|
169 |
QAbstractButton *makeButton(const QIcon &icon, const char *slot); |
|
170 |
void insertEditor(int idx); |
|
171 |
void deleteEditor(int idx); |
|
172 |
||
173 |
QLabel *m_label; |
|
174 |
QList<FormatTextEdit *> m_editors; |
|
175 |
QList<QWidget *> m_plusButtons; |
|
176 |
QList<QAbstractButton *> m_minusButtons; |
|
177 |
bool m_hideWhenEmpty; |
|
178 |
bool m_multiEnabled; |
|
179 |
QIcon m_plusIcon, m_minusIcon; |
|
180 |
}; |
|
181 |
||
182 |
QT_END_NAMESPACE |
|
183 |
||
184 |
#endif // MESSAGEEDITORWIDGETS_H |