Classified ads
textedit.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the demonstration applications of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef TEXTEDIT_H
43 #define TEXTEDIT_H
44 
45 
46 #include <QMap>
47 #include <QPointer>
48 #include <QShortcut>
49 #include "../ui/dialogbase.h"
50 
51 QT_FORWARD_DECLARE_CLASS(QAction)
52 QT_FORWARD_DECLARE_CLASS(QComboBox)
53 QT_FORWARD_DECLARE_CLASS(QFontComboBox)
54 QT_FORWARD_DECLARE_CLASS(QTextEdit)
55 QT_FORWARD_DECLARE_CLASS(QTextCharFormat)
56 QT_FORWARD_DECLARE_CLASS(QMenu)
57 
58 class QLayout ;
59 class QWidget ;
60 class QMenuBar ;
61 class QPrinter ;
62 class QToolBar ;
63 
70 class TextEdit : public DialogBase
71 {
72  Q_OBJECT
73 
74 public:
80  TextEdit(QWidget* aParent,
81  MController* aController,
82  const Profile& aSelectedProfile);
83 
85  ~TextEdit() ;
86 
94  void initializeTextEditor(QTextEdit *aTextEdit,
95  QLayout *aLayOutForMenu,
96  QLayout* aWidgetForActionsUpper,
97  QLayout* aWidgetForActionsLower) ;
98 protected:
99  virtual void closeEvent(QCloseEvent *e);
100 
101 private:
102  void setupFileActions();
103  void setupEditActions();
104  void setupTextActions();
105  bool load(const QString &f);
106  bool maybeSave();
107  void setCurrentFileName(const QString &fileName);
108 
109 private slots:
110  void fileNew();
111  void fileOpen();
112  bool fileSave();
113  bool fileSaveAs();
114  void filePrint();
115  void filePrintPreview();
116  void filePrintPdf();
117 
118  void textBold();
119  void textUnderline();
120  void textItalic();
121  void textFamily(const QString &f);
122  void textSize(const QString &p);
123  void textStyle(int styleIndex);
124  void textColor();
125  void textAlign(QAction *a);
126 
127  void currentCharFormatChanged(const QTextCharFormat &format);
128  void cursorPositionChanged();
129 
130  void clipboardDataChanged();
131  void printPreview(QPrinter *);
132 
133 private:
134  void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
135  void fontChanged(const QFont &f);
136  void colorChanged(const QColor &c);
137  void alignmentChanged(Qt::Alignment a);
139  void addAction(QAction* aAction) ;
140  void addAction(QWidget* aAction,bool aLower=true) ;
142  QMenuBar* menuBar() { return iDialogMenuBar ; } ;
143 protected: // variables
144  QTextEdit *textEdit;
145 private: // variables
146  QAction *actionSave,
147  *actionTextBold,
148  *actionTextUnderline,
149  *actionTextItalic,
150  *actionTextColor,
151  *actionAlignLeft,
152  *actionAlignCenter,
153  *actionAlignRight,
154  *actionAlignJustify,
155  *actionUndo,
156  *actionRedo,
157  *actionCut,
158  *actionCopy,
159  *actionPaste;
160 
161  QComboBox *comboStyle;
162  QFontComboBox *comboFont;
163  QComboBox *comboSize;
164 
165  QToolBar *tb;
166  QString fileName;
169  QMenuBar* iDialogMenuBar ;
170 };
171 
172 #endif
QAction * actionUndo
Definition: textedit.h:146
QMenuBar * iDialogMenuBar
Definition: textedit.h:169
QComboBox * comboStyle
Definition: textedit.h:161
QString fileName
Definition: textedit.h:166
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:39
QFontComboBox * comboFont
Definition: textedit.h:162
QLayout * iWidgetForActionsUpper
Definition: textedit.h:167
QComboBox * comboSize
Definition: textedit.h:163
QToolBar * tb
Definition: textedit.h:165
Carrier-class for user-profile data.
Definition: profile.h:36
base-class for content-posting dialogs of classified ads
Definition: dialogbase.h:31
QLayout * iWidgetForActionsLower
Definition: textedit.h:168
text editor class.
Definition: textedit.h:70