comparison src/MainWindow.h @ 751:ac165b6ae67e

Done some refactoring: - Moved includes into the cpp files where possible and using class pre-declarations if possible - Made class member variable names begin with an underscore - Made by uic created header files be used as class members instead of inherting them - Renamed some variables to reflect their purpose better - Added some NULL initializations and added some comments - Rearranged some include and declaration code parts to be consistent and better readable - Updated for QScintilla 2.4.5 - Made UiGuiSettings be accessed via a shared pointer only git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@1028 59b1889a-e5ac-428c-b0c7-476e01d41282
author thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
date Thu, 14 Oct 2010 19:52:47 +0000
parents aae5a8d04f70
children 49839f3eed83
comparison
equal deleted inserted replaced
750:a884b5861e93 751:ac165b6ae67e
18 ***************************************************************************/ 18 ***************************************************************************/
19 19
20 #ifndef MAINWINDOW_H 20 #ifndef MAINWINDOW_H
21 #define MAINWINDOW_H 21 #define MAINWINDOW_H
22 22
23 #include "ui_MainWindow.h" 23 #include <QMainWindow>
24 #include "ui_ToolBarWidget.h"
25 #include "AboutDialog.h"
26 #include "AboutDialogGraphicsView.h"
27 #include "UiGuiSettings.h"
28 #include "UiGuiSettingsDialog.h"
29 #include "UiGuiHighlighter.h"
30 #include "IndentHandler.h"
31 #include "UpdateCheckDialog.h"
32 24
33 #include <QWidget> 25 class UiGuiSettings;
34 #include <QString> 26 class UiGuiSettingsDialog;
35 #include <QScrollBar> 27 class AboutDialog;
36 #include <QTextCursor> 28 class AboutDialogGraphicsView;
37 #include <QFileDialog> 29 class UiGuiHighlighter;
38 #include <QTextStream> 30 class IndentHandler;
39 #include <QPrinter> 31 class UpdateCheckDialog;
40 #include <QPrintDialog> 32 namespace Ui {
41 #include <QCloseEvent> 33 class ToolBarWidget;
42 #include <QHelpEvent> 34 class MainWindowUi;
43 #include <QToolTip> 35 }
44 #include <QTranslator>
45 #include <QLocale>
46 #include <QTextCodec>
47 #include <QDate>
48 36
49 #include <Qsci/qsciscintilla.h> 37 class QLabel;
50 #include <Qsci/qsciprinter.h> 38 class QScrollBar;
39 class QActionGroup;
40 class QTranslator;
51 41
52 class MainWindow : public QMainWindow, private Ui::MainWindowUi 42 class QsciScintilla;
43
44
45 class MainWindow : public QMainWindow
53 { 46 {
54 Q_OBJECT 47 Q_OBJECT
55 48
56 public: 49 public:
57 //! Constructor 50 //! Constructor
58 MainWindow(QString file2OpenOnStart = "", QWidget *parent = 0); 51 MainWindow(QString file2OpenOnStart = "", QWidget *parent = NULL);
59
60 private:
61 QString loadFile(QString filePath);
62 QString openFileDialog(QString dialogHeaderStr, QString startPath, QString fileMaskStr);
63 void updateWindowTitle();
64 void loadLastOpenedFile();
65 void saveSettings();
66 bool maybeSave();
67 void createEncodingMenu();
68 void createHighlighterMenu();
69 bool initApplicationLanguage();
70 void initMainWindow();
71 void initToolBar();
72 void initTextEditor();
73 void initSyntaxHighlighter();
74 void initIndenter();
75 void changeEvent(QEvent *event);
76 void dragEnterEvent(QDragEnterEvent *event);
77 void dropEvent(QDropEvent *event);
78
79 QsciScintilla *qSciSourceCodeEditor;
80 UiGuiSettings *settings;
81
82 QString currentEncoding;
83 QString sourceFileContent;
84 QString sourceFormattedContent;
85 QString sourceViewContent;
86 UiGuiHighlighter *highlighter;
87 QScrollBar *textEditVScrollBar;
88 AboutDialog *aboutDialog;
89 AboutDialogGraphicsView *aboutDialogGraphicsView;
90 UiGuiSettingsDialog *settingsDialog;
91 int textEditLastScrollPos;
92 int currentIndenterID;
93 bool loadLastSourceCodeFileOnStartup;
94 QString currentSourceFile;
95 QString currentSourceFileExtension;
96 QString savedSourceContent;
97 QActionGroup *encodingActionGroup;
98 QActionGroup *saveEncodedActionGroup;
99 QActionGroup *highlighterActionGroup;
100 QTranslator *uiGuiTranslator;
101 QTranslator *qTTranslator;
102 bool isFirstRunOfThisVersion;
103
104 bool sourceCodeChanged;
105 bool scrollPositionChanged;
106 bool indentSettingsChanged;
107 bool previewToggled;
108 QStringList encodingsList;
109
110 Ui::ToolBarWidget *toolBarWidget;
111 IndentHandler *indentHandler;
112 UpdateCheckDialog *updateCheckDialog;
113 QLabel *textEditLineColumnInfoLabel;
114 52
115 protected: 53 protected:
116 void closeEvent( QCloseEvent *event ); 54 void closeEvent( QCloseEvent *event );
117 bool eventFilter(QObject *obj, QEvent *event); 55 bool eventFilter(QObject *obj, QEvent *event);
118 56
137 void updateRecentlyOpenedList(); 75 void updateRecentlyOpenedList();
138 void openFileFromRecentlyOpenedList(QAction* recentlyOpenedAction); 76 void openFileFromRecentlyOpenedList(QAction* recentlyOpenedAction);
139 void clearRecentlyOpenedList(); 77 void clearRecentlyOpenedList();
140 void showAboutDialog(); 78 void showAboutDialog();
141 void setStatusBarCursorPosInfo(int line, int column); 79 void setStatusBarCursorPosInfo(int line, int column);
80
81 private:
82 Ui::MainWindowUi *_mainWindowForm;
83
84 QString loadFile(QString filePath);
85 QString openFileDialog(QString dialogHeaderStr, QString startPath, QString fileMaskStr);
86 void updateWindowTitle();
87 void loadLastOpenedFile();
88 void saveSettings();
89 bool maybeSave();
90 void createEncodingMenu();
91 void createHighlighterMenu();
92 bool initApplicationLanguage();
93 void initMainWindow();
94 void initToolBar();
95 void initTextEditor();
96 void initSyntaxHighlighter();
97 void initIndenter();
98 void changeEvent(QEvent *event);
99 void dragEnterEvent(QDragEnterEvent *event);
100 void dropEvent(QDropEvent *event);
101
102 QsciScintilla *_qSciSourceCodeEditor;
103 QSharedPointer<UiGuiSettings> _settings;
104
105 QString _currentEncoding;
106 QString _sourceFileContent;
107 QString _sourceFormattedContent;
108 QString _sourceViewContent;
109 UiGuiHighlighter *_highlighter;
110 QScrollBar *_textEditVScrollBar;
111 AboutDialog *_aboutDialog;
112 AboutDialogGraphicsView *_aboutDialogGraphicsView;
113 UiGuiSettingsDialog *_settingsDialog;
114 int _textEditLastScrollPos;
115 int _currentIndenterID;
116 bool _loadLastSourceCodeFileOnStartup;
117 QString _currentSourceFile;
118 QString _currentSourceFileExtension;
119 QString _savedSourceContent;
120 QActionGroup *_encodingActionGroup;
121 QActionGroup *_saveEncodedActionGroup;
122 QActionGroup *_highlighterActionGroup;
123 QTranslator *_uiGuiTranslator;
124 QTranslator *_qTTranslator;
125 bool _isFirstRunOfThisVersion;
126
127 bool _sourceCodeChanged;
128 bool _scrollPositionChanged;
129 bool _indentSettingsChanged;
130 bool _previewToggled;
131 QStringList _encodingsList;
132
133 Ui::ToolBarWidget *_toolBarWidget;
134 IndentHandler *_indentHandler;
135 UpdateCheckDialog *_updateCheckDialog;
136 QLabel *_textEditLineColumnInfoLabel;
142 }; 137 };
143 138
144 #endif // MAINWINDOW_H 139 #endif // MAINWINDOW_H