Index: src/mainwindow.cpp
===================================================================
--- src/mainwindow.cpp	(revision 946f442ab003c2d35edec967cd26d68f91b38e6c)
+++ src/mainwindow.cpp	(revision 1757eb594b8b3dff685100cc94067b0bf552099d)
@@ -1,5 +1,5 @@
 /*
  *  TSPSG: TSP Solver and Generator
- *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
+ *  Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
  *
  *  $Id$
@@ -124,11 +124,11 @@
 		return;
 
-QStringList filters(trUtf8("All Supported Formats") + " (*.tspt *.zkt)");
-	filters.append(trUtf8("%1 Task Files").arg("TSPSG") + " (*.tspt)");
-	filters.append(trUtf8("%1 Task Files").arg("ZKomModRd") + " (*.zkt)");
-	filters.append(trUtf8("All Files") + " (*)");
+QStringList filters(tr("All Supported Formats") + " (*.tspt *.zkt)");
+	filters.append(tr("%1 Task Files").arg("TSPSG") + " (*.tspt)");
+	filters.append(tr("%1 Task Files").arg("ZKomModRd") + " (*.zkt)");
+	filters.append(tr("All Files") + " (*)");
 
 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog;
-QString file = QFileDialog::getOpenFileName(this, trUtf8("Task Load"), QString(), filters.join(";;"), NULL, opts);
+QString file = QFileDialog::getOpenFileName(this, tr("Task Load"), QString(), filters.join(";;"), NULL, opts);
 	if (file.isEmpty() || !QFileInfo(file).isFile())
 		return;
@@ -144,5 +144,5 @@
 void MainWindow::actionFileSaveTriggered()
 {
-	if ((fileName == trUtf8("Untitled") + ".tspt") || (!fileName.endsWith(".tspt",Qt::CaseInsensitive)))
+	if ((fileName == tr("Untitled") + ".tspt") || (!fileName.endsWith(".tspt",Qt::CaseInsensitive)))
 		saveTask();
 	else
@@ -160,5 +160,5 @@
 static QString selectedFile;
 	if (selectedFile.isEmpty()) {
-		if (fileName == trUtf8("Untitled") + ".tspt") {
+		if (fileName == tr("Untitled") + ".tspt") {
 #ifndef QT_NO_PRINTER
 			selectedFile = "solution.pdf";
@@ -177,11 +177,11 @@
 QStringList filters;
 #ifndef QT_NO_PRINTER
-	filters.append(trUtf8("PDF Files") + " (*.pdf)");
+	filters.append(tr("PDF Files") + " (*.pdf)");
 #endif
-	filters.append(trUtf8("HTML Files") + " (*.html *.htm)");
+	filters.append(tr("HTML Files") + " (*.html *.htm)");
 #if QT_VERSION >= 0x040500
-	filters.append(trUtf8("OpenDocument Files") + " (*.odt)");
+	filters.append(tr("OpenDocument Files") + " (*.odt)");
 #endif // QT_VERSION >= 0x040500
-	filters.append(trUtf8("All Files") + " (*)");
+	filters.append(tr("All Files") + " (*)");
 
 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog;
@@ -252,5 +252,5 @@
 	if (sd.colorChanged() || sd.fontChanged()) {
 		initDocStyleSheet();
-		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)) {
+		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)) {
 			QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 			solutionText->clear();
@@ -265,5 +265,5 @@
 	if (checked) {
 		settings->remove("Language");
-		QMessageBox(QMessageBox::Information,trUtf8("Language change"),trUtf8("Language will be autodetected on next application start."),QMessageBox::Ok,this).exec();
+		QMessageBox(QMessageBox::Information,tr("Language change"),tr("Language will be autodetected on next application start."),QMessageBox::Ok,this).exec();
 	} else
 		settings->setValue("Language",groupSettingsLanguageList->checkedAction()->data().toString());
@@ -274,10 +274,10 @@
 	if (actionSettingsLanguageAutodetect->isChecked()) {
 		// We have language autodetection. It needs to be disabled to change language.
-		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) {
+		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) {
 			actionSettingsLanguageAutodetect->trigger();
 		} else
 			return;
 	}
-bool untitled = (fileName == trUtf8("Untitled") + ".tspt");
+bool untitled = (fileName == tr("Untitled") + ".tspt");
 	if (loadLanguage(action->data().toString())) {
 		QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@@ -357,5 +357,5 @@
 
 	dlg->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
-	dlg->setWindowTitle(trUtf8("About TSPSG"));
+	dlg->setWindowTitle(tr("About TSPSG"));
 	dlg->setLayout(vb);
 
@@ -383,5 +383,5 @@
 {
 TMatrix matrix;
-QList<double> row;
+QList<qreal> row;
 int n = spinCities->value();
 bool ok;
@@ -389,7 +389,7 @@
 		row.clear();
 		for (int c = 0; c < n; c++) {
-			row.append(tspmodel->index(r,c).data(Qt::UserRole).toDouble(&ok));
+			row.append(tspmodel->index(r,c).data(Qt::UserRole).toReal(&ok));
 			if (!ok) {
-				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();
+				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();
 				return;
 			}
@@ -404,9 +404,9 @@
 QColor color = settings->value("Output/Color",DEF_FONT_COLOR).value<QColor>();
 	output.clear();
-	output.append("<p>" + trUtf8("Variant #%1").arg(spinVariant->value()) + "</p>");
-	output.append("<p>" + trUtf8("Task:") + "</p>");
+	output.append("<p>" + tr("Variant #%1").arg(spinVariant->value()) + "</p>");
+	output.append("<p>" + tr("Task:") + "</p>");
 	outputMatrix(matrix, output);
 	output.append("<hr>");
-	output.append("<p>" + trUtf8("Solution of Variant #%1 task").arg(spinVariant->value()) + "</p>");
+	output.append("<p>" + tr("Solution of Variant #%1 task").arg(spinVariant->value()) + "</p>");
 SStep *step = root;
 	n = 1;
@@ -414,9 +414,9 @@
 		if (step->prNode->prNode != NULL || ((step->prNode->prNode == NULL) && (step->plNode->prNode == NULL))) {
 			if (n != spinCities->value()) {
-				output.append("<p>" + trUtf8("Step #%1").arg(n++) + "</p>");
+				output.append("<p>" + tr("Step #%1").arg(n++) + "</p>");
 				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())) {
 					outputMatrix(*step, output);
 				}
-				output.append("<p>" + trUtf8("Selected candidate for branching: %1.").arg(trUtf8("(%1;%2)").arg(step->candidate.nRow + 1).arg(step->candidate.nCol + 1)) + "</p>");
+				output.append("<p>" + tr("Selected candidate for branching: %1.").arg(tr("(%1;%2)").arg(step->candidate.nRow + 1).arg(step->candidate.nCol + 1)) + "</p>");
 				if (!step->alts.empty()) {
 SCandidate cand;
@@ -425,7 +425,7 @@
 						if (!alts.isEmpty())
 							alts += ", ";
-						alts += trUtf8("(%1;%2)").arg(cand.nRow + 1).arg(cand.nCol + 1);
+						alts += tr("(%1;%2)").arg(cand.nRow + 1).arg(cand.nCol + 1);
 					}
-					output.append("<p class=\"hasalts\">" + trUtf8("%n alternate candidate(s) for branching: %1.","",step->alts.count()).arg(alts) + "</p>");
+					output.append("<p class=\"hasalts\">" + tr("%n alternate candidate(s) for branching: %1.","",step->alts.count()).arg(alts) + "</p>");
 				}
 				output.append("<p>&nbsp;</p>");
@@ -440,20 +440,20 @@
 	}
 	if (solver.isOptimal())
-		output.append("<p>" + trUtf8("Optimal path:") + "</p>");
+		output.append("<p>" + tr("Optimal path:") + "</p>");
 	else
-		output.append("<p>" + trUtf8("Resulting path:") + "</p>");
+		output.append("<p>" + tr("Resulting path:") + "</p>");
 	output.append("<p>&nbsp;&nbsp;" + solver.getSortedPath() + "</p>");
 	if (isInteger(step->price))
-		output.append("<p>" + trUtf8("The price is <b>%n</b> unit(s).", "", step->price) + "</p>");
+		output.append("<p>" + tr("The price is <b>%n</b> unit(s).", "", step->price) + "</p>");
 	else
-		output.append("<p>" + trUtf8("The price is <b>%1</b> units.").arg(step->price, 0, 'f', 2) + "</p>");
+		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>");
 	if (!solver.isOptimal()) {
 		output.append("<p>&nbsp;</p>");
-		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>");
+		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>");
 	}
 	output.append("<p></p>");
 
 	solutionText->setHtml(output.join(""));
-	solutionText->setDocumentTitle(trUtf8("Solution of Variant #%1 task").arg(spinVariant->value()));
+	solutionText->setDocumentTitle(tr("Solution of Variant #%1 task").arg(spinVariant->value()));
 
 	if (settings->value("Output/ScrollToEnd", DEF_SCROLL_TO_END).toBool()) {
@@ -624,5 +624,5 @@
 		translator = NULL;
 		if (!ad)
-			QMessageBox(QMessageBox::Warning,trUtf8("Language Change"),trUtf8("Unable to load translation language."),QMessageBox::Ok,this).exec();
+			QMessageBox(QMessageBox::Warning,tr("Language Change"),tr("Unable to load translation language."),QMessageBox::Ok,this).exec();
 		return false;
 	}
@@ -634,5 +634,5 @@
 	if (!isWindowModified())
 		return true;
-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();
+int 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();
 	if (res == QMessageBox::Save)
 		return saveTask();
@@ -654,5 +654,5 @@
 				line += "<td align=\"center\">"INFSTR"</td>";
 			else
-				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);
+				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());
 		}
 		line += "</tr>";
@@ -673,5 +673,5 @@
 				line += "<td align=\"center\">"INFSTR"</td>";
 			else if ((r == step.candidate.nRow) && (c == step.candidate.nCol))
-				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);
+				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());
 			else {
 SCandidate cand;
@@ -679,7 +679,7 @@
 				cand.nCol = c;
 				if (step.alts.contains(cand))
-					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);
+					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());
 				else
-					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);
+					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());
 			}
 		}
@@ -716,6 +716,6 @@
 
 bool MainWindow::saveTask() {
-QStringList filters(trUtf8("%1 Task File").arg("TSPSG") + " (*.tspt)");
-	filters.append(trUtf8("All Files") + " (*)");
+QStringList filters(tr("%1 Task File").arg("TSPSG") + " (*.tspt)");
+	filters.append(tr("All Files") + " (*)");
 QString file;
 	if (fileName.endsWith(".tspt", Qt::CaseInsensitive))
@@ -725,5 +725,5 @@
 
 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog;
-	file = QFileDialog::getSaveFileName(this, trUtf8("Task Save"), file, filters.join(";;"), NULL, opts);
+	file = QFileDialog::getSaveFileName(this, tr("Task Save"), file, filters.join(";;"), NULL, opts);
 
 	if (file.isEmpty())
@@ -740,5 +740,5 @@
 {
 	this->fileName = fileName;
-	setWindowTitle(QString("%1[*] - %2").arg(QFileInfo(fileName).completeBaseName()).arg(trUtf8("Travelling Salesman Problem")));
+	setWindowTitle(QString("%1[*] - %2").arg(QFileInfo(fileName).completeBaseName()).arg(tr("Travelling Salesman Problem")));
 }
 
