summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/ofiledialog.cc110
-rw-r--r--libopie/ofiledialog.h77
-rw-r--r--libopie/ofileselector.cc2
-rw-r--r--libopie/ofileselector.h7
4 files changed, 192 insertions, 4 deletions
diff --git a/libopie/ofiledialog.cc b/libopie/ofiledialog.cc
new file mode 100644
index 0000000..92b0d0a
--- a/dev/null
+++ b/libopie/ofiledialog.cc
@@ -0,0 +1,110 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include <qpe/applnk.h>
30#include <qstring.h>
31#include <qapplication.h>
32#include <qlayout.h>
33
34#include "ofiledialog.h"
35
36OFileDialog::OFileDialog(const QString &caption,
37 QWidget *wid, int mode, int selector,
38 const QString &dirName,
39 const QString &fileName,
40 const QStringList &mimetypes )
41 : QDialog( wid, "OFileDialog", true )
42{
43 QVBoxLayout *lay = new QVBoxLayout(this);
44
45 file = new OFileSelector(0 , mode, selector,
46 dirName, fileName,
47 mimetypes );
48 lay->addWidget( file );
49 //showFullScreen();
50 setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
51 connect(file, SIGNAL(fileSelected(const QString&) ),
52 this, SLOT(slotFileSelected(const QString&) ) );
53
54 connect(file, SIGNAL(dirSelected(const QString &) ),
55 this, SLOT(slotDirSelected(const QString &) ) );
56 showMaximized();
57 file->setYesCancelVisible( false ); // relayout
58}
59QString OFileDialog::mimetype()const
60{
61 return QString::null;
62}
63QString OFileDialog::fileName()const
64{
65 return file->selectedName();
66}
67DocLnk OFileDialog::selectedDocument()const
68{
69 return file->selectedDocument();
70}
71QString OFileDialog::getOpenFileName(int selector,
72 const QString &startDir,
73 const QString &file,
74 const QStringList &mimes,
75 QWidget *wid,
76 const QString &caption )
77{
78 QString ret;
79 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption,
80 wid, OFileSelector::OPEN, selector, startDir, file, mimes);
81 if( dlg.exec() )
82 ret = dlg.fileName();
83
84 return ret;
85}
86QString OFileDialog::getSaveFileName(int selector,
87 const QString &startDir,
88 const QString &file,
89 const QStringList &mimes,
90 QWidget *wid,
91 const QString &caption )
92{
93 QString ret;
94 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption,
95 wid, OFileSelector::SAVE, selector, startDir, file, mimes);
96 if( dlg.exec() )
97 ret = dlg.fileName();
98
99 return ret;
100}
101
102void OFileDialog::slotFileSelected(const QString & )
103{
104 accept();
105}
106void OFileDialog::slotDirSelected(const QString & )
107{
108 // if mode
109 //accept();
110}
diff --git a/libopie/ofiledialog.h b/libopie/ofiledialog.h
new file mode 100644
index 0000000..40d147e
--- a/dev/null
+++ b/libopie/ofiledialog.h
@@ -0,0 +1,77 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 zecke <zecke@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29
30#ifndef OpieFileDialog_h
31#define OpieFileDialog_h
32
33#include <qdialog.h>
34
35#include <opie/ofileselector.h>
36
37class OFileDialog : public QDialog {
38 Q_OBJECT
39 public:
40 OFileDialog(const QString &caption,
41 QWidget *, int mode, int selector,
42 const QString &dirName,
43 const QString &fileName = QString::null,
44 const QStringList &mimetypes = QStringList() );
45 QString mimetype() const;
46 QString fileName() const;
47 DocLnk selectedDocument()const;
48
49 // static methods
50 static QString getOpenFileName(int selector,
51 const QString& startDir = QString::null,
52 const QString &fileName = QString::null,
53 const QStringList& mimefilter = QStringList(),
54 QWidget *wid = 0,
55 const QString &caption = QString::null );
56
57 static QString getSaveFileName(int selector,
58 const QString& startDir = QString::null,
59 const QString& fileName = QString::null,
60 const QStringList& mimefilter = QStringList(),
61 QWidget *wid = 0,
62 const QString &caption = QString::null );
63
64 //let's OFileSelector catch up first
65 //static QString getExistingDirectory(const QString& startDir = QString::null,
66 // QWidget *parent = 0,
67 // const QString& caption = QString::null );
68 private:
69 class OFileDialogPrivate;
70 OFileDialogPrivate *d;
71 OFileSelector *file;
72
73 private slots:
74 void slotFileSelected( const QString & );
75 void slotDirSelected(const QString & );
76};
77#endif
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index fbe69ed..bc7c6c2 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -77,7 +77,7 @@ namespace {
77 77
78 78
79OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, 79OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName,
80 const QString &fileName, const QStringList mimetypes ) : QWidget( wid ) 80 const QString &fileName, const QStringList &mimetypes ) : QWidget( wid )
81{ 81{
82 m_selector = selector; 82 m_selector = selector;
83 m_currentDir = dirName; 83 m_currentDir = dirName;
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index bf3cb48..5e98a1e 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -116,11 +116,11 @@ class OFileSelectorItem : public QListViewItem {
116class OFileSelector : public QWidget { 116class OFileSelector : public QWidget {
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 enum Mode {OPEN=1, SAVE, FILESELECTOR }; 119 enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 };
120 enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; 120 enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 };
121 enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; 121 enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 };
122 OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList mimetypes = QStringList() ); 122 OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList &mimetypes = QStringList() );
123 123 ~OFileSelector() {};
124 bool isToolbarVisible() const { return m_shTool; }; 124 bool isToolbarVisible() const { return m_shTool; };
125 bool isPermissionBarVisible() const { return m_shPerm; }; 125 bool isPermissionBarVisible() const { return m_shPerm; };
126 bool isLineEditVisible()const { return m_shLne; }; 126 bool isLineEditVisible()const { return m_shLne; };
@@ -180,6 +180,7 @@ class OFileSelector : public QWidget {
180 signals: 180 signals:
181 void fileSelected( const DocLnk & ); 181 void fileSelected( const DocLnk & );
182 void fileSelected( const QString & ); 182 void fileSelected( const QString & );
183 void dirSelected(const QString &dir );
183 void closeMe(); 184 void closeMe();
184 void ok(); 185 void ok();
185 void cancel(); 186 void cancel();