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