summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index 1807575..128292f 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -79,363 +79,371 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString
79 m_autoMime = true; 79 m_autoMime = true;
80 80
81 m_mode = mode; 81 m_mode = mode;
82 m_shTool = true; 82 m_shTool = true;
83 m_shPerm = true; 83 m_shPerm = true;
84 m_shLne = true; 84 m_shLne = true;
85 m_shChooser = true; 85 m_shChooser = true;
86 m_shYesNo = true; 86 m_shYesNo = true;
87 // for FILESELECTOR only view is interesting 87 // for FILESELECTOR only view is interesting
88 m_location = 0; 88 m_location = 0;
89 m_homeButton = 0; 89 m_homeButton = 0;
90 m_docButton = 0; 90 m_docButton = 0;
91 m_hideButton = 0; 91 m_hideButton = 0;
92 m_ok = 0; 92 m_ok = 0;
93 m_cancel = 0; 93 m_cancel = 0;
94 m_reread = 0; 94 m_reread = 0;
95 m_up = 0; 95 m_up = 0;
96 m_View = 0; 96 m_View = 0;
97 m_select = 0; 97 m_select = 0;
98 m_stack = 0; 98 m_stack = 0;
99 99
100 m_select = 0; 100 m_select = 0;
101 m_stack = 0; 101 m_stack = 0;
102 m_lay = 0; 102 m_lay = 0;
103 m_boxToolbar = 0; 103 m_boxToolbar = 0;
104 m_boxOk = 0; 104 m_boxOk = 0;
105 m_edit = 0; 105 m_edit = 0;
106 106
107 m_fnLabel = 0; 107 m_fnLabel = 0;
108 m_checkPerm = 0; 108 m_checkPerm = 0;
109 m_mimeCheck = 0; 109 m_mimeCheck = 0;
110 m_viewCheck = 0; 110 m_viewCheck = 0;
111 111
112 m_dir = true; 112 m_dir = true;
113 m_files = true; 113 m_files = true;
114 114
115 if(m_pixmaps == 0 ) // init the pixmaps 115 if(m_pixmaps == 0 ) // init the pixmaps
116 initPics(); 116 initPics();
117 117
118 m_lay = new QVBoxLayout(this); 118 m_lay = new QVBoxLayout(this);
119 init(); 119 init();
120 m_edit->setText( fileName ); 120 m_edit->setText( fileName );
121} 121}
122void OFileSelector::initPics() 122void OFileSelector::initPics()
123{ 123{
124 qWarning("init pics" ); 124 qWarning("init pics" );
125 m_pixmaps = new QMap<QString,QPixmap>; 125 m_pixmaps = new QMap<QString,QPixmap>;
126 QPixmap pm = Resource::loadPixmap( "folder" ); 126 QPixmap pm = Resource::loadPixmap( "folder" );
127 QPixmap lnk = Resource::loadPixmap( "symlink" ); 127 QPixmap lnk = Resource::loadPixmap( "symlink" );
128 QPainter painter( &pm ); 128 QPainter painter( &pm );
129 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 129 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
130 pm.setMask( pm.createHeuristicMask( FALSE ) ); 130 pm.setMask( pm.createHeuristicMask( FALSE ) );
131 m_pixmaps->insert("dirsymlink", pm ); 131 m_pixmaps->insert("dirsymlink", pm );
132 132
133 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); 133 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
134 QPainter pen(&pm2 ); 134 QPainter pen(&pm2 );
135 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); 135 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
136 pm2.setMask( pm2.createHeuristicMask( FALSE ) ); 136 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
137 m_pixmaps->insert("symlinkedlocked", pm2 ); 137 m_pixmaps->insert("symlinkedlocked", pm2 );
138 138
139}; 139};
140// let's initialize the gui 140// let's initialize the gui
141/** 141/**
142 -------------------- 142 --------------------
143 | cmbBox Button | 143 | cmbBox Button |
144 -------------------- 144 --------------------
145 | FileSlector | 145 | FileSlector |
146 | or | 146 | or |
147 | OSelector | 147 | OSelector |
148 | | 148 | |
149 | | 149 | |
150 ____________________ 150 ____________________
151 | LineEdit | 151 | LineEdit |
152 ____________________ 152 ____________________
153 | Permission Bar | 153 | Permission Bar |
154 ____________________ 154 ____________________
155 | ViewChoose | 155 | ViewChoose |
156 ____________________ 156 ____________________
157 | Save Cancel| 157 | Save Cancel|
158 ____________________ 158 ____________________
159 */ 159 */
160void OFileSelector::delItems() 160void OFileSelector::delItems()
161{ 161{
162 QLayoutIterator it = m_lay->iterator(); 162 QLayoutIterator it = m_lay->iterator();
163 while ( it.current() != 0 ){ 163 while ( it.current() != 0 ){
164 it.deleteCurrent(); 164 it.deleteCurrent();
165 } 165 }
166} 166}
167void OFileSelector::init() 167void OFileSelector::init()
168{ 168{
169 169
170 m_stack = new QWidgetStack(this, "wstack" ); 170 m_stack = new QWidgetStack(this, "wstack" );
171 if( m_selector == NORMAL ){ 171 if( m_selector == NORMAL ){
172 QString currMime; 172 QString currMime;
173 if( m_mimeCheck != 0 ) 173 if( m_mimeCheck != 0 )
174 currMime = m_mimeCheck->currentText(); 174 currMime = m_mimeCheck->currentText();
175
175 updateMimes(); 176 updateMimes();
176 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); 177 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE );
177 m_stack->addWidget(m_select, NORMAL ); 178 m_stack->addWidget(m_select, NORMAL );
178 m_lay->addWidget(m_stack ); 179 m_lay->addWidget(m_stack );
179 m_stack->raiseWidget(NORMAL ); 180 m_stack->raiseWidget(NORMAL );
180 }else { 181 }else {
181 initializeListView(); 182 initializeListView();
182 } 183 }
183 184
184 if(m_shLne ){ 185 if(m_shLne ){
185 initializeName(); 186 initializeName();
186 } 187 }
187 188
188 if(m_shPerm ){ 189 if(m_shPerm ){
189 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); 190 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" );
190 m_checkPerm->setChecked( false ); 191 m_checkPerm->setChecked( false );
191 m_lay->addWidget(m_checkPerm ); 192 m_lay->addWidget(m_checkPerm );
192 } 193 }
193 194
194 if( m_shChooser ) 195 if( m_shChooser )
195 initializeChooser(); 196 initializeChooser();
196 197
197 if(m_shYesNo ) 198 if(m_shYesNo )
198 initializeYes(); 199 initializeYes();
199 200
200 201
201}; 202};
202 203
203void OFileSelector::setYesCancelVisible( bool show ) 204void OFileSelector::setYesCancelVisible( bool show )
204{ 205{
205 if ( show == m_shYesNo ) 206 if ( show == m_shYesNo )
206 return; 207 return;
207 m_shYesNo = show; 208 m_shYesNo = show;
208 if( !show ){ 209 if( !show ){
209 delete m_ok; 210 delete m_ok;
210 delete m_cancel; 211 delete m_cancel;
211 m_ok = 0; 212 m_ok = 0;
212 m_cancel = 0; 213 m_cancel = 0;
213 // delete m_boxOk; all ready deleted in delItems 214 // delete m_boxOk; all ready deleted in delItems
214 } 215 }
215 updateLay(); // recreate it and save the other states 216 updateLay(); // recreate it and save the other states
216} 217}
217 218
218void OFileSelector::setToolbarVisible( bool show ) 219void OFileSelector::setToolbarVisible( bool show )
219{ 220{
220 if ( m_shTool == show ) 221 if ( m_shTool == show )
221 return; 222 return;
222 /* if( show ){ 223 /* if( show ){
223 224
224 }else { 225 }else {
225 226
226 }*/ 227 }*/
227} 228}
228 229
229void OFileSelector::setPermissionBarVisible( bool show ) 230void OFileSelector::setPermissionBarVisible( bool show )
230{ 231{
231 if( show == m_shPerm ) 232 if( show == m_shPerm )
232 return; 233 return;
233 234
234 m_shPerm = show; 235 m_shPerm = show;
235 236
236 updateLay(); 237 updateLay();
237} 238}
238void OFileSelector::setLineEditVisible( bool show ) 239void OFileSelector::setLineEditVisible( bool show )
239{ 240{
240 if( show == m_shLne ) 241 if( show == m_shLne )
241 return; 242 return;
242 243
243 m_shLne = show; 244 m_shLne = show;
244 if( !show ){ 245 if( !show ){
245 delete m_edit; 246 delete m_edit;
246 delete m_fnLabel; 247 delete m_fnLabel;
247 m_edit = 0; 248 m_edit = 0;
248 m_fnLabel = 0; 249 m_fnLabel = 0;
249 //delete m_boxName; will be deleted 250 //delete m_boxName; will be deleted
250 } 251 }
251 updateLay(); 252 updateLay();
252} 253}
253void OFileSelector::setChooserVisible( bool show ) 254void OFileSelector::setChooserVisible( bool show )
254{ 255{
255 if( show = m_shChooser ) 256 if( show = m_shChooser )
256 return; 257 return;
257 m_shChooser = show; 258 m_shChooser = show;
258 if( !show ){ 259 if( !show ){
259 delete m_mimeCheck; 260 delete m_mimeCheck;
260 delete m_viewCheck; 261 delete m_viewCheck;
261 m_mimeCheck = 0; 262 m_mimeCheck = 0;
262 m_viewCheck = 0; 263 m_viewCheck = 0;
263 } 264 }
264 updateLay(); 265 updateLay();
265} 266}
266QCheckBox* OFileSelector::permissionCheckbox( ) 267QCheckBox* OFileSelector::permissionCheckbox( )
267{ 268{
268 return m_checkPerm; 269 return m_checkPerm;
269} 270}
270void OFileSelector::setCaseSensetive( bool caSe ) 271void OFileSelector::setCaseSensetive( bool caSe )
271{ 272{
272 m_case = caSe; 273 m_case = caSe;
273 reparse(); 274 reparse();
274} 275}
275void OFileSelector::setShowFiles(bool files ){ 276void OFileSelector::setShowFiles(bool files ){
276 m_files = files; 277 m_files = files;
277 reparse(); 278 reparse();
278} 279}
279void OFileSelector::setPopupMenu(const QPopupMenu * ) 280void OFileSelector::setPopupMenu(const QPopupMenu * )
280{ 281{
281 //delete oldpopup; 282 //delete oldpopup;
282 283
283} 284}
284bool OFileSelector::setPermission( ) const 285bool OFileSelector::setPermission( ) const
285{ 286{
286 if( m_checkPerm == 0 ) 287 if( m_checkPerm == 0 )
287 return false; 288 return false;
288 else 289 else
289 return m_checkPerm->isChecked(); 290 return m_checkPerm->isChecked();
290} 291}
291void OFileSelector::setPermissionChecked( bool check ) 292void OFileSelector::setPermissionChecked( bool check )
292{ 293{
293 if( m_checkPerm == 0 ) 294 if( m_checkPerm == 0 )
294 return; 295 return;
295 m_checkPerm->setChecked( check ); 296 m_checkPerm->setChecked( check );
296} 297}
297QString OFileSelector::selectedName( )const 298QString OFileSelector::selectedName( )const
298{ 299{
299 QString string; 300 QString string;
300 if( m_selector == NORMAL ){ 301 if( m_selector == NORMAL ){
301 const DocLnk *lnk = m_select->selected(); 302 const DocLnk *lnk = m_select->selected();
302 string = lnk->file(); 303 string = lnk->file();
303 }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { 304 }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
304 QListViewItem *item = m_View->currentItem(); 305 QListViewItem *item = m_View->currentItem();
305 if(item != 0 ){ 306 if(item != 0 ){
306 string = item->text( 1 ); 307 string = item->text( 1 );
307 } 308 }
308 } 309 }
309 return string; 310 return string;
310} 311}
311QStringList OFileSelector::selectedNames()const 312QStringList OFileSelector::selectedNames()const
312{ 313{
313 QStringList list; 314 QStringList list;
314 return list; 315 return list;
315} 316}
316DocLnk OFileSelector::selectedDocument( )const 317DocLnk OFileSelector::selectedDocument( )const
317{ 318{
318 DocLnk lnk; 319 DocLnk lnk;
319 return lnk; 320 return lnk;
320} 321}
321void OFileSelector::updateLay() 322void OFileSelector::updateLay()
322{ 323{
323 /* if( m_shTool ) 324 /* if( m_shTool )
324 // 325 //
325 else 326 else
326 // hide 327 // hide
327 */ 328 */
328 // save the state 329 // save the state
329 bool check = false; 330 bool check = false;
330 if( m_checkPerm != 0 ) 331 if( m_checkPerm != 0 )
331 check = m_checkPerm->isChecked(); 332 check = m_checkPerm->isChecked();
332 QString text; 333 QString text;
333 334
334 if( m_edit != 0 ) 335 if( m_edit != 0 )
335 text = m_edit->text(); 336 text = m_edit->text();
336 // save current mimetype 337 // save current mimetype
337 338
338 delItems(); 339 delItems();
339 delete m_checkPerm; 340 delete m_checkPerm;
341 m_checkPerm = 0;
340 delete m_edit; 342 delete m_edit;
343 m_edit = 0;
341 delete m_fnLabel; 344 delete m_fnLabel;
345 m_fnLabel = 0;
342 delete m_ok; 346 delete m_ok;
347 m_ok = 0;
343 delete m_cancel; 348 delete m_cancel;
349 m_cancel = 0;
344 delete m_mimeCheck; 350 delete m_mimeCheck;
351 m_mimeCheck = 0;
345 delete m_viewCheck; 352 delete m_viewCheck;
353 m_viewCheck = 0;
346 delete m_select; // test 354 delete m_select; // test
347 delete m_stack; 355 delete m_stack;
348 //delete m_list; 356 //delete m_list;
349 init(); 357 init();
350 if( m_shLne ) 358 if( m_shLne )
351 m_edit->setText(text ); 359 m_edit->setText(text );
352 if( m_shPerm ) 360 if( m_shPerm )
353 m_checkPerm->setChecked(check ); 361 m_checkPerm->setChecked(check );
354} 362}
355// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve 363// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve
356// insert QListViewItems with the right options 364// insert QListViewItems with the right options
357bool OFileSelector::compliesMime(const QString &path, const QString &mime ) 365bool OFileSelector::compliesMime(const QString &path, const QString &mime )
358{ 366{
359 if( mime == "All" ) 367 if( mime == "All" )
360 return true; 368 return true;
361 MimeType type( path ); 369 MimeType type( path );
362 if( type.id() == mime ) 370 if( type.id() == mime )
363 return true; 371 return true;
364 return false; 372 return false;
365} 373}
366 374
367void OFileSelector::reparse() 375void OFileSelector::reparse()
368{ 376{
369 if(m_View== 0 || m_selector == NORMAL) 377 if(m_View== 0 || m_selector == NORMAL)
370 return; 378 return;
371 379
372 m_View->clear(); 380 m_View->clear();
373 381
374 382
375 QString currMime =m_mimeCheck->currentText(); 383 QString currMime =m_mimeCheck->currentText();
376 // update the mimetype now 384 // update the mimetype now
377 if( m_autoMime ) { 385 if( m_autoMime ) {
378 QDir dir( m_currentDir ); 386 QDir dir( m_currentDir );
379 m_mimetypes.clear(); 387 m_mimetypes.clear();
380 m_mimeCheck->clear(); 388 m_mimeCheck->clear();
381 dir.setFilter( QDir::Files | QDir::Readable ); 389 dir.setFilter( QDir::Files | QDir::Readable );
382 dir.setSorting(QDir::Size ); 390 dir.setSorting(QDir::Size );
383 const QFileInfoList *list = dir.entryInfoList(); 391 const QFileInfoList *list = dir.entryInfoList();
384 QFileInfoListIterator it( *list ); 392 QFileInfoListIterator it( *list );
385 QFileInfo *fi; 393 QFileInfo *fi;
386 while( (fi=it.current()) ){ 394 while( (fi=it.current()) ){
387 if(fi->extension() == QString::fromLatin1("desktop") ){ 395 if(fi->extension() == QString::fromLatin1("desktop") ){
388 ++it; 396 ++it;
389 continue; 397 continue;
390 } 398 }
391 MimeType type(fi->filePath() ); 399 MimeType type(fi->filePath() );
392 if( !m_mimetypes.contains( type.id() ) ) 400 if( !m_mimetypes.contains( type.id() ) )
393 m_mimetypes.append( type.id() ); 401 m_mimetypes.append( type.id() );
394 402
395 ++it; 403 ++it;
396 } 404 }
397 m_mimetypes.prepend("All" ); 405 m_mimetypes.prepend("All" );
398 m_mimeCheck->insertStringList(m_mimetypes ); 406 m_mimeCheck->insertStringList(m_mimetypes );
399 // set it to the current mimetype 407 // set it to the current mimetype
400 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); 408 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) );
401 }; 409 };
402 QDir dir( m_currentDir ); 410 QDir dir( m_currentDir );
403 //dir.setFilter(-1 ); 411 //dir.setFilter(-1 );
404 dir.setSorting(QDir::Name | QDir::DirsFirst | QDir::Reversed | QDir::IgnoreCase ); 412 dir.setSorting(QDir::Name | QDir::DirsFirst | QDir::Reversed | QDir::IgnoreCase );
405 const QFileInfoList *list = dir.entryInfoList(); 413 const QFileInfoList *list = dir.entryInfoList();
406 QFileInfoListIterator it( *list ); 414 QFileInfoListIterator it( *list );
407 QFileInfo *fi; 415 QFileInfo *fi;
408 while( (fi=it.current()) ){ 416 while( (fi=it.current()) ){
409 if(fi->fileName() == ".." || fi->fileName() == "." ){ 417 if(fi->fileName() == ".." || fi->fileName() == "." ){
410 ++it; 418 ++it;
411 continue; 419 continue;
412 } 420 }
413 qWarning("Test: %s", fi->fileName().latin1() ); 421 qWarning("Test: %s", fi->fileName().latin1() );
414 if(fi->isSymLink() ){ 422 if(fi->isSymLink() ){
415 qWarning("Symlink %s", fi->fileName().latin1() ); 423 qWarning("Symlink %s", fi->fileName().latin1() );
416 QString file = fi->dirPath(true)+"/"+ fi->readLink(); 424 QString file = fi->dirPath(true)+"/"+ fi->readLink();
417 qWarning("File ->%s", file.latin1() ); 425 qWarning("File ->%s", file.latin1() );
418 for(int i=0; i<=4; i++ ){ // prepend from dos 426 for(int i=0; i<=4; i++ ){ // prepend from dos
419 QFileInfo info( file ); 427 QFileInfo info( file );
420 if( !info.exists() ){ 428 if( !info.exists() ){
421 qWarning("does not exist" ); 429 qWarning("does not exist" );
422 addSymlink(currMime, fi, TRUE ); 430 addSymlink(currMime, fi, TRUE );
423 break; 431 break;
424 }else if( info.isDir() ){ 432 }else if( info.isDir() ){
425 qWarning("isDir" ); 433 qWarning("isDir" );
426 addDir(currMime, fi, TRUE ); 434 addDir(currMime, fi, TRUE );
427 break; 435 break;
428 }else if( info.isFile() ){ 436 }else if( info.isFile() ){
429 qWarning("isFile" ); 437 qWarning("isFile" );
430 addFile(currMime, fi, TRUE ); 438 addFile(currMime, fi, TRUE );
431 break; 439 break;
432 }else if( info.isSymLink() ){ 440 }else if( info.isSymLink() ){
433 file = info.dirPath(true)+ "/"+ info.readLink(); 441 file = info.dirPath(true)+ "/"+ info.readLink();
434 qWarning("isSymlink again %s", file.latin1() ); 442 qWarning("isSymlink again %s", file.latin1() );
435 }else if( i == 4 ){ // just insert it and have the symlink symbol 443 }else if( i == 4 ){ // just insert it and have the symlink symbol
436 addSymlink(currMime, fi ); 444 addSymlink(currMime, fi );
437 qWarning("level too deep" ); 445 qWarning("level too deep" );
438 } 446 }
439 } 447 }
440 }else if( fi->isDir() ){ 448 }else if( fi->isDir() ){
441 addDir(currMime, fi ); 449 addDir(currMime, fi );