/*! * \file mainwindow.h * \author Copyright © 2007-2013 Oleksii Serdiuk * * $Id: $Format:%h %ai %an$ $ * $URL: http://tspsg.info/ $ * * \brief Defines MainWindow class. * * TSPSG: TSP Solver and Generator * * This file is part of TSPSG. * * TSPSG is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TSPSG is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TSPSG. If not, see . */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include "globals.h" #include "ui_mainwindow.h" #include "tspsolver.h" #include #ifdef Q_OS_WIN32 // Forward declaration. A real one is in shobjidl.h struct ITaskbarList3; #endif class CTSPModel; #ifndef HANDHELD class QtToolbarDialog; class QtToolBarManager; #endif #ifndef QT_NO_PRINTER class QPrinter; #endif /*! * \brief Class for handling Main Window UI and logic. * \author Copyright © 2007-2013 Oleksii Serdiuk */ class MainWindow: public QMainWindow, Ui::MainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: // Actions void actionFileNewTriggered(); void actionFileOpenTriggered(); bool actionFileSaveTriggered(); void actionFileSaveAsTaskTriggered(); void actionFileSaveAsSolutionTriggered(); #ifndef QT_NO_PRINTER void actionFilePrintPreviewTriggered(); void actionFilePageSetupTriggered(); void actionFilePrintTriggered(); #endif // QT_NO_PRINTER void actionSettingsPreferencesTriggered(); void actionSettingsLanguageAutodetectTriggered(bool checked); void groupSettingsLanguageListTriggered(QAction *action); void actionSettingsStyleSystemTriggered(bool checked); void groupSettingsStyleListTriggered(QAction *action); #ifndef HANDHELD void actionSettingsToolbarsConfigureTriggered(); #endif // HANDHELD void actionHelpOnlineSupportTriggered(); void actionHelpReportBugTriggered(); void actionHelpCheck4UpdatesTriggered(); void actionHelpAboutTriggered(); // Buttons void buttonBackToTaskClicked(); void buttonRandomClicked(); void buttonSolveClicked(); void dataChanged(); void dataChanged(const QModelIndex &tl, const QModelIndex &br); #ifdef Q_OS_WINCE_WM void changeEvent(QEvent *ev); void desktopResized(int screen); #endif // Q_OS_WINCE_WM void numCitiesChanged(int nCities); #ifndef QT_NO_PRINTER void printPreview(QPrinter *printer); #endif // QT_NO_PRINTER #ifdef Q_OS_WIN32 void solverRoutePartFound(int n); #endif // Q_OS_WIN32 void spinCitiesValueChanged(int nCities); private: QString fileName; QActionGroup *groupSettingsLanguageList; QActionGroup *groupSettingsStyleList; #ifndef HANDHELD QAction *actionSettingsToolbarsConfigure; QtToolBarManager *toolBarManager; #endif // HANDHELD #ifndef QT_NO_PRINTER QPrinter *printer; QAction *actionFilePrintPreview; QAction *actionFilePageSetup; QAction *actionFilePrint; #endif // QT_NO_PRINTER QAction *actionHelpCheck4Updates; #ifdef Q_OS_SYMBIAN QAction *actionRightSoftKey; #endif QSettings *settings; CTSPModel *tspmodel; #ifdef Q_OS_WINCE_WM QRect currentGeometry; #endif // Q_OS_WINCE_WM #ifdef Q_OS_WIN32 ITaskbarList3 *tl; #endif // Q_OS_WIN32 // The solution graph SVG QPicture graph; // Formats QTextTableFormat fmt_table; QTextBlockFormat fmt_paragraph, fmt_lastparagraph, fmt_cell; QTextCharFormat fmt_default, fmt_selected, fmt_alternate, fmt_altlist; void check4Updates(bool silent = false); void closeEvent(QCloseEvent *ev); void dragEnterEvent(QDragEnterEvent *ev); void drawNode(QPainter &pic, int nstep, bool left = false, TSPSolver::SStep *step = NULL); void dropEvent(QDropEvent *ev); QByteArray generateImage(const QString &format); void initDocStyleSheet(); void loadLangList(); bool loadLanguage(const QString &lang = QString()); void loadStyleList(); void loadToolbarList(); bool maybeSave(); void outputMatrix(QTextCursor &cur, const TSPSolver::TMatrix &matrix); void outputMatrix(QTextCursor &cur, const TSPSolver::SStep &step); #ifdef Q_OS_SYMBIAN void resizeEvent(QResizeEvent *ev); #endif // Q_OS_SYMBIAN void retranslateUi(bool all = true); bool saveTask(); void setFileName(const QString &fileName = tr("Untitled") + ".tspt"); void setupUi(); void toggleSolutionActions(bool enable = true); void toggleTranclucency(bool enable); }; #ifdef Q_OS_SYMBIAN #include // A quickly hacked QMessageBox for Symbian that supports three buttons. class QSMessageBox: public QMessageBox { Q_OBJECT private slots: void cancel(); void discard(); public: QSMessageBox(QWidget *parent = 0); }; #endif // Q_OS_SYMBIAN #endif // MAINWINDOW_H