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