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  Q_OBJECT
72 
73 public:
79  TextEdit(QWidget* aParent,
80  MController* aController,
81  Profile& aSelectedProfile);
82 
84  ~TextEdit() ;
85 
93  void initializeTextEditor(QTextEdit *aTextEdit,
94  QLayout *aLayOutForMenu,
95  QLayout* aWidgetForActionsUpper,
96  QLayout* aWidgetForActionsLower) ;
97 public slots:
102  virtual void linkReady(const QString& aLinkAddress,
103  const QString& aLinkLabel) ;
104 protected:
105  virtual void closeEvent(QCloseEvent *e);
106 private:
107  void setupFileActions();
108  void setupEditActions();
109  void setupTextActions();
110  bool load(const QString &f);
111  bool maybeSave();
112  void setCurrentFileName(const QString &fileName);
113 private slots:
114  void fileNew();
115  void fileOpen();
116  bool fileSave();
117  bool fileSaveAs();
118  void filePrint();
119  void filePrintPreview();
120  void filePrintPdf();
121 
122  void textBold();
123  void textUnderline();
124  void textItalic();
125  void textFamily(const QString &f);
126  void textSize(const QString &p);
127  void textStyle(int styleIndex);
128  void textColor();
129  void textAlign(QAction *a);
130 
131  void currentCharFormatChanged(const QTextCharFormat &format);
132  void cursorPositionChanged();
133 
134  void clipboardDataChanged();
135  void printPreview(QPrinter *);
136  void insertLinkSelected() ;
137  void insertImageSelected() ;
138 private:
139  void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
140  void fontChanged(const QFont &f);
141  void colorChanged(const QColor &c);
142  void alignmentChanged(Qt::Alignment a);
144  void addAction(QAction* aAction) ;
145  void addAction(QWidget* aAction,bool aLower=true) ;
147  QMenuBar* menuBar() {
148  return iDialogMenuBar ;
149  } ;
150 protected: // variables
151  QTextEdit *textEdit;
152 private: // variables
153  QAction *actionSave,
154  *actionTextBold,
155  *actionTextUnderline,
156  *actionTextItalic,
157  *actionTextColor,
158  *actionAlignLeft,
159  *actionAlignCenter,
160  *actionAlignRight,
161  *actionAlignJustify,
162  *actionUndo,
163  *actionRedo,
164  *actionCut,
165  *actionCopy,
166  *actionPaste,
167  *actionInsertLink,
168  *actionInsertImage;
169 
170  QComboBox *comboStyle;
171  QFontComboBox *comboFont;
172  QComboBox *comboSize;
173 
174  QToolBar *tb;
175  QString fileName;
178  QMenuBar* iDialogMenuBar ;
179 };
180 
181 #endif
QAction * actionUndo
Definition: textedit.h:153
QMenuBar * iDialogMenuBar
Definition: textedit.h:178
QComboBox * comboStyle
Definition: textedit.h:170
QString fileName
Definition: textedit.h:175
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:43
QMenuBar * menuBar()
Definition: textedit.h:147
QFontComboBox * comboFont
Definition: textedit.h:171
QTextEdit * textEdit
Definition: textedit.h:149
QLayout * iWidgetForActionsUpper
Definition: textedit.h:176
QComboBox * comboSize
Definition: textedit.h:172
QToolBar * tb
Definition: textedit.h:174
Carrier-class for user-profile data.
Definition: profile.h:37
base-class for content-posting dialogs of classified ads
Definition: dialogbase.h:32
QLayout * iWidgetForActionsLower
Definition: textedit.h:177
text editor class.
Definition: textedit.h:70