TSP Solver and Generator
src/mainwindow.h
Go to the documentation of this file.
00001 
00028 #ifndef MAINWINDOW_H
00029 #define MAINWINDOW_H
00030 
00031 #include "globals.h"
00032 
00033 #include "ui_mainwindow.h"
00034 #include "settingsdialog.h"
00035 
00036 #include "tspmodel.h"
00037 
00038 #ifdef Q_WS_WIN32
00039     // Forward declaration. A real one is in shobjidl.h
00040     struct ITaskbarList3;
00041 #endif
00042 
00043 using namespace TSPSolver;
00044 
00049 class MainWindow: public QMainWindow, Ui::MainWindow
00050 {
00051     Q_OBJECT
00052 
00053 public:
00054     MainWindow(QWidget *parent = 0);
00055     ~MainWindow();
00056 
00057 private slots:
00058 // Actions
00059     void actionFileNewTriggered();
00060     void actionFileOpenTriggered();
00061     bool actionFileSaveTriggered();
00062     void actionFileSaveAsTaskTriggered();
00063     void actionFileSaveAsSolutionTriggered();
00064 #ifndef QT_NO_PRINTER
00065     void actionFilePrintPreviewTriggered();
00066     void actionFilePageSetupTriggered();
00067     void actionFilePrintTriggered();
00068 #endif // QT_NO_PRINTER
00069     void actionSettingsPreferencesTriggered();
00070     void actionSettingsLanguageAutodetectTriggered(bool checked);
00071     void groupSettingsLanguageListTriggered(QAction *action);
00072     void actionSettingsStyleSystemTriggered(bool checked);
00073     void groupSettingsStyleListTriggered(QAction *action);
00074 #ifndef HANDHELD
00075     void actionSettingsToolbarsConfigureTriggered();
00076 #endif // HANDHELD
00077     void actionHelpOnlineSupportTriggered();
00078     void actionHelpReportBugTriggered();
00079     void actionHelpCheck4UpdatesTriggered();
00080     void actionHelpAboutTriggered();
00081 // Buttons
00082     void buttonBackToTaskClicked();
00083     void buttonRandomClicked();
00084     void buttonSolveClicked();
00085 
00086     void dataChanged();
00087     void dataChanged(const QModelIndex &tl, const QModelIndex &br);
00088 #ifdef Q_WS_WINCE_WM
00089     void changeEvent(QEvent *ev);
00090     void desktopResized(int screen);
00091 #endif // Q_WS_WINCE_WM
00092     void numCitiesChanged(int nCities);
00093 #ifndef QT_NO_PRINTER
00094     void printPreview(QPrinter *printer);
00095 #endif // QT_NO_PRINTER
00096 #ifdef Q_WS_WIN32
00097     void solverRoutePartFound(int n);
00098 #endif // Q_WS_WIN32
00099     void spinCitiesValueChanged(int nCities);
00100 
00101 private:
00102     QString fileName;
00103     QActionGroup *groupSettingsLanguageList;
00104     QActionGroup *groupSettingsStyleList;
00105 #ifndef HANDHELD
00106     QAction *actionSettingsToolbarsConfigure;
00107     QtToolBarManager *toolBarManager;
00108 #endif // HANDHELD
00109 #ifndef QT_NO_PRINTER
00110     QPrinter *printer;
00111     QAction *actionFilePrintPreview;
00112     QAction *actionFilePageSetup;
00113     QAction *actionFilePrint;
00114 #endif // QT_NO_PRINTER
00115     QAction *actionHelpCheck4Updates;
00116 #ifdef Q_WS_S60
00117     QAction *actionRightSoftKey;
00118 #endif
00119     QSettings *settings;
00120     CTSPModel *tspmodel;
00121 #ifdef Q_WS_WINCE_WM
00122     QRect currentGeometry;
00123 #endif // Q_WS_WINCE_WM
00124 
00125 #ifdef Q_WS_WIN32
00126     ITaskbarList3 *tl;
00127 #endif // Q_WS_WIN32
00128 
00129     // The solution graph SVG
00130     QPicture graph;
00131 
00132     // Formats
00133     QTextTableFormat fmt_table;
00134     QTextBlockFormat fmt_paragraph,
00135         fmt_lastparagraph,
00136         fmt_cell;
00137     QTextCharFormat fmt_default,
00138         fmt_selected,
00139         fmt_alternate,
00140         fmt_altlist;
00141 
00142     void check4Updates(bool silent = false);
00143     void closeEvent(QCloseEvent *ev);
00144     void dragEnterEvent(QDragEnterEvent *ev);
00145     void drawNode(QPainter &pic, int nstep, bool left = false, SStep *step = NULL);
00146     void dropEvent(QDropEvent *ev);
00147     void initDocStyleSheet();
00148     void loadLangList();
00149     bool loadLanguage(const QString &lang = QString());
00150     void loadStyleList();
00151     void loadToolbarList();
00152     bool maybeSave();
00153     void outputMatrix(QTextCursor &cur, const TMatrix &matrix);
00154     void outputMatrix(QTextCursor &cur, const SStep &step);
00155     void retranslateUi(bool all = true);
00156     bool saveTask();
00157     void setFileName(const QString &fileName = tr("Untitled") + ".tspt");
00158     void setupUi();
00159     void toggleSolutionActions(bool enable = true);
00160     void toggleTranclucency(bool enable);
00161 };
00162 
00163 #ifdef Q_WS_S60
00164 // A quickly hacked QMessageBox for Symbian that supports three buttons.
00165 class QSMessageBox: public QMessageBox {
00166     Q_OBJECT
00167 private slots:
00168     void cancel();
00169     void discard();
00170 public:
00171     QSMessageBox(QWidget *parent = 0);
00172 };
00173 #endif // Q_WS_S60
00174 
00175 #endif // MAINWINDOW_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines