Changeset c10297cf73 in tspsg for src


Ignore:
Timestamp:
Aug 9, 2009, 1:45:19 AM (15 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
6dfdef0c3e
Parents:
6332a24386
Message:
  • mainwindow.ui and mainwindow.ce.ui had differences only in printing actions and statusbar, so I merged them into one. Differences are now applied in source code. This will simplify Main Window maintenance.
  • Changed #ifndef Q_OS_WINCE to #ifndef QT_NO_PRINTER where relevant.
  • Now using method at() instead of operator [] in solving algorithm. This change dramatically decreased solution time (from 13 seconds to 10-40 milliseconds for 20 cities on my PC).
  • Increased maximum number of cities to 30. Setting more makes no sense at this moment, because generated solution output is big and inserting it to QTextEdit takes veeeeery long time.
  • Translations were updated.
Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/globals.h

    r6332a24386 rc10297cf73  
    3131// Version info
    3232#include "version.h"
    33 // OS detection
     33// OS and ARCH detection
    3434#include "os.h"
    3535
     
    5858
    5959// Maximum available number of cities
    60 #define MAX_NUM_CITIES 20
     60#define MAX_NUM_CITIES 30
    6161// This value means infinity :-)
    6262#ifndef INFINITY
  • src/mainwindow.cpp

    r6332a24386 rc10297cf73  
    3030        loadLanguage();
    3131        setupUi(this);
     32#ifndef Q_OS_WINCE
     33QStatusBar *statusbar = new QStatusBar(this);
     34        statusbar->setObjectName("statusbar");
     35        setStatusBar(statusbar);
     36#endif // Q_OS_WINCE
    3237        initDocStyleSheet();
    3338        solutionText->document()->setDefaultFont(settings->value("Output/Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>());
     
    3944        toolBar->setIconSize(QSize(s / 10,s / 10));
    4045#endif
    41 #ifndef Q_OS_WINCE
     46#ifndef QT_NO_PRINTER
    4247        printer = new QPrinter(QPrinter::HighResolution);
    43 #endif // Q_OS_WINCE
     48#endif // QT_NO_PRINTER
    4449        groupSettingsLanguageList = new QActionGroup(this);
    4550        actionSettingsLanguageEnglish->setData("en");
     
    5863        connect(actionHelpAboutQt,SIGNAL(triggered()),qApp,SLOT(aboutQt()));
    5964        connect(actionHelpAbout,SIGNAL(triggered()),this,SLOT(actionHelpAboutTriggered()));
    60 #ifndef Q_OS_WINCE
     65#ifndef QT_NO_PRINTER
     66        menuFile->insertAction(actionFileExit,actionFilePrintPreview);
     67        menuFile->insertAction(actionFileExit,actionFilePrint);
     68        menuFile->insertSeparator(actionFileExit);
     69        toolBar->insertAction(actionSettingsPreferences,actionFilePrint);
    6170        connect(actionFilePrintPreview,SIGNAL(triggered()),this,SLOT(actionFilePrintPreviewTriggered()));
    6271        connect(actionFilePrint,SIGNAL(triggered()),this,SLOT(actionFilePrintTriggered()));
    63 #endif // Q_OS_WINCE
     72#endif // QT_NO_PRINTER
    6473        connect(buttonSolve,SIGNAL(clicked()),this,SLOT(buttonSolveClicked()));
    6574        connect(buttonRandom,SIGNAL(clicked()),this,SLOT(buttonRandomClicked()));
     
    106115        if (!enable)
    107116                output.clear();
    108 #ifndef Q_OS_WINCE
     117#ifndef QT_NO_PRINTER
    109118        actionFilePrint->setEnabled(enable);
    110119        actionFilePrintPreview->setEnabled(enable);
    111 #endif // Q_OS_WINCE
     120#endif // QT_NO_PRINTER
    112121}
    113122
     
    206215        if (!maybeSave())
    207216                return;
     217        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    208218        tspmodel->clear();
    209219        taskView->resizeColumnsToContents();
     
    214224        solutionText->clear();
    215225        enableSolutionActions(false);
     226        QApplication::restoreOverrideCursor();
    216227}
    217228
     
    349360}
    350361
    351 #ifndef Q_OS_WINCE
     362#ifndef QT_NO_PRINTER
    352363void MainWindow::printPreview(QPrinter *printer)
    353364{
     
    372383        if (pd.exec() != QDialog::Accepted)
    373384                return;
     385        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    374386        solutionText->document()->print(printer);
    375 }
    376 #endif // Q_OS_WINCE
     387        QApplication::restoreOverrideCursor();
     388}
     389#endif // QT_NO_PRINTER
    377390
    378391void MainWindow::buttonRandomClicked()
    379392{
     393        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    380394        tspmodel->randomize();
    381395        setWindowModified(true);
    382396        taskView->resizeColumnsToContents();
    383397        taskView->resizeRowsToContents();
     398        QApplication::restoreOverrideCursor();
    384399}
    385400
  • src/mainwindow.h

    r6332a24386 rc10297cf73  
    2626
    2727#include "globals.h"
    28 #ifdef Q_OS_WINCE
    29         #include "ui_mainwindow.ce.h"
    30 #else
    31         #include "ui_mainwindow.h"
    32 #endif // Q_OS_WINCE
     28#include "ui_mainwindow.h"
    3329#include "settingsdialog.h"
    3430#include "tspsolver.h"
     
    5450        void actionHelpAboutTriggered();
    5551        void dataChanged();
    56 #ifndef Q_OS_WINCE
     52#ifndef QT_NO_PRINTER
    5753        void printPreview(QPrinter *);
    5854        void actionFilePrintPreviewTriggered();
    5955        void actionFilePrintTriggered();
    60 #endif // Q_OS_WINCE
     56#endif // QT_NO_PRINTER
    6157        void buttonSolveClicked();
    6258        void buttonRandomClicked();
     
    6763private:
    6864        QSettings *settings;
    69 #ifndef Q_OS_WINCE
     65#ifndef QT_NO_PRINTER
    7066        QPrinter *printer;
    71 #endif // Q_OS_WINCE
     67#endif // QT_NO_PRINTER
    7268        CTSPModel *tspmodel;
    7369        QString fileName;
  • src/tspsolver.cpp

    r6332a24386 rc10297cf73  
    3939double min = INFINITY;
    4040        for (int k = 0; k < nCities; k++)
    41                 if (((k != exc)) && (min > matrix[nRow][k]))
    42                         min = matrix[nRow][k];
     41                if (((k != exc)) && (min > matrix.at(nRow).at(k)))
     42                        min = matrix.at(nRow).at(k);
    4343        return min == INFINITY ? 0 : min;
    4444}
     
    4848double min = INFINITY;
    4949        for (int k = 0; k < nCities; k++)
    50                 if ((k != exr) && (min > matrix[k][nCol]))
    51                         min = matrix[k][nCol];
     50                if ((k != exr) && (min > matrix.at(k).at(nCol)))
     51                        min = matrix.at(k).at(nCol);
    5252        return min == INFINITY ? 0 : min;
    5353}
     
    9898                for (int c = 0; c < nCities; c++)
    9999//                      if ((matrix[r][c] == 0) && !forbidden.values(r).contains(c)) {
    100                         if (matrix[r][c] == 0) {
     100                        if (matrix.at(r).at(c) == 0) {
    101101                                sum = findMinInRow(r,matrix,c) + findMinInCol(c,matrix,r);
    102102                                if (sum > h) {
Note: See TracChangeset for help on using the changeset viewer.