TSP Solver and Generator
mainwindow.h
Go to the documentation of this file.
1 
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 
43 class 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 
58 class MainWindow: public QMainWindow, Ui::MainWindow
59 {
60  Q_OBJECT
61 
62 public:
64  ~MainWindow();
65 
66 #ifdef Q_OS_BLACKBERRY
67 public slots:
68  void setWindowModified(bool modified);
69 #endif
70 
71 private slots:
72 // Actions
73  void actionFileNewTriggered();
74  void actionFileOpenTriggered();
75  bool actionFileSaveTriggered();
76  void actionFileSaveAsTaskTriggered();
77  void actionFileSaveAsSolutionTriggered();
78 #ifndef QT_NO_PRINTDIALOG
79  void actionFilePrintPreviewTriggered();
80  void actionFilePageSetupTriggered();
81  void actionFilePrintTriggered();
82 #endif // QT_NO_PRINTDIALOG
83  void actionSettingsPreferencesTriggered();
84  void actionSettingsLanguageAutodetectTriggered(bool checked);
85  void groupSettingsLanguageListTriggered(QAction *action);
86  void actionSettingsStyleSystemTriggered(bool checked);
87  void groupSettingsStyleListTriggered(QAction *action);
88 #ifndef HANDHELD
89  void actionSettingsToolbarsConfigureTriggered();
90 #endif // HANDHELD
91  void actionHelpOnlineSupportTriggered();
92  void actionHelpReportBugTriggered();
93  void actionHelpCheck4UpdatesTriggered();
94  void actionHelpAboutTriggered();
95 // Buttons
96  void buttonBackToTaskClicked();
97  void buttonRandomClicked();
98  void buttonSolveClicked();
99 
100  void dataChanged();
101  void dataChanged(const QModelIndex &tl, const QModelIndex &br);
102 #ifdef Q_OS_WINCE_WM
103  void changeEvent(QEvent *ev);
104  void desktopResized(int screen);
105 #endif // Q_OS_WINCE_WM
106  void numCitiesChanged(int nCities);
107 #ifndef QT_NO_PRINTER
108  void printPreview(QPrinter *printer);
109 #endif // QT_NO_PRINTER
110 #ifdef Q_OS_WIN32
111  void solverRoutePartFound(int n);
112 #endif // Q_OS_WIN32
113  void spinCitiesValueChanged(int nCities);
114 
115 private:
116  QString fileName;
117  QActionGroup *groupSettingsLanguageList;
118  QActionGroup *groupSettingsStyleList;
119 #ifndef HANDHELD
120  QAction *actionSettingsToolbarsConfigure;
121  QtToolBarManager *toolBarManager;
122 #endif // HANDHELD
123 #ifndef QT_NO_PRINTER
124  QPrinter *printer;
125 #ifndef QT_NO_PRINTDIALOG
126  QAction *actionFilePrintPreview;
127  QAction *actionFilePageSetup;
128  QAction *actionFilePrint;
129 #endif // QT_NO_PRINTDIALOG
130 #endif // QT_NO_PRINTER
131  QAction *actionHelpCheck4Updates;
132 #ifdef Q_OS_SYMBIAN
133  QAction *actionRightSoftKey;
134 #endif
135  QSettings *settings;
136  CTSPModel *tspmodel;
137 #ifdef Q_OS_WINCE_WM
138  QRect currentGeometry;
139 #endif // Q_OS_WINCE_WM
140 
141 #ifdef Q_OS_WIN32
142  ITaskbarList3 *tl;
143 #endif // Q_OS_WIN32
144 
145  // The solution graph SVG
146  QPicture graph;
147 
148  // Formats
149  QTextTableFormat fmt_table;
150  QTextBlockFormat fmt_paragraph,
151  fmt_lastparagraph,
152  fmt_cell;
153  QTextCharFormat fmt_default,
154  fmt_selected,
155  fmt_alternate,
156  fmt_altlist;
157 
158  void check4Updates(bool silent = false);
159  void closeEvent(QCloseEvent *ev);
160  void dragEnterEvent(QDragEnterEvent *ev);
161  void drawNode(QPainter &pic, int nstep, bool left = false, TSPSolver::SStep *step = NULL);
162  void dropEvent(QDropEvent *ev);
163  QByteArray generateImage(const QString &format);
164  void initDocStyleSheet();
165  void loadLangList();
166  bool loadLanguage(const QString &lang = QString());
167  void loadStyleList();
168  void loadToolbarList();
169  bool maybeSave();
170  void outputMatrix(QTextCursor &cur, const TSPSolver::TMatrix &matrix);
171  void outputMatrix(QTextCursor &cur, const TSPSolver::SStep &step);
172 #ifdef Q_OS_SYMBIAN
173  void resizeEvent(QResizeEvent *ev);
174 #endif // Q_OS_SYMBIAN
175  void retranslateUi(bool all = true);
176  bool saveTask();
177  void setFileName(const QString &fileName = tr("Untitled") + ".tspt");
178  void setupUi();
179  void toggleSolutionActions(bool enable = true);
180  void toggleTranclucency(bool enable);
181 };
182 
183 #ifdef Q_OS_SYMBIAN
184 #include <QMessageBox>
185 // A quickly hacked QMessageBox for Symbian that supports three buttons.
186 class QSMessageBox: public QMessageBox {
187  Q_OBJECT
188 private slots:
189  void cancel();
190  void discard();
191 public:
192  QSMessageBox(QWidget *parent = 0);
193 };
194 #endif // Q_OS_SYMBIAN
195 
196 #endif // MAINWINDOW_H
QString tr(const char *sourceText, const char *disambiguation, int n)
void setWindowModified(bool)
Contains TSPSG global defines.
Defines TSPSolver namespace and everything needed for solving TSP tasks.
Exposes methods that control the taskbar.
Definition: shobjidl.h:75
This structure represents one step of solving.
Definition: tspsolver.h:63
virtual void changeEvent(QEvent *event)
MainWindow(QWidget *parent=0)
Class constructor.
Definition: mainwindow.cpp:136
virtual void resizeEvent(QResizeEvent *event)
Class for handling Main Window UI and logic.
Definition: mainwindow.h:58
QObject * parent() const
This class implements table model for manipulating a task.
Definition: tspmodel.h:41