-rw-r--r-- | libopie/ofileselector.cc | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 824acf2..3c3a6c4 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -141,602 +141,627 @@ OFileSelector::~OFileSelector() | |||
141 | { | 141 | { |
142 | 142 | ||
143 | 143 | ||
144 | } | 144 | } |
145 | 145 | ||
146 | void OFileSelector::setNewVisible( bool visible ) | 146 | void OFileSelector::setNewVisible( bool visible ) |
147 | { | 147 | { |
148 | m_shNew = visible; | 148 | m_shNew = visible; |
149 | if( m_selector == NORMAL ){ | 149 | if( m_selector == NORMAL ){ |
150 | delete m_select; | 150 | delete m_select; |
151 | // we need to initialize but keep the selected mimetype | 151 | // we need to initialize but keep the selected mimetype |
152 | QString mime = currentMimeType(); | 152 | QString mime = currentMimeType(); |
153 | m_select = new FileSelector( mime , | 153 | m_select = new FileSelector( mime , |
154 | m_stack, "fileselector", | 154 | m_stack, "fileselector", |
155 | m_shNew, m_shClose); | 155 | m_shNew, m_shClose); |
156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
158 | connect(m_select, SIGNAL(closeMe() ), | 158 | connect(m_select, SIGNAL(closeMe() ), |
159 | this, SIGNAL(closeMe() ) ); | 159 | this, SIGNAL(closeMe() ) ); |
160 | //connect to close me and other signals as well | 160 | //connect to close me and other signals as well |
161 | m_stack->addWidget( m_select, NORMAL ); | 161 | m_stack->addWidget( m_select, NORMAL ); |
162 | }else{ | 162 | }else{ |
163 | m_new->show(); | 163 | m_new->show(); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | void OFileSelector::setCloseVisible( bool visible ) | 166 | void OFileSelector::setCloseVisible( bool visible ) |
167 | { | 167 | { |
168 | m_shClose = visible; | 168 | m_shClose = visible; |
169 | if( m_selector == NORMAL ){ | 169 | if( m_selector == NORMAL ){ |
170 | setNewVisible( m_shNew ); // yeah baby | 170 | setNewVisible( m_shNew ); // yeah baby |
171 | }else{ | 171 | }else{ |
172 | m_close->show(); | 172 | m_close->show(); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | void OFileSelector::reread() | 175 | void OFileSelector::reread() |
176 | { | 176 | { |
177 | if( m_selector == NORMAL ){ | 177 | if( m_selector == NORMAL ){ |
178 | setNewVisible( m_shNew ); // make it a initializeSelector | 178 | setNewVisible( m_shNew ); // make it a initializeSelector |
179 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 179 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
180 | reparse(); | 180 | reparse(); |
181 | //}else{ | 181 | //}else{ |
182 | //; | 182 | //; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | const DocLnk *OFileSelector::selected() | 186 | const DocLnk *OFileSelector::selected() |
187 | { | 187 | { |
188 | if( m_selector == NORMAL ){ | 188 | if( m_selector == NORMAL ){ |
189 | return m_select->selected(); | 189 | return m_select->selected(); |
190 | }else{ | 190 | }else{ |
191 | DocLnk *lnk = new DocLnk(selectedDocument() ); | 191 | DocLnk *lnk = new DocLnk(selectedDocument() ); |
192 | return lnk; | 192 | return lnk; |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | void OFileSelector::setYesCancelVisible( bool show ) | 196 | void OFileSelector::setYesCancelVisible( bool show ) |
197 | { | 197 | { |
198 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( | 198 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( |
199 | m_shYesNo = show; | 199 | m_shYesNo = show; |
200 | if( m_shYesNo ) | 200 | if( m_shYesNo ) |
201 | m_boxOk->show(); | 201 | m_boxOk->show(); |
202 | else | 202 | else |
203 | m_boxOk->hide(); | 203 | m_boxOk->hide(); |
204 | 204 | ||
205 | } | 205 | } |
206 | void OFileSelector::setToolbarVisible( bool show ) | 206 | void OFileSelector::setToolbarVisible( bool show ) |
207 | { | 207 | { |
208 | m_shTool = show; | 208 | m_shTool = show; |
209 | initializeListView(); // FIXME see above waste of memory | 209 | initializeListView(); // FIXME see above waste of memory |
210 | if(!m_shTool ){ | 210 | if(!m_shTool ){ |
211 | m_location->hide(); | 211 | m_location->hide(); |
212 | m_up->hide(); | 212 | m_up->hide(); |
213 | m_homeButton->hide(); | 213 | m_homeButton->hide(); |
214 | m_docButton->hide(); | 214 | m_docButton->hide(); |
215 | }else{ | 215 | }else{ |
216 | m_location->show(); | 216 | m_location->show(); |
217 | m_up->show(); | 217 | m_up->show(); |
218 | m_homeButton->show(); | 218 | m_homeButton->show(); |
219 | m_docButton->show(); | 219 | m_docButton->show(); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | void OFileSelector::setPermissionBarVisible( bool show ) | 222 | void OFileSelector::setPermissionBarVisible( bool show ) |
223 | { | 223 | { |
224 | m_shPerm = show; | 224 | m_shPerm = show; |
225 | initializePerm(); | 225 | initializePerm(); |
226 | if( m_shPerm ) | 226 | if( m_shPerm ) |
227 | m_checkPerm->show(); | 227 | m_checkPerm->show(); |
228 | else | 228 | else |
229 | m_checkPerm->hide(); | 229 | m_checkPerm->hide(); |
230 | } | 230 | } |
231 | void OFileSelector::setLineEditVisible( bool show ) | 231 | void OFileSelector::setLineEditVisible( bool show ) |
232 | { | 232 | { |
233 | if( show ){ | 233 | if( show ){ |
234 | initializeName(); | 234 | initializeName(); |
235 | m_boxName->show(); | 235 | m_boxName->show(); |
236 | }else{ | 236 | }else{ |
237 | if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go | 237 | if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go |
238 | m_boxName->hide(); | 238 | m_boxName->hide(); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | m_shLne = show; | 241 | m_shLne = show; |
242 | } | 242 | } |
243 | 243 | ||
244 | void OFileSelector::setChooserVisible( bool show ) | 244 | void OFileSelector::setChooserVisible( bool show ) |
245 | { | 245 | { |
246 | m_shChooser = show; | 246 | m_shChooser = show; |
247 | initializeChooser(); | 247 | initializeChooser(); |
248 | if( m_shChooser ){ | 248 | if( m_shChooser ){ |
249 | m_boxView->hide(); | 249 | m_boxView->hide(); |
250 | }else{ | 250 | }else{ |
251 | m_boxView->show(); | 251 | m_boxView->show(); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | QCheckBox* OFileSelector::permissionCheckbox() | 255 | QCheckBox* OFileSelector::permissionCheckbox() |
256 | { | 256 | { |
257 | if( m_selector == NORMAL ) | 257 | if( m_selector == NORMAL ) |
258 | return 0l; | 258 | return 0l; |
259 | else | 259 | else |
260 | return m_checkPerm; | 260 | return m_checkPerm; |
261 | } | 261 | } |
262 | bool OFileSelector::setPermission()const | 262 | bool OFileSelector::setPermission()const |
263 | { | 263 | { |
264 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); | 264 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); |
265 | } | 265 | } |
266 | void OFileSelector::setPermissionChecked( bool check ) | 266 | void OFileSelector::setPermissionChecked( bool check ) |
267 | { | 267 | { |
268 | if( m_checkPerm ) | 268 | if( m_checkPerm ) |
269 | m_checkPerm->setChecked( check ); | 269 | m_checkPerm->setChecked( check ); |
270 | } | 270 | } |
271 | 271 | ||
272 | void OFileSelector::setMode(int mode) // FIXME do direct raising | 272 | void OFileSelector::setMode(int mode) // FIXME do direct raising |
273 | { | 273 | { |
274 | m_mode = mode; | 274 | m_mode = mode; |
275 | if( m_selector == NORMAL ) | 275 | if( m_selector == NORMAL ) |
276 | return; | 276 | return; |
277 | } | 277 | } |
278 | void OFileSelector::setShowDirs(bool ) | 278 | void OFileSelector::setShowDirs(bool ) |
279 | { | 279 | { |
280 | m_dir = true; | 280 | m_dir = true; |
281 | reparse(); | 281 | reparse(); |
282 | } | 282 | } |
283 | void OFileSelector::setCaseSensetive(bool caSe ) | 283 | void OFileSelector::setCaseSensetive(bool caSe ) |
284 | { | 284 | { |
285 | m_case = caSe; | 285 | m_case = caSe; |
286 | reparse(); | 286 | reparse(); |
287 | } | 287 | } |
288 | void OFileSelector::setShowFiles(bool show ) | 288 | void OFileSelector::setShowFiles(bool show ) |
289 | { | 289 | { |
290 | m_files = show; | 290 | m_files = show; |
291 | reparse(); | 291 | reparse(); |
292 | } | 292 | } |
293 | /// | 293 | /// |
294 | bool OFileSelector::cd(const QString &path ) | 294 | bool OFileSelector::cd(const QString &path ) |
295 | { | 295 | { |
296 | m_currentDir = path; | 296 | m_currentDir = path; |
297 | reparse(); | 297 | reparse(); |
298 | return true; | 298 | return true; |
299 | } | 299 | } |
300 | void OFileSelector::setSelector(int mode ) | 300 | void OFileSelector::setSelector(int mode ) |
301 | { | 301 | { |
302 | QString text; | 302 | QString text; |
303 | switch( mode ){ | 303 | switch( mode ){ |
304 | case NORMAL: | 304 | case NORMAL: |
305 | text = tr("Documents"); | 305 | text = tr("Documents"); |
306 | break; | 306 | break; |
307 | case EXTENDED: | 307 | case EXTENDED: |
308 | text = tr("Files"); | 308 | text = tr("Files"); |
309 | break; | 309 | break; |
310 | case EXTENDED_ALL: | 310 | case EXTENDED_ALL: |
311 | text = tr("All Files"); | 311 | text = tr("All Files"); |
312 | break; | 312 | break; |
313 | } | 313 | } |
314 | slotViewCheck( text ); | 314 | slotViewCheck( text ); |
315 | } | 315 | } |
316 | 316 | ||
317 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) | 317 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) |
318 | { | 318 | { |
319 | m_custom = popup; | 319 | m_custom = popup; |
320 | m_showPopup = true; | 320 | m_showPopup = true; |
321 | } | 321 | } |
322 | 322 | ||
323 | //void OFileSelector::updateL | 323 | //void OFileSelector::updateL |
324 | 324 | ||
325 | QString OFileSelector::selectedName() const | 325 | QString OFileSelector::selectedName() const |
326 | { | 326 | { |
327 | QString name; | 327 | QString name; |
328 | if( m_selector == NORMAL ){ | 328 | if( m_selector == NORMAL ){ |
329 | const DocLnk *lnk = m_select->selected(); | 329 | const DocLnk *lnk = m_select->selected(); |
330 | name = lnk->file(); | 330 | name = lnk->file(); |
331 | delete lnk; | 331 | delete lnk; |
332 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 332 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
333 | QListViewItem *item = m_View->currentItem(); | 333 | if ( m_shLne ) { |
334 | if( item != 0 ) | 334 | name = m_currentDir + "/" +m_edit->text(); |
335 | name = m_currentDir + "/" + item->text( 1 ); | 335 | }else{ |
336 | QListViewItem *item = m_View->currentItem(); | ||
337 | if( item != 0 ) | ||
338 | name = m_currentDir + "/" + item->text( 1 ); | ||
339 | } | ||
336 | }else { // installed view | 340 | }else { // installed view |
337 | ; | 341 | ; |
338 | } | 342 | } |
339 | return name; | 343 | return name; |
340 | } | 344 | } |
341 | QStringList OFileSelector::selectedNames()const | 345 | QStringList OFileSelector::selectedNames()const |
342 | { | 346 | { |
343 | QStringList list; | 347 | QStringList list; |
344 | if( m_selector == NORMAL ){ | 348 | if( m_selector == NORMAL ){ |
345 | list << selectedName(); | 349 | list << selectedName(); |
346 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 350 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
347 | list << selectedName(); // FIXME implement multiple Selections | 351 | list << selectedName(); // FIXME implement multiple Selections |
348 | } | 352 | } |
349 | return list; | 353 | return list; |
350 | } | 354 | } |
351 | /** If mode is set to the Dir selection this will return the selected path. | 355 | /** If mode is set to the Dir selection this will return the selected path. |
352 | * | 356 | * |
353 | * | 357 | * |
354 | */ | 358 | */ |
355 | QString OFileSelector::selectedPath()const | 359 | QString OFileSelector::selectedPath()const |
356 | { | 360 | { |
357 | QString path; | 361 | QString path; |
358 | if( m_selector == NORMAL ){ | 362 | if( m_selector == NORMAL ){ |
359 | path = QPEApplication::documentDir(); | 363 | path = QPEApplication::documentDir(); |
360 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 364 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
361 | ; | 365 | ; |
362 | } | 366 | } |
363 | return path; | 367 | return path; |
364 | } | 368 | } |
365 | QStringList OFileSelector::selectedPaths() const | 369 | QStringList OFileSelector::selectedPaths() const |
366 | { | 370 | { |
367 | QStringList list; | 371 | QStringList list; |
368 | list << selectedPath(); | 372 | list << selectedPath(); |
369 | return list; | 373 | return list; |
370 | } | 374 | } |
371 | QString OFileSelector::directory()const | 375 | QString OFileSelector::directory()const |
372 | { | 376 | { |
373 | if( m_selector == NORMAL ) | 377 | if( m_selector == NORMAL ) |
374 | return QPEApplication::documentDir(); | 378 | return QPEApplication::documentDir(); |
375 | 379 | ||
376 | return QDir(m_currentDir).absPath(); | 380 | return QDir(m_currentDir).absPath(); |
377 | } | 381 | } |
378 | 382 | ||
379 | int OFileSelector::fileCount() | 383 | int OFileSelector::fileCount() |
380 | { | 384 | { |
381 | int count; | 385 | int count; |
382 | switch( m_selector ){ | 386 | switch( m_selector ){ |
383 | case NORMAL: | 387 | case NORMAL: |
384 | count = m_select->fileCount(); | 388 | count = m_select->fileCount(); |
385 | break; | 389 | break; |
386 | //case CUSTOM: | 390 | //case CUSTOM: |
387 | case EXTENDED: | 391 | case EXTENDED: |
388 | case EXTENDED_ALL: | 392 | case EXTENDED_ALL: |
389 | default: | 393 | default: |
390 | count = m_View->childCount(); | 394 | count = m_View->childCount(); |
391 | break; | 395 | break; |
392 | } | 396 | } |
393 | return count; | 397 | return count; |
394 | } | 398 | } |
395 | DocLnk OFileSelector::selectedDocument() const | 399 | DocLnk OFileSelector::selectedDocument() const |
396 | { | 400 | { |
397 | DocLnk lnk; | 401 | DocLnk lnk; |
398 | switch( m_selector ){ | 402 | switch( m_selector ){ |
399 | case NORMAL:{ | 403 | case NORMAL:{ |
400 | const DocLnk *lnk2 = m_select->selected(); | 404 | const DocLnk *lnk2 = m_select->selected(); |
401 | lnk = DocLnk(*lnk2 ); // copy | 405 | lnk = DocLnk(*lnk2 ); // copy |
402 | delete lnk2; | 406 | delete lnk2; |
403 | break; | 407 | break; |
404 | } | 408 | } |
405 | case EXTENDED: | 409 | case EXTENDED: |
406 | case EXTENDED_ALL: | 410 | case EXTENDED_ALL: |
407 | default: | 411 | default: |
408 | lnk = DocLnk( selectedName() ); // new DocLnk | 412 | lnk = DocLnk( selectedName() ); // new DocLnk |
409 | break; | 413 | break; |
410 | } | 414 | } |
411 | return lnk; | 415 | return lnk; |
412 | } | 416 | } |
413 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | 417 | QValueList<DocLnk> OFileSelector::selectedDocuments() const |
414 | { | 418 | { |
415 | QValueList<DocLnk> docs; | 419 | QValueList<DocLnk> docs; |
416 | docs.append( selectedDocument() ); | 420 | docs.append( selectedDocument() ); |
417 | return docs; | 421 | return docs; |
418 | } | 422 | } |
419 | 423 | ||
420 | 424 | ||
421 | // slots internal | 425 | // slots internal |
422 | 426 | ||
423 | void OFileSelector::slotOk() | 427 | void OFileSelector::slotOk() |
424 | { | 428 | { |
425 | emit ok(); | 429 | emit ok(); |
426 | } | 430 | } |
427 | void OFileSelector::slotCancel() | 431 | void OFileSelector::slotCancel() |
428 | { | 432 | { |
429 | emit cancel(); | 433 | emit cancel(); |
430 | } | 434 | } |
431 | void OFileSelector::slotViewCheck(const QString &sel) | 435 | void OFileSelector::slotViewCheck(const QString &sel) |
432 | { | 436 | { |
433 | if( sel == tr("Documents" ) ){ | 437 | if( sel == tr("Documents" ) ){ |
434 | if( m_select == 0 ){ | 438 | if( m_select == 0 ){ |
435 | // autMime? fix cause now we use All and not the current | 439 | // autMime? fix cause now we use All and not the current |
436 | // yes currentMime fixes that for us | 440 | // yes currentMime fixes that for us |
437 | QString mime = currentMimeType(); | 441 | QString mime = currentMimeType(); |
438 | m_select = new FileSelector(mime, | 442 | m_select = new FileSelector(mime, |
439 | m_stack, "fileselector", | 443 | m_stack, "fileselector", |
440 | m_shNew, m_shClose); | 444 | m_shNew, m_shClose); |
441 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 445 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
442 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 446 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
443 | connect(m_select, SIGNAL(closeMe() ), | 447 | connect(m_select, SIGNAL(closeMe() ), |
444 | this, SIGNAL(closeMe() ) ); | 448 | this, SIGNAL(closeMe() ) ); |
445 | //connect to close me and other signals as well | 449 | //connect to close me and other signals as well |
446 | 450 | ||
447 | m_stack->addWidget( m_select, NORMAL ); | 451 | m_stack->addWidget( m_select, NORMAL ); |
448 | } | 452 | } |
449 | m_stack->raiseWidget( NORMAL ); | 453 | m_stack->raiseWidget( NORMAL ); |
450 | m_selector = NORMAL; | 454 | m_selector = NORMAL; |
451 | }else if( sel == tr("Files") ){ | 455 | }else if( sel == tr("Files") ){ |
452 | m_selector = EXTENDED; | 456 | m_selector = EXTENDED; |
453 | initializeListView(); | 457 | initializeListView(); |
454 | reparse(); | 458 | reparse(); |
455 | m_stack->raiseWidget( EXTENDED ); | 459 | m_stack->raiseWidget( EXTENDED ); |
456 | }else if( sel == tr("All Files") ){ | 460 | }else if( sel == tr("All Files") ){ |
457 | m_selector = EXTENDED_ALL; | 461 | m_selector = EXTENDED_ALL; |
458 | initializeListView(); | 462 | initializeListView(); |
459 | reparse(); | 463 | reparse(); |
460 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter | 464 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter |
461 | } | 465 | } |
462 | } | 466 | } |
463 | // not yet finished..... | 467 | // not yet finished..... |
464 | QString OFileSelector::currentMimeType() const{ | 468 | QString OFileSelector::currentMimeType() const{ |
465 | QString mime; | 469 | QString mime; |
466 | QString currentText; | 470 | QString currentText; |
467 | if (m_shChooser ) | 471 | if (m_shChooser ) |
468 | currentText = m_mimeCheck->currentText(); | 472 | currentText = m_mimeCheck->currentText(); |
469 | 473 | ||
470 | if (tr("All") == currentText ) return QString::null; | 474 | if (tr("All") == currentText ) return QString::null; |
471 | else if (currentText.isEmpty() ) { | 475 | else if (currentText.isEmpty() ) { |
472 | ; | 476 | ; |
473 | }else { | 477 | }else { |
474 | QMap<QString, QStringList>::ConstIterator it; | 478 | QMap<QString, QStringList>::ConstIterator it; |
475 | it = m_mimetypes.find( currentText ); | 479 | it = m_mimetypes.find( currentText ); |
476 | if ( it == m_mimetypes.end() ) { | 480 | if ( it == m_mimetypes.end() ) { |
477 | mime = it.data().join(";"); | 481 | mime = it.data().join(";"); |
478 | }else{ | 482 | }else{ |
479 | mime = currentText; | 483 | mime = currentText; |
480 | } | 484 | } |
481 | } | 485 | } |
482 | return mime; | 486 | return mime; |
483 | } | 487 | } |
484 | void OFileSelector::slotMimeCheck(const QString &mime) | 488 | void OFileSelector::slotMimeCheck(const QString &mime) |
485 | { | 489 | { |
486 | if( m_selector == NORMAL ){ | 490 | if( m_selector == NORMAL ){ |
487 | //if( m_autoMime ){ | 491 | //if( m_autoMime ){ |
488 | QString newMimeType; | 492 | QString newMimeType; |
489 | if (mime != tr("All") ) { | 493 | if (mime != tr("All") ) { |
490 | QMap<QString, QStringList>::Iterator it; | 494 | QMap<QString, QStringList>::Iterator it; |
491 | it = m_mimetypes.find(mime); | 495 | it = m_mimetypes.find(mime); |
492 | if ( it != m_mimetypes.end() ) { | 496 | if ( it != m_mimetypes.end() ) { |
493 | newMimeType = it.data().join(";"); | 497 | newMimeType = it.data().join(";"); |
494 | }else{ | 498 | }else{ |
495 | newMimeType = mime; | 499 | newMimeType = mime; |
496 | } | 500 | } |
497 | } | 501 | } |
498 | delete m_select; | 502 | delete m_select; |
499 | m_select = new FileSelector( newMimeType, | 503 | m_select = new FileSelector( newMimeType, |
500 | m_stack, "fileselector", | 504 | m_stack, "fileselector", |
501 | m_shNew, m_shClose); | 505 | m_shNew, m_shClose); |
502 | 506 | ||
503 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 507 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
504 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 508 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
505 | connect(m_select, SIGNAL(closeMe() ), | 509 | connect(m_select, SIGNAL(closeMe() ), |
506 | this, SIGNAL(closeMe() ) ); | 510 | this, SIGNAL(closeMe() ) ); |
507 | //connect to close me and other signals as well | 511 | //connect to close me and other signals as well |
508 | m_stack->addWidget( m_select, NORMAL ); | 512 | m_stack->addWidget( m_select, NORMAL ); |
509 | m_stack->raiseWidget( NORMAL ); | 513 | m_stack->raiseWidget( NORMAL ); |
510 | updateMimes(); | 514 | updateMimes(); |
511 | updateMimeCheck(); | 515 | updateMimeCheck(); |
512 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 516 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
513 | //} | 517 | //} |
514 | }else{ // others | 518 | }else{ // others |
515 | qWarning("Mime %s", mime.latin1() ); | 519 | qWarning("Mime %s", mime.latin1() ); |
516 | if(m_shChooser ){ | 520 | if(m_shChooser ){ |
517 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | 521 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); |
518 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 522 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
519 | } | 523 | } |
520 | reparse(); | 524 | reparse(); |
521 | } | 525 | } |
522 | 526 | ||
523 | } | 527 | } |
528 | /* | ||
529 | * Ok if a non dir gets inserted into this combobox | ||
530 | * we need to change it | ||
531 | * QFileInfo and dirPath will give us the right Dir | ||
532 | */ | ||
524 | void OFileSelector::slotLocationActivated(const QString &file) | 533 | void OFileSelector::slotLocationActivated(const QString &file) |
525 | { | 534 | { |
526 | cd(file.left(file.find("<-",0,TRUE))); | 535 | qWarning("slotLocationActivated"); |
527 | reparse(); | 536 | QString name = file.left( file.find("<-", 0, TRUE ) ); |
537 | QFileInfo info( name ); | ||
538 | if ( info.isFile() ) | ||
539 | cd(info.dirPath( TRUE ) ); //absolute | ||
540 | else | ||
541 | cd(name ); | ||
542 | reparse(); | ||
528 | } | 543 | } |
529 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | 544 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) |
530 | { | 545 | { |
531 | QStringList pathList; | 546 | QStringList pathList; |
532 | bool underDog = FALSE; | 547 | bool underDog = FALSE; |
533 | for(int i=0;i<count;i++) { | 548 | for(int i=0;i<count;i++) { |
534 | pathList << m_location->text(i); | 549 | pathList << m_location->text(i); |
535 | if( m_location->text(i) == currentPath) | 550 | if( m_location->text(i) == currentPath) |
536 | underDog = TRUE; | 551 | underDog = TRUE; |
537 | } | 552 | } |
538 | if( !underDog) { | 553 | if( !underDog) { |
539 | m_location->clear(); | 554 | m_location->clear(); |
540 | if( currentPath.left(2)=="//") | 555 | if( currentPath.left(2)=="//") |
541 | pathList.append( currentPath.right(currentPath.length()-1) ); | 556 | pathList.append( currentPath.right(currentPath.length()-1) ); |
542 | else | 557 | else |
543 | pathList.append( currentPath ); | 558 | pathList.append( currentPath ); |
544 | m_location->insertStringList( pathList,-1); | 559 | m_location->insertStringList( pathList,-1); |
545 | } | 560 | } |
546 | } | 561 | } |
562 | /* | ||
563 | * Do not crash anymore | ||
564 | * don't try to change dir to a file | ||
565 | */ | ||
547 | void OFileSelector::locationComboChanged() | 566 | void OFileSelector::locationComboChanged() |
548 | { | 567 | { |
549 | cd( m_location->lineEdit()->text()); | 568 | QFileInfo info( m_location->lineEdit()->text() ); |
550 | reparse(); | 569 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); |
570 | if (info.isFile() ) | ||
571 | cd(info.dirPath(TRUE) ); //absolute path | ||
572 | else | ||
573 | cd( m_location->lineEdit()->text() ); | ||
574 | |||
575 | reparse(); | ||
551 | } | 576 | } |
552 | void OFileSelector::init() | 577 | void OFileSelector::init() |
553 | { | 578 | { |
554 | m_lay = new QVBoxLayout( this ); | 579 | m_lay = new QVBoxLayout( this ); |
555 | m_lay->setSpacing(0 ); | 580 | m_lay->setSpacing(0 ); |
556 | 581 | ||
557 | m_stack = new QWidgetStack( this ); | 582 | m_stack = new QWidgetStack( this ); |
558 | if( m_selector == NORMAL ){ | 583 | if( m_selector == NORMAL ){ |
559 | QString mime; | 584 | QString mime; |
560 | if (!m_autoMime) { | 585 | if (!m_autoMime) { |
561 | if (!m_mimetypes.isEmpty() ) { | 586 | if (!m_mimetypes.isEmpty() ) { |
562 | QMap<QString, QStringList>::Iterator it; | 587 | QMap<QString, QStringList>::Iterator it; |
563 | it = m_mimetypes.begin(); // cause we're in the init | 588 | it = m_mimetypes.begin(); // cause we're in the init |
564 | mime = it.data().join(";"); | 589 | mime = it.data().join(";"); |
565 | } | 590 | } |
566 | } | 591 | } |
567 | m_select = new FileSelector(mime, | 592 | m_select = new FileSelector(mime, |
568 | m_stack, "fileselector", | 593 | m_stack, "fileselector", |
569 | m_shNew, m_shClose); | 594 | m_shNew, m_shClose); |
570 | 595 | ||
571 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 596 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
572 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 597 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
573 | connect(m_select, SIGNAL(closeMe() ), | 598 | connect(m_select, SIGNAL(closeMe() ), |
574 | this, SIGNAL( closeMe() ) ); | 599 | this, SIGNAL( closeMe() ) ); |
575 | //connect to close me and other signals as well | 600 | //connect to close me and other signals as well |
576 | 601 | ||
577 | m_stack->addWidget( m_select, NORMAL ); | 602 | m_stack->addWidget( m_select, NORMAL ); |
578 | m_stack->raiseWidget( NORMAL ); | 603 | m_stack->raiseWidget( NORMAL ); |
579 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL | 604 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL |
580 | // and initializeListview will take care of those | 605 | // and initializeListview will take care of those |
581 | // toolbar get's generade in initializeListView | 606 | // toolbar get's generade in initializeListView |
582 | initializeListView( ); // will raise the widget as well | 607 | initializeListView( ); // will raise the widget as well |
583 | m_stack->raiseWidget( EXTENDED ); | 608 | m_stack->raiseWidget( EXTENDED ); |
584 | } | 609 | } |
585 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch | 610 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch |
586 | 611 | ||
587 | if( m_shLne ) // the LineEdit with the current FileName | 612 | if( m_shLne ) // the LineEdit with the current FileName |
588 | initializeName(); | 613 | initializeName(); |
589 | 614 | ||
590 | if( m_shPerm ) // the Permission QCheckBox | 615 | if( m_shPerm ) // the Permission QCheckBox |
591 | initializePerm(); | 616 | initializePerm(); |
592 | 617 | ||
593 | if( m_shChooser ) // the Chooser for the view and Mimetypes | 618 | if( m_shChooser ) // the Chooser for the view and Mimetypes |
594 | initializeChooser(); | 619 | initializeChooser(); |
595 | 620 | ||
596 | if( m_shYesNo ) // the Yes No button row | 621 | if( m_shYesNo ) // the Yes No button row |
597 | initializeYes( ); | 622 | initializeYes( ); |
598 | 623 | ||
599 | if (m_selector != NORMAL ) | 624 | if (m_selector != NORMAL ) |
600 | reparse(); | 625 | reparse(); |
601 | } | 626 | } |
602 | void OFileSelector::updateMimes() | 627 | void OFileSelector::updateMimes() |
603 | { | 628 | { |
604 | if( m_autoMime ){ | 629 | if( m_autoMime ){ |
605 | m_mimetypes.clear(); | 630 | m_mimetypes.clear(); |
606 | m_mimetypes.insert( tr("All"), QString::null ); | 631 | m_mimetypes.insert( tr("All"), QString::null ); |
607 | if( m_selector == NORMAL ){ | 632 | if( m_selector == NORMAL ){ |
608 | DocLnkSet set; | 633 | DocLnkSet set; |
609 | Global::findDocuments(&set, QString::null ); | 634 | Global::findDocuments(&set, QString::null ); |
610 | QListIterator<DocLnk> dit( set.children() ); | 635 | QListIterator<DocLnk> dit( set.children() ); |
611 | for( ; dit.current(); ++dit ){ | 636 | for( ; dit.current(); ++dit ){ |
612 | if( !m_mimetypes.contains( (*dit)->type() ) ) | 637 | if( !m_mimetypes.contains( (*dit)->type() ) ) |
613 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | 638 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); |
614 | } | 639 | } |
615 | }// else done in reparse | 640 | }// else done in reparse |
616 | } | 641 | } |
617 | } | 642 | } |
618 | void OFileSelector::initVars() | 643 | void OFileSelector::initVars() |
619 | { | 644 | { |
620 | if( m_mimetypes.isEmpty() ) | 645 | if( m_mimetypes.isEmpty() ) |
621 | m_autoMime = true; | 646 | m_autoMime = true; |
622 | else | 647 | else |
623 | m_autoMime = false; | 648 | m_autoMime = false; |
624 | m_shClose = false; | 649 | m_shClose = false; |
625 | m_shNew = false; | 650 | m_shNew = false; |
626 | m_shTool = true; | 651 | m_shTool = true; |
627 | m_shPerm = false; | 652 | m_shPerm = false; |
628 | m_shLne = true; | 653 | m_shLne = true; |
629 | m_shChooser = true; | 654 | m_shChooser = true; |
630 | m_shYesNo = true; | 655 | m_shYesNo = true; |
631 | m_case = false; | 656 | m_case = false; |
632 | m_dir = true; | 657 | m_dir = true; |
633 | m_files = true; | 658 | m_files = true; |
634 | m_showPopup = false; | 659 | m_showPopup = false; |
635 | if(m_pixmaps == 0 ) // init the pixmaps | 660 | if(m_pixmaps == 0 ) // init the pixmaps |
636 | initPics(); | 661 | initPics(); |
637 | 662 | ||
638 | // pointers | 663 | // pointers |
639 | m_location = 0; | 664 | m_location = 0; |
640 | m_mimeCheck = 0; | 665 | m_mimeCheck = 0; |
641 | m_viewCheck = 0; | 666 | m_viewCheck = 0; |
642 | m_homeButton = 0; | 667 | m_homeButton = 0; |
643 | m_docButton = 0; | 668 | m_docButton = 0; |
644 | m_hideButton = 0; | 669 | m_hideButton = 0; |
645 | m_ok = 0; | 670 | m_ok = 0; |
646 | m_cancel = 0; | 671 | m_cancel = 0; |
647 | m_reread = 0; | 672 | m_reread = 0; |
648 | m_up = 0; | 673 | m_up = 0; |
649 | m_View = 0; | 674 | m_View = 0; |
650 | m_checkPerm = 0; | 675 | m_checkPerm = 0; |
651 | m_pseudo = 0; | 676 | m_pseudo = 0; |
652 | m_pseudoLayout = 0; | 677 | m_pseudoLayout = 0; |
653 | m_select = 0; | 678 | m_select = 0; |
654 | m_stack = 0; | 679 | m_stack = 0; |
655 | m_lay = 0; | 680 | m_lay = 0; |
656 | m_Oselector = 0; | 681 | m_Oselector = 0; |
657 | m_boxToolbar = 0; | 682 | m_boxToolbar = 0; |
658 | m_boxOk = 0; | 683 | m_boxOk = 0; |
659 | m_boxName = 0; | 684 | m_boxName = 0; |
660 | m_boxView = 0; | 685 | m_boxView = 0; |
661 | m_custom = 0; | 686 | m_custom = 0; |
662 | m_edit = 0; | 687 | m_edit = 0; |
663 | m_fnLabel = 0; | 688 | m_fnLabel = 0; |
664 | m_new = 0; | 689 | m_new = 0; |
665 | m_close = 0; | 690 | m_close = 0; |
666 | } | 691 | } |
667 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink) | 692 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink) |
668 | { | 693 | { |
669 | if(!m_files) | 694 | if(!m_files) |
670 | return; | 695 | return; |
671 | // if( !compliesMime(info->absFilePath(), mime ) ) | 696 | // if( !compliesMime(info->absFilePath(), mime ) ) |
672 | // return; | 697 | // return; |
673 | MimeType type( info->absFilePath() ); | 698 | MimeType type( info->absFilePath() ); |
674 | if (!compliesMime( type.id() ) ) | 699 | if (!compliesMime( type.id() ) ) |
675 | return; | 700 | return; |
676 | 701 | ||
677 | QPixmap pix = type.pixmap(); | 702 | QPixmap pix = type.pixmap(); |
678 | QString dir; | 703 | QString dir; |
679 | QString name; | 704 | QString name; |
680 | bool locked; | 705 | bool locked; |
681 | if( pix.isNull() ) | 706 | if( pix.isNull() ) |
682 | pix = Resource::loadPixmap( "UnknownDocument-14"); | 707 | pix = Resource::loadPixmap( "UnknownDocument-14"); |
683 | dir = info->dirPath( true ); | 708 | dir = info->dirPath( true ); |
684 | if( symlink ) | 709 | if( symlink ) |
685 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); | 710 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); |
686 | else { | 711 | else { |
687 | name = info->fileName(); | 712 | name = info->fileName(); |
688 | if( ( m_mode == OPEN && !info->isReadable() )|| | 713 | if( ( m_mode == OPEN && !info->isReadable() )|| |
689 | ( m_mode == SAVE && !info->isWritable() ) ){ | 714 | ( m_mode == SAVE && !info->isWritable() ) ){ |
690 | 715 | ||
691 | locked = true; pix = Resource::loadPixmap("locked"); | 716 | locked = true; pix = Resource::loadPixmap("locked"); |
692 | } | 717 | } |
693 | } | 718 | } |
694 | new OFileSelectorItem( m_View, pix, name, | 719 | new OFileSelectorItem( m_View, pix, name, |
695 | info->lastModified().toString(), | 720 | info->lastModified().toString(), |
696 | QString::number( info->size() ), | 721 | QString::number( info->size() ), |
697 | dir, locked ); | 722 | dir, locked ); |
698 | } | 723 | } |
699 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | 724 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) |
700 | { | 725 | { |
701 | if(!m_dir) | 726 | if(!m_dir) |
702 | return; | 727 | return; |
703 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ | 728 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ |
704 | bool locked = false; | 729 | bool locked = false; |
705 | QString name; | 730 | QString name; |
706 | QPixmap pix; | 731 | QPixmap pix; |
707 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ | 732 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ |
708 | locked = true; | 733 | locked = true; |
709 | if( symlink ) | 734 | if( symlink ) |
710 | pix = (*m_pixmaps)["symlinkedlocked"]; | 735 | pix = (*m_pixmaps)["symlinkedlocked"]; |
711 | else | 736 | else |
712 | pix = Resource::loadPixmap("lockedfolder"); | 737 | pix = Resource::loadPixmap("lockedfolder"); |
713 | }else { // readable | 738 | }else { // readable |
714 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; | 739 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; |
715 | } | 740 | } |
716 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; | 741 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; |
717 | new OFileSelectorItem( m_View, pix, name, | 742 | new OFileSelectorItem( m_View, pix, name, |
718 | info->lastModified().toString(), | 743 | info->lastModified().toString(), |
719 | QString::number( info->size() ), | 744 | QString::number( info->size() ), |
720 | info->dirPath( true ), locked, | 745 | info->dirPath( true ), locked, |
721 | true ); | 746 | true ); |
722 | 747 | ||
723 | }// else CUSTOM View | 748 | }// else CUSTOM View |
724 | } | 749 | } |
725 | void OFileSelector::delItems() | 750 | void OFileSelector::delItems() |
726 | { | 751 | { |
727 | 752 | ||
728 | } | 753 | } |
729 | void OFileSelector::initializeName() | 754 | void OFileSelector::initializeName() |
730 | { | 755 | { |
731 | /** Name Layout Line | 756 | /** Name Layout Line |
732 | * This is the Layout line arranged in | 757 | * This is the Layout line arranged in |
733 | * horizontal way each components | 758 | * horizontal way each components |
734 | * are next to each other | 759 | * are next to each other |
735 | * but we will only do this if | 760 | * but we will only do this if |
736 | * we didn't initialize a while ago. | 761 | * we didn't initialize a while ago. |
737 | */ | 762 | */ |
738 | if( m_boxName == 0 ){ | 763 | if( m_boxName == 0 ){ |
739 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox | 764 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox |
740 | m_fnLabel = new QLabel( m_boxName ); | 765 | m_fnLabel = new QLabel( m_boxName ); |
741 | m_fnLabel->setText( tr("Name:") ); | 766 | m_fnLabel->setText( tr("Name:") ); |
742 | m_edit = new QLineEdit( m_boxName ); | 767 | m_edit = new QLineEdit( m_boxName ); |