Subversion Repositories svn1

Rev

Rev 212 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 212 Rev 380
Line 1... Line 1...
1
#include <QFileDialog>
1
#include <QFileDialog>
-
 
2
#include <QFileInfo>
2
#include "qmdownloadlegtimes.h"
3
#include "qmdownloadlegtimes.h"
3
#include "ui_qmdownloadlegtimes.h"
4
#include "ui_qmdownloadlegtimes.h"
4
#include "mainwindow.h"
5
#include "mainwindow.h"
5
 
6
 
6
#include    "consts.h"
7
#include    "consts.h"
Line 31... Line 32...
31
{
32
{
32
    ui->save->setEnabled(leg != 0);
33
    ui->save->setEnabled(leg != 0);
33
    updateFileName();
34
    updateFileName();
34
}
35
}
35
 
36
 
-
 
37
/*----------------------------------------------------------------------------
-
 
38
** FUNCTION           : save
-
 
39
**
-
 
40
** DESCRIPTION        : Save leg time information to an external file
-
 
41
**
-
 
42
**
-
 
43
** INPUTS             :
-
 
44
**
-
 
45
** RETURNS            :
-
 
46
**
-
 
47
----------------------------------------------------------------------------*/
-
 
48
 
36
void QmDownloadLegTimes::save(void)
49
void QmDownloadLegTimes::save(void)
37
{
50
{
38
    bool manstart = !ui->legEnd->isChecked();
51
    bool manstart = !ui->legEnd->isChecked();
39
    int leg = ui->legNumber->value();
52
    int leg = ui->legNumber->value();
40
 
53
 
41
        /*
54
    /*
42
         * Locate the required data file and prepare for processing
55
     * Locate the required data file and prepare for processing
43
         */
56
     */
44
    QString filename = ui->fileName->text();
57
    QString filename = ui->fileName->text();
45
    MainWindow::showMessage(QString("Using: ") + filename);
58
    MainWindow::showMessage(QString("Using: ") + filename);
-
 
59
 
-
 
60
    /*
-
 
61
    **  Join a directory and the suggested filename 
-
 
62
    **  The directory will be either
-
 
63
    **      The remembers directory
46
    filename.prepend(filepath);
64
    **      Appications 'filepath'
-
 
65
    */
-
 
66
    filename = QDir(appSettings->value("Recent/SaveLegTimesDir",filepath).toString()).filePath(filename);
47
    qDebug("Using:%s", qPrintable(filename));
67
    qDebug("Using:%s", qPrintable(filename));
48
 
68
 
-
 
69
    /*
-
 
70
    ** Let the user navigate to where we will store the file
-
 
71
    */
49
    filename = QFileDialog::getSaveFileName(this, tr("Store Leg Data to File"),
72
    filename = QFileDialog::getSaveFileName(
50
                                                     filename,
73
        this, tr("Store Leg Data to File"),
-
 
74
        filename,
51
                                                     tr("Data (*.txt);;All (*.*)"),
75
        tr("Data (*.txt);;All (*.*)"),
52
                                                     0
76
        0
53
                                                     );
77
        );
54
    if ( filename.isEmpty() )
78
    if ( filename.isEmpty() )
55
    {
79
    {
56
        return;
80
        return;
57
    }
81
    }
58
 
82
 
-
 
83
    /*
-
 
84
    ** Remember the directory part of the user specified file name 
-
 
85
    ** Will put future files in the directory too 
-
 
86
    */
-
 
87
    QFileInfo fileinfo(filename);
-
 
88
    appSettings->setValue("Recent/SaveLegTimesDir", fileinfo.absoluteDir().absolutePath());
59
 
89
 
-
 
90
    /*
-
 
91
    ** Open the file for output.
-
 
92
    */
60
    QFile file;
93
    QFile file;
61
    file.setFileName(filename);
94
    file.setFileName(filename);
62
    if ( ! file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text) )
95
    if ( ! file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text) )
63
    {
96
    {
64
        MainWindow::showMessage("Cannot open external leg file");
97
        MainWindow::showMessage("Cannot open external leg file");