Changeset 27 in tspsg-svn for trunk/src


Ignore:
Timestamp:
Jun 23, 2009, 7:56:29 PM (15 years ago)
Author:
laleppa
Message:

+ Language is automatically loaded at application startup (based on user's locale name).
+ Full Ukrainian and Russian translation.

  • English is now default language.
Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defines.h

    r23 r27  
    3333#define DEF_FONT_COLOR Qt::black
    3434
     35// Decided, that static array with 100 of cities maximum hard limit
     36// will be enough for most cases, but the code will be simplier than
     37// when using dynamic lists. If you need more, just change this value
     38// and recompile the program ;-)
     39#define MAX_CITIES 100
     40// This value means infinity :-)
     41#ifndef INFINITY
     42        #define INFINITY 1.7E+308
     43#endif
     44// This is string, which represents infinite value in table
     45#define INFSTR "-----"
     46
    3547#endif // DEFINES_H
  • trunk/src/main.cpp

    r21 r27  
    3333        app.setOrganizationDomain("www.leppsville.com");
    3434        app.setApplicationName("TSPSG");
    35 /*/ i18n
    36 // TODO: Make English as program's "native" language
     35// i18n
     36// TODO: Language selection in application.
     37// TODO: Saving and restoring selected language.
    3738QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
    3839QString locale = QLocale::languageToString(QLocale::system().language());
    3940QTranslator translator;
    40         // Getting current locale languge name and trying to load it
    41         if (translator.load(locale,"i18n"))
     41        // Getting current locale language name and trying to load it, if it's not English
     42        if (locale.compare("English") && translator.load(locale,"i18n"))
    4243                app.installTranslator(&translator);
    43         // If language loading failed and locale language is not
    44         // application's "native" we're trying to load English
    45         else if (locale.compare("Russian") && translator.load("English","i18n"))
    46                 app.installTranslator(&translator);
    47 //*/
    4844MainWindow mainwindow;
    4945        mainwindow.show();
  • trunk/src/mainwindow.cpp

    r26 r27  
    2626        #include <QPrintDialog>
    2727#endif // Q_OS_WINCE
    28 #include "defines.h"
    2928#include "mainwindow.h"
    3029
     
    124123                        row[c] = tspmodel->index(r,c).data(Qt::UserRole).toDouble(&ok);
    125124                        if (!ok) {
    126                                 QMessageBox(QMessageBox::Critical,trUtf8("Ошибка в данных"),QString(trUtf8("Ошибка в ячейке [Строка %1; Колонка %2]: Неверный формат данных.")).arg(r + 1).arg(c + 1),QMessageBox::Ok,this).exec();
     125                                QMessageBox(QMessageBox::Critical,trUtf8("Data error"),QString(trUtf8("Error in cell [Row %1; Column %2]: Invalid data format.")).arg(r + 1).arg(c + 1),QMessageBox::Ok,this).exec();
    127126                                return;
    128127                        }
     
    133132sStep *root = solver.solve(spinCities->value(),matrix);
    134133        if (!root)
    135                 QMessageBox(QMessageBox::Critical,trUtf8("Ошибка при решении"),trUtf8("Во время решения задачи возникла ошибка"),QMessageBox::Ok,this).exec();
     134                QMessageBox(QMessageBox::Critical,trUtf8("Solution error"),trUtf8("There was an error while solving the task."),QMessageBox::Ok,this).exec();
    136135        // tabWidget->setCurrentIndex(1);
    137136}
     
    147146\n\
    148147TSPSG is licensed under the terms of the GNU General Public License. You should have received a copy of the GNU General Public License along with TSPSG.").arg(QDate().toString("%Y"),QT_VERSION_STR,qVersion());
    149         QMessageBox(QMessageBox::Information,"About",about).exec();
     148        QMessageBox(QMessageBox::Information,"About",about,QMessageBox::Ok,this).exec();
    150149}
    151150
  • trunk/src/tspmodel.cpp

    r23 r27  
    2323
    2424#include <QtGui>
    25 #include "defines.h"
    2625#include "tspmodel.h"
    2726
     
    5150        if (role == Qt::DisplayRole)
    5251                if (orientation == Qt::Vertical)
    53                         return trUtf8("Город %1").arg(section + 1);
     52                        return trUtf8("City %1").arg(section + 1);
    5453                else
    5554                        return trUtf8("%1").arg(section + 1);
  • trunk/src/tspmodel.h

    r21 r27  
    2525#define TSPMODEL_H
    2626
    27 // Decided, that static array with 100 of cities maximum hard limit
    28 // will be enough for most cases, but the code will be simplier than
    29 // when using dynamic lists. If you need more, just change this value
    30 // and recompile the program ;-)
    31 #define MAX_CITIES 100
    32 // This value means infinity :-)
    33 #ifndef INFINITY
    34         #define INFINITY 1.7E+308
    35 #endif
    36 // This is string, which represents infinite value in table
    37 #define INFSTR "---"
    38 
    3927#include <QAbstractTableModel>
    4028#include <QSettings>
     29#include "defines.h"
    4130
    4231class CTSPModel: public QAbstractTableModel
Note: See TracChangeset for help on using the changeset viewer.