source: tspsg/src/mainwindow.h @ b96b44b6b7

appveyorimgbotreadme
Last change on this file since b96b44b6b7 was 07e43cf61a, checked in by Oleksii Serdiuk, 12 years ago

Improved compilation time by about 30%.

By reducing number of includes to only required minimum.

NOTE: Compilation time comparison was done by measuring compilation time
while using only one thread (i.e., "make -j1").

  • Property mode set to 100644
File size: 5.3 KB
Line 
1/*!
2 * \file mainwindow.h
3 * \author Copyright &copy; 2007-2012 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 3 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
43class 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 &copy; 2007-2012 Oleksii Serdiuk <contacts[at]oleksii[dot]name>
57 */
58class MainWindow: public QMainWindow, Ui::MainWindow
59{
60    Q_OBJECT
61
62public:
63    MainWindow(QWidget *parent = 0);
64    ~MainWindow();
65
66private slots:
67// Actions
68    void actionFileNewTriggered();
69    void actionFileOpenTriggered();
70    bool actionFileSaveTriggered();
71    void actionFileSaveAsTaskTriggered();
72    void actionFileSaveAsSolutionTriggered();
73#ifndef QT_NO_PRINTER
74    void actionFilePrintPreviewTriggered();
75    void actionFilePageSetupTriggered();
76    void actionFilePrintTriggered();
77#endif // QT_NO_PRINTER
78    void actionSettingsPreferencesTriggered();
79    void actionSettingsLanguageAutodetectTriggered(bool checked);
80    void groupSettingsLanguageListTriggered(QAction *action);
81    void actionSettingsStyleSystemTriggered(bool checked);
82    void groupSettingsStyleListTriggered(QAction *action);
83#ifndef HANDHELD
84    void actionSettingsToolbarsConfigureTriggered();
85#endif // HANDHELD
86    void actionHelpOnlineSupportTriggered();
87    void actionHelpReportBugTriggered();
88    void actionHelpCheck4UpdatesTriggered();
89    void actionHelpAboutTriggered();
90// Buttons
91    void buttonBackToTaskClicked();
92    void buttonRandomClicked();
93    void buttonSolveClicked();
94
95    void dataChanged();
96    void dataChanged(const QModelIndex &tl, const QModelIndex &br);
97#ifdef Q_OS_WINCE_WM
98    void changeEvent(QEvent *ev);
99    void desktopResized(int screen);
100#endif // Q_OS_WINCE_WM
101    void numCitiesChanged(int nCities);
102#ifndef QT_NO_PRINTER
103    void printPreview(QPrinter *printer);
104#endif // QT_NO_PRINTER
105#ifdef Q_OS_WIN32
106    void solverRoutePartFound(int n);
107#endif // Q_OS_WIN32
108    void spinCitiesValueChanged(int nCities);
109
110private:
111    QString fileName;
112    QActionGroup *groupSettingsLanguageList;
113    QActionGroup *groupSettingsStyleList;
114#ifndef HANDHELD
115    QAction *actionSettingsToolbarsConfigure;
116    QtToolBarManager *toolBarManager;
117#endif // HANDHELD
118#ifndef QT_NO_PRINTER
119    QPrinter *printer;
120    QAction *actionFilePrintPreview;
121    QAction *actionFilePageSetup;
122    QAction *actionFilePrint;
123#endif // QT_NO_PRINTER
124    QAction *actionHelpCheck4Updates;
125#ifdef Q_OS_SYMBIAN
126    QAction *actionRightSoftKey;
127#endif
128    QSettings *settings;
129    CTSPModel *tspmodel;
130#ifdef Q_OS_WINCE_WM
131    QRect currentGeometry;
132#endif // Q_OS_WINCE_WM
133
134#ifdef Q_OS_WIN32
135    ITaskbarList3 *tl;
136#endif // Q_OS_WIN32
137
138    // The solution graph SVG
139    QPicture graph;
140
141    // Formats
142    QTextTableFormat fmt_table;
143    QTextBlockFormat fmt_paragraph,
144        fmt_lastparagraph,
145        fmt_cell;
146    QTextCharFormat fmt_default,
147        fmt_selected,
148        fmt_alternate,
149        fmt_altlist;
150
151    void check4Updates(bool silent = false);
152    void closeEvent(QCloseEvent *ev);
153    void dragEnterEvent(QDragEnterEvent *ev);
154    void drawNode(QPainter &pic, int nstep, bool left = false, TSPSolver::SStep *step = NULL);
155    void dropEvent(QDropEvent *ev);
156    QByteArray generateImage(const QString &format);
157    void initDocStyleSheet();
158    void loadLangList();
159    bool loadLanguage(const QString &lang = QString());
160    void loadStyleList();
161    void loadToolbarList();
162    bool maybeSave();
163    void outputMatrix(QTextCursor &cur, const TSPSolver::TMatrix &matrix);
164    void outputMatrix(QTextCursor &cur, const TSPSolver::SStep &step);
165#ifdef Q_OS_SYMBIAN
166    void resizeEvent(QResizeEvent *ev);
167#endif // Q_OS_SYMBIAN
168    void retranslateUi(bool all = true);
169    bool saveTask();
170    void setFileName(const QString &fileName = tr("Untitled") + ".tspt");
171    void setupUi();
172    void toggleSolutionActions(bool enable = true);
173    void toggleTranclucency(bool enable);
174};
175
176#ifdef Q_OS_SYMBIAN
177#include <QMessageBox>
178// A quickly hacked QMessageBox for Symbian that supports three buttons.
179class QSMessageBox: public QMessageBox {
180    Q_OBJECT
181private slots:
182    void cancel();
183    void discard();
184public:
185    QSMessageBox(QWidget *parent = 0);
186};
187#endif // Q_OS_SYMBIAN
188
189#endif // MAINWINDOW_H
Note: See TracBrowser for help on using the repository browser.