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