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


Ignore:
Timestamp:
Jun 30, 2009, 1:02:31 AM (15 years ago)
Author:
laleppa
Message:

+ Opening task file
+ Saving task file

  • Translations update to reflect recent changes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mainwindow.cpp

    r30 r31  
    2222 */
    2323
    24 #include <QtGui>
    25 #ifndef Q_OS_WINCE
    26         #include <QPrintDialog>
    27 #endif // Q_OS_WINCE
    2824#include "mainwindow.h"
    2925
     
    4440        actionSettingsLanguageAutodetect->setChecked(settings->value("Language","").toString().isEmpty());
    4541        connect(actionFileNew,SIGNAL(triggered()),this,SLOT(actionFileNewTriggered()));
     42        connect(actionFileOpen,SIGNAL(triggered()),this,SLOT(actionFileOpenTriggered()));
     43        connect(actionFileSaveTask,SIGNAL(triggered()),this,SLOT(actionFileSaveTaskTriggered()));
    4644        connect(actionSettingsPreferences,SIGNAL(triggered()),this,SLOT(actionSettingsPreferencesTriggered()));
    4745        connect(actionSettingsLanguageAutodetect,SIGNAL(triggered(bool)),this,SLOT(actionSettingsLanguageAutodetectTriggered(bool)));
     
    7977        tspmodel->setNumCities(spinCities->value());
    8078        taskView->setModel(tspmodel);
     79        connect(tspmodel,SIGNAL(numCitiesChanged(int)),this,SLOT(numCitiesChanged(int)));
    8180#ifdef Q_OS_WINCE
    8281        taskView->resizeColumnsToContents();
     
    153152}
    154153
     154void MainWindow::actionFileOpenTriggered()
     155{
     156QFileDialog od(this);
     157        od.setAcceptMode(QFileDialog::AcceptOpen);
     158        od.setFileMode(QFileDialog::ExistingFile);
     159QStringList filters(trUtf8("All Supported Formats") + " (*.tspt *.zkt)");
     160        filters.append(QString(trUtf8("%1 Task Files")).arg("TSPSG") + " (*.tspt)");
     161        filters.append(QString(trUtf8("%1 Task Files")).arg("ZKomModRd") + " (*.zkt)");
     162        filters.append(trUtf8("All Files") + " (*)");
     163        od.setNameFilters(filters);
     164        if (od.exec() != QDialog::Accepted)
     165                return;
     166QStringList files = od.selectedFiles();
     167        if (files.size() < 1)
     168                return;
     169        tspmodel->loadTask(files.first());
     170}
     171
     172void MainWindow::actionFileSaveTaskTriggered()
     173{
     174QFileDialog sd(this);
     175        sd.setAcceptMode(QFileDialog::AcceptSave);
     176QStringList filters(QString(trUtf8("%1 Task File")).arg("TSPSG") + " (*.tspt)");
     177        filters.append(trUtf8("All Files") + " (*)");
     178        sd.setNameFilters(filters);
     179        sd.setDefaultSuffix("tspt");
     180        if (sd.exec() != QDialog::Accepted)
     181                return;
     182QStringList files = sd.selectedFiles();
     183        if (files.size() < 1)
     184                return;
     185        tspmodel->saveTask(files.first());
     186}
     187
    155188void MainWindow::actionSettingsPreferencesTriggered()
    156189{
     
    209242about += QString::fromUtf8("    Copyright (C) 2007-%1 Lёppa <contacts[at]oleksii[dot]name>\n").arg(QDate::currentDate().toString("yyyy"));
    210243        about += "Qt library versions:\n";
     244        about += QString::fromUtf8("    OS: %1\n").arg(OS);
    211245        about += QString::fromUtf8("    Compile time: %1\n").arg(QT_VERSION_STR);
    212246        about += QString::fromUtf8("    Runtime: %1\n").arg(qVersion());
     
    281315        QMainWindow::closeEvent(event);
    282316}
     317
     318void MainWindow::numCitiesChanged(int nCities)
     319{
     320        spinCities->setValue(nCities);
     321}
Note: See TracChangeset for help on using the changeset viewer.