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