Changeset 56dca709c9 in tspsg


Ignore:
Timestamp:
Aug 4, 2009, 6:18:14 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:
6332a24386
Parents:
f44855d99e
Message:

Implemented printing of solution results (not supported under wince).

Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • resources/tspsg.qrc

    rf44855d99e r56dca709c9  
    11<RCC>
    22    <qresource prefix="/images" >
    3         <file>about.bmp</file>
    4         <file>icon.png</file>
     3        <file>Icon.png</file>
    54        <file>icons/back.png</file>
    65        <file>icons/button_cancel.png</file>
     
    98        <file>icons/contents.png</file>
    109        <file>icons/contexthelp.png</file>
     10        <file>icons/document_preview.png</file>
    1111        <file>icons/exit.png</file>
    1212        <file>icons/filenew.png</file>
  • src/mainwindow.cpp

    rf44855d99e r56dca709c9  
    4040#endif
    4141#ifndef Q_OS_WINCE
    42         printer = new QPrinter();
     42        printer = new QPrinter(QPrinter::HighResolution);
    4343#endif // Q_OS_WINCE
    4444        groupSettingsLanguageList = new QActionGroup(this);
     
    5959        connect(actionHelpAbout,SIGNAL(triggered()),this,SLOT(actionHelpAboutTriggered()));
    6060#ifndef Q_OS_WINCE
    61         connect(actionFilePrintSetup,SIGNAL(triggered()),this,SLOT(actionFilePrintSetupTriggered()));
     61        connect(actionFilePrintPreview,SIGNAL(triggered()),this,SLOT(actionFilePrintPreviewTriggered()));
     62        connect(actionFilePrint,SIGNAL(triggered()),this,SLOT(actionFilePrintTriggered()));
    6263#endif // Q_OS_WINCE
    6364        connect(buttonSolve,SIGNAL(clicked()),this,SLOT(buttonSolveClicked()));
     
    8485        qsrand(QDateTime().currentDateTime().toTime_t());
    8586        tspmodel = new CTSPModel();
     87        taskView->setModel(tspmodel);
    8688        connect(tspmodel,SIGNAL(numCitiesChanged(int)),this,SLOT(numCitiesChanged(int)));
    8789        connect(tspmodel,SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),this,SLOT(dataChanged()));
     
    9294                setFileName();
    9395                spinCities->setValue(settings->value("NumCities",DEF_NUM_CITIES).toInt());
    94                 tspmodel->setNumCities(spinCities->value());
    95         }
    96         taskView->setModel(tspmodel);
     96                spinCitiesValueChanged(spinCities->value());
     97        }
    9798        setWindowModified(false);
    98         taskView->resizeColumnsToContents();
    99         taskView->resizeRowsToContents();
    10099}
    101100
     
    107106        if (!enable)
    108107                output.clear();
     108#ifndef Q_OS_WINCE
     109        actionFilePrint->setEnabled(enable);
     110        actionFilePrintPreview->setEnabled(enable);
     111#endif // Q_OS_WINCE
    109112}
    110113
     
    117120                lang = settings->value("Language",QLocale::system().name()).toString();
    118121        }
    119 static QTranslator *qtTranslator;
     122static QTranslator *qtTranslator; // Qt library translator
    120123        if (qtTranslator) {
    121124                qApp->removeTranslator(qtTranslator);
     
    124127        }
    125128        qtTranslator = new QTranslator();
    126 static QTranslator *translator;
     129static QTranslator *translator; // Application translator
    127130        if (translator) {
    128131                qApp->removeTranslator(translator);
     
    139142                                qApp->installTranslator(qtTranslator);
    140143                        else {
     144                                // Qt library translation unavailable
    141145                                delete qtTranslator;
    142146                                qtTranslator = NULL;
     
    147151                else {
    148152                        if (!ad)
    149                                 QMessageBox(QMessageBox::Warning,trUtf8("Language change"),trUtf8("Unable to load translation language."),QMessageBox::Ok,this).exec();
     153                                QMessageBox(QMessageBox::Warning,trUtf8("Language Change"),trUtf8("Unable to load translation language."),QMessageBox::Ok,this).exec();
    150154                        delete translator;
    151155                        translator = NULL;
     
    346350
    347351#ifndef Q_OS_WINCE
    348 void MainWindow::actionFilePrintSetupTriggered()
     352void MainWindow::printPreview(QPrinter *printer)
     353{
     354        solutionText->print(printer);
     355}
     356
     357void MainWindow::actionFilePrintPreviewTriggered()
     358{
     359QPrintPreviewDialog ppd(printer, this);
     360    connect(&ppd,SIGNAL(paintRequested(QPrinter *)),SLOT(printPreview(QPrinter *)));
     361    ppd.exec();
     362}
     363
     364void MainWindow::actionFilePrintTriggered()
    349365{
    350366QPrintDialog pd(printer,this);
     
    354370        pd.setOption(QAbstractPrintDialog::PrintPageRange,false);
    355371#endif
    356         pd.exec();
     372        if (pd.exec() != QDialog::Accepted)
     373                return;
     374        solutionText->document()->print(printer);
    357375}
    358376#endif // Q_OS_WINCE
  • src/mainwindow.h

    rf44855d99e r56dca709c9  
    5555        void dataChanged();
    5656#ifndef Q_OS_WINCE
    57         void actionFilePrintSetupTriggered();
     57        void printPreview(QPrinter *);
     58        void actionFilePrintPreviewTriggered();
     59        void actionFilePrintTriggered();
    5860#endif // Q_OS_WINCE
    5961        void buttonSolveClicked();
  • ui/mainwindow.ce.ui

    rf44855d99e r56dca709c9  
    1818  </property>
    1919  <property name="windowIcon">
    20    <iconset resource="../resources/tspsg.qrc">
     20   <iconset>
    2121    <normaloff>:/images/icon.png</normaloff>:/images/icon.png</iconset>
    2222  </property>
  • ui/mainwindow.ui

    rf44855d99e r56dca709c9  
    1515  </property>
    1616  <property name="windowIcon">
    17    <iconset resource="../resources/tspsg.qrc">
     17   <iconset>
    1818    <normaloff>:/images/icon.png</normaloff>:/images/icon.png</iconset>
    1919  </property>
     
    297297    <addaction name="menuFileSaveAs"/>
    298298    <addaction name="separator"/>
    299     <addaction name="actionFilePrintSetup"/>
     299    <addaction name="actionFilePrintPreview"/>
    300300    <addaction name="actionFilePrint"/>
    301301    <addaction name="separator"/>
     
    362362   <addaction name="actionFileExit"/>
    363363  </widget>
    364   <action name="actionFilePrintSetup">
     364  <action name="actionFilePrintPreview">
    365365   <property name="enabled">
    366366    <bool>false</bool>
     
    368368   <property name="icon">
    369369    <iconset resource="../resources/tspsg.qrc">
    370      <normaloff>:/images/icons/fileprint.png</normaloff>:/images/icons/fileprint.png</iconset>
    371    </property>
    372    <property name="text">
    373     <string>P&amp;rint Setup...</string>
    374    </property>
    375    <property name="statusTip">
    376     <string>Setup printing</string>
     370     <normaloff>:/images/icons/document_preview.png</normaloff>:/images/icons/document_preview.png</iconset>
     371   </property>
     372   <property name="text">
     373    <string>P&amp;rint Preview...</string>
     374   </property>
     375   <property name="iconText">
     376    <string>Print Preview...</string>
     377   </property>
     378   <property name="toolTip">
     379    <string>Preview solution results</string>
     380   </property>
     381   <property name="statusTip">
     382    <string>Preview current solution results before printing</string>
    377383   </property>
    378384  </action>
     
    388394    <string>&amp;Print...</string>
    389395   </property>
    390    <property name="statusTip">
    391     <string>Print solution results</string>
     396   <property name="iconText">
     397    <string>Print...</string>
     398   </property>
     399   <property name="toolTip">
     400    <string>Print solution</string>
     401   </property>
     402   <property name="statusTip">
     403    <string>Print current solution results</string>
    392404   </property>
    393405   <property name="shortcut">
Note: See TracChangeset for help on using the changeset viewer.