Changeset 54 in tspsg-svn for trunk/src/mainwindow.cpp


Ignore:
Timestamp:
Aug 9, 2009, 1:45:19 AM (15 years ago)
Author:
laleppa
Message:
  • mainwindow.ui and mainwindow.ce.ui had differences only in printing actions and statusbar, so I merged them into one. Differences are now applied in source code. This will simplify Main Window maintenance.
  • Changed #ifndef Q_OS_WINCE to #ifndef QT_NO_PRINTER where relevant.
  • Now using method at() instead of operator [] in solving algorithm. This change dramatically decreased solution time (from 13 seconds to 10-40 milliseconds for 20 cities on my PC).
  • Increased maximum number of cities to 30. Setting more makes no sense at this moment, because generated solution output is big and inserting it to QTextEdit takes veeeeery long time.
  • Translations were updated.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mainwindow.cpp

    r52 r54  
    3030        loadLanguage();
    3131        setupUi(this);
     32#ifndef Q_OS_WINCE
     33QStatusBar *statusbar = new QStatusBar(this);
     34        statusbar->setObjectName("statusbar");
     35        setStatusBar(statusbar);
     36#endif // Q_OS_WINCE
    3237        initDocStyleSheet();
    3338        solutionText->document()->setDefaultFont(settings->value("Output/Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>());
     
    3944        toolBar->setIconSize(QSize(s / 10,s / 10));
    4045#endif
    41 #ifndef Q_OS_WINCE
     46#ifndef QT_NO_PRINTER
    4247        printer = new QPrinter(QPrinter::HighResolution);
    43 #endif // Q_OS_WINCE
     48#endif // QT_NO_PRINTER
    4449        groupSettingsLanguageList = new QActionGroup(this);
    4550        actionSettingsLanguageEnglish->setData("en");
     
    5863        connect(actionHelpAboutQt,SIGNAL(triggered()),qApp,SLOT(aboutQt()));
    5964        connect(actionHelpAbout,SIGNAL(triggered()),this,SLOT(actionHelpAboutTriggered()));
    60 #ifndef Q_OS_WINCE
     65#ifndef QT_NO_PRINTER
     66        menuFile->insertAction(actionFileExit,actionFilePrintPreview);
     67        menuFile->insertAction(actionFileExit,actionFilePrint);
     68        menuFile->insertSeparator(actionFileExit);
     69        toolBar->insertAction(actionSettingsPreferences,actionFilePrint);
    6170        connect(actionFilePrintPreview,SIGNAL(triggered()),this,SLOT(actionFilePrintPreviewTriggered()));
    6271        connect(actionFilePrint,SIGNAL(triggered()),this,SLOT(actionFilePrintTriggered()));
    63 #endif // Q_OS_WINCE
     72#endif // QT_NO_PRINTER
    6473        connect(buttonSolve,SIGNAL(clicked()),this,SLOT(buttonSolveClicked()));
    6574        connect(buttonRandom,SIGNAL(clicked()),this,SLOT(buttonRandomClicked()));
     
    106115        if (!enable)
    107116                output.clear();
    108 #ifndef Q_OS_WINCE
     117#ifndef QT_NO_PRINTER
    109118        actionFilePrint->setEnabled(enable);
    110119        actionFilePrintPreview->setEnabled(enable);
    111 #endif // Q_OS_WINCE
     120#endif // QT_NO_PRINTER
    112121}
    113122
     
    206215        if (!maybeSave())
    207216                return;
     217        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    208218        tspmodel->clear();
    209219        taskView->resizeColumnsToContents();
     
    214224        solutionText->clear();
    215225        enableSolutionActions(false);
     226        QApplication::restoreOverrideCursor();
    216227}
    217228
     
    349360}
    350361
    351 #ifndef Q_OS_WINCE
     362#ifndef QT_NO_PRINTER
    352363void MainWindow::printPreview(QPrinter *printer)
    353364{
     
    372383        if (pd.exec() != QDialog::Accepted)
    373384                return;
     385        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    374386        solutionText->document()->print(printer);
    375 }
    376 #endif // Q_OS_WINCE
     387        QApplication::restoreOverrideCursor();
     388}
     389#endif // QT_NO_PRINTER
    377390
    378391void MainWindow::buttonRandomClicked()
    379392{
     393        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    380394        tspmodel->randomize();
    381395        setWindowModified(true);
    382396        taskView->resizeColumnsToContents();
    383397        taskView->resizeRowsToContents();
     398        QApplication::restoreOverrideCursor();
    384399}
    385400
Note: See TracChangeset for help on using the changeset viewer.