summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector/ofiledialog.cpp116
-rw-r--r--libopie/ofileselector/ofiledialog.h77
-rw-r--r--libopie/ofileselector/ofilelistview.cpp118
-rw-r--r--libopie/ofileselector/ofilelistview.h45
-rw-r--r--libopie/ofileselector/ofileselector.cpp1246
-rw-r--r--libopie/ofileselector/ofileselector.h474
-rw-r--r--libopie/ofileselector/ofileselectoritem.cpp53
-rw-r--r--libopie/ofileselector/ofileselectoritem.h30
-rw-r--r--libopie/ofileselector/ofileview.cpp28
-rw-r--r--libopie/ofileselector/ofileview.h109
10 files changed, 2296 insertions, 0 deletions
diff --git a/libopie/ofileselector/ofiledialog.cpp b/libopie/ofileselector/ofiledialog.cpp
new file mode 100644
index 0000000..4783004
--- a/dev/null
+++ b/libopie/ofileselector/ofiledialog.cpp
@@ -0,0 +1,116 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
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/applnk.h>
30#include <qstring.h>
31#include <qapplication.h>
32#include <qlayout.h>
33
34#include "ofiledialog.h"
35
36OFileDialog::OFileDialog(const QString &caption,
37 QWidget *wid, int mode, int selector,
38 const QString &dirName,
39 const QString &fileName,
40 const QMap<QString,QStringList>& mimetypes )
41 : QDialog( wid, "OFileDialog", true )
42{
43 // QVBoxLayout *lay = new QVBoxLayout(this);
44 //showMaximized();
45 QVBoxLayout *lay = new QVBoxLayout(this );
46 file = new OFileSelector(this , mode, selector,
47 dirName, fileName,
48 mimetypes );
49 lay->addWidget( file );
50
51 //lay->addWidget( file );
52 //showFullScreen();
53 setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
54 connect(file, SIGNAL(fileSelected(const QString&) ),
55 this, SLOT(slotFileSelected(const QString&) ) );
56
57 connect(file, SIGNAL(dirSelected(const QString &) ),
58 this, SLOT(slotDirSelected(const QString &) ) );
59
60
61 file->setYesCancelVisible( false ); // relayout
62}
63QString OFileDialog::mimetype()const
64{
65 return QString::null;
66}
67QString OFileDialog::fileName()const
68{
69 return file->selectedName();
70}
71DocLnk OFileDialog::selectedDocument()const
72{
73 return file->selectedDocument();
74}
75QString OFileDialog::getOpenFileName(int selector,
76 const QString &startDir,
77 const QString &file,
78 const MimeTypes &mimes,
79 QWidget *wid,
80 const QString &caption )
81{
82 QString ret;
83 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption,
84 wid, OFileSelector::OPEN, selector, startDir, file, mimes);
85 dlg.showMaximized();
86 if( dlg.exec() )
87 ret = dlg.fileName();
88
89 return ret;
90}
91QString OFileDialog::getSaveFileName(int selector,
92 const QString &startDir,
93 const QString &file,
94 const MimeTypes &mimes,
95 QWidget *wid,
96 const QString &caption )
97{
98 QString ret;
99 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption,
100 wid, OFileSelector::SAVE, selector, startDir, file, mimes);
101 dlg.showMaximized();
102 if( dlg.exec() )
103 ret = dlg.fileName();
104
105 return ret;
106}
107
108void OFileDialog::slotFileSelected(const QString & )
109{
110 accept();
111}
112void OFileDialog::slotDirSelected(const QString & )
113{
114 // if mode
115 //accept();
116}
diff --git a/libopie/ofileselector/ofiledialog.h b/libopie/ofileselector/ofiledialog.h
new file mode 100644
index 0000000..e14253c
--- a/dev/null
+++ b/libopie/ofileselector/ofiledialog.h
@@ -0,0 +1,77 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 zecke <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
30#ifndef OpieFileDialog_h
31#define OpieFileDialog_h
32
33#include <qdialog.h>
34
35#include <opie/ofileselector.h>
36
37class OFileDialog : public QDialog {
38 Q_OBJECT
39 public:
40 OFileDialog(const QString &caption,
41 QWidget *, int mode, int selector,
42 const QString &dirName,
43 const QString &fileName = QString::null,
44 const MimeTypes &mimetypes = MimeTypes() );
45 QString mimetype() const;
46 QString fileName() const;
47 DocLnk selectedDocument()const;
48
49 // static methods
50 static QString getOpenFileName(int selector,
51 const QString& startDir = QString::null,
52 const QString &fileName = QString::null,
53 const MimeTypes& mime = MimeTypes(),
54 QWidget *wid = 0,
55 const QString &caption = QString::null );
56
57 static QString getSaveFileName(int selector,
58 const QString& startDir = QString::null,
59 const QString& fileName = QString::null,
60 const MimeTypes& mimefilter = MimeTypes(),
61 QWidget *wid = 0,
62 const QString &caption = QString::null );
63
64 //let's OFileSelector catch up first
65 //static QString getExistingDirectory(const QString& startDir = QString::null,
66 // QWidget *parent = 0,
67 // const QString& caption = QString::null );
68 private:
69 class OFileDialogPrivate;
70 OFileDialogPrivate *d;
71 OFileSelector *file;
72
73 private slots:
74 void slotFileSelected( const QString & );
75 void slotDirSelected(const QString & );
76};
77#endif
diff --git a/libopie/ofileselector/ofilelistview.cpp b/libopie/ofileselector/ofilelistview.cpp
new file mode 100644
index 0000000..0c7d45b
--- a/dev/null
+++ b/libopie/ofileselector/ofilelistview.cpp
@@ -0,0 +1,118 @@
1
2#include "ofileselector.h"
3#include "ofileselectoritem.h"
4#include "ofilelistview.h"
5
6
7OFileListView::OFileListView( QWidget* parent, OFileSelector* sel)
8 : QListView( parent ), OFileView( sel )
9{
10
11}
12OFileListView::~OFileListView() {
13
14}
15void OFileListView::clear() {
16 QListView::clear();
17}
18void OFileListView::addFile( const QString& mime,
19 QFileInfo* info,
20 bool isSymlink ) {
21 MimeType type( info->absFilePath() );
22 QPixmap pix = type.pixmap();
23 QString dir;
24 QString name;
25 bool locked = false;
26
27 if( pix.isNull() )
28 pix = Resource::loadPixmap( "UnknownDocument-14");
29
30 dir = info->dirPath( true );
31
32 if( isSymlink )
33 name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink();
34 else {
35 name = info->fileName();
36 if( ( selector()->mode() == Open && !info->isReadable() )||
37 ( selector()->mode() == Save && !info->isWritable() ) ){
38
39 locked = true; pix = Resource::loadPixmap("locked");
40 }
41 }
42 new OFileSelectorItem( this, pix, name,
43 info->lastModified().toString(),
44 QString::number( info->size() ),
45 dir, locked );
46}
47void OFileListView::addFile( const QString& /*mime*/, const QString& /*dir*/,
48 const QString& /*file*/, bool /*isSyml*/ ) {
49
50}
51void OFileListView::addDir( const QString& mime,
52 QFileInfo* info, bool isSym ) {
53
54 bool locked = false;
55 QString name;
56 QPixmap pix;
57
58 if( ( selector()->mode() == Open && !info->isReadable() ) ||
59 ( selector()->mode() == Save && !info->isWritable() ) ){
60
61 locked = true;
62
63 if( symlink )
64 pix = selector()->pixmap("symlinkedlocked");
65 else
66 pix = Resource::loadPixmap("lockedfolder");
67
68 }else { // readable
69 pix = symlink ? selector()->pixmap("dirsymlink") : Resource::loadPixmap("folder") ;
70 }
71
72 name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ;
73
74 new OFileSelectorItem( this, pix, name,
75 info->lastModified().toString(),
76 QString::number( info->size() ),
77 info->dirPath( true ), locked,
78 true );
79
80}
81void OFileListView::addDir( const QString& mime, const QString& dir,
82 const QString& file, bool ) {
83
84}
85void OFileListView::addSymlink( const QString& mime,
86 QFileInfo* info,
87 bool isSym ) {
88
89}
90void OFileListView::addSymlink( const QString& mime, const QString& path,
91 const QString& file, bool isSym ) {
92
93}
94void OFileListView::cd( const QString& ) {
95
96}
97QWidget* OFileListView::widget() {
98 return this;
99}
100QString OFileListView::selectedName()const{
101 QListViewItem *item = currentItem();
102 if (!item )
103 return QString::null;
104
105 return item->text( 1 );
106}
107QStringList OFileListView::selectedNames()const {
108
109}
110QString OFileListView::selectedPath()const {
111
112}
113QString OFileListView::selectedPaths()const {
114
115}
116int OFileListView::fileCount() {
117 return childCount();
118}
diff --git a/libopie/ofileselector/ofilelistview.h b/libopie/ofileselector/ofilelistview.h
new file mode 100644
index 0000000..c7e9223
--- a/dev/null
+++ b/libopie/ofileselector/ofilelistview.h
@@ -0,0 +1,45 @@
1#ifndef OPIE_FILE_LIST_VIEW_H
2#define OPIE_FILE_LIST_VIEW_H
3
4#include <qlistview.h>
5
6#include "ofileview.h"
7
8class OFileListView : public QListView, public OFileView {
9 Q_OBJECT
10public:
11 OFileListView( QWidget* parent, OFileSelector* );
12 ~OFileListView();
13
14 void clear();
15 void addFile( const QString& mine,
16 QFileInfo* info,
17 bool isSymlink = FALSE );
18
19 void addFile( const QString& mime,
20 const QString& dir,
21 const QString& file,
22 bool = false );
23
24 void addDir( const QString& mime,
25 QFileInfo* info, bool = FALSE );
26 void addDir( const QString& mime, const QString& dir,
27 const QString& file, bool = FALSE );
28
29 void addSymlink( const QString& mime,
30 QFileInfo* info, bool = FALSE );
31 void addSymlink( const QString& mine, const QString& path,
32 const QString& file, bool isSymlink = FALSE );
33 void cd( const QString& path );
34 QWidget* widget();
35
36 QString selectedName()const ;
37 QStringList selectedNames()const;
38
39 QString selectedPath()const;
40 QStringList selectedPaths()const;
41 int fileCount();
42
43};
44
45#endif
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp
new file mode 100644
index 0000000..f655606
--- a/dev/null
+++ b/libopie/ofileselector/ofileselector.cpp
@@ -0,0 +1,1246 @@
1
2
3#include <qcheckbox.h>
4#include <qcombobox.h>
5#include <qheader.h>
6#include <qlabel.h>
7#include <qabstractlayout.h>
8#include <qlayout.h>
9#include <qlineedit.h>
10#include <qlistview.h>
11#include <qmessagebox.h>
12#include <qpainter.h>
13#include <qpushbutton.h>
14#include <qwidgetstack.h>
15#include <qpopupmenu.h>
16#include <qdir.h>
17#include <qfile.h>
18#include <qfileinfo.h>
19#include <qtimer.h>
20
21#include <qpe/qpeapplication.h>
22#include <qpe/applnk.h>
23#include <qpe/global.h>
24#include <qpe/mimetype.h>
25#include <qpe/resource.h>
26#include <qpe/storage.h>
27
28#include <unistd.h>
29#include <stdlib.h>
30#include <sys/stat.h>
31
32#include "ofileview.h"
33#include "ofileselector.h"
34
35
36QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
37
38namespace {
39 int indexByString( const QComboBox *box, const QString &str ){
40 int index= 0;
41 for(int i= 0; i < box->count(); i++ ){
42 if( str == box->text(i ) ){
43 index= i;
44 break;
45 }
46 }
47 return index;
48 }
49
50}
51
52OFileSelector::OFileSelector( QWidget *wid, int mode, int selector,
53 const QString &dirName,
54 const QString &fileName,
55 const QMap<QString,QStringList>& mimeTypes)
56 : QWidget( wid, "OFileSelector")
57{
58 m_mimetypes = mimeTypes;
59 if (mode == Save )
60 m_name = fileName;
61 initVars();
62 m_mode = mode;
63 m_selector = selector;
64 m_currentDir = dirName;
65 init();
66 //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) );
67}
68
69OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent,
70 const char *name, bool newVisible,
71 bool closeVisible )
72 : QWidget( parent, name )
73{
74 if (!mimeFilter.isEmpty() ) {
75 QStringList list = QStringList::split(";", mimeFilter );
76 m_mimetypes.insert(mimeFilter, list );
77 }
78 initVars();
79 m_currentDir = QPEApplication::documentDir();
80 m_mode = Fileselector;
81 m_selector = Normal;
82 m_shClose = closeVisible;
83 m_shNew = newVisible;
84 m_shLne = false;
85 m_shPerm = false;
86 m_shYesNo = false;
87 init();
88
89
90}
91
92OFileSelector::~OFileSelector()
93{
94
95
96}
97
98void OFileSelector::setNewVisible( bool visible )
99{
100 m_shNew = visible;
101 if( m_selector == Normal ){
102 delete m_select;
103 // we need to initialize but keep the selected mimetype
104 QString mime = currentMimeType();
105 m_select = new FileSelector( mime ,
106 m_stack, "fileselector",
107 m_shNew, m_shClose);
108
109 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
110 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
111 connect(m_select, SIGNAL(closeMe() ),
112 this, SIGNAL(closeMe() ) );
113 //connect to close me and other signals as well
114 m_stack->addWidget( m_select, Normal );
115 }else{
116 m_new->show();
117 }
118}
119void OFileSelector::setCloseVisible( bool visible )
120{
121 m_shClose = visible;
122 if( m_selector == Normal ){
123 setNewVisible( m_shNew ); // yeah baby
124 }else{
125 m_close->show();
126 }
127}
128void OFileSelector::reread()
129{
130 if( m_selector == Normal ){
131 setNewVisible( m_shNew ); // make it a initializeSelector
132 }else {
133 reparse();
134 }
135}
136
137const DocLnk *OFileSelector::selected()
138{
139 DocLnk *lnk = new DocLnk(selectedDocument() );
140 return lnk;
141}
142
143void OFileSelector::setYesCancelVisible( bool show )
144{
145 initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :(
146 m_shYesNo = show;
147 if( m_shYesNo )
148 m_boxOk->show();
149 else
150 m_boxOk->hide();
151
152}
153void OFileSelector::setToolbarVisible( bool show )
154{
155 m_shTool = show;
156 initializeListView(); // FIXME see above waste of memory
157 if(!m_shTool ){
158 m_location->hide();
159 m_up->hide();
160 m_homeButton->hide();
161 m_docButton->hide();
162 }else{
163 m_location->show();
164 m_up->show();
165 m_homeButton->show();
166 m_docButton->show();
167 }
168}
169void OFileSelector::setPermissionBarVisible( bool show )
170{
171 m_shPerm = show;
172 initializePerm();
173 if( m_shPerm )
174 m_checkPerm->show();
175 else
176 m_checkPerm->hide();
177}
178void OFileSelector::setLineEditVisible( bool show )
179{
180 if( show ){
181 initializeName();
182 m_boxName->show();
183 }else{
184 if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go
185 m_boxName->hide();
186 }
187 }
188 m_shLne = show;
189}
190
191void OFileSelector::setChooserVisible( bool show )
192{
193 m_shChooser = show;
194 initializeChooser();
195 if( m_shChooser ){
196 m_boxView->hide();
197 }else{
198 m_boxView->show();
199 }
200}
201
202QCheckBox* OFileSelector::permissionCheckbox()
203{
204 if( m_selector == Normal )
205 return 0l;
206 else
207 return m_checkPerm;
208}
209bool OFileSelector::setPermission()const
210{
211 return m_checkPerm == 0 ? false : m_checkPerm->isChecked();
212}
213void OFileSelector::setPermissionChecked( bool check )
214{
215 if( m_checkPerm )
216 m_checkPerm->setChecked( check );
217}
218
219void OFileSelector::setMode(int mode) // FIXME do direct raising
220{
221 m_mode = mode;
222 if( m_selector == Normal )
223 return;
224}
225void OFileSelector::setShowDirs(bool )
226{
227 m_dir = true;
228 reparse();
229}
230void OFileSelector::setCaseSensetive(bool caSe )
231{
232 m_case = caSe;
233 reparse();
234}
235void OFileSelector::setShowFiles(bool show )
236{
237 m_files = show;
238 reparse();
239}
240///
241bool OFileSelector::cd(const QString &path )
242{
243 m_currentDir = path;
244 reparse();
245 return true;
246}
247void OFileSelector::setSelector(int mode )
248{
249QString text;
250 switch( mode ){
251 case Normal:
252 text = tr("Documents");
253 break;
254 case Extended:
255 text = tr("Files");
256 break;
257 case ExtendedAll:
258 text = tr("All Files");
259 break;
260 }
261 slotViewCheck( text );
262}
263
264void OFileSelector::setPopupFactory(OPopupMenuFactory *popup )
265{
266/* m_custom = popup;
267 m_showPopup = true;
268*/
269}
270
271//void OFileSelector::updateL
272
273QString OFileSelector::selectedName() const
274{
275 QString name;
276 if( m_selector == Normal ){
277 DocLnk lnk = m_select->selectedDocument();
278 name = lnk.file();
279 }else if( m_selector == Extended || m_selector == ExtendedAll ){
280 if ( m_shLne ) {
281 name = m_currentDir + "/" +m_edit->text();
282 }else{
283 name = m_currentDir + "/" + currentView()->selectedName();
284 }
285 }
286 return name;
287}
288QStringList OFileSelector::selectedNames()const
289{
290 QStringList list;
291 if( m_selector == Normal ){
292 list << selectedName();
293 }else {
294 list << selectedName(); // FIXME implement multiple Selections
295 }
296 return list;
297}
298/** If mode is set to the Dir selection this will return the selected path.
299 *
300 *
301 */
302QString OFileSelector::selectedPath()const
303{
304 QString path;
305 if( m_selector == Normal ){
306 path = QPEApplication::documentDir();
307 }else if( m_selector == Extended || m_selector == ExtendedAll ){
308 ; //FIXME
309 }
310 return path;
311}
312QStringList OFileSelector::selectedPaths() const
313{
314 QStringList list;
315 list << selectedPath();
316 return list;
317}
318QString OFileSelector::directory()const
319{
320 if( m_selector == Normal )
321 return QPEApplication::documentDir();
322
323 return QDir(m_currentDir).absPath();
324}
325
326int OFileSelector::fileCount()
327{
328 int count;
329 switch( m_selector ){
330 case Normal:
331 count = m_select->fileCount();
332 break;
333 case Extended:
334 case ExtendedAll:
335 default:
336 count = currentView()->childCount();
337 break;
338 }
339 return count;
340}
341DocLnk OFileSelector::selectedDocument() const
342{
343 DocLnk lnk;
344 switch( m_selector ){
345 case Normal:{
346 lnk = m_select->selectedDocument();
347 break;
348 }
349 case Extended:
350 case ExtendedAll:
351 default:
352 lnk = DocLnk( selectedName() ); // new DocLnk
353 break;
354 }
355 return lnk;
356}
357QValueList<DocLnk> OFileSelector::selectedDocuments() const
358{
359 QValueList<DocLnk> docs;
360 docs.append( selectedDocument() );
361 return docs;
362}
363
364
365// slots internal
366
367void OFileSelector::slotOk()
368{
369 emit ok();
370}
371void OFileSelector::slotCancel()
372{
373 emit cancel();
374}
375void OFileSelector::slotViewCheck(const QString &sel)
376{
377 if( sel == tr("Documents" ) ){
378 if( m_select == 0 ){
379 // autMime? fix cause now we use All and not the current
380 // yes currentMime fixes that for us
381 QString mime = currentMimeType();
382 m_select = new FileSelector(mime,
383 m_stack, "fileselector",
384 m_shNew, m_shClose);
385 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
386 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
387 connect(m_select, SIGNAL(closeMe() ),
388 this, SIGNAL(closeMe() ) );
389 //connect to close me and other signals as well
390
391 m_stack->addWidget( m_select, Normal );
392 }
393 m_stack->raiseWidget( Normal );
394 m_selector = Normal;
395 }else if( sel == tr("Files") ){
396 m_selector = Extended;
397 initializeListView();
398 reparse();
399 m_stack->raiseWidget( Extended );
400 }else if( sel == tr("All Files") ){
401 m_selector = ExtendedAll;
402 initializeListView();
403 reparse();
404 m_stack->raiseWidget( Extended ); // same widget other QFileFilter
405 }
406}
407// not yet finished.....
408QString OFileSelector::currentMimeType() const{
409 QString mime;
410 QString currentText;
411 if (m_shChooser )
412 currentText = m_mimeCheck->currentText();
413
414 if (tr("All") == currentText ) return QString::null;
415 else if (currentText.isEmpty() ) {
416 ;
417 }else {
418 QMap<QString, QStringList>::ConstIterator it;
419 it = m_mimetypes.find( currentText );
420 if ( it == m_mimetypes.end() ) {
421 mime = it.data().join(";");
422 }else{
423 mime = currentText;
424 }
425 }
426 return mime;
427}
428void OFileSelector::slotMimeCheck(const QString &mime)
429{
430 if( m_selector == Normal ){
431 //if( m_autoMime ){
432 QString newMimeType;
433 if (mime != tr("All") ) {
434 QMap<QString, QStringList>::Iterator it;
435 it = m_mimetypes.find(mime);
436 if ( it != m_mimetypes.end() ) {
437 newMimeType = it.data().join(";");
438 }else{
439 newMimeType = mime;
440 }
441 }
442 delete m_select;
443 m_select = new FileSelector( newMimeType,
444 m_stack, "fileselector",
445 m_shNew, m_shClose);
446
447 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
448 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
449 connect(m_select, SIGNAL(closeMe() ),
450 this, SIGNAL(closeMe() ) );
451 //connect to close me and other signals as well
452 m_stack->addWidget( m_select, Normal );
453 m_stack->raiseWidget( Normal );
454 updateMimes();
455 updateMimeCheck();
456 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
457 //}
458 }else{ // others
459 qWarning("Mime %s", mime.latin1() );
460 if(m_shChooser ){
461 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() );
462 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
463 }
464 reparse();
465 }
466
467}
468/*
469 * Ok if a non dir gets inserted into this combobox
470 * we need to change it
471 * QFileInfo and dirPath will give us the right Dir
472 */
473void OFileSelector::slotLocationActivated(const QString &file)
474{
475 qWarning("slotLocationActivated");
476 QString name = file.left( file.find("<-", 0, TRUE ) );
477 QFileInfo info( name );
478 if ( info.isFile() )
479 cd(info.dirPath( TRUE ) ); //absolute
480 else
481 cd(name );
482 reparse();
483}
484void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count)
485{
486 QStringList pathList;
487 bool underDog = FALSE;
488 for(int i=0;i<count;i++) {
489 pathList << m_location->text(i);
490 if( m_location->text(i) == currentPath)
491 underDog = TRUE;
492 }
493 if( !underDog) {
494 m_location->clear();
495 if( currentPath.left(2)=="//")
496 pathList.append( currentPath.right(currentPath.length()-1) );
497 else
498 pathList.append( currentPath );
499 m_location->insertStringList( pathList,-1);
500 }
501}
502/*
503 * Do not crash anymore
504 * don't try to change dir to a file
505 */
506void OFileSelector::locationComboChanged()
507{
508 QFileInfo info( m_location->lineEdit()->text() );
509 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() );
510 if (info.isFile() )
511 cd(info.dirPath(TRUE) ); //absolute path
512 else
513 cd( m_location->lineEdit()->text() );
514
515 reparse();
516}
517void OFileSelector::init()
518{
519 m_lay = new QVBoxLayout( this );
520 m_lay->setSpacing(0 );
521
522 m_stack = new QWidgetStack( this );
523 if( m_selector == Normal ){
524 QString mime;
525 if (!m_autoMime) {
526 if (!m_mimetypes.isEmpty() ) {
527 QMap<QString, QStringList>::Iterator it;
528 it = m_mimetypes.begin(); // cause we're in the init
529 mime = it.data().join(";");
530 }
531 }
532 m_select = new FileSelector(mime,
533 m_stack, "fileselector",
534 m_shNew, m_shClose);
535
536 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
537 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
538 connect(m_select, SIGNAL(closeMe() ),
539 this, SIGNAL( closeMe() ) );
540 //connect to close me and other signals as well
541
542 m_stack->addWidget( m_select, Normal );
543 m_stack->raiseWidget( Normal );
544 }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL
545 // and initializeListview will take care of those
546 // toolbar get's generade in initializeListView
547 initializeListView( ); // will raise the widget as well
548 m_stack->raiseWidget( Extended );
549 }
550 m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch
551
552 if( m_shLne ) // the LineEdit with the current FileName
553 initializeName();
554
555 if( m_shPerm ) // the Permission QCheckBox
556 initializePerm();
557
558 if( m_shChooser ) // the Chooser for the view and Mimetypes
559 initializeChooser();
560
561 if( m_shYesNo ) // the Yes No button row
562 initializeYes( );
563
564 if (m_selector != Normal )
565 reparse();
566}
567void OFileSelector::updateMimes()
568{
569 if( m_autoMime ){
570 m_mimetypes.clear();
571 m_mimetypes.insert( tr("All"), QString::null );
572 if( m_selector == Normal ){
573 DocLnkSet set;
574 Global::findDocuments(&set, QString::null );
575 QListIterator<DocLnk> dit( set.children() );
576 for( ; dit.current(); ++dit ){
577 if( !m_mimetypes.contains( (*dit)->type() ) )
578 m_mimetypes.insert( (*dit)->type(), (*dit)->type() );
579 }
580 }// else done in reparse
581 }
582}
583void OFileSelector::initVars()
584{
585 if( m_mimetypes.isEmpty() )
586 m_autoMime = true;
587 else
588 m_autoMime = false;
589
590 m_shClose = false;
591 m_shNew = false;
592 m_shTool = true;
593 m_shPerm = false;
594 m_shLne = true;
595 m_shChooser = true;
596 m_shYesNo = true;
597 m_case = false;
598 m_dir = true;
599 m_files = true;
600 m_showPopup = false;
601
602 if(m_pixmaps == 0 ) // init the pixmaps
603 initPics();
604
605 // pointers
606 m_location = 0;
607 m_mimeCheck = 0;
608 m_viewCheck = 0;
609 m_homeButton = 0;
610 m_docButton = 0;
611 m_hideButton = 0;
612 m_ok = 0;
613 m_cancel = 0;
614 m_reread = 0;
615 m_up = 0;
616 m_View = 0;
617 m_checkPerm = 0;
618 m_pseudo = 0;
619 m_pseudoLayout = 0;
620 m_select = 0;
621 m_stack = 0;
622 m_lay = 0;
623 m_Oselector = 0;
624 m_boxToolbar = 0;
625 m_boxOk = 0;
626 m_boxName = 0;
627 m_boxView = 0;
628 m_custom = 0;
629 m_edit = 0;
630 m_fnLabel = 0;
631 m_new = 0;
632 m_close = 0;
633}
634void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink)
635{
636 if(!m_files)
637 return;
638 // if( !compliesMime(info->absFilePath(), mime ) )
639 // return;
640 MimeType type( info->absFilePath() );
641 if (!compliesMime( type.id() ) )
642 return;
643
644}
645void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
646{
647 if(!m_dir)
648 return;
649}
650void OFileSelector::delItems()
651{
652
653}
654void OFileSelector::initializeName()
655{
656 /** Name Layout Line
657 * This is the Layout line arranged in
658 * horizontal way each components
659 * are next to each other
660 * but we will only do this if
661 * we didn't initialize a while ago.
662 */
663 if( m_boxName == 0 ){
664 m_boxName = new QHBox( this ); // remove this this? or use a QHBox
665 m_fnLabel = new QLabel( m_boxName );
666 m_fnLabel->setText( tr("Name:") );
667 m_edit = new QLineEdit( m_boxName );
668 m_edit->setText( m_name );
669 //m_boxName->addWidget( m_fnLabel );
670 m_boxName->setMargin( 5 );
671 m_boxName->setSpacing( 8 );
672 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor
673
674 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout
675 }// else we already initialized
676 // maybe show the components?
677 //
678}
679void OFileSelector::initializeYes()
680{
681 /** The Save Cancel bar
682 *
683 */
684 if( m_boxOk == 0 ){
685 m_boxOk = new QHBox( this );
686 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" );
687 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" );
688
689 //m_boxOk->addWidget( m_ok );
690 //m_boxOk->addWidget( m_cancel );
691 m_boxOk->setMargin( 5 );
692 m_boxOk->setSpacing( 10 );
693 m_lay->addWidget( m_boxOk, 0 );
694
695 connect( m_ok, SIGNAL( clicked() ),
696 this, SLOT(slotOk() ) );
697 connect( m_cancel, SIGNAL( clicked() ),
698 this, SLOT( slotCancel() ) );
699 }
700}
701/*
702 * OK m_mimeCheck is a QComboBox we now want to fill
703 * out that combobox
704 * if automime we need to update the mimetypes
705 */
706void OFileSelector::updateMimeCheck() {
707 m_mimeCheck->clear();
708 if (m_autoMime ) {
709 //m_mimeCheck->insertItem( tr("All") );
710 updateMimes();
711 }
712
713 QMap<QString, QStringList>::Iterator it;
714 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) {
715 m_mimeCheck->insertItem( it.key() );
716 }
717}
718
719void OFileSelector::initializeChooser()
720{
721 if( m_boxView == 0 ){
722 m_boxView = new QHBox( this );
723 m_viewCheck = new QComboBox( m_boxView, "view check");
724 m_mimeCheck = new QComboBox( m_boxView, "mime check");
725 m_boxView->setSpacing( 8 );
726 m_lay->addWidget(m_boxView, 0 );
727
728 m_viewCheck->insertItem( tr("Documents") );
729 m_viewCheck->insertItem( tr("Files") );
730 m_viewCheck->insertItem( tr("All Files") );
731 updateMimeCheck();
732
733 connect( m_viewCheck, SIGNAL( activated(const QString & ) ),
734 this, SLOT( slotViewCheck(const QString & ) ) );
735 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ),
736 this, SLOT( slotMimeCheck( const QString & ) ) );
737 }
738}
739void OFileSelector::initializeListView()
740{
741 qWarning("initializeListView");
742 if( m_pseudo == 0 ){
743 qWarning("init");
744 m_pseudo = new QWidget( m_stack, "Pseudo Widget");
745 m_pseudoLayout = new QVBoxLayout( m_pseudo );
746 // toolbar
747 m_boxToolbar = new QHBox( m_pseudo );
748 m_boxToolbar->setSpacing(0 ); // next to each other please
749
750 // toolbar members
751 {
752 // location QComboBox
753 m_location = new QComboBox( m_boxToolbar );
754 m_location->setEditable( TRUE );
755 m_location->setDuplicatesEnabled( FALSE );
756 connect( m_location, SIGNAL(activated(const QString &) ),
757 this, SLOT( slotLocationActivated(const QString &) ) );
758 connect( m_location->lineEdit(), SIGNAL(returnPressed() ),
759 this, SLOT(locationComboChanged() ) );
760 // UP Button
761 m_up = new QPushButton(Resource::loadIconSet("up"),"",
762 m_boxToolbar,"cdUpButton");
763 m_up->setFixedSize( QSize( 20, 20 ) );
764 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) );
765 m_up->setFlat(TRUE);
766
767 // Home Button
768 m_homeButton = new QPushButton(Resource::loadIconSet("home") ,
769 "", m_boxToolbar);
770 m_homeButton->setFixedSize( QSize( 20, 20 ) );
771 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) );
772 m_homeButton->setFlat(TRUE);
773 // Documents Button
774 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",
775 m_boxToolbar,"docsButton");
776 m_docButton->setFixedSize( QSize( 20, 20 ) );
777 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) );
778 m_docButton->setFlat(TRUE);
779
780 // Close button
781 m_close = new QPushButton( Resource::loadIconSet( "close"), "",
782 m_boxToolbar );
783 connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) );
784 m_close->setFixedSize( 20, 20 );
785
786 m_boxToolbar->setFixedHeight( 20 );
787 m_pseudoLayout->addWidget(m_boxToolbar );
788
789 // let;s fill the Location ComboBox
790 StorageInfo storage;
791 const QList<FileSystem> &fs = storage.fileSystems();
792 QListIterator<FileSystem> it ( fs );
793 for( ; it.current(); ++it ){
794 const QString disk = (*it)->name();
795 const QString path = (*it)->path();
796 m_location->insertItem(path+ "<-"+disk );
797 }
798 int count = m_location->count();
799 m_location->insertItem( m_currentDir );
800 m_location->setCurrentItem( count );
801 // due to the New and Close button we can not simply hide m_boxToolBar to not show it
802 if( !m_shTool ){
803 m_location->hide( );
804 m_up->hide( );
805 m_homeButton->hide( );
806 m_docButton->hide( );
807 }
808 if(!m_shClose )
809 m_close->hide();
810 //if(!m_shNew)
811 //m_close->hide();
812
813 } // off toolbar
814 // the Main ListView
815 // make a QWidgetStack first so Views can share the Toolbar
816 m_View = new QListView( m_pseudo, "Extended view");
817 QPEApplication::setStylusOperation( m_View->viewport(),
818 QPEApplication::RightOnHold);
819 m_View->addColumn(" " );
820 m_View->addColumn(tr("Name"), 135 );
821 m_View->addColumn(tr("Size"), -1 );
822 m_View->addColumn(tr("Date"), 60 );
823 m_View->addColumn(tr("Mime Type"), -1 );
824 QHeader *header = m_View->header();
825 header->hide();
826 m_View->setSorting( 1 );
827 m_View->setAllColumnsShowFocus( TRUE );
828
829 connect(m_View, SIGNAL(selectionChanged() ),
830 this, SLOT(slotSelectionChanged() ) );
831
832 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ),
833 this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
834
835 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
836 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
837
838 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
839 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
840
841 m_pseudoLayout->addWidget( m_View, 288 );
842 m_stack->addWidget( m_pseudo, Extended );
843 }
844}
845void OFileSelector::initializePerm()
846{
847 if( m_checkPerm == 0 ){
848 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm");
849 m_checkPerm->setChecked( false );
850 m_lay->addWidget( m_checkPerm );
851
852 }
853}
854void OFileSelector::initPics()
855{
856 m_pixmaps = new QMap<QString,QPixmap>;
857 QPixmap pm = Resource::loadPixmap( "folder" );
858 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
859 QPainter painter( &pm );
860 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
861 pm.setMask( pm.createHeuristicMask( FALSE ) );
862 m_pixmaps->insert("dirsymlink", pm );
863
864 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
865 QPainter pen(&pm2 );
866 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
867 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
868 m_pixmaps->insert("symlinkedlocked", pm2 );
869}
870// if a mime complies with the m_mimeCheck->currentItem
871bool OFileSelector::compliesMime( const QString &path, const QString &mime )
872{
873 if( mime == "All" )
874 return true;
875 MimeType type( path );
876 if( type.id() == mime )
877 return true;
878 return false;
879}
880/* check if the mimetype in mime
881 * complies with the one which is current
882 */
883/*
884 * We've the mimetype of the file
885 * We need to get the stringlist of the current mimetype
886 *
887 * mime = image/jpeg
888 * QStringList = 'image/*'
889 * or QStringList = image/jpeg;image/png;application/x-ogg
890 * or QStringList = application/x-ogg;image/*;
891 * with all these mime filters it should get acceptes
892 * to do so we need to look if mime is contained inside
893 * the stringlist
894 * if it's contained return true
895 * if not ( I'm no RegExp expert at all ) we'll look if a '/*'
896 * is contained in the mimefilter and then we will
897 * look if both are equal until the '/'
898 */
899bool OFileSelector::compliesMime( const QString& mime ) {
900 qWarning("mimetype is %s", mime.latin1() );
901 QString currentText;
902 if (m_shChooser )
903 currentText = m_mimeCheck->currentText();
904
905 qWarning("current text is %s", currentText.latin1() );
906 QMap<QString, QStringList>::Iterator it;
907 QStringList list;
908 if ( currentText == tr("All") ) return true;
909 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) {
910 it = m_mimetypes.begin();
911 list = it.data();
912 }else if ( currentText.isEmpty() ) return true;
913 else{
914 it = m_mimetypes.find(currentText );
915 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText;
916 else qWarning("found"), list = it.data();
917 }
918 // dump it now
919 //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
920 // qWarning( "%s", (*it).latin1() );
921 //}
922
923
924 if ( list.contains(mime) ) return true;
925 qWarning("list doesn't contain it ");
926 QStringList::Iterator it2;
927 int pos;
928 int pos2;
929 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) {
930 pos = (*it2).findRev("/*");
931 if ( pos >= 0 ) {
932 if ( mime.contains( (*it2).left(pos) ) ) return true;
933 }
934 }
935 return false;
936}
937void OFileSelector::slotFileSelected( const QString &string )
938{
939 if( m_shLne )
940 m_edit->setText( string );
941 emit fileSelected( string );
942}
943void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
944{
945 slotFileSelected( lnk.name() );
946 // emit fileSelected( lnk );
947}
948void OFileSelector::slotSelectionChanged()
949{
950
951}
952void OFileSelector::slotCurrentChanged(QListViewItem* item )
953{
954 if( item == 0 )
955 return;
956 if( m_selector == Extended || m_selector == ExtendedAll ) {
957 OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;)
958 qWarning("current changed");
959 if(!sel->isDir() ){
960 if( m_shLne )
961 m_edit->setText( sel->text(1) );
962
963 if (m_mode == Fileselector ) {
964 QStringList str = QStringList::split("->", sel->text(1) );
965 QString path =sel->directory() + "/" + str[0].stripWhiteSpace();
966 emit fileSelected(path );
967 DocLnk lnk( path );
968 emit fileSelected(lnk );
969 }
970 }
971 }
972}
973void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int)
974{
975 if ( item == 0 )
976 return;
977
978 if( button != Qt::LeftButton )
979 return;
980
981 switch( m_selector ){
982 default:
983 break;
984 case Extended: // fall through
985 case ExtendedAll:{
986 OFileSelectorItem *sel = (OFileSelectorItem*)item;
987 if(!sel->isLocked() ){
988 QStringList str = QStringList::split("->", sel->text(1) );
989 if( sel->isDir() ){
990 cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
991 // if MODE Dir m_shLne set the Text
992 }else{
993 if( m_shLne )
994 m_edit->setText( str[0].stripWhiteSpace() );
995 qWarning("selected here in slot clicked");
996 emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() );
997 DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() );
998 qWarning("file selected");
999 emit fileSelected( lnk );
1000 }
1001 }
1002 break;
1003 }
1004 }
1005}
1006void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
1007{
1008 if( item == 0 )
1009 return;
1010
1011 if( button != Qt::RightButton )
1012 return;
1013 slotContextMenu( item );
1014}
1015void OFileSelector::slotContextMenu( QListViewItem *item)
1016{
1017
1018}
1019void OFileSelector::slotChangedDir()
1020{
1021 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1022 if(sel->isDir() ){
1023 QStringList str = QStringList::split("->", sel->text(1) );
1024 cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
1025 }
1026}
1027void OFileSelector::slotOpen()
1028{
1029 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1030 if(!sel->isDir() ){
1031 QStringList str = QStringList::split("->", sel->text(1) );
1032 slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() );
1033 qWarning("slot open");
1034 // DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() );
1035 //emit fileSelected( lnk );
1036 }
1037}
1038void OFileSelector::slotRescan()
1039{
1040
1041}
1042void OFileSelector::slotRename()
1043{
1044 reparse();
1045}
1046void OFileSelector::slotDelete()
1047{
1048 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1049 QStringList list = QStringList::split("->", sel->text(1) );
1050 if( sel->isDir() ){
1051 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry
1052 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
1053 tr("Yes"),tr("No"),0,1,1) ) {
1054 case 0:
1055 ::system(str.utf8().data() );
1056 break;
1057 }
1058 } else {
1059 QFile::remove( list[0] );
1060 }
1061 m_View->takeItem( sel );
1062 delete sel;
1063}
1064void OFileSelector::cdUP()
1065{
1066 QDir dir( m_currentDir );
1067 dir.cdUp();
1068 if(dir.exists() ){
1069 m_currentDir = dir.absPath();
1070 reparse();
1071 int count = m_location->count();
1072 slotInsertLocationPath( m_currentDir, count);
1073 m_location->setCurrentItem( indexByString( m_location, m_currentDir));
1074 //this wont work in all instances
1075 // FIXME
1076 }
1077}
1078void OFileSelector::slotHome()
1079{
1080 cd(QDir::homeDirPath() );
1081}
1082void OFileSelector::slotDoc()
1083{
1084 cd(QPEApplication::documentDir() );
1085}
1086void OFileSelector::slotNavigate( )
1087{
1088
1089}
1090// fill the View with life
1091void OFileSelector::reparse()
1092{
1093 if( m_selector == Normal )
1094 return;
1095 if( m_selector == Extended || m_selector == ExtendedAll )
1096 m_View->clear();
1097 else // custom view
1098 ; // currentView()->clear();
1099 if( m_shChooser)
1100 qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
1101
1102 QString currentMimeType;
1103 // let's update the mimetype
1104 if( m_autoMime ){
1105 m_mimetypes.clear();
1106 // ok we can change mimetype so we need to be able to give a selection
1107 if( m_shChooser ) {
1108 currentMimeType = m_mimeCheck->currentText();
1109 m_mimeCheck->clear();
1110
1111 // let's find possible mimetypes
1112 QDir dir( m_currentDir );
1113 dir.setFilter( QDir::Files | QDir::Readable );
1114 dir.setSorting( QDir::Size );
1115 const QFileInfoList *list = dir.entryInfoList();
1116 QFileInfoListIterator it( *list );
1117 QFileInfo *fi;
1118 while( (fi=it.current() ) ) {
1119 if( fi->extension() == QString::fromLatin1("desktop") ){
1120 ++it;
1121 continue;
1122 }
1123 MimeType type( fi->absFilePath() );
1124 if( !m_mimetypes.contains( type.id() ) ){
1125 //qWarning("Type %s", type.id().latin1() );
1126 m_mimetypes.insert( type.id(), type.id() );
1127 }
1128
1129 ++it;
1130 }
1131 // add them to the chooser
1132 updateMimeCheck();
1133 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
1134 currentMimeType = m_mimeCheck->currentText();
1135 }
1136 }else { // no autoMime
1137 // let the mimetype be set from out side the m_mimeCheck FEATURE
1138
1139 if( m_shChooser ){
1140 currentMimeType = m_mimeCheck->currentText();
1141// updateMimeCheck();
1142 }
1143 }
1144 // now we got our mimetypes we can add the files
1145
1146 QDir dir( m_currentDir );
1147
1148 int sort;
1149 if ( m_case )
1150 sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed);
1151 else
1152 sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed);
1153 dir.setSorting( sort );
1154
1155 int filter;
1156 if( m_selector == ExtendedAll /*|| m_selector ==CUSTOM_ALL */ ){
1157 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
1158 }else
1159 filter = QDir::Files | QDir::Dirs | QDir::All;
1160 dir.setFilter( filter );
1161
1162 // now go through all files
1163 const QFileInfoList *list = dir.entryInfoList();
1164 QFileInfoListIterator it( *list );
1165 QFileInfo *fi;
1166 while( (fi=it.current() ) ){
1167 //qWarning("True and only" );
1168 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){
1169 //qWarning(".. or ." );
1170 ++it;
1171 continue;
1172 }
1173 if( fi->isSymLink() ){
1174 QString file = fi->dirPath( true ) + "/" + fi->readLink();
1175 for( int i = 0; i<=4; i++) { // 5 tries to prevent dos
1176 QFileInfo info( file );
1177 if( !info.exists() ){
1178 addSymlink( currentMimeType, fi, TRUE );
1179 break;
1180 }else if( info.isDir() ){
1181 addDir( currentMimeType, fi, TRUE );
1182 break;
1183 }else if( info.isFile() ){
1184 addFile( currentMimeType, fi, TRUE );
1185 break;
1186 }else if( info.isSymLink() ){
1187 file = info.dirPath(true ) + "/" + info.readLink() ;
1188 break;
1189 }else if( i == 4){
1190 addSymlink( currentMimeType, fi );
1191 }
1192 } // off for loop
1193 }else if( fi->isDir() ){
1194 addDir( currentMimeType, fi );
1195 }else if( fi->isFile() ){
1196 addFile( currentMimeType, fi );
1197 }
1198 //qWarning( "%s", fi->fileName().latin1() );
1199 ++it;
1200 } // of while loop
1201 m_View->sort();
1202 if( m_shTool ){
1203 m_location->insertItem( m_currentDir );
1204
1205 }
1206 // reenable painting and updates
1207}
1208
1209
1210OFileView* OFileSelector::currentView() {
1211 return 0l;
1212}
1213int OFileSelector::filter() {
1214 int filter;
1215 if ( m_selector == ExtendedAll )
1216 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
1217 else
1218 filter = QDir::Files | QDir::Dirs | QDir::All ;
1219
1220 return filter;
1221}
1222int OFileSelector::sorting() {
1223 int sort;
1224
1225 if (m_case )
1226 sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed );
1227 else
1228 sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed );
1229
1230 return sort;
1231}
1232void OFileSelector::internFileSelected( const QString& s) {
1233 emit fileSelected( s );
1234}
1235void OFileSelector::internFileSelected( const DocLnk& d ) {
1236 emit fileSelected( d );
1237}
1238void OFileSelector::internContextMenu() {
1239 emit contextMenu();
1240}
1241void OFileSelector::internChangedDir( const QString& s) {
1242 emit dirSelected( s );
1243}
1244void OFileSelector::internChangedDir( const QDir& s) {
1245 emit dirSelected( s );
1246}
diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h
new file mode 100644
index 0000000..937569d
--- a/dev/null
+++ b/libopie/ofileselector/ofileselector.h
@@ -0,0 +1,474 @@
1/*
2 This is based on code and ideas of
3 L. J. Potter ljp@llornkcor.com
4 Thanks a lot
5
6
7               =. This file is part of the OPIE Project
8             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
9           .>+-=
10 _;:,     .>    :=|. This library is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This library is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
33
34#ifndef opiefileselector_h
35#define opiefileselector_h
36
37#include <qpe/fileselector.h>
38
39#include <qdir.h>
40#include <qwidget.h>
41#include <qstring.h>
42#include <qpixmap.h>
43#include <qstringlist.h>
44#include <qmap.h>
45#include <qvaluelist.h>
46
47#include <qpe/applnk.h>
48#include <qlistview.h>
49
50/** This is OPIEs FileDialog Widget. You can use it
51 * as a dropin replacement of the fileselector and
52 * or use any of the new features.
53 * This is also a complete FileSave and FileLoad widget
54 * If you look for a Dialog check OFileDialog
55 *
56 */
57class DocLnk;
58class QCheckBox;
59class QComboBox;
60class QPushButton;
61class QGridLayout;
62class QLineEdit;
63class QLabel;
64class QWidgetStack;
65class QHBoxLayout;
66class QVBoxLayout;
67class QPopupMenu;
68class QFileInfo;
69class QHBox;
70class OFileView;
71//
72
73/* the mimetypes one name and a list of mimetypes */
74typedef QMap< QString, QStringList> MimeTypes;
75
76/**
77 * FIXME later
78 */
79struct OPopupMenuFactory {
80 OPopupMenuFactory() {}
81
82};
83
84
85/**
86 * Opie the default OFileSelector
87 * It features multiple views.
88 */
89class OFileSelector : public QWidget {
90 Q_OBJECT
91
92 /* friends are evil but I don't want to make the
93 * methods public
94 */
95 friend class OLister;
96 friend class OFileView;
97 public:
98 /**
99 * The mode of the file selector
100 * Either open, save, fileselector or dir browsing mode
101 *
102 */
103 enum Mode {Open = 1, Save = 2, Fileselector = 4, Dir = 8 };
104
105 /**
106 * Selector. Either Normal for the one shipped with
107 * libqpe or Extended. for the Extended
108 * ExtendedAll also shows 'hidden' files
109 */
110 enum Selector{Normal=0, Extended = 1, ExtendedAll =2 };
111
112 /**
113 * This is reserved for futrue views
114 */
115 enum View { Dirs = 1, Files = 2, Tree = 4, Icon = 8 };
116
117 /**
118 * A c'tor which should be used for advanced mode
119 * @param wid the parent
120 * @param mode the Mode of the Selector
121 * @param selector the current View of the Selector
122 * @param dirName in which dir to start
123 * @param fileName a proposed filename
124 * @param mimetypes A list of mimetypes \
125 * QString is for a identifier name like "Text files"
126 * the coresponding QStringList is used for the mimetypes
127 * if empty it'll fill the list of mimetypes depending
128 * on the content of the current directory
129 */
130
131 OFileSelector(QWidget *wid, int mode, int selector,
132 const QString &dirName,
133 const QString &fileName = QString::null,
134 const MimeTypes &mimetypes = MimeTypes() );
135
136
137 /**
138 * This is a QPE compatible c'tor
139 */
140 OFileSelector(const QString &mimeFilter, QWidget *parent,
141 const char *name, bool newVisible = TRUE,
142 bool closeVisible = FALSE );
143
144 ~OFileSelector();
145
146 // currently only for the FileSelector Mode
147 /* compability mode but only work
148 * with FileSelector
149 */
150 void setNewVisible( bool /*b*/ );
151 void setCloseVisible(bool /*b*/ );
152
153 // end file selector mode
154 // deprecated
155 void reread();
156 // make sure not to leak please
157 const DocLnk *selected();
158 // end deprecated
159
160 /**
161 * @return if the toolbar is visible
162 */
163 bool isToolbarVisible() const { return m_shTool; };
164
165 /**
166 * @return if the permissionBas is visible
167 */
168 bool isPermissionBarVisible() const { return m_shPerm; };
169
170 /**
171 * @return if the lineEdit is visible
172 */
173 bool isLineEditVisible()const { return m_shLne; };
174
175 /**
176 * if the chooser is visible
177 */
178 bool isChooserVisible( )const { return m_shChooser; };
179
180 /**
181 * @return if the yesCancel Bar is visible
182 */
183 bool isYesCancelVisible()const { return m_shYesNo; };
184
185 /**
186 * set Yes/Cancel visible
187 */
188 void setYesCancelVisible( bool show );
189
190 /**
191 * set the toolbar visible
192 */
193 void setToolbarVisible( bool show );
194
195 /**
196 * set the permissionBar to be visible
197 */
198 void setPermissionBarVisible( bool show );
199
200 /**
201 * set the lineedit for file entering visible
202 */
203 void setLineEditVisible(bool show) ;
204
205 /**
206 * set the chooser is visible
207 */
208 void setChooserVisible( bool chooser );
209
210 /**
211 * The permissionCheckbox
212 *
213 */
214 QCheckBox* permissionCheckbox();
215
216 /**
217 * setPermission
218 */
219 bool setPermission() const;
220
221 /**
222 * set ther permission to bool
223 */
224 void setPermissionChecked( bool check );
225
226 /**
227 * set the Selector Mode
228 */
229 void setMode( int );
230
231 /**
232 * whether or not to show dirs
233 */
234 bool showDirs()const { return m_dir; }
235
236 /**
237 * setShowDirs
238 */
239 void setShowDirs(bool );
240
241 /**
242 * set CaseSensetive
243 */
244 bool isCaseSensetive()const { return m_case; }
245
246 /**
247 * set if to be case sensetive
248 */
249 void setCaseSensetive(bool caSe );
250
251 /**
252 * @return if to show files
253 */
254 bool showFiles()const { return m_files; };
255
256 /**
257 * set if files should be shown
258 */
259 void setShowFiles(bool );
260
261 /**
262 * change dir to path
263 */
264 bool cd(const QString &path );
265
266
267 /**
268 * return the mode of the fileselector
269 */
270 int mode()const { return m_mode; };
271
272 /**
273 * return the selector
274 */
275 int selector()const { return m_selector; };
276
277 /**
278 * set the Selector
279 */
280 void setSelector( int );
281
282 /**
283 * wether or not to show popups
284 */
285 bool showPopup()const { return m_showPopup; };
286
287 /**
288 * set show popups
289 */
290 void setShowPopup( bool pop ) { m_showPopup = pop; }
291
292 /**
293 * set the popup factory
294 */
295 void setPopupFactory( OPopupMenuFactory * );
296
297 /**
298 * reparse the current directory and updates
299 * the views + mimetypes
300 */
301 void reparse(); // re reads the dir
302
303 /**
304 * return the selected name
305 */
306 QString selectedName( )const;
307
308 /**
309 * for multiple selections return multiple
310 * filenames
311 */
312 QStringList selectedNames()const;
313
314 /**
315 * return the complete to the file
316 */
317 QString selectedPath() const;
318
319 /**
320 * return the completed paths
321 */
322 QStringList selectedPaths() const;
323
324 /**
325 * the current directory
326 */
327 QString directory()const;
328
329 /**
330 * fileCount
331 */
332 int fileCount();
333
334 DocLnk selectedDocument()const;
335
336 QValueList<DocLnk> selectedDocuments()const;
337
338 OFileView* currentView();
339 int filter();
340 int sorting();
341
342 signals:
343 void fileSelected( const DocLnk & );
344 void fileSelected( const QString & );
345 void dirSelected(const QString &dir );
346 void dirSelected( const QDir& );
347 void closeMe();
348 void ok();
349 void cancel();
350 void contextMenu();
351
352 private slots:
353 void slotOk();
354 void slotCancel();
355 void slotViewCheck(const QString & );
356 void slotMimeCheck(const QString & );
357 void slotLocationActivated(const QString & );
358 void slotInsertLocationPath(const QString &, int);
359 void locationComboChanged();
360
361 private:
362 void init();
363 void updateMimes();
364
365
366 private:
367
368 FileSelector* m_select;
369 int m_mode, m_selector;
370 QComboBox *m_location, *m_mimeCheck, *m_viewCheck;
371 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel;
372 QPushButton *m_reread, *m_up, *m_new, *m_close;
373 QListView *m_View;
374 QCheckBox *m_checkPerm;
375 QWidget *m_pseudo;
376 QVBoxLayout *m_pseudoLayout;
377
378 QString m_currentDir;
379 QString m_name;
380// QStringList m_mimetypes;
381 QMap<QString, QStringList> m_mimetypes;
382
383
384 QWidgetStack *m_stack;
385 QVBoxLayout *m_lay;
386 QGridLayout *m_Oselector;
387
388 QHBox *m_boxToolbar;
389 QHBox *m_boxOk; // (no layout anymore) wait
390 QHBox *m_boxName; // (no Layout anymore) wait
391 QHBox *m_boxView;
392
393 QPopupMenu *m_custom;
394
395 QLineEdit *m_edit;
396 QLabel *m_fnLabel;
397
398 bool m_shClose : 1;
399 bool m_shNew : 1;
400 bool m_shTool : 1;
401 bool m_shPerm : 1;
402 bool m_shLne : 1;
403 bool m_shChooser : 1;
404 bool m_shYesNo : 1;
405 bool m_boCheckPerm : 1;
406 bool m_autoMime : 1;
407 bool m_case : 1;
408 bool m_dir : 1;
409 bool m_files : 1;
410 bool m_showPopup : 1;
411
412 void initVars();
413 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE );
414 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE );
415 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){};
416 void delItems();
417 void initializeName();
418 void initializeYes();
419 void initializeChooser();
420 void initializeListView();
421 void initializePerm();
422 void initPics();
423 bool compliesMime(const QString &path,
424 const QString &mime);
425 bool compliesMime(const QString& mime );
426 /**
427 * Updates the QComboBox with the current mimetypes
428 */
429 void updateMimeCheck();
430
431 /**
432 * Returns the current mimetype
433 */
434 QString currentMimeType()const;
435 class OFileSelectorPrivate;
436 OFileSelectorPrivate *d;
437 static QMap<QString,QPixmap> *m_pixmaps;
438
439private slots:
440 void slotFileSelected(const QString & ); // not really meant to be a slot
441 void slotFileBridgeSelected( const DocLnk & );
442 virtual void slotSelectionChanged();
443 virtual void slotCurrentChanged(QListViewItem* );
444 virtual void slotClicked( int, QListViewItem *item, const QPoint &, int);
445 virtual void slotRightButton(int, QListViewItem *, const QPoint &, int );
446 virtual void slotContextMenu( QListViewItem *item);
447 // listview above
448 // popup below
449 virtual void slotChangedDir();
450 virtual void slotOpen();
451 virtual void slotRescan();
452 virtual void slotRename();
453 virtual void slotDelete();
454 virtual void cdUP();
455 virtual void slotHome();
456 virtual void slotDoc();
457 virtual void slotNavigate( );
458
459 /* for OLister */
460private:
461
462 /* for OFileView */
463private:
464 void internFileSelected( const QString& );
465 void internFileSelected( const DocLnk& );
466 void internContextMenu();
467 void internChangedDir( const QString& );
468 void internChangedDir( const QDir& ) ;
469
470};
471
472
473#endif
474
diff --git a/libopie/ofileselector/ofileselectoritem.cpp b/libopie/ofileselector/ofileselectoritem.cpp
new file mode 100644
index 0000000..1e745a1
--- a/dev/null
+++ b/libopie/ofileselector/ofileselectoritem.cpp
@@ -0,0 +1,53 @@
1#include "ofileselectoritem.h"
2
3OFileSelectorItem::OFileSelectorItem( QListView*view,
4 const QPixmap& pix,
5 const QString& path,
6 const QString& date,
7 const QString& size,
8 const QString& dir,
9 bool isLocked,
10 bool isDir )
11 : QListViewItem( view )
12{
13 setPixmap( 0, pix );
14 setText( 1, path );
15 setText( 2, size );
16 setText( 3, date );
17 m_dir = isDir;
18 m_locked = isLocked;
19 m_dirStr = dir;
20}
21OFileSelectorItem::~OFileSelectorItem() {
22}
23bool OFileSelectorItem::isLocked()const {
24 return m_locked;
25}
26QString OFileSelectorItem::directory()const {
27 return m_dirStr;
28}
29bool OFileSelectorItem::isDir()const {
30 return m_dir;
31}
32QString OFileSelectorItem::path() const {
33 return text(1);
34}
35QString OFileSelectorItem::key( int id, bool ) {
36 QString ke;
37
38 if( id == 0 || id == 1 ){ // name
39 if( m_dir ){
40 ke.append("0" );
41 ke.append( text(1) );
42 }else{
43 ke.append("1" );
44 ke.append( text(1) );
45 }
46 }else if( id == 2 ){ // size
47 return text(2);
48 }else if( id == 3 ){ // date
49 return text(3);
50 }
51
52 return ke;
53}
diff --git a/libopie/ofileselector/ofileselectoritem.h b/libopie/ofileselector/ofileselectoritem.h
new file mode 100644
index 0000000..21460c4
--- a/dev/null
+++ b/libopie/ofileselector/ofileselectoritem.h
@@ -0,0 +1,30 @@
1#ifndef OPIE_FILE_SELECTOR_ITEM_H
2#define OPIE_FILE_SELECTOR_ITEM_H
3
4#include <qlistview.h>
5
6class OFileSelectorItem : public QListViewItem {
7public:
8 OFileSelectorItem( QListView* view,
9 const QPixmap&,
10 const QString& path,
11 const QString& date,
12 const QString& size,
13 const QString& dir,
14 bool isLocked,
15 bool isDir = false);
16 ~OFileSelectorItem();
17 bool isLocked() const;
18 QString directory()const;
19 bool isDir()const;
20 QString path()const;
21 QString key(int id, bool );
22
23private:
24 bool m_locked : 1;
25 bool m_dir : 1;
26 QString m_dirStr;
27
28};
29
30#endif
diff --git a/libopie/ofileselector/ofileview.cpp b/libopie/ofileselector/ofileview.cpp
new file mode 100644
index 0000000..71843c1
--- a/dev/null
+++ b/libopie/ofileselector/ofileview.cpp
@@ -0,0 +1,28 @@
1#include <qpe/applnk.h>
2
3#include "ofileselector.h"
4
5#include "ofileview.h"
6
7
8OFileView::OFileView( OFileSelector* sel)
9 : m_sel( sel )
10{
11}
12OFileView::~OFileView() {
13}
14void OFileView::fileSelected( const QString& s ) {
15 m_sel->internFileSelected( s );
16}
17void OFileView::fileSelected( const DocLnk& s) {
18 m_sel->internFileSelected( s );
19}
20void OFileView::contextMenu() {
21 m_sel->internContextMenu();
22}
23void OFileView::changedDir( const QString& s) {
24 m_sel->internChangedDir( s );
25}
26void OFileView::changedDir( const QDir& d ) {
27 m_sel->internChangedDir( d );
28}
diff --git a/libopie/ofileselector/ofileview.h b/libopie/ofileselector/ofileview.h
new file mode 100644
index 0000000..997266a
--- a/dev/null
+++ b/libopie/ofileselector/ofileview.h
@@ -0,0 +1,109 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 zecke <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#ifndef ofileview_h
30#define ofileview_h
31
32#include <qobject.h>
33#include <qwidget.h>
34#include <qpopupmenu.h>
35
36class QFileInfo;
37class QDir;
38class DocLnk;
39
40/**
41 * A OFileView is a specialised View for the
42 * OFileSelector
43 * With a View you can chage the user visible
44 * representation of a OFileLister
45 * OFileView is just a basic interface which helps you to
46 * write new views
47 */
48class OFileSelector;
49class OFileView {
50public:
51 OFileView( OFileSelector* );
52 OFileView();
53 virtual ~OFileView();
54
55 virtual void clear() = 0;
56 virtual void addFile(const QString &mine,
57 QFileInfo *info,
58 bool isSymlink = FALSE ) = 0;
59 virtual void addFile(const QString& mine, const QString& dir,
60 const QString& file, bool = FALSE ) = 0;
61
62 virtual void addDir (const QString &mine,
63 QFileInfo *info,
64 bool isSymlink = FALSE ) = 0;
65 virtual void addDir (const QString& mine, const QString& dir,
66 const QString& file, bool = FALSE) = 0;
67
68 virtual void addSymlink(const QString &mime,
69 QFileInfo *info,
70 bool isSymlink = FALSE ) = 0;
71 virtual void addSymlink(const QString& mine,
72 const QString& path,
73 const QString& file,
74 bool isSymlink = FALSE ) = 0;
75
76 virtual void cd(const QString &path ) = 0;
77 virtual QWidget* widget() = 0;
78
79 virtual QString selectedName()const = 0;
80 virtual QStringList selectedNames()const = 0;
81 virtual QString selectedPath()const = 0;
82 virtual QStringList selectedPaths()const = 0;
83 virtual int fileCount() = 0;
84
85/*signals:*/
86protected:
87
88 void fileSelected(const QString &);
89 void fileSelected(const DocLnk & );
90 void contextMenu();
91 void changedDir(const QString &);
92 void changedDir(const QDir & );
93 OFileSelector* selector();
94
95private:
96 OFileSelector* m_sel;
97};
98
99class OFileViewFactory {
100 public:
101 OFileViewFactory() {} ;
102 virtual ~OFileViewFactory() = 0;
103
104 OFileView* newView(QWidget *parent, const char *name );
105 QString name()const;
106};
107
108
109#endif