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 "tspsolver.h"
00037 #include "tspmodel.h"
00038
00043 class MainWindow: public QMainWindow, Ui::MainWindow
00044 {
00045 Q_OBJECT
00046
00047 public:
00048 MainWindow(QWidget *parent = 0);
00049 ~MainWindow();
00050
00051 private slots:
00052
00053 void actionFileNewTriggered();
00054 void actionFileOpenTriggered();
00055 void actionFileSaveTriggered();
00056 void actionFileSaveAsTaskTriggered();
00057 void actionFileSaveAsSolutionTriggered();
00058 #ifndef QT_NO_PRINTER
00059 void actionFilePrintPreviewTriggered();
00060 void actionFilePrintTriggered();
00061 #endif // QT_NO_PRINTER
00062 void actionSettingsPreferencesTriggered();
00063 void actionSettingsLanguageAutodetectTriggered(bool checked);
00064 void groupSettingsLanguageListTriggered(QAction *action);
00065 void actionHelpAboutTriggered();
00066
00067 void buttonBackToTaskClicked();
00068 void buttonRandomClicked();
00069 void buttonSolveClicked();
00070
00071 void dataChanged();
00072 void dataChanged(const QModelIndex &tl, const QModelIndex &br);
00073 void numCitiesChanged(int nCities);
00074 #ifndef QT_NO_PRINTER
00075 void printPreview(QPrinter *printer);
00076 #endif // QT_NO_PRINTER
00077 void spinCitiesValueChanged(int nCities);
00078
00079 private:
00080 QString fileName;
00081 QActionGroup *groupSettingsLanguageList;
00082 QStringList output;
00083 #ifndef QT_NO_PRINTER
00084 QPrinter *printer;
00085 QAction *actionFilePrintPreview;
00086 QAction *actionFilePrint;
00087 #endif // QT_NO_PRINTER
00088 QSettings *settings;
00089 CTSPModel *tspmodel;
00090
00091 void closeEvent(QCloseEvent *ev);
00092 void initDocStyleSheet();
00093 void loadLangList();
00094 bool loadLanguage(const QString &lang = QString());
00095 bool maybeSave();
00096 void outputMatrix(const TMatrix &matrix, QStringList &output);
00097 void outputMatrix(const SStep &step, QStringList &output);
00098 void retranslateUi(bool all = true);
00099 bool saveTask();
00100 void setFileName(const QString &fileName = trUtf8("Untitled") + ".tspt");
00101 void setupUi();
00102 void toggleSolutionActions(bool enable = true);
00103 };
00104
00105 #endif // MAINWINDOW_H