summaryrefslogtreecommitdiffabout
path: root/microkde/kfiledialog.cpp
blob: c64f325827ad1921aee2c12c21115ceccfcdc561 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <kfiledialog.h>
#include <qdialog.h>
#include <qlayout.h>
#include <qdir.h>
#include <qfileinfo.h>
#include <qapplication.h>

#ifndef DESKTOP_VERSION
//US orig#include <ofileselector.h>
#include <ofileselector_p.h>
QString KFileDialog::getSaveFileName( const QString & fn,
                                             const QString & cap , QWidget * par )
{
    QString retfile = "";
    QDialog dia ( par, "input-dialog", true ); 
    QVBoxLayout lay( &dia );
    lay.setMargin(7); 
    lay.setSpacing(7); 
    QString file = fn;
    if ( file.isEmpty() )
        file = QDir::homeDirPath()+"/*";
    QFileInfo fi ( file );
    OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Save, fi.dirPath(true), fi.fileName() );
    QObject::connect (  &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) );
    lay.addWidget( &o);
    // o.setNewVisible( true );
    // o.setNameVisible( true );
    dia.showMaximized();
    if ( cap.isEmpty() )
        dia.setCaption( file );
    else
        dia.setCaption( cap );
    int res = dia.exec();
    if ( res )
        retfile = o.selectedName();
    return retfile;
}

QString KFileDialog::getOpenFileName( const QString & fn,
                                             const QString & cap, QWidget * par )
{
   QString retfile = "";
    QDialog dia ( par, "input-dialog", true ); 
    // QLineEdit lab ( &dia ); 
    QVBoxLayout lay( &dia );
    lay.setMargin(7); 
    lay.setSpacing(7);
    QString file = fn;
    if ( file.isEmpty() )
        file = QDir::homeDirPath()+"/*";;
    QFileInfo fi ( file );
    OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Open, fi.dirPath(true), fi.fileName() );
    QObject::connect (  &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) );
    lay.addWidget( &o);
    dia.showMaximized();
    dia.setCaption( cap );
    int res = dia.exec();
    if ( res )
        retfile = o.selectedName();
    return retfile;
}
QString KFileDialog::getExistingDirectory( const QString & fn,
                                             const QString & cap, QWidget * par )
{
    return KFileDialog::getSaveFileName( fn, cap, pr );
}
#else

#include <qfiledialog.h> 

QString KFileDialog::getSaveFileName( const QString & fn,
                                             const QString & cap , QWidget * par )
{
    return QFileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap );
}
QString KFileDialog::getOpenFileName( const QString & fn,
                                             const QString & cap, QWidget * par )
{

    return QFileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap );
}
QString KFileDialog::getExistingDirectory( const QString & fn,
                                             const QString & cap, QWidget * par )
{
    return QFileDialog::getExistingDirectory( fn, par, "exidtingdir", cap );
}
#endif