summaryrefslogtreecommitdiff
authorzecke <zecke>2005-02-06 11:41:25 (UTC)
committer zecke <zecke>2005-02-06 11:41:25 (UTC)
commit69d318d86a08c362e5ce66f12106689c58126be9 (patch) (unidiff)
tree044c59aaf9797625b2ad0164f22d9cf351af4543
parente29e3328f35e9d74e48d26b99f0e6e8d6dcdd33a (diff)
downloadopie-69d318d86a08c362e5ce66f12106689c58126be9.zip
opie-69d318d86a08c362e5ce66f12106689c58126be9.tar.gz
opie-69d318d86a08c362e5ce66f12106689c58126be9.tar.bz2
Use the right parameters for the syntax.
Disconnect all slots in OFileDialog from the OFileSelector
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofiledialog.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/libopie2/opieui/fileselector/ofiledialog.cpp b/libopie2/opieui/fileselector/ofiledialog.cpp
index f2a0c7b..2d38961 100644
--- a/libopie2/opieui/fileselector/ofiledialog.cpp
+++ b/libopie2/opieui/fileselector/ofiledialog.cpp
@@ -1,254 +1,253 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (C) Holger Freyther <freyther@handhelds.org> 3             .=l. Copyright (C) Holger Freyther <freyther@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29 29
30/* OPIE */ 30/* OPIE */
31#include <opie2/ofiledialog.h> 31#include <opie2/ofiledialog.h>
32#include <qpe/applnk.h> 32#include <qpe/applnk.h>
33#include <qpe/config.h> 33#include <qpe/config.h>
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35 35
36/* QT */ 36/* QT */
37#include <qfileinfo.h> 37#include <qfileinfo.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <qapplication.h> 39#include <qapplication.h>
40#include <qlayout.h> 40#include <qlayout.h>
41 41
42 42
43/* TRANSLATOR Opie::Ui::OFileDialog */ 43/* TRANSLATOR Opie::Ui::OFileDialog */
44 44
45using namespace Opie::Ui; 45using namespace Opie::Ui;
46 46
47namespace 47namespace
48{ 48{
49/* 49/*
50 * helper functions to load the start dir 50 * helper functions to load the start dir
51 * and to save it 51 * and to save it
52 * helper to extract the dir out of a file name 52 * helper to extract the dir out of a file name
53 */ 53 */
54/** 54/**
55 * This method will use Config( argv[0] ); 55 * This method will use Config( argv[0] );
56 * @param key The group key used 56 * @param key The group key used
57 */ 57 */
58QString lastUsedDir( const QString& key ) 58QString lastUsedDir( const QString& key )
59{ 59{
60 if ( qApp->argc() < 1 ) 60 if ( qApp->argc() < 1 )
61 return QString::null; 61 return QString::null;
62 62
63 Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname 63 Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); // appname
64 cfg.setGroup( key ); 64 cfg.setGroup( key );
65 return cfg.readEntry("LastDir", QPEApplication::documentDir() ); 65 return cfg.readEntry("LastDir", QPEApplication::documentDir() );
66} 66}
67 67
68void saveLastDir( const QString& key, const QString& file ) 68void saveLastDir( const QString& key, const QString& file )
69{ 69{
70 if ( qApp->argc() < 1 ) 70 if ( qApp->argc() < 1 )
71 return; 71 return;
72 72
73 Config cfg( QFileInfo(qApp->argv()[0]).fileName() ); 73 Config cfg( QFileInfo(qApp->argv()[0]).fileName() );
74 cfg.setGroup( key ); 74 cfg.setGroup( key );
75 QFileInfo inf( file ); 75 QFileInfo inf( file );
76 if ( inf.isFile() ) 76 if ( inf.isFile() )
77 cfg.writeEntry("LastDir", inf.dirPath( true ) ); 77 cfg.writeEntry("LastDir", inf.dirPath( true ) );
78 else 78 else
79 cfg.writeEntry("LastDir", file ); 79 cfg.writeEntry("LastDir", file );
80} 80}
81}; 81};
82 82
83/** 83/**
84 * This constructs a modal dialog 84 * This constructs a modal dialog
85 * 85 *
86 * @param caption The caption of the dialog 86 * @param caption The caption of the dialog
87 * @param wid The parent widget 87 * @param wid The parent widget
88 * @param mode The mode of the OFileSelector @see OFileSelector 88 * @param mode The mode of the OFileSelector @see OFileSelector
89 * @param selector The selector of the OFileSelector 89 * @param selector The selector of the OFileSelector
90 * @param dirName the dir or resource to start from 90 * @param dirName the dir or resource to start from
91 * @param fileName a proposed or existing filename 91 * @param fileName a proposed or existing filename
92 * @param mimetypes The mimeTypes 92 * @param mimetypes The mimeTypes
93 */ 93 */
94OFileDialog::OFileDialog(const QString &caption, 94OFileDialog::OFileDialog(const QString &caption,
95 QWidget *wid, int mode, int selector, 95 QWidget *wid, int mode, int selector,
96 const QString &dirName, 96 const QString &dirName,
97 const QString &fileName, 97 const QString &fileName,
98 const QMap<QString,QStringList>& mimetypes ) 98 const QMap<QString,QStringList>& mimetypes )
99 : QDialog( wid, "OFileDialog", true ) 99 : QDialog( wid, "OFileDialog", true )
100{ 100{
101 QVBoxLayout *lay = new QVBoxLayout(this ); 101 QVBoxLayout *lay = new QVBoxLayout(this );
102 file = new OFileSelector(this , mode, selector, 102 file = new OFileSelector(this , mode, selector,
103 dirName, fileName, 103 dirName, fileName,
104 mimetypes ); 104 mimetypes );
105 lay->addWidget( file ); 105 lay->addWidget( file );
106 106
107 setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); 107 setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
108 connect(file, SIGNAL(fileSelected(const QString&) ), 108 connect(file, SIGNAL(fileSelected(const QString&) ),
109 this, SLOT(slotFileSelected(const QString&) ) ); 109 this, SLOT(slotFileSelected(const QString&) ) );
110 connect(file, SIGNAL(ok() ), 110 connect(file, SIGNAL(ok() ),
111 this, SLOT(slotSelectorOk()) ) ; 111 this, SLOT(slotSelectorOk()) ) ;
112 112
113 connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) ); 113 connect(file, SIGNAL(dirSelected(const QString&) ), this, SLOT(slotDirSelected(const QString&) ) );
114} 114}
115/** 115/**
116 * @returns the mimetype of the selected 116 * @returns the mimetype of the selected
117 * currently it return QString::null 117 * currently it return QString::null
118 */ 118 */
119QString OFileDialog::mimetype()const 119QString OFileDialog::mimetype()const
120{ 120{
121 return QString::null; 121 return QString::null;
122} 122}
123 123
124/** 124/**
125 * @return the fileName 125 * @return the fileName
126 */ 126 */
127QString OFileDialog::fileName()const 127QString OFileDialog::fileName()const
128{ 128{
129 return file->selectedName(); 129 return file->selectedName();
130} 130}
131 131
132/** 132/**
133 * return a DocLnk to the current file 133 * return a DocLnk to the current file
134 */ 134 */
135DocLnk OFileDialog::selectedDocument()const 135DocLnk OFileDialog::selectedDocument()const
136{ 136{
137 return file->selectedDocument(); 137 return file->selectedDocument();
138} 138}
139 139
140/** 140/**
141 * This opens up a filedialog in Open mode 141 * This opens up a filedialog in Open mode
142 * 142 *
143 * @param selector the Selector Mode 143 * @param selector the Selector Mode
144 * @param startDir Where to start from 144 * @param startDir Where to start from
145 * @param file A proposed filename 145 * @param file A proposed filename
146 * @param mimes A list of MimeTypes 146 * @param mimes A list of MimeTypes
147 * @param wid the parent 147 * @param wid the parent
148 * @param caption of the dialog if QString::null tr("Open") will be used 148 * @param caption of the dialog if QString::null tr("Open") will be used
149 * @return the fileName or QString::null 149 * @return the fileName or QString::null
150 */ 150 */
151QString OFileDialog::getOpenFileName(int selector, 151QString OFileDialog::getOpenFileName(int selector,
152 const QString &_startDir, 152 const QString &_startDir,
153 const QString &file, 153 const QString &file,
154 const MimeTypes &mimes, 154 const MimeTypes &mimes,
155 QWidget *wid, 155 QWidget *wid,
156 const QString &caption ) 156 const QString &caption )
157{ 157{
158 QString ret; 158 QString ret;
159 QString startDir = _startDir; 159 QString startDir = _startDir;
160 if (startDir.isEmpty() ) 160 if (startDir.isEmpty() )
161 startDir = lastUsedDir( "FileDialog-OPEN" ); 161 startDir = lastUsedDir( "FileDialog-OPEN" );
162 162
163 163
164 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, 164 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption,
165 wid, OFileSelector::Open, selector, startDir, file, mimes); 165 wid, OFileSelector::Open, selector, startDir, file, mimes);
166 if( QPEApplication::execDialog(&dlg ) ) 166 if( QPEApplication::execDialog(&dlg ) )
167 { 167 {
168 ret = dlg.fileName(); 168 ret = dlg.fileName();
169 saveLastDir( "FileDialog-OPEN", ret ); 169 saveLastDir( "FileDialog-OPEN", ret );
170 } 170 }
171 171
172 return ret; 172 return ret;
173} 173}
174 174
175/** 175/**
176 * This opens up a file dialog in save mode 176 * This opens up a file dialog in save mode
177 * @see getOpenFileName 177 * @see getOpenFileName
178 */ 178 */
179QString OFileDialog::getSaveFileName(int selector, 179QString OFileDialog::getSaveFileName(int selector,
180 const QString &_startDir, 180 const QString &_startDir,
181 const QString &file, 181 const QString &file,
182 const MimeTypes &mimes, 182 const MimeTypes &mimes,
183 QWidget *wid, 183 QWidget *wid,
184 const QString &caption ) 184 const QString &caption )
185{ 185{
186 QString ret; 186 QString ret;
187 QString startDir = _startDir; 187 QString startDir = _startDir;
188 if (startDir.isEmpty() ) 188 if (startDir.isEmpty() )
189 startDir = lastUsedDir( "FileDialog-SAVE" ); 189 startDir = lastUsedDir( "FileDialog-SAVE" );
190 190
191 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, 191 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption,
192 wid, OFileSelector::Save, selector, startDir, file, mimes); 192 wid, OFileSelector::Save, selector, startDir, file, mimes);
193 193
194 /* 194 /*
195 * For the save mode we do not want a file to be written 195 * For the save mode we do not want a file to be written
196 * if the user just clicked on it 196 * if the user just clicked on it
197 * #1522 197 * #1522
198 */ 198 */
199 dlg.disconnect( dlg.file, SIGNAL(fileSelected(const QString&)) ); 199 dlg.file->disconnect( &dlg );
200 dlg.disconnect( dlg.file, SIGNAL(ok()) );
201 200
202 if( QPEApplication::execDialog(&dlg) ) 201 if( QPEApplication::execDialog(&dlg) )
203 { 202 {
204 ret = dlg.fileName(); 203 ret = dlg.fileName();
205 saveLastDir( "FileDialog-SAVE", ret ); 204 saveLastDir( "FileDialog-SAVE", ret );
206 } 205 }
207 206
208 return ret; 207 return ret;
209} 208}
210 209
211/** 210/**
212 * This opens up a filedialog in select directory mode 211 * This opens up a filedialog in select directory mode
213 * 212 *
214 * @param selector the Selector Mode 213 * @param selector the Selector Mode
215 * @param startDir Where to start from 214 * @param startDir Where to start from
216 * @param wid the parent 215 * @param wid the parent
217 * @param caption of the dialog if QString::null tr("Open") will be used 216 * @param caption of the dialog if QString::null tr("Open") will be used
218 * @return the directoryName or QString::null 217 * @return the directoryName or QString::null
219 */ 218 */
220QString OFileDialog::getDirectory(int selector, 219QString OFileDialog::getDirectory(int selector,
221 const QString &_startDir, 220 const QString &_startDir,
222 QWidget *wid, 221 QWidget *wid,
223 const QString &caption ) 222 const QString &caption )
224{ 223{
225 QString ret; 224 QString ret;
226 QString startDir = _startDir; 225 QString startDir = _startDir;
227 if ( startDir.isEmpty() ) 226 if ( startDir.isEmpty() )
228 startDir = lastUsedDir( "FileDialog-SELECTDIR" ); 227 startDir = lastUsedDir( "FileDialog-SELECTDIR" );
229 228
230 OFileDialog dlg( caption.isEmpty() ? tr( "Select Directory" ) : caption, 229 OFileDialog dlg( caption.isEmpty() ? tr( "Select Directory" ) : caption,
231 wid, OFileSelector::DirectorySelector, selector, startDir ); 230 wid, OFileSelector::DirectorySelector, selector, startDir );
232 231
233 if ( QPEApplication::execDialog(&dlg) ) 232 if ( QPEApplication::execDialog(&dlg) )
234 { 233 {
235 ret = dlg.fileName(); 234 ret = dlg.fileName();
236 saveLastDir( "FileDialog-SELECTDIR", ret ); 235 saveLastDir( "FileDialog-SELECTDIR", ret );
237 } 236 }
238 return ret; 237 return ret;
239} 238}
240 239
241void OFileDialog::slotFileSelected(const QString & ) 240void OFileDialog::slotFileSelected(const QString & )
242{ 241{
243 accept(); 242 accept();
244} 243}
245 244
246void OFileDialog::slotSelectorOk( ) 245void OFileDialog::slotSelectorOk( )
247{ 246{
248 accept(); 247 accept();
249} 248}
250 249
251void OFileDialog::slotDirSelected(const QString &dir ) 250void OFileDialog::slotDirSelected(const QString &dir )
252{ 251{
253 setCaption( dir ); 252 setCaption( dir );
254} 253}