summaryrefslogtreecommitdiff
path: root/libopie/ofiledialog.cc
Unidiff
Diffstat (limited to 'libopie/ofiledialog.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofiledialog.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/libopie/ofiledialog.cc b/libopie/ofiledialog.cc
index 4783004..9e725c2 100644
--- a/libopie/ofiledialog.cc
+++ b/libopie/ofiledialog.cc
@@ -12,103 +12,143 @@
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> 29#include <qpe/applnk.h>
30#include <qstring.h> 30#include <qstring.h>
31#include <qapplication.h> 31#include <qapplication.h>
32#include <qlayout.h> 32#include <qlayout.h>
33 33
34#include "ofiledialog.h" 34#include "ofiledialog.h"
35 35
36/**
37 * This constructs a modal dialog
38 *
39 * @param caption The caption of the dialog
40 * @param wid The parent widget
41 * @param mode The mode of the OFileSelector @see OFileSelector
42 * @param selector The selector of the OFileSelector
43 * @param dirName the dir or resource to start from
44 * @param fileName a proposed or existing filename
45 * @param mimetypes The mimeTypes
46 */
36OFileDialog::OFileDialog(const QString &caption, 47OFileDialog::OFileDialog(const QString &caption,
37 QWidget *wid, int mode, int selector, 48 QWidget *wid, int mode, int selector,
38 const QString &dirName, 49 const QString &dirName,
39 const QString &fileName, 50 const QString &fileName,
40 const QMap<QString,QStringList>& mimetypes ) 51 const QMap<QString,QStringList>& mimetypes )
41 : QDialog( wid, "OFileDialog", true ) 52 : QDialog( wid, "OFileDialog", true )
42{ 53{
43 // QVBoxLayout *lay = new QVBoxLayout(this); 54 // QVBoxLayout *lay = new QVBoxLayout(this);
44 //showMaximized(); 55 //showMaximized();
45 QVBoxLayout *lay = new QVBoxLayout(this ); 56 QVBoxLayout *lay = new QVBoxLayout(this );
46 file = new OFileSelector(this , mode, selector, 57 file = new OFileSelector(this , mode, selector,
47 dirName, fileName, 58 dirName, fileName,
48 mimetypes ); 59 mimetypes );
49 lay->addWidget( file ); 60 lay->addWidget( file );
50 61
51 //lay->addWidget( file ); 62 //lay->addWidget( file );
52 //showFullScreen(); 63 //showFullScreen();
53 setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); 64 setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
54 connect(file, SIGNAL(fileSelected(const QString&) ), 65 connect(file, SIGNAL(fileSelected(const QString&) ),
55 this, SLOT(slotFileSelected(const QString&) ) ); 66 this, SLOT(slotFileSelected(const QString&) ) );
56 67
57 connect(file, SIGNAL(dirSelected(const QString &) ), 68 connect(file, SIGNAL(dirSelected(const QString &) ),
58 this, SLOT(slotDirSelected(const QString &) ) ); 69 this, SLOT(slotDirSelected(const QString &) ) );
59 70
60 71
61 file->setYesCancelVisible( false ); // relayout 72 file->setYesCancelVisible( false ); // relayout
62} 73}
74/**
75 * @returns the mimetype of the selected
76 * currently it return QString::null
77 */
63QString OFileDialog::mimetype()const 78QString OFileDialog::mimetype()const
64{ 79{
65 return QString::null; 80 return QString::null;
66} 81}
82
83/**
84 * @return the fileName
85 */
67QString OFileDialog::fileName()const 86QString OFileDialog::fileName()const
68{ 87{
69 return file->selectedName(); 88 return file->selectedName();
70} 89}
90
91/**
92 * return a DocLnk to the current file
93 */
71DocLnk OFileDialog::selectedDocument()const 94DocLnk OFileDialog::selectedDocument()const
72{ 95{
73 return file->selectedDocument(); 96 return file->selectedDocument();
74} 97}
98
99/**
100 * This opens up a filedialog in Open mode
101 *
102 * @param selector the Selector Mode
103 * @param startDir Where to start from
104 * @param file A proposed filename
105 * @param mimes A list of MimeTypes
106 * @param wid the parent
107 * @param caption of the dialog if QString::null tr("Open") will be used
108 * @return the fileName or QString::null
109 */
75QString OFileDialog::getOpenFileName(int selector, 110QString OFileDialog::getOpenFileName(int selector,
76 const QString &startDir, 111 const QString &startDir,
77 const QString &file, 112 const QString &file,
78 const MimeTypes &mimes, 113 const MimeTypes &mimes,
79 QWidget *wid, 114 QWidget *wid,
80 const QString &caption ) 115 const QString &caption )
81{ 116{
82 QString ret; 117 QString ret;
83 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, 118 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption,
84 wid, OFileSelector::OPEN, selector, startDir, file, mimes); 119 wid, OFileSelector::OPEN, selector, startDir, file, mimes);
85 dlg.showMaximized(); 120 dlg.showMaximized();
86 if( dlg.exec() ) 121 if( dlg.exec() )
87 ret = dlg.fileName(); 122 ret = dlg.fileName();
88 123
89 return ret; 124 return ret;
90} 125}
126
127/**
128 * This opens up a file dialog in save mode
129 * @see getOpenFileName
130 */
91QString OFileDialog::getSaveFileName(int selector, 131QString OFileDialog::getSaveFileName(int selector,
92 const QString &startDir, 132 const QString &startDir,
93 const QString &file, 133 const QString &file,
94 const MimeTypes &mimes, 134 const MimeTypes &mimes,
95 QWidget *wid, 135 QWidget *wid,
96 const QString &caption ) 136 const QString &caption )
97{ 137{
98 QString ret; 138 QString ret;
99 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, 139 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption,
100 wid, OFileSelector::SAVE, selector, startDir, file, mimes); 140 wid, OFileSelector::SAVE, selector, startDir, file, mimes);
101 dlg.showMaximized(); 141 dlg.showMaximized();
102 if( dlg.exec() ) 142 if( dlg.exec() )
103 ret = dlg.fileName(); 143 ret = dlg.fileName();
104 144
105 return ret; 145 return ret;
106} 146}
107 147
108void OFileDialog::slotFileSelected(const QString & ) 148void OFileDialog::slotFileSelected(const QString & )
109{ 149{
110 accept(); 150 accept();
111} 151}
112void OFileDialog::slotDirSelected(const QString & ) 152void OFileDialog::slotDirSelected(const QString & )
113{ 153{
114 // if mode 154 // if mode