Changeset 87 in tspsg-svn


Ignore:
Timestamp:
Jan 12, 2010, 3:11:24 PM (15 years ago)
Author:
laleppa
Message:

+ Added Fractional accuracy (in decimail places) to settings.
+ Created defaults.h file. Moved all default defines there.

  • Replaced all double types with qreal.
  • Replaced all calls to trUtf8() with tr() as we use setCodecForTr() to set UTF-8 encoding as default and tr() is enough.
  • Replaced all 2009 with 2010 in copyrights.
  • Fixed an error when loading .zkt file with less than 5 cities.
Location:
trunk
Files:
1 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/README

    r65 r87  
    11TSPSG: TSP Solver and Generator
    2 Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     2Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    33
    44$Id$
  • trunk/doxygen.conf

    • Property svn:keywords set to Id URL
    r72 r87  
     1######################################################################
     2#
     3# TSPSG: TSP Solver and Generator
     4# Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
     5#
     6# $Id$
     7# $URL$
     8#
     9# This file is part of TSPSG.
     10#
     11######################################################################
     12
    113# Doxyfile 1.6.1
    214
  • trunk/resources/tspsg.rc

    r71 r87  
    11/*
    22 *  TSPSG: TSP Solver and Generator
    3  *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 *  Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    5050            VALUE "FileVersion", BUILD_VERSION
    5151            VALUE "InternalName", "TSPSG"
    52             VALUE "LegalCopyright", "Copyright © 2007 - 2009 Lёppa"
     52            VALUE "LegalCopyright", "Copyright © 2007-2010 Lёppa <contacts[at]oleksii[dot]name>"
    5353            VALUE "OriginalFilename", "tspsg.exe"
    5454            VALUE "ProductName", "TSPSG"
  • trunk/src/globals.h

    r82 r87  
    11/*!
    22 * \file globals.h
    3  * \author Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 * \author Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    3737// OS and ARCH detection
    3838#include "os.h"
     39// TSPSG Defaults
     40#include "defaults.h"
    3941
    4042// DEFINES
    41 // Default values
    42 //! Default minimum for random numbers generation
    43 #define DEF_RAND_MIN 1
    44 //! Default maximum for random numbers generation
    45 #define DEF_RAND_MAX 10
    46 //! Default number of cities
    47 #define DEF_NUM_CITIES 5
    48 /*!
    49  * \def DEF_USE_NATIVE_DIALOGS
    50  * \brief Default for "Use native file dialog".
    51  */
    52 #ifdef Q_OS_WINCE
    53         #define DEF_USE_NATIVE_DIALOGS false
    54 #else
    55         #define DEF_USE_NATIVE_DIALOGS true
    56 #endif // Q_OS_WINCE
    57 //! Default for "Automatically resize rows and columns to their contents"
    58 #define DEF_AUTOSIZE true
    59 //! Default for "Save main window state and position"
    60 #define DEF_SAVEPOS false
    61 //! Default for "Fractional random values"
    62 #define DEF_FRACTIONAL_RANDOM false
    63 //! Default for "Show solution steps' matrices for every solution step"
    64 #define DEF_SHOW_MATRIX true
    65 //! Default for "Show or hide solution steps' matrices based on number of cities in the task"
    66 #define DEF_USE_SHOW_MATRIX_LIMIT true
    67 //! Default for "Maximum number of cities to show solution steps' matrices"
    68 #define DEF_SHOW_MATRIX_LIMIT 15
    69 //! Default for "Scroll to the end of output after solving"
    70 #define DEF_SCROLL_TO_END true
    71 //! Default font name
    72 #define DEF_FONT_FAMILY "Courier New"
    73 //! Default font size
    74 #define DEF_FONT_SIZE 10
    75 //! Default font color
    76 #define DEF_FONT_COLOR Qt::black
    77 
    7843//! Maximum available number of cities
    7944#define MAX_NUM_CITIES 50
     
    13196 * \return \c true if \a x countains an integer, oherwise \c false.
    13297 */
    133 inline bool isInteger(double x)
     98inline bool isInteger(qreal x)
    13499{
    135 double i;
     100qreal i;
    136101        return (modf(x, &i) == 0.0);
    137102}
  • trunk/src/main.cpp

    r80 r87  
    11/*
    22 *  TSPSG: TSP Solver and Generator
    3  *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 *  Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
  • trunk/src/mainwindow.cpp

    r82 r87  
    11/*
    22 *  TSPSG: TSP Solver and Generator
    3  *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 *  Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    124124                return;
    125125
    126 QStringList filters(trUtf8("All Supported Formats") + " (*.tspt *.zkt)");
    127         filters.append(trUtf8("%1 Task Files").arg("TSPSG") + " (*.tspt)");
    128         filters.append(trUtf8("%1 Task Files").arg("ZKomModRd") + " (*.zkt)");
    129         filters.append(trUtf8("All Files") + " (*)");
     126QStringList filters(tr("All Supported Formats") + " (*.tspt *.zkt)");
     127        filters.append(tr("%1 Task Files").arg("TSPSG") + " (*.tspt)");
     128        filters.append(tr("%1 Task Files").arg("ZKomModRd") + " (*.zkt)");
     129        filters.append(tr("All Files") + " (*)");
    130130
    131131QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog;
    132 QString file = QFileDialog::getOpenFileName(this, trUtf8("Task Load"), QString(), filters.join(";;"), NULL, opts);
     132QString file = QFileDialog::getOpenFileName(this, tr("Task Load"), QString(), filters.join(";;"), NULL, opts);
    133133        if (file.isEmpty() || !QFileInfo(file).isFile())
    134134                return;
     
    144144void MainWindow::actionFileSaveTriggered()
    145145{
    146         if ((fileName == trUtf8("Untitled") + ".tspt") || (!fileName.endsWith(".tspt",Qt::CaseInsensitive)))
     146        if ((fileName == tr("Untitled") + ".tspt") || (!fileName.endsWith(".tspt",Qt::CaseInsensitive)))
    147147                saveTask();
    148148        else
     
    160160static QString selectedFile;
    161161        if (selectedFile.isEmpty()) {
    162                 if (fileName == trUtf8("Untitled") + ".tspt") {
     162                if (fileName == tr("Untitled") + ".tspt") {
    163163#ifndef QT_NO_PRINTER
    164164                        selectedFile = "solution.pdf";
     
    177177QStringList filters;
    178178#ifndef QT_NO_PRINTER
    179         filters.append(trUtf8("PDF Files") + " (*.pdf)");
     179        filters.append(tr("PDF Files") + " (*.pdf)");
    180180#endif
    181         filters.append(trUtf8("HTML Files") + " (*.html *.htm)");
     181        filters.append(tr("HTML Files") + " (*.html *.htm)");
    182182#if QT_VERSION >= 0x040500
    183         filters.append(trUtf8("OpenDocument Files") + " (*.odt)");
     183        filters.append(tr("OpenDocument Files") + " (*.odt)");
    184184#endif // QT_VERSION >= 0x040500
    185         filters.append(trUtf8("All Files") + " (*)");
     185        filters.append(tr("All Files") + " (*)");
    186186
    187187QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog;
     
    252252        if (sd.colorChanged() || sd.fontChanged()) {
    253253                initDocStyleSheet();
    254                 if (!output.isEmpty() && sd.colorChanged() && (QMessageBox(QMessageBox::Question,trUtf8("Settings Changed"),trUtf8("You have changed color settings.\nDo you wish to apply them to current solution text?"),QMessageBox::Yes | QMessageBox::No,this).exec() == QMessageBox::Yes)) {
     254                if (!output.isEmpty() && sd.colorChanged() && (QMessageBox(QMessageBox::Question,tr("Settings Changed"),tr("You have changed color settings.\nDo you wish to apply them to current solution text?"),QMessageBox::Yes | QMessageBox::No,this).exec() == QMessageBox::Yes)) {
    255255                        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    256256                        solutionText->clear();
     
    265265        if (checked) {
    266266                settings->remove("Language");
    267                 QMessageBox(QMessageBox::Information,trUtf8("Language change"),trUtf8("Language will be autodetected on next application start."),QMessageBox::Ok,this).exec();
     267                QMessageBox(QMessageBox::Information,tr("Language change"),tr("Language will be autodetected on next application start."),QMessageBox::Ok,this).exec();
    268268        } else
    269269                settings->setValue("Language",groupSettingsLanguageList->checkedAction()->data().toString());
     
    274274        if (actionSettingsLanguageAutodetect->isChecked()) {
    275275                // We have language autodetection. It needs to be disabled to change language.
    276                 if (QMessageBox(QMessageBox::Question,trUtf8("Language change"),trUtf8("You have language autodetection turned on.\nIt needs to be off.\nDo you wish to turn it off?"),QMessageBox::Yes | QMessageBox::No,this).exec() == QMessageBox::Yes) {
     276                if (QMessageBox(QMessageBox::Question,tr("Language change"),tr("You have language autodetection turned on.\nIt needs to be off.\nDo you wish to turn it off?"),QMessageBox::Yes | QMessageBox::No,this).exec() == QMessageBox::Yes) {
    277277                        actionSettingsLanguageAutodetect->trigger();
    278278                } else
    279279                        return;
    280280        }
    281 bool untitled = (fileName == trUtf8("Untitled") + ".tspt");
     281bool untitled = (fileName == tr("Untitled") + ".tspt");
    282282        if (loadLanguage(action->data().toString())) {
    283283                QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
     
    357357
    358358        dlg->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
    359         dlg->setWindowTitle(trUtf8("About TSPSG"));
     359        dlg->setWindowTitle(tr("About TSPSG"));
    360360        dlg->setLayout(vb);
    361361
     
    383383{
    384384TMatrix matrix;
    385 QList<double> row;
     385QList<qreal> row;
    386386int n = spinCities->value();
    387387bool ok;
     
    389389                row.clear();
    390390                for (int c = 0; c < n; c++) {
    391                         row.append(tspmodel->index(r,c).data(Qt::UserRole).toDouble(&ok));
     391                        row.append(tspmodel->index(r,c).data(Qt::UserRole).toReal(&ok));
    392392                        if (!ok) {
    393                                 QMessageBox(QMessageBox::Critical,trUtf8("Data error"),trUtf8("Error in cell [Row %1; Column %2]: Invalid data format.").arg(r + 1).arg(c + 1),QMessageBox::Ok,this).exec();
     393                                QMessageBox(QMessageBox::Critical,tr("Data error"),tr("Error in cell [Row %1; Column %2]: Invalid data format.").arg(r + 1).arg(c + 1),QMessageBox::Ok,this).exec();
    394394                                return;
    395395                        }
     
    404404QColor color = settings->value("Output/Color",DEF_FONT_COLOR).value<QColor>();
    405405        output.clear();
    406         output.append("<p>" + trUtf8("Variant #%1").arg(spinVariant->value()) + "</p>");
    407         output.append("<p>" + trUtf8("Task:") + "</p>");
     406        output.append("<p>" + tr("Variant #%1").arg(spinVariant->value()) + "</p>");
     407        output.append("<p>" + tr("Task:") + "</p>");
    408408        outputMatrix(matrix, output);
    409409        output.append("<hr>");
    410         output.append("<p>" + trUtf8("Solution of Variant #%1 task").arg(spinVariant->value()) + "</p>");
     410        output.append("<p>" + tr("Solution of Variant #%1 task").arg(spinVariant->value()) + "</p>");
    411411SStep *step = root;
    412412        n = 1;
     
    414414                if (step->prNode->prNode != NULL || ((step->prNode->prNode == NULL) && (step->plNode->prNode == NULL))) {
    415415                        if (n != spinCities->value()) {
    416                                 output.append("<p>" + trUtf8("Step #%1").arg(n++) + "</p>");
     416                                output.append("<p>" + tr("Step #%1").arg(n++) + "</p>");
    417417                                if (settings->value("Output/ShowMatrix", DEF_SHOW_MATRIX).toBool() && settings->value("Output/UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT).toBool() && (spinCities->value() <= settings->value("Output/ShowMatrixLimit", DEF_SHOW_MATRIX_LIMIT).toInt())) {
    418418                                        outputMatrix(*step, output);
    419419                                }
    420                                 output.append("<p>" + trUtf8("Selected candidate for branching: %1.").arg(trUtf8("(%1;%2)").arg(step->candidate.nRow + 1).arg(step->candidate.nCol + 1)) + "</p>");
     420                                output.append("<p>" + tr("Selected candidate for branching: %1.").arg(tr("(%1;%2)").arg(step->candidate.nRow + 1).arg(step->candidate.nCol + 1)) + "</p>");
    421421                                if (!step->alts.empty()) {
    422422SCandidate cand;
     
    425425                                                if (!alts.isEmpty())
    426426                                                        alts += ", ";
    427                                                 alts += trUtf8("(%1;%2)").arg(cand.nRow + 1).arg(cand.nCol + 1);
     427                                                alts += tr("(%1;%2)").arg(cand.nRow + 1).arg(cand.nCol + 1);
    428428                                        }
    429                                         output.append("<p class=\"hasalts\">" + trUtf8("%n alternate candidate(s) for branching: %1.","",step->alts.count()).arg(alts) + "</p>");
     429                                        output.append("<p class=\"hasalts\">" + tr("%n alternate candidate(s) for branching: %1.","",step->alts.count()).arg(alts) + "</p>");
    430430                                }
    431431                                output.append("<p>&nbsp;</p>");
     
    440440        }
    441441        if (solver.isOptimal())
    442                 output.append("<p>" + trUtf8("Optimal path:") + "</p>");
     442                output.append("<p>" + tr("Optimal path:") + "</p>");
    443443        else
    444                 output.append("<p>" + trUtf8("Resulting path:") + "</p>");
     444                output.append("<p>" + tr("Resulting path:") + "</p>");
    445445        output.append("<p>&nbsp;&nbsp;" + solver.getSortedPath() + "</p>");
    446446        if (isInteger(step->price))
    447                 output.append("<p>" + trUtf8("The price is <b>%n</b> unit(s).", "", step->price) + "</p>");
     447                output.append("<p>" + tr("The price is <b>%n</b> unit(s).", "", step->price) + "</p>");
    448448        else
    449                 output.append("<p>" + trUtf8("The price is <b>%1</b> units.").arg(step->price, 0, 'f', 2) + "</p>");
     449                output.append("<p>" + tr("The price is <b>%1</b> units.").arg(step->price, 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt()) + "</p>");
    450450        if (!solver.isOptimal()) {
    451451                output.append("<p>&nbsp;</p>");
    452                 output.append("<p>" + trUtf8("<b>WARNING!!!</b><br>This result is a record, but it may not be optimal.<br>Iterations need to be continued to check whether this result is optimal or get an optimal one.") + "</p>");
     452                output.append("<p>" + tr("<b>WARNING!!!</b><br>This result is a record, but it may not be optimal.<br>Iterations need to be continued to check whether this result is optimal or get an optimal one.") + "</p>");
    453453        }
    454454        output.append("<p></p>");
    455455
    456456        solutionText->setHtml(output.join(""));
    457         solutionText->setDocumentTitle(trUtf8("Solution of Variant #%1 task").arg(spinVariant->value()));
     457        solutionText->setDocumentTitle(tr("Solution of Variant #%1 task").arg(spinVariant->value()));
    458458
    459459        if (settings->value("Output/ScrollToEnd", DEF_SCROLL_TO_END).toBool()) {
     
    624624                translator = NULL;
    625625                if (!ad)
    626                         QMessageBox(QMessageBox::Warning,trUtf8("Language Change"),trUtf8("Unable to load translation language."),QMessageBox::Ok,this).exec();
     626                        QMessageBox(QMessageBox::Warning,tr("Language Change"),tr("Unable to load translation language."),QMessageBox::Ok,this).exec();
    627627                return false;
    628628        }
     
    634634        if (!isWindowModified())
    635635                return true;
    636 int res = QMessageBox(QMessageBox::Warning,trUtf8("Unsaved Changes"),trUtf8("Would you like to save changes in current task?"),QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,this).exec();
     636int res = QMessageBox(QMessageBox::Warning,tr("Unsaved Changes"),tr("Would you like to save changes in current task?"),QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,this).exec();
    637637        if (res == QMessageBox::Save)
    638638                return saveTask();
     
    654654                                line += "<td align=\"center\">"INFSTR"</td>";
    655655                        else
    656                                 line += isInteger(matrix.at(r).at(c)) ? QString("<td align=\"center\">%1</td>").arg(matrix.at(r).at(c)) : QString("<td align=\"center\">%1</td>").arg(matrix.at(r).at(c), 0, 'f', 2);
     656                                line += isInteger(matrix.at(r).at(c)) ? QString("<td align=\"center\">%1</td>").arg(matrix.at(r).at(c)) : QString("<td align=\"center\">%1</td>").arg(matrix.at(r).at(c), 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());
    657657                }
    658658                line += "</tr>";
     
    673673                                line += "<td align=\"center\">"INFSTR"</td>";
    674674                        else if ((r == step.candidate.nRow) && (c == step.candidate.nCol))
    675                                 line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\" class=\"selected\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\" class=\"selected\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', 2);
     675                                line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\" class=\"selected\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\" class=\"selected\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());
    676676                        else {
    677677SCandidate cand;
     
    679679                                cand.nCol = c;
    680680                                if (step.alts.contains(cand))
    681                                         line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\" class=\"alternate\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\" class=\"alternate\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', 2);
     681                                        line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\" class=\"alternate\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\" class=\"alternate\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());
    682682                                else
    683                                         line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', 2);
     683                                        line += isInteger(step.matrix.at(r).at(c)) ? QString("<td align=\"center\">%1</td>").arg(step.matrix.at(r).at(c)) : QString("<td align=\"center\">%1</td>").arg(step.matrix.at(r).at(c), 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());
    684684                        }
    685685                }
     
    716716
    717717bool MainWindow::saveTask() {
    718 QStringList filters(trUtf8("%1 Task File").arg("TSPSG") + " (*.tspt)");
    719         filters.append(trUtf8("All Files") + " (*)");
     718QStringList filters(tr("%1 Task File").arg("TSPSG") + " (*.tspt)");
     719        filters.append(tr("All Files") + " (*)");
    720720QString file;
    721721        if (fileName.endsWith(".tspt", Qt::CaseInsensitive))
     
    725725
    726726QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog;
    727         file = QFileDialog::getSaveFileName(this, trUtf8("Task Save"), file, filters.join(";;"), NULL, opts);
     727        file = QFileDialog::getSaveFileName(this, tr("Task Save"), file, filters.join(";;"), NULL, opts);
    728728
    729729        if (file.isEmpty())
     
    740740{
    741741        this->fileName = fileName;
    742         setWindowTitle(QString("%1[*] - %2").arg(QFileInfo(fileName).completeBaseName()).arg(trUtf8("Travelling Salesman Problem")));
     742        setWindowTitle(QString("%1[*] - %2").arg(QFileInfo(fileName).completeBaseName()).arg(tr("Travelling Salesman Problem")));
    743743}
    744744
  • trunk/src/mainwindow.h

    r80 r87  
    11/*!
    22 * \file mainwindow.h
    3  * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    3939/*!
    4040 * \brief Class for handling Main Window UI and logic.
    41  * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     41 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    4242 */
    4343class MainWindow: public QMainWindow, Ui::MainWindow
     
    9898        void retranslateUi(bool all = true);
    9999        bool saveTask();
    100         void setFileName(const QString &fileName = trUtf8("Untitled") + ".tspt");
     100        void setFileName(const QString &fileName = tr("Untitled") + ".tspt");
    101101        void setupUi();
    102102        void toggleSolutionActions(bool enable = true);
  • trunk/src/os.h

    r67 r87  
    11/*!
    22 * \file os.h
    3  * \author Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 * \author Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
  • trunk/src/resource.h

    r67 r87  
    11/*!
    22 * \file resource.h
    3  * \author Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 * \author Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
  • trunk/src/settingsdialog.cpp

    r85 r87  
    11/*
    22 *  TSPSG: TSP Solver and Generator
    3  *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 *  Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    3434{
    3535        setupUi(this);
    36         // Laying out elements
    37 /*      layoutCitiesLimit = new QHBoxLayout();
    38         layoutCitiesLimit->setMargin(0);
    39         layoutCitiesLimit->setSpacing(0);
    40         layoutCitiesLimit->addSpacing(10);
    41         layoutCitiesLimit->addWidget(cbCitiesLimit);
    42         layoutCitiesLimit->addWidget(spinCitiesLimit);
    43         layoutCitiesLimit->addStretch();
    44 */
     36
    4537        buttonBox->button(QDialogButtonBox::Save)->setIcon(QIcon(":/images/icons/button_ok.png"));
    46         buttonBox->button(QDialogButtonBox::Save)->setStatusTip(trUtf8("Save new preferences"));
     38        buttonBox->button(QDialogButtonBox::Save)->setStatusTip(tr("Save new preferences"));
    4739        buttonBox->button(QDialogButtonBox::Save)->setCursor(QCursor(Qt::PointingHandCursor));
    4840        buttonBox->button(QDialogButtonBox::Cancel)->setIcon(QIcon(":/images/icons/button_cancel.png"));
    49         buttonBox->button(QDialogButtonBox::Cancel)->setStatusTip(trUtf8("Close without saving preferences"));
     41        buttonBox->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Close without saving preferences"));
    5042        buttonBox->button(QDialogButtonBox::Cancel)->setCursor(QCursor(Qt::PointingHandCursor));
    5143
     
    8072        cbSaveState->setObjectName("cbSaveState");
    8173#ifndef QT_NO_STATUSTIP
    82         cbSaveState->setStatusTip(trUtf8("Restore main window state and position on application restart"));
     74        cbSaveState->setStatusTip(tr("Restore main window state and position on application restart"));
    8375#endif // QT_NO_STATUSTIP
    84         cbSaveState->setText(trUtf8("Save main window state and position"));
     76        cbSaveState->setText(tr("Save main window state and position"));
    8577        cbSaveState->setCursor(QCursor(Qt::PointingHandCursor));
    8678
     
    10597        labelHint->setWordWrap(true);
    10698#ifndef QT_NO_STATUSTIP
    107         labelHint->setStatusTip(trUtf8("Hover mouse pointer over dialog elements to get additional help"));
     99        labelHint->setStatusTip(tr("Hover mouse pointer over dialog elements to get additional help"));
    108100#endif // QT_NO_STATUSTIP
    109101
     
    121113
    122114        vbox1 = static_cast<QVBoxLayout *>(tabGeneral->layout());
    123         vbox1->insertWidget(vbox2->indexOf(cbUseNativeDialogs) + 1, cbSaveState);
     115        vbox1->insertWidget(vbox1->indexOf(cbUseNativeDialogs) + 1, cbSaveState);
    124116
    125117        // Bottom part (with grey bg)
     
    152144        settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this);
    153145
    154         spinRandMin->setMaximum(MAX_RAND_VALUE);
    155         spinRandMin->setValue(settings->value("MinCost",DEF_RAND_MIN).toInt());
    156         spinRandMax->setMaximum(MAX_RAND_VALUE);
    157         spinRandMax->setValue(settings->value("MaxCost",DEF_RAND_MAX).toInt());
    158         cbFractionalRandom->setChecked(settings->value("FractionalRandom", DEF_FRACTIONAL_RANDOM).toBool());
    159146        cbAutosize->setChecked(settings->value("Autosize", DEF_AUTOSIZE).toBool());
    160147        cbUseNativeDialogs->setChecked(settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool());
     
    162149        cbSaveState->setChecked(settings->value("SavePos", DEF_SAVEPOS).toBool());
    163150#endif // Q_OS_WINCE
     151
     152        settings->beginGroup("Task");
     153        spinFractionalAccuracy->setValue(settings->value("FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());
     154        spinRandMin->setMaximum(MAX_RAND_VALUE);
     155        spinRandMin->setValue(settings->value("RandMin",DEF_RAND_MIN).toInt());
     156        spinRandMax->setMaximum(MAX_RAND_VALUE);
     157        spinRandMax->setValue(settings->value("RandMax",DEF_RAND_MAX).toInt());
     158        cbFractionalRandom->setChecked(settings->value("FractionalRandom", DEF_FRACTIONAL_RANDOM).toBool());
     159        settings->endGroup();
    164160
    165161        settings->beginGroup("Output");
     
    206202        settings->setValue("UseNativeDialogs", cbUseNativeDialogs->isChecked());
    207203        settings->setValue("Autosize", cbAutosize->isChecked());
    208         settings->setValue("MinCost", spinRandMin->value());
    209         settings->setValue("MaxCost", spinRandMax->value());
     204
     205        settings->beginGroup("Task");
     206        settings->setValue("FractionalAccuracy", spinFractionalAccuracy->value());
     207        settings->setValue("RandMin", spinRandMin->value());
     208        settings->setValue("RandMax", spinRandMax->value());
    210209        settings->setValue("FractionalRandom", cbFractionalRandom->isChecked());
     210        settings->endGroup();
    211211
    212212        settings->beginGroup("Output");
  • trunk/src/settingsdialog.h

    r78 r87  
    11/*!
    22 * \file settingsdialog.h
    3  * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    3535/*!
    3636 * \brief Class for handling Settings Dialog UI and logic.
    37  * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     37 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    3838 */
    3939class SettingsDialog: public QDialog, Ui::SettingsDialog
  • trunk/src/tspmodel.cpp

    r81 r87  
    11/*
    22 *  TSPSG: TSP Solver and Generator
    3  *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 *  Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    8282                if (index.row() < nCities && index.column() < nCities)
    8383                        if (table[index.row()][index.column()] == INFINITY)
    84                                 return trUtf8(INFSTR);
     84                                return tr(INFSTR);
    8585                        else
    8686//! \hack HACK: Converting to string to prevent spinbox in edit mode
     
    119119        if (role == Qt::DisplayRole) {
    120120                if (orientation == Qt::Vertical)
    121                         return trUtf8("City %1").arg(section + 1);
     121                        return tr("City %1").arg(section + 1);
    122122                else
    123                         return trUtf8("%1").arg(section + 1);
     123                        return tr("%1").arg(section + 1);
    124124        }
    125125        return QVariant();
     
    139139        if (!f.open(QIODevice::ReadOnly)) {
    140140                QApplication::restoreOverrideCursor();
    141                 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),QString(trUtf8("Unable to open task file.\nError: %1")).arg(f.errorString()),QMessageBox::Ok).exec();
     141                QMessageBox(QMessageBox::Critical,tr("Task Load"),QString(tr("Unable to open task file.\nError: %1")).arg(f.errorString()),QMessageBox::Ok).exec();
    142142                return false;
    143143        }
     
    163163                f.close();
    164164                QApplication::restoreOverrideCursor();
    165                 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("Unknown file format or file is corrupted."),QMessageBox::Ok).exec();
     165                QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + tr("Unknown file format or file is corrupted."),QMessageBox::Ok).exec();
    166166                return false;
    167167        }
     
    191191void CTSPModel::randomize()
    192192{
    193 int randMin = settings->value("MinCost",DEF_RAND_MIN).toInt();
    194 int randMax = settings->value("MaxCost",DEF_RAND_MAX).toInt();
     193int randMin = settings->value("Task/RandMin",DEF_RAND_MIN).toInt();
     194int randMax = settings->value("Task/RandMax",DEF_RAND_MAX).toInt();
    195195        for (int r = 0; r < nCities; r++)
    196196                for (int c = 0; c < nCities; c++)
     
    226226        if (!f.open(QIODevice::WriteOnly)) {
    227227                QApplication::restoreOverrideCursor();
    228                 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),QString(trUtf8("Unable to create task file.\nError: %1\nMaybe, file is read-only?")).arg(f.errorString()),QMessageBox::Ok).exec();
     228                QMessageBox(QMessageBox::Critical,tr("Task Save"),QString(tr("Unable to create task file.\nError: %1\nMaybe, file is read-only?")).arg(f.errorString()),QMessageBox::Ok).exec();
    229229                return false;
    230230        }
     
    234234                f.close();
    235235                QApplication::restoreOverrideCursor();
    236                 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
     236                QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
    237237                return false;
    238238        }
     
    242242                f.close();
    243243                QApplication::restoreOverrideCursor();
    244                 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
     244                QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
    245245                return false;
    246246        }
     
    250250                f.close();
    251251                QApplication::restoreOverrideCursor();
    252                 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
     252                QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
    253253                return false;
    254254        }
     
    258258                f.close();
    259259                QApplication::restoreOverrideCursor();
    260                 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
     260                QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
    261261                return false;
    262262        }
     
    266266                f.close();
    267267                QApplication::restoreOverrideCursor();
    268                 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
     268                QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
    269269                return false;
    270270        }
     
    274274                f.close();
    275275                QApplication::restoreOverrideCursor();
    276                 QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
     276                QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
    277277                return false;
    278278        }
     
    281281                for (int c = 0; c < nCities; c++)
    282282                        if (r != c) {
    283                                 ds << table[r][c];
     283                                ds << static_cast<double>(table[r][c]); // We cast to double because qreal may be float on some platforms and we store double values in file
    284284                                if (f.error() != QFile::NoError) {
    285285                                        f.close();
    286286                                        QApplication::restoreOverrideCursor();
    287                                         QMessageBox(QMessageBox::Critical,trUtf8("Task Save"),trUtf8("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
     287                                        QMessageBox(QMessageBox::Critical,tr("Task Save"),tr("Unable to save task.\nError: %1").arg(f.errorString()),QMessageBox::Ok).exec();
    288288                                        return false;
    289289                                }
     
    312312                else {
    313313bool ok;
    314 double tmp = value.toDouble(&ok);
     314qreal tmp = value.toReal(&ok);
    315315                        if (!ok || tmp < 0)
    316316                                return false;
     
    354354                return false;
    355355        else if (status == QDataStream::ReadPastEnd)
    356                 err = trUtf8("Unexpected end of file.");
     356                err = tr("Unexpected end of file.");
    357357        else if (status == QDataStream::ReadCorruptData)
    358                 err = trUtf8("Corrupt data read. File possibly corrupted.");
     358                err = tr("Corrupt data read. File possibly corrupted.");
    359359        else
    360                 err = trUtf8("Unknown error.");
     360                err = tr("Unknown error.");
    361361        QApplication::restoreOverrideCursor();
    362         QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + err,QMessageBox::Ok).exec();
     362        QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + err,QMessageBox::Ok).exec();
    363363        return true;
    364364}
     
    377377        if (version > TSPT_VERSION) {
    378378                QApplication::restoreOverrideCursor();
    379                 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("File version is newer than application supports.\nPlease, try to update application."),QMessageBox::Ok).exec();
     379                QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + tr("File version is newer than application supports.\nPlease, try to update application."),QMessageBox::Ok).exec();
    380380                return false;
    381381        }
     
    391391        if ((size < 3) || (size > MAX_NUM_CITIES)) {
    392392                QApplication::restoreOverrideCursor();
    393                 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("Unexpected data read.\nFile is possibly corrupted."),QMessageBox::Ok).exec();
     393                QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + tr("Unexpected data read.\nFile is possibly corrupted."),QMessageBox::Ok).exec();
    394394                return false;
    395395        }
     
    398398                emit numCitiesChanged(size);
    399399        }
     400
     401double x; // We need this as qreal may be float on some platforms and we store double values in file
    400402        // Travel costs
    401403        for (int r = 0; r < size; r++)
    402404                for (int c = 0; c < size; c++)
    403405                        if (r != c) {
    404                                 *ds >> table[r][c];
     406                                *ds >> x;
     407                                table[r][c] = x;
    405408                                if (loadError(ds->status())) {
    406409                                        clear();
     
    426429        if (version > ZKT_VERSION) {
    427430                QApplication::restoreOverrideCursor();
    428                 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("File version is newer than application supports.\nPlease, try to update application."),QMessageBox::Ok).exec();
     431                QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + tr("File version is newer than application supports.\nPlease, try to update application."),QMessageBox::Ok).exec();
    429432                return false;
    430433        }
     
    436439        if ((size < 3) || (size > 5)) {
    437440                QApplication::restoreOverrideCursor();
    438                 QMessageBox(QMessageBox::Critical,trUtf8("Task Load"),trUtf8("Unable to load task:") + "\n" + trUtf8("Unexpected data read.\nFile is possibly corrupted."),QMessageBox::Ok).exec();
     441                QMessageBox(QMessageBox::Critical,tr("Task Load"),tr("Unable to load task:") + "\n" + tr("Unexpected data read.\nFile is possibly corrupted."),QMessageBox::Ok).exec();
    439442                return false;
    440443        }
     
    444447        }
    445448        // Travel costs
    446 double val;
     449qreal val;
    447450        for (int r = 0; r < 5; r++)
    448451                for (int c = 0; c < 5; c++)
    449                         if ((r != c) && (r < size)) {
     452                        if ((r != c) && (r < size) && (c < size)) {
    450453                                ds->readRawData(reinterpret_cast<char *>(&val),8);
    451454                                if (loadError(ds->status())) {
     
    466469}
    467470
    468 inline double CTSPModel::rand(int min, int max) const
    469 {
    470 double r;
    471         if (settings->value("FractionalRandom", DEF_FRACTIONAL_RANDOM).toBool())
    472                 r = (double)qRound((double)qrand() / RAND_MAX * (max - min) * 100) / 100;
    473         else
    474                 r = qRound((double)qrand() / RAND_MAX * (max - min));
     471inline qreal CTSPModel::rand(int min, int max) const
     472{
     473qreal r;
     474        if (settings->value("Task/FractionalRandom", DEF_FRACTIONAL_RANDOM).toBool()) {
     475qreal x = qPow(10, settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());
     476                r = (qreal)qRound((qreal)qrand() / RAND_MAX * (max - min) * x) / x;
     477        } else
     478                r = qRound((qreal)qrand() / RAND_MAX * (max - min));
    475479        return min + r;
    476480}
  • trunk/src/tspmodel.h

    r81 r87  
    11/*!
    22 * \file tspmodel.h
    3  * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    3333/*!
    3434 * \brief This class implements table model for manipulating a task.
    35  * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     35 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    3636 */
    3737class CTSPModel: public QAbstractTableModel
     
    6464private:
    6565        QSettings *settings;
    66         QVector<QVector<double> > table;
     66        QVector<QVector<qreal> > table;
    6767        quint16 nCities;
    6868        bool loadError(QDataStream::Status);
    6969        bool loadTSPT(QDataStream *);
    7070        bool loadZKT(QDataStream *);
    71         double rand(int, int) const;
     71        qreal rand(int, int) const;
    7272};
    7373
  • trunk/src/tspsolver.cpp

    r79 r87  
    11/*
    22 *  TSPSG: TSP Solver and Generator
    3  *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 *  Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    4040
    4141int i = 0; // We start from City 1
    42 QString path = trUtf8("City %1").arg(1) + " -> ";
     42QString path = tr("City %1").arg(1) + " -> ";
    4343        while ((i = route[i]) != 0) {
    44                 path += trUtf8("City %1").arg(i + 1) + " -> ";
     44                path += tr("City %1").arg(i + 1) + " -> ";
    4545        }
    4646        // And finish in City 1, too
    47         path += trUtf8("City %1").arg(1);
     47        path += tr("City %1").arg(1);
    4848
    4949        return path;
     
    8989QProgressBar *pb = new QProgressBar(&pd);
    9090        pb->setAlignment(Qt::AlignCenter);
    91         pb->setFormat(trUtf8("%v of %m parts found"));
     91        pb->setFormat(tr("%v of %m parts found"));
    9292        pd.setBar(pb);
    9393        pd.setMaximum(nCities);
    9494        pd.setMinimumDuration(1000);
    95         pd.setLabelText(trUtf8("Calculating optimal route..."));
    96         pd.setWindowTitle(trUtf8("Solution Progress"));
     95        pd.setLabelText(tr("Calculating optimal route..."));
     96        pd.setWindowTitle(tr("Solution Progress"));
    9797        pd.setWindowModality(Qt::ApplicationModal);
    9898        pd.setValue(0);
     
    106106int nRow, nCol;
    107107bool firstStep = true;
    108 double check;
     108qreal check;
    109109        while (this->route.size() < nCities) {
    110110//              forbidden.clear();
     
    168168        if (!root && !pd.wasCanceled()) {
    169169                pd.reset();
    170                 QMessageBox(QMessageBox::Warning,trUtf8("Solution Result"),trUtf8("Unable to find solution.\nMaybe, this task has no solutions."),QMessageBox::Ok,parent).exec();
     170                QMessageBox(QMessageBox::Warning,tr("Solution Result"),tr("Unable to find solution.\nMaybe, this task has no solutions."),QMessageBox::Ok,parent).exec();
    171171        }
    172172
     
    188188/* Privates **********************************************************/
    189189
    190 double CTSPSolver::align(TMatrix &matrix)
    191 {
    192 double r = 0;
    193 double min;
     190qreal CTSPSolver::align(TMatrix &matrix)
     191{
     192qreal r = 0;
     193qreal min;
    194194        for (int k = 0; k < nCities; k++) {
    195195                min = findMinInRow(k,matrix);
     
    240240QList<SCandidate> alts;
    241241SCandidate cand;
    242 double h = -1;
    243 double sum;
     242qreal h = -1;
     243qreal sum;
    244244        for (int r = 0; r < nCities; r++)
    245245                for (int c = 0; c < nCities; c++)
     
    261261}
    262262
    263 double CTSPSolver::findMinInCol(int nCol, const TMatrix &matrix, int exr) const
    264 {
    265 double min = INFINITY;
     263qreal CTSPSolver::findMinInCol(int nCol, const TMatrix &matrix, int exr) const
     264{
     265qreal min = INFINITY;
    266266        for (int k = 0; k < nCities; k++)
    267267                if ((k != exr) && (min > matrix.at(k).at(nCol)))
     
    270270}
    271271
    272 double CTSPSolver::findMinInRow(int nRow, const TMatrix &matrix, int exc) const
    273 {
    274 double min = INFINITY;
     272qreal CTSPSolver::findMinInRow(int nRow, const TMatrix &matrix, int exc) const
     273{
     274qreal min = INFINITY;
    275275        for (int k = 0; k < nCities; k++)
    276276                if (((k != exc)) && (min > matrix.at(nRow).at(k)))
     
    293293}
    294294
    295 void CTSPSolver::subCol(TMatrix &matrix, int nCol, double val)
     295void CTSPSolver::subCol(TMatrix &matrix, int nCol, qreal val)
    296296{
    297297        for (int k = 0; k < nCities; k++)
     
    300300}
    301301
    302 void CTSPSolver::subRow(TMatrix &matrix, int nRow, double val)
     302void CTSPSolver::subRow(TMatrix &matrix, int nRow, qreal val)
    303303{
    304304        for (int k = 0; k < nCities; k++)
  • trunk/src/tspsolver.h

    r77 r87  
    11/*!
    22 * \file tspsolver.h
    3  * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    3434
    3535//! A matrix of city-to-city travel costs.
    36 typedef QList<QList<double> > TMatrix;
     36typedef QList<QList<qreal> > TMatrix;
    3737
    3838/*!
     
    6060struct SStep {
    6161        TMatrix matrix; //!< This step's matrix
    62         double price; //!< The price of travel to this step
     62        qreal price; //!< The price of travel to this step
    6363        SCandidate candidate; //!< A candiadate for branching in the current matrix
    6464        QList<SCandidate> alts; //!< A list of alternative branching candidates
     
    7575/*!
    7676 * \brief This class solves Travelling Salesman Problem task.
    77  * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     77 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    7878 *
    7979 * \todo TODO: Deletion of solution tree on destroy and cleanup.
     
    9898//      QHash<int,int> forbidden;
    9999
    100         double align(TMatrix &matrix);
     100        qreal align(TMatrix &matrix);
    101101        void cleanup();
    102102        void deleteNode(SStep *&node);
    103103        QList<SCandidate> findCandidate(const TMatrix &matrix, int &nRow, int &nCol) const;
    104         double findMinInCol(int nCol, const TMatrix &matrix, int exr = -1) const;
    105         double findMinInRow(int nRow, const TMatrix &matrix, int exc = -1) const;
     104        qreal findMinInCol(int nCol, const TMatrix &matrix, int exr = -1) const;
     105        qreal findMinInRow(int nRow, const TMatrix &matrix, int exc = -1) const;
    106106        bool hasSubCycles(int nRow, int nCol) const;
    107         void subCol(TMatrix &matrix, int nCol, double val);
    108         void subRow(TMatrix &matrix, int nRow, double val);
     107        void subCol(TMatrix &matrix, int nCol, qreal val);
     108        void subRow(TMatrix &matrix, int nRow, qreal val);
    109109};
    110110
  • trunk/src/version.h

    r71 r87  
    11/*!
    22 * \file version.h
    3  * \author Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     3 * \author Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    44 *
    55 *  $Id$
     
    2929 * \image html tspsg.png
    3030 *  <b>TSPSG: TSP Solver and Generator</b>
    31  * \author Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     31 * \author Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    3232 *
    3333 *  $Id$
  • trunk/tspsg.pri

    r56 r87  
    22#
    33# TSPSG: TSP Solver and Generator
    4 # Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     4# Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    55#
    66# $Id$
     
    1515        src/version.h \
    1616        src/os.h \
     17        src/defaults.h \
    1718        src/mainwindow.h \
    1819        src/settingsdialog.h \
  • trunk/tspsg.pro

    r71 r87  
    22#
    33# TSPSG: TSP Solver and Generator
    4 # Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     4# Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
    55#
    66# $Id$
  • trunk/ui/settingsdialog.ui

    r85 r87  
    155155    <item>
    156156     <widget class="QTabWidget" name="tabWidget">
    157       <property name="currentIndex">
    158        <number>0</number>
    159       </property>
    160157      <widget class="QWidget" name="tabGeneral">
    161158       <attribute name="title">
     
    207204       </layout>
    208205      </widget>
    209       <widget class="QWidget" name="tabRandom">
     206      <widget class="QWidget" name="tabTask">
    210207       <attribute name="title">
    211         <string>Random</string>
     208        <string>Task</string>
    212209       </attribute>
    213210       <attribute name="toolTip">
    214         <string>Random number generation settings</string>
     211        <string>Task generation and solving settings</string>
    215212       </attribute>
    216213       <layout class="QVBoxLayout" name="verticalLayout_4">
    217214        <item>
    218          <layout class="QHBoxLayout" name="horizontalLayout_2">
    219           <item>
    220            <layout class="QFormLayout" name="formLayout">
    221             <item row="0" column="0">
    222              <widget class="QLabel" name="labelRandMin">
    223               <property name="text">
    224                <string>&amp;Minimal:</string>
    225               </property>
    226               <property name="buddy">
    227                <cstring>spinRandMin</cstring>
    228               </property>
    229              </widget>
    230             </item>
    231             <item row="0" column="1">
    232              <widget class="QSpinBox" name="spinRandMin">
    233               <property name="cursor">
    234                <cursorShape>PointingHandCursor</cursorShape>
    235               </property>
    236               <property name="statusTip">
    237                <string>Minimum for random number generation</string>
    238               </property>
    239              </widget>
    240             </item>
    241             <item row="1" column="0">
    242              <widget class="QLabel" name="labelRandMax">
    243               <property name="text">
    244                <string>Ma&amp;ximal:</string>
    245               </property>
    246               <property name="buddy">
    247                <cstring>spinRandMax</cstring>
    248               </property>
    249              </widget>
    250             </item>
    251             <item row="1" column="1">
    252              <widget class="QSpinBox" name="spinRandMax">
    253               <property name="cursor">
    254                <cursorShape>PointingHandCursor</cursorShape>
    255               </property>
    256               <property name="statusTip">
    257                <string>Maximum for random number generation</string>
    258               </property>
    259              </widget>
    260             </item>
    261            </layout>
     215         <layout class="QHBoxLayout" name="horizontalLayout_3">
     216          <item>
     217           <widget class="QLabel" name="labelFractionalAccuracy">
     218            <property name="text">
     219             <string>Fractional accuracy:</string>
     220            </property>
     221            <property name="buddy">
     222             <cstring>spinFractionalAccuracy</cstring>
     223            </property>
     224           </widget>
     225          </item>
     226          <item>
     227           <widget class="QSpinBox" name="spinFractionalAccuracy">
     228            <property name="cursor">
     229             <cursorShape>PointingHandCursor</cursorShape>
     230            </property>
     231            <property name="statusTip">
     232             <string>Accuracy of the fractional values (in decimal places)</string>
     233            </property>
     234            <property name="maximum">
     235             <number>6</number>
     236            </property>
     237           </widget>
    262238          </item>
    263239          <item>
     
    268244            <property name="sizeHint" stdset="0">
    269245             <size>
    270               <width>10</width>
     246              <width>0</width>
    271247              <height>0</height>
    272248             </size>
     
    277253        </item>
    278254        <item>
    279          <widget class="QCheckBox" name="cbFractionalRandom">
    280           <property name="cursor">
    281            <cursorShape>PointingHandCursor</cursorShape>
    282           </property>
    283           <property name="statusTip">
    284            <string>Generate fractional random values with the accuracy of 2 decimal places</string>
    285           </property>
    286           <property name="text">
    287            <string>Fractional random values</string>
    288           </property>
    289          </widget>
     255         <layout class="QHBoxLayout" name="horizontalLayout_2">
     256          <item>
     257           <widget class="QGroupBox" name="groupBox">
     258            <property name="title">
     259             <string>Random numbers</string>
     260            </property>
     261            <layout class="QVBoxLayout" name="verticalLayout_5">
     262             <item>
     263              <layout class="QFormLayout" name="formLayout">
     264               <property name="fieldGrowthPolicy">
     265                <enum>QFormLayout::ExpandingFieldsGrow</enum>
     266               </property>
     267               <item row="0" column="0">
     268                <widget class="QLabel" name="labelRandMin">
     269                 <property name="text">
     270                  <string>&amp;Minimal:</string>
     271                 </property>
     272                 <property name="buddy">
     273                  <cstring>spinRandMin</cstring>
     274                 </property>
     275                </widget>
     276               </item>
     277               <item row="0" column="1">
     278                <widget class="QSpinBox" name="spinRandMin">
     279                 <property name="cursor">
     280                  <cursorShape>PointingHandCursor</cursorShape>
     281                 </property>
     282                 <property name="statusTip">
     283                  <string>Minimum for random number generation</string>
     284                 </property>
     285                </widget>
     286               </item>
     287               <item row="1" column="0">
     288                <widget class="QLabel" name="labelRandMax">
     289                 <property name="text">
     290                  <string>Ma&amp;ximal:</string>
     291                 </property>
     292                 <property name="buddy">
     293                  <cstring>spinRandMax</cstring>
     294                 </property>
     295                </widget>
     296               </item>
     297               <item row="1" column="1">
     298                <widget class="QSpinBox" name="spinRandMax">
     299                 <property name="cursor">
     300                  <cursorShape>PointingHandCursor</cursorShape>
     301                 </property>
     302                 <property name="statusTip">
     303                  <string>Maximum for random number generation</string>
     304                 </property>
     305                </widget>
     306               </item>
     307              </layout>
     308             </item>
     309             <item>
     310              <widget class="QCheckBox" name="cbFractionalRandom">
     311               <property name="cursor">
     312                <cursorShape>PointingHandCursor</cursorShape>
     313               </property>
     314               <property name="statusTip">
     315                <string>Generate fractional random values with the Fractional accuracy</string>
     316               </property>
     317               <property name="text">
     318                <string>Fractional random values</string>
     319               </property>
     320              </widget>
     321             </item>
     322            </layout>
     323           </widget>
     324          </item>
     325          <item>
     326           <spacer name="horizontalSpacer">
     327            <property name="orientation">
     328             <enum>Qt::Horizontal</enum>
     329            </property>
     330            <property name="sizeHint" stdset="0">
     331             <size>
     332              <width>0</width>
     333              <height>0</height>
     334             </size>
     335            </property>
     336           </spacer>
     337          </item>
     338         </layout>
    290339        </item>
    291340        <item>
     
    297346           <size>
    298347            <width>0</width>
    299             <height>25</height>
     348            <height>1</height>
    300349           </size>
    301350          </property>
     
    401450        </item>
    402451        <item>
    403          <layout class="QHBoxLayout" name="horizontalLayout">
    404           <item>
    405            <widget class="QPushButton" name="buttonFont">
    406             <property name="cursor">
    407              <cursorShape>PointingHandCursor</cursorShape>
    408             </property>
    409             <property name="statusTip">
    410              <string>Font face for solution output</string>
    411             </property>
    412             <property name="text">
    413              <string>&amp;Font...</string>
    414             </property>
    415             <property name="icon">
    416              <iconset resource="../resources/tspsg.qrc">
    417               <normaloff>:/images/icons/fonts.png</normaloff>:/images/icons/fonts.png</iconset>
    418             </property>
    419            </widget>
    420           </item>
    421           <item>
    422            <widget class="QPushButton" name="buttonColor">
    423             <property name="cursor">
    424              <cursorShape>PointingHandCursor</cursorShape>
    425             </property>
    426             <property name="statusTip">
    427              <string>Font color for solution output</string>
    428             </property>
    429             <property name="text">
    430              <string>&amp;Color...</string>
    431             </property>
    432             <property name="icon">
    433              <iconset resource="../resources/tspsg.qrc">
    434               <normaloff>:/images/icons/color_line.png</normaloff>:/images/icons/color_line.png</iconset>
    435             </property>
     452         <layout class="QHBoxLayout" name="horizontalLayout_4">
     453          <item>
     454           <widget class="QGroupBox" name="groupBox_2">
     455            <property name="title">
     456             <string>Output font settings</string>
     457            </property>
     458            <layout class="QHBoxLayout" name="horizontalLayout">
     459             <item>
     460              <widget class="QPushButton" name="buttonFont">
     461               <property name="cursor">
     462                <cursorShape>PointingHandCursor</cursorShape>
     463               </property>
     464               <property name="statusTip">
     465                <string>Font face for solution output</string>
     466               </property>
     467               <property name="text">
     468                <string>&amp;Font...</string>
     469               </property>
     470               <property name="icon">
     471                <iconset resource="../resources/tspsg.qrc">
     472                 <normaloff>:/images/icons/fonts.png</normaloff>:/images/icons/fonts.png</iconset>
     473               </property>
     474              </widget>
     475             </item>
     476             <item>
     477              <widget class="QPushButton" name="buttonColor">
     478               <property name="cursor">
     479                <cursorShape>PointingHandCursor</cursorShape>
     480               </property>
     481               <property name="statusTip">
     482                <string>Font color for solution output</string>
     483               </property>
     484               <property name="text">
     485                <string>&amp;Color...</string>
     486               </property>
     487               <property name="icon">
     488                <iconset resource="../resources/tspsg.qrc">
     489                 <normaloff>:/images/icons/color_line.png</normaloff>:/images/icons/color_line.png</iconset>
     490               </property>
     491              </widget>
     492             </item>
     493            </layout>
    436494           </widget>
    437495          </item>
Note: See TracChangeset for help on using the changeset viewer.