source: tspsg-svn/trunk/src/mainwindow.h @ 139

Last change on this file since 139 was 139, checked in by laleppa, 14 years ago

+ Automatically check for updates at the given interval functionality (Windows only at this moment).

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