summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector/ofileselector.cpp15
-rw-r--r--libopie/ofileselector/olister.cpp10
-rw-r--r--libopie/ofileselector/olister.h18
-rw-r--r--libopie/ofileselector/olocallister.cpp29
-rw-r--r--libopie/ofileselector/olocallister.h5
5 files changed, 62 insertions, 15 deletions
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp
index 255e79e..9ce07dd 100644
--- a/libopie/ofileselector/ofileselector.cpp
+++ b/libopie/ofileselector/ofileselector.cpp
@@ -241,62 +241,56 @@ bool OFileSelector::cd(const QString &path )
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("List View"); 249 text = tr("List View");
250 break; 250 break;
251 case ExtendedAll: 251 case ExtendedAll:
252 text = tr("All List View"); 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
266
267QString OFileSelector::selectedName() const 265QString OFileSelector::selectedName() const
268{ 266{
269 QString name; 267 QString name;
270 if( m_selector == Normal ){ 268 if( m_selector == Normal ){
271 DocLnk lnk = m_select->selectedDocument(); 269 DocLnk lnk = m_select->selectedDocument();
272 name = lnk.file(); 270 name = lnk.file();
273 }else { 271 }else {
274 if ( m_shLne ) { 272 name = currentLister()->selectedName();
275 name = m_currentDir + "/" +m_edit->text();
276 }else{
277 name = m_currentDir + "/" + currentView()->selectedName();
278 }
279 } 273 }
280 return name; 274 return name;
281} 275}
282QStringList OFileSelector::selectedNames()const 276QStringList OFileSelector::selectedNames()const
283{ 277{
284 QStringList list; 278 QStringList list;
285 if( m_selector == Normal ){ 279 if( m_selector == Normal ){
286 list << selectedName(); 280 list << selectedName();
287 }else { 281 }else {
288 list << selectedName(); // FIXME implement multiple Selections 282 list << selectedName(); // FIXME implement multiple Selections
289 } 283 }
290 return list; 284 return list;
291} 285}
292/** If mode is set to the Dir selection this will return the selected path. 286/** If mode is set to the Dir selection this will return the selected path.
293 * 287 *
294 * 288 *
295 */ 289 */
296QString OFileSelector::selectedPath()const 290QString OFileSelector::selectedPath()const
297{ 291{
298 QString path; 292 QString path;
299 if( m_selector == Normal ){ 293 if( m_selector == Normal ){
300 path = QPEApplication::documentDir(); 294 path = QPEApplication::documentDir();
301 } /* normal case to do */ 295 } /* normal case to do */
302 return path; 296 return path;
@@ -401,82 +395,79 @@ void OFileSelector::slotMimeCheck(const QString &mime)
401 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 395 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
402 }else{ // others 396 }else{ // others
403 qWarning("Mime %s", mime.latin1() ); 397 qWarning("Mime %s", mime.latin1() );
404 if(m_shChooser ){ 398 if(m_shChooser ){
405 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); 399 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() );
406 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 400 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
407 } 401 }
408 reparse(); 402 reparse();
409 } 403 }
410} 404}
411/* 405/*
412 * Ok if a non dir gets inserted into this combobox 406 * Ok if a non dir gets inserted into this combobox
413 * we need to change it 407 * we need to change it
414 * QFileInfo and dirPath will give us the right Dir 408 * QFileInfo and dirPath will give us the right Dir
415 */ 409 */
416void OFileSelector::slotLocationActivated(const QString &file) 410void OFileSelector::slotLocationActivated(const QString &file)
417{ 411{
418 qWarning("slotLocationActivated"); 412 qWarning("slotLocationActivated");
419 QString name = file.left( file.find("<-", 0, TRUE ) ); 413 QString name = file.left( file.find("<-", 0, TRUE ) );
420 QFileInfo info( name ); 414 QFileInfo info( name );
421 if ( info.isFile() ) 415 if ( info.isFile() )
422 cd(info.dirPath( TRUE ) ); //absolute 416 cd(info.dirPath( TRUE ) ); //absolute
423 else 417 else
424 cd(name ); 418 cd(name );
425 reparse();
426} 419}
427void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count) 420void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count)
428{ 421{
429 QStringList pathList; 422 QStringList pathList;
430 bool underDog = FALSE; 423 bool underDog = FALSE;
431 for(int i=0;i<count;i++) { 424 for(int i=0;i<count;i++) {
432 pathList << m_location->text(i); 425 pathList << m_location->text(i);
433 if( m_location->text(i) == currentPath) 426 if( m_location->text(i) == currentPath)
434 underDog = TRUE; 427 underDog = TRUE;
435 } 428 }
436 if( !underDog) { 429 if( !underDog) {
437 m_location->clear(); 430 m_location->clear();
438 if( currentPath.left(2)=="//") 431 if( currentPath.left(2)=="//")
439 pathList.append( currentPath.right(currentPath.length()-1) ); 432 pathList.append( currentPath.right(currentPath.length()-1) );
440 else 433 else
441 pathList.append( currentPath ); 434 pathList.append( currentPath );
442 m_location->insertStringList( pathList,-1); 435 m_location->insertStringList( pathList,-1);
443 } 436 }
444} 437}
445/* 438/*
446 * Do not crash anymore 439 * Do not crash anymore
447 * don't try to change dir to a file 440 * don't try to change dir to a file
448 */ 441 */
449void OFileSelector::locationComboChanged() 442void OFileSelector::locationComboChanged()
450{ 443{
451 QFileInfo info( m_location->lineEdit()->text() ); 444 QFileInfo info( m_location->lineEdit()->text() );
452 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); 445 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() );
453 if (info.isFile() ) 446 if (info.isFile() )
454 cd(info.dirPath(TRUE) ); //absolute path 447 cd(info.dirPath(TRUE) ); //absolute path
455 else 448 else
456 cd( m_location->lineEdit()->text() ); 449 cd( m_location->lineEdit()->text() );
457
458 reparse();
459} 450}
460void OFileSelector::init() 451void OFileSelector::init()
461{ 452{
462 initFactory(); 453 initFactory();
463 m_lay = new QVBoxLayout( this ); 454 m_lay = new QVBoxLayout( this );
464 m_lay->setSpacing(0 ); 455 m_lay->setSpacing(0 );
465 456
466 /* take care of the main view... */ 457 /* take care of the main view... */
467 initToolbar(); 458 initToolbar();
468 //if( m_shChooser ) // the Chooser for the view and Mimetypes 459 //if( m_shChooser ) // the Chooser for the view and Mimetypes
469 initializeChooser(); 460 initializeChooser();
470 461
471 /* initialize the file lister */ 462 /* initialize the file lister */
472 if( m_selector == Normal ){ 463 if( m_selector == Normal ){
473 QString mime; 464 QString mime;
474 if (!m_autoMime) { 465 if (!m_autoMime) {
475 if (!m_mimetypes.isEmpty() ) { 466 if (!m_mimetypes.isEmpty() ) {
476 QMap<QString, QStringList>::Iterator it; 467 QMap<QString, QStringList>::Iterator it;
477 it = m_mimetypes.begin(); // cause we're in the init 468 it = m_mimetypes.begin(); // cause we're in the init
478 mime = it.data().join(";"); 469 mime = it.data().join(";");
479 } 470 }
480 } 471 }
481 initializeOldSelector(); 472 initializeOldSelector();
482 }else{ 473 }else{
@@ -833,58 +824,58 @@ void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
833 824
834 825
835void OFileSelector::slotDelete() 826void OFileSelector::slotDelete()
836{ 827{
837 /* 828 /*
838 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 829 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
839 QStringList list = QStringList::split("->", sel->text(1) ); 830 QStringList list = QStringList::split("->", sel->text(1) );
840 if( sel->isDir() ){ 831 if( sel->isDir() ){
841 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry 832 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry
842 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], 833 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
843 tr("Yes"),tr("No"),0,1,1) ) { 834 tr("Yes"),tr("No"),0,1,1) ) {
844 case 0: 835 case 0:
845 ::system(str.utf8().data() ); 836 ::system(str.utf8().data() );
846 break; 837 break;
847 } 838 }
848 } else { 839 } else {
849 QFile::remove( list[0] ); 840 QFile::remove( list[0] );
850 } 841 }
851 m_View->takeItem( sel ); 842 m_View->takeItem( sel );
852 delete sel; 843 delete sel;
853 */ 844 */
854} 845}
855void OFileSelector::cdUP() 846void OFileSelector::cdUP()
856{ 847{
848 // FIXME won't work on non filesystem based systems
849 // better call the Olister
857 QDir dir( m_currentDir ); 850 QDir dir( m_currentDir );
858 dir.cdUp(); 851 dir.cdUp();
859 if(dir.exists() ){ 852 if(dir.exists() ){
860 m_currentDir = dir.absPath(); 853 m_currentDir = dir.absPath();
861 reparse(); 854 reparse();
862 int count = m_location->count(); 855 int count = m_location->count();
863 slotInsertLocationPath( m_currentDir, count); 856 slotInsertLocationPath( m_currentDir, count);
864 m_location->setCurrentItem( indexByString( m_location, m_currentDir)); 857 m_location->setCurrentItem( indexByString( m_location, m_currentDir));
865 //this wont work in all instances
866 // FIXME
867 } 858 }
868} 859}
869void OFileSelector::slotHome() 860void OFileSelector::slotHome()
870{ 861{
871 cd(QDir::homeDirPath() ); 862 cd(QDir::homeDirPath() );
872} 863}
873void OFileSelector::slotDoc() 864void OFileSelector::slotDoc()
874{ 865{
875 cd(QPEApplication::documentDir() ); 866 cd(QPEApplication::documentDir() );
876} 867}
877void OFileSelector::slotNavigate( ) 868void OFileSelector::slotNavigate( )
878{ 869{
879 870
880} 871}
881// fill the View with life 872// fill the View with life
882void OFileSelector::reparse() 873void OFileSelector::reparse()
883{ 874{
884 if( m_selector == Normal ) 875 if( m_selector == Normal )
885 return; 876 return;
886 877
887 currentView()->clear(); 878 currentView()->clear();
888 879
889 if( m_shChooser) 880 if( m_shChooser)
890 qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); 881 qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
diff --git a/libopie/ofileselector/olister.cpp b/libopie/ofileselector/olister.cpp
index ea09940..aaaf6a2 100644
--- a/libopie/ofileselector/olister.cpp
+++ b/libopie/ofileselector/olister.cpp
@@ -1,25 +1,26 @@
1#include <qcombobox.h> 1#include <qcombobox.h>
2#include <qlineedit.h>
2 3
3#include "olister.h" 4#include "olister.h"
4#include "ofileview.h" 5#include "ofileview.h"
5#include "opixmapprovider.h" 6#include "opixmapprovider.h"
6#include "ofileselector.h" 7#include "ofileselector.h"
7 8
8 9
9OLister::OLister( OFileSelector* view) 10OLister::OLister( OFileSelector* view)
10 : m_view( view ), m_acc( 0l ) 11 : m_view( view ), m_acc( 0l )
11{ 12{
12 m_prov = new OPixmapProvider( view ); 13 m_prov = new OPixmapProvider( view );
13} 14}
14OLister::~OLister() { 15OLister::~OLister() {
15 delete m_prov; 16 delete m_prov;
16} 17}
17void OLister::setPixmapProvider( OPixmapProvider* prov ) { 18void OLister::setPixmapProvider( OPixmapProvider* prov ) {
18 delete m_prov; 19 delete m_prov;
19 m_prov = prov; 20 m_prov = prov;
20} 21}
21bool OLister::showFiles()const { 22bool OLister::showFiles()const {
22 return m_view->showFiles(); 23 return m_view->showFiles();
23} 24}
24bool OLister::showDirs()const { 25bool OLister::showDirs()const {
25 return m_view->showDirs(); 26 return m_view->showDirs();
@@ -91,48 +92,51 @@ void OLister::addSymlink( const QString& mine,
91 QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, info ); 92 QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, info );
92 view()->currentView()->addSymlink( pix, 93 view()->currentView()->addSymlink( pix,
93 mine, 94 mine,
94 info, 95 info,
95 extra, 96 extra,
96 isSymlink ); 97 isSymlink );
97} 98}
98void OLister::addSymlink( const QString& mine, 99void OLister::addSymlink( const QString& mine,
99 const QString& path, 100 const QString& path,
100 const QString& name, 101 const QString& name,
101 const QString& extra, 102 const QString& extra,
102 bool isSymlink ) { 103 bool isSymlink ) {
103 QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, 104 QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine,
104 path, name ); 105 path, name );
105 view()->currentView()->addSymlink( pix, 106 view()->currentView()->addSymlink( pix,
106 mine, 107 mine,
107 path, 108 path,
108 name, 109 name,
109 extra, 110 extra,
110 isSymlink ); 111 isSymlink );
111} 112}
112OFileSelector* OLister::view() { 113OFileSelector* OLister::view() {
113 return m_view; 114 return m_view;
114} 115}
116OFileSelector* OLister::view()const {
117 return m_view;
118}
115OPixmapProvider* OLister::provider() { 119OPixmapProvider* OLister::provider() {
116 return m_prov; 120 return m_prov;
117} 121}
118bool OLister::compliesMime( const QString& mime ) { 122bool OLister::compliesMime( const QString& mime ) {
119 return view()->compliesMime( mime ); 123 return view()->compliesMime( mime );
120} 124}
121void OLister::internFileSelected( const QString& dir ) { 125void OLister::internFileSelected( const QString& dir ) {
122 view()->internFileSelected( dir ); 126 view()->internFileSelected( dir );
123} 127}
124void OLister::internChangedDir( const QString& dir ) { 128void OLister::internChangedDir( const QString& dir ) {
125 view()->internChangedDir( dir ); 129 view()->internChangedDir( dir );
126} 130}
127OListerCmbAccess* OLister::comboBox() { 131OListerCmbAccess* OLister::comboBox() {
128 if (!m_acc ) 132 if (!m_acc )
129 m_acc = new OListerCmbAccess( view()->m_location ); 133 m_acc = new OListerCmbAccess( view()->m_location );
130 134
131 return m_acc; 135 return m_acc;
132} 136}
133 137
134 138
135OListerCmbAccess::OListerCmbAccess(QComboBox* cmb ) 139OListerCmbAccess::OListerCmbAccess(QComboBox* cmb )
136 : m_cmb( cmb ) 140 : m_cmb( cmb )
137{} 141{}
138OListerCmbAccess::~OListerCmbAccess() { 142OListerCmbAccess::~OListerCmbAccess() {
@@ -148,24 +152,30 @@ void OListerCmbAccess::setCurrentItem( const QString& add, bool FORCE_ADD) {
148 int c = m_cmb->count(); 152 int c = m_cmb->count();
149 for ( int i = 0; i < m_cmb->count(); i++ ) { 153 for ( int i = 0; i < m_cmb->count(); i++ ) {
150 if ( m_cmb->text(i) == add ) { 154 if ( m_cmb->text(i) == add ) {
151 m_cmb->setCurrentItem( i ); 155 m_cmb->setCurrentItem( i );
152 return; 156 return;
153 } 157 }
154 } 158 }
155 if (!FORCE_ADD ) return; 159 if (!FORCE_ADD ) return;
156 160
157 161
158 m_cmb->insertItem(add ); 162 m_cmb->insertItem(add );
159 m_cmb->setCurrentItem( c ); 163 m_cmb->setCurrentItem( c );
160} 164}
161void OListerCmbAccess::insert( const QString& str ) { 165void OListerCmbAccess::insert( const QString& str ) {
162 if ( m_cmb ) 166 if ( m_cmb )
163 m_cmb->insertItem( str ); 167 m_cmb->insertItem( str );
164} 168}
165QString OListerCmbAccess::currentText()const { 169QString OListerCmbAccess::currentText()const {
166 QString str; 170 QString str;
167 if (m_cmb ) 171 if (m_cmb )
168 str = m_cmb->currentText(); 172 str = m_cmb->currentText();
169 173
170 return str; 174 return str;
171} 175}
176QString OLister::lineEdit()const {
177 if ( view()->m_shLne )
178 return view()->m_edit->text();
179
180 return QString::null;
181}
diff --git a/libopie/ofileselector/olister.h b/libopie/ofileselector/olister.h
index cd84316..4adb9f8 100644
--- a/libopie/ofileselector/olister.h
+++ b/libopie/ofileselector/olister.h
@@ -2,105 +2,121 @@
2#define OPIE_FILE_LISTER_H 2#define OPIE_FILE_LISTER_H
3 3
4#include <qfileinfo.h> 4#include <qfileinfo.h>
5#include <qmap.h> 5#include <qmap.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8 8
9class QComboBox; 9class QComboBox;
10class OPixmapProvider; 10class OPixmapProvider;
11class OFileSelector; 11class OFileSelector;
12 12
13class OListerCmbAccess; 13class OListerCmbAccess;
14/** 14/**
15 * lister is something like KIO but very 15 * lister is something like KIO but very
16 * very basic and currently only for 16 * very basic and currently only for
17 * populating our views. 17 * populating our views.
18 * This is a base class which needs to be implemented. 18 * This is a base class which needs to be implemented.
19 * @see OLocalLister for a filesystem based implementation 19 * @see OLocalLister for a filesystem based implementation
20 */ 20 */
21 21
22class OLister { 22class OLister {
23public: 23public:
24 OLister( OFileSelector* ); 24 OLister( OFileSelector* );
25 virtual ~OLister(); 25 virtual ~OLister();
26 virtual void reparse(const QString& path) = 0; 26
27 /**
28 * if path == QString::null reread current dir
29 */
30 virtual void reparse(const QString& path = QString::null ) = 0;
27 31
28 /** 32 /**
29 * return a list of available mimetypes 33 * return a list of available mimetypes
30 */ 34 */
31 virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0; 35 virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0;
32 void setPixmapProvider( OPixmapProvider* ); 36 void setPixmapProvider( OPixmapProvider* );
33 37
34 38
35 /* some way a slot */ 39 /* some way a slot */
36 virtual void fileSelected( const QString& dir, const QString& file, const QString& extra ) = 0; 40 virtual void fileSelected( const QString& dir, const QString& file, const QString& extra ) = 0;
37 virtual void changedDir( const QString& dir, const QString& file, const QString& extra ) = 0; 41 virtual void changedDir( const QString& dir, const QString& file, const QString& extra ) = 0;
42 virtual QString selectedName()const = 0;
43 virtual QStringList selectedNames()const = 0;
38protected: 44protected:
39 /** 45 /**
40 * I hate too big classes 46 * I hate too big classes
41 * this is a way to group 47 * this is a way to group
42 * access to a ComboBox 48 * access to a ComboBox
43 * which might exist or 49 * which might exist or
44 * not in a secure way 50 * not in a secure way
45 */ 51 */
46 OListerCmbAccess* comboBox(); 52 OListerCmbAccess* comboBox();
47 53
48 bool showFiles()const; 54 bool showFiles()const;
49 bool showDirs()const; 55 bool showDirs()const;
50 bool compliesMime( const QString& mime ); 56 bool compliesMime( const QString& mime );
51 void addFile( const QString& mine, 57 void addFile( const QString& mine,
52 QFileInfo*, 58 QFileInfo*,
53 const QString& extra = QString::null, 59 const QString& extra = QString::null,
54 bool isSymlink = FALSE ); 60 bool isSymlink = FALSE );
55 61
56 void addFile( const QString& mine, 62 void addFile( const QString& mine,
57 const QString& path, 63 const QString& path,
58 const QString& file, 64 const QString& file,
59 const QString& extra = QString::null, 65 const QString& extra = QString::null,
60 bool isSymlink = FALSE ); 66 bool isSymlink = FALSE );
61 void addDir( const QString& mine, 67 void addDir( const QString& mine,
62 QFileInfo*, 68 QFileInfo*,
63 const QString& extra = QString::null, 69 const QString& extra = QString::null,
64 bool isSymlink = FALSE ); 70 bool isSymlink = FALSE );
65 void addDir( const QString& mine, 71 void addDir( const QString& mine,
66 const QString& path, 72 const QString& path,
67 const QString& dir, 73 const QString& dir,
68 const QString& extra = QString::null, 74 const QString& extra = QString::null,
69 bool isSymlink = FALSE ); 75 bool isSymlink = FALSE );
70 void addSymlink( const QString& mine, 76 void addSymlink( const QString& mine,
71 QFileInfo* info, 77 QFileInfo* info,
72 const QString& extra = QString::null, 78 const QString& extra = QString::null,
73 bool isSymlink = FALSE); 79 bool isSymlink = FALSE);
74 void addSymlink( const QString& mine, 80 void addSymlink( const QString& mine,
75 const QString& path, 81 const QString& path,
76 const QString& name, 82 const QString& name,
77 const QString& extra = QString::null, 83 const QString& extra = QString::null,
78 bool isSymlink = FALSE ); 84 bool isSymlink = FALSE );
79 OFileSelector* view(); 85 OFileSelector* view();
86 OFileSelector* view()const;
80 OPixmapProvider* provider(); 87 OPixmapProvider* provider();
81 void internFileSelected( const QString& file ); 88 void internFileSelected( const QString& file );
82 void internChangedDir( const QString& dir ); 89 void internChangedDir( const QString& dir );
90
91 /**
92 * try to take
93 * the text from the mainwindows
94 * lineedit
95 * if it's not available QString::null
96 * will be returned
97 */
98 QString lineEdit()const;
83private: 99private:
84 OFileSelector* m_view; 100 OFileSelector* m_view;
85 OPixmapProvider* m_prov; 101 OPixmapProvider* m_prov;
86 OListerCmbAccess* m_acc; 102 OListerCmbAccess* m_acc;
87 103
88 class Private; 104 class Private;
89 Private *d; 105 Private *d;
90}; 106};
91 107
92class OListerCmbAccess { 108class OListerCmbAccess {
93 friend class OLister; 109 friend class OLister;
94public: 110public:
95 OListerCmbAccess( QComboBox* = 0l); 111 OListerCmbAccess( QComboBox* = 0l);
96 ~OListerCmbAccess(); 112 ~OListerCmbAccess();
97 113
98 /** 114 /**
99 * clears the combobox 115 * clears the combobox
100 */ 116 */
101 void clear(); 117 void clear();
102 118
103 /** 119 /**
104 * set's @param add to be the current Item 120 * set's @param add to be the current Item
105 * if the item is not present it'll be removed 121 * if the item is not present it'll be removed
106 */ 122 */
diff --git a/libopie/ofileselector/olocallister.cpp b/libopie/ofileselector/olocallister.cpp
index 5d7884d..4d36d64 100644
--- a/libopie/ofileselector/olocallister.cpp
+++ b/libopie/ofileselector/olocallister.cpp
@@ -1,80 +1,85 @@
1#include <qdir.h> 1#include <qdir.h>
2#include <qfileinfo.h> 2#include <qfileinfo.h>
3#include <qmap.h> 3#include <qmap.h>
4 4
5#include <qpe/mimetype.h> 5#include <qpe/mimetype.h>
6 6
7#include "ofileselector.h" 7#include "ofileselector.h"
8#include "ofileview.h"
8#include "olocallister.h" 9#include "olocallister.h"
9 10
10OLocalLister::OLocalLister( OFileSelector* file ) 11OLocalLister::OLocalLister( OFileSelector* file )
11 : OLister( file ) 12 : OLister( file )
12{ 13{
14 m_dir = QDir::homeDirPath();
13} 15}
14OLocalLister::~OLocalLister() { 16OLocalLister::~OLocalLister() {
15} 17}
16 18
17QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) { 19QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) {
18 QMap<QString, QStringList> mimes; 20 QMap<QString, QStringList> mimes;
19 21
20 // let's find possible mimetypes 22 // let's find possible mimetypes
21 QDir dir( curDir ); 23 QDir dir( curDir );
22 dir.setFilter( QDir::Files | QDir::Readable ); 24 dir.setFilter( QDir::Files | QDir::Readable );
23 dir.setSorting( QDir::Size ); 25 dir.setSorting( QDir::Size );
24 26
25 const QFileInfoList *list = dir.entryInfoList(); 27 const QFileInfoList *list = dir.entryInfoList();
26 QFileInfoListIterator it( *list ); 28 QFileInfoListIterator it( *list );
27 QFileInfo *fi; 29 QFileInfo *fi;
28 30
29 while( (fi=it.current() ) ) { 31 while( (fi=it.current() ) ) {
30 /* skip .desktop */ 32 /* skip .desktop */
31 if( fi->extension() == QString::fromLatin1("desktop") ){ 33 if( fi->extension() == QString::fromLatin1("desktop") ){
32 ++it; 34 ++it;
33 continue; 35 continue;
34 } 36 }
35 MimeType type( fi->absFilePath() ); 37 MimeType type( fi->absFilePath() );
36 38
37 if( !mimes.contains( type.id() ) ){ 39 if( !mimes.contains( type.id() ) ){
38 mimes.insert( type.id(), type.id() ); 40 mimes.insert( type.id(), type.id() );
39 } 41 }
40 42
41 ++it; 43 ++it;
42 } 44 }
43 45
44 return mimes; 46 return mimes;
45} 47}
46/** 48/**
47 * FIXME mimecheck 49 * FIXME mimecheck
48 * use mime check for that 50 * use mime check for that
49 * filter dirs 51 * filter dirs
50 * filter filters 52 * filter filters
51 * filter files 53 * filter files
52 * filter mimetypes 54 * filter mimetypes
53 */ 55 */
54void OLocalLister::reparse( const QString& path ) { 56void OLocalLister::reparse( const QString& pa ) {
57 if (!pa.isEmpty() )
58 m_dir = pa;
59
55 QString currentMimeType; 60 QString currentMimeType;
56 QDir dir( path ); 61 QDir dir( m_dir );
57 62
58 dir.setSorting( view()->sorting() ); 63 dir.setSorting( view()->sorting() );
59 dir.setFilter( view()->filter() ); 64 dir.setFilter( view()->filter() );
60 65
61 66
62 const QFileInfoList *list = dir.entryInfoList(); 67 const QFileInfoList *list = dir.entryInfoList();
63 QFileInfoListIterator it( *list ); 68 QFileInfoListIterator it( *list );
64 QFileInfo *fi; 69 QFileInfo *fi;
65 70
66 while( (fi=it.current() ) ){ 71 while( (fi=it.current() ) ){
67 72
68 if( fi->fileName() == QString::fromLatin1("..") || 73 if( fi->fileName() == QString::fromLatin1("..") ||
69 fi->fileName() == QString::fromLatin1(".") ){ 74 fi->fileName() == QString::fromLatin1(".") ){
70 ++it; 75 ++it;
71 continue; 76 continue;
72 } 77 }
73 if( fi->isSymLink() ){ 78 if( fi->isSymLink() ){
74 QString file = fi->dirPath( true ) + "/" + fi->readLink(); 79 QString file = fi->dirPath( true ) + "/" + fi->readLink();
75 /* 80 /*
76 * 5 tries to prevent dos attack 81 * 5 tries to prevent dos attack
77 */ 82 */
78 for( int i = 0; i<=4; i++) { 83 for( int i = 0; i<=4; i++) {
79 QFileInfo info( file ); 84 QFileInfo info( file );
80 if( !info.exists() ){ 85 if( !info.exists() ){
@@ -102,24 +107,44 @@ void OLocalLister::reparse( const QString& path ) {
102 file = info.dirPath(true ) + "/" + info.readLink() ; 107 file = info.dirPath(true ) + "/" + info.readLink() ;
103 break; 108 break;
104 }else if( i == 4){ 109 }else if( i == 4){
105 addSymlink( currentMimeType, fi ); 110 addSymlink( currentMimeType, fi );
106 } 111 }
107 } 112 }
108 113
109 }else if( fi->isDir() ){ 114 }else if( fi->isDir() ){
110 if (showDirs() ) 115 if (showDirs() )
111 addDir( currentMimeType, fi ); 116 addDir( currentMimeType, fi );
112 }else if( fi->isFile() ){ 117 }else if( fi->isFile() ){
113 if ( showFiles() ) 118 if ( showFiles() )
114 addFile( currentMimeType, fi ); 119 addFile( currentMimeType, fi );
115 } 120 }
116 ++it; 121 ++it;
117 } // of while loop 122 } // of while loop
118} 123}
119/* more accepting it code */ 124/* more accepting it code */
120void OLocalLister::fileSelected( const QString& dir, const QString& file, const QString& ) { 125void OLocalLister::fileSelected( const QString& dir, const QString& file, const QString& ) {
121 internFileSelected( dir + "/" + file ); 126 internFileSelected( dir + "/" + file );
122} 127}
123void OLocalLister::changedDir( const QString& dir, const QString& file, const QString& ) { 128void OLocalLister::changedDir( const QString& dir, const QString& file, const QString& ) {
124 internChangedDir( dir + "/" + file ); 129 internChangedDir( dir + "/" + file );
125} 130}
131/*
132 * assemble the the Url now
133 */
134QString OLocalLister::selectedName()const {
135 QString str = m_dir;
136 QString name = lineEdit();
137
138 if ( name.isEmpty() )
139 name = view()->currentView()->selectedName();
140
141 str += "/" + name;
142
143 return str;
144}
145QStringList OLocalLister::selectedNames()const {
146 QStringList list;
147 list << selectedName();
148
149 return list;
150}
diff --git a/libopie/ofileselector/olocallister.h b/libopie/ofileselector/olocallister.h
index 01e6f3c..0cdf51f 100644
--- a/libopie/ofileselector/olocallister.h
+++ b/libopie/ofileselector/olocallister.h
@@ -1,16 +1,21 @@
1#ifndef OPIE_LOCAL_LISTER 1#ifndef OPIE_LOCAL_LISTER
2#define OPIE_LOCAL_LISTER 2#define OPIE_LOCAL_LISTER
3 3
4#include "olister.h" 4#include "olister.h"
5 5
6class OLocalLister : public OLister { 6class OLocalLister : public OLister {
7public: 7public:
8 OLocalLister( OFileSelector* ); 8 OLocalLister( OFileSelector* );
9 ~OLocalLister(); 9 ~OLocalLister();
10 void reparse( const QString& path ); 10 void reparse( const QString& path );
11 QMap<QString, QStringList> mimeTypes(const QString& dir ); 11 QMap<QString, QStringList> mimeTypes(const QString& dir );
12 void fileSelected( const QString& dir, const QString& file, const QString& ); 12 void fileSelected( const QString& dir, const QString& file, const QString& );
13 void changedDir( const QString& dir, const QString& file,const QString& ); 13 void changedDir( const QString& dir, const QString& file,const QString& );
14 QString selectedName()const;
15 QStringList selectedNames()const;
16
17private:
18 QString m_dir;
14}; 19};
15 20
16#endif 21#endif