1 | /*! |
---|
2 | * \file mainwindow.h |
---|
3 | * \author Copyright © 2007-2014 Oleksii Serdiuk <contacts[at]oleksii[dot]name> |
---|
4 | * |
---|
5 | * $Id: $Format:%h %ai %an$ $ |
---|
6 | * $URL: http://tspsg.info/ $ |
---|
7 | * |
---|
8 | * \brief Defines MainWindow class. |
---|
9 | * |
---|
10 | * <b>TSPSG: TSP Solver and Generator</b> |
---|
11 | * |
---|
12 | * This file is part of TSPSG. |
---|
13 | * |
---|
14 | * TSPSG 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 2 of the License, or |
---|
17 | * (at your option) any later version. |
---|
18 | * |
---|
19 | * TSPSG 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 TSPSG. If not, see <http://www.gnu.org/licenses/>. |
---|
26 | */ |
---|
27 | |
---|
28 | #ifndef MAINWINDOW_H |
---|
29 | #define MAINWINDOW_H |
---|
30 | |
---|
31 | #include "globals.h" |
---|
32 | |
---|
33 | #include "ui_mainwindow.h" |
---|
34 | #include "tspsolver.h" |
---|
35 | |
---|
36 | #include <QPicture> |
---|
37 | |
---|
38 | #ifdef Q_OS_WIN32 |
---|
39 | // Forward declaration. A real one is in shobjidl.h |
---|
40 | struct ITaskbarList3; |
---|
41 | #endif |
---|
42 | |
---|
43 | class CTSPModel; |
---|
44 | |
---|
45 | #ifndef HANDHELD |
---|
46 | class QtToolbarDialog; |
---|
47 | class QtToolBarManager; |
---|
48 | #endif |
---|
49 | |
---|
50 | #ifndef QT_NO_PRINTER |
---|
51 | class QPrinter; |
---|
52 | #endif |
---|
53 | |
---|
54 | /*! |
---|
55 | * \brief Class for handling Main Window UI and logic. |
---|
56 | * \author Copyright © 2007-2014 Oleksii Serdiuk <contacts[at]oleksii[dot]name> |
---|
57 | */ |
---|
58 | class MainWindow: public QMainWindow, Ui::MainWindow |
---|
59 | { |
---|
60 | Q_OBJECT |
---|
61 | |
---|
62 | public: |
---|
63 | MainWindow(QWidget *parent = 0); |
---|
64 | ~MainWindow(); |
---|
65 | |
---|
66 | #ifdef Q_OS_BLACKBERRY |
---|
67 | public slots: |
---|
68 | void setWindowModified(bool modified); |
---|
69 | #endif |
---|
70 | |
---|
71 | private slots: |
---|
72 | // Actions |
---|
73 | void actionFileNewTriggered(); |
---|
74 | void actionFileOpenTriggered(); |
---|
75 | bool actionFileSaveTriggered(); |
---|
76 | void actionFileSaveAsTaskTriggered(); |
---|
77 | void actionFileSaveAsSolutionTriggered(); |
---|
78 | #ifndef QT_NO_PRINTDIALOG |
---|
79 | void actionFilePrintPreviewTriggered(); |
---|
80 | void actionFilePageSetupTriggered(); |
---|
81 | void actionFilePrintTriggered(); |
---|
82 | #endif // QT_NO_PRINTDIALOG |
---|
83 | void actionSettingsPreferencesTriggered(); |
---|
84 | void actionSettingsLanguageAutodetectTriggered(bool checked); |
---|
85 | void groupSettingsLanguageListTriggered(QAction *action); |
---|
86 | void actionSettingsStyleSystemTriggered(bool checked); |
---|
87 | void groupSettingsStyleListTriggered(QAction *action); |
---|
88 | #ifndef HANDHELD |
---|
89 | void actionSettingsToolbarsConfigureTriggered(); |
---|
90 | #endif // HANDHELD |
---|
91 | void actionHelpOnlineSupportTriggered(); |
---|
92 | void actionHelpReportBugTriggered(); |
---|
93 | void actionHelpCheck4UpdatesTriggered(); |
---|
94 | void actionHelpAboutTriggered(); |
---|
95 | // Buttons |
---|
96 | void buttonBackToTaskClicked(); |
---|
97 | void buttonRandomClicked(); |
---|
98 | void buttonSolveClicked(); |
---|
99 | |
---|
100 | void dataChanged(); |
---|
101 | void dataChanged(const QModelIndex &tl, const QModelIndex &br); |
---|
102 | #ifdef Q_OS_WINCE_WM |
---|
103 | void changeEvent(QEvent *ev); |
---|
104 | void desktopResized(int screen); |
---|
105 | #endif // Q_OS_WINCE_WM |
---|
106 | void numCitiesChanged(int nCities); |
---|
107 | #ifndef QT_NO_PRINTER |
---|
108 | void printPreview(QPrinter *printer); |
---|
109 | #endif // QT_NO_PRINTER |
---|
110 | #ifdef Q_OS_WIN32 |
---|
111 | void solverRoutePartFound(int n); |
---|
112 | #endif // Q_OS_WIN32 |
---|
113 | void spinCitiesValueChanged(int nCities); |
---|
114 | |
---|
115 | private: |
---|
116 | QString fileName; |
---|
117 | QActionGroup *groupSettingsLanguageList; |
---|
118 | QActionGroup *groupSettingsStyleList; |
---|
119 | #ifndef HANDHELD |
---|
120 | QAction *actionSettingsToolbarsConfigure; |
---|
121 | QtToolBarManager *toolBarManager; |
---|
122 | #endif // HANDHELD |
---|
123 | #ifndef QT_NO_PRINTER |
---|
124 | QPrinter *printer; |
---|
125 | #ifndef QT_NO_PRINTDIALOG |
---|
126 | QAction *actionFilePrintPreview; |
---|
127 | QAction *actionFilePageSetup; |
---|
128 | QAction *actionFilePrint; |
---|
129 | #endif // QT_NO_PRINTDIALOG |
---|
130 | #endif // QT_NO_PRINTER |
---|
131 | QAction *actionHelpCheck4Updates; |
---|
132 | #ifdef Q_OS_SYMBIAN |
---|
133 | QAction *actionRightSoftKey; |
---|
134 | #endif |
---|
135 | QSettings *settings; |
---|
136 | CTSPModel *tspmodel; |
---|
137 | #ifdef Q_OS_WINCE_WM |
---|
138 | QRect currentGeometry; |
---|
139 | #endif // Q_OS_WINCE_WM |
---|
140 | |
---|
141 | #ifdef Q_OS_WIN32 |
---|
142 | ITaskbarList3 *tl; |
---|
143 | #endif // Q_OS_WIN32 |
---|
144 | |
---|
145 | // The solution graph SVG |
---|
146 | QPicture graph; |
---|
147 | |
---|
148 | // Formats |
---|
149 | QTextTableFormat fmt_table; |
---|
150 | QTextBlockFormat fmt_paragraph, |
---|
151 | fmt_lastparagraph, |
---|
152 | fmt_cell; |
---|
153 | QTextCharFormat fmt_default, |
---|
154 | fmt_selected, |
---|
155 | fmt_alternate, |
---|
156 | fmt_altlist; |
---|
157 | |
---|
158 | void check4Updates(bool silent = false); |
---|
159 | void closeEvent(QCloseEvent *ev); |
---|
160 | void dragEnterEvent(QDragEnterEvent *ev); |
---|
161 | void drawNode(QPainter &pic, int nstep, bool left = false, TSPSolver::SStep *step = NULL); |
---|
162 | void dropEvent(QDropEvent *ev); |
---|
163 | QByteArray generateImage(const QString &format); |
---|
164 | void initDocStyleSheet(); |
---|
165 | void loadLangList(); |
---|
166 | bool loadLanguage(const QString &lang = QString()); |
---|
167 | void loadStyleList(); |
---|
168 | void loadToolbarList(); |
---|
169 | bool maybeSave(); |
---|
170 | void outputMatrix(QTextCursor &cur, const TSPSolver::TMatrix &matrix); |
---|
171 | void outputMatrix(QTextCursor &cur, const TSPSolver::SStep &step); |
---|
172 | #ifdef Q_OS_SYMBIAN |
---|
173 | void resizeEvent(QResizeEvent *ev); |
---|
174 | #endif // Q_OS_SYMBIAN |
---|
175 | void retranslateUi(bool all = true); |
---|
176 | bool saveTask(); |
---|
177 | void setFileName(const QString &fileName = tr("Untitled") + ".tspt"); |
---|
178 | void setupUi(); |
---|
179 | void toggleSolutionActions(bool enable = true); |
---|
180 | void toggleTranclucency(bool enable); |
---|
181 | }; |
---|
182 | |
---|
183 | #ifdef Q_OS_SYMBIAN |
---|
184 | #include <QMessageBox> |
---|
185 | // A quickly hacked QMessageBox for Symbian that supports three buttons. |
---|
186 | class QSMessageBox: public QMessageBox { |
---|
187 | Q_OBJECT |
---|
188 | private slots: |
---|
189 | void cancel(); |
---|
190 | void discard(); |
---|
191 | public: |
---|
192 | QSMessageBox(QWidget *parent = 0); |
---|
193 | }; |
---|
194 | #endif // Q_OS_SYMBIAN |
---|
195 | |
---|
196 | #endif // MAINWINDOW_H |
---|