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