Changeset f1fb54b9f7 in tspsg for src/mainwindow.cpp


Ignore:
Timestamp:
Jan 7, 2010, 2:24:18 AM (14 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
946f442ab0
Parents:
4ccf855df8
Message:

+ Added the ability to generate fractional random numbers.
+ Added "Scroll to the end of solution output after solving" option.

  • Set the accuracy for fractional numbers on output to 2 decimail places.
  • Updated translations to reflect changes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mainwindow.cpp

    r4ccf855df8 rf1fb54b9f7  
    450450                output.append("<p>" + trUtf8("Resulting path:") + "</p>");
    451451        output.append("<p>&nbsp;&nbsp;" + solver.getSortedPath() + "</p>");
    452         output.append("<p>" + trUtf8("The price is <b>%n</b> unit(s).", "", step->price) + "</p>");
     452        if (isInteger(step->price))
     453                output.append("<p>" + trUtf8("The price is <b>%n</b> unit(s).", "", step->price) + "</p>");
     454        else
     455                output.append("<p>" + trUtf8("The price is <b>%1</b> units.").arg(step->price, 0, 'f', 2) + "</p>");
    453456        if (!solver.isOptimal()) {
    454457                output.append("<p>&nbsp;</p>");
     
    460463        solutionText->setDocumentTitle(trUtf8("Solution of Variant #%1 task").arg(spinVariant->value()));
    461464
    462         // Scrolling to the end of text.
    463         solutionText->moveCursor(QTextCursor::End);
     465        if (settings->value("Output/ScrollToEnd", DEF_SCROLL_TO_END).toBool()) {
     466                // Scrolling to the end of text.
     467                solutionText->moveCursor(QTextCursor::End);
     468        }
    464469
    465470        toggleSolutionActions();
     
    655660                                line += "<td align=\"center\">"INFSTR"</td>";
    656661                        else
    657                                 line += "<td align=\"center\">" + QVariant(matrix.at(r).at(c)).toString() + "</td>";
     662                                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);
    658663                }
    659664                line += "</tr>";
     
    674679                                line += "<td align=\"center\">"INFSTR"</td>";
    675680                        else if ((r == step.candidate.nRow) && (c == step.candidate.nCol))
    676                                 line += "<td align=\"center\" class=\"selected\">" + QVariant(step.matrix.at(r).at(c)).toString() + "</td>";
     681                                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);
    677682                        else {
    678683SCandidate cand;
     
    680685                                cand.nCol = c;
    681686                                if (step.alts.contains(cand))
    682                                         line += "<td align=\"center\" class=\"alternate\">" + QVariant(step.matrix.at(r).at(c)).toString() + "</td>";
     687                                        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);
    683688                                else
    684                                         line += "<td align=\"center\">" + QVariant(step.matrix.at(r).at(c)).toString() + "</td>";
     689                                        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);
    685690                        }
    686691                }
Note: See TracChangeset for help on using the changeset viewer.