[116] | 1 | /*! |
---|
| 2 | * \file mainwindow.h |
---|
[151] | 3 | * \author Copyright © 2007-2011 Lёppa <contacts[at]oleksii[dot]name> |
---|
[116] | 4 | * |
---|
| 5 | * $Id: mainwindow.h 163 2011-04-15 02:21:25Z laleppa $ |
---|
| 6 | * $URL: https://tspsg.svn.sourceforge.net/svnroot/tspsg/trunk/src/mainwindow.h $ |
---|
| 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 "settingsdialog.h" |
---|
| 35 | |
---|
| 36 | #include "tspmodel.h" |
---|
| 37 | |
---|
[141] | 38 | #ifdef Q_WS_WIN32 |
---|
[149] | 39 | // Forward declaration. A real one is in shobjidl.h |
---|
| 40 | struct ITaskbarList3; |
---|
[124] | 41 | #endif |
---|
| 42 | |
---|
[116] | 43 | using namespace TSPSolver; |
---|
| 44 | |
---|
| 45 | /*! |
---|
| 46 | * \brief Class for handling Main Window UI and logic. |
---|
[151] | 47 | * \author Copyright © 2007-2011 Lёppa <contacts[at]oleksii[dot]name> |
---|
[116] | 48 | */ |
---|
| 49 | class MainWindow: public QMainWindow, Ui::MainWindow |
---|
| 50 | { |
---|
[149] | 51 | Q_OBJECT |
---|
[116] | 52 | |
---|
| 53 | public: |
---|
[149] | 54 | MainWindow(QWidget *parent = 0); |
---|
| 55 | ~MainWindow(); |
---|
[116] | 56 | |
---|
| 57 | private slots: |
---|
| 58 | // Actions |
---|
[149] | 59 | void actionFileNewTriggered(); |
---|
| 60 | void actionFileOpenTriggered(); |
---|
| 61 | bool actionFileSaveTriggered(); |
---|
| 62 | void actionFileSaveAsTaskTriggered(); |
---|
| 63 | void actionFileSaveAsSolutionTriggered(); |
---|
[116] | 64 | #ifndef QT_NO_PRINTER |
---|
[149] | 65 | void actionFilePrintPreviewTriggered(); |
---|
[161] | 66 | void actionFilePageSetupTriggered(); |
---|
[149] | 67 | void actionFilePrintTriggered(); |
---|
[116] | 68 | #endif // QT_NO_PRINTER |
---|
[149] | 69 | void actionSettingsPreferencesTriggered(); |
---|
| 70 | void actionSettingsLanguageAutodetectTriggered(bool checked); |
---|
| 71 | void groupSettingsLanguageListTriggered(QAction *action); |
---|
| 72 | void actionSettingsStyleSystemTriggered(bool checked); |
---|
| 73 | void groupSettingsStyleListTriggered(QAction *action); |
---|
[118] | 74 | #ifndef HANDHELD |
---|
[149] | 75 | void actionSettingsToolbarsConfigureTriggered(); |
---|
[118] | 76 | #endif // HANDHELD |
---|
[149] | 77 | void actionHelpOnlineSupportTriggered(); |
---|
| 78 | void actionHelpReportBugTriggered(); |
---|
| 79 | void actionHelpCheck4UpdatesTriggered(); |
---|
| 80 | void actionHelpAboutTriggered(); |
---|
[116] | 81 | // Buttons |
---|
[149] | 82 | void buttonBackToTaskClicked(); |
---|
| 83 | void buttonRandomClicked(); |
---|
| 84 | void buttonSolveClicked(); |
---|
[116] | 85 | |
---|
[149] | 86 | void dataChanged(); |
---|
| 87 | void dataChanged(const QModelIndex &tl, const QModelIndex &br); |
---|
[141] | 88 | #ifdef Q_WS_WINCE_WM |
---|
[149] | 89 | void changeEvent(QEvent *ev); |
---|
| 90 | void desktopResized(int screen); |
---|
[141] | 91 | #endif // Q_WS_WINCE_WM |
---|
[149] | 92 | void numCitiesChanged(int nCities); |
---|
[116] | 93 | #ifndef QT_NO_PRINTER |
---|
[149] | 94 | void printPreview(QPrinter *printer); |
---|
[116] | 95 | #endif // QT_NO_PRINTER |
---|
[141] | 96 | #ifdef Q_WS_WIN32 |
---|
[149] | 97 | void solverRoutePartFound(int n); |
---|
[141] | 98 | #endif // Q_WS_WIN32 |
---|
[149] | 99 | void spinCitiesValueChanged(int nCities); |
---|
[116] | 100 | |
---|
| 101 | private: |
---|
[149] | 102 | QString fileName; |
---|
| 103 | QActionGroup *groupSettingsLanguageList; |
---|
| 104 | QActionGroup *groupSettingsStyleList; |
---|
[117] | 105 | #ifndef HANDHELD |
---|
[149] | 106 | QAction *actionSettingsToolbarsConfigure; |
---|
| 107 | QtToolBarManager *toolBarManager; |
---|
[117] | 108 | #endif // HANDHELD |
---|
[116] | 109 | #ifndef QT_NO_PRINTER |
---|
[149] | 110 | QPrinter *printer; |
---|
| 111 | QAction *actionFilePrintPreview; |
---|
[161] | 112 | QAction *actionFilePageSetup; |
---|
[149] | 113 | QAction *actionFilePrint; |
---|
[116] | 114 | #endif // QT_NO_PRINTER |
---|
[149] | 115 | QAction *actionHelpCheck4Updates; |
---|
[159] | 116 | #ifdef Q_WS_S60 |
---|
| 117 | QAction *actionRightSoftKey; |
---|
| 118 | #endif |
---|
[149] | 119 | QSettings *settings; |
---|
| 120 | CTSPModel *tspmodel; |
---|
[141] | 121 | #ifdef Q_WS_WINCE_WM |
---|
[149] | 122 | QRect currentGeometry; |
---|
[141] | 123 | #endif // Q_WS_WINCE_WM |
---|
[116] | 124 | |
---|
[141] | 125 | #ifdef Q_WS_WIN32 |
---|
[149] | 126 | ITaskbarList3 *tl; |
---|
[141] | 127 | #endif // Q_WS_WIN32 |
---|
[124] | 128 | |
---|
[149] | 129 | // The solution graph SVG |
---|
| 130 | QPicture graph; |
---|
[116] | 131 | |
---|
[149] | 132 | // Formats |
---|
| 133 | QTextTableFormat fmt_table; |
---|
| 134 | QTextBlockFormat fmt_paragraph, |
---|
[162] | 135 | fmt_lastparagraph, |
---|
[149] | 136 | fmt_cell; |
---|
| 137 | QTextCharFormat fmt_default, |
---|
| 138 | fmt_selected, |
---|
| 139 | fmt_alternate, |
---|
| 140 | fmt_altlist; |
---|
[116] | 141 | |
---|
[149] | 142 | void check4Updates(bool silent = false); |
---|
| 143 | void closeEvent(QCloseEvent *ev); |
---|
| 144 | void dragEnterEvent(QDragEnterEvent *ev); |
---|
| 145 | void drawNode(QPainter &pic, int nstep, bool left = false, SStep *step = NULL); |
---|
| 146 | void dropEvent(QDropEvent *ev); |
---|
| 147 | void initDocStyleSheet(); |
---|
| 148 | void loadLangList(); |
---|
| 149 | bool loadLanguage(const QString &lang = QString()); |
---|
| 150 | void loadStyleList(); |
---|
| 151 | void loadToolbarList(); |
---|
| 152 | bool maybeSave(); |
---|
| 153 | void outputMatrix(QTextCursor &cur, const TMatrix &matrix); |
---|
| 154 | void outputMatrix(QTextCursor &cur, const SStep &step); |
---|
| 155 | void retranslateUi(bool all = true); |
---|
| 156 | bool saveTask(); |
---|
| 157 | void setFileName(const QString &fileName = tr("Untitled") + ".tspt"); |
---|
| 158 | void setupUi(); |
---|
| 159 | void toggleSolutionActions(bool enable = true); |
---|
| 160 | void toggleTranclucency(bool enable); |
---|
[116] | 161 | }; |
---|
| 162 | |
---|
[163] | 163 | #ifdef Q_WS_S60 |
---|
| 164 | // A quickly hacked QMessageBox for Symbian that supports three buttons. |
---|
| 165 | class QSMessageBox: public QMessageBox { |
---|
| 166 | Q_OBJECT |
---|
| 167 | private slots: |
---|
| 168 | void cancel(); |
---|
| 169 | void discard(); |
---|
| 170 | public: |
---|
| 171 | QSMessageBox(QWidget *parent = 0); |
---|
| 172 | }; |
---|
| 173 | #endif // Q_WS_S60 |
---|
| 174 | |
---|
[116] | 175 | #endif // MAINWINDOW_H |
---|