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