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