summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp19
-rw-r--r--libopie2/opieui/fileselector/ofileselector.h10
2 files changed, 24 insertions, 5 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 5528aed..b06defd 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -1,1175 +1,1184 @@
1 1
2/* 2/*
3               =. This file is part of the OPIE Project 3               =. This file is part of the OPIE Project
4             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> 4             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This library is free software; you can 6 _;:,     .>    :=|. This library is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This library is distributed in the hope that 13    .i_,=:_.      -<s. This library is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30/* hacky but we need to get FileSelector::filter */ 30/* hacky but we need to get FileSelector::filter */
31#define private public 31#define private public
32#include <qpe/fileselector.h> 32#include <qpe/fileselector.h>
33#undef private 33#undef private
34 34
35#include "ofileselector_p.h" 35#include "ofileselector_p.h"
36 36
37/* OPIE */ 37/* OPIE */
38#include <opie2/ofileselector.h> 38#include <opie2/ofileselector.h>
39#include <opie2/odebug.h> 39#include <opie2/odebug.h>
40 40
41#include <qpe/qpeapplication.h> 41#include <qpe/qpeapplication.h>
42#include <qpe/mimetype.h> 42#include <qpe/mimetype.h>
43#include <qpe/resource.h> 43#include <qpe/resource.h>
44#include <qpe/storage.h> 44#include <qpe/storage.h>
45 45
46/* QT */ 46/* QT */
47#include <qcombobox.h> 47#include <qcombobox.h>
48#include <qdir.h> 48#include <qdir.h>
49#include <qhbox.h> 49#include <qhbox.h>
50#include <qheader.h> 50#include <qheader.h>
51#include <qlabel.h> 51#include <qlabel.h>
52#include <qlayout.h> 52#include <qlayout.h>
53#include <qlineedit.h> 53#include <qlineedit.h>
54#include <qlistview.h> 54#include <qlistview.h>
55#include <qpopupmenu.h> 55#include <qpopupmenu.h>
56#include <qwidgetstack.h> 56#include <qwidgetstack.h>
57#include <qregexp.h> 57#include <qregexp.h>
58#include <qobjectlist.h> 58#include <qobjectlist.h>
59 59
60using namespace Opie::Ui::Internal; 60using namespace Opie::Ui::Internal;
61 61
62namespace Opie { 62namespace Opie {
63namespace Ui { 63namespace Ui {
64namespace Internal { 64namespace Internal {
65OFileViewInterface::OFileViewInterface( OFileSelector* selector ) 65OFileViewInterface::OFileViewInterface( OFileSelector* _selector )
66 : m_selector( selector ) 66 : m_selector( _selector )
67{} 67{
68 selector()->registerView( this );
69}
68 70
69OFileViewInterface::~OFileViewInterface() 71OFileViewInterface::~OFileViewInterface()
70{} 72{}
71 73
72QString OFileViewInterface::name()const 74QString OFileViewInterface::name()const
73{ 75{
74 return m_name; 76 return m_name;
75} 77}
76 78
77void OFileViewInterface::setName( const QString& name ) 79void OFileViewInterface::setName( const QString& name )
78{ 80{
79 m_name = name; 81 m_name = name;
80} 82}
81 83
82OFileSelector* OFileViewInterface::selector()const 84OFileSelector* OFileViewInterface::selector()const
83{ 85{
84 return m_selector; 86 return m_selector;
85} 87}
86 88
87DocLnk OFileViewInterface::selectedDocument()const 89DocLnk OFileViewInterface::selectedDocument()const
88{ 90{
89 return DocLnk( selectedName() ); 91 return DocLnk( selectedName() );
90} 92}
91 93
92bool OFileViewInterface::showNew()const 94bool OFileViewInterface::showNew()const
93{ 95{
94 return selector()->showNew(); 96 return selector()->showNew();
95} 97}
96 98
97bool OFileViewInterface::showClose()const 99bool OFileViewInterface::showClose()const
98{ 100{
99 return selector()->showClose(); 101 return selector()->showClose();
100} 102}
101 103
102MimeTypes OFileViewInterface::mimeTypes()const 104MimeTypes OFileViewInterface::mimeTypes()const
103{ 105{
104 return selector()->mimeTypes(); 106 return selector()->mimeTypes();
105} 107}
106 108
107QStringList OFileViewInterface::currentMimeType()const 109QStringList OFileViewInterface::currentMimeType()const
108{ 110{
109 return selector()->currentMimeType(); 111 return selector()->currentMimeType();
110} 112}
111 113
112void OFileViewInterface::activate( const QString& ) 114void OFileViewInterface::activate( const QString& )
113{ 115{
114 // not implemented here 116 // not implemented here
115} 117}
116 118
117void OFileViewInterface::ok() 119void OFileViewInterface::ok()
118{ 120{
119 emit selector()->ok(); 121 emit selector()->ok();
120} 122}
121 123
122void OFileViewInterface::cancel() 124void OFileViewInterface::cancel()
123{ 125{
124 emit selector()->cancel(); 126 emit selector()->cancel();
125} 127}
126 128
127void OFileViewInterface::closeMe() 129void OFileViewInterface::closeMe()
128{ 130{
129 emit selector()->closeMe(); 131 emit selector()->closeMe();
130} 132}
131 133
132void OFileViewInterface::fileSelected( const QString& str) 134void OFileViewInterface::fileSelected( const QString& str)
133{ 135{
134 emit selector()->fileSelected( str); 136 emit selector()->fileSelected( str);
135} 137}
136 138
137void OFileViewInterface::fileSelected( const DocLnk& lnk) 139void OFileViewInterface::fileSelected( const DocLnk& lnk)
138{ 140{
139 emit selector()->fileSelected( lnk ); 141 emit selector()->fileSelected( lnk );
140} 142}
141 143
142void OFileViewInterface::setCurrentFileName( const QString& str ) 144void OFileViewInterface::setCurrentFileName( const QString& str )
143{ 145{
144 selector()->m_lneEdit->setText( str ); 146 selector()->m_lneEdit->setText( str );
145} 147}
146 148
147QString OFileViewInterface::currentFileName()const 149QString OFileViewInterface::currentFileName()const
148{ 150{
149 return selector()->m_lneEdit->text(); 151 return selector()->m_lneEdit->text();
150} 152}
151 153
152QString OFileViewInterface::startDirectory()const 154QString OFileViewInterface::startDirectory()const
153{ 155{
154 return selector()->m_startDir; 156 return selector()->m_startDir;
155} 157}
156 158
157ODocumentFileView::ODocumentFileView( OFileSelector* selector ) 159ODocumentFileView::ODocumentFileView( OFileSelector* selector )
158 :OFileViewInterface( selector ) 160 :OFileViewInterface( selector )
159{ 161{
160 m_selector = 0; 162 m_selector = 0;
161 setName( QObject::tr("Documents") ); 163 setName( QObject::tr("Documents") );
162} 164}
163 165
164ODocumentFileView::~ODocumentFileView() 166ODocumentFileView::~ODocumentFileView()
165{ 167{
166} 168}
167 169
168QString ODocumentFileView::selectedName()const 170QString ODocumentFileView::selectedName()const
169{ 171{
170 if (!m_selector) 172 if (!m_selector)
171 return QString::null; 173 return QString::null;
172 174
173 return m_selector->selectedDocument().file(); 175 return m_selector->selectedDocument().file();
174} 176}
175 177
176QString ODocumentFileView::selectedPath()const 178QString ODocumentFileView::selectedPath()const
177{ 179{
178 return QPEApplication::documentDir(); 180 return QPEApplication::documentDir();
179} 181}
180 182
181QString ODocumentFileView::directory()const 183QString ODocumentFileView::directory()const
182{ 184{
183 return selectedPath(); 185 return selectedPath();
184} 186}
185 187
186void ODocumentFileView::reread() 188void ODocumentFileView::reread()
187{ 189{
188 if (!m_selector) 190 if (!m_selector)
189 return; 191 return;
190 192
191 m_selector->setNewVisible( showNew() ); 193 m_selector->setNewVisible( showNew() );
192 m_selector->setCloseVisible( showClose() ); 194 m_selector->setCloseVisible( showClose() );
193 m_selector->filter = currentMimeType().join(";"); 195 m_selector->filter = currentMimeType().join(";");
194 m_selector->reread(); 196 m_selector->reread();
195} 197}
196 198
197int ODocumentFileView::fileCount()const 199int ODocumentFileView::fileCount()const
198{ 200{
199 if (!m_selector) 201 if (!m_selector)
200 return -1; 202 return -1;
201 203
202 return m_selector->fileCount(); 204 return m_selector->fileCount();
203} 205}
204 206
205DocLnk ODocumentFileView::selectedDocument()const 207DocLnk ODocumentFileView::selectedDocument()const
206{ 208{
207 if (!m_selector) 209 if (!m_selector)
208 return DocLnk(); 210 return DocLnk();
209 211
210 return m_selector->selectedDocument(); 212 return m_selector->selectedDocument();
211} 213}
212 214
213QWidget* ODocumentFileView::widget( QWidget* parent ) 215QWidget* ODocumentFileView::widget( QWidget* parent )
214{ 216{
215 if (!m_selector ) 217 if (!m_selector )
216 { 218 {
217 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); 219 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
218 QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), 220 QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ),
219 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); 221 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
220 QObject::connect(m_selector, SIGNAL(closeMe() ), 222 QObject::connect(m_selector, SIGNAL(closeMe() ),
221 selector(), SIGNAL(closeMe() ) ); 223 selector(), SIGNAL(closeMe() ) );
222 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), 224 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ),
223 selector(), SIGNAL(newSelected(const DocLnk&) ) ); 225 selector(), SIGNAL(newSelected(const DocLnk&) ) );
224 } 226 }
225 227
226 return m_selector; 228 return m_selector;
227} 229}
228 230
229/* 231/*
230 * This is the file system view used 232 * This is the file system view used
231 * we use a QListView + QListViewItems for it 233 * we use a QListView + QListViewItems for it
232 */ 234 */
233 235
234OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 236OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
235 const QString& path, const QString& date, 237 const QString& path, const QString& date,
236 const QString& size, const QString& dir, 238 const QString& size, const QString& dir,
237 bool isLocked, bool isDir ) 239 bool isLocked, bool isDir )
238 : QListViewItem( view ) 240 : QListViewItem( view )
239{ 241{
240 setPixmap(0, pixmap ); 242 setPixmap(0, pixmap );
241 setText(1, path ); 243 setText(1, path );
242 setText(2, size ); 244 setText(2, size );
243 setText(3, date ); 245 setText(3, date );
244 m_isDir = isDir; 246 m_isDir = isDir;
245 m_dir = dir; 247 m_dir = dir;
246 m_locked = isLocked; 248 m_locked = isLocked;
247} 249}
248 250
249OFileSelectorItem::~OFileSelectorItem() 251OFileSelectorItem::~OFileSelectorItem()
250{ 252{
251} 253}
252 254
253bool OFileSelectorItem::isLocked()const 255bool OFileSelectorItem::isLocked()const
254{ 256{
255 return m_locked; 257 return m_locked;
256} 258}
257 259
258QString OFileSelectorItem::directory()const 260QString OFileSelectorItem::directory()const
259{ 261{
260 return m_dir; 262 return m_dir;
261} 263}
262 264
263bool OFileSelectorItem::isDir()const 265bool OFileSelectorItem::isDir()const
264{ 266{
265 return m_isDir; 267 return m_isDir;
266} 268}
267 269
268QString OFileSelectorItem::path()const 270QString OFileSelectorItem::path()const
269{ 271{
270 return text( 1 ); 272 return text( 1 );
271} 273}
272 274
273QString OFileSelectorItem::key( int id, bool )const 275QString OFileSelectorItem::key( int id, bool )const
274{ 276{
275 QString ke; 277 QString ke;
276 if( id == 0 || id == 1 ) 278 if( id == 0 || id == 1 )
277 { // name 279 { // name
278 if( m_isDir ) 280 if( m_isDir )
279 { 281 {
280 ke.append("0" ); 282 ke.append("0" );
281 ke.append( text(1) ); 283 ke.append( text(1) );
282 } 284 }
283 else 285 else
284 { 286 {
285 ke.append("1" ); 287 ke.append("1" );
286 ke.append( text(1) ); 288 ke.append( text(1) );
287 } 289 }
288 return ke; 290 return ke;
289 } 291 }
290 else 292 else
291 return text( id ); 293 return text( id );
292 294
293} 295}
294 296
295OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) 297OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel)
296 :QWidget( parent ), m_sel( sel ) 298 :QWidget( parent ), m_sel( sel )
297{ 299{
298 m_all = false; 300 m_all = false;
299 QVBoxLayout* lay = new QVBoxLayout( this ); 301 QVBoxLayout* lay = new QVBoxLayout( this );
300 m_currentDir = startDir; 302 m_currentDir = startDir;
301 303
302 /* 304 /*
303 * now we add a special bar 305 * now we add a special bar
304 * One Button For Up 306 * One Button For Up
305 * Home 307 * Home
306 * Doc 308 * Doc
307 * And a dropdown menu with FileSystems 309 * And a dropdown menu with FileSystems
308 * FUTURE: one to change dir with lineedit 310 * FUTURE: one to change dir with lineedit
309 * Bookmarks 311 * Bookmarks
310 * Create Dir 312 * Create Dir
311 */ 313 */
312 QHBox* box = new QHBox(this ); 314 QHBox* box = new QHBox(this );
313 box->setBackgroundMode( PaletteButton ); 315 box->setBackgroundMode( PaletteButton );
314 box->setSpacing( 0 ); 316 box->setSpacing( 0 );
315 317
316 QToolButton *btn = new QToolButton( box ); 318 QToolButton *btn = new QToolButton( box );
317 btn->setIconSet( Resource::loadIconSet("up") ); 319 btn->setIconSet( Resource::loadIconSet("up") );
318 connect(btn, SIGNAL(clicked() ), 320 connect(btn, SIGNAL(clicked() ),
319 this, SLOT( cdUP() ) ); 321 this, SLOT( cdUP() ) );
320 322
321 btn = new QToolButton( box ); 323 btn = new QToolButton( box );
322 btn->setIconSet( Resource::loadIconSet("home") ); 324 btn->setIconSet( Resource::loadIconSet("home") );
323 connect(btn, SIGNAL(clicked() ), 325 connect(btn, SIGNAL(clicked() ),
324 this, SLOT( cdHome() ) ); 326 this, SLOT( cdHome() ) );
325 327
326 btn = new QToolButton( box ); 328 btn = new QToolButton( box );
327 btn->setIconSet( Resource::loadIconSet("DocsIcon") ); 329 btn->setIconSet( Resource::loadIconSet("DocsIcon") );
328 connect(btn, SIGNAL(clicked() ), 330 connect(btn, SIGNAL(clicked() ),
329 this, SLOT(cdDoc() ) ); 331 this, SLOT(cdDoc() ) );
330 332
331 m_btnNew = new QToolButton( box ); 333 m_btnNew = new QToolButton( box );
332 m_btnNew->setIconSet( Resource::loadIconSet("new") ); 334 m_btnNew->setIconSet( Resource::loadIconSet("new") );
333 connect(m_btnNew, SIGNAL(clicked() ), 335 connect(m_btnNew, SIGNAL(clicked() ),
334 this, SLOT(slotNew() ) ); 336 this, SLOT(slotNew() ) );
335 337
336 338
337 m_btnClose = new QToolButton( box ); 339 m_btnClose = new QToolButton( box );
338 m_btnClose->setIconSet( Resource::loadIconSet("close") ); 340 m_btnClose->setIconSet( Resource::loadIconSet("close") );
339 connect(m_btnClose, SIGNAL(clicked() ), 341 connect(m_btnClose, SIGNAL(clicked() ),
340 selector(), SIGNAL(closeMe() ) ); 342 selector(), SIGNAL(closeMe() ) );
341 343
342 btn = new QToolButton( box ); 344 btn = new QToolButton( box );
343 btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); 345 btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") );
344 346
345 /* let's fill device parts */ 347 /* let's fill device parts */
346 QPopupMenu* pop = new QPopupMenu(this); 348 QPopupMenu* pop = new QPopupMenu(this);
347 connect(pop, SIGNAL( activated(int) ), 349 connect(pop, SIGNAL( activated(int) ),
348 this, SLOT(slotFSActivated(int) ) ); 350 this, SLOT(slotFSActivated(int) ) );
349 351
350 StorageInfo storage; 352 StorageInfo storage;
351 const QList<FileSystem> &fs = storage.fileSystems(); 353 const QList<FileSystem> &fs = storage.fileSystems();
352 QListIterator<FileSystem> it(fs); 354 QListIterator<FileSystem> it(fs);
353 for ( ; it.current(); ++it ) 355 for ( ; it.current(); ++it )
354 { 356 {
355 const QString disk = (*it)->name(); 357 const QString disk = (*it)->name();
356 const QString path = (*it)->path(); 358 const QString path = (*it)->path();
357 m_dev.insert( disk, path ); 359 m_dev.insert( disk, path );
358 pop->insertItem( disk ); 360 pop->insertItem( disk );
359 } 361 }
360 m_fsPop = pop; 362 m_fsPop = pop;
361 363
362 364
363 btn->setPopup( pop ); 365 btn->setPopup( pop );
364 366
365 lay->addWidget( box ); 367 lay->addWidget( box );
366 368
367 m_view = new QListView( this ); 369 m_view = new QListView( this );
368 370
369 m_view->installEventFilter(this); 371 m_view->installEventFilter(this);
370 372
371 QPEApplication::setStylusOperation( m_view->viewport(), 373 QPEApplication::setStylusOperation( m_view->viewport(),
372 QPEApplication::RightOnHold); 374 QPEApplication::RightOnHold);
373 m_view->addColumn(" " ); 375 m_view->addColumn(" " );
374 m_view->addColumn(tr("Name"), 135 ); 376 m_view->addColumn(tr("Name"), 135 );
375 m_view->addColumn(tr("Size"), -1 ); 377 m_view->addColumn(tr("Size"), -1 );
376 m_view->addColumn(tr("Date"), 60 ); 378 m_view->addColumn(tr("Date"), 60 );
377 m_view->addColumn(tr("Mime Type"), -1 ); 379 m_view->addColumn(tr("Mime Type"), -1 );
378 380
379 381
380 m_view->setSorting( 1 ); 382 m_view->setSorting( 1 );
381 m_view->setAllColumnsShowFocus( TRUE ); 383 m_view->setAllColumnsShowFocus( TRUE );
382 384
383 lay->addWidget( m_view, 1000 ); 385 lay->addWidget( m_view, 1000 );
384 connectSlots(); 386 connectSlots();
385} 387}
386 388
387OFileViewFileListView::~OFileViewFileListView() 389OFileViewFileListView::~OFileViewFileListView()
388{ 390{
389} 391}
390 392
391void OFileViewFileListView::slotNew() 393void OFileViewFileListView::slotNew()
392{ 394{
393 DocLnk lnk; 395 DocLnk lnk;
394 emit selector()->newSelected( lnk ); 396 emit selector()->newSelected( lnk );
395} 397}
396 398
397OFileSelectorItem* OFileViewFileListView::currentItem()const 399OFileSelectorItem* OFileViewFileListView::currentItem()const
398{ 400{
399 QListViewItem* item = m_view->currentItem(); 401 QListViewItem* item = m_view->currentItem();
400 if (!item ) 402 if (!item )
401 return 0l; 403 return 0l;
402 404
403 return static_cast<OFileSelectorItem*>(item); 405 return static_cast<OFileSelectorItem*>(item);
404} 406}
405 407
406void OFileViewFileListView::reread( bool all ) 408void OFileViewFileListView::reread( bool all )
407{ 409{
408 m_view->clear(); 410 m_view->clear();
409 411
410 if (selector()->showClose() ) 412 if (selector()->showClose() )
411 m_btnClose->show(); 413 m_btnClose->show();
412 else 414 else
413 m_btnClose->hide(); 415 m_btnClose->hide();
414 416
415 if (selector()->showNew() ) 417 if (selector()->showNew() )
416 m_btnNew->show(); 418 m_btnNew->show();
417 else 419 else
418 m_btnNew->hide(); 420 m_btnNew->hide();
419 421
420 m_mimes = selector()->currentMimeType(); 422 m_mimes = selector()->currentMimeType();
421 m_all = all; 423 m_all = all;
422 424
423 QDir dir( m_currentDir ); 425 QDir dir( m_currentDir );
424 if (!dir.exists() ) 426 if (!dir.exists() )
425 return; 427 return;
426 428
427 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 429 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
428 int filter; 430 int filter;
429 if (m_all ) 431 if (m_all )
430 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 432 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
431 else 433 else
432 filter = QDir::Files | QDir::Dirs | QDir::All; 434 filter = QDir::Files | QDir::Dirs | QDir::All;
433 dir.setFilter( filter ); 435 dir.setFilter( filter );
434 436
435 // now go through all files 437 // now go through all files
436 const QFileInfoList *list = dir.entryInfoList(); 438 const QFileInfoList *list = dir.entryInfoList();
437 if (!list) 439 if (!list)
438 { 440 {
439 cdUP(); 441 cdUP();
440 return; 442 return;
441 } 443 }
442 444
443 QFileInfoListIterator it( *list ); 445 QFileInfoListIterator it( *list );
444 QFileInfo *fi; 446 QFileInfo *fi;
445 while( (fi=it.current() ) ) 447 while( (fi=it.current() ) )
446 { 448 {
447 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) 449 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") )
448 { 450 {
449 ++it; 451 ++it;
450 continue; 452 continue;
451 } 453 }
452 454
453 /* 455 /*
454 * It is a symlink we try to resolve it now but don't let us attack by DOS 456 * It is a symlink we try to resolve it now but don't let us attack by DOS
455 * 457 *
456 */ 458 */
457 if( fi->isSymLink() ) 459 if( fi->isSymLink() )
458 { 460 {
459 QString file = fi->dirPath( true ) + "/" + fi->readLink(); 461 QString file = fi->dirPath( true ) + "/" + fi->readLink();
460 for( int i = 0; i<=4; i++) 462 for( int i = 0; i<=4; i++)
461 { // 5 tries to prevent dos 463 { // 5 tries to prevent dos
462 QFileInfo info( file ); 464 QFileInfo info( file );
463 if( !info.exists() ) 465 if( !info.exists() )
464 { 466 {
465 addSymlink( fi, TRUE ); 467 addSymlink( fi, TRUE );
466 break; 468 break;
467 } 469 }
468 else if( info.isDir() ) 470 else if( info.isDir() )
469 { 471 {
470 addDir( fi, TRUE ); 472 addDir( fi, TRUE );
471 break; 473 break;
472 } 474 }
473 else if( info.isFile() ) 475 else if( info.isFile() )
474 { 476 {
475 addFile( fi, TRUE ); 477 addFile( fi, TRUE );
476 break; 478 break;
477 } 479 }
478 else if( info.isSymLink() ) 480 else if( info.isSymLink() )
479 { 481 {
480 file = info.dirPath(true ) + "/" + info.readLink() ; 482 file = info.dirPath(true ) + "/" + info.readLink() ;
481 break; 483 break;
482 } 484 }
483 else if( i == 4) 485 else if( i == 4)
484 { // couldn't resolve symlink add it as symlink 486 { // couldn't resolve symlink add it as symlink
485 addSymlink( fi ); 487 addSymlink( fi );
486 } 488 }
487 } // off for loop for symlink resolving 489 } // off for loop for symlink resolving
488 } 490 }
489 else if( fi->isDir() ) 491 else if( fi->isDir() )
490 addDir( fi ); 492 addDir( fi );
491 else if( fi->isFile() ) 493 else if( fi->isFile() )
492 addFile( fi ); 494 addFile( fi );
493 495
494 ++it; 496 ++it;
495 } // of while loop 497 } // of while loop
496 m_view->sort(); 498 m_view->sort();
497 499
498} 500}
499int OFileViewFileListView::fileCount()const 501int OFileViewFileListView::fileCount()const
500{ 502{
501 return m_view->childCount(); 503 return m_view->childCount();
502} 504}
503 505
504QString OFileViewFileListView::currentDir()const 506QString OFileViewFileListView::currentDir()const
505{ 507{
506 return m_currentDir; 508 return m_currentDir;
507} 509}
508 510
509OFileSelector* OFileViewFileListView::selector() 511OFileSelector* OFileViewFileListView::selector()
510{ 512{
511 return m_sel; 513 return m_sel;
512} 514}
513 515
514bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) 516bool OFileViewFileListView::eventFilter (QObject *, QEvent *e)
515{ 517{
516 if ( e->type() == QEvent::KeyPress ) 518 if ( e->type() == QEvent::KeyPress )
517 { 519 {
518 QKeyEvent *k = (QKeyEvent *)e; 520 QKeyEvent *k = (QKeyEvent *)e;
519 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 521 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
520 { 522 {
521 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 523 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
522 return true; 524 return true;
523 } 525 }
524 } 526 }
525 return false; 527 return false;
526} 528}
527 529
528void OFileViewFileListView::connectSlots() 530void OFileViewFileListView::connectSlots()
529{ 531{
530 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 532 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
531 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 533 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
532 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), 534 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
533 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); 535 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) );
534} 536}
535 537
536void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) 538void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
537{ 539{
538 if (!item) 540 if (!item)
539 return; 541 return;
540#if 0 542#if 0
541 543
542 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 544 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
543 545
544 if (!sel->isDir() ) 546 if (!sel->isDir() )
545 { 547 {
546 selector()->m_lneEdit->setText( sel->text(1) ); 548 selector()->m_lneEdit->setText( sel->text(1) );
547 // if in fileselector mode we will emit selected 549 // if in fileselector mode we will emit selected
548 if ( selector()->mode() == OFileSelector::FileSelector ) 550 if ( selector()->mode() == OFileSelector::FileSelector )
549 { 551 {
550 odebug << "slot Current Changed" << oendl; 552 odebug << "slot Current Changed" << oendl;
551 QStringList str = QStringList::split("->", sel->text(1) ); 553 QStringList str = QStringList::split("->", sel->text(1) );
552 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 554 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
553 emit selector()->fileSelected( path ); 555 emit selector()->fileSelected( path );
554 DocLnk lnk( path ); 556 DocLnk lnk( path );
555 emit selector()->fileSelected( lnk ); 557 emit selector()->fileSelected( lnk );
556 } 558 }
557 } 559 }
558#endif 560#endif
559} 561}
560 562
561void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) 563void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int )
562{ 564{
563 if (!item || ( button != Qt::LeftButton) ) 565 if (!item || ( button != Qt::LeftButton) )
564 return; 566 return;
565 567
566 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 568 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
567 if (!sel->isLocked() ) 569 if (!sel->isLocked() )
568 { 570 {
569 QStringList str = QStringList::split("->", sel->text(1) ); 571 QStringList str = QStringList::split("->", sel->text(1) );
570 if (sel->isDir() ) 572 if (sel->isDir() )
571 { 573 {
572 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); 574 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace();
573 emit selector()->dirSelected( m_currentDir ); 575 emit selector()->dirSelected( m_currentDir );
574 reread( m_all ); 576 reread( m_all );
575 } 577 }
576 else 578 else
577 { // file 579 { // file
578 odebug << "slot Clicked" << oendl; 580 odebug << "slot Clicked" << oendl;
579 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); 581 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
580 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 582 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
581 emit selector()->fileSelected( path ); 583 emit selector()->fileSelected( path );
582 DocLnk lnk( path ); 584 DocLnk lnk( path );
583 emit selector()->fileSelected( lnk ); 585 emit selector()->fileSelected( lnk );
584 } 586 }
585 } // not locked 587 } // not locked
586} 588}
587 589
588void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) 590void OFileViewFileListView::addFile( QFileInfo* info, bool symlink )
589{ 591{
590 MimeType type( info->absFilePath() ); 592 MimeType type( info->absFilePath() );
591 if (!compliesMime( type.id() ) ) 593 if (!compliesMime( type.id() ) )
592 return; 594 return;
593 595
594 QPixmap pix = type.pixmap(); 596 QPixmap pix = type.pixmap();
595 QString dir, name; bool locked; 597 QString dir, name; bool locked;
596 if ( pix.isNull() ) 598 if ( pix.isNull() )
597 { 599 {
598 QWMatrix matrix; 600 QWMatrix matrix;
599 QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); 601 QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
600 matrix.scale( .4, .4 ); 602 matrix.scale( .4, .4 );
601 pix = pixer.xForm( matrix ); 603 pix = pixer.xForm( matrix );
602 } 604 }
603 dir = info->dirPath( true ); 605 dir = info->dirPath( true );
604 locked = false; 606 locked = false;
605 if ( symlink ) 607 if ( symlink )
606 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 608 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
607 else 609 else
608 { 610 {
609 name = info->fileName(); 611 name = info->fileName();
610 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || 612 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
611 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) 613 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) )
612 { 614 {
613 locked = true; pix = Resource::loadPixmap("locked"); 615 locked = true; pix = Resource::loadPixmap("locked");
614 } 616 }
615 } 617 }
616 (void)new OFileSelectorItem( m_view, pix, name, 618 (void)new OFileSelectorItem( m_view, pix, name,
617 info->lastModified().toString(), QString::number( info->size() ), 619 info->lastModified().toString(), QString::number( info->size() ),
618 dir, locked ); 620 dir, locked );
619} 621}
620 622
621void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) 623void OFileViewFileListView::addDir( QFileInfo* info, bool symlink )
622{ 624{
623 bool locked = false; QString name; QPixmap pix; 625 bool locked = false; QString name; QPixmap pix;
624 626
625 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || 627 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
626 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) 628 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) )
627 { 629 {
628 locked = true; 630 locked = true;
629 if ( symlink ) 631 if ( symlink )
630 pix = Resource::loadPixmap( "opie/symlink" ); 632 pix = Resource::loadPixmap( "opie/symlink" );
631 else 633 else
632 pix = Resource::loadPixmap( "lockedfolder" ); 634 pix = Resource::loadPixmap( "lockedfolder" );
633 } 635 }
634 else 636 else
635 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); 637 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder");
636 638
637 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : 639 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() :
638 info->fileName(); 640 info->fileName();
639 641
640 (void)new OFileSelectorItem( m_view, pix, name, 642 (void)new OFileSelectorItem( m_view, pix, name,
641 info->lastModified().toString(), 643 info->lastModified().toString(),
642 QString::number( info->size() ), 644 QString::number( info->size() ),
643 info->dirPath( true ), locked, true ); 645 info->dirPath( true ), locked, true );
644 646
645 647
646} 648}
647 649
648void OFileViewFileListView::addSymlink( QFileInfo* , bool ) 650void OFileViewFileListView::addSymlink( QFileInfo* , bool )
649{ 651{
650} 652}
651 653
652void OFileViewFileListView::cdUP() 654void OFileViewFileListView::cdUP()
653{ 655{
654 QDir dir( m_currentDir ); 656 QDir dir( m_currentDir );
655 dir.cdUp(); 657 dir.cdUp();
656 658
657 if (!dir.exists() ) 659 if (!dir.exists() )
658 m_currentDir = "/"; 660 m_currentDir = "/";
659 else 661 else
660 m_currentDir = dir.absPath(); 662 m_currentDir = dir.absPath();
661 663
662 emit selector()->dirSelected( m_currentDir ); 664 emit selector()->dirSelected( m_currentDir );
663 reread( m_all ); 665 reread( m_all );
664} 666}
665 667
666void OFileViewFileListView::cdHome() 668void OFileViewFileListView::cdHome()
667{ 669{
668 m_currentDir = QDir::homeDirPath(); 670 m_currentDir = QDir::homeDirPath();
669 emit selector()->dirSelected( m_currentDir ); 671 emit selector()->dirSelected( m_currentDir );
670 reread( m_all ); 672 reread( m_all );
671} 673}
672 674
673void OFileViewFileListView::cdDoc() 675void OFileViewFileListView::cdDoc()
674{ 676{
675 m_currentDir = QPEApplication::documentDir(); 677 m_currentDir = QPEApplication::documentDir();
676 emit selector()->dirSelected( m_currentDir ); 678 emit selector()->dirSelected( m_currentDir );
677 reread( m_all ); 679 reread( m_all );
678} 680}
679 681
680void OFileViewFileListView::changeDir( const QString& dir ) 682void OFileViewFileListView::changeDir( const QString& dir )
681{ 683{
682 m_currentDir = dir; 684 m_currentDir = dir;
683 emit selector()->dirSelected( m_currentDir ); 685 emit selector()->dirSelected( m_currentDir );
684 reread( m_all ); 686 reread( m_all );
685} 687}
686 688
687void OFileViewFileListView::slotFSActivated( int id ) 689void OFileViewFileListView::slotFSActivated( int id )
688{ 690{
689 changeDir ( m_dev[m_fsPop->text(id)] ); 691 changeDir ( m_dev[m_fsPop->text(id)] );
690} 692}
691 693
692/* check if the mimetype in mime 694/* check if the mimetype in mime
693 * complies with the one which is current 695 * complies with the one which is current
694 */ 696 */
695/* 697/*
696 * We've the mimetype of the file 698 * We've the mimetype of the file
697 * We need to get the stringlist of the current mimetype 699 * We need to get the stringlist of the current mimetype
698 * 700 *
699 * mime = image@slashjpeg 701 * mime = image@slashjpeg
700 * QStringList = 'image@slash*' 702 * QStringList = 'image@slash*'
701 * or QStringList = image/jpeg;image/png;application/x-ogg 703 * or QStringList = image/jpeg;image/png;application/x-ogg
702 * or QStringList = application/x-ogg;image@slash*; 704 * or QStringList = application/x-ogg;image@slash*;
703 * with all these mime filters it should get acceptes 705 * with all these mime filters it should get acceptes
704 * to do so we need to look if mime is contained inside 706 * to do so we need to look if mime is contained inside
705 * the stringlist 707 * the stringlist
706 * if it's contained return true 708 * if it's contained return true
707 * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' 709 * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*'
708 * is contained in the mimefilter and then we will 710 * is contained in the mimefilter and then we will
709 * look if both are equal until the '/' 711 * look if both are equal until the '/'
710 */ 712 */
711 713
712bool OFileViewFileListView::compliesMime( const QString& str) 714bool OFileViewFileListView::compliesMime( const QString& str)
713{ 715{
714 if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) 716 if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() )
715 return true; 717 return true;
716 718
717 for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) 719 for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it )
718 { 720 {
719 QRegExp reg( (*it) ); 721 QRegExp reg( (*it) );
720 reg.setWildcard( true ); 722 reg.setWildcard( true );
721 if ( str.find( reg ) != -1 ) 723 if ( str.find( reg ) != -1 )
722 return true; 724 return true;
723 725
724 } 726 }
725 return false; 727 return false;
726} 728}
727/* 729/*
728 * The listView giving access to the file system! 730 * The listView giving access to the file system!
729 */ 731 */
730 732
731class OFileViewFileSystem : public OFileViewInterface 733class OFileViewFileSystem : public OFileViewInterface
732{ 734{
733public: 735public:
734 OFileViewFileSystem( OFileSelector* ); 736 OFileViewFileSystem( OFileSelector* );
735 ~OFileViewFileSystem(); 737 ~OFileViewFileSystem();
736 738
737 QString selectedName() const; 739 QString selectedName() const;
738 QString selectedPath() const; 740 QString selectedPath() const;
739 741
740 QString directory()const; 742 QString directory()const;
741 void reread(); 743 void reread();
742 int fileCount()const; 744 int fileCount()const;
743 745
744 QWidget* widget( QWidget* parent ); 746 QWidget* widget( QWidget* parent );
745 void activate( const QString& ); 747 void activate( const QString& );
746private: 748private:
747 OFileViewFileListView* m_view; 749 OFileViewFileListView* m_view;
748 bool m_all : 1; 750 bool m_all : 1;
749}; 751};
750 752
751OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) 753OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel)
752 : OFileViewInterface( sel ) 754 : OFileViewInterface( sel )
753{ 755{
754 m_view = 0; 756 m_view = 0;
755 m_all = false; 757 m_all = false;
756} 758}
757 759
758OFileViewFileSystem::~OFileViewFileSystem() 760OFileViewFileSystem::~OFileViewFileSystem()
759{ 761{
760} 762}
761 763
762QString OFileViewFileSystem::selectedName()const 764QString OFileViewFileSystem::selectedName()const
763{ 765{
764 if (!m_view ) 766 if (!m_view )
765 return QString::null; 767 return QString::null;
766 768
767 QString cFN=currentFileName(); 769 QString cFN=currentFileName();
768 if (cFN.startsWith("/")) return cFN; 770 if (cFN.startsWith("/")) return cFN;
769 return m_view->currentDir() + "/" + cFN; 771 return m_view->currentDir() + "/" + cFN;
770} 772}
771 773
772QString OFileViewFileSystem::selectedPath()const 774QString OFileViewFileSystem::selectedPath()const
773{ 775{
774 return QString::null; 776 return QString::null;
775} 777}
776 778
777QString OFileViewFileSystem::directory()const 779QString OFileViewFileSystem::directory()const
778{ 780{
779 if (!m_view) 781 if (!m_view)
780 return QString::null; 782 return QString::null;
781 783
782 OFileSelectorItem* item = m_view->currentItem(); 784 OFileSelectorItem* item = m_view->currentItem();
783 if (!item ) 785 if (!item )
784 return QString::null; 786 return QString::null;
785 787
786 return QDir(item->directory() ).absPath(); 788 return QDir(item->directory() ).absPath();
787} 789}
788 790
789void OFileViewFileSystem::reread() 791void OFileViewFileSystem::reread()
790{ 792{
791 if (!m_view) 793 if (!m_view)
792 return; 794 return;
793 795
794 m_view->reread( m_all ); 796 m_view->reread( m_all );
795} 797}
796 798
797int OFileViewFileSystem::fileCount()const 799int OFileViewFileSystem::fileCount()const
798{ 800{
799 if (!m_view ) 801 if (!m_view )
800 return -1; 802 return -1;
801 return m_view->fileCount(); 803 return m_view->fileCount();
802} 804}
803 805
804QWidget* OFileViewFileSystem::widget( QWidget* parent ) 806QWidget* OFileViewFileSystem::widget( QWidget* parent )
805{ 807{
806 if (!m_view ) 808 if (!m_view )
807 { 809 {
808 m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); 810 m_view = new OFileViewFileListView( parent, startDirectory(), selector() );
809 } 811 }
810 return m_view; 812 return m_view;
811} 813}
812 814
813void OFileViewFileSystem::activate( const QString& str) 815void OFileViewFileSystem::activate( const QString& str)
814{ 816{
815 m_all = (str != QObject::tr("Files") ); 817 m_all = (str != QObject::tr("Files") );
816} 818}
817 819
818 820
819} 821}
820/* Selector */ 822/* Selector */
821/** 823/**
822 * @short new and complete c'tor 824 * @short new and complete c'tor
823 * 825 *
824 * Create a OFileSelector to let the user select a file. It can 826 * Create a OFileSelector to let the user select a file. It can
825 * either be used to open a file, select a save name in a dir or 827 * either be used to open a file, select a save name in a dir or
826 * as a dropin for the FileSelector. 828 * as a dropin for the FileSelector.
827 * 829 *
828 * <pre> 830 * <pre>
829 * QMap<QString, QStringList> mimeTypes; 831 * QMap<QString, QStringList> mimeTypes;
830 * QStringList types; 832 * QStringList types;
831 * types << "text@slash* "; 833 * types << "text@slash* ";
832 * types << "audio@slash*"; 834 * types << "audio@slash*";
833 * mimeTypes.insert( tr("Audio and Text"), types ); 835 * mimeTypes.insert( tr("Audio and Text"), types );
834 * mimeTypes.insert( tr("All"), "*@slash*); 836 * mimeTypes.insert( tr("All"), "*@slash*);
835 * 837 *
836 * now you could create your fileselector 838 * now you could create your fileselector
837 * </pre> 839 * </pre>
838 * 840 *
839 * 841 *
840 * @param parent the parent of this widget 842 * @param parent the parent of this widget
841 * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) 843 * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR)
842 * @param sel The selector to be used 844 * @param sel The selector to be used
843 * @param dirName The name of the dir to start int 845 * @param dirName The name of the dir to start int
844 * @param fileName The fileName placed in the fileselector lineedit 846 * @param fileName The fileName placed in the fileselector lineedit
845 * @param mimetypes The MimeType map of used mimetypes 847 * @param mimetypes The MimeType map of used mimetypes
846 * @param showNew Show a New Button. Most likely to be used in the FileSelector view. 848 * @param showNew Show a New Button. Most likely to be used in the FileSelector view.
847 * @param showClose Show a Close Button. Most likely to be used in FileSelector view. 849 * @param showClose Show a Close Button. Most likely to be used in FileSelector view.
848 * 850 *
849 */ 851 */
850OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, 852OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
851 const QString& dirName, const QString& fileName, 853 const QString& dirName, const QString& fileName,
852 const MimeTypes& mimetypes, 854 const MimeTypes& mimetypes,
853 bool showNew, bool showClose) 855 bool showNew, bool showClose)
854 :QWidget( parent, "OFileSelector" ) 856 :QWidget( parent, "OFileSelector" )
855{ 857{
856 m_current = 0; 858 m_current = 0;
857 m_shNew = showNew; 859 m_shNew = showNew;
858 m_shClose = showClose; 860 m_shClose = showClose;
859 m_mimeType = mimetypes; 861 m_mimeType = mimetypes;
860 m_startDir = dirName; 862 m_startDir = dirName;
861 863
862 m_mode = mode; 864 m_mode = mode;
863 m_selector = sel; 865 m_selector = sel;
864 866
865 initUI(); 867 initUI();
866 m_lneEdit->setText( fileName ); 868 m_lneEdit->setText( fileName );
867 initMime(); 869 initMime();
868 initViews(); 870 initViews();
869 871
870 QString str; 872 QString str;
871 switch ( m_selector ) 873 switch ( m_selector )
872 { 874 {
873 default: 875 default:
874 case Normal: 876 case Normal:
875 str = QObject::tr("Documents"); 877 str = QObject::tr("Documents");
876 m_cmbView->setCurrentItem( 0 ); 878 m_cmbView->setCurrentItem( 0 );
877 break; 879 break;
878 case Extended: 880 case Extended:
879 str = QObject::tr("Files"); 881 str = QObject::tr("Files");
880 m_cmbView->setCurrentItem( 1 ); 882 m_cmbView->setCurrentItem( 1 );
881 break; 883 break;
882 case ExtendedAll: 884 case ExtendedAll:
883 str = QObject::tr("All Files"); 885 str = QObject::tr("All Files");
884 m_cmbView->setCurrentItem( 2 ); 886 m_cmbView->setCurrentItem( 2 );
885 break; 887 break;
886 } 888 }
887 slotViewChange( str ); 889 slotViewChange( str );
888 890
889} 891}
890 892
891 893
892/** 894/**
893 * This a convience c'tor to just substitute the use of FileSelector 895 * This a convience c'tor to just substitute the use of FileSelector
894 */ 896 */
895OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, 897OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name,
896 bool showNew, bool showClose ) 898 bool showNew, bool showClose )
897 : QWidget( parent, name ) 899 : QWidget( parent, name )
898{ 900{
899 m_current = 0; 901 m_current = 0;
900 m_shNew = showNew; 902 m_shNew = showNew;
901 m_shClose = showClose; 903 m_shClose = showClose;
902 m_startDir = QPEApplication::documentDir(); 904 m_startDir = QPEApplication::documentDir();
903 905
904 if (!mimeFilter.isEmpty() ) 906 if (!mimeFilter.isEmpty() )
905 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); 907 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) );
906 908
907 m_mode = OFileSelector::FileSelector; 909 m_mode = OFileSelector::FileSelector;
908 m_selector = OFileSelector::Normal; 910 m_selector = OFileSelector::Normal;
909 911
910 initUI(); 912 initUI();
911 initMime(); 913 initMime();
912 initViews(); 914 initViews();
913 m_cmbView->setCurrentItem( 0 ); 915 m_cmbView->setCurrentItem( 0 );
914 slotViewChange( QObject::tr("Documents") ); 916 slotViewChange( QObject::tr("Documents") );
915} 917}
916 918
917/* 919/*
918 * INIT UI will set up the basic GUI 920 * INIT UI will set up the basic GUI
919 * Layout: Simple VBoxLayout 921 * Layout: Simple VBoxLayout
920 * On top a WidgetStack containing the Views... 922 * On top a WidgetStack containing the Views...
921 * - List View 923 * - List View
922 * - Document View 924 * - Document View
923 * Below we will have a Label + LineEdit 925 * Below we will have a Label + LineEdit
924 * Below we will have two ComoBoxes one for choosing the view one for 926 * Below we will have two ComoBoxes one for choosing the view one for
925 * choosing the mimetype 927 * choosing the mimetype
926 */ 928 */
927void OFileSelector::initUI() 929void OFileSelector::initUI()
928{ 930{
929 QVBoxLayout* lay = new QVBoxLayout( this ); 931 QVBoxLayout* lay = new QVBoxLayout( this );
930 932
931 m_stack = new QWidgetStack( this ); 933 m_stack = new QWidgetStack( this );
932 lay->addWidget( m_stack, 1000 ); 934 lay->addWidget( m_stack, 1000 );
933 935
934 m_nameBox = new QHBox( this ); 936 m_nameBox = new QHBox( this );
935 (void)new QLabel( tr("Name:"), m_nameBox ); 937 (void)new QLabel( tr("Name:"), m_nameBox );
936 m_lneEdit = new QLineEdit( m_nameBox ); 938 m_lneEdit = new QLineEdit( m_nameBox );
937 m_lneEdit ->installEventFilter(this); 939 m_lneEdit ->installEventFilter(this);
938 lay->addWidget( m_nameBox ); 940 lay->addWidget( m_nameBox );
939 941
940 m_cmbBox = new QHBox( this ); 942 m_cmbBox = new QHBox( this );
941 m_cmbView = new QComboBox( m_cmbBox ); 943 m_cmbView = new QComboBox( m_cmbBox );
942 m_cmbMime = new QComboBox( m_cmbBox ); 944 m_cmbMime = new QComboBox( m_cmbBox );
943 lay->addWidget( m_cmbBox ); 945 lay->addWidget( m_cmbBox );
944} 946}
945 947
946/* 948/*
947 * This will make sure that the return key in the name edit causes dialogs to close 949 * This will make sure that the return key in the name edit causes dialogs to close
948 */ 950 */
949 951
950bool OFileSelector::eventFilter (QObject *o, QEvent *e) 952bool OFileSelector::eventFilter (QObject *, QEvent *e)
951{ 953{
952 if ( e->type() == QEvent::KeyPress ) 954 if ( e->type() == QEvent::KeyPress )
953 { 955 {
954 QKeyEvent *k = (QKeyEvent *)e; 956 QKeyEvent *k = (QKeyEvent *)e;
955 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 957 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
956 { 958 {
957 emit ok(); 959 emit ok();
958 return true; 960 return true;
959 } 961 }
960 } 962 }
961 return false; 963 return false;
962} 964}
963 965
964/* 966/*
965 * This will insert the MimeTypes into the Combo Box 967 * This will insert the MimeTypes into the Combo Box
966 * And also connect the changed signal 968 * And also connect the changed signal
967 * 969 *
968 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes 970 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes
969 */ 971 */
970void OFileSelector::initMime() 972void OFileSelector::initMime()
971{ 973{
972 MimeTypes::Iterator it; 974 MimeTypes::Iterator it;
973 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) 975 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it )
974 { 976 {
975 m_cmbMime->insertItem( it.key() ); 977 m_cmbMime->insertItem( it.key() );
976 } 978 }
977 m_cmbMime->setCurrentItem( 0 ); 979 m_cmbMime->setCurrentItem( 0 );
978 980
979 connect( m_cmbMime, SIGNAL(activated(int) ), 981 connect( m_cmbMime, SIGNAL(activated(int) ),
980 this, SLOT(slotMimeTypeChanged() ) ); 982 this, SLOT(slotMimeTypeChanged() ) );
981 983
982} 984}
983 985
984void OFileSelector::initViews() 986void OFileSelector::initViews()
985{ 987{
986 m_cmbView->insertItem( QObject::tr("Documents") ); 988 m_cmbView->insertItem( QObject::tr("Documents") );
987 m_cmbView->insertItem( QObject::tr("Files") ); 989 m_cmbView->insertItem( QObject::tr("Files") );
988 m_cmbView->insertItem( QObject::tr("All Files") ); 990 m_cmbView->insertItem( QObject::tr("All Files") );
989 connect(m_cmbView, SIGNAL(activated(const QString&) ), 991 connect(m_cmbView, SIGNAL(activated(const QString&) ),
990 this, SLOT(slotViewChange(const QString&) ) ); 992 this, SLOT(slotViewChange(const QString&) ) );
991 993
992 994
993 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); 995 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
994 996
995 /* see above why add both */ 997 /* see above why add both */
996 OFileViewInterface* in = new OFileViewFileSystem( this ); 998 OFileViewInterface* in = new OFileViewFileSystem( this );
997 m_views.insert( QObject::tr("Files"), in ); 999 m_views.insert( QObject::tr("Files"), in );
998 m_views.insert( QObject::tr("All Files"), in ); 1000 m_views.insert( QObject::tr("All Files"), in );
999} 1001}
1000 1002
1003void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) {
1004 m_viewsPtr.append( iface );
1005}
1006
1007
1001/** 1008/**
1002 * d'tor 1009 * d'tor
1003 */ 1010 */
1004OFileSelector::~OFileSelector() 1011OFileSelector::~OFileSelector()
1005{ 1012{
1013 m_viewsPtr.setAutoDelete( true );
1014 m_viewsPtr.clear();
1006} 1015}
1007 1016
1008 1017
1009 1018
1010/** 1019/**
1011 * Convience function for the fileselector 1020 * Convience function for the fileselector
1012 * make sure to delete the DocLnk 1021 * make sure to delete the DocLnk
1013 * 1022 *
1014 * @see DocLnk 1023 * @see DocLnk
1015 * @todo remove in ODP 1024 * @todo remove in ODP
1016 */ 1025 */
1017const DocLnk* OFileSelector::selected() 1026const DocLnk* OFileSelector::selected()
1018{ 1027{
1019 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); 1028 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() );
1020 return lnk; 1029 return lnk;
1021} 1030}
1022 1031
1023/** 1032/**
1024 * 1033 *
1025 * @return the name of the selected file 1034 * @return the name of the selected file
1026 */ 1035 */
1027QString OFileSelector::selectedName()const 1036QString OFileSelector::selectedName()const
1028{ 1037{
1029 return currentView()->selectedName(); 1038 return currentView()->selectedName();
1030} 1039}
1031 1040
1032 1041
1033/** 1042/**
1034 * @return the selected path 1043 * @return the selected path
1035 */ 1044 */
1036QString OFileSelector::selectedPath()const 1045QString OFileSelector::selectedPath()const
1037{ 1046{
1038 return currentView()->selectedPath(); 1047 return currentView()->selectedPath();
1039} 1048}
1040 1049
1041/** 1050/**
1042 * @return the directory name 1051 * @return the directory name
1043 */ 1052 */
1044QString OFileSelector::directory()const 1053QString OFileSelector::directory()const
1045{ 1054{
1046 return currentView()->directory(); 1055 return currentView()->directory();
1047} 1056}
1048 1057
1049/** 1058/**
1050 * @return a DocLnk for the selected document 1059 * @return a DocLnk for the selected document
1051 */ 1060 */
1052DocLnk OFileSelector::selectedDocument()const 1061DocLnk OFileSelector::selectedDocument()const
1053{ 1062{
1054 return currentView()->selectedDocument(); 1063 return currentView()->selectedDocument();
1055} 1064}
1056 1065
1057/** 1066/**
1058 * @return the number of items for the current view 1067 * @return the number of items for the current view
1059 */ 1068 */
1060int OFileSelector::fileCount()const 1069int OFileSelector::fileCount()const
1061{ 1070{
1062 return currentView()->fileCount(); 1071 return currentView()->fileCount();
1063} 1072}
1064 1073
1065/** 1074/**
1066 * @return reparse the file content 1075 * @return reparse the file content
1067 */ 1076 */
1068void OFileSelector::reread() 1077void OFileSelector::reread()
1069{ 1078{
1070 return currentView()->reread(); 1079 return currentView()->reread();
1071} 1080}
1072 1081
1073OFileViewInterface* OFileSelector::currentView()const 1082OFileViewInterface* OFileSelector::currentView()const
1074{ 1083{
1075 return m_current; 1084 return m_current;
1076} 1085}
1077 1086
1078bool OFileSelector::showNew()const 1087bool OFileSelector::showNew()const
1079{ 1088{
1080 return m_shNew; 1089 return m_shNew;
1081} 1090}
1082 1091
1083bool OFileSelector::showClose()const 1092bool OFileSelector::showClose()const
1084{ 1093{
1085 return m_shClose; 1094 return m_shClose;
1086} 1095}
1087 1096
1088MimeTypes OFileSelector::mimeTypes()const 1097MimeTypes OFileSelector::mimeTypes()const
1089{ 1098{
1090 return m_mimeType; 1099 return m_mimeType;
1091} 1100}
1092 1101
1093/** 1102/**
1094 * @return the Mode of the OFileSelector 1103 * @return the Mode of the OFileSelector
1095 */ 1104 */
1096int OFileSelector::mode()const 1105int OFileSelector::mode()const
1097{ 1106{
1098 return m_mode; 1107 return m_mode;
1099} 1108}
1100 1109
1101 1110
1102/** 1111/**
1103 * @return the Selector of the OFileSelector 1112 * @return the Selector of the OFileSelector
1104 */ 1113 */
1105int OFileSelector::selector()const 1114int OFileSelector::selector()const
1106{ 1115{
1107 return m_selector; 1116 return m_selector;
1108} 1117}
1109 1118
1110QStringList OFileSelector::currentMimeType()const 1119QStringList OFileSelector::currentMimeType()const
1111{ 1120{
1112 return m_mimeType[m_cmbMime->currentText()]; 1121 return m_mimeType[m_cmbMime->currentText()];
1113} 1122}
1114 1123
1115void OFileSelector::slotMimeTypeChanged() 1124void OFileSelector::slotMimeTypeChanged()
1116{ 1125{
1117 reread(); 1126 reread();
1118} 1127}
1119 1128
1120void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) 1129void OFileSelector::slotDocLnkBridge( const DocLnk& lnk)
1121{ 1130{
1122 m_lneEdit->setText( lnk.name() ); 1131 m_lneEdit->setText( lnk.name() );
1123 emit fileSelected( lnk ); 1132 emit fileSelected( lnk );
1124 emit fileSelected( lnk.name() ); 1133 emit fileSelected( lnk.name() );
1125} 1134}
1126 1135
1127void OFileSelector::slotFileBridge( const QString& str) 1136void OFileSelector::slotFileBridge( const QString& str)
1128{ 1137{
1129 DocLnk lnk( str ); 1138 DocLnk lnk( str );
1130 emit fileSelected( lnk ); 1139 emit fileSelected( lnk );
1131} 1140}
1132 1141
1133void OFileSelector::slotViewChange( const QString& view ) 1142void OFileSelector::slotViewChange( const QString& view )
1134{ 1143{
1135 OFileViewInterface* interface = m_views[view]; 1144 OFileViewInterface* interface = m_views[view];
1136 if (!interface) 1145 if (!interface)
1137 return; 1146 return;
1138 1147
1139 interface->activate( view ); 1148 interface->activate( view );
1140 if (m_current) 1149 if (m_current)
1141 m_stack->removeWidget( m_current->widget( m_stack ) ); 1150 m_stack->removeWidget( m_current->widget( m_stack ) );
1142 1151
1143 static int id = 1; 1152 static int id = 1;
1144 1153
1145 m_stack->addWidget( interface->widget(m_stack), id ); 1154 m_stack->addWidget( interface->widget(m_stack), id );
1146 m_stack->raiseWidget( id ); 1155 m_stack->raiseWidget( id );
1147 1156
1148 interface->reread(); 1157 interface->reread();
1149 m_current = interface; 1158 m_current = interface;
1150 1159
1151 id++; 1160 id++;
1152} 1161}
1153 1162
1154void OFileSelector::setNewVisible( bool b ) 1163void OFileSelector::setNewVisible( bool b )
1155{ 1164{
1156 m_shNew = b; 1165 m_shNew = b;
1157 currentView()->reread(); 1166 currentView()->reread();
1158} 1167}
1159 1168
1160void OFileSelector::setCloseVisible( bool b ) 1169void OFileSelector::setCloseVisible( bool b )
1161{ 1170{
1162 m_shClose = b; 1171 m_shClose = b;
1163 currentView()->reread(); 1172 currentView()->reread();
1164} 1173}
1165 1174
1166void OFileSelector::setNameVisible( bool b ) 1175void OFileSelector::setNameVisible( bool b )
1167{ 1176{
1168 if ( b ) 1177 if ( b )
1169 m_nameBox->show(); 1178 m_nameBox->show();
1170 else 1179 else
1171 m_nameBox->hide(); 1180 m_nameBox->hide();
1172} 1181}
1173 1182
1174} 1183}
1175} 1184}
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h
index 8bcd9ee..de2b98a 100644
--- a/libopie2/opieui/fileselector/ofileselector.h
+++ b/libopie2/opieui/fileselector/ofileselector.h
@@ -1,222 +1,232 @@
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 Holger Freyther <zecke@handhelds.org> 3             .=l. Copyright (C) 2002,2003 Holger Freyther <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/* 29/*
30 This is based on code and ideas of 30 This is based on code and ideas of
31 L. J. Potter ljp@llornkcor.com 31 L. J. Potter ljp@llornkcor.com
32 Thanks a lot 32 Thanks a lot
33*/ 33*/
34 34
35#ifndef OFILESELECTOR_H 35#ifndef OFILESELECTOR_H
36#define OFILESELECTOR_H 36#define OFILESELECTOR_H
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/applnk.h> 39#include <qpe/applnk.h>
40 40
41/* QT */ 41/* QT */
42#include <qlist.h> 42#include <qlist.h>
43#include <qwidget.h> 43#include <qwidget.h>
44#include <qmap.h> 44#include <qmap.h>
45#include <qvaluelist.h> 45#include <qvaluelist.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47#include <qlist.h>
47 48
48class QLineEdit; 49class QLineEdit;
49class QComboBox; 50class QComboBox;
50class QWidgetStack; 51class QWidgetStack;
51class QHBox; 52class QHBox;
52 53
53typedef QMap<QString, QStringList> MimeTypes; 54typedef QMap<QString, QStringList> MimeTypes;
54 55
55namespace Opie { 56namespace Opie {
56namespace Ui { 57namespace Ui {
57 58
58namespace Internal { 59namespace Internal {
59class OFileViewInterface; 60class OFileViewInterface;
60class OFileViewFileListView; 61class OFileViewFileListView;
61} 62}
62 63
63 64
64/** 65/**
65 * @short a dropin replacement for the FileSelector 66 * @short a dropin replacement for the FileSelector
66 * 67 *
67 * This class is first used insert the OFileDialog. 68 * This class is first used insert the OFileDialog.
68 * It supports multiple view and mimetype filtering for now. 69 * It supports multiple view and mimetype filtering for now.
69 * 70 *
70 * @see OFileDialog 71 * @see OFileDialog
71 * @see FileSelector 72 * @see FileSelector
72 * @author zecke 73 * @author zecke
73 * @version 0.1 74 * @version 0.1
74 */ 75 */
75class OFileSelector : public QWidget 76class OFileSelector : public QWidget
76{ 77{
77 Q_OBJECT 78 Q_OBJECT
78 friend class Internal::OFileViewInterface; 79 friend class Internal::OFileViewInterface;
79 friend class Internal::OFileViewFileListView; 80 friend class Internal::OFileViewFileListView;
80 81
81public: 82public:
82 /** 83 /**
83 * The Mode of the Fileselector 84 * The Mode of the Fileselector
84 * Open = Open A File 85 * Open = Open A File
85 * Save = Save a File 86 * Save = Save a File
86 * FILESELECTOR = As A GUI in a screen to select a file 87 * FILESELECTOR = As A GUI in a screen to select a file
87 */ 88 */
88 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; 89 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 };
89 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; 90 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
90 /** 91 /**
91 * Normal = The old FileSelector 92 * Normal = The old FileSelector
92 * Extended = Dir View 93 * Extended = Dir View
93 * ExtendedAll = Dir View with all hidden files 94 * ExtendedAll = Dir View with all hidden files
94 * Default = What the vendor considers best 95 * Default = What the vendor considers best
95 */ 96 */
96 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; 97 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
97 // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; 98 // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2};
98 99
99 OFileSelector(QWidget* parent, int mode, int selector, 100 OFileSelector(QWidget* parent, int mode, int selector,
100 const QString& dirName, 101 const QString& dirName,
101 const QString& fileName, 102 const QString& fileName,
102 const MimeTypes& mimetypes = MimeTypes(), 103 const MimeTypes& mimetypes = MimeTypes(),
103 bool newVisible = FALSE, bool closeVisible = FALSE ); 104 bool newVisible = FALSE, bool closeVisible = FALSE );
104 105
105 OFileSelector(const QString& mimeFilter, QWidget* parent, 106 OFileSelector(const QString& mimeFilter, QWidget* parent,
106 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); 107 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE );
107 ~OFileSelector(); 108 ~OFileSelector();
108 109
109 const DocLnk* selected(); 110 const DocLnk* selected();
110 111
111 QString selectedName()const; 112 QString selectedName()const;
112 QString selectedPath()const; 113 QString selectedPath()const;
113 QString directory()const; 114 QString directory()const;
114 115
115 DocLnk selectedDocument()const; 116 DocLnk selectedDocument()const;
116 117
117 int fileCount()const; 118 int fileCount()const;
118 void reread(); 119 void reread();
119 120
120 int mode()const; 121 int mode()const;
121 int selector()const; 122 int selector()const;
122 123
123 /** 124 /**
124 * Set the Icon visible 125 * Set the Icon visible
125 * @param b Show or Hide the New Button 126 * @param b Show or Hide the New Button
126 */ 127 */
127 void setNewVisible( bool b ); 128 void setNewVisible( bool b );
128 129
129 /** 130 /**
130 * Set the Icon visible 131 * Set the Icon visible
131 */ 132 */
132 void setCloseVisible( bool b ); 133 void setCloseVisible( bool b );
133 134
134 /** 135 /**
135 * Set the Name Line visible 136 * Set the Name Line visible
136 */ 137 */
137 void setNameVisible( bool b ); 138 void setNameVisible( bool b );
138 139
139signals: 140signals:
140 /** 141 /**
141 * dirSelected is emitted whenever changed into a different dir 142 * dirSelected is emitted whenever changed into a different dir
142 */ 143 */
143 void dirSelected( const QString& ); 144 void dirSelected( const QString& );
144 145
145 /** 146 /**
146 * fileSelected is emitted when a file is selected 147 * fileSelected is emitted when a file is selected
147 * it uses a DocLnk as parameter 148 * it uses a DocLnk as parameter
148 */ 149 */
149 void fileSelected( const DocLnk& ); 150 void fileSelected( const DocLnk& );
150 151
151 /** 152 /**
152 * fileSelected is emitted when a file is selected 153 * fileSelected is emitted when a file is selected
153 * the complete path is a parameter 154 * the complete path is a parameter
154 */ 155 */
155 void fileSelected( const QString& ); 156 void fileSelected( const QString& );
156 157
157 /** 158 /**
158 * Create a new File with a DocLnk 159 * Create a new File with a DocLnk
159 */ 160 */
160 void newSelected( const DocLnk& ); 161 void newSelected( const DocLnk& );
161 162
162 void closeMe(); 163 void closeMe();
163 164
164 /** 165 /**
165 * Ok is emitted on a Qt::Key_Return or Q::Key_Enter 166 * Ok is emitted on a Qt::Key_Return or Q::Key_Enter
166 * in the line edit 167 * in the line edit
167 */ 168 */
168 void ok(); 169 void ok();
169 void cancel(); 170 void cancel();
170 171
171 /* used by the ViewInterface */ 172 /* used by the ViewInterface */
172private: 173private:
173 bool showNew()const; 174 bool showNew()const;
174 bool showClose()const; 175 bool showClose()const;
175 MimeTypes mimeTypes()const; 176 MimeTypes mimeTypes()const;
176 QStringList currentMimeType()const; 177 QStringList currentMimeType()const;
177 178
178private: 179private:
179 /* inits the Widgets */ 180 /* inits the Widgets */
180 void initUI(); 181 void initUI();
181 /* inits the MimeType ComboBox content + connects signals and slots */ 182 /* inits the MimeType ComboBox content + connects signals and slots */
182 void initMime(); 183 void initMime();
183 /* init the Views :) */ 184 /* init the Views :) */
184 void initViews(); 185 void initViews();
185 186
187
188 /*
189 * register a view for deletion.
190 * This happens on creation of a OFileViewInterface
191 */
192 void registerView( const Internal::OFileViewInterface* );
193
186private: 194private:
187 QLineEdit* m_lneEdit; // the LineEdit for the Name 195 QLineEdit* m_lneEdit; // the LineEdit for the Name
188 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType 196 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
189 QWidgetStack* m_stack; // our widget stack which will contain the views 197 QWidgetStack* m_stack; // our widget stack which will contain the views
190 Internal::OFileViewInterface* currentView() const; // returns the currentView 198 Internal::OFileViewInterface* currentView() const; // returns the currentView
191 Internal::OFileViewInterface* m_current; // here is the view saved 199 Internal::OFileViewInterface* m_current; // here is the view saved
192 bool m_shNew : 1; // should we show New? 200 bool m_shNew : 1; // should we show New?
193 bool m_shClose : 1; // should we show Close? 201 bool m_shClose : 1; // should we show Close?
194 MimeTypes m_mimeType; // list of mimetypes 202 MimeTypes m_mimeType; // list of mimetypes
195 203
196 QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr 204 QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
205 /* views register themselves automatically */
206 QList<Internal::OFileViewInterface> m_viewsPtr;
197 QHBox* m_nameBox; // the LineEdit + Label is hold here 207 QHBox* m_nameBox; // the LineEdit + Label is hold here
198 QHBox* m_cmbBox; // this holds the two combo boxes 208 QHBox* m_cmbBox; // this holds the two combo boxes
199 209
200 QString m_startDir; 210 QString m_startDir;
201 int m_mode; 211 int m_mode;
202 int m_selector; 212 int m_selector;
203 213
204 struct Data; // used for future versions 214 struct Data; // used for future versions
205 Data *d; 215 Data *d;
206 216
207private slots: 217private slots:
208 void slotMimeTypeChanged(); 218 void slotMimeTypeChanged();
209 219
210 /* will set the text of the lineedit and emit a fileChanged signal */ 220 /* will set the text of the lineedit and emit a fileChanged signal */
211 void slotDocLnkBridge( const DocLnk& ); 221 void slotDocLnkBridge( const DocLnk& );
212 void slotFileBridge( const QString& ); 222 void slotFileBridge( const QString& );
213 void slotViewChange( const QString& ); 223 void slotViewChange( const QString& );
214 224
215 bool eventFilter (QObject *o, QEvent *e); 225 bool eventFilter (QObject *o, QEvent *e);
216 226
217}; 227};
218 228
219} 229}
220} 230}
221 231
222#endif 232#endif