Changeset 6dfdef0c3e in tspsg for src/mainwindow.cpp


Ignore:
Timestamp:
Aug 11, 2009, 6:54:01 PM (15 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
281303f1f7
Parents:
c10297cf73
Message:

+ PDF format option when saving solution if platform supports printing.

  • Check alternative candidates for subcycles.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mainwindow.cpp

    rc10297cf73 r6dfdef0c3e  
    280280static QString selectedFile;
    281281        if (selectedFile.isEmpty())
     282#ifndef QT_NO_PRINTER
     283                selectedFile = "solution.pdf";
     284#else
    282285                selectedFile = "solution.html";
     286#endif // QT_NO_PRINTER
    283287QFileDialog sd(this);
    284288        sd.setAcceptMode(QFileDialog::AcceptSave);
    285 QStringList filters(trUtf8("HTML Files") + " (*.html *.htm)");
     289QStringList filters;
     290#ifndef QT_NO_PRINTER
     291        filters.append(trUtf8("PDF Files") + "(*.pdf)");
     292#endif
     293        filters.append(trUtf8("HTML Files") + " (*.html *.htm)");
    286294#if QT_VERSION >= 0x040500
    287295        filters.append(trUtf8("OpenDocument Files") + " (*.odt)");
     
    297305        selectedFile = files.first();
    298306        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
     307#ifndef QT_NO_PRINTER
     308        if (selectedFile.endsWith(".pdf",Qt::CaseInsensitive)) {
     309QPrinter printer(QPrinter::HighResolution);
     310                printer.setOutputFormat(QPrinter::PdfFormat);
     311                printer.setOutputFileName(selectedFile);
     312                solutionText->document()->print(&printer);
     313                QApplication::restoreOverrideCursor();
     314                return;
     315        }
     316#endif
    299317#if QT_VERSION >= 0x040500
    300318QTextDocumentWriter dw(selectedFile);
     
    488506{
    489507        // TODO: Normal about window :-)
    490 QString about = QString::fromUtf8("TSPSG - TSP Solver and Generator\n");
     508QString about = QString::fromUtf8("TSPSG: TSP Solver and Generator\n");
    491509        about += QString::fromUtf8("    Version: "BUILD_VERSION"\n");
    492510        about += QString::fromUtf8("    Copyright (C) 2007-%1 Lёppa <contacts[at]oleksii[dot]name>\n").arg(QDate::currentDate().toString("yyyy"));
Note: See TracChangeset for help on using the changeset viewer.