summaryrefslogtreecommitdiff
authorzecke <zecke>2002-04-12 13:07:35 (UTC)
committer zecke <zecke>2002-04-12 13:07:35 (UTC)
commit3973cf42c778055ab81a9ee254eaf8829464f936 (patch) (unidiff)
tree4ae4fc512c9e37657ea9f4e05f28d1ea57a855d3
parentc1c9ac64f7f4871642d645ac1da1a2f36853ccb2 (diff)
downloadopie-3973cf42c778055ab81a9ee254eaf8829464f936.zip
opie-3973cf42c778055ab81a9ee254eaf8829464f936.tar.gz
opie-3973cf42c778055ab81a9ee254eaf8829464f936.tar.bz2
Add OFileDialog to the .pro
OFileDialog is now working resize it when not used by the static methods OFileSelector some bugfixes. Some bugs are not yet fixed (the switching from views can segfault )
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/libopie.pro4
-rw-r--r--libopie/ofiledialog.cc14
-rw-r--r--libopie/ofileselector.cc40
3 files changed, 20 insertions, 38 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro
index 4ba2836..3c8da78 100644
--- a/libopie/libopie.pro
+++ b/libopie/libopie.pro
@@ -1,8 +1,8 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qte warn_on release 2CONFIG += qte warn_on release
3 HEADERS = ofileselector.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h oconfig.h 3 HEADERS = ofileselector.h ofiledialog.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h oconfig.h
4 SOURCES = ofileselector.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp oconfig.cpp 4 SOURCES = ofileselector.cc ofiledialog.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp oconfig.cpp
5 TARGET = opie 5 TARGET = opie
6INCLUDEPATH += $(OPIEDIR)/include 6INCLUDEPATH += $(OPIEDIR)/include
7DESTDIR = $(QTDIR)/lib$(PROJMAK) 7DESTDIR = $(QTDIR)/lib$(PROJMAK)
8#VERSION = 1.0.0 \ No newline at end of file 8#VERSION = 1.0.0 \ No newline at end of file
diff --git a/libopie/ofiledialog.cc b/libopie/ofiledialog.cc
index 92b0d0a..164fadd 100644
--- a/libopie/ofiledialog.cc
+++ b/libopie/ofiledialog.cc
@@ -1,110 +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 QStringList &mimetypes ) 40 const 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 44 //showMaximized();
45 file = new OFileSelector(0 , mode, selector, 45 QVBoxLayout *lay = new QVBoxLayout(this );
46 file = new OFileSelector(this , mode, selector,
46 dirName, fileName, 47 dirName, fileName,
47 mimetypes ); 48 mimetypes );
48 lay->addWidget( file ); 49 lay->addWidget( file );
50
51 //lay->addWidget( file );
49 //showFullScreen(); 52 //showFullScreen();
50 setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); 53 setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
51 connect(file, SIGNAL(fileSelected(const QString&) ), 54 connect(file, SIGNAL(fileSelected(const QString&) ),
52 this, SLOT(slotFileSelected(const QString&) ) ); 55 this, SLOT(slotFileSelected(const QString&) ) );
53 56
54 connect(file, SIGNAL(dirSelected(const QString &) ), 57 connect(file, SIGNAL(dirSelected(const QString &) ),
55 this, SLOT(slotDirSelected(const QString &) ) ); 58 this, SLOT(slotDirSelected(const QString &) ) );
56 showMaximized(); 59
60
57 file->setYesCancelVisible( false ); // relayout 61 file->setYesCancelVisible( false ); // relayout
58} 62}
59QString OFileDialog::mimetype()const 63QString OFileDialog::mimetype()const
60{ 64{
61 return QString::null; 65 return QString::null;
62} 66}
63QString OFileDialog::fileName()const 67QString OFileDialog::fileName()const
64{ 68{
65 return file->selectedName(); 69 return file->selectedName();
66} 70}
67DocLnk OFileDialog::selectedDocument()const 71DocLnk OFileDialog::selectedDocument()const
68{ 72{
69 return file->selectedDocument(); 73 return file->selectedDocument();
70} 74}
71QString OFileDialog::getOpenFileName(int selector, 75QString OFileDialog::getOpenFileName(int selector,
72 const QString &startDir, 76 const QString &startDir,
73 const QString &file, 77 const QString &file,
74 const QStringList &mimes, 78 const QStringList &mimes,
75 QWidget *wid, 79 QWidget *wid,
76 const QString &caption ) 80 const QString &caption )
77{ 81{
78 QString ret; 82 QString ret;
79 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, 83 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption,
80 wid, OFileSelector::OPEN, selector, startDir, file, mimes); 84 wid, OFileSelector::OPEN, selector, startDir, file, mimes);
85 dlg.showMaximized();
81 if( dlg.exec() ) 86 if( dlg.exec() )
82 ret = dlg.fileName(); 87 ret = dlg.fileName();
83 88
84 return ret; 89 return ret;
85} 90}
86QString OFileDialog::getSaveFileName(int selector, 91QString OFileDialog::getSaveFileName(int selector,
87 const QString &startDir, 92 const QString &startDir,
88 const QString &file, 93 const QString &file,
89 const QStringList &mimes, 94 const QStringList &mimes,
90 QWidget *wid, 95 QWidget *wid,
91 const QString &caption ) 96 const QString &caption )
92{ 97{
93 QString ret; 98 QString ret;
94 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, 99 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption,
95 wid, OFileSelector::SAVE, selector, startDir, file, mimes); 100 wid, OFileSelector::SAVE, selector, startDir, file, mimes);
101 dlg.showMaximized();
96 if( dlg.exec() ) 102 if( dlg.exec() )
97 ret = dlg.fileName(); 103 ret = dlg.fileName();
98 104
99 return ret; 105 return ret;
100} 106}
101 107
102void OFileDialog::slotFileSelected(const QString & ) 108void OFileDialog::slotFileSelected(const QString & )
103{ 109{
104 accept(); 110 accept();
105} 111}
106void OFileDialog::slotDirSelected(const QString & ) 112void OFileDialog::slotDirSelected(const QString & )
107{ 113{
108 // if mode 114 // if mode
109 //accept(); 115 //accept();
110} 116}
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index c3a3514..7451c1b 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -1,1082 +1,1058 @@
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 Holger Freyther <zecke@handhelds.org> 3             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
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 <qnamespace.h> 29#include <qnamespace.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qhbox.h> 32#include <qhbox.h>
33#include <qvbox.h> 33#include <qvbox.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qwidgetstack.h> 35#include <qwidgetstack.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qcheckbox.h> 37#include <qcheckbox.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qheader.h> 39#include <qheader.h>
40#include <qdir.h> 40#include <qdir.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qaction.h> 42#include <qaction.h>
43#include <qpopupmenu.h> 43#include <qpopupmenu.h>
44#include <qcursor.h> 44#include <qcursor.h>
45 45
46#include <qpe/qpeapplication.h> 46#include <qpe/qpeapplication.h>
47#include <qpe/fileselector.h> 47#include <qpe/fileselector.h>
48#include <qpe/applnk.h> 48#include <qpe/applnk.h>
49#include <qpe/global.h> 49#include <qpe/global.h>
50#include <qpe/mimetype.h> 50#include <qpe/mimetype.h>
51#include <qpe/resource.h> 51#include <qpe/resource.h>
52#include <qpe/storage.h> 52#include <qpe/storage.h>
53 53
54#include <unistd.h> 54#include <unistd.h>
55#include <stdlib.h> 55#include <stdlib.h>
56#include <sys/stat.h> 56#include <sys/stat.h>
57 57
58#include "ofileselector.h" 58#include "ofileselector.h"
59 59
60QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; 60QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
61 61
62namespace { 62namespace {
63 63
64 int indexByString( const QComboBox *box, const QString &str ){ 64 int indexByString( const QComboBox *box, const QString &str ){
65 int index= -1; 65 int index= -1;
66 for(int i= 0; i < box->count(); i++ ){ 66 for(int i= 0; i < box->count(); i++ ){
67 qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); 67 qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() );
68 if( str == box->text(i ) ){ 68 if( str == box->text(i ) ){
69 index= i; 69 index= i;
70 break; 70 break;
71 } 71 }
72 } 72 }
73 return index; 73 return index;
74 } 74 }
75 75
76}; 76};
77 77
78 78
79OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, 79OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName,
80 const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) 80 const QString &fileName, const QStringList &mimetypes ) : QWidget( wid )
81{ 81{
82 82 if(wid!=0)
83 resize(wid->width(),wid->height()); 83 resize(wid->width(),wid->height());
84 m_selector = selector; 84 m_selector = selector;
85 m_currentDir = dirName; 85 m_currentDir = dirName;
86 m_name = fileName; 86 m_name = fileName;
87 m_mimetypes = mimetypes; 87 m_mimetypes = mimetypes;
88 if( mimetypes.isEmpty() ) 88 if( mimetypes.isEmpty() )
89 m_autoMime = true; 89 m_autoMime = true;
90 90
91 m_mode = mode; 91 m_mode = mode;
92 m_shTool = true; 92 m_shTool = true;
93 m_shPerm = true; 93 m_shPerm = true;
94 m_shLne = true; 94 m_shLne = true;
95 m_shChooser = true; 95 m_shChooser = true;
96 m_shYesNo = true; 96 m_shYesNo = true;
97 // for FILESELECTOR only view is interesting 97 // for FILESELECTOR only view is interesting
98 m_location = 0; 98 m_location = 0;
99 m_homeButton = 0; 99 m_homeButton = 0;
100 m_docButton = 0; 100 m_docButton = 0;
101 m_hideButton = 0; 101 m_hideButton = 0;
102 m_ok = 0; 102 m_ok = 0;
103 m_cancel = 0; 103 m_cancel = 0;
104 m_reread = 0; 104 m_reread = 0;
105 m_up = 0; 105 m_up = 0;
106 m_View = 0; 106 m_View = 0;
107 m_select = 0; 107 m_select = 0;
108 m_stack = 0; 108 m_stack = 0;
109 109
110 m_select = 0; 110 m_select = 0;
111 m_stack = 0; 111 m_stack = 0;
112 m_lay = 0; 112 m_lay = 0;
113 m_boxToolbar = 0; 113 m_boxToolbar = 0;
114 m_boxOk = 0; 114 m_boxOk = 0;
115 m_edit = 0; 115 m_edit = 0;
116 116
117 m_fnLabel = 0; 117 m_fnLabel = 0;
118 m_checkPerm = 0; 118 m_checkPerm = 0;
119 m_mimeCheck = 0; 119 m_mimeCheck = 0;
120 m_viewCheck = 0; 120 m_viewCheck = 0;
121 121
122 m_pseudo = 0; 122 m_pseudo = 0;
123 m_pseudoLayout = 0; 123 m_pseudoLayout = 0;
124 124
125 m_dir = true; 125 m_dir = true;
126 m_files = true; 126 m_files = true;
127 m_custom = 0; 127 m_custom = 0;
128 m_showPopup = true; 128 m_showPopup = true;
129 129
130 if(m_pixmaps == 0 ) // init the pixmaps 130 if(m_pixmaps == 0 ) // init the pixmaps
131 initPics(); 131 initPics();
132 132
133 m_lay = new QVBoxLayout(this); 133 m_lay = new QVBoxLayout(this);
134 init(); 134 init();
135 m_edit->setText( fileName ); 135 m_edit->setText( fileName );
136} 136}
137void OFileSelector::initPics() 137void OFileSelector::initPics()
138{ 138{
139 qWarning("init pics" ); 139 qWarning("init pics" );
140 m_pixmaps = new QMap<QString,QPixmap>; 140 m_pixmaps = new QMap<QString,QPixmap>;
141 QPixmap pm = Resource::loadPixmap( "folder" ); 141 QPixmap pm = Resource::loadPixmap( "folder" );
142 QPixmap lnk = Resource::loadPixmap( "symlink" ); 142 QPixmap lnk = Resource::loadPixmap( "symlink" );
143 QPainter painter( &pm ); 143 QPainter painter( &pm );
144 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 144 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
145 pm.setMask( pm.createHeuristicMask( FALSE ) ); 145 pm.setMask( pm.createHeuristicMask( FALSE ) );
146 m_pixmaps->insert("dirsymlink", pm ); 146 m_pixmaps->insert("dirsymlink", pm );
147 147
148 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); 148 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
149 QPainter pen(&pm2 ); 149 QPainter pen(&pm2 );
150 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); 150 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
151 pm2.setMask( pm2.createHeuristicMask( FALSE ) ); 151 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
152 m_pixmaps->insert("symlinkedlocked", pm2 ); 152 m_pixmaps->insert("symlinkedlocked", pm2 );
153 153
154}; 154};
155// let's initialize the gui 155// let's initialize the gui
156/** 156/**
157 -------------------- 157 --------------------
158 | cmbBox Button | 158 | cmbBox Button |
159 -------------------- 159 --------------------
160 | FileSlector | 160 | FileSlector |
161 | or | 161 | or |
162 | OSelector | 162 | OSelector |
163 | | 163 | |
164 | | 164 | |
165 ____________________ 165 ____________________
166 | LineEdit | 166 | LineEdit |
167 ____________________ 167 ____________________
168 | Permission Bar | 168 | Permission Bar |
169 ____________________ 169 ____________________
170 | ViewChoose | 170 | ViewChoose |
171 ____________________ 171 ____________________
172 | Save Cancel| 172 | Save Cancel|
173 ____________________ 173 ____________________
174 */ 174 */
175void OFileSelector::delItems() 175void OFileSelector::delItems()
176{ 176{
177 QLayoutIterator it = m_lay->iterator(); 177 QLayoutIterator it = m_lay->iterator();
178 while ( it.current() != 0 ){ 178 while ( it.current() != 0 ){
179 it.deleteCurrent(); 179 it.deleteCurrent();
180 } 180 }
181} 181}
182void OFileSelector::init() 182void OFileSelector::init()
183{ 183{
184 184
185 m_stack = new QWidgetStack(this, "wstack" ); 185 m_stack = new QWidgetStack(this, "wstack" );
186 if( m_selector == NORMAL ){ 186 if( m_selector == NORMAL ){
187 QString currMime; 187 QString currMime;
188 if( m_mimeCheck != 0 ) 188 if( m_mimeCheck != 0 )
189 currMime = m_mimeCheck->currentText(); 189 currMime = m_mimeCheck->currentText();
190 190
191 updateMimes(); 191 updateMimes();
192 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); 192 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE );
193 m_stack->addWidget(m_select, NORMAL ); 193 m_stack->addWidget(m_select, NORMAL );
194 m_lay->addWidget(m_stack ); 194 m_lay->addWidget(m_stack );
195 m_stack->raiseWidget(NORMAL ); 195 m_stack->raiseWidget(NORMAL );
196 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); 196 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
197 m_pseudoLayout = 0l;
197 }else { 198 }else {
198 initializeListView(); 199 initializeListView();
199 } 200 }
200 201
201 if(m_shLne ){ 202 if(m_shLne ){
202 initializeName(); 203 initializeName();
203 } 204 }
204 205
205 if(m_shPerm ){ 206 if(m_shPerm ){
206 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); 207 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" );
207 m_checkPerm->setChecked( false ); 208 m_checkPerm->setChecked( false );
208 m_lay->addWidget(m_checkPerm ); 209 m_lay->addWidget(m_checkPerm );
209 } 210 }
210 211
211 if( m_shChooser ) 212 if( m_shChooser )
212 initializeChooser(); 213 initializeChooser();
213 214
214 if(m_shYesNo ) 215 if(m_shYesNo )
215 initializeYes(); 216 initializeYes();
216 217
217 218
218}; 219};
219 220
220void OFileSelector::setYesCancelVisible( bool show ) 221void OFileSelector::setYesCancelVisible( bool show )
221{ 222{
222 if ( show == m_shYesNo ) 223 if ( show == m_shYesNo )
223 return; 224 return;
224 m_shYesNo = show; 225 m_shYesNo = show;
225 if( !show ){ 226 if( !show ){
226 delete m_ok; 227 delete m_ok;
227 delete m_cancel; 228 delete m_cancel;
228 m_ok = 0; 229 m_ok = 0;
229 m_cancel = 0; 230 m_cancel = 0;
230 // delete m_boxOk; all ready deleted in delItems 231 // delete m_boxOk; all ready deleted in delItems
231 } 232 }
232 updateLay(); // recreate it and save the other states 233 updateLay(); // recreate it and save the other states
233} 234}
234 235
235void OFileSelector::setToolbarVisible( bool show ) 236void OFileSelector::setToolbarVisible( bool show )
236{ 237{
237 if ( m_shTool == show ) 238 if ( m_shTool == show )
238 return; 239 return;
239 if(!m_shTool ){ 240 if(!m_shTool ){
240 delete m_boxToolbar; 241 delete m_boxToolbar;
241 delete m_homeButton; 242 delete m_homeButton;
242 delete m_docButton; 243 delete m_docButton;
243 delete m_location; 244 delete m_location;
244 delete m_up; 245 delete m_up;
245 m_boxToolbar = 0; 246 m_boxToolbar = 0;
246 m_homeButton = 0; 247 m_homeButton = 0;
247 m_docButton = 0; 248 m_docButton = 0;
248 m_location = 0; 249 m_location = 0;
249 m_up = 0; 250 m_up = 0;
250 }; 251 };
251 updateLay();// overkill fix it 252 updateLay();// overkill fix it
252} 253}
253 254
254void OFileSelector::setPermissionBarVisible( bool show ) 255void OFileSelector::setPermissionBarVisible( bool show )
255{ 256{
256 if( show == m_shPerm ) 257 if( show == m_shPerm )
257 return; 258 return;
258 259
259 m_shPerm = show; 260 m_shPerm = show;
260 261
261 updateLay(); 262 updateLay();
262} 263}
263void OFileSelector::setLineEditVisible( bool show ) 264void OFileSelector::setLineEditVisible( bool show )
264{ 265{
265 if( show == m_shLne ) 266 if( show == m_shLne )
266 return; 267 return;
267 268
268 m_shLne = show; 269 m_shLne = show;
269 if( !show ){ 270 if( !show ){
270 delete m_edit; 271 delete m_edit;
271 delete m_fnLabel; 272 delete m_fnLabel;
272 m_edit = 0; 273 m_edit = 0;
273 m_fnLabel = 0; 274 m_fnLabel = 0;
274 //delete m_boxName; will be deleted 275 //delete m_boxName; will be deleted
275 } 276 }
276 updateLay(); 277 updateLay();
277} 278}
278void OFileSelector::setChooserVisible( bool show ) 279void OFileSelector::setChooserVisible( bool show )
279{ 280{
280 if( show = m_shChooser ) 281 if( show = m_shChooser )
281 return; 282 return;
282 m_shChooser = show; 283 m_shChooser = show;
283 if( !show ){ 284 if( !show ){
284 delete m_mimeCheck; 285 delete m_mimeCheck;
285 delete m_viewCheck; 286 delete m_viewCheck;
286 m_mimeCheck = 0; 287 m_mimeCheck = 0;
287 m_viewCheck = 0; 288 m_viewCheck = 0;
288 } 289 }
289 updateLay(); 290 updateLay();
290} 291}
291QCheckBox* OFileSelector::permissionCheckbox( ) 292QCheckBox* OFileSelector::permissionCheckbox( )
292{ 293{
293 return m_checkPerm; 294 return m_checkPerm;
294} 295}
295void OFileSelector::setCaseSensetive( bool caSe ) 296void OFileSelector::setCaseSensetive( bool caSe )
296{ 297{
297 m_case = caSe; 298 m_case = caSe;
298 reparse(); 299 reparse();
299} 300}
300void OFileSelector::setShowFiles(bool files ){ 301void OFileSelector::setShowFiles(bool files ){
301 m_files = files; 302 m_files = files;
302 reparse(); 303 reparse();
303} 304}
304void OFileSelector::setPopupMenu(QPopupMenu *pop ) 305void OFileSelector::setPopupMenu(QPopupMenu *pop )
305{ 306{
306 //delete oldpopup; 307 //delete oldpopup;
307 m_custom = pop; 308 m_custom = pop;
308} 309}
309bool OFileSelector::setPermission( ) const 310bool OFileSelector::setPermission( ) const
310{ 311{
311 if( m_checkPerm == 0 ) 312 if( m_checkPerm == 0 )
312 return false; 313 return false;
313 else 314 else
314 return m_checkPerm->isChecked(); 315 return m_checkPerm->isChecked();
315} 316}
316void OFileSelector::setPermissionChecked( bool check ) 317void OFileSelector::setPermissionChecked( bool check )
317{ 318{
318 if( m_checkPerm == 0 ) 319 if( m_checkPerm == 0 )
319 return; 320 return;
320 m_checkPerm->setChecked( check ); 321 m_checkPerm->setChecked( check );
321} 322}
322QString OFileSelector::selectedName( )const 323QString OFileSelector::selectedName( )const
323{ 324{
324 QString string; 325 QString string;
325 if( m_selector == NORMAL ){ 326 if( m_selector == NORMAL ){
326 const DocLnk *lnk = m_select->selected(); 327 const DocLnk *lnk = m_select->selected();
327 string = lnk->file(); 328 string = lnk->file();
328 }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { 329 }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
329 QListViewItem *item = m_View->currentItem(); 330 QListViewItem *item = m_View->currentItem();
330 if(item != 0 ){ 331 if(item != 0 ){
331 string = item->text( 1 ); 332 string = item->text( 1 );
332 } 333 }
333 } 334 }
334 return string; 335 return string;
335} 336}
336QStringList OFileSelector::selectedNames()const 337QStringList OFileSelector::selectedNames()const
337{ 338{
338 QStringList list; 339 QStringList list;
339 return list; 340 return list;
340} 341}
341DocLnk OFileSelector::selectedDocument( )const 342DocLnk OFileSelector::selectedDocument( )const
342{ 343{
343 DocLnk lnk; 344 DocLnk lnk;
344 return lnk; 345 return lnk;
345} 346}
346void OFileSelector::updateLay() 347void OFileSelector::updateLay()
347{ 348{
348 /* if( m_shTool ) 349 /* if( m_shTool )
349 // 350 //
350 else 351 else
351 // hide 352 // hide
352 */ 353 */
353 // save the state 354 // save the state
354 bool check = false; 355 bool check = false;
355 if( m_checkPerm != 0 ) 356 if( m_checkPerm != 0 )
356 check = m_checkPerm->isChecked(); 357 check = m_checkPerm->isChecked();
357 QString text; 358 QString text;
358 359
359 if( m_edit != 0 ) 360 if( m_edit != 0 )
360 text = m_edit->text(); 361 text = m_edit->text();
361 // save current mimetype 362 // save current mimetype
362 363
363 delItems(); 364 delItems();
364 delete m_checkPerm; 365 delete m_checkPerm;
365 m_checkPerm = 0; 366 m_checkPerm = 0;
366 delete m_edit; 367 delete m_edit;
367 m_edit = 0; 368 m_edit = 0;
368 delete m_fnLabel; 369 delete m_fnLabel;
369 m_fnLabel = 0; 370 m_fnLabel = 0;
370 delete m_ok; 371 delete m_ok;
371 m_ok = 0; 372 m_ok = 0;
372 delete m_cancel; 373 delete m_cancel;
373 m_cancel = 0; 374 m_cancel = 0;
374 delete m_mimeCheck; 375 delete m_mimeCheck;
375 m_mimeCheck = 0; 376 m_mimeCheck = 0;
376 delete m_viewCheck; 377 delete m_viewCheck;
377 m_viewCheck = 0; 378 m_viewCheck = 0;
378 delete m_select; // test 379 delete m_select; // test
379 delete m_stack; 380 delete m_stack;
380 //delete m_list; 381 //delete m_list;
381 init(); 382 init();
382 if( m_shLne ) 383 if( m_shLne )
383 m_edit->setText(text ); 384 m_edit->setText(text );
384 if( m_shPerm ) 385 if( m_shPerm )
385 m_checkPerm->setChecked(check ); 386 m_checkPerm->setChecked(check );
386} 387}
387// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve 388// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve
388// insert QListViewItems with the right options 389// insert QListViewItems with the right options
389bool OFileSelector::compliesMime(const QString &path, const QString &mime ) 390bool OFileSelector::compliesMime(const QString &path, const QString &mime )
390{ 391{
391 if( mime == "All" ) 392 if( mime == "All" )
392 return true; 393 return true;
393 MimeType type( path ); 394 MimeType type( path );
394 if( type.id() == mime ) 395 if( type.id() == mime )
395 return true; 396 return true;
396 return false; 397 return false;
397} 398}
398 399
399void OFileSelector::reparse() 400void OFileSelector::reparse()
400{ 401{
401 if(m_View== 0 || m_selector == NORMAL) 402 if(m_View== 0 || m_selector == NORMAL)
402 return; 403 return;
403 404
404 m_View->clear(); 405 m_View->clear();
405 406
406 407
407 QString currMime =m_mimeCheck->currentText(); 408 QString currMime =m_mimeCheck->currentText();
408 // update the mimetype now 409 // update the mimetype now
409 if( m_autoMime ) { 410 if( m_autoMime ) {
410 QDir dir( m_currentDir ); 411 QDir dir( m_currentDir );
411 m_mimetypes.clear(); 412 m_mimetypes.clear();
412 m_mimeCheck->clear(); 413 m_mimeCheck->clear();
413 dir.setFilter( QDir::Files | QDir::Readable ); 414 dir.setFilter( QDir::Files | QDir::Readable );
414 dir.setSorting(QDir::Size ); 415 dir.setSorting(QDir::Size );
415 const QFileInfoList *list = dir.entryInfoList(); 416 const QFileInfoList *list = dir.entryInfoList();
416 QFileInfoListIterator it( *list ); 417 QFileInfoListIterator it( *list );
417 QFileInfo *fi; 418 QFileInfo *fi;
418 while( (fi=it.current()) ){ 419 while( (fi=it.current()) ){
419 if(fi->extension() == QString::fromLatin1("desktop") ){ 420 if(fi->extension() == QString::fromLatin1("desktop") ){
420 ++it; 421 ++it;
421 continue; 422 continue;
422 } 423 }
423 MimeType type(fi->filePath() ); 424 MimeType type(fi->filePath() );
424 if( !m_mimetypes.contains( type.id() ) ) 425 if( !m_mimetypes.contains( type.id() ) )
425 m_mimetypes.append( type.id() ); 426 m_mimetypes.append( type.id() );
426 427
427 ++it; 428 ++it;
428 } 429 }
429 m_mimetypes.prepend("All" ); 430 m_mimetypes.prepend("All" );
430 m_mimeCheck->insertStringList(m_mimetypes ); 431 m_mimeCheck->insertStringList(m_mimetypes );
431 // set it to the current mimetype 432 // set it to the current mimetype
432 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); 433 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) );
433 }; 434 };
434 QDir dir( m_currentDir ); 435 QDir dir( m_currentDir );
435 //dir.setFilter(-1 ); 436 //dir.setFilter(-1 );
436 int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; 437 int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed;
437 if( m_case ) 438 if( m_case )
438 sort = QDir::IgnoreCase; 439 sort = QDir::IgnoreCase;
439 dir.setSorting( sort ); 440 dir.setSorting( sort );
440 441
441 int filter; 442 int filter;
442 /* if( m_dir && !m_files) 443 /* if( m_dir && !m_files)
443 filter |= QDir::Dirs; 444 filter |= QDir::Dirs;
444 else if( !m_dir && m_files ) 445 else if( !m_dir && m_files )
445 filter |= QDir::Files; 446 filter |= QDir::Files;
446 else 447 else
447 filter |= QDir::All; 448 filter |= QDir::All;
448 */ 449 */
449 if( m_selector == EXTENDED_ALL ) 450 if( m_selector == EXTENDED_ALL )
450 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 451 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
451 else 452 else
452 filter = QDir::Files | QDir::Dirs | QDir::All; 453 filter = QDir::Files | QDir::Dirs | QDir::All;
453 dir.setFilter( filter ); 454 dir.setFilter( filter );
454 455
455 const QFileInfoList *list = dir.entryInfoList(); 456 const QFileInfoList *list = dir.entryInfoList();
456 QFileInfoListIterator it( *list ); 457 QFileInfoListIterator it( *list );
457 QFileInfo *fi; 458 QFileInfo *fi;
458 while( (fi=it.current()) ){ 459 while( (fi=it.current()) ){
459 if(fi->fileName() == ".." || fi->fileName() == "." ){ 460 if(fi->fileName() == ".." || fi->fileName() == "." ){
460 ++it; 461 ++it;
461 continue; 462 continue;
462 } 463 }
463 qWarning("Test: %s", fi->fileName().latin1() ); 464 qWarning("Test: %s", fi->fileName().latin1() );
464 if(fi->isSymLink() ){ 465 if(fi->isSymLink() ){
465 qWarning("Symlink %s", fi->fileName().latin1() ); 466 qWarning("Symlink %s", fi->fileName().latin1() );
466 QString file = fi->dirPath(true)+"/"+ fi->readLink(); 467 QString file = fi->dirPath(true)+"/"+ fi->readLink();
467 qWarning("File ->%s", file.latin1() ); 468 qWarning("File ->%s", file.latin1() );
468 for(int i=0; i<=4; i++ ){ // prepend from dos 469 for(int i=0; i<=4; i++ ){ // prepend from dos
469 QFileInfo info( file ); 470 QFileInfo info( file );
470 if( !info.exists() ){ 471 if( !info.exists() ){
471 qWarning("does not exist" ); 472 qWarning("does not exist" );
472 addSymlink(currMime, fi, TRUE ); 473 addSymlink(currMime, fi, TRUE );
473 break; 474 break;
474 }else if( info.isDir() ){ 475 }else if( info.isDir() ){
475 qWarning("isDir" ); 476 qWarning("isDir" );
476 addDir(currMime, fi, TRUE ); 477 addDir(currMime, fi, TRUE );
477 break; 478 break;
478 }else if( info.isFile() ){ 479 }else if( info.isFile() ){
479 qWarning("isFile" ); 480 qWarning("isFile" );
480 addFile(currMime, fi, TRUE ); 481 addFile(currMime, fi, TRUE );
481 break; 482 break;
482 }else if( info.isSymLink() ){ 483 }else if( info.isSymLink() ){
483 file = info.dirPath(true)+ "/"+ info.readLink(); 484 file = info.dirPath(true)+ "/"+ info.readLink();
484 qWarning("isSymlink again %s", file.latin1() ); 485 qWarning("isSymlink again %s", file.latin1() );
485 }else if( i == 4 ){ // just insert it and have the symlink symbol 486 }else if( i == 4 ){ // just insert it and have the symlink symbol
486 addSymlink(currMime, fi ); 487 addSymlink(currMime, fi );
487 qWarning("level too deep" ); 488 qWarning("level too deep" );
488 } 489 }
489 } 490 }
490 }else if( fi->isDir() ){ 491 }else if( fi->isDir() ){
491 addDir(currMime, fi ); 492 addDir(currMime, fi );
492 }else if( fi->isFile() ) { // file ? 493 }else if( fi->isFile() ) { // file ?
493 addFile(currMime, fi ); 494 addFile(currMime, fi );
494 } 495 }
495 ++it; 496 ++it;
496 } 497 }
497 m_View->sort(); 498 m_View->sort();
498} 499}
499QString OFileSelector::directory()const 500QString OFileSelector::directory()const
500{ 501{
501 return m_currentDir; 502 return m_currentDir;
502} 503}
503int OFileSelector::fileCount() 504int OFileSelector::fileCount()
504{ 505{
505 return 0; 506 return 0;
506} 507}
507void OFileSelector::slotOk( ) 508void OFileSelector::slotOk( )
508{ 509{
509 emit ok(); 510 emit ok();
510} 511}
511void OFileSelector::slotCancel( ) 512void OFileSelector::slotCancel( )
512{ 513{
513 emit cancel(); 514 emit cancel();
514} 515}
515 516
516void OFileSelector::initializeName() 517void OFileSelector::initializeName()
517{ 518{
518 m_boxName = new QHBoxLayout(this ); 519 m_boxName = new QHBoxLayout(this );
519 m_edit = new QLineEdit(this ); 520 m_edit = new QLineEdit(this );
520 m_fnLabel = new QLabel(this ); 521 m_fnLabel = new QLabel(this );
521 m_fnLabel->setText(tr("Name:") ); 522 m_fnLabel->setText(tr("Name:") );
522 m_boxName->addWidget(m_fnLabel ); 523 m_boxName->addWidget(m_fnLabel );
523 m_boxName->insertSpacing(1, 8 ); 524 m_boxName->insertSpacing(1, 8 );
524 m_boxName->addWidget(m_edit, 100 ); 525 m_boxName->addWidget(m_edit, 100 );
525 526
526 m_lay->addLayout(m_boxName); 527 m_lay->addLayout(m_boxName);
527} 528}
528void OFileSelector::initializeYes() 529void OFileSelector::initializeYes()
529{ 530{
530 m_ok = new QPushButton("&Save", this, "save" ); 531 m_ok = new QPushButton("&Save", this, "save" );
531 m_cancel = new QPushButton("C&ancel", this, "cancel" ); 532 m_cancel = new QPushButton("C&ancel", this, "cancel" );
532 m_boxOk = new QHBoxLayout(this ); 533 m_boxOk = new QHBoxLayout(this );
533 m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); 534 m_boxOk->addWidget( m_ok, Qt::AlignHCenter );
534 m_boxOk->insertSpacing(1, 8 ); 535 m_boxOk->insertSpacing(1, 8 );
535 m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); 536 m_boxOk->addWidget( m_cancel, Qt::AlignHCenter);
536 m_lay->addLayout(m_boxOk ); 537 m_lay->addLayout(m_boxOk );
537 connect(m_ok, SIGNAL(clicked() ), 538 connect(m_ok, SIGNAL(clicked() ),
538 this, SLOT(slotOk() ) ); 539 this, SLOT(slotOk() ) );
539 connect(m_cancel, SIGNAL(clicked() ), 540 connect(m_cancel, SIGNAL(clicked() ),
540 this, SLOT(slotCancel() ) ); 541 this, SLOT(slotCancel() ) );
541 542
542} 543}
543void OFileSelector::initializeChooser() 544void OFileSelector::initializeChooser()
544{ 545{
545 m_boxView = new QHBoxLayout(this ); 546 m_boxView = new QHBoxLayout(this );
546 547
547 m_mimeCheck = new QComboBox(this, "mime check"); 548 m_mimeCheck = new QComboBox(this, "mime check");
548 m_viewCheck = new QComboBox(this, "view check"); 549 m_viewCheck = new QComboBox(this, "view check");
549 m_boxView->addWidget(m_viewCheck, 0 ); 550 m_boxView->addWidget(m_viewCheck, 0 );
550 m_boxView->insertSpacing(1, 8 ); 551 m_boxView->insertSpacing(1, 8 );
551 m_boxView->addWidget(m_mimeCheck, 0 ); 552 m_boxView->addWidget(m_mimeCheck, 0 );
552 m_lay->addLayout(m_boxView ); 553 m_lay->addLayout(m_boxView );
553 554
554 m_viewCheck->insertItem(tr("Documents") ); 555 m_viewCheck->insertItem(tr("Documents") );
555 m_viewCheck->insertItem(tr("Files") ); 556 m_viewCheck->insertItem(tr("Files") );
556 m_viewCheck->insertItem(tr("All Files") ); 557 m_viewCheck->insertItem(tr("All Files") );
557 558
558 if(!m_autoMime ) 559 if(!m_autoMime )
559 m_mimeCheck->insertItem(m_mimetypes.join("," ) ); 560 m_mimeCheck->insertItem(m_mimetypes.join("," ) );
560 else{ // check 561 else{ // check
561 updateMimes(); 562 updateMimes();
562 m_mimeCheck->insertStringList( m_mimetypes ); 563 m_mimeCheck->insertStringList( m_mimetypes );
563 } 564 }
564 565
565 connect( m_viewCheck, SIGNAL(activated(const QString &) ), 566 connect( m_viewCheck, SIGNAL(activated(const QString &) ),
566 this, SLOT(slotViewCheck(const QString & ) ) ); 567 this, SLOT(slotViewCheck(const QString & ) ) );
567 568
568 connect( m_mimeCheck, SIGNAL(activated(const QString &) ), 569 connect( m_mimeCheck, SIGNAL(activated(const QString &) ),
569 this, SLOT(slotMimeCheck(const QString & ) ) ); 570 this, SLOT(slotMimeCheck(const QString & ) ) );
570} 571}
571void OFileSelector::slotMimeCheck(const QString &view ){ 572void OFileSelector::slotMimeCheck(const QString &view ){
572 if(m_selector == NORMAL ){ 573 if(m_selector == NORMAL ){
573 delete m_select; 574 delete m_select;
574 m_select = new FileSelector(view == "All" ? QString::null : view 575 m_select = new FileSelector(view == "All" ? QString::null : view
575 , m_stack, "fileselector", FALSE, FALSE ); 576 , m_stack, "fileselector", FALSE, FALSE );
576 m_stack->addWidget( m_select, NORMAL ); 577 m_stack->addWidget( m_select, NORMAL );
577 m_stack->raiseWidget( NORMAL ); 578 m_stack->raiseWidget( NORMAL );
578 }else{ 579 }else{
579 reparse(); 580 reparse();
580 } 581 }
581} 582}
582 583
583void OFileSelector::slotViewCheck(const QString &view ){ 584void OFileSelector::slotViewCheck(const QString &view ){
584 qWarning("changed: show %s", view.latin1() ); 585 qWarning("changed: show %s", view.latin1() );
585 // if the current view is the one 586 // if the current view is the one
586 QString currMime = m_mimeCheck->currentText(); 587 QString currMime = m_mimeCheck->currentText();
587 if( view == QString::fromLatin1("Documents") ){ 588 if( view == QString::fromLatin1("Documents") ){
588 // get the mimetype now 589 // get the mimetype now
589 // check if we're the current widget and return 590 // check if we're the current widget and return
590 if( m_View != 0) { // delete 0 shouldn't crash but it did :( 591 if( m_View != 0) { // delete 0 shouldn't crash but it did :(
591 delete m_View; 592 delete m_View;
592 delete m_boxToolbar; 593 delete m_boxToolbar;
593 delete m_homeButton; 594 delete m_homeButton;
594 delete m_docButton; 595 delete m_docButton;
595 delete m_location; 596 delete m_location;
596 delete m_up; 597 delete m_up;
597 delete m_pseudo; 598 delete m_pseudo;
598 delete m_pseudoLayout; 599 if(m_pseudoLayout!=0 )
600 delete m_pseudoLayout;
599 } 601 }
600 m_View = 0; 602 m_View = 0;
601 m_boxToolbar = 0; 603 m_boxToolbar = 0;
602 m_homeButton = 0; 604 m_homeButton = 0;
603 m_docButton = 0; 605 m_docButton = 0;
604 m_location = 0; 606 m_location = 0;
605 m_up = 0; 607 m_up = 0;
606 m_pseudo = 0; 608 m_pseudo = 0;
607 m_pseudoLayout = 0; 609 m_pseudoLayout = 0;
608 610
609 delete m_select; 611 delete m_select;
610 m_select = new FileSelector( currMime == "All" ? QString::null : currMime, 612 m_select = new FileSelector( currMime == "All" ? QString::null : currMime,
611 m_stack,"fileselector", FALSE, FALSE ); 613 m_stack,"fileselector", FALSE, FALSE );
612 m_stack->addWidget( m_select, NORMAL ); 614 m_stack->addWidget( m_select, NORMAL );
613 m_mimeCheck->clear(); 615 m_mimeCheck->clear();
614 m_selector = NORMAL; 616 m_selector = NORMAL;
615 updateMimes(); 617 updateMimes();
616 m_mimeCheck->insertStringList( m_mimetypes ); 618 m_mimeCheck->insertStringList( m_mimetypes );
617 m_stack->raiseWidget( NORMAL ); 619 m_stack->raiseWidget( NORMAL );
618 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); 620 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
619 621
620 }else if(view == QString::fromLatin1("Files") ){ 622 }else if(view == QString::fromLatin1("Files") ){
621 // remove from the stack 623 // remove from the stack
622 delete m_select; 624 delete m_select;
623 m_select = 0; 625 m_select = 0;
624 delete m_View; 626 delete m_View;
625 m_View = 0; 627 m_View = 0;
626 628
627 delete m_boxToolbar; 629
628 delete m_homeButton;
629 delete m_docButton;
630 delete m_location;
631 delete m_up;
632 delete m_pseudo;
633 delete m_pseudoLayout;
634 m_boxToolbar = 0;
635 m_homeButton = 0;
636 m_docButton = 0;
637 m_location = 0;
638 m_up = 0;
639 m_pseudo = 0;
640 m_pseudoLayout = 0;
641 630
642 m_selector = EXTENDED; 631 m_selector = EXTENDED;
643 // create the ListView or IconView 632 // create the ListView or IconView
644 initializeListView(); 633 initializeListView();
645 634
646 reparse(); 635 reparse();
647 }else if(view == QString::fromLatin1("All Files") ) { 636 }else if(view == QString::fromLatin1("All Files") ) {
648 // remove from the stack 637 // remove from the stack
649 delete m_select; 638 delete m_select;
650 m_select = 0; 639 m_select = 0;
651 delete m_View; 640 delete m_View;
652 m_View = 0; 641 m_View = 0;
653 delete m_boxToolbar;
654 delete m_homeButton;
655 delete m_docButton;
656 delete m_location;
657 delete m_up;
658 delete m_pseudo;
659 delete m_pseudoLayout;
660 m_boxToolbar = 0;
661 m_homeButton = 0;
662 m_docButton = 0;
663 m_location = 0;
664 m_up = 0;
665 m_pseudo = 0;
666 m_pseudoLayout = 0;
667 642
668 m_selector = EXTENDED_ALL; 643 m_selector = EXTENDED_ALL;
669 initializeListView(); 644 initializeListView();
670 reparse(); 645 reparse();
671 }; 646 };
672}; 647};
673 648
674 649
675void OFileSelector::updateMimes() // lets check which mode is active 650void OFileSelector::updateMimes() // lets check which mode is active
676 // check the current dir for items then 651 // check the current dir for items then
677{ 652{
678 m_mimetypes.clear(); 653 m_mimetypes.clear();
679 m_mimetypes.append("All" ); 654 m_mimetypes.append("All" );
680 if( m_selector == NORMAL ){ 655 if( m_selector == NORMAL ){
681 DocLnkSet set; 656 DocLnkSet set;
682 Global::findDocuments(&set, QString::null ); 657 Global::findDocuments(&set, QString::null );
683 QListIterator<DocLnk> dit( set.children() ); 658 QListIterator<DocLnk> dit( set.children() );
684 for ( ; dit.current(); ++dit ) { 659 for ( ; dit.current(); ++dit ) {
685 if( !m_mimetypes.contains((*dit)->type() ) ) 660 if( !m_mimetypes.contains((*dit)->type() ) )
686 m_mimetypes.append( (*dit)->type() ); 661 m_mimetypes.append( (*dit)->type() );
687 } 662 }
688 }else{ 663 }else{
689 // should be allreday updatet 664 // should be allreday updatet
690 ; 665 ;
691 } 666 }
692}; 667};
693void OFileSelector::initializeListView() 668void OFileSelector::initializeListView()
694{ 669{
695 // just to make sure but clean it up better FIXME 670 // just to make sure but clean it up better FIXME
696 delete m_View; 671 delete m_View;
697 m_View = 0; 672 m_View = 0;
698 delete m_boxToolbar; 673 delete m_boxToolbar;
699 delete m_homeButton; 674 delete m_homeButton;
700 delete m_docButton; 675 delete m_docButton;
701 delete m_location; 676 delete m_location;
702 delete m_up; 677 delete m_up;
703 delete m_pseudo; 678 delete m_pseudo;
704 delete m_pseudoLayout; 679 if(m_pseudoLayout!=0 ) // why did you overload malloc
680 delete m_pseudoLayout;
705 m_boxToolbar = 0; 681 m_boxToolbar = 0;
706 m_homeButton = 0; 682 m_homeButton = 0;
707 m_docButton = 0; 683 m_docButton = 0;
708 m_location = 0; 684 m_location = 0;
709 m_up = 0; 685 m_up = 0;
710 m_pseudo = 0; 686 m_pseudo = 0;
711 m_pseudoLayout = 0; 687 m_pseudoLayout = 0;
712 // time for the toolbar 688 // time for the toolbar
713 m_pseudo = new QWidget(m_stack, "Pseudo Widget"); 689 m_pseudo = new QWidget(m_stack, "Pseudo Widget");
714 m_pseudoLayout = new QVBoxLayout(m_pseudo ); 690 m_pseudoLayout = new QVBoxLayout(m_pseudo );
715 if(m_shTool ){ 691 if(m_shTool ){
716 m_boxToolbar = new QHBoxLayout( ); 692 m_boxToolbar = new QHBoxLayout( );
717 m_boxToolbar->setAutoAdd( true ); 693 m_boxToolbar->setAutoAdd( true );
718 m_location = new QComboBox(m_pseudo ); 694 m_location = new QComboBox(m_pseudo );
719 695
720 m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); 696 m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton");
721 m_up->setMinimumSize( QSize( 20, 20 ) ); 697 m_up->setMinimumSize( QSize( 20, 20 ) );
722 m_up->setMaximumSize( QSize( 20, 20 ) ); 698 m_up->setMaximumSize( QSize( 20, 20 ) );
723 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); 699 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) );
724 m_up->setFlat(TRUE); 700 m_up->setFlat(TRUE);
725 701
726 m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo); 702 m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo);
727 m_homeButton->setMinimumSize( QSize( 20, 20 ) ); 703 m_homeButton->setMinimumSize( QSize( 20, 20 ) );
728 m_homeButton->setMaximumSize( QSize( 20, 20 ) ); 704 m_homeButton->setMaximumSize( QSize( 20, 20 ) );
729 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); 705 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) );
730 m_homeButton->setFlat(TRUE); 706 m_homeButton->setFlat(TRUE);
731 707
732 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton"); 708 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton");
733 m_docButton->setMinimumSize( QSize( 20, 20 ) ); 709 m_docButton->setMinimumSize( QSize( 20, 20 ) );
734 m_docButton->setMaximumSize( QSize( 20, 20 ) ); 710 m_docButton->setMaximumSize( QSize( 20, 20 ) );
735 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); 711 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) );
736 m_docButton->setFlat(TRUE); 712 m_docButton->setFlat(TRUE);
737 713
738 m_boxToolbar->addWidget(m_location ); 714 m_boxToolbar->addWidget(m_location );
739 m_boxToolbar->addWidget(m_up ); 715 m_boxToolbar->addWidget(m_up );
740 m_boxToolbar->addWidget(m_homeButton ); 716 m_boxToolbar->addWidget(m_homeButton );
741 m_boxToolbar->addWidget(m_docButton ); 717 m_boxToolbar->addWidget(m_docButton );
742 m_pseudoLayout->addLayout(m_boxToolbar ); 718 m_pseudoLayout->addLayout(m_boxToolbar );
743 // lets fill the combobox 719 // lets fill the combobox
744 StorageInfo storage; 720 StorageInfo storage;
745 const QList<FileSystem> &fs = storage.fileSystems(); 721 const QList<FileSystem> &fs = storage.fileSystems();
746 QListIterator<FileSystem> it ( fs ); 722 QListIterator<FileSystem> it ( fs );
747 for( ; it.current(); ++it ){ 723 for( ; it.current(); ++it ){
748 const QString disk = (*it)->name(); 724 const QString disk = (*it)->name();
749 const QString path = (*it)->path(); 725 const QString path = (*it)->path();
750 m_location->insertItem(path+ "<-"+disk ); 726 m_location->insertItem(path+ "<-"+disk );
751 } 727 }
752 int count = m_location->count(); 728 int count = m_location->count();
753 m_location->insertItem(m_currentDir ); 729 m_location->insertItem(m_currentDir );
754 m_location->setCurrentItem( count ); 730 m_location->setCurrentItem( count );
755 }; 731 };
756 m_View = new QListView(m_pseudo, "Extended view" ); 732 m_View = new QListView(m_pseudo, "Extended view" );
757 m_stack->addWidget( m_pseudo, EXTENDED ); 733 m_stack->addWidget( m_pseudo, EXTENDED );
758 m_stack->raiseWidget( EXTENDED ); 734 m_stack->raiseWidget( EXTENDED );
759 m_pseudoLayout->addWidget(m_View ); 735 m_pseudoLayout->addWidget(m_View );
760 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold); 736 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold);
761 // set up the stuff 737 // set up the stuff
762 // Pixmap Name Date Size mime 738 // Pixmap Name Date Size mime
763 //(m_View->header() )->hide(); 739 //(m_View->header() )->hide();
764 //m_View->setRootIsDecorated(false); 740 //m_View->setRootIsDecorated(false);
765 m_View->addColumn(" "); 741 m_View->addColumn(" ");
766 m_View->addColumn(tr("Name") ); 742 m_View->addColumn(tr("Name") );
767 m_View->addColumn(tr("Size") ); 743 m_View->addColumn(tr("Size") );
768 m_View->addColumn(tr("Date"), 60 ); 744 m_View->addColumn(tr("Date"), 60 );
769 m_View->addColumn(tr("Mime Type") ); 745 m_View->addColumn(tr("Mime Type") );
770 QHeader *header = m_View->header(); 746 QHeader *header = m_View->header();
771 header->hide(); 747 header->hide();
772 m_View->setSorting(1 ); 748 m_View->setSorting(1 );
773 // connect now 749 // connect now
774 connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) ); 750 connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) );
775 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); 751 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
776 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), 752 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
777 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); 753 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
778 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), 754 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
779 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); 755 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
780 756
781 757
782}; 758};
783/* If a item is locked depends on the mode 759/* If a item is locked depends on the mode
784 if we're in OPEN !isReadable is locked 760 if we're in OPEN !isReadable is locked
785 if we're in SAVE !isWriteable is locked 761 if we're in SAVE !isWriteable is locked
786 762
787 763
788 */ 764 */
789 765
790 766
791void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ 767void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){
792 qWarning("Add Files" ); 768 qWarning("Add Files" );
793 if( !m_files ){ 769 if( !m_files ){
794 qWarning("not mfiles" ); 770 qWarning("not mfiles" );
795 return; 771 return;
796 } 772 }
797 773
798 MimeType type( info->filePath() ); 774 MimeType type( info->filePath() );
799 QString name; 775 QString name;
800 QString dir; 776 QString dir;
801 bool locked= false; 777 bool locked= false;
802 if(mime == "All" ){ 778 if(mime == "All" ){
803 ; 779 ;
804 }else if( type.id() != mime ) { 780 }else if( type.id() != mime ) {
805 return; 781 return;
806 } 782 }
807 QPixmap pix = type.pixmap(); 783 QPixmap pix = type.pixmap();
808 if(pix.isNull() ) 784 if(pix.isNull() )
809 pix = Resource::loadPixmap( "UnknownDocument-14" ); 785 pix = Resource::loadPixmap( "UnknownDocument-14" );
810 dir = info->dirPath( true ); 786 dir = info->dirPath( true );
811 if( symlink ) { // check if the readLink is readable 787 if( symlink ) { // check if the readLink is readable
812 // do it right later 788 // do it right later
813 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 789 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
814 }else{ // keep track of the icons 790 }else{ // keep track of the icons
815 name = info->fileName(); 791 name = info->fileName();
816 if( m_mode == OPEN ){ 792 if( m_mode == OPEN ){
817 if( !info->isReadable() ){ 793 if( !info->isReadable() ){
818 locked = true; 794 locked = true;
819 pix = Resource::loadPixmap("locked" ); 795 pix = Resource::loadPixmap("locked" );
820 } 796 }
821 }else if( m_mode == SAVE ){ 797 }else if( m_mode == SAVE ){
822 if( !info->isWritable() ){ 798 if( !info->isWritable() ){
823 locked = true; 799 locked = true;
824 pix = Resource::loadPixmap("locked" ); 800 pix = Resource::loadPixmap("locked" );
825 } 801 }
826 } 802 }
827 } 803 }
828 new OFileSelectorItem( m_View, pix, name, 804 new OFileSelectorItem( m_View, pix, name,
829 info->lastModified().toString(), 805 info->lastModified().toString(),
830 QString::number( info->size() ), 806 QString::number( info->size() ),
831 dir, locked ); 807 dir, locked );
832} 808}
833void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) 809void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
834{ 810{
835 if(!m_dir ) 811 if(!m_dir )
836 return; 812 return;
837 //if( showDirs ) 813 //if( showDirs )
838 { 814 {
839 bool locked=false; 815 bool locked=false;
840 QString name; 816 QString name;
841 QPixmap pix; 817 QPixmap pix;
842 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ 818 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){
843 locked = true; 819 locked = true;
844 if( symlink ){ 820 if( symlink ){
845 pix = (*m_pixmaps)["symlinkedlocked"]; 821 pix = (*m_pixmaps)["symlinkedlocked"];
846 }else{ 822 }else{
847 pix = Resource::loadPixmap("lockedfolder" ); 823 pix = Resource::loadPixmap("lockedfolder" );
848 } 824 }
849 }else{ 825 }else{
850 if( symlink ){ 826 if( symlink ){
851 pix = (*m_pixmaps)["dirsymlink" ]; 827 pix = (*m_pixmaps)["dirsymlink" ];
852 }else{ 828 }else{
853 pix = Resource::loadPixmap("folder" ); 829 pix = Resource::loadPixmap("folder" );
854 } 830 }
855 } 831 }
856 if( symlink){ 832 if( symlink){
857 name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); 833 name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink();
858 834
859 }else{ 835 }else{
860 //if(info->isReadable() ) 836 //if(info->isReadable() )
861 name = info->fileName(); 837 name = info->fileName();
862 } 838 }
863 839
864 new OFileSelectorItem(m_View, pix, 840 new OFileSelectorItem(m_View, pix,
865 name, info->lastModified().toString(), 841 name, info->lastModified().toString(),
866 QString::number(info->size() ),info->dirPath(true), locked, true ); 842 QString::number(info->size() ),info->dirPath(true), locked, true );
867 843
868 } 844 }
869} 845}
870void OFileSelector::setShowDirs(bool dir ) 846void OFileSelector::setShowDirs(bool dir )
871{ 847{
872 m_dir = dir; 848 m_dir = dir;
873 reparse(); 849 reparse();
874} 850}
875 851
876void OFileSelector::slotFileSelected(const QString &string ) 852void OFileSelector::slotFileSelected(const QString &string )
877{ 853{
878 if(m_shLne ) 854 if(m_shLne )
879 m_edit->setText( string ); 855 m_edit->setText( string );
880 856
881 emit fileSelected( string ); 857 emit fileSelected( string );
882 // do AppLnk stuff 858 // do AppLnk stuff
883} 859}
884void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 860void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
885{ 861{
886 slotFileSelected(lnk.name() ); 862 slotFileSelected(lnk.name() );
887 emit fileSelected( lnk ); 863 emit fileSelected( lnk );
888} 864}
889void OFileSelector::slotSelectionChanged() // get the current items 865void OFileSelector::slotSelectionChanged() // get the current items
890 // fixme 866 // fixme
891{ 867{
892 qWarning("selection changed" ); 868 qWarning("selection changed" );
893} 869}
894void OFileSelector::slotCurrentChanged(QListViewItem *item ) 870void OFileSelector::slotCurrentChanged(QListViewItem *item )
895{ 871{
896 qWarning("current changed" ); 872 qWarning("current changed" );
897 if( item == 0 ) 873 if( item == 0 )
898 return; 874 return;
899 875
900 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 876 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
901 OFileSelectorItem *sel = (OFileSelectorItem*)item; 877 OFileSelectorItem *sel = (OFileSelectorItem*)item;
902 if(!sel->isDir() ){ 878 if(!sel->isDir() ){
903 qWarning("is not dir" ); 879 qWarning("is not dir" );
904 if(m_shLne ){ 880 if(m_shLne ){
905 m_edit->setText(sel->text(1) ); 881 m_edit->setText(sel->text(1) );
906 qWarning("setTexy" ); 882 qWarning("setTexy" );
907 } 883 }
908 } 884 }
909 }else { 885 }else {
910 qWarning("mode not extended" ); 886 qWarning("mode not extended" );
911 } 887 }
912} 888}
913// either select or change dir 889// either select or change dir
914void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) 890void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int )
915{ 891{
916 if( item == 0 ) 892 if( item == 0 )
917 return; 893 return;
918 894
919 if( button != Qt::LeftButton ) 895 if( button != Qt::LeftButton )
920 return; 896 return;
921 897
922 qWarning("clicked" ); 898 qWarning("clicked" );
923 if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 899 if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
924 qWarning("inside" ); 900 qWarning("inside" );
925 OFileSelectorItem *sel = (OFileSelectorItem*)item; 901 OFileSelectorItem *sel = (OFileSelectorItem*)item;
926 if(!sel->isLocked() ){ // not locked either changedir or open 902 if(!sel->isLocked() ){ // not locked either changedir or open
927 QStringList str = QStringList::split("->", sel->text(1) ); 903 QStringList str = QStringList::split("->", sel->text(1) );
928 if(sel->isDir() ){ 904 if(sel->isDir() ){
929 cd( sel->directory() + "/" + str[0] ); 905 cd( sel->directory() + "/" + str[0] );
930 }else{ 906 }else{
931 qWarning("file" ); 907 qWarning("file" );
932 if(m_shLne ) 908 if(m_shLne )
933 m_edit->setText(str[0] ); 909 m_edit->setText(str[0] );
934 emit fileSelected(str[0] ); 910 emit fileSelected(str[0] );
935 // emit DocLnk need to do it 911 // emit DocLnk need to do it
936 } 912 }
937 }else{ 913 }else{
938 qWarning( "locked" ); 914 qWarning( "locked" );
939 } 915 }
940 }; 916 };
941} 917}
942void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) 918void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
943{ 919{
944 if (item == 0 ) 920 if (item == 0 )
945 return; 921 return;
946 922
947 if( button != Qt::RightButton ) 923 if( button != Qt::RightButton )
948 return; 924 return;
949 qWarning("right button" ); 925 qWarning("right button" );
950 slotContextMenu(item); 926 slotContextMenu(item);
951} 927}
952void OFileSelector::slotContextMenu(QListViewItem *item) 928void OFileSelector::slotContextMenu(QListViewItem *item)
953{ 929{
954 qWarning("context menu" ); 930 qWarning("context menu" );
955 if( item ==0 || !m_showPopup ) 931 if( item ==0 || !m_showPopup )
956 return; 932 return;
957 933
958 if( m_custom !=0){ 934 if( m_custom !=0){
959 m_custom->exec(); 935 m_custom->exec();
960 }else{ 936 }else{
961 QPopupMenu menu; 937 QPopupMenu menu;
962 QAction up; 938 QAction up;
963 up.setText("cd up"); 939 up.setText("cd up");
964 up.addTo( &menu ); 940 up.addTo( &menu );
965 connect(&up, SIGNAL(activated() ), 941 connect(&up, SIGNAL(activated() ),
966 this, SLOT(cdUP() ) ); 942 this, SLOT(cdUP() ) );
967 943
968 QAction act; 944 QAction act;
969 OFileSelectorItem *sel = (OFileSelectorItem*)item; 945 OFileSelectorItem *sel = (OFileSelectorItem*)item;
970 if(sel->isDir() ){ 946 if(sel->isDir() ){
971 act.setText( tr("Change Directory") ); 947 act.setText( tr("Change Directory") );
972 act.addTo(&menu ); 948 act.addTo(&menu );
973 connect(&act, SIGNAL(activated() ), 949 connect(&act, SIGNAL(activated() ),
974 this, SLOT(slotChangedDir() ) ); 950 this, SLOT(slotChangedDir() ) );
975 }else{ 951 }else{
976 act.setText( tr("Open file" ) ); 952 act.setText( tr("Open file" ) );
977 act.addTo( &menu ); 953 act.addTo( &menu );
978 connect(&act, SIGNAL(activated() ), 954 connect(&act, SIGNAL(activated() ),
979 this, SLOT(slotOpen() ) ); 955 this, SLOT(slotOpen() ) );
980 } 956 }
981 QAction rescan; 957 QAction rescan;
982 rescan.setText( tr("Rescan") ); 958 rescan.setText( tr("Rescan") );
983 rescan.addTo( &menu ); 959 rescan.addTo( &menu );
984 connect(&rescan, SIGNAL(activated() ), 960 connect(&rescan, SIGNAL(activated() ),
985 this, SLOT(slotRescan() ) ); 961 this, SLOT(slotRescan() ) );
986 962
987 QAction rename; 963 QAction rename;
988 rename.setText( tr("Rename") ); 964 rename.setText( tr("Rename") );
989 rename.addTo( &menu ); 965 rename.addTo( &menu );
990 connect(&rename, SIGNAL(activated() ), 966 connect(&rename, SIGNAL(activated() ),
991 this, SLOT(slotRename() ) ); 967 this, SLOT(slotRename() ) );
992 968
993 menu.insertSeparator(); 969 menu.insertSeparator();
994 QAction delItem; 970 QAction delItem;
995 delItem.setText( tr("Delete") ); 971 delItem.setText( tr("Delete") );
996 delItem.addTo(&menu ); 972 delItem.addTo(&menu );
997 connect(&delItem, SIGNAL(activated() ), 973 connect(&delItem, SIGNAL(activated() ),
998 this, SLOT(slotDelete() ) ); 974 this, SLOT(slotDelete() ) );
999 975
1000 menu.exec(QCursor::pos() ); 976 menu.exec(QCursor::pos() );
1001 } 977 }
1002} 978}
1003bool OFileSelector::cd(const QString &str ) 979bool OFileSelector::cd(const QString &str )
1004{ 980{
1005 qWarning(" dir %s", str.latin1() ); 981 qWarning(" dir %s", str.latin1() );
1006 QDir dir( str); 982 QDir dir( str);
1007 if(dir.exists() ){ 983 if(dir.exists() ){
1008 m_currentDir = str; 984 m_currentDir = str;
1009 reparse(); 985 reparse();
1010 if(m_shTool ){ 986 if(m_shTool ){
1011 int count = m_location->count(); 987 int count = m_location->count();
1012 m_location->insertItem(str ); 988 m_location->insertItem(str );
1013 m_location->setCurrentItem( count ); 989 m_location->setCurrentItem( count );
1014 } 990 }
1015 return true; 991 return true;
1016 } 992 }
1017 return false; 993 return false;
1018} 994}
1019 995
1020void OFileSelector::slotChangedDir() 996void OFileSelector::slotChangedDir()
1021{ 997{
1022 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 998 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1023 if(sel->isDir() ){ 999 if(sel->isDir() ){
1024 QStringList str = QStringList::split("->", sel->text(1) ); 1000 QStringList str = QStringList::split("->", sel->text(1) );
1025 cd( sel->directory() + "/" + str[0] ); 1001 cd( sel->directory() + "/" + str[0] );
1026 } 1002 }
1027} 1003}
1028void OFileSelector::slotOpen() 1004void OFileSelector::slotOpen()
1029{ 1005{
1030 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1006 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1031 if(!sel->isDir() ){ 1007 if(!sel->isDir() ){
1032 QStringList str = QStringList::split("->", sel->text(1) ); 1008 QStringList str = QStringList::split("->", sel->text(1) );
1033 slotFileSelected( str[0] ); 1009 slotFileSelected( str[0] );
1034 } 1010 }
1035} 1011}
1036void OFileSelector::slotRescan() 1012void OFileSelector::slotRescan()
1037{ 1013{
1038 reparse(); 1014 reparse();
1039} 1015}
1040void OFileSelector::slotRename() 1016void OFileSelector::slotRename()
1041{ 1017{
1042 // rename inline 1018 // rename inline
1043} 1019}
1044void OFileSelector::slotDelete() 1020void OFileSelector::slotDelete()
1045{ 1021{
1046 qWarning("delete slot" ); 1022 qWarning("delete slot" );
1047 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1023 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1048 QStringList list = QStringList::split("->", sel->text(1) ); 1024 QStringList list = QStringList::split("->", sel->text(1) );
1049 if( sel->isDir() ){ 1025 if( sel->isDir() ){
1050 QString str = QString::fromLatin1("rm -rf ") + list[0]; 1026 QString str = QString::fromLatin1("rm -rf ") + list[0];
1051 ::system(str.utf8().data() ); 1027 ::system(str.utf8().data() );
1052 }else{ 1028 }else{
1053 QFile::remove( list[0] ); 1029 QFile::remove( list[0] );
1054 } 1030 }
1055 m_View->takeItem( sel ); 1031 m_View->takeItem( sel );
1056 delete sel; 1032 delete sel;
1057} 1033}
1058 1034
1059void OFileSelector::cdUP() 1035void OFileSelector::cdUP()
1060{ 1036{
1061 QDir dir( m_currentDir ); 1037 QDir dir( m_currentDir );
1062 dir.cdUp(); 1038 dir.cdUp();
1063 if(dir.exists() ){ 1039 if(dir.exists() ){
1064 m_currentDir = dir.absPath(); 1040 m_currentDir = dir.absPath();
1065 reparse(); 1041 reparse();
1066 int count = m_location->count(); 1042 int count = m_location->count();
1067 m_location->insertItem(m_currentDir ); 1043 m_location->insertItem(m_currentDir );
1068 m_location->setCurrentItem( count ); 1044 m_location->setCurrentItem( count );
1069 } 1045 }
1070} 1046}
1071void OFileSelector::slotHome() 1047void OFileSelector::slotHome()
1072{ 1048{
1073 cd(QDir::homeDirPath() ); 1049 cd(QDir::homeDirPath() );
1074} 1050}
1075void OFileSelector::slotDoc() 1051void OFileSelector::slotDoc()
1076{ 1052{
1077 cd(QDir::homeDirPath() + "/Documents" ); 1053 cd(QDir::homeDirPath() + "/Documents" );
1078} 1054}
1079void OFileSelector::slotNavigate() 1055void OFileSelector::slotNavigate()
1080{ 1056{
1081 1057
1082} 1058}