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