summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2002-10-13 19:02:48 (UTC)
committer zecke <zecke>2002-10-13 19:02:48 (UTC)
commita469689def798954c0f571a00cc52e87d6b008ce (patch) (unidiff)
tree410514b96d2951c6a8c29c26e21660094dd14bbd /libopie
parent130ae6144e031b4de2244990c53df8654bd840ae (diff)
downloadopie-a469689def798954c0f571a00cc52e87d6b008ce.zip
opie-a469689def798954c0f571a00cc52e87d6b008ce.tar.gz
opie-a469689def798954c0f571a00cc52e87d6b008ce.tar.bz2
Fix a Crash when using All Files.. as name and default() returns 0l
Fix a Crash in reparse when the chooser is not yet initialized
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector/ofileselector.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp
index 7f38f5b..4ab744c 100644
--- a/libopie/ofileselector/ofileselector.cpp
+++ b/libopie/ofileselector/ofileselector.cpp
@@ -1,1100 +1,1100 @@
1 1
2 2
3#include <qcheckbox.h> 3#include <qcheckbox.h>
4#include <qcombobox.h> 4#include <qcombobox.h>
5#include <qheader.h> 5#include <qheader.h>
6#include <qlabel.h> 6#include <qlabel.h>
7#include <qabstractlayout.h> 7#include <qabstractlayout.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qlistview.h> 10#include <qlistview.h>
11#include <qmessagebox.h> 11#include <qmessagebox.h>
12#include <qpainter.h> 12#include <qpainter.h>
13#include <qpushbutton.h> 13#include <qpushbutton.h>
14#include <qwidgetstack.h> 14#include <qwidgetstack.h>
15#include <qpopupmenu.h> 15#include <qpopupmenu.h>
16#include <qdir.h> 16#include <qdir.h>
17#include <qfile.h> 17#include <qfile.h>
18#include <qfileinfo.h> 18#include <qfileinfo.h>
19#include <qtimer.h> 19#include <qtimer.h>
20 20
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qpe/applnk.h> 22#include <qpe/applnk.h>
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/mimetype.h> 24#include <qpe/mimetype.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/storage.h> 26#include <qpe/storage.h>
27 27
28#include <unistd.h> 28#include <unistd.h>
29#include <stdlib.h> 29#include <stdlib.h>
30#include <sys/stat.h> 30#include <sys/stat.h>
31 31
32#include "ofileview.h" 32#include "ofileview.h"
33#include "ofileselectormain.h" 33#include "ofileselectormain.h"
34#include "ofileselector.h" 34#include "ofileselector.h"
35#include "olocallister.h" 35#include "olocallister.h"
36#include "olister.h" 36#include "olister.h"
37#include "odefaultfactories.h" 37#include "odefaultfactories.h"
38 38
39QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; 39QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
40 40
41namespace { 41namespace {
42 /* let's find the index for a specified string */ 42 /* let's find the index for a specified string */
43 int indexByString( const QComboBox *box, const QString &str ){ 43 int indexByString( const QComboBox *box, const QString &str ){
44 int index= 0; 44 int index= 0;
45 for(int i= 0; i < box->count(); i++ ){ 45 for(int i= 0; i < box->count(); i++ ){
46 /* found */ 46 /* found */
47 if( str == box->text(i ) ){ 47 if( str == box->text(i ) ){
48 index= i; 48 index= i;
49 break; 49 break;
50 } 50 }
51 } 51 }
52 return index; 52 return index;
53 } 53 }
54} 54}
55 55
56OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, 56OFileSelector::OFileSelector( QWidget *wid, int mode, int selector,
57 const QString &dirName, 57 const QString &dirName,
58 const QString &fileName, 58 const QString &fileName,
59 const QMap<QString,QStringList>& mimeTypes) 59 const QMap<QString,QStringList>& mimeTypes)
60 : QWidget( wid, "OFileSelector") 60 : QWidget( wid, "OFileSelector")
61{ 61{
62 m_mimetypes = mimeTypes; 62 m_mimetypes = mimeTypes;
63 if (mode == Save ) 63 if (mode == Save )
64 m_name = fileName; 64 m_name = fileName;
65 65
66 initVars(); 66 initVars();
67 67
68 m_mode = mode; 68 m_mode = mode;
69 m_selector = selector; 69 m_selector = selector;
70 m_currentDir = dirName; 70 m_currentDir = dirName;
71 init(); 71 init();
72} 72}
73 73
74OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, 74OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent,
75 const char *name, bool newVisible, 75 const char *name, bool newVisible,
76 bool closeVisible ) 76 bool closeVisible )
77 : QWidget( parent, name ) 77 : QWidget( parent, name )
78{ 78{
79 /* update the mimefilter */ 79 /* update the mimefilter */
80 if (!mimeFilter.isEmpty() ) { 80 if (!mimeFilter.isEmpty() ) {
81 QStringList list = QStringList::split(";", mimeFilter ); 81 QStringList list = QStringList::split(";", mimeFilter );
82 m_mimetypes.insert(mimeFilter, list ); 82 m_mimetypes.insert(mimeFilter, list );
83 } 83 }
84 initVars(); 84 initVars();
85 m_currentDir = QPEApplication::documentDir(); 85 m_currentDir = QPEApplication::documentDir();
86 m_mode = Fileselector; 86 m_mode = Fileselector;
87 m_selector = Normal; 87 m_selector = Normal;
88 m_shClose = closeVisible; 88 m_shClose = closeVisible;
89 m_shNew = newVisible; 89 m_shNew = newVisible;
90 m_shLne = false; 90 m_shLne = false;
91 m_shPerm = false; 91 m_shPerm = false;
92 m_shYesNo = false; 92 m_shYesNo = false;
93 init(); 93 init();
94 94
95 95
96} 96}
97 97
98OFileSelector::~OFileSelector() 98OFileSelector::~OFileSelector()
99{ 99{
100 100
101 101
102} 102}
103 103
104void OFileSelector::setNewVisible( bool visible ) 104void OFileSelector::setNewVisible( bool visible )
105{ 105{
106 m_shNew = visible; 106 m_shNew = visible;
107 if (m_new ) 107 if (m_new )
108 m_new->show(); 108 m_new->show();
109} 109}
110void OFileSelector::setCloseVisible( bool visible ) 110void OFileSelector::setCloseVisible( bool visible )
111{ 111{
112 m_shClose = visible; 112 m_shClose = visible;
113 113
114 if( m_close ) 114 if( m_close )
115 m_close->show(); 115 m_close->show();
116} 116}
117void OFileSelector::reread() 117void OFileSelector::reread()
118{ 118{
119 if( m_selector == Normal ) 119 if( m_selector == Normal )
120 initializeOldSelector(); 120 initializeOldSelector();
121 else 121 else
122 reparse(); 122 reparse();
123} 123}
124 124
125const DocLnk *OFileSelector::selected() 125const DocLnk *OFileSelector::selected()
126{ 126{
127 DocLnk *lnk = new DocLnk(selectedDocument() ); 127 DocLnk *lnk = new DocLnk(selectedDocument() );
128 return lnk; 128 return lnk;
129} 129}
130 130
131void OFileSelector::setYesCancelVisible( bool show ) 131void OFileSelector::setYesCancelVisible( bool show )
132{ 132{
133 initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( 133 initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :(
134 m_shYesNo = show; 134 m_shYesNo = show;
135 135
136 if( m_shYesNo ) 136 if( m_shYesNo )
137 m_boxOk->show(); 137 m_boxOk->show();
138 else 138 else
139 m_boxOk->hide(); 139 m_boxOk->hide();
140 140
141} 141}
142void OFileSelector::setToolbarVisible( bool show ) 142void OFileSelector::setToolbarVisible( bool show )
143{ 143{
144 m_shTool = show; 144 m_shTool = show;
145 145
146 if(!m_shTool ){ 146 if(!m_shTool ){
147 m_location->hide(); 147 m_location->hide();
148 m_up->hide(); 148 m_up->hide();
149 m_homeButton->hide(); 149 m_homeButton->hide();
150 m_docButton->hide(); 150 m_docButton->hide();
151 }else{ 151 }else{
152 m_location->show(); 152 m_location->show();
153 m_up->show(); 153 m_up->show();
154 m_homeButton->show(); 154 m_homeButton->show();
155 m_docButton->show(); 155 m_docButton->show();
156 } 156 }
157} 157}
158void OFileSelector::setPermissionBarVisible( bool show ) 158void OFileSelector::setPermissionBarVisible( bool show )
159{ 159{
160 m_shPerm = show; 160 m_shPerm = show;
161 initializePerm(); 161 initializePerm();
162 162
163 if( m_shPerm ) 163 if( m_shPerm )
164 m_checkPerm->show(); 164 m_checkPerm->show();
165 else 165 else
166 m_checkPerm->hide(); 166 m_checkPerm->hide();
167} 167}
168void OFileSelector::setLineEditVisible( bool show ) 168void OFileSelector::setLineEditVisible( bool show )
169{ 169{
170 if( show ){ 170 if( show ){
171 initializeName(); 171 initializeName();
172 m_boxName->show(); 172 m_boxName->show();
173 }else{ 173 }else{
174 // check if we showed before this is the way to go 174 // check if we showed before this is the way to go
175 if( m_shLne && m_boxName != 0 ) 175 if( m_shLne && m_boxName != 0 )
176 m_boxName->hide(); 176 m_boxName->hide();
177 } 177 }
178 m_shLne = show; 178 m_shLne = show;
179} 179}
180 180
181void OFileSelector::setChooserVisible( bool show ) 181void OFileSelector::setChooserVisible( bool show )
182{ 182{
183 m_shChooser = show; 183 m_shChooser = show;
184 initializeChooser(); 184 initializeChooser();
185 185
186 if( m_shChooser ) 186 if( m_shChooser )
187 m_boxView->hide(); 187 m_boxView->hide();
188 else 188 else
189 m_boxView->show(); 189 m_boxView->show();
190 190
191} 191}
192 192
193QCheckBox* OFileSelector::permissionCheckbox() 193QCheckBox* OFileSelector::permissionCheckbox()
194{ 194{
195 if( m_selector == Normal ) 195 if( m_selector == Normal )
196 return 0l; 196 return 0l;
197 else 197 else
198 return m_checkPerm; 198 return m_checkPerm;
199} 199}
200bool OFileSelector::setPermission()const 200bool OFileSelector::setPermission()const
201{ 201{
202 return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); 202 return m_checkPerm == 0 ? false : m_checkPerm->isChecked();
203} 203}
204void OFileSelector::setPermissionChecked( bool check ) 204void OFileSelector::setPermissionChecked( bool check )
205{ 205{
206 if( m_checkPerm ) 206 if( m_checkPerm )
207 m_checkPerm->setChecked( check ); 207 m_checkPerm->setChecked( check );
208} 208}
209 209
210void OFileSelector::setMode(int mode) // FIXME do direct raising 210void OFileSelector::setMode(int mode) // FIXME do direct raising
211{ 211{
212 m_mode = mode; 212 m_mode = mode;
213 if( m_selector == Normal ) 213 if( m_selector == Normal )
214 return; 214 return;
215} 215}
216void OFileSelector::setShowDirs(bool dir) 216void OFileSelector::setShowDirs(bool dir)
217{ 217{
218 m_dir = dir; 218 m_dir = dir;
219 if ( m_selector != Fileselector ) 219 if ( m_selector != Fileselector )
220 reparse(); 220 reparse();
221} 221}
222void OFileSelector::setCaseSensetive(bool caSe ) 222void OFileSelector::setCaseSensetive(bool caSe )
223{ 223{
224 m_case = caSe; 224 m_case = caSe;
225 225
226 if ( m_selector != Fileselector ) 226 if ( m_selector != Fileselector )
227 reparse(); 227 reparse();
228} 228}
229void OFileSelector::setShowFiles(bool show ) 229void OFileSelector::setShowFiles(bool show )
230{ 230{
231 m_files = show; 231 m_files = show;
232 reparse(); 232 reparse();
233} 233}
234/// 234///
235bool OFileSelector::cd(const QString &path ) 235bool OFileSelector::cd(const QString &path )
236{ 236{
237 m_currentDir = path; 237 m_currentDir = path;
238 reparse(); 238 reparse();
239 return true; 239 return true;
240} 240}
241void OFileSelector::setSelector(int mode ) 241void OFileSelector::setSelector(int mode )
242{ 242{
243 QString text; 243 QString text;
244 switch( mode ){ 244 switch( mode ){
245 case Normal: 245 case Normal:
246 text = tr("Documents"); 246 text = tr("Documents");
247 break; 247 break;
248 case Extended: 248 case Extended:
249 text = tr("Files"); 249 text = tr("List View");
250 break; 250 break;
251 case ExtendedAll: 251 case ExtendedAll:
252 text = tr("All Files"); 252 text = tr("All List View");
253 break; 253 break;
254 } 254 }
255 slotViewCheck( text ); 255 slotViewCheck( text );
256} 256}
257 257
258void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) 258void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ )
259{ 259{
260/* m_custom = popup; 260/* m_custom = popup;
261 m_showPopup = true; 261 m_showPopup = true;
262*/ 262*/
263} 263}
264 264
265//void OFileSelector::updateL 265//void OFileSelector::updateL
266 266
267QString OFileSelector::selectedName() const 267QString OFileSelector::selectedName() const
268{ 268{
269 QString name; 269 QString name;
270 if( m_selector == Normal ){ 270 if( m_selector == Normal ){
271 DocLnk lnk = m_select->selectedDocument(); 271 DocLnk lnk = m_select->selectedDocument();
272 name = lnk.file(); 272 name = lnk.file();
273 }else { 273 }else {
274 if ( m_shLne ) { 274 if ( m_shLne ) {
275 name = m_currentDir + "/" +m_edit->text(); 275 name = m_currentDir + "/" +m_edit->text();
276 }else{ 276 }else{
277 name = m_currentDir + "/" + currentView()->selectedName(); 277 name = m_currentDir + "/" + currentView()->selectedName();
278 } 278 }
279 } 279 }
280 return name; 280 return name;
281} 281}
282QStringList OFileSelector::selectedNames()const 282QStringList OFileSelector::selectedNames()const
283{ 283{
284 QStringList list; 284 QStringList list;
285 if( m_selector == Normal ){ 285 if( m_selector == Normal ){
286 list << selectedName(); 286 list << selectedName();
287 }else { 287 }else {
288 list << selectedName(); // FIXME implement multiple Selections 288 list << selectedName(); // FIXME implement multiple Selections
289 } 289 }
290 return list; 290 return list;
291} 291}
292/** If mode is set to the Dir selection this will return the selected path. 292/** If mode is set to the Dir selection this will return the selected path.
293 * 293 *
294 * 294 *
295 */ 295 */
296QString OFileSelector::selectedPath()const 296QString OFileSelector::selectedPath()const
297{ 297{
298 QString path; 298 QString path;
299 if( m_selector == Normal ){ 299 if( m_selector == Normal ){
300 path = QPEApplication::documentDir(); 300 path = QPEApplication::documentDir();
301 } /* normal case to do */ 301 } /* normal case to do */
302 return path; 302 return path;
303} 303}
304QStringList OFileSelector::selectedPaths() const 304QStringList OFileSelector::selectedPaths() const
305{ 305{
306 QStringList list; 306 QStringList list;
307 list << selectedPath(); 307 list << selectedPath();
308 return list; 308 return list;
309} 309}
310QString OFileSelector::directory()const 310QString OFileSelector::directory()const
311{ 311{
312 if( m_selector == Normal ) 312 if( m_selector == Normal )
313 return QPEApplication::documentDir(); 313 return QPEApplication::documentDir();
314 314
315 return QDir(m_currentDir).absPath(); 315 return QDir(m_currentDir).absPath();
316} 316}
317 317
318int OFileSelector::fileCount() 318int OFileSelector::fileCount()
319{ 319{
320 int count; 320 int count;
321 switch( m_selector ){ 321 switch( m_selector ){
322 case Normal: 322 case Normal:
323 count = m_select->fileCount(); 323 count = m_select->fileCount();
324 break; 324 break;
325 case Extended: 325 case Extended:
326 case ExtendedAll: 326 case ExtendedAll:
327 default: 327 default:
328 count = currentView()->fileCount(); 328 count = currentView()->fileCount();
329 break; 329 break;
330 } 330 }
331 return count; 331 return count;
332} 332}
333DocLnk OFileSelector::selectedDocument() const 333DocLnk OFileSelector::selectedDocument() const
334{ 334{
335 DocLnk lnk; 335 DocLnk lnk;
336 switch( m_selector ){ 336 switch( m_selector ){
337 case Normal:{ 337 case Normal:{
338 lnk = m_select->selectedDocument(); 338 lnk = m_select->selectedDocument();
339 break; 339 break;
340 } 340 }
341 case Extended: 341 case Extended:
342 case ExtendedAll: 342 case ExtendedAll:
343 default: 343 default:
344 lnk = DocLnk( selectedName() ); 344 lnk = DocLnk( selectedName() );
345 break; 345 break;
346 } 346 }
347 return lnk; 347 return lnk;
348} 348}
349QValueList<DocLnk> OFileSelector::selectedDocuments() const 349QValueList<DocLnk> OFileSelector::selectedDocuments() const
350{ 350{
351 QValueList<DocLnk> docs; 351 QValueList<DocLnk> docs;
352 docs.append( selectedDocument() ); 352 docs.append( selectedDocument() );
353 return docs; 353 return docs;
354} 354}
355 355
356 356
357// slots internal 357// slots internal
358 358
359void OFileSelector::slotOk() 359void OFileSelector::slotOk()
360{ 360{
361 emit ok(); 361 emit ok();
362} 362}
363void OFileSelector::slotCancel() 363void OFileSelector::slotCancel()
364{ 364{
365 emit cancel(); 365 emit cancel();
366} 366}
367/* switch the views */ 367/* switch the views */
368void OFileSelector::slotViewCheck(const QString &sel) 368void OFileSelector::slotViewCheck(const QString &sel)
369{ 369{
370 setView( sel ); 370 setView( sel );
371} 371}
372 372
373QString OFileSelector::currentMimeType() const{ 373QString OFileSelector::currentMimeType() const{
374 QString mime; 374 QString mime;
375 QString currentText; 375 QString currentText;
376 if (m_shChooser && m_mimeCheck ) 376 if (m_shChooser && m_mimeCheck )
377 currentText = m_mimeCheck->currentText(); 377 currentText = m_mimeCheck->currentText();
378 378
379 qWarning("CurrentText" + currentText ); 379 qWarning("CurrentText" + currentText );
380 if (tr("All") == currentText ) return QString::null; 380 if (tr("All") == currentText ) return QString::null;
381 else if (currentText.isEmpty() ) { 381 else if (currentText.isEmpty() ) {
382 ; 382 ;
383 }else { 383 }else {
384 QMap<QString, QStringList>::ConstIterator it; 384 QMap<QString, QStringList>::ConstIterator it;
385 it = m_mimetypes.find( currentText ); 385 it = m_mimetypes.find( currentText );
386 if ( it != m_mimetypes.end() ) { 386 if ( it != m_mimetypes.end() ) {
387 mime = it.data().join(";"); 387 mime = it.data().join(";");
388 }else{ 388 }else{
389 mime = currentText; 389 mime = currentText;
390 } 390 }
391 } 391 }
392 return mime; 392 return mime;
393} 393}
394void OFileSelector::slotMimeCheck(const QString &mime) 394void OFileSelector::slotMimeCheck(const QString &mime)
395{ 395{
396 if( m_selector == Normal ){ 396 if( m_selector == Normal ){
397 initializeOldSelector(); 397 initializeOldSelector();
398 398
399 updateMimes(); 399 updateMimes();
400 updateMimeCheck(); 400 updateMimeCheck();
401 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 401 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
402 }else{ // others 402 }else{ // others
403 qWarning("Mime %s", mime.latin1() ); 403 qWarning("Mime %s", mime.latin1() );
404 if(m_shChooser ){ 404 if(m_shChooser ){
405 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); 405 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() );
406 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 406 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
407 } 407 }
408 reparse(); 408 reparse();
409 } 409 }
410 410
411} 411}
412/* 412/*
413 * Ok if a non dir gets inserted into this combobox 413 * Ok if a non dir gets inserted into this combobox
414 * we need to change it 414 * we need to change it
415 * QFileInfo and dirPath will give us the right Dir 415 * QFileInfo and dirPath will give us the right Dir
416 */ 416 */
417void OFileSelector::slotLocationActivated(const QString &file) 417void OFileSelector::slotLocationActivated(const QString &file)
418{ 418{
419 qWarning("slotLocationActivated"); 419 qWarning("slotLocationActivated");
420 QString name = file.left( file.find("<-", 0, TRUE ) ); 420 QString name = file.left( file.find("<-", 0, TRUE ) );
421 QFileInfo info( name ); 421 QFileInfo info( name );
422 if ( info.isFile() ) 422 if ( info.isFile() )
423 cd(info.dirPath( TRUE ) ); //absolute 423 cd(info.dirPath( TRUE ) ); //absolute
424 else 424 else
425 cd(name ); 425 cd(name );
426 reparse(); 426 reparse();
427} 427}
428void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count) 428void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count)
429{ 429{
430 QStringList pathList; 430 QStringList pathList;
431 bool underDog = FALSE; 431 bool underDog = FALSE;
432 for(int i=0;i<count;i++) { 432 for(int i=0;i<count;i++) {
433 pathList << m_location->text(i); 433 pathList << m_location->text(i);
434 if( m_location->text(i) == currentPath) 434 if( m_location->text(i) == currentPath)
435 underDog = TRUE; 435 underDog = TRUE;
436 } 436 }
437 if( !underDog) { 437 if( !underDog) {
438 m_location->clear(); 438 m_location->clear();
439 if( currentPath.left(2)=="//") 439 if( currentPath.left(2)=="//")
440 pathList.append( currentPath.right(currentPath.length()-1) ); 440 pathList.append( currentPath.right(currentPath.length()-1) );
441 else 441 else
442 pathList.append( currentPath ); 442 pathList.append( currentPath );
443 m_location->insertStringList( pathList,-1); 443 m_location->insertStringList( pathList,-1);
444 } 444 }
445} 445}
446/* 446/*
447 * Do not crash anymore 447 * Do not crash anymore
448 * don't try to change dir to a file 448 * don't try to change dir to a file
449 */ 449 */
450void OFileSelector::locationComboChanged() 450void OFileSelector::locationComboChanged()
451{ 451{
452 QFileInfo info( m_location->lineEdit()->text() ); 452 QFileInfo info( m_location->lineEdit()->text() );
453 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); 453 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() );
454 if (info.isFile() ) 454 if (info.isFile() )
455 cd(info.dirPath(TRUE) ); //absolute path 455 cd(info.dirPath(TRUE) ); //absolute path
456 else 456 else
457 cd( m_location->lineEdit()->text() ); 457 cd( m_location->lineEdit()->text() );
458 458
459 reparse(); 459 reparse();
460} 460}
461void OFileSelector::init() 461void OFileSelector::init()
462{ 462{
463 initFactory(); 463 initFactory();
464 m_lay = new QVBoxLayout( this ); 464 m_lay = new QVBoxLayout( this );
465 m_lay->setSpacing(0 ); 465 m_lay->setSpacing(0 );
466 466
467 /* take care of the main view... */ 467 /* take care of the main view... */
468 initToolbar(); 468 initToolbar();
469 //if( m_shChooser ) // the Chooser for the view and Mimetypes
470 initializeChooser();
469 471
470 /* initialize the file lister */ 472 /* initialize the file lister */
471 if( m_selector == Normal ){ 473 if( m_selector == Normal ){
472 QString mime; 474 QString mime;
473 if (!m_autoMime) { 475 if (!m_autoMime) {
474 if (!m_mimetypes.isEmpty() ) { 476 if (!m_mimetypes.isEmpty() ) {
475 QMap<QString, QStringList>::Iterator it; 477 QMap<QString, QStringList>::Iterator it;
476 it = m_mimetypes.begin(); // cause we're in the init 478 it = m_mimetypes.begin(); // cause we're in the init
477 mime = it.data().join(";"); 479 mime = it.data().join(";");
478 } 480 }
479 } 481 }
480 initializeOldSelector(); 482 initializeOldSelector();
481 }else{ 483 }else{
482 initializeView(); 484 initializeView();
483 } 485 }
484 486
485 if( m_shLne ) // the LineEdit with the current FileName 487 if( m_shLne ) // the LineEdit with the current FileName
486 initializeName(); 488 initializeName();
487 489
488 if( m_shPerm ) // the Permission QCheckBox 490 if( m_shPerm ) // the Permission QCheckBox
489 initializePerm(); 491 initializePerm();
490 492
491 if( m_shChooser ) // the Chooser for the view and Mimetypes
492 initializeChooser();
493
494 if( m_shYesNo ) // the Yes No button row 493 if( m_shYesNo ) // the Yes No button row
495 initializeYes( ); 494 initializeYes( );
496 495
497 if (m_selector != Normal ) 496 if (m_selector != Normal )
498 reparse(); 497 reparse();
499} 498}
500void OFileSelector::updateMimes() 499void OFileSelector::updateMimes()
501{ 500{
502 if( m_autoMime ){ 501 if( m_autoMime ){
503 m_mimetypes.clear(); 502 m_mimetypes.clear();
504 m_mimetypes.insert( tr("All"), QString::null ); 503 m_mimetypes.insert( tr("All"), QString::null );
505 if( m_selector == Normal ){ 504 if( m_selector == Normal ){
506 DocLnkSet set; 505 DocLnkSet set;
507 Global::findDocuments(&set, QString::null ); 506 Global::findDocuments(&set, QString::null );
508 QListIterator<DocLnk> dit( set.children() ); 507 QListIterator<DocLnk> dit( set.children() );
509 for( ; dit.current(); ++dit ){ 508 for( ; dit.current(); ++dit ){
510 if( !m_mimetypes.contains( (*dit)->type() ) ) 509 if( !m_mimetypes.contains( (*dit)->type() ) )
511 m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); 510 m_mimetypes.insert( (*dit)->type(), (*dit)->type() );
512 } 511 }
513 }// else done in reparse 512 }// else done in reparse
514 } 513 }
515} 514}
516void OFileSelector::initVars() 515void OFileSelector::initVars()
517{ 516{
518 if( m_mimetypes.isEmpty() ) 517 if( m_mimetypes.isEmpty() )
519 m_autoMime = true; 518 m_autoMime = true;
520 else 519 else
521 m_autoMime = false; 520 m_autoMime = false;
522 521
523 m_shClose = false; 522 m_shClose = false;
524 m_shNew = false; 523 m_shNew = false;
525 m_shTool = true; 524 m_shTool = true;
526 m_shPerm = false; 525 m_shPerm = false;
527 m_shLne = true; 526 m_shLne = true;
528 m_shChooser = true; 527 m_shChooser = true;
529 m_shYesNo = true; 528 m_shYesNo = true;
530 m_case = false; 529 m_case = false;
531 m_dir = true; 530 m_dir = true;
532 m_files = true; 531 m_files = true;
533 m_showPopup = false; 532 m_showPopup = false;
534 m_mainView = 0l; 533 m_mainView = 0l;
535 m_fileView = 0l; 534 m_fileView = 0l;
536 m_lister = 0l; 535 m_lister = 0l;
537 536
538 if(m_pixmaps == 0 ) // init the pixmaps 537 if(m_pixmaps == 0 ) // init the pixmaps
539 initPics(); 538 initPics();
540 539
541 // pointers 540 // pointers
542 m_location = 0; 541 m_location = 0;
543 m_mimeCheck = 0; 542 m_mimeCheck = 0;
544 m_viewCheck = 0; 543 m_viewCheck = 0;
545 m_homeButton = 0; 544 m_homeButton = 0;
546 m_docButton = 0; 545 m_docButton = 0;
547 m_hideButton = 0; 546 m_hideButton = 0;
548 m_ok = 0; 547 m_ok = 0;
549 m_cancel = 0; 548 m_cancel = 0;
550 m_reread = 0; 549 m_reread = 0;
551 m_up = 0; 550 m_up = 0;
552 m_View = 0; 551 m_View = 0;
553 m_checkPerm = 0; 552 m_checkPerm = 0;
554 m_pseudo = 0; 553 m_pseudo = 0;
555 m_pseudoLayout = 0; 554 m_pseudoLayout = 0;
556 m_select = 0; 555 m_select = 0;
557 m_lay = 0; 556 m_lay = 0;
558 m_Oselector = 0; 557 m_Oselector = 0;
559 m_boxToolbar = 0; 558 m_boxToolbar = 0;
560 m_boxOk = 0; 559 m_boxOk = 0;
561 m_boxName = 0; 560 m_boxName = 0;
562 m_boxView = 0; 561 m_boxView = 0;
563 m_edit = 0; 562 m_edit = 0;
564 m_fnLabel = 0; 563 m_fnLabel = 0;
565 m_new = 0; 564 m_new = 0;
566 m_close = 0; 565 m_close = 0;
567} 566}
568void OFileSelector::initializeName() 567void OFileSelector::initializeName()
569{ 568{
570 /** Name Layout Line 569 /** Name Layout Line
571 * This is the Layout line arranged in 570 * This is the Layout line arranged in
572 * horizontal way each components 571 * horizontal way each components
573 * are next to each other 572 * are next to each other
574 * but we will only do this if 573 * but we will only do this if
575 * we didn't initialize a while ago. 574 * we didn't initialize a while ago.
576 */ 575 */
577 if( m_boxName == 0 ){ 576 if( m_boxName == 0 ){
578 m_boxName = new QHBox( this ); // remove this this? or use a QHBox 577 m_boxName = new QHBox( this ); // remove this this? or use a QHBox
579 m_fnLabel = new QLabel( m_boxName ); 578 m_fnLabel = new QLabel( m_boxName );
580 m_fnLabel->setText( tr("Name:") ); 579 m_fnLabel->setText( tr("Name:") );
581 m_edit = new QLineEdit( m_boxName ); 580 m_edit = new QLineEdit( m_boxName );
582 m_edit->setText( m_name ); 581 m_edit->setText( m_name );
583 //m_boxName->addWidget( m_fnLabel ); 582 //m_boxName->addWidget( m_fnLabel );
584 m_boxName->setMargin( 5 ); 583 m_boxName->setMargin( 5 );
585 m_boxName->setSpacing( 8 ); 584 m_boxName->setSpacing( 8 );
586 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor 585 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor
587 586
588 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout 587 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout
589 }// else we already initialized 588 }// else we already initialized
590 // maybe show the components? 589 // maybe show the components?
591 // 590 //
592} 591}
593void OFileSelector::initializeYes() 592void OFileSelector::initializeYes()
594{ 593{
595 /** The Save Cancel bar 594 /** The Save Cancel bar
596 * 595 *
597 */ 596 */
598 if( m_boxOk == 0 ){ 597 if( m_boxOk == 0 ){
599 m_boxOk = new QHBox( this ); 598 m_boxOk = new QHBox( this );
600 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); 599 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" );
601 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); 600 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" );
602 601
603 //m_boxOk->addWidget( m_ok ); 602 //m_boxOk->addWidget( m_ok );
604 //m_boxOk->addWidget( m_cancel ); 603 //m_boxOk->addWidget( m_cancel );
605 m_boxOk->setMargin( 5 ); 604 m_boxOk->setMargin( 5 );
606 m_boxOk->setSpacing( 10 ); 605 m_boxOk->setSpacing( 10 );
607 m_lay->addWidget( m_boxOk, 0 ); 606 m_lay->addWidget( m_boxOk, 0 );
608 607
609 connect( m_ok, SIGNAL( clicked() ), 608 connect( m_ok, SIGNAL( clicked() ),
610 this, SLOT(slotOk() ) ); 609 this, SLOT(slotOk() ) );
611 connect( m_cancel, SIGNAL( clicked() ), 610 connect( m_cancel, SIGNAL( clicked() ),
612 this, SLOT( slotCancel() ) ); 611 this, SLOT( slotCancel() ) );
613 } 612 }
614} 613}
615/* 614/*
616 * OK m_mimeCheck is a QComboBox we now want to fill 615 * OK m_mimeCheck is a QComboBox we now want to fill
617 * out that combobox 616 * out that combobox
618 * if automime we need to update the mimetypes 617 * if automime we need to update the mimetypes
619 */ 618 */
620void OFileSelector::updateMimeCheck() { 619void OFileSelector::updateMimeCheck() {
621 m_mimeCheck->clear(); 620 m_mimeCheck->clear();
622 if (m_autoMime ) { 621 if (m_autoMime ) {
623 //m_mimeCheck->insertItem( tr("All") ); 622 //m_mimeCheck->insertItem( tr("All") );
624 updateMimes(); 623 updateMimes();
625 } 624 }
626 625
627 QMap<QString, QStringList>::Iterator it; 626 QMap<QString, QStringList>::Iterator it;
628 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { 627 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) {
629 m_mimeCheck->insertItem( it.key() ); 628 m_mimeCheck->insertItem( it.key() );
630 } 629 }
631} 630}
632 631
633void OFileSelector::initializeChooser() 632void OFileSelector::initializeChooser()
634{ 633{
635 if( m_boxView == 0 ){ 634 if( m_boxView == 0 ){
636 m_boxView = new QHBox( this ); 635 m_boxView = new QHBox( this );
637 m_viewCheck = new QComboBox( m_boxView, "view check"); 636 m_viewCheck = new QComboBox( m_boxView, "view check");
638 m_mimeCheck = new QComboBox( m_boxView, "mime check"); 637 m_mimeCheck = new QComboBox( m_boxView, "mime check");
639 m_boxView->setSpacing( 8 ); 638 m_boxView->setSpacing( 8 );
640 m_lay->addWidget(m_boxView, 0 ); 639 m_lay->addWidget(m_boxView, 0 );
641 640
642 641
643 updateMimeCheck(); 642 updateMimeCheck();
644 fillList(); 643 fillList();
645 644
646 connect( m_viewCheck, SIGNAL( activated(const QString & ) ), 645 connect( m_viewCheck, SIGNAL( activated(const QString & ) ),
647 this, SLOT( slotViewCheck(const QString & ) ) ); 646 this, SLOT( slotViewCheck(const QString & ) ) );
648 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), 647 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ),
649 this, SLOT( slotMimeCheck( const QString & ) ) ); 648 this, SLOT( slotMimeCheck( const QString & ) ) );
650 } 649 }
651} 650}
652/* generate the buttons for the toolbar */ 651/* generate the buttons for the toolbar */
653void OFileSelector::initToolbar() { 652void OFileSelector::initToolbar() {
654 m_mainView = new OFileSelectorMain( this ); 653 m_mainView = new OFileSelectorMain( this );
655 654
656 /* now generate the tool bar */ 655 /* now generate the tool bar */
657 qWarning( "toolbar" ); 656 qWarning( "toolbar" );
658 m_pseudo = new QWidget( m_mainView, "Pseudo Widget" ); 657 m_pseudo = new QWidget( m_mainView, "Pseudo Widget" );
659 m_pseudoLayout = new QVBoxLayout( m_pseudo ); 658 m_pseudoLayout = new QVBoxLayout( m_pseudo );
660 659
661 m_boxToolbar = new QHBox( m_pseudo ); 660 m_boxToolbar = new QHBox( m_pseudo );
662 m_boxToolbar->setSpacing( 0 ); 661 m_boxToolbar->setSpacing( 0 );
663 662
664 // tool bar members now 663 // tool bar members now
665 m_location = new QComboBox( m_boxToolbar ); 664 m_location = new QComboBox( m_boxToolbar );
666 m_location->setEditable( TRUE ); 665 m_location->setEditable( TRUE );
667 m_location->setDuplicatesEnabled( FALSE ); 666 m_location->setDuplicatesEnabled( FALSE );
668 connect( m_location, SIGNAL(activated(const QString& ) ), 667 connect( m_location, SIGNAL(activated(const QString& ) ),
669 this, SLOT(slotLocationActivated(const QString& )) ); 668 this, SLOT(slotLocationActivated(const QString& )) );
670 connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , 669 connect( m_location->lineEdit(), SIGNAL(returnPressed() ) ,
671 this, SLOT(locationComboChanged() ) ); 670 this, SLOT(locationComboChanged() ) );
672 671
673 // UP Button 672 // UP Button
674 m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, 673 m_up = new QPushButton( Resource::loadIconSet("up"), QString::null,
675 m_boxToolbar, "cdUpButton" ); 674 m_boxToolbar, "cdUpButton" );
676 m_up->setFixedSize( QSize(20, 20 ) ); 675 m_up->setFixedSize( QSize(20, 20 ) );
677 connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); 676 connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) );
678 m_up->setFlat( TRUE ); 677 m_up->setFlat( TRUE );
679 678
680 // Home Button 679 // Home Button
681 m_homeButton = new QPushButton(Resource::loadIconSet("home"), 680 m_homeButton = new QPushButton(Resource::loadIconSet("home"),
682 QString::null, m_boxToolbar ); 681 QString::null, m_boxToolbar );
683 m_homeButton->setFixedSize( QSize(20, 20 ) ); 682 m_homeButton->setFixedSize( QSize(20, 20 ) );
684 connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); 683 connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) );
685 m_homeButton->setFlat( TRUE ); 684 m_homeButton->setFlat( TRUE );
686 685
687 // Documents Button 686 // Documents Button
688 m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), 687 m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"),
689 QString::null, m_boxToolbar, 688 QString::null, m_boxToolbar,
690 "docsButton" ); 689 "docsButton" );
691 m_docButton->setFixedSize( QSize(20, 20 ) ); 690 m_docButton->setFixedSize( QSize(20, 20 ) );
692 m_docButton->setFlat( true ); 691 m_docButton->setFlat( true );
693 connect( m_docButton, SIGNAL(clicked() ), 692 connect( m_docButton, SIGNAL(clicked() ),
694 this, SLOT(slotDoc() ) ); 693 this, SLOT(slotDoc() ) );
695 694
696 // close button 695 // close button
697 m_close = new QPushButton( Resource::loadIconSet( "close"), "", 696 m_close = new QPushButton( Resource::loadIconSet( "close"), "",
698 m_boxToolbar ); 697 m_boxToolbar );
699 connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); 698 connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) );
700 m_close->setFixedSize( 20, 20 ); 699 m_close->setFixedSize( 20, 20 );
701 700
702 m_boxToolbar->setFixedHeight( 20 ); 701 m_boxToolbar->setFixedHeight( 20 );
703 m_pseudoLayout->addWidget(m_boxToolbar ); 702 m_pseudoLayout->addWidget(m_boxToolbar );
704 703
705 /* init the locations */ 704 /* init the locations */
706 initLocations(); 705 initLocations();
707 706
708 if( !m_shTool ){ 707 if( !m_shTool ){
709 m_location->hide( ); 708 m_location->hide( );
710 m_up->hide( ); 709 m_up->hide( );
711 m_homeButton->hide( ); 710 m_homeButton->hide( );
712 m_docButton->hide( ); 711 m_docButton->hide( );
713 } 712 }
714 if(!m_shClose ) 713 if(!m_shClose )
715 m_close->hide(); 714 m_close->hide();
716 715
717 m_mainView->setToolbar( m_pseudo ); 716 m_mainView->setToolbar( m_pseudo );
718 m_lay->addWidget( m_mainView, 100 ); 717 m_lay->addWidget( m_mainView, 100 );
719} 718}
720/* put default locations into the bar */ 719/* put default locations into the bar */
721void OFileSelector::initLocations () { 720void OFileSelector::initLocations () {
722 721
723 // let;s fill the Location ComboBox 722 // let;s fill the Location ComboBox
724 StorageInfo storage; 723 StorageInfo storage;
725 const QList<FileSystem> &fs = storage.fileSystems(); 724 const QList<FileSystem> &fs = storage.fileSystems();
726 QListIterator<FileSystem> it ( fs ); 725 QListIterator<FileSystem> it ( fs );
727 for( ; it.current(); ++it ){ 726 for( ; it.current(); ++it ){
728 const QString disk = (*it)->name(); 727 const QString disk = (*it)->name();
729 const QString path = (*it)->path(); 728 const QString path = (*it)->path();
730 m_location->insertItem(path+ "<-"+disk ); 729 m_location->insertItem(path+ "<-"+disk );
731 } 730 }
732 int count = m_location->count(); 731 int count = m_location->count();
733 m_location->insertItem( m_currentDir ); 732 m_location->insertItem( m_currentDir );
734 m_location->setCurrentItem( count ); 733 m_location->setCurrentItem( count );
735 734
736} 735}
737void OFileSelector::initializePerm() 736void OFileSelector::initializePerm()
738{ 737{
739 if( m_checkPerm == 0 ){ 738 if( m_checkPerm == 0 ){
740 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); 739 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm");
741 m_checkPerm->setChecked( false ); 740 m_checkPerm->setChecked( false );
742 m_lay->addWidget( m_checkPerm ); 741 m_lay->addWidget( m_checkPerm );
743 } 742 }
744} 743}
745void OFileSelector::initPics() 744void OFileSelector::initPics()
746{ 745{
747 m_pixmaps = new QMap<QString,QPixmap>; 746 m_pixmaps = new QMap<QString,QPixmap>;
748 QPixmap pm = Resource::loadPixmap( "folder" ); 747 QPixmap pm = Resource::loadPixmap( "folder" );
749 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 748 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
750 749
751 QPainter painter( &pm ); 750 QPainter painter( &pm );
752 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 751 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
753 pm.setMask( pm.createHeuristicMask( FALSE ) ); 752 pm.setMask( pm.createHeuristicMask( FALSE ) );
754 m_pixmaps->insert("dirsymlink", pm ); 753 m_pixmaps->insert("dirsymlink", pm );
755 754
756 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); 755 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
757 QPainter pen(&pm2 ); 756 QPainter pen(&pm2 );
758 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); 757 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
759 pm2.setMask( pm2.createHeuristicMask( FALSE ) ); 758 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
760 m_pixmaps->insert("symlinkedlocked", pm2 ); 759 m_pixmaps->insert("symlinkedlocked", pm2 );
761} 760}
762// if a mime complies with the m_mimeCheck->currentItem 761// if a mime complies with the m_mimeCheck->currentItem
763bool OFileSelector::compliesMime( const QString &path, const QString &mime ) 762bool OFileSelector::compliesMime( const QString &path, const QString &mime )
764{ 763{
765 if( mime == "All" ) 764 if( mime == "All" )
766 return true; 765 return true;
767 MimeType type( path ); 766 MimeType type( path );
768 if( type.id() == mime ) 767 if( type.id() == mime )
769 return true; 768 return true;
770 return false; 769 return false;
771} 770}
772/* check if the mimetype in mime 771/* check if the mimetype in mime
773 * complies with the one which is current 772 * complies with the one which is current
774 */ 773 */
775/* 774/*
776 * We've the mimetype of the file 775 * We've the mimetype of the file
777 * We need to get the stringlist of the current mimetype 776 * We need to get the stringlist of the current mimetype
778 * 777 *
779 * mime = image/jpeg 778 * mime = image/jpeg
780 * QStringList = 'image/*' 779 * QStringList = 'image/*'
781 * or QStringList = image/jpeg;image/png;application/x-ogg 780 * or QStringList = image/jpeg;image/png;application/x-ogg
782 * or QStringList = application/x-ogg;image/*; 781 * or QStringList = application/x-ogg;image/*;
783 * with all these mime filters it should get acceptes 782 * with all these mime filters it should get acceptes
784 * to do so we need to look if mime is contained inside 783 * to do so we need to look if mime is contained inside
785 * the stringlist 784 * the stringlist
786 * if it's contained return true 785 * if it's contained return true
787 * if not ( I'm no RegExp expert at all ) we'll look if a '/*' 786 * if not ( I'm no RegExp expert at all ) we'll look if a '/*'
788 * is contained in the mimefilter and then we will 787 * is contained in the mimefilter and then we will
789 * look if both are equal until the '/' 788 * look if both are equal until the '/'
790 */ 789 */
791bool OFileSelector::compliesMime( const QString& mime ) { 790bool OFileSelector::compliesMime( const QString& mime ) {
792 qWarning("mimetype is %s", mime.latin1() ); 791 qWarning("mimetype is %s", mime.latin1() );
793 QString currentText; 792 QString currentText;
794 if (m_shChooser ) 793 if (m_shChooser )
795 currentText = m_mimeCheck->currentText(); 794 currentText = m_mimeCheck->currentText();
796 795
797 qWarning("current text is %s", currentText.latin1() ); 796 qWarning("current text is %s", currentText.latin1() );
798 QMap<QString, QStringList>::Iterator it; 797 QMap<QString, QStringList>::Iterator it;
799 QStringList list; 798 QStringList list;
800 if ( currentText == tr("All") ) return true; 799 if ( currentText == tr("All") ) return true;
801 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { 800 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) {
802 it = m_mimetypes.begin(); 801 it = m_mimetypes.begin();
803 list = it.data(); 802 list = it.data();
804 }else if ( currentText.isEmpty() ) return true; 803 }else if ( currentText.isEmpty() ) return true;
805 else{ 804 else{
806 it = m_mimetypes.find(currentText ); 805 it = m_mimetypes.find(currentText );
807 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; 806 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText;
808 else qWarning("found"), list = it.data(); 807 else qWarning("found"), list = it.data();
809 } 808 }
810 809
811 810
812 if ( list.contains(mime) ) return true; 811 if ( list.contains(mime) ) return true;
813 qWarning("list doesn't contain it "); 812 qWarning("list doesn't contain it ");
814 QStringList::Iterator it2; 813 QStringList::Iterator it2;
815 int pos; 814 int pos;
816 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { 815 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) {
817 pos = (*it2).findRev("/*"); 816 pos = (*it2).findRev("/*");
818 if ( pos >= 0 ) { 817 if ( pos >= 0 ) {
819 if ( mime.contains( (*it2).left(pos) ) ) return true; 818 if ( mime.contains( (*it2).left(pos) ) ) return true;
820 } 819 }
821 } 820 }
822 return false; 821 return false;
823} 822}
824void OFileSelector::slotFileSelected( const QString &string ) 823void OFileSelector::slotFileSelected( const QString &string )
825{ 824{
826 if( m_shLne ) 825 if( m_shLne )
827 m_edit->setText( string ); 826 m_edit->setText( string );
828 emit fileSelected( string ); 827 emit fileSelected( string );
829} 828}
830void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 829void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
831{ 830{
832 slotFileSelected( lnk.name() ); 831 slotFileSelected( lnk.name() );
833 // emit fileSelected( lnk ); 832 // emit fileSelected( lnk );
834} 833}
835 834
836 835
837void OFileSelector::slotDelete() 836void OFileSelector::slotDelete()
838{ 837{
839 /* 838 /*
840 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 839 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
841 QStringList list = QStringList::split("->", sel->text(1) ); 840 QStringList list = QStringList::split("->", sel->text(1) );
842 if( sel->isDir() ){ 841 if( sel->isDir() ){
843 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry 842 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry
844 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], 843 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
845 tr("Yes"),tr("No"),0,1,1) ) { 844 tr("Yes"),tr("No"),0,1,1) ) {
846 case 0: 845 case 0:
847 ::system(str.utf8().data() ); 846 ::system(str.utf8().data() );
848 break; 847 break;
849 } 848 }
850 } else { 849 } else {
851 QFile::remove( list[0] ); 850 QFile::remove( list[0] );
852 } 851 }
853 m_View->takeItem( sel ); 852 m_View->takeItem( sel );
854 delete sel; 853 delete sel;
855 */ 854 */
856} 855}
857void OFileSelector::cdUP() 856void OFileSelector::cdUP()
858{ 857{
859 QDir dir( m_currentDir ); 858 QDir dir( m_currentDir );
860 dir.cdUp(); 859 dir.cdUp();
861 if(dir.exists() ){ 860 if(dir.exists() ){
862 m_currentDir = dir.absPath(); 861 m_currentDir = dir.absPath();
863 reparse(); 862 reparse();
864 int count = m_location->count(); 863 int count = m_location->count();
865 slotInsertLocationPath( m_currentDir, count); 864 slotInsertLocationPath( m_currentDir, count);
866 m_location->setCurrentItem( indexByString( m_location, m_currentDir)); 865 m_location->setCurrentItem( indexByString( m_location, m_currentDir));
867 //this wont work in all instances 866 //this wont work in all instances
868 // FIXME 867 // FIXME
869 } 868 }
870} 869}
871void OFileSelector::slotHome() 870void OFileSelector::slotHome()
872{ 871{
873 cd(QDir::homeDirPath() ); 872 cd(QDir::homeDirPath() );
874} 873}
875void OFileSelector::slotDoc() 874void OFileSelector::slotDoc()
876{ 875{
877 cd(QPEApplication::documentDir() ); 876 cd(QPEApplication::documentDir() );
878} 877}
879void OFileSelector::slotNavigate( ) 878void OFileSelector::slotNavigate( )
880{ 879{
881 880
882} 881}
883// fill the View with life 882// fill the View with life
884void OFileSelector::reparse() 883void OFileSelector::reparse()
885{ 884{
886 if( m_selector == Normal ) 885 if( m_selector == Normal )
887 return; 886 return;
888 887
889 currentView()->clear(); 888 currentView()->clear();
890 889
891 if( m_shChooser) 890 if( m_shChooser)
892 qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); 891 qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
893 892
894 QString currentMimeType; 893 QString currentMimeType;
895 894
896 // let's update the mimetype 895 // let's update the mimetype
897 if( m_autoMime ){ 896 if( m_autoMime ){
898 m_mimetypes.clear(); 897 m_mimetypes.clear();
899 // ok we can change mimetype so we need to be able to give a selection 898 // ok we can change mimetype so we need to be able to give a selection
900 if( m_shChooser ) { 899 if( m_shChooser ) {
901 currentMimeType = m_mimeCheck->currentText(); 900 currentMimeType = m_mimeCheck->currentText();
902 m_mimeCheck->clear(); 901 m_mimeCheck->clear();
903 902
904 // let's find possible mimetypes 903 // let's find possible mimetypes
905 m_mimetypes = currentLister()->mimeTypes( m_currentDir ); 904 m_mimetypes = currentLister()->mimeTypes( m_currentDir );
906 905
907 // add them to the chooser 906 // add them to the chooser
908 updateMimeCheck(); 907 updateMimeCheck();
909 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); 908 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
910 currentMimeType = m_mimeCheck->currentText(); 909 currentMimeType = m_mimeCheck->currentText();
911 } 910 }
912 }else { // no autoMime 911 }else { // no autoMime
913 // let the mimetype be set from out side the m_mimeCheck FEATURE 912 // let the mimetype be set from out side the m_mimeCheck FEATURE
914 913
915 if( m_shChooser ) 914 if( m_shChooser )
916 currentMimeType = m_mimeCheck->currentText(); 915 currentMimeType = m_mimeCheck->currentText();
917 916
918 } 917 }
919 // now we got our mimetypes we can add the files 918 // now we got our mimetypes we can add the files
920 919
921 currentLister()->reparse( m_currentDir ); 920 currentLister()->reparse( m_currentDir );
922 /* we're done with adding let's sort */ 921 /* we're done with adding let's sort */
923 currentView()->sort(); 922 currentView()->sort();
924 923
925 924
926 if( m_shTool ){ 925 if( m_shTool ){
927 m_location->insertItem( m_currentDir ); 926 m_location->insertItem( m_currentDir );
928 927
929 } 928 }
930 // reenable painting and updates 929 // reenable painting and updates
931} 930}
932/* switch lister to @param lister */ 931/* switch lister to @param lister */
933void OFileSelector::setLister(const QString& lister) { 932void OFileSelector::setLister(const QString& lister) {
934 QStringList listerList = factory()->lister(); 933 QStringList listerList = factory()->lister();
935 934
936 if (listerList.contains(lister) ) { 935 if (listerList.contains(lister) ) {
937 delete (OLister*) m_lister; 936 delete (OLister*) m_lister;
938 m_lister = factory()->lister( lister, this ); 937 m_lister = factory()->lister( lister, this );
939 }else if (!m_lister ) { 938 }else if (!m_lister ) {
940 /* 939 /*
941 * if we do not have a lister 940 * if we do not have a lister
942 * we need to take the default one 941 * we need to take the default one
943 */ 942 */
944 m_lister = new OLocalLister(this); 943 m_lister = new OLocalLister(this);
945 } 944 }
946 m_listerName = lister; 945 m_listerName = lister;
947} 946}
948void OFileSelector::setView( const QString& lis ) { 947void OFileSelector::setView( const QString& lis ) {
949 qWarning("setView "); 948 qWarning("setView ");
950 fillList(); 949 fillList();
951 if ( lis == tr("Documents") ) { 950 if ( lis == tr("Documents") ) {
952 m_selector = Normal; 951 m_selector = Normal;
953 delete m_lister; 952 delete m_lister;
954 delete m_fileView; 953 delete m_fileView;
955 m_lister = 0l; 954 m_lister = 0l;
956 m_fileView = 0l; 955 m_fileView = 0l;
957 initializeOldSelector(); 956 initializeOldSelector();
958 }else { 957 }else {
958 qWarning("lis %s", lis.latin1() );
959 QString list; 959 QString list;
960 960
961 delete m_lister; 961 delete m_lister;
962 delete m_fileView; 962 delete m_fileView;
963 delete m_select; 963 delete m_select;
964 m_lister =0l; 964 m_lister =0l;
965 m_fileView = 0l; 965 m_fileView = 0l;
966 m_select = 0l; 966 m_select = 0l;
967 if ( lis.startsWith("All") ) { 967 if ( lis.startsWith("All") ) {
968 m_selector = ExtendedAll; 968 m_selector = ExtendedAll;
969 list = lis.mid(4 ).stripWhiteSpace(); 969 list = lis.mid(4 ).stripWhiteSpace();
970 } else{ 970 } else{
971 list = lis; 971 list = lis;
972 m_selector = Extended; 972 m_selector = Extended;
973 } 973 }
974 setLister(m_listerName); 974 setLister(m_listerName);
975 m_fileView = factory()->view( list, this, m_mainView ); 975 m_fileView = factory()->view( list, this, m_mainView );
976 m_mainView->setWidget( m_fileView->widget() ); 976 m_mainView->setWidget( m_fileView->widget() );
977 reparse(); 977 reparse();
978 } 978 }
979} 979}
980/* 980/*
981 * the factory 981 * the factory
982 */ 982 */
983void OFileSelector::initFactory() { 983void OFileSelector::initFactory() {
984 m_fileFactory = new OFileFactory(); 984 m_fileFactory = new OFileFactory();
985 m_fileFactory->addLister(tr("Files"), newLocalLister ); 985 m_fileFactory->addLister(tr("Files"), newLocalLister );
986 m_fileFactory->addView(tr("List View"), newFileListView ); 986 m_fileFactory->addView(tr("List View"), newFileListView );
987 /* the factory is just a dummy */ 987 /* the factory is just a dummy */
988 m_fileFactory->addView(tr("Documents"), newFileListView ); 988 m_fileFactory->addView(tr("Documents"), newFileListView );
989} 989}
990void OFileSelector::fillList() { 990void OFileSelector::fillList() {
991 qWarning("fill list"); 991 qWarning("fill list");
992 if (!m_viewCheck ) 992 if (!m_viewCheck )
993 return; 993 return;
994 994
995 m_viewCheck->clear(); 995 m_viewCheck->clear();
996 QStringList list = factory()->views(); 996 QStringList list = factory()->views();
997 qWarning("views: " + list.join(";") ); 997 qWarning("views: " + list.join(";") );
998 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 998 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
999 qWarning( (*it) ); 999 qWarning( (*it) );
1000 if ( (*it) == tr("Documents") ) { 1000 if ( (*it) == tr("Documents") ) {
1001 m_viewCheck->insertItem( (*it) ); 1001 m_viewCheck->insertItem( (*it) );
1002 }else{ 1002 }else{
1003 m_viewCheck->insertItem( (*it) ); 1003 m_viewCheck->insertItem( (*it) );
1004 m_viewCheck->insertItem( tr("All ") + (*it) ); 1004 m_viewCheck->insertItem( tr("All ") + (*it) );
1005 } 1005 }
1006 } 1006 }
1007} 1007}
1008OFileFactory* OFileSelector::factory() { 1008OFileFactory* OFileSelector::factory() {
1009 return m_fileFactory; 1009 return m_fileFactory;
1010} 1010}
1011 1011
1012 1012
1013OFileView* OFileSelector::currentView() { 1013OFileView* OFileSelector::currentView() {
1014 return m_fileView; 1014 return m_fileView;
1015} 1015}
1016OFileView* OFileSelector::currentView() const{ 1016OFileView* OFileSelector::currentView() const{
1017 return m_fileView; 1017 return m_fileView;
1018} 1018}
1019int OFileSelector::filter() { 1019int OFileSelector::filter() {
1020 int filter; 1020 int filter;
1021 if ( m_selector == ExtendedAll ) 1021 if ( m_selector == ExtendedAll )
1022 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 1022 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
1023 else 1023 else
1024 filter = QDir::Files | QDir::Dirs | QDir::All ; 1024 filter = QDir::Files | QDir::Dirs | QDir::All ;
1025 1025
1026 return filter; 1026 return filter;
1027} 1027}
1028int OFileSelector::sorting() { 1028int OFileSelector::sorting() {
1029 int sort; 1029 int sort;
1030 1030
1031 if (m_case ) 1031 if (m_case )
1032 sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); 1032 sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed );
1033 else 1033 else
1034 sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 1034 sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed );
1035 1035
1036 return sort; 1036 return sort;
1037} 1037}
1038void OFileSelector::internFileSelected( const QString& s) { 1038void OFileSelector::internFileSelected( const QString& s) {
1039 emit fileSelected( s ); 1039 emit fileSelected( s );
1040} 1040}
1041void OFileSelector::internFileSelected( const DocLnk& d ) { 1041void OFileSelector::internFileSelected( const DocLnk& d ) {
1042 emit fileSelected( d ); 1042 emit fileSelected( d );
1043} 1043}
1044void OFileSelector::internContextMenu() { 1044void OFileSelector::internContextMenu() {
1045 emit contextMenu(); 1045 emit contextMenu();
1046} 1046}
1047void OFileSelector::internChangedDir( const QString& s) { 1047void OFileSelector::internChangedDir( const QString& s) {
1048 emit dirSelected( s ); 1048 emit dirSelected( s );
1049 cd(s ); 1049 cd(s );
1050} 1050}
1051void OFileSelector::internChangedDir( const QDir& s) { 1051void OFileSelector::internChangedDir( const QDir& s) {
1052 emit dirSelected( s ); 1052 emit dirSelected( s );
1053} 1053}
1054QPixmap OFileSelector::pixmap( const QString& s ) { 1054QPixmap OFileSelector::pixmap( const QString& s ) {
1055 1055
1056 return (*m_pixmaps)[s]; 1056 return (*m_pixmaps)[s];
1057} 1057}
1058OLister* OFileSelector::currentLister()const { 1058OLister* OFileSelector::currentLister()const {
1059 return m_lister; 1059 return m_lister;
1060} 1060}
1061void OFileSelector::initializeOldSelector() { 1061void OFileSelector::initializeOldSelector() {
1062 qWarning("initializeOldSelector"); 1062 qWarning("initializeOldSelector");
1063 1063
1064 delete m_select; 1064 delete m_select;
1065 1065
1066 // we need to initialize but keep the selected mimetype 1066 // we need to initialize but keep the selected mimetype
1067 /* we default not to show close and new buttons */ 1067 /* we default not to show close and new buttons */
1068 QString mime = currentMimeType(); 1068 QString mime = currentMimeType();
1069 qWarning("MimeType " + mime ); 1069 qWarning("MimeType " + mime );
1070 m_select = new FileSelector( mime , 1070 m_select = new FileSelector( mime ,
1071 m_mainView, "fileselector", 1071 m_mainView, "fileselector",
1072 FALSE, FALSE); 1072 FALSE, FALSE);
1073 m_select->setCategorySelectVisible( FALSE ); 1073 m_select->setCategorySelectVisible( FALSE );
1074 m_select->setTypeComboVisible( FALSE ); 1074 m_select->setTypeComboVisible( FALSE );
1075 1075
1076 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 1076 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
1077 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 1077 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
1078 connect(m_select, SIGNAL(closeMe() ), 1078 connect(m_select, SIGNAL(closeMe() ),
1079 this, SIGNAL(closeMe() ) ); 1079 this, SIGNAL(closeMe() ) );
1080 //connect to close me and other signals as well 1080 //connect to close me and other signals as well
1081 m_mainView->setWidget( m_select ); 1081 m_mainView->setWidget( m_select );
1082} 1082}
1083/* 1083/*
1084 * initialize the listview 1084 * initialize the listview
1085 * we will call fillList 1085 * we will call fillList
1086 * setLister 1086 * setLister
1087 * with QString::null to get the default 1087 * with QString::null to get the default
1088 * setView with either Files or All Files 1088 * setView with either Files or All Files
1089 * depending on Extended 1089 * depending on Extended
1090 */ 1090 */
1091void OFileSelector::initializeView() { 1091void OFileSelector::initializeView() {
1092 setLister(QString::null); 1092 setLister(QString::null);
1093 fillList(); 1093 fillList();
1094 if (m_selector == Extended ) { 1094 if (m_selector == Extended ) {
1095 setView( tr("Files") ); 1095 setView( tr("List View") );
1096 }else{ 1096 }else{
1097 setView( tr("All Files") ); 1097 setView( tr("All List View") );
1098 } 1098 }
1099} 1099}
1100 1100