summaryrefslogtreecommitdiff
path: root/libopie/ofiledialog.cc
Unidiff
Diffstat (limited to 'libopie/ofiledialog.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofiledialog.cc212
1 files changed, 0 insertions, 212 deletions
diff --git a/libopie/ofiledialog.cc b/libopie/ofiledialog.cc
deleted file mode 100644
index 47306b6..0000000
--- a/libopie/ofiledialog.cc
+++ b/dev/null
@@ -1,212 +0,0 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002,2003 <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#include <qpe/config.h>
30#include <qpe/qpeapplication.h>
31
32#include <qfileinfo.h>
33#include <qlayout.h>
34
35
36#include "ofiledialog.h"
37
38
39namespace {
40 /*
41 * helper functions to load the start dir
42 * and to save it
43 * helper to extract the dir out of a file name
44 */
45 /**
46 * This method will use Config( argv[0] );
47 * @param key The group key used
48 */
49 QString lastUsedDir( const QString& key ) {
50 if ( qApp->argc() < 1 )
51 return QString::null;
52
53 Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname
54 cfg.setGroup( key );
55 return cfg.readEntry("LastDir", QPEApplication::documentDir() );
56 }
57
58 void saveLastDir( const QString& key, const QString& file ) {
59 if ( qApp->argc() < 1 )
60 return;
61
62 Config cfg( QFileInfo(qApp->argv()[0]).fileName() );
63 cfg.setGroup( key );
64 QFileInfo inf( file );
65 cfg.writeEntry("LastDir", inf.dirPath( true ) );
66 }
67};
68
69/**
70 * This constructs a modal dialog
71 *
72 * @param caption The caption of the dialog
73 * @param wid The parent widget
74 * @param mode The mode of the OFileSelector @see OFileSelector
75 * @param selector The selector of the OFileSelector
76 * @param dirName the dir or resource to start from
77 * @param fileName a proposed or existing filename
78 * @param mimetypes The mimeTypes
79 */
80OFileDialog::OFileDialog(const QString &caption,
81 QWidget *wid, int mode, int selector,
82 const QString &dirName,
83 const QString &fileName,
84 const QMap<QString,QStringList>& mimetypes )
85 : QDialog( wid, "OFileDialog", true )
86{
87 // QVBoxLayout *lay = new QVBoxLayout(this);
88 //showMaximized();
89 QVBoxLayout *lay = new QVBoxLayout(this );
90 file = new OFileSelector(this , mode, selector,
91 dirName, fileName,
92 mimetypes );
93 lay->addWidget( file );
94
95 //lay->addWidget( file );
96 //showFullScreen();
97 setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
98 connect(file, SIGNAL(fileSelected(const QString&) ),
99 this, SLOT(slotFileSelected(const QString&) ) );
100 connect(file, SIGNAL(ok() ),
101 this, SLOT(slotSelectorOk()) ) ;
102
103 connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) );
104
105#if 0
106 connect(file, SIGNAL(dirSelected(const QString &) ),
107 this, SLOT(slotDirSelected(const QString &) ) );
108#endif
109}
110/**
111 * @returns the mimetype of the selected
112 * currently it return QString::null
113 */
114QString OFileDialog::mimetype()const
115{
116 return QString::null;
117}
118
119/**
120 * @return the fileName
121 */
122QString OFileDialog::fileName()const
123{
124 return file->selectedName();
125}
126
127/**
128 * return a DocLnk to the current file
129 */
130DocLnk OFileDialog::selectedDocument()const
131{
132 return file->selectedDocument();
133}
134
135/**
136 * This opens up a filedialog in Open mode
137 *
138 * @param selector the Selector Mode
139 * @param startDir Where to start from
140 * @param file A proposed filename
141 * @param mimes A list of MimeTypes
142 * @param wid the parent
143 * @param caption of the dialog if QString::null tr("Open") will be used
144 * @return the fileName or QString::null
145 */
146QString OFileDialog::getOpenFileName(int selector,
147 const QString &_startDir,
148 const QString &file,
149 const MimeTypes &mimes,
150 QWidget *wid,
151 const QString &caption )
152{
153 QString ret;
154 QString startDir = _startDir;
155 if (startDir.isEmpty() )
156 startDir = lastUsedDir( "FileDialog-OPEN" );
157
158
159 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption,
160 wid, OFileSelector::Open, selector, startDir, file, mimes);
161 dlg.showMaximized();
162 if( dlg.exec() ) {
163 ret = dlg.fileName();
164 saveLastDir( "FileDialog-OPEN", ret );
165 }
166
167 return ret;
168}
169
170/**
171 * This opens up a file dialog in save mode
172 * @see getOpenFileName
173 */
174QString OFileDialog::getSaveFileName(int selector,
175 const QString &_startDir,
176 const QString &file,
177 const MimeTypes &mimes,
178 QWidget *wid,
179 const QString &caption )
180{
181 QString ret;
182 QString startDir = _startDir;
183 if (startDir.isEmpty() )
184 startDir = lastUsedDir( "FileDialog-SAVE" );
185
186 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption,
187 wid, OFileSelector::Save, selector, startDir, file, mimes);
188 dlg.showMaximized();
189 if( dlg.exec() ) {
190 ret = dlg.fileName();
191 saveLastDir( "FileDialog-SAVE", ret );
192 }
193
194 return ret;
195}
196
197void OFileDialog::slotFileSelected(const QString & )
198{
199 accept();
200}
201
202void OFileDialog::slotSelectorOk( )
203{
204 accept();
205}
206
207void OFileDialog::slotDirSelected(const QString &dir )
208{
209 setCaption( dir );
210 // if mode
211 //accept();
212}