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