texteditor.h
Go to the documentation of this file.
1 /****************************************************************************
2 SocNetV: Social Network Visualizer
3 version: 3.1
4 Written in Qt
5 
6  texteditor.h
7  -------------------
8  copyright : (C) 2005-2023 by Dimitris B. Kalamaras
9  project site : https://socnetv.org
10 
11 *****************************************************************************/
12 
13 /*******************************************************************************
14 * This program is free software: you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation, either version 3 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
26 ********************************************************************************/
27 
28 #ifndef TEXTEDITOR_H
29 #define TEXTEDITOR_H
30 
31 #include <QMainWindow>
32 //#include <QMimeData>
33 
34 class QAction;
35 class QMenu;
36 class QTextEdit;
37 
38 class TextEditor : public QMainWindow
39 {
40  Q_OBJECT
41 
42 public:
43  TextEditor(const QString &fileName ,
44  QWidget *parent= Q_NULLPTR , const bool &format=false);
45 
46 protected:
47  void closeEvent(QCloseEvent *event);
48 
49 private slots:
50  void newFile();
51  void open();
52  bool save();
53  bool saveAs();
54  void about();
55  void documentWasModified();
56 //protected:
57 // bool canInsertFromMimeData(const QMimeData *source) const;
58 // void insertFromMimeData(const QMimeData *source) ;
59 private:
60  void createActions();
61  void createMenus();
62  void createToolBars();
63  void createStatusBar();
64  void readSettings();
65  void writeSettings();
66  bool maybeSave();
67  void loadFile(const QString &fileName);
68  bool saveFile(const QString &fileName);
69  void setCurrentFile(const QString &fileName);
70  QString strippedName(const QString &fullFileName);
71 
72  QTextEdit *textEdit;
73  QString curFile;
74  bool formatHTML;
75  QMenu *fileMenu;
76  QMenu *editMenu;
77  QMenu *helpMenu;
78  QToolBar *fileToolBar;
79  QToolBar *editToolBar;
80  QAction *newAct;
81  QAction *openAct;
82  QAction *saveAct;
83  QAction *saveAsAct;
84  QAction *exitAct;
85  QAction *cutAct;
86  QAction *copyAct;
87  QAction *pasteAct;
88  QAction *aboutAct;
89  QAction *aboutQtAct;
90 
91 };
92 
93 
94 
95 #endif
Definition: texteditor.h:39
QAction * exitAct
Definition: texteditor.h:84
bool save()
Definition: texteditor.cpp:87
bool saveAs()
Definition: texteditor.cpp:96
bool maybeSave()
Definition: texteditor.cpp:228
QAction * openAct
Definition: texteditor.h:81
void open()
Definition: texteditor.cpp:78
QAction * copyAct
Definition: texteditor.h:86
QMenu * editMenu
Definition: texteditor.h:76
void closeEvent(QCloseEvent *event)
Definition: texteditor.cpp:60
void createToolBars()
Definition: texteditor.cpp:194
void createActions()
Definition: texteditor.cpp:112
void about()
Definition: texteditor.cpp:334
void createStatusBar()
Definition: texteditor.cpp:207
QAction * saveAct
Definition: texteditor.h:82
QAction * cutAct
Definition: texteditor.h:85
void readSettings()
Definition: texteditor.cpp:212
QAction * newAct
Definition: texteditor.h:80
QAction * aboutQtAct
Definition: texteditor.h:89
QAction * pasteAct
Definition: texteditor.h:87
void setCurrentFile(const QString &fileName)
Definition: texteditor.cpp:295
QToolBar * editToolBar
Definition: texteditor.h:79
QToolBar * fileToolBar
Definition: texteditor.h:78
void newFile()
Definition: texteditor.cpp:70
QMenu * helpMenu
Definition: texteditor.h:77
bool formatHTML
Definition: texteditor.h:74
void writeSettings()
Definition: texteditor.cpp:221
QString curFile
Definition: texteditor.h:73
QMenu * fileMenu
Definition: texteditor.h:75
QAction * aboutAct
Definition: texteditor.h:88
TextEditor(const QString &fileName, QWidget *parent=Q_NULLPTR, const bool &format=false)
Definition: texteditor.cpp:32
bool saveFile(const QString &fileName)
Definition: texteditor.cpp:268
QAction * saveAsAct
Definition: texteditor.h:83
QTextEdit * textEdit
Definition: texteditor.h:72
QString strippedName(const QString &fullFileName)
Definition: texteditor.cpp:310
void createMenus()
Definition: texteditor.cpp:172
void loadFile(const QString &fileName)
Definition: texteditor.cpp:244
void documentWasModified()
Definition: texteditor.cpp:107