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
@@ -257,30 +257,24 @@ void OFileSelector::setSelector(int mode )
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();
@@ -417,17 +411,16 @@ void 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)
@@ -449,18 +442,16 @@ void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count
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... */
@@ -849,26 +840,26 @@ void OFileSelector::slotDelete()
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{
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,9 +1,10 @@
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)
@@ -107,16 +108,19 @@ void OLister::addSymlink( const QString& 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 );
@@ -164,8 +168,14 @@ void OListerCmbAccess::insert( const QString& 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
@@ -18,28 +18,34 @@ class OListerCmbAccess;
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 */
@@ -72,19 +78,29 @@ protected:
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};
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,20 +1,22 @@
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
@@ -46,19 +48,22 @@ QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) {
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;
@@ -118,8 +123,28 @@ void OLocalLister::reparse( const QString& path ) {
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
@@ -6,11 +6,16 @@
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