summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2002-03-29 00:53:55 (UTC)
committer zecke <zecke>2002-03-29 00:53:55 (UTC)
commit4d2839434de70bc67dca076ccf6a09d2d578d627 (patch) (unidiff)
tree7cb5823e727eb4b3bf19d224e9fbb041180b7c5c /libopie
parente5c50fab1c8a84f6e2337ebe85be57f354bef676 (diff)
downloadopie-4d2839434de70bc67dca076ccf6a09d2d578d627.zip
opie-4d2839434de70bc67dca076ccf6a09d2d578d627.tar.gz
opie-4d2839434de70bc67dca076ccf6a09d2d578d627.tar.bz2
interface updates. and some more implementation
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc132
-rw-r--r--libopie/ofileselector.h12
2 files changed, 132 insertions, 12 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index c9abde1..b911d37 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -1,6 +1,6 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
@@ -36,10 +36,14 @@
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qcheckbox.h> 37#include <qcheckbox.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qheader.h>
40#include <qdir.h>
39 41
42#include <qpe/qpeapplication.h>
40#include <qpe/fileselector.h> 43#include <qpe/fileselector.h>
41#include <qpe/applnk.h> 44#include <qpe/applnk.h>
42#include <qpe/global.h> 45#include <qpe/global.h>
46#include <qpe/mimetype.h>
43 47
44#include "ofileselector.h" 48#include "ofileselector.h"
45 49
@@ -268,9 +272,81 @@ void OFileSelector::updateLay()
268 if( m_shPerm ) 272 if( m_shPerm )
269 m_checkPerm->setChecked(check ); 273 m_checkPerm->setChecked(check );
270} 274}
275// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve
276// insert QListViewItems with the right options
277bool OFileSelector::compliesMime(const QString &path, const QString &mime )
278{
279 if( mime == "All" )
280 return true;
281 MimeType type( path );
282 if( type.id() == mime )
283 return true;
284 return false;
285}
286
271void OFileSelector::reparse() 287void OFileSelector::reparse()
272{ 288{
289 if(m_View== 0)
290 return;
291
292 m_View->clear();
293
294 QDir dir( m_currentDir );
295 QString currMime =m_mimeCheck->currentText();
296 // update the mimetype now
297 if( m_autoMime ) {
298 m_mimetypes.clear();
299 m_mimeCheck->clear();
300 dir.setFilter( QDir::Files | QDir::Readable );
301 dir.setSorting(QDir::Size );
302 const QFileInfoList *list = dir.entryInfoList();
303 QFileInfoListIterator it( *list );
304 QFileInfo *fi;
305 while( (fi=it.current()) ){
306 if(fi->extension() == QString::fromLatin1("desktop") ){
307 ++it;
308 continue;
309 }
310 MimeType type(fi->filePath() );
311 if( !m_mimetypes.contains( type.id() ) )
312 m_mimetypes.append( type.id() );
313
314 ++it;
315 }
316 m_mimeCheck->insertStringList(m_mimetypes );
317 // set it to the current mimetype
318 };
319 dir.setFilter(QDir::All );
320 dir.setSorting(QDir::Name | QDir::DirsFirst );
321 const QFileInfoList *list = dir.entryInfoList();
322 QFileInfoListIterator it( *list );
323 QFileInfo *fi;
324 while( (fi=it.current()) ){
325 if(fi->isSymLink() ){
326 QString file = fi->readLink();
327 for(int i=0; i<=4; i++ ){ // prepend from dos
328 QFileInfo info( file );
329 if( !info.exists() ){
330 addSymlink(m_currentDir, info.fileName(), TRUE );
331 break;
332 }else if( info.isDir() ){
333 //addDir( );
334 }else if( info.isFile() ){
335
336 }else if( info.isSymLink() ){
337 file = info.readLink();
338 }else if( i == 4 ){ // just insert it and have the symlink symbol
339 addSymlink(m_currentDir, info.fileName() );
340 }
341 }
342 }else if( fi->isDir() ){
343
344 }else if( fi->isFile() ) { // file ?
273 345
346
347 }
348 ++it;
349 }
274} 350}
275QString OFileSelector::directory() 351QString OFileSelector::directory()
276{ 352{
@@ -365,6 +441,9 @@ void OFileSelector::slotViewCheck(const QString &view ){
365 if( view == QString::fromLatin1("Documents") ){ 441 if( view == QString::fromLatin1("Documents") ){
366 // get the mimetype now 442 // get the mimetype now
367 // check if we're the current widget and return 443 // check if we're the current widget and return
444 if( m_View != 0) // delete 0 shouldn't crash but it did :(
445 delete m_View;
446 m_View = 0;
368 delete m_select; 447 delete m_select;
369 m_select = new FileSelector( currMime == "All" ? QString::null : currMime, 448 m_select = new FileSelector( currMime == "All" ? QString::null : currMime,
370 m_stack,"fileselector", FALSE, FALSE ); 449 m_stack,"fileselector", FALSE, FALSE );
@@ -373,21 +452,24 @@ void OFileSelector::slotViewCheck(const QString &view ){
373 m_selector = NORMAL; 452 m_selector = NORMAL;
374 453
375 }else if(view == QString::fromLatin1("Files") ){ 454 }else if(view == QString::fromLatin1("Files") ){
376 if( m_select != 0 ){ 455 // remove from the stack
377 // remove from the stack 456 delete m_select;
378 delete m_select; 457 m_select = 0;
379 m_select = 0; 458 delete m_View;
380 m_selector = EXTENDED; 459 m_View = 0;
381 // create the ListView or IconView 460 m_selector = EXTENDED;
382 461 // create the ListView or IconView
383 reparse(); 462 initializeListView();
384 } 463
464 reparse();
385 }else if(view == QString::fromLatin1("All Files") ) { 465 }else if(view == QString::fromLatin1("All Files") ) {
386 // remove from the stack 466 // remove from the stack
387 delete m_select; 467 delete m_select;
388 m_select = 0; 468 m_select = 0;
469 delete m_View;
470 m_View = 0;
389 m_selector = EXTENDED_ALL; 471 m_selector = EXTENDED_ALL;
390 472 initializeListView();
391 reparse(); 473 reparse();
392 }; 474 };
393}; 475};
@@ -407,7 +489,33 @@ void OFileSelector::updateMimes() // lets check which mode is active
407 m_mimetypes.append( (*dit)->type() ); 489 m_mimetypes.append( (*dit)->type() );
408 } 490 }
409 }else{ 491 }else{
410 492 // should be allreday updatet
411 493
412 } 494 }
413}; 495};
496void OFileSelector::initializeListView()
497{
498 m_View = new QListView(m_stack, "Extended view" );
499 m_stack->addWidget( m_View, EXTENDED );
500 m_stack->raiseWidget( EXTENDED );
501 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold);
502 // set up the stuff
503 // Pixmap Name Date Size mime
504 //(m_View->header() )->hide();
505 //m_View->setRootIsDecorated(false);
506 m_View->addColumn(" ");
507 m_View->addColumn(tr("Name") );
508 m_View->addColumn(tr("Size") );
509 m_View->addColumn(tr("Date"), 60 );
510 m_View->addColumn(tr("Mime Type") );
511 QHeader *header = m_View->header();
512 header->hide();
513};
514
515
516
517
518
519
520
521
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index 757a960..a90219f 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -58,6 +58,8 @@ class QLabel;
58class QWidgetStack; 58class QWidgetStack;
59class QHBoxLayout; 59class QHBoxLayout;
60class QVBoxLayout; 60class QVBoxLayout;
61class QPopupMenu;
62
61 63
62class OFileSelectorItem : public QListViewItem { 64class OFileSelectorItem : public QListViewItem {
63 public: 65 public:
@@ -102,10 +104,14 @@ class OFileSelector : public QWidget {
102 bool setPermission() const; 104 bool setPermission() const;
103 void setPermissionChecked( bool check ); 105 void setPermissionChecked( bool check );
104 void setMode( int ); 106 void setMode( int );
107 void setShowDirs(bool dir ) { };
108 bool showDirs() {bool turn; return turn; }
105 int mode()const { return m_mode; }; 109 int mode()const { return m_mode; };
106 int selector()const { return m_selector; }; 110 int selector()const { return m_selector; };
107 void setSelector( int ); 111 void setSelector( int );
108 QString selectedName( ); 112 QString selectedName( );
113 void setPopupMenu( const QPopupMenu * );
114
109 const DocLnk* selectedDocument()const; 115 const DocLnk* selectedDocument()const;
110 void updateLay(); 116 void updateLay();
111 117
@@ -162,10 +168,16 @@ class OFileSelector : public QWidget {
162 protected: 168 protected:
163 169
164 private: 170 private:
171 // implementation todo
172 virtual void addFile(const QString &path, const QString &name, bool symlink = FALSE ) {};
173 virtual void addDir( const QString &path, const QString &dir , bool symlink = FALSE ){};
174 virtual void addSymlink(const QString &path, const QString &name, bool broken = FALSE ){};
165 void delItems(); 175 void delItems();
166 void initializeName(); 176 void initializeName();
167 void initializeYes(); 177 void initializeYes();
168 void initializeChooser(); 178 void initializeChooser();
179 void initializeListView();
180 bool compliesMime(const QString &path, const QString &mime);
169 181
170 class OFileSelectorPrivate; 182 class OFileSelectorPrivate;
171 OFileSelectorPrivate *d; 183 OFileSelectorPrivate *d;