summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/oclickablelabel.cpp2
-rw-r--r--libopie/ofileselector.cc9
-rw-r--r--libopie/ofileselector.h2
-rw-r--r--libopie/ofileselector/odefaultfactories.cpp4
-rw-r--r--libopie/ofileselector/odefaultfactories.h1
-rw-r--r--libopie/ofileselector/ofileselector.cpp3
-rw-r--r--libopie/pim/opimaccessbackend.h4
-rw-r--r--libopie/pim/opimaccesstemplate.h10
-rw-r--r--libopie/pim/orecordlist.h4
-rw-r--r--libopie/pim/otodo.cpp2
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h4
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h10
-rw-r--r--libopie2/opiepim/orecordlist.h4
-rw-r--r--libopie2/opiepim/otodo.cpp2
14 files changed, 28 insertions, 33 deletions
diff --git a/libopie/oclickablelabel.cpp b/libopie/oclickablelabel.cpp
index 43a0524..5768529 100644
--- a/libopie/oclickablelabel.cpp
+++ b/libopie/oclickablelabel.cpp
@@ -1,88 +1,88 @@
1#include "oclickablelabel.h" 1#include "oclickablelabel.h"
2#include <stdio.h> 2#include <stdio.h>
3 3
4OClickableLabel::OClickableLabel(QWidget* parent, 4OClickableLabel::OClickableLabel(QWidget* parent,
5 const char* name, 5 const char* name,
6 WFlags fl) : 6 WFlags fl) :
7 QLabel(parent,name,fl) 7 QLabel(parent,name,fl)
8{ 8{
9 textInverted=false; 9 textInverted=false;
10 isToggle=false; 10 isToggle=false;
11 isDown=false; 11 isDown=false;
12 showState(false); 12 showState(false);
13 setFrameShadow(Sunken); 13 setFrameShadow(Sunken);
14} 14}
15 15
16void OClickableLabel::setToggleButton(bool t) { 16void OClickableLabel::setToggleButton(bool t) {
17 isToggle=t; 17 isToggle=t;
18} 18}
19 19
20void OClickableLabel::mousePressEvent( QMouseEvent *e ) { 20void OClickableLabel::mousePressEvent( QMouseEvent * /*e*/ ) {
21 if (isToggle && isDown) { 21 if (isToggle && isDown) {
22 showState(false); 22 showState(false);
23 } else { 23 } else {
24 showState(true); 24 showState(true);
25 } 25 }
26} 26}
27 27
28void OClickableLabel::mouseReleaseEvent( QMouseEvent *e ) { 28void OClickableLabel::mouseReleaseEvent( QMouseEvent *e ) {
29 if (rect().contains(e->pos()) && isToggle) isDown=!isDown; 29 if (rect().contains(e->pos()) && isToggle) isDown=!isDown;
30 30
31 if (isToggle && isDown) { 31 if (isToggle && isDown) {
32 showState(true); 32 showState(true);
33 } else { 33 } else {
34 showState(false); 34 showState(false);
35 } 35 }
36 36
37 if (rect().contains(e->pos())) { 37 if (rect().contains(e->pos())) {
38 if (isToggle) { 38 if (isToggle) {
39 emit toggled(isDown); 39 emit toggled(isDown);
40 } 40 }
41 emit clicked(); 41 emit clicked();
42 } 42 }
43} 43}
44 44
45void OClickableLabel::mouseMoveEvent( QMouseEvent *e ) { 45void OClickableLabel::mouseMoveEvent( QMouseEvent *e ) {
46 if (rect().contains(e->pos())) { 46 if (rect().contains(e->pos())) {
47 if (isToggle && isDown) { 47 if (isToggle && isDown) {
48 showState(false); 48 showState(false);
49 } else { 49 } else {
50 showState(true); 50 showState(true);
51 } 51 }
52 } else { 52 } else {
53 if (isToggle && isDown) { 53 if (isToggle && isDown) {
54 showState(true); 54 showState(true);
55 } else { 55 } else {
56 showState(false); 56 showState(false);
57 } 57 }
58 } 58 }
59} 59}
60 60
61void OClickableLabel::showState(bool on) { 61void OClickableLabel::showState(bool on) {
62 if (on) { 62 if (on) {
63 //setFrameShape(Panel); 63 //setFrameShape(Panel);
64 setInverted(true); 64 setInverted(true);
65 setBackgroundMode(PaletteHighlight); 65 setBackgroundMode(PaletteHighlight);
66 } else { 66 } else {
67 //setFrameShape(NoFrame); 67 //setFrameShape(NoFrame);
68 setInverted(false); 68 setInverted(false);
69 setBackgroundMode(PaletteBackground); 69 setBackgroundMode(PaletteBackground);
70 } 70 }
71 repaint(); 71 repaint();
72} 72}
73 73
74void OClickableLabel::setInverted(bool on) { 74void OClickableLabel::setInverted(bool on) {
75 if ( (!textInverted && on) || (textInverted && !on) ) { 75 if ( (!textInverted && on) || (textInverted && !on) ) {
76 QPalette pal=palette(); 76 QPalette pal=palette();
77 QColor col=pal.color(QPalette::Normal, QColorGroup::Foreground); 77 QColor col=pal.color(QPalette::Normal, QColorGroup::Foreground);
78 col.setRgb(255-col.red(),255-col.green(),255-col.blue()); 78 col.setRgb(255-col.red(),255-col.green(),255-col.blue());
79 pal.setColor(QPalette::Normal, QColorGroup::Foreground, col); 79 pal.setColor(QPalette::Normal, QColorGroup::Foreground, col);
80 setPalette(pal); 80 setPalette(pal);
81 textInverted=!textInverted; 81 textInverted=!textInverted;
82 } 82 }
83} 83}
84 84
85void OClickableLabel::setOn(bool on) { 85void OClickableLabel::setOn(bool on) {
86 isDown=on; 86 isDown=on;
87 showState(isDown); 87 showState(isDown);
88} 88}
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index 9534667..6a6a300 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -250,257 +250,257 @@ void OFileSelector::setChooserVisible( bool show )
250 250
251QCheckBox* OFileSelector::permissionCheckbox() 251QCheckBox* OFileSelector::permissionCheckbox()
252{ 252{
253 if( m_selector == NORMAL ) 253 if( m_selector == NORMAL )
254 return 0l; 254 return 0l;
255 else 255 else
256 return m_checkPerm; 256 return m_checkPerm;
257} 257}
258bool OFileSelector::setPermission()const 258bool OFileSelector::setPermission()const
259{ 259{
260 return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); 260 return m_checkPerm == 0 ? false : m_checkPerm->isChecked();
261} 261}
262void OFileSelector::setPermissionChecked( bool check ) 262void OFileSelector::setPermissionChecked( bool check )
263{ 263{
264 if( m_checkPerm ) 264 if( m_checkPerm )
265 m_checkPerm->setChecked( check ); 265 m_checkPerm->setChecked( check );
266} 266}
267 267
268void OFileSelector::setMode(int mode) // FIXME do direct raising 268void OFileSelector::setMode(int mode) // FIXME do direct raising
269{ 269{
270 m_mode = mode; 270 m_mode = mode;
271 if( m_selector == NORMAL ) 271 if( m_selector == NORMAL )
272 return; 272 return;
273} 273}
274void OFileSelector::setShowDirs(bool ) 274void OFileSelector::setShowDirs(bool )
275{ 275{
276 m_dir = true; 276 m_dir = true;
277 reparse(); 277 reparse();
278} 278}
279void OFileSelector::setCaseSensetive(bool caSe ) 279void OFileSelector::setCaseSensetive(bool caSe )
280{ 280{
281 m_case = caSe; 281 m_case = caSe;
282 reparse(); 282 reparse();
283} 283}
284void OFileSelector::setShowFiles(bool show ) 284void OFileSelector::setShowFiles(bool show )
285{ 285{
286 m_files = show; 286 m_files = show;
287 reparse(); 287 reparse();
288} 288}
289/// 289///
290bool OFileSelector::cd(const QString &path ) 290bool OFileSelector::cd(const QString &path )
291{ 291{
292 m_currentDir = path; 292 m_currentDir = path;
293 reparse(); 293 reparse();
294 return true; 294 return true;
295} 295}
296void OFileSelector::setSelector(int mode ) 296void OFileSelector::setSelector(int mode )
297{ 297{
298QString text; 298QString text;
299 switch( mode ){ 299 switch( mode ){
300 case NORMAL: 300 case NORMAL:
301 text = tr("Documents"); 301 text = tr("Documents");
302 break; 302 break;
303 case EXTENDED: 303 case EXTENDED:
304 text = tr("Files"); 304 text = tr("Files");
305 break; 305 break;
306 case EXTENDED_ALL: 306 case EXTENDED_ALL:
307 text = tr("All Files"); 307 text = tr("All Files");
308 break; 308 break;
309 } 309 }
310 slotViewCheck( text ); 310 slotViewCheck( text );
311} 311}
312 312
313void OFileSelector::setPopupMenu(QPopupMenu *popup ) 313void OFileSelector::setPopupMenu(QPopupMenu *popup )
314{ 314{
315 m_custom = popup; 315 m_custom = popup;
316 m_showPopup = true; 316 m_showPopup = true;
317} 317}
318 318
319//void OFileSelector::updateL 319//void OFileSelector::updateL
320 320
321QString OFileSelector::selectedName() const 321QString OFileSelector::selectedName() const
322{ 322{
323 QString name; 323 QString name;
324 if( m_selector == NORMAL ){ 324 if( m_selector == NORMAL ){
325 DocLnk lnk = m_select->selectedDocument(); 325 DocLnk lnk = m_select->selectedDocument();
326 name = lnk.file(); 326 name = lnk.file();
327 }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 327 }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
328 if ( m_shLne ) { 328 if ( m_shLne ) {
329 name = m_currentDir + "/" +m_edit->text(); 329 name = m_currentDir + "/" +m_edit->text();
330 }else{ 330 }else{
331 QListViewItem *item = m_View->currentItem(); 331 QListViewItem *item = m_View->currentItem();
332 if( item != 0 ) 332 if( item != 0 )
333 name = m_currentDir + "/" + item->text( 1 ); 333 name = m_currentDir + "/" + item->text( 1 );
334 } 334 }
335 }else { // installed view 335 }else { // installed view
336 ; 336 ;
337 } 337 }
338 return name; 338 return name;
339} 339}
340QStringList OFileSelector::selectedNames()const 340QStringList OFileSelector::selectedNames()const
341{ 341{
342 QStringList list; 342 QStringList list;
343 if( m_selector == NORMAL ){ 343 if( m_selector == NORMAL ){
344 list << selectedName(); 344 list << selectedName();
345 }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { 345 }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
346 list << selectedName(); // FIXME implement multiple Selections 346 list << selectedName(); // FIXME implement multiple Selections
347 } 347 }
348 return list; 348 return list;
349} 349}
350/** If mode is set to the Dir selection this will return the selected path. 350/** If mode is set to the Dir selection this will return the selected path.
351 * 351 *
352 * 352 *
353 */ 353 */
354QString OFileSelector::selectedPath()const 354QString OFileSelector::selectedPath()const
355{ 355{
356 QString path; 356 QString path;
357 if( m_selector == NORMAL ){ 357 if( m_selector == NORMAL ){
358 path = QPEApplication::documentDir(); 358 path = QPEApplication::documentDir();
359 }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 359 }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
360 ; 360 ;
361 } 361 }
362 return path; 362 return path;
363} 363}
364QStringList OFileSelector::selectedPaths() const 364QStringList OFileSelector::selectedPaths() const
365{ 365{
366 QStringList list; 366 QStringList list;
367 list << selectedPath(); 367 list << selectedPath();
368 return list; 368 return list;
369} 369}
370QString OFileSelector::directory()const 370QString OFileSelector::directory()const
371{ 371{
372 if( m_selector == NORMAL ) 372 if( m_selector == NORMAL )
373 return QPEApplication::documentDir(); 373 return QPEApplication::documentDir();
374 374
375 return QDir(m_currentDir).absPath(); 375 return QDir(m_currentDir).absPath();
376} 376}
377 377
378int OFileSelector::fileCount() 378int OFileSelector::fileCount() const
379{ 379{
380 int count; 380 int count;
381 switch( m_selector ){ 381 switch( m_selector ){
382 case NORMAL: 382 case NORMAL:
383 count = m_select->fileCount(); 383 count = m_select->fileCount();
384 break; 384 break;
385 //case CUSTOM: 385 //case CUSTOM:
386 case EXTENDED: 386 case EXTENDED:
387 case EXTENDED_ALL: 387 case EXTENDED_ALL:
388 default: 388 default:
389 count = m_View->childCount(); 389 count = m_View->childCount();
390 break; 390 break;
391 } 391 }
392 return count; 392 return count;
393} 393}
394DocLnk OFileSelector::selectedDocument() const 394DocLnk OFileSelector::selectedDocument() const
395{ 395{
396 DocLnk lnk; 396 DocLnk lnk;
397 switch( m_selector ){ 397 switch( m_selector ){
398 case NORMAL:{ 398 case NORMAL:{
399 lnk = m_select->selectedDocument(); 399 lnk = m_select->selectedDocument();
400 break; 400 break;
401 } 401 }
402 case EXTENDED: 402 case EXTENDED:
403 case EXTENDED_ALL: 403 case EXTENDED_ALL:
404 default: 404 default:
405 lnk = DocLnk( selectedName() ); // new DocLnk 405 lnk = DocLnk( selectedName() ); // new DocLnk
406 break; 406 break;
407 } 407 }
408 return lnk; 408 return lnk;
409} 409}
410QValueList<DocLnk> OFileSelector::selectedDocuments() const 410QValueList<DocLnk> OFileSelector::selectedDocuments() const
411{ 411{
412 QValueList<DocLnk> docs; 412 QValueList<DocLnk> docs;
413 docs.append( selectedDocument() ); 413 docs.append( selectedDocument() );
414 return docs; 414 return docs;
415} 415}
416 416
417 417
418// slots internal 418// slots internal
419 419
420void OFileSelector::slotOk() 420void OFileSelector::slotOk()
421{ 421{
422 emit ok(); 422 emit ok();
423} 423}
424void OFileSelector::slotCancel() 424void OFileSelector::slotCancel()
425{ 425{
426 emit cancel(); 426 emit cancel();
427} 427}
428void OFileSelector::slotViewCheck(const QString &sel) 428void OFileSelector::slotViewCheck(const QString &sel)
429{ 429{
430 if( sel == tr("Documents" ) ){ 430 if( sel == tr("Documents" ) ){
431 if( m_select == 0 ){ 431 if( m_select == 0 ){
432 // autMime? fix cause now we use All and not the current 432 // autMime? fix cause now we use All and not the current
433 // yes currentMime fixes that for us 433 // yes currentMime fixes that for us
434 QString mime = currentMimeType(); 434 QString mime = currentMimeType();
435 m_select = new FileSelector(mime, 435 m_select = new FileSelector(mime,
436 m_stack, "fileselector", 436 m_stack, "fileselector",
437 m_shNew, m_shClose); 437 m_shNew, m_shClose);
438 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 438 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
439 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 439 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
440 connect(m_select, SIGNAL(closeMe() ), 440 connect(m_select, SIGNAL(closeMe() ),
441 this, SIGNAL(closeMe() ) ); 441 this, SIGNAL(closeMe() ) );
442 //connect to close me and other signals as well 442 //connect to close me and other signals as well
443 443
444 m_stack->addWidget( m_select, NORMAL ); 444 m_stack->addWidget( m_select, NORMAL );
445 } 445 }
446 m_stack->raiseWidget( NORMAL ); 446 m_stack->raiseWidget( NORMAL );
447 m_selector = NORMAL; 447 m_selector = NORMAL;
448 }else if( sel == tr("Files") ){ 448 }else if( sel == tr("Files") ){
449 m_selector = EXTENDED; 449 m_selector = EXTENDED;
450 initializeListView(); 450 initializeListView();
451 reparse(); 451 reparse();
452 m_stack->raiseWidget( EXTENDED ); 452 m_stack->raiseWidget( EXTENDED );
453 }else if( sel == tr("All Files") ){ 453 }else if( sel == tr("All Files") ){
454 m_selector = EXTENDED_ALL; 454 m_selector = EXTENDED_ALL;
455 initializeListView(); 455 initializeListView();
456 reparse(); 456 reparse();
457 m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter 457 m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter
458 } 458 }
459} 459}
460// not yet finished..... 460// not yet finished.....
461QString OFileSelector::currentMimeType() const{ 461QString OFileSelector::currentMimeType() const{
462 QString mime; 462 QString mime;
463 QString currentText; 463 QString currentText;
464 if (m_shChooser ) 464 if (m_shChooser )
465 currentText = m_mimeCheck->currentText(); 465 currentText = m_mimeCheck->currentText();
466 466
467 if (tr("All") == currentText ) return QString::null; 467 if (tr("All") == currentText ) return QString::null;
468 else if (currentText.isEmpty() ) { 468 else if (currentText.isEmpty() ) {
469 ; 469 ;
470 }else { 470 }else {
471 QMap<QString, QStringList>::ConstIterator it; 471 QMap<QString, QStringList>::ConstIterator it;
472 it = m_mimetypes.find( currentText ); 472 it = m_mimetypes.find( currentText );
473 if ( it == m_mimetypes.end() ) { 473 if ( it == m_mimetypes.end() ) {
474 mime = it.data().join(";"); 474 mime = it.data().join(";");
475 }else{ 475 }else{
476 mime = currentText; 476 mime = currentText;
477 } 477 }
478 } 478 }
479 return mime; 479 return mime;
480} 480}
481void OFileSelector::slotMimeCheck(const QString &mime) 481void OFileSelector::slotMimeCheck(const QString &mime)
482{ 482{
483 if( m_selector == NORMAL ){ 483 if( m_selector == NORMAL ){
484 //if( m_autoMime ){ 484 //if( m_autoMime ){
485 QString newMimeType; 485 QString newMimeType;
486 if (mime != tr("All") ) { 486 if (mime != tr("All") ) {
487 QMap<QString, QStringList>::Iterator it; 487 QMap<QString, QStringList>::Iterator it;
488 it = m_mimetypes.find(mime); 488 it = m_mimetypes.find(mime);
489 if ( it != m_mimetypes.end() ) { 489 if ( it != m_mimetypes.end() ) {
490 newMimeType = it.data().join(";"); 490 newMimeType = it.data().join(";");
491 }else{ 491 }else{
492 newMimeType = mime; 492 newMimeType = mime;
493 } 493 }
494 } 494 }
495 delete m_select; 495 delete m_select;
496 m_select = new FileSelector( newMimeType, 496 m_select = new FileSelector( newMimeType,
497 m_stack, "fileselector", 497 m_stack, "fileselector",
498 m_shNew, m_shClose); 498 m_shNew, m_shClose);
499 499
500 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 500 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
501 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 501 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
502 connect(m_select, SIGNAL(closeMe() ), 502 connect(m_select, SIGNAL(closeMe() ),
503 this, SIGNAL(closeMe() ) ); 503 this, SIGNAL(closeMe() ) );
504 //connect to close me and other signals as well 504 //connect to close me and other signals as well
505 m_stack->addWidget( m_select, NORMAL ); 505 m_stack->addWidget( m_select, NORMAL );
506 m_stack->raiseWidget( NORMAL ); 506 m_stack->raiseWidget( NORMAL );
@@ -557,289 +557,289 @@ void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count
557 * don't try to change dir to a file 557 * don't try to change dir to a file
558 */ 558 */
559void OFileSelector::locationComboChanged() 559void OFileSelector::locationComboChanged()
560{ 560{
561 QFileInfo info( m_location->lineEdit()->text() ); 561 QFileInfo info( m_location->lineEdit()->text() );
562 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); 562 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() );
563 if (info.isFile() ) 563 if (info.isFile() )
564 cd(info.dirPath(TRUE) ); //absolute path 564 cd(info.dirPath(TRUE) ); //absolute path
565 else 565 else
566 cd( m_location->lineEdit()->text() ); 566 cd( m_location->lineEdit()->text() );
567 567
568 reparse(); 568 reparse();
569} 569}
570void OFileSelector::init() 570void OFileSelector::init()
571{ 571{
572 m_lay = new QVBoxLayout( this ); 572 m_lay = new QVBoxLayout( this );
573 m_lay->setSpacing(0 ); 573 m_lay->setSpacing(0 );
574 574
575 m_stack = new QWidgetStack( this ); 575 m_stack = new QWidgetStack( this );
576 if( m_selector == NORMAL ){ 576 if( m_selector == NORMAL ){
577 QString mime; 577 QString mime;
578 if (!m_autoMime) { 578 if (!m_autoMime) {
579 if (!m_mimetypes.isEmpty() ) { 579 if (!m_mimetypes.isEmpty() ) {
580 QMap<QString, QStringList>::Iterator it; 580 QMap<QString, QStringList>::Iterator it;
581 it = m_mimetypes.begin(); // cause we're in the init 581 it = m_mimetypes.begin(); // cause we're in the init
582 mime = it.data().join(";"); 582 mime = it.data().join(";");
583 } 583 }
584 } 584 }
585 m_select = new FileSelector(mime, 585 m_select = new FileSelector(mime,
586 m_stack, "fileselector", 586 m_stack, "fileselector",
587 m_shNew, m_shClose); 587 m_shNew, m_shClose);
588 588
589 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 589 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
590 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 590 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
591 connect(m_select, SIGNAL(closeMe() ), 591 connect(m_select, SIGNAL(closeMe() ),
592 this, SIGNAL( closeMe() ) ); 592 this, SIGNAL( closeMe() ) );
593 //connect to close me and other signals as well 593 //connect to close me and other signals as well
594 594
595 m_stack->addWidget( m_select, NORMAL ); 595 m_stack->addWidget( m_select, NORMAL );
596 m_stack->raiseWidget( NORMAL ); 596 m_stack->raiseWidget( NORMAL );
597 }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL 597 }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL
598 // and initializeListview will take care of those 598 // and initializeListview will take care of those
599 // toolbar get's generade in initializeListView 599 // toolbar get's generade in initializeListView
600 initializeListView( ); // will raise the widget as well 600 initializeListView( ); // will raise the widget as well
601 m_stack->raiseWidget( EXTENDED ); 601 m_stack->raiseWidget( EXTENDED );
602 } 602 }
603 m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch 603 m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch
604 604
605 if( m_shLne ) // the LineEdit with the current FileName 605 if( m_shLne ) // the LineEdit with the current FileName
606 initializeName(); 606 initializeName();
607 607
608 if( m_shPerm ) // the Permission QCheckBox 608 if( m_shPerm ) // the Permission QCheckBox
609 initializePerm(); 609 initializePerm();
610 610
611 if( m_shChooser ) // the Chooser for the view and Mimetypes 611 if( m_shChooser ) // the Chooser for the view and Mimetypes
612 initializeChooser(); 612 initializeChooser();
613 613
614 if( m_shYesNo ) // the Yes No button row 614 if( m_shYesNo ) // the Yes No button row
615 initializeYes( ); 615 initializeYes( );
616 616
617 if (m_selector != NORMAL ) 617 if (m_selector != NORMAL )
618 reparse(); 618 reparse();
619} 619}
620void OFileSelector::updateMimes() 620void OFileSelector::updateMimes()
621{ 621{
622 if( m_autoMime ){ 622 if( m_autoMime ){
623 m_mimetypes.clear(); 623 m_mimetypes.clear();
624 m_mimetypes.insert( tr("All"), QString::null ); 624 m_mimetypes.insert( tr("All"), QString::null );
625 if( m_selector == NORMAL ){ 625 if( m_selector == NORMAL ){
626 DocLnkSet set; 626 DocLnkSet set;
627 Global::findDocuments(&set, QString::null ); 627 Global::findDocuments(&set, QString::null );
628 QListIterator<DocLnk> dit( set.children() ); 628 QListIterator<DocLnk> dit( set.children() );
629 for( ; dit.current(); ++dit ){ 629 for( ; dit.current(); ++dit ){
630 if( !m_mimetypes.contains( (*dit)->type() ) ) 630 if( !m_mimetypes.contains( (*dit)->type() ) )
631 m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); 631 m_mimetypes.insert( (*dit)->type(), (*dit)->type() );
632 } 632 }
633 }// else done in reparse 633 }// else done in reparse
634 } 634 }
635} 635}
636void OFileSelector::initVars() 636void OFileSelector::initVars()
637{ 637{
638 if( m_mimetypes.isEmpty() ) 638 if( m_mimetypes.isEmpty() )
639 m_autoMime = true; 639 m_autoMime = true;
640 else 640 else
641 m_autoMime = false; 641 m_autoMime = false;
642 m_shClose = false; 642 m_shClose = false;
643 m_shNew = false; 643 m_shNew = false;
644 m_shTool = true; 644 m_shTool = true;
645 m_shPerm = false; 645 m_shPerm = false;
646 m_shLne = true; 646 m_shLne = true;
647 m_shChooser = true; 647 m_shChooser = true;
648 m_shYesNo = true; 648 m_shYesNo = true;
649 m_case = false; 649 m_case = false;
650 m_dir = true; 650 m_dir = true;
651 m_files = true; 651 m_files = true;
652 m_showPopup = false; 652 m_showPopup = false;
653 if(m_pixmaps == 0 ) // init the pixmaps 653 if(m_pixmaps == 0 ) // init the pixmaps
654 initPics(); 654 initPics();
655 655
656 // pointers 656 // pointers
657 m_location = 0; 657 m_location = 0;
658 m_mimeCheck = 0; 658 m_mimeCheck = 0;
659 m_viewCheck = 0; 659 m_viewCheck = 0;
660 m_homeButton = 0; 660 m_homeButton = 0;
661 m_docButton = 0; 661 m_docButton = 0;
662 m_hideButton = 0; 662 m_hideButton = 0;
663 m_ok = 0; 663 m_ok = 0;
664 m_cancel = 0; 664 m_cancel = 0;
665 m_reread = 0; 665 m_reread = 0;
666 m_up = 0; 666 m_up = 0;
667 m_View = 0; 667 m_View = 0;
668 m_checkPerm = 0; 668 m_checkPerm = 0;
669 m_pseudo = 0; 669 m_pseudo = 0;
670 m_pseudoLayout = 0; 670 m_pseudoLayout = 0;
671 m_select = 0; 671 m_select = 0;
672 m_stack = 0; 672 m_stack = 0;
673 m_lay = 0; 673 m_lay = 0;
674 m_Oselector = 0; 674 m_Oselector = 0;
675 m_boxToolbar = 0; 675 m_boxToolbar = 0;
676 m_boxOk = 0; 676 m_boxOk = 0;
677 m_boxName = 0; 677 m_boxName = 0;
678 m_boxView = 0; 678 m_boxView = 0;
679 m_custom = 0; 679 m_custom = 0;
680 m_edit = 0; 680 m_edit = 0;
681 m_fnLabel = 0; 681 m_fnLabel = 0;
682 m_new = 0; 682 m_new = 0;
683 m_close = 0; 683 m_close = 0;
684} 684}
685void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink) 685void OFileSelector::addFile(const QString &/*mime*/, QFileInfo *info, bool symlink)
686{ 686{
687 if(!m_files) 687 if(!m_files)
688 return; 688 return;
689 // if( !compliesMime(info->absFilePath(), mime ) ) 689 // if( !compliesMime(info->absFilePath(), mime ) )
690 // return; 690 // return;
691 MimeType type( info->absFilePath() ); 691 MimeType type( info->absFilePath() );
692 if (!compliesMime( type.id() ) ) 692 if (!compliesMime( type.id() ) )
693 return; 693 return;
694 694
695 QPixmap pix = type.pixmap(); 695 QPixmap pix = type.pixmap();
696 QString dir; 696 QString dir;
697 QString name; 697 QString name;
698 bool locked; 698 bool locked;
699 if( pix.isNull() ) 699 if( pix.isNull() )
700 pix = Resource::loadPixmap( "UnknownDocument-14"); 700 pix = Resource::loadPixmap( "UnknownDocument-14");
701 dir = info->dirPath( true ); 701 dir = info->dirPath( true );
702 if( symlink ) 702 if( symlink )
703 name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); 703 name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink();
704 else { 704 else {
705 name = info->fileName(); 705 name = info->fileName();
706 if( ( m_mode == OPEN && !info->isReadable() )|| 706 if( ( m_mode == OPEN && !info->isReadable() )||
707 ( m_mode == SAVE && !info->isWritable() ) ){ 707 ( m_mode == SAVE && !info->isWritable() ) ){
708 708
709 locked = true; pix = Resource::loadPixmap("locked"); 709 locked = true; pix = Resource::loadPixmap("locked");
710 } 710 }
711 } 711 }
712 new OFileSelectorItem( m_View, pix, name, 712 new OFileSelectorItem( m_View, pix, name,
713 info->lastModified().toString(), 713 info->lastModified().toString(),
714 QString::number( info->size() ), 714 QString::number( info->size() ),
715 dir, locked ); 715 dir, locked );
716} 716}
717void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) 717void OFileSelector::addDir(const QString &/*mime*/, QFileInfo *info, bool symlink )
718{ 718{
719 if(!m_dir) 719 if(!m_dir)
720 return; 720 return;
721 if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ 721 if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){
722 bool locked = false; 722 bool locked = false;
723 QString name; 723 QString name;
724 QPixmap pix; 724 QPixmap pix;
725 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ 725 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){
726 locked = true; 726 locked = true;
727 if( symlink ) 727 if( symlink )
728 pix = (*m_pixmaps)["symlinkedlocked"]; 728 pix = (*m_pixmaps)["symlinkedlocked"];
729 else 729 else
730 pix = Resource::loadPixmap("lockedfolder"); 730 pix = Resource::loadPixmap("lockedfolder");
731 }else { // readable 731 }else { // readable
732 pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; 732 pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ;
733 } 733 }
734 name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; 734 name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ;
735 new OFileSelectorItem( m_View, pix, name, 735 new OFileSelectorItem( m_View, pix, name,
736 info->lastModified().toString(), 736 info->lastModified().toString(),
737 QString::number( info->size() ), 737 QString::number( info->size() ),
738 info->dirPath( true ), locked, 738 info->dirPath( true ), locked,
739 true ); 739 true );
740 740
741 }// else CUSTOM View 741 }// else CUSTOM View
742} 742}
743void OFileSelector::delItems() 743void OFileSelector::delItems()
744{ 744{
745 745
746} 746}
747void OFileSelector::initializeName() 747void OFileSelector::initializeName()
748{ 748{
749 /** Name Layout Line 749 /** Name Layout Line
750 * This is the Layout line arranged in 750 * This is the Layout line arranged in
751 * horizontal way each components 751 * horizontal way each components
752 * are next to each other 752 * are next to each other
753 * but we will only do this if 753 * but we will only do this if
754 * we didn't initialize a while ago. 754 * we didn't initialize a while ago.
755 */ 755 */
756 if( m_boxName == 0 ){ 756 if( m_boxName == 0 ){
757 m_boxName = new QHBox( this ); // remove this this? or use a QHBox 757 m_boxName = new QHBox( this ); // remove this this? or use a QHBox
758 m_fnLabel = new QLabel( m_boxName ); 758 m_fnLabel = new QLabel( m_boxName );
759 m_fnLabel->setText( tr("Name:") ); 759 m_fnLabel->setText( tr("Name:") );
760 m_edit = new QLineEdit( m_boxName ); 760 m_edit = new QLineEdit( m_boxName );
761 m_edit->setText( m_name ); 761 m_edit->setText( m_name );
762 //m_boxName->addWidget( m_fnLabel ); 762 //m_boxName->addWidget( m_fnLabel );
763 m_boxName->setMargin( 5 ); 763 m_boxName->setMargin( 5 );
764 m_boxName->setSpacing( 8 ); 764 m_boxName->setSpacing( 8 );
765 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor 765 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor
766 766
767 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout 767 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout
768 }// else we already initialized 768 }// else we already initialized
769 // maybe show the components? 769 // maybe show the components?
770 // 770 //
771} 771}
772void OFileSelector::initializeYes() 772void OFileSelector::initializeYes()
773{ 773{
774 /** The Save Cancel bar 774 /** The Save Cancel bar
775 * 775 *
776 */ 776 */
777 if( m_boxOk == 0 ){ 777 if( m_boxOk == 0 ){
778 m_boxOk = new QHBox( this ); 778 m_boxOk = new QHBox( this );
779 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); 779 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" );
780 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); 780 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" );
781 781
782 //m_boxOk->addWidget( m_ok ); 782 //m_boxOk->addWidget( m_ok );
783 //m_boxOk->addWidget( m_cancel ); 783 //m_boxOk->addWidget( m_cancel );
784 m_boxOk->setMargin( 5 ); 784 m_boxOk->setMargin( 5 );
785 m_boxOk->setSpacing( 10 ); 785 m_boxOk->setSpacing( 10 );
786 m_lay->addWidget( m_boxOk, 0 ); 786 m_lay->addWidget( m_boxOk, 0 );
787 787
788 connect( m_ok, SIGNAL( clicked() ), 788 connect( m_ok, SIGNAL( clicked() ),
789 this, SLOT(slotOk() ) ); 789 this, SLOT(slotOk() ) );
790 connect( m_cancel, SIGNAL( clicked() ), 790 connect( m_cancel, SIGNAL( clicked() ),
791 this, SLOT( slotCancel() ) ); 791 this, SLOT( slotCancel() ) );
792 } 792 }
793} 793}
794/* 794/*
795 * OK m_mimeCheck is a QComboBox we now want to fill 795 * OK m_mimeCheck is a QComboBox we now want to fill
796 * out that combobox 796 * out that combobox
797 * if automime we need to update the mimetypes 797 * if automime we need to update the mimetypes
798 */ 798 */
799void OFileSelector::updateMimeCheck() { 799void OFileSelector::updateMimeCheck() {
800 m_mimeCheck->clear(); 800 m_mimeCheck->clear();
801 if (m_autoMime ) { 801 if (m_autoMime ) {
802 //m_mimeCheck->insertItem( tr("All") ); 802 //m_mimeCheck->insertItem( tr("All") );
803 updateMimes(); 803 updateMimes();
804 } 804 }
805 805
806 QMap<QString, QStringList>::Iterator it; 806 QMap<QString, QStringList>::Iterator it;
807 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { 807 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) {
808 m_mimeCheck->insertItem( it.key() ); 808 m_mimeCheck->insertItem( it.key() );
809 } 809 }
810} 810}
811 811
812void OFileSelector::initializeChooser() 812void OFileSelector::initializeChooser()
813{ 813{
814 if( m_boxView == 0 ){ 814 if( m_boxView == 0 ){
815 m_boxView = new QHBox( this ); 815 m_boxView = new QHBox( this );
816 m_viewCheck = new QComboBox( m_boxView, "view check"); 816 m_viewCheck = new QComboBox( m_boxView, "view check");
817 m_mimeCheck = new QComboBox( m_boxView, "mime check"); 817 m_mimeCheck = new QComboBox( m_boxView, "mime check");
818 m_boxView->setSpacing( 8 ); 818 m_boxView->setSpacing( 8 );
819 m_lay->addWidget(m_boxView, 0 ); 819 m_lay->addWidget(m_boxView, 0 );
820 820
821 m_viewCheck->insertItem( tr("Documents") ); 821 m_viewCheck->insertItem( tr("Documents") );
822 m_viewCheck->insertItem( tr("Files") ); 822 m_viewCheck->insertItem( tr("Files") );
823 m_viewCheck->insertItem( tr("All Files") ); 823 m_viewCheck->insertItem( tr("All Files") );
824 updateMimeCheck(); 824 updateMimeCheck();
825 825
826 connect( m_viewCheck, SIGNAL( activated(const QString & ) ), 826 connect( m_viewCheck, SIGNAL( activated(const QString & ) ),
827 this, SLOT( slotViewCheck(const QString & ) ) ); 827 this, SLOT( slotViewCheck(const QString & ) ) );
828 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), 828 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ),
829 this, SLOT( slotMimeCheck( const QString & ) ) ); 829 this, SLOT( slotMimeCheck( const QString & ) ) );
830 } 830 }
831} 831}
832void OFileSelector::initializeListView() 832void OFileSelector::initializeListView()
833{ 833{
834 qWarning("initializeListView"); 834 qWarning("initializeListView");
835 if( m_pseudo == 0 ){ 835 if( m_pseudo == 0 ){
836 qWarning("init"); 836 qWarning("init");
837 m_pseudo = new QWidget( m_stack, "Pseudo Widget"); 837 m_pseudo = new QWidget( m_stack, "Pseudo Widget");
838 m_pseudoLayout = new QVBoxLayout( m_pseudo ); 838 m_pseudoLayout = new QVBoxLayout( m_pseudo );
839 // toolbar 839 // toolbar
840 m_boxToolbar = new QHBox( m_pseudo ); 840 m_boxToolbar = new QHBox( m_pseudo );
841 m_boxToolbar->setSpacing(0 ); // next to each other please 841 m_boxToolbar->setSpacing(0 ); // next to each other please
842 842
843 // toolbar members 843 // toolbar members
844 { 844 {
845 // location QComboBox 845 // location QComboBox
@@ -893,344 +893,343 @@ void OFileSelector::initializeListView()
893 m_location->setCurrentItem( count ); 893 m_location->setCurrentItem( count );
894 // due to the New and Close button we can not simply hide m_boxToolBar to not show it 894 // due to the New and Close button we can not simply hide m_boxToolBar to not show it
895 if( !m_shTool ){ 895 if( !m_shTool ){
896 m_location->hide( ); 896 m_location->hide( );
897 m_up->hide( ); 897 m_up->hide( );
898 m_homeButton->hide( ); 898 m_homeButton->hide( );
899 m_docButton->hide( ); 899 m_docButton->hide( );
900 } 900 }
901 if(!m_shClose ) 901 if(!m_shClose )
902 m_close->hide(); 902 m_close->hide();
903 //if(!m_shNew) 903 //if(!m_shNew)
904 //m_close->hide(); 904 //m_close->hide();
905 905
906 } // off toolbar 906 } // off toolbar
907 // the Main ListView 907 // the Main ListView
908 // make a QWidgetStack first so Views can share the Toolbar 908 // make a QWidgetStack first so Views can share the Toolbar
909 m_View = new QListView( m_pseudo, "Extended view"); 909 m_View = new QListView( m_pseudo, "Extended view");
910 QPEApplication::setStylusOperation( m_View->viewport(), 910 QPEApplication::setStylusOperation( m_View->viewport(),
911 QPEApplication::RightOnHold); 911 QPEApplication::RightOnHold);
912 m_View->addColumn(" " ); 912 m_View->addColumn(" " );
913 m_View->addColumn(tr("Name"), 135 ); 913 m_View->addColumn(tr("Name"), 135 );
914 m_View->addColumn(tr("Size"), -1 ); 914 m_View->addColumn(tr("Size"), -1 );
915 m_View->addColumn(tr("Date"), 60 ); 915 m_View->addColumn(tr("Date"), 60 );
916 m_View->addColumn(tr("Mime Type"), -1 ); 916 m_View->addColumn(tr("Mime Type"), -1 );
917 QHeader *header = m_View->header(); 917 QHeader *header = m_View->header();
918 header->hide(); 918 header->hide();
919 m_View->setSorting( 1 ); 919 m_View->setSorting( 1 );
920 m_View->setAllColumnsShowFocus( TRUE ); 920 m_View->setAllColumnsShowFocus( TRUE );
921 921
922 connect(m_View, SIGNAL(selectionChanged() ), 922 connect(m_View, SIGNAL(selectionChanged() ),
923 this, SLOT(slotSelectionChanged() ) ); 923 this, SLOT(slotSelectionChanged() ) );
924 924
925 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), 925 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ),
926 this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); 926 this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
927 927
928 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), 928 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
929 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); 929 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
930 930
931 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), 931 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
932 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); 932 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
933 933
934 m_pseudoLayout->addWidget( m_View, 288 ); 934 m_pseudoLayout->addWidget( m_View, 288 );
935 m_stack->addWidget( m_pseudo, EXTENDED ); 935 m_stack->addWidget( m_pseudo, EXTENDED );
936 } 936 }
937} 937}
938void OFileSelector::initializePerm() 938void OFileSelector::initializePerm()
939{ 939{
940 if( m_checkPerm == 0 ){ 940 if( m_checkPerm == 0 ){
941 m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); 941 m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm");
942 m_checkPerm->setChecked( false ); 942 m_checkPerm->setChecked( false );
943 m_lay->addWidget( m_checkPerm ); 943 m_lay->addWidget( m_checkPerm );
944 944
945 } 945 }
946} 946}
947void OFileSelector::initPics() 947void OFileSelector::initPics()
948{ 948{
949 m_pixmaps = new QMap<QString,QPixmap>; 949 m_pixmaps = new QMap<QString,QPixmap>;
950 QPixmap pm = Resource::loadPixmap( "folder" ); 950 QPixmap pm = Resource::loadPixmap( "folder" );
951 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 951 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
952 QPainter painter( &pm ); 952 QPainter painter( &pm );
953 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 953 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
954 pm.setMask( pm.createHeuristicMask( FALSE ) ); 954 pm.setMask( pm.createHeuristicMask( FALSE ) );
955 m_pixmaps->insert("dirsymlink", pm ); 955 m_pixmaps->insert("dirsymlink", pm );
956 956
957 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); 957 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
958 QPainter pen(&pm2 ); 958 QPainter pen(&pm2 );
959 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); 959 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
960 pm2.setMask( pm2.createHeuristicMask( FALSE ) ); 960 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
961 m_pixmaps->insert("symlinkedlocked", pm2 ); 961 m_pixmaps->insert("symlinkedlocked", pm2 );
962} 962}
963// if a mime complies with the m_mimeCheck->currentItem 963// if a mime complies with the m_mimeCheck->currentItem
964bool OFileSelector::compliesMime( const QString &path, const QString &mime ) 964bool OFileSelector::compliesMime( const QString &path, const QString &mime )
965{ 965{
966 if( mime == "All" ) 966 if( mime == "All" )
967 return true; 967 return true;
968 MimeType type( path ); 968 MimeType type( path );
969 if( type.id() == mime ) 969 if( type.id() == mime )
970 return true; 970 return true;
971 return false; 971 return false;
972} 972}
973/* check if the mimetype in mime 973/* check if the mimetype in mime
974 * complies with the one which is current 974 * complies with the one which is current
975 */ 975 */
976/* 976/*
977 * We've the mimetype of the file 977 * We've the mimetype of the file
978 * We need to get the stringlist of the current mimetype 978 * We need to get the stringlist of the current mimetype
979 * 979 *
980 * mime = image/jpeg 980 * mime = image/jpeg
981 * QStringList = 'image/*' 981 * QStringList = 'image/*'
982 * or QStringList = image/jpeg;image/png;application/x-ogg 982 * or QStringList = image/jpeg;image/png;application/x-ogg
983 * or QStringList = application/x-ogg;image/*; 983 * or QStringList = application/x-ogg;image/*;
984 * with all these mime filters it should get acceptes 984 * with all these mime filters it should get acceptes
985 * to do so we need to look if mime is contained inside 985 * to do so we need to look if mime is contained inside
986 * the stringlist 986 * the stringlist
987 * if it's contained return true 987 * if it's contained return true
988 * if not ( I'm no RegExp expert at all ) we'll look if a '/*' 988 * if not ( I'm no RegExp expert at all ) we'll look if a '/*'
989 * is contained in the mimefilter and then we will 989 * is contained in the mimefilter and then we will
990 * look if both are equal until the '/' 990 * look if both are equal until the '/'
991 */ 991 */
992bool OFileSelector::compliesMime( const QString& mime ) { 992bool OFileSelector::compliesMime( const QString& mime ) {
993 qWarning("mimetype is %s", mime.latin1() ); 993 qWarning("mimetype is %s", mime.latin1() );
994 QString currentText; 994 QString currentText;
995 if (m_shChooser ) 995 if (m_shChooser )
996 currentText = m_mimeCheck->currentText(); 996 currentText = m_mimeCheck->currentText();
997 997
998 qWarning("current text is %s", currentText.latin1() ); 998 qWarning("current text is %s", currentText.latin1() );
999 QMap<QString, QStringList>::Iterator it; 999 QMap<QString, QStringList>::Iterator it;
1000 QStringList list; 1000 QStringList list;
1001 if ( currentText == tr("All") ) return true; 1001 if ( currentText == tr("All") ) return true;
1002 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { 1002 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) {
1003 it = m_mimetypes.begin(); 1003 it = m_mimetypes.begin();
1004 list = it.data(); 1004 list = it.data();
1005 }else if ( currentText.isEmpty() ) return true; 1005 }else if ( currentText.isEmpty() ) return true;
1006 else{ 1006 else{
1007 it = m_mimetypes.find(currentText ); 1007 it = m_mimetypes.find(currentText );
1008 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; 1008 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText;
1009 else qWarning("found"), list = it.data(); 1009 else qWarning("found"), list = it.data();
1010 } 1010 }
1011 // dump it now 1011 // dump it now
1012 //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 1012 //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
1013 // qWarning( "%s", (*it).latin1() ); 1013 // qWarning( "%s", (*it).latin1() );
1014 //} 1014 //}
1015 1015
1016 1016
1017 if ( list.contains(mime) ) return true; 1017 if ( list.contains(mime) ) return true;
1018 qWarning("list doesn't contain it "); 1018 qWarning("list doesn't contain it ");
1019 QStringList::Iterator it2; 1019 QStringList::Iterator it2;
1020 int pos; 1020 int pos;
1021 int pos2;
1022 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { 1021 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) {
1023 pos = (*it2).findRev("/*"); 1022 pos = (*it2).findRev("/*");
1024 if ( pos >= 0 ) { 1023 if ( pos >= 0 ) {
1025 if ( mime.contains( (*it2).left(pos) ) ) return true; 1024 if ( mime.contains( (*it2).left(pos) ) ) return true;
1026 } 1025 }
1027 } 1026 }
1028 return false; 1027 return false;
1029} 1028}
1030void OFileSelector::slotFileSelected( const QString &string ) 1029void OFileSelector::slotFileSelected( const QString &string )
1031{ 1030{
1032 if( m_shLne ) 1031 if( m_shLne )
1033 m_edit->setText( string ); 1032 m_edit->setText( string );
1034 emit fileSelected( string ); 1033 emit fileSelected( string );
1035} 1034}
1036void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 1035void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
1037{ 1036{
1038 slotFileSelected( lnk.name() ); 1037 slotFileSelected( lnk.name() );
1039 emit fileSelected( lnk ); 1038 emit fileSelected( lnk );
1040} 1039}
1041void OFileSelector::slotSelectionChanged() 1040void OFileSelector::slotSelectionChanged()
1042{ 1041{
1043 1042
1044} 1043}
1045void OFileSelector::slotCurrentChanged(QListViewItem* item ) 1044void OFileSelector::slotCurrentChanged(QListViewItem* item )
1046{ 1045{
1047 if( item == 0 ) 1046 if( item == 0 )
1048 return; 1047 return;
1049 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { 1048 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
1050 OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) 1049 OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;)
1051 qWarning("current changed"); 1050 qWarning("current changed");
1052 if(!sel->isDir() ){ 1051 if(!sel->isDir() ){
1053 if( m_shLne ) 1052 if( m_shLne )
1054 m_edit->setText( sel->text(1) ); 1053 m_edit->setText( sel->text(1) );
1055 1054
1056 if (m_mode == FILESELECTOR ) { 1055 if (m_mode == FILESELECTOR ) {
1057 QStringList str = QStringList::split("->", sel->text(1) ); 1056 QStringList str = QStringList::split("->", sel->text(1) );
1058 QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); 1057 QString path =sel->directory() + "/" + str[0].stripWhiteSpace();
1059 emit fileSelected(path ); 1058 emit fileSelected(path );
1060 DocLnk lnk( path ); 1059 DocLnk lnk( path );
1061 emit fileSelected(lnk ); 1060 emit fileSelected(lnk );
1062 } 1061 }
1063 } 1062 }
1064 } 1063 }
1065} 1064}
1066void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) 1065void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int)
1067{ 1066{
1068 if ( item == 0 ) 1067 if ( item == 0 )
1069 return; 1068 return;
1070 1069
1071 if( button != Qt::LeftButton ) 1070 if( button != Qt::LeftButton )
1072 return; 1071 return;
1073 1072
1074 switch( m_selector ){ 1073 switch( m_selector ){
1075 default: 1074 default:
1076 break; 1075 break;
1077 case EXTENDED: // fall through 1076 case EXTENDED: // fall through
1078 case EXTENDED_ALL:{ 1077 case EXTENDED_ALL:{
1079 OFileSelectorItem *sel = (OFileSelectorItem*)item; 1078 OFileSelectorItem *sel = (OFileSelectorItem*)item;
1080 if(!sel->isLocked() ){ 1079 if(!sel->isLocked() ){
1081 QStringList str = QStringList::split("->", sel->text(1) ); 1080 QStringList str = QStringList::split("->", sel->text(1) );
1082 if( sel->isDir() ){ 1081 if( sel->isDir() ){
1083 cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); 1082 cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
1084 // if MODE Dir m_shLne set the Text 1083 // if MODE Dir m_shLne set the Text
1085 }else{ 1084 }else{
1086 if( m_shLne ) 1085 if( m_shLne )
1087 m_edit->setText( str[0].stripWhiteSpace() ); 1086 m_edit->setText( str[0].stripWhiteSpace() );
1088 qWarning("selected here in slot clicked"); 1087 qWarning("selected here in slot clicked");
1089 emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); 1088 emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() );
1090 DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); 1089 DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() );
1091 qWarning("file selected"); 1090 qWarning("file selected");
1092 emit fileSelected( lnk ); 1091 emit fileSelected( lnk );
1093 } 1092 }
1094 } 1093 }
1095 break; 1094 break;
1096 } 1095 }
1097 } 1096 }
1098} 1097}
1099void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) 1098void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
1100{ 1099{
1101 if( item == 0 ) 1100 if( item == 0 )
1102 return; 1101 return;
1103 1102
1104 if( button != Qt::RightButton ) 1103 if( button != Qt::RightButton )
1105 return; 1104 return;
1106 slotContextMenu( item ); 1105 slotContextMenu( item );
1107} 1106}
1108void OFileSelector::slotContextMenu( QListViewItem *item) 1107void OFileSelector::slotContextMenu( QListViewItem * /*item*/)
1109{ 1108{
1110 1109
1111} 1110}
1112void OFileSelector::slotChangedDir() 1111void OFileSelector::slotChangedDir()
1113{ 1112{
1114 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1113 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1115 if(sel->isDir() ){ 1114 if(sel->isDir() ){
1116 QStringList str = QStringList::split("->", sel->text(1) ); 1115 QStringList str = QStringList::split("->", sel->text(1) );
1117 cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); 1116 cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
1118 } 1117 }
1119} 1118}
1120void OFileSelector::slotOpen() 1119void OFileSelector::slotOpen()
1121{ 1120{
1122 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1121 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1123 if(!sel->isDir() ){ 1122 if(!sel->isDir() ){
1124 QStringList str = QStringList::split("->", sel->text(1) ); 1123 QStringList str = QStringList::split("->", sel->text(1) );
1125 slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); 1124 slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() );
1126 qWarning("slot open"); 1125 qWarning("slot open");
1127 // DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); 1126 // DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() );
1128 //emit fileSelected( lnk ); 1127 //emit fileSelected( lnk );
1129 } 1128 }
1130} 1129}
1131void OFileSelector::slotRescan() 1130void OFileSelector::slotRescan()
1132{ 1131{
1133 1132
1134} 1133}
1135void OFileSelector::slotRename() 1134void OFileSelector::slotRename()
1136{ 1135{
1137 reparse(); 1136 reparse();
1138} 1137}
1139void OFileSelector::slotDelete() 1138void OFileSelector::slotDelete()
1140{ 1139{
1141 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1140 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1142 QStringList list = QStringList::split("->", sel->text(1) ); 1141 QStringList list = QStringList::split("->", sel->text(1) );
1143 if( sel->isDir() ){ 1142 if( sel->isDir() ){
1144 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry 1143 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry
1145 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], 1144 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
1146 tr("Yes"),tr("No"),0,1,1) ) { 1145 tr("Yes"),tr("No"),0,1,1) ) {
1147 case 0: 1146 case 0:
1148 ::system(str.utf8().data() ); 1147 ::system(str.utf8().data() );
1149 break; 1148 break;
1150 } 1149 }
1151 } else { 1150 } else {
1152 QFile::remove( list[0] ); 1151 QFile::remove( list[0] );
1153 } 1152 }
1154 m_View->takeItem( sel ); 1153 m_View->takeItem( sel );
1155 delete sel; 1154 delete sel;
1156} 1155}
1157void OFileSelector::cdUP() 1156void OFileSelector::cdUP()
1158{ 1157{
1159 QDir dir( m_currentDir ); 1158 QDir dir( m_currentDir );
1160 dir.cdUp(); 1159 dir.cdUp();
1161 if(dir.exists() ){ 1160 if(dir.exists() ){
1162 m_currentDir = dir.absPath(); 1161 m_currentDir = dir.absPath();
1163 reparse(); 1162 reparse();
1164 int count = m_location->count(); 1163 int count = m_location->count();
1165 slotInsertLocationPath( m_currentDir, count); 1164 slotInsertLocationPath( m_currentDir, count);
1166 m_location->setCurrentItem( indexByString( m_location, m_currentDir)); 1165 m_location->setCurrentItem( indexByString( m_location, m_currentDir));
1167 //this wont work in all instances 1166 //this wont work in all instances
1168 // FIXME 1167 // FIXME
1169 } 1168 }
1170} 1169}
1171void OFileSelector::slotHome() 1170void OFileSelector::slotHome()
1172{ 1171{
1173 cd(QDir::homeDirPath() ); 1172 cd(QDir::homeDirPath() );
1174} 1173}
1175void OFileSelector::slotDoc() 1174void OFileSelector::slotDoc()
1176{ 1175{
1177 cd(QPEApplication::documentDir() ); 1176 cd(QPEApplication::documentDir() );
1178} 1177}
1179void OFileSelector::slotNavigate( ) 1178void OFileSelector::slotNavigate( )
1180{ 1179{
1181 1180
1182} 1181}
1183// fill the View with life 1182// fill the View with life
1184void OFileSelector::reparse() 1183void OFileSelector::reparse()
1185{ 1184{
1186 if( m_selector == NORMAL ) 1185 if( m_selector == NORMAL )
1187 return; 1186 return;
1188 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) 1187 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL )
1189 m_View->clear(); 1188 m_View->clear();
1190 else // custom view 1189 else // custom view
1191 ; // currentView()->clear(); 1190 ; // currentView()->clear();
1192 if( m_shChooser) 1191 if( m_shChooser)
1193 qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); 1192 qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
1194 1193
1195 QString currentMimeType; 1194 QString currentMimeType;
1196 // let's update the mimetype 1195 // let's update the mimetype
1197 if( m_autoMime ){ 1196 if( m_autoMime ){
1198 m_mimetypes.clear(); 1197 m_mimetypes.clear();
1199 // ok we can change mimetype so we need to be able to give a selection 1198 // ok we can change mimetype so we need to be able to give a selection
1200 if( m_shChooser ) { 1199 if( m_shChooser ) {
1201 currentMimeType = m_mimeCheck->currentText(); 1200 currentMimeType = m_mimeCheck->currentText();
1202 m_mimeCheck->clear(); 1201 m_mimeCheck->clear();
1203 1202
1204 // let's find possible mimetypes 1203 // let's find possible mimetypes
1205 QDir dir( m_currentDir ); 1204 QDir dir( m_currentDir );
1206 dir.setFilter( QDir::Files | QDir::Readable ); 1205 dir.setFilter( QDir::Files | QDir::Readable );
1207 dir.setSorting( QDir::Size ); 1206 dir.setSorting( QDir::Size );
1208 const QFileInfoList *list = dir.entryInfoList(); 1207 const QFileInfoList *list = dir.entryInfoList();
1209 QFileInfoListIterator it( *list ); 1208 QFileInfoListIterator it( *list );
1210 QFileInfo *fi; 1209 QFileInfo *fi;
1211 while( (fi=it.current() ) ) { 1210 while( (fi=it.current() ) ) {
1212 if( fi->extension() == QString::fromLatin1("desktop") ){ 1211 if( fi->extension() == QString::fromLatin1("desktop") ){
1213 ++it; 1212 ++it;
1214 continue; 1213 continue;
1215 } 1214 }
1216 MimeType type( fi->absFilePath() ); 1215 MimeType type( fi->absFilePath() );
1217 if( !m_mimetypes.contains( type.id() ) ){ 1216 if( !m_mimetypes.contains( type.id() ) ){
1218 //qWarning("Type %s", type.id().latin1() ); 1217 //qWarning("Type %s", type.id().latin1() );
1219 m_mimetypes.insert( type.id(), type.id() ); 1218 m_mimetypes.insert( type.id(), type.id() );
1220 } 1219 }
1221 1220
1222 ++it; 1221 ++it;
1223 } 1222 }
1224 // add them to the chooser 1223 // add them to the chooser
1225 updateMimeCheck(); 1224 updateMimeCheck();
1226 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); 1225 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
1227 currentMimeType = m_mimeCheck->currentText(); 1226 currentMimeType = m_mimeCheck->currentText();
1228 } 1227 }
1229 }else { // no autoMime 1228 }else { // no autoMime
1230 // let the mimetype be set from out side the m_mimeCheck FEATURE 1229 // let the mimetype be set from out side the m_mimeCheck FEATURE
1231 1230
1232 if( m_shChooser ){ 1231 if( m_shChooser ){
1233 currentMimeType = m_mimeCheck->currentText(); 1232 currentMimeType = m_mimeCheck->currentText();
1234// updateMimeCheck(); 1233// updateMimeCheck();
1235 } 1234 }
1236 } 1235 }
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index f2d5f84..17c494e 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -55,255 +55,255 @@ class DocLnk;
55class QCheckBox; 55class QCheckBox;
56class QComboBox; 56class QComboBox;
57class QPushButton; 57class QPushButton;
58class FileSelector; 58class FileSelector;
59class QGridLayout; 59class QGridLayout;
60class QLineEdit; 60class QLineEdit;
61class QLabel; 61class QLabel;
62class QWidgetStack; 62class QWidgetStack;
63class QHBoxLayout; 63class QHBoxLayout;
64class QVBoxLayout; 64class QVBoxLayout;
65class QPopupMenu; 65class QPopupMenu;
66class QFileInfo; 66class QFileInfo;
67class QHBox; 67class QHBox;
68// 68//
69 69
70typedef QMap< QString, QStringList> MimeTypes; 70typedef QMap< QString, QStringList> MimeTypes;
71 71
72class OFileSelector : public QWidget { 72class OFileSelector : public QWidget {
73 Q_OBJECT 73 Q_OBJECT
74 public: 74 public:
75 /** 75 /**
76 * The mode of the file selector 76 * The mode of the file selector
77 * Either open, save, fileselector or dir browsing mode 77 * Either open, save, fileselector or dir browsing mode
78 * 78 *
79 */ 79 */
80 enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; 80 enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 };
81 81
82 /** 82 /**
83 * Selector. Either NORMAL for the one shipped with 83 * Selector. Either NORMAL for the one shipped with
84 * libqpe or EXTENDED. for the EXTENDED 84 * libqpe or EXTENDED. for the EXTENDED
85 * EXTENDED_ALL also shows 'hidden' files 85 * EXTENDED_ALL also shows 'hidden' files
86 */ 86 */
87 enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 }; 87 enum Selector{NORMAL=0, EXTENDED = 1, EXTENDED_ALL =2 };
88 88
89 /** 89 /**
90 * This is reserved for futrue views 90 * This is reserved for futrue views
91 */ 91 */
92 enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; 92 enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 };
93 93
94 /** 94 /**
95 * A c'tor which should be used for advanced mode 95 * A c'tor which should be used for advanced mode
96 * @param wid the parent 96 * @param wid the parent
97 * @param mode the Mode of the Selector 97 * @param mode the Mode of the Selector
98 * @param selector the current View of the Selector 98 * @param selector the current View of the Selector
99 * @param dirName in which dir to start 99 * @param dirName in which dir to start
100 * @param fileName a proposed filename 100 * @param fileName a proposed filename
101 * @param mimetypes A list of mimetypes \ 101 * @param mimetypes A list of mimetypes \
102 * QString is for a identifier name like "Text files" 102 * QString is for a identifier name like "Text files"
103 * the coresponding QStringList is used for the mimetypes 103 * the coresponding QStringList is used for the mimetypes
104 * if empty it'll fill the list of mimetypes depending 104 * if empty it'll fill the list of mimetypes depending
105 * on the content of the current directory 105 * on the content of the current directory
106 */ 106 */
107 107
108 OFileSelector(QWidget *wid, int mode, int selector, 108 OFileSelector(QWidget *wid, int mode, int selector,
109 const QString &dirName, 109 const QString &dirName,
110 const QString &fileName = QString::null, 110 const QString &fileName = QString::null,
111 const MimeTypes &mimetypes = MimeTypes() ); 111 const MimeTypes &mimetypes = MimeTypes() );
112 112
113 113
114 /** 114 /**
115 * This is a QPE compatible c'tor 115 * This is a QPE compatible c'tor
116 */ 116 */
117 OFileSelector(const QString &mimeFilter, QWidget *parent, 117 OFileSelector(const QString &mimeFilter, QWidget *parent,
118 const char *name, bool newVisible = TRUE, 118 const char *name, bool newVisible = TRUE,
119 bool closeVisible = FALSE ); 119 bool closeVisible = FALSE );
120 120
121 ~OFileSelector(); 121 ~OFileSelector();
122 122
123 // currently only for the FILESELECTOR Mode 123 // currently only for the FILESELECTOR Mode
124 void setNewVisible( bool /*b*/ ); 124 void setNewVisible( bool /*b*/ );
125 void setCloseVisible(bool /*b*/ ); 125 void setCloseVisible(bool /*b*/ );
126 126
127 // end file selector mode 127 // end file selector mode
128 // deprecated 128 // deprecated
129 void reread(); 129 void reread();
130 // make sure not to leak please 130 // make sure not to leak please
131 const DocLnk *selected(); 131 const DocLnk *selected();
132 // end deprecated 132 // end deprecated
133 133
134 bool isToolbarVisible() const { return m_shTool; }; 134 bool isToolbarVisible() const { return m_shTool; };
135 bool isPermissionBarVisible() const { return m_shPerm; }; 135 bool isPermissionBarVisible() const { return m_shPerm; };
136 bool isLineEditVisible()const { return m_shLne; }; 136 bool isLineEditVisible()const { return m_shLne; };
137 bool isChooserVisible( )const { return m_shChooser; }; 137 bool isChooserVisible( )const { return m_shChooser; };
138 bool isYesCancelVisible()const { return m_shYesNo; }; 138 bool isYesCancelVisible()const { return m_shYesNo; };
139 void setYesCancelVisible( bool show ); 139 void setYesCancelVisible( bool show );
140 void setToolbarVisible( bool show ); 140 void setToolbarVisible( bool show );
141 void setPermissionBarVisible( bool show ); 141 void setPermissionBarVisible( bool show );
142 void setLineEditVisible(bool show) ; 142 void setLineEditVisible(bool show) ;
143 void setChooserVisible( bool chooser ); 143 void setChooserVisible( bool chooser );
144 144
145 QCheckBox* permissionCheckbox(); 145 QCheckBox* permissionCheckbox();
146 bool setPermission() const; 146 bool setPermission() const;
147 void setPermissionChecked( bool check ); 147 void setPermissionChecked( bool check );
148 148
149 void setMode( int ); 149 void setMode( int );
150 150
151 bool showDirs()const { return m_dir; } 151 bool showDirs()const { return m_dir; }
152 void setShowDirs(bool ); 152 void setShowDirs(bool );
153 153
154 const QListView* listView() { return m_View; }; 154 const QListView* listView() { return m_View; };
155 155
156 bool isCaseSensetive()const { return m_case; } 156 bool isCaseSensetive()const { return m_case; }
157 void setCaseSensetive(bool caSe ); 157 void setCaseSensetive(bool caSe );
158 158
159 bool showFiles()const { return m_files; }; 159 bool showFiles()const { return m_files; };
160 void setShowFiles(bool ); 160 void setShowFiles(bool );
161 bool cd(const QString &path ); 161 bool cd(const QString &path );
162 162
163 163
164 int mode()const { return m_mode; }; 164 int mode()const { return m_mode; };
165 int selector()const { return m_selector; }; 165 int selector()const { return m_selector; };
166 void setSelector( int ); 166 void setSelector( int );
167 167
168 bool showPopup()const { return m_showPopup; }; 168 bool showPopup()const { return m_showPopup; };
169 void setShowPopup( bool pop ) { m_showPopup = pop; }; 169 void setShowPopup( bool pop ) { m_showPopup = pop; };
170 void setPopupMenu( QPopupMenu * ); 170 void setPopupMenu( QPopupMenu * );
171 171
172 // void updateLay(); 172 // void updateLay();
173 173
174 void reparse(); // re reads the dir 174 void reparse(); // re reads the dir
175 175
176 QString selectedName( )const; 176 QString selectedName( )const;
177 QStringList selectedNames()const; 177 QStringList selectedNames()const;
178 178
179 QString selectedPath() const; 179 QString selectedPath() const;
180 QStringList selectedPaths() const; 180 QStringList selectedPaths() const;
181 181
182 QString directory()const; 182 QString directory()const;
183 int fileCount(); 183 int fileCount() const;
184 184
185 /* the user needs to delete it */ 185 /* the user needs to delete it */
186 DocLnk selectedDocument()const; 186 DocLnk selectedDocument()const;
187 /* the user needs to delete it */ 187 /* the user needs to delete it */
188 QValueList<DocLnk> selectedDocuments()const; 188 QValueList<DocLnk> selectedDocuments()const;
189 189
190 signals: 190 signals:
191 void fileSelected( const DocLnk & ); 191 void fileSelected( const DocLnk & );
192 void fileSelected( const QString & ); 192 void fileSelected( const QString & );
193 void dirSelected(const QString &dir ); 193 void dirSelected(const QString &dir );
194 void closeMe(); 194 void closeMe();
195 void ok(); 195 void ok();
196 void cancel(); 196 void cancel();
197 void contextMenu(); 197 void contextMenu();
198 198
199 private slots: 199 private slots:
200 void slotTest() { qWarning("slotTest" ); setLineEditVisible(false ); }; 200 void slotTest() { qWarning("slotTest" ); setLineEditVisible(false ); };
201 void slotOk(); 201 void slotOk();
202 void slotCancel(); 202 void slotCancel();
203 void slotViewCheck(const QString & ); 203 void slotViewCheck(const QString & );
204 void slotMimeCheck(const QString & ); 204 void slotMimeCheck(const QString & );
205 void slotLocationActivated(const QString & ); 205 void slotLocationActivated(const QString & );
206 void slotInsertLocationPath(const QString &, int); 206 void slotInsertLocationPath(const QString &, int);
207 void locationComboChanged(); 207 void locationComboChanged();
208 208
209 private: 209 private:
210 void init(); 210 void init();
211 void updateMimes(); 211 void updateMimes();
212 212
213 protected: 213 protected:
214 214
215 private: 215 private:
216 int m_mode, m_selector; 216 int m_mode, m_selector;
217 QComboBox *m_location, *m_mimeCheck, *m_viewCheck; 217 QComboBox *m_location, *m_mimeCheck, *m_viewCheck;
218 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; 218 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel;
219 QPushButton *m_reread, *m_up, *m_new, *m_close; 219 QPushButton *m_reread, *m_up, *m_new, *m_close;
220 QListView *m_View; 220 QListView *m_View;
221 QCheckBox *m_checkPerm; 221 QCheckBox *m_checkPerm;
222 QWidget *m_pseudo; 222 QWidget *m_pseudo;
223 QVBoxLayout *m_pseudoLayout; 223 QVBoxLayout *m_pseudoLayout;
224 224
225 QString m_currentDir; 225 QString m_currentDir;
226 QString m_name; 226 QString m_name;
227// QStringList m_mimetypes; 227// QStringList m_mimetypes;
228 QMap<QString, QStringList> m_mimetypes; 228 QMap<QString, QStringList> m_mimetypes;
229 229
230 FileSelector *m_select; 230 FileSelector *m_select;
231 QWidgetStack *m_stack; 231 QWidgetStack *m_stack;
232 QVBoxLayout *m_lay; 232 QVBoxLayout *m_lay;
233 QGridLayout *m_Oselector; 233 QGridLayout *m_Oselector;
234 234
235 QHBox *m_boxToolbar; 235 QHBox *m_boxToolbar;
236 QHBox *m_boxOk; // (no layout anymore) wait 236 QHBox *m_boxOk; // (no layout anymore) wait
237 QHBox *m_boxName; // (no Layout anymore) wait 237 QHBox *m_boxName; // (no Layout anymore) wait
238 QHBox *m_boxView; 238 QHBox *m_boxView;
239 239
240 QPopupMenu *m_custom; 240 QPopupMenu *m_custom;
241 241
242 QLineEdit *m_edit; 242 QLineEdit *m_edit;
243 QLabel *m_fnLabel; 243 QLabel *m_fnLabel;
244 244
245 bool m_shClose : 1; 245 bool m_shClose : 1;
246 bool m_shNew : 1; 246 bool m_shNew : 1;
247 bool m_shTool : 1; 247 bool m_shTool : 1;
248 bool m_shPerm : 1; 248 bool m_shPerm : 1;
249 bool m_shLne : 1; 249 bool m_shLne : 1;
250 bool m_shChooser : 1; 250 bool m_shChooser : 1;
251 bool m_shYesNo : 1; 251 bool m_shYesNo : 1;
252 bool m_boCheckPerm : 1; 252 bool m_boCheckPerm : 1;
253 bool m_autoMime : 1; 253 bool m_autoMime : 1;
254 bool m_case : 1; 254 bool m_case : 1;
255 bool m_dir : 1; 255 bool m_dir : 1;
256 bool m_files : 1; 256 bool m_files : 1;
257 bool m_showPopup : 1; 257 bool m_showPopup : 1;
258 258
259 void initVars(); 259 void initVars();
260 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); 260 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE );
261 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); 261 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE );
262 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; 262 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){};
263 void delItems(); 263 void delItems();
264 void initializeName(); 264 void initializeName();
265 void initializeYes(); 265 void initializeYes();
266 void initializeChooser(); 266 void initializeChooser();
267 void initializeListView(); 267 void initializeListView();
268 void initializePerm(); 268 void initializePerm();
269 void initPics(); 269 void initPics();
270 bool compliesMime(const QString &path, 270 bool compliesMime(const QString &path,
271 const QString &mime); 271 const QString &mime);
272 bool compliesMime(const QString& mime ); 272 bool compliesMime(const QString& mime );
273 /** 273 /**
274 * Updates the QComboBox with the current mimetypes 274 * Updates the QComboBox with the current mimetypes
275 */ 275 */
276 void updateMimeCheck(); 276 void updateMimeCheck();
277 277
278 /** 278 /**
279 * Returns the current mimetype 279 * Returns the current mimetype
280 */ 280 */
281 QString currentMimeType()const; 281 QString currentMimeType()const;
282 class OFileSelectorPrivate; 282 class OFileSelectorPrivate;
283 OFileSelectorPrivate *d; 283 OFileSelectorPrivate *d;
284 static QMap<QString,QPixmap> *m_pixmaps; 284 static QMap<QString,QPixmap> *m_pixmaps;
285 285
286private slots: 286private slots:
287 void slotFileSelected(const QString & ); // not really meant to be a slot 287 void slotFileSelected(const QString & ); // not really meant to be a slot
288 void slotFileBridgeSelected( const DocLnk & ); 288 void slotFileBridgeSelected( const DocLnk & );
289 virtual void slotSelectionChanged(); 289 virtual void slotSelectionChanged();
290 virtual void slotCurrentChanged(QListViewItem* ); 290 virtual void slotCurrentChanged(QListViewItem* );
291 virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); 291 virtual void slotClicked( int, QListViewItem *item, const QPoint &, int);
292 virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); 292 virtual void slotRightButton(int, QListViewItem *, const QPoint &, int );
293 virtual void slotContextMenu( QListViewItem *item); 293 virtual void slotContextMenu( QListViewItem *item);
294 // listview above 294 // listview above
295 // popup below 295 // popup below
296 virtual void slotChangedDir(); 296 virtual void slotChangedDir();
297 virtual void slotOpen(); 297 virtual void slotOpen();
298 virtual void slotRescan(); 298 virtual void slotRescan();
299 virtual void slotRename(); 299 virtual void slotRename();
300 virtual void slotDelete(); 300 virtual void slotDelete();
301 virtual void cdUP(); 301 virtual void cdUP();
302 virtual void slotHome(); 302 virtual void slotHome();
303 virtual void slotDoc(); 303 virtual void slotDoc();
304 virtual void slotNavigate( ); 304 virtual void slotNavigate( );
305}; 305};
306 306
307 307
308#endif 308#endif
309 309
diff --git a/libopie/ofileselector/odefaultfactories.cpp b/libopie/ofileselector/odefaultfactories.cpp
index c8efffb..2f8ef9b 100644
--- a/libopie/ofileselector/odefaultfactories.cpp
+++ b/libopie/ofileselector/odefaultfactories.cpp
@@ -1,23 +1,19 @@
1#include "ofilelistview.h" 1#include "ofilelistview.h"
2#include "ofileiconview.h"
3#include "olocallister.h" 2#include "olocallister.h"
4 3
5 4
6#include "odefaultfactories.h" 5#include "odefaultfactories.h"
7 6
8extern "C" { 7extern "C" {
9 8
10 9
11 OFileView* newFileIconView( OFileSelector* sel, QWidget* parent ) {
12 return new OFileIconView( parent, sel );
13 }
14 10
15 OFileView* newFileListView( OFileSelector* sel, QWidget* par ) { 11 OFileView* newFileListView( OFileSelector* sel, QWidget* par ) {
16 return new OFileListView(par, sel ); 12 return new OFileListView(par, sel );
17 } 13 }
18 14
19 OLister* newLocalLister( OFileSelector* sel) { 15 OLister* newLocalLister( OFileSelector* sel) {
20 return new OLocalLister( sel ); 16 return new OLocalLister( sel );
21 } 17 }
22 18
23}; 19};
diff --git a/libopie/ofileselector/odefaultfactories.h b/libopie/ofileselector/odefaultfactories.h
index b4c35af..0cc90e5 100644
--- a/libopie/ofileselector/odefaultfactories.h
+++ b/libopie/ofileselector/odefaultfactories.h
@@ -1,17 +1,16 @@
1#ifndef OPIE_DEFAULT_FACTORIES_H 1#ifndef OPIE_DEFAULT_FACTORIES_H
2#define OPIE_DEFAULT_FACTORIES_H 2#define OPIE_DEFAULT_FACTORIES_H
3 3
4#include "ofilefactory.h" 4#include "ofilefactory.h"
5 5
6extern "C" { 6extern "C" {
7 7
8 OFileView* newFileIconView( OFileSelector*, QWidget* parent );
9 OFileView* newFileListView( OFileSelector*, QWidget* parent ); 8 OFileView* newFileListView( OFileSelector*, QWidget* parent );
10 9
11 OLister* newLocalLister(OFileSelector* ); 10 OLister* newLocalLister(OFileSelector* );
12 11
13 12
14}; 13};
15 14
16 15
17#endif 16#endif
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp
index c6e923f..abc2889 100644
--- a/libopie/ofileselector/ofileselector.cpp
+++ b/libopie/ofileselector/ofileselector.cpp
@@ -851,244 +851,245 @@ void OFileSelector::cdUP()
851 // better call the Olister 851 // better call the Olister
852 QDir dir( m_currentDir ); 852 QDir dir( m_currentDir );
853 dir.cdUp(); 853 dir.cdUp();
854 if(dir.exists() ){ 854 if(dir.exists() ){
855 m_currentDir = dir.absPath(); 855 m_currentDir = dir.absPath();
856 reparse(); 856 reparse();
857 int count = m_location->count(); 857 int count = m_location->count();
858 slotInsertLocationPath( m_currentDir, count); 858 slotInsertLocationPath( m_currentDir, count);
859 m_location->setCurrentItem( indexByString( m_location, m_currentDir)); 859 m_location->setCurrentItem( indexByString( m_location, m_currentDir));
860 } 860 }
861} 861}
862void OFileSelector::slotHome() 862void OFileSelector::slotHome()
863{ 863{
864 cd(QDir::homeDirPath() ); 864 cd(QDir::homeDirPath() );
865} 865}
866void OFileSelector::slotDoc() 866void OFileSelector::slotDoc()
867{ 867{
868 cd(QPEApplication::documentDir() ); 868 cd(QPEApplication::documentDir() );
869} 869}
870void OFileSelector::slotNavigate( ) 870void OFileSelector::slotNavigate( )
871{ 871{
872 872
873} 873}
874// fill the View with life 874// fill the View with life
875void OFileSelector::reparse() 875void OFileSelector::reparse()
876{ 876{
877 if( m_selector == Normal ) 877 if( m_selector == Normal )
878 return; 878 return;
879 879
880 currentView()->clear(); 880 currentView()->clear();
881 881
882 if( m_shChooser) 882 if( m_shChooser)
883 qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); 883 qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
884 884
885 QString currentMimeType; 885 QString currentMimeType;
886 886
887 // let's update the mimetype 887 // let's update the mimetype
888 if( m_autoMime ){ 888 if( m_autoMime ){
889 m_mimetypes.clear(); 889 m_mimetypes.clear();
890 // ok we can change mimetype so we need to be able to give a selection 890 // ok we can change mimetype so we need to be able to give a selection
891 if( m_shChooser ) { 891 if( m_shChooser ) {
892 currentMimeType = m_mimeCheck->currentText(); 892 currentMimeType = m_mimeCheck->currentText();
893 m_mimeCheck->clear(); 893 m_mimeCheck->clear();
894 894
895 // let's find possible mimetypes 895 // let's find possible mimetypes
896 m_mimetypes = currentLister()->mimeTypes( m_currentDir ); 896 m_mimetypes = currentLister()->mimeTypes( m_currentDir );
897 897
898 // add them to the chooser 898 // add them to the chooser
899 updateMimeCheck(); 899 updateMimeCheck();
900 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); 900 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
901 currentMimeType = m_mimeCheck->currentText(); 901 currentMimeType = m_mimeCheck->currentText();
902 } 902 }
903 }else { // no autoMime 903 }else { // no autoMime
904 // let the mimetype be set from out side the m_mimeCheck FEATURE 904 // let the mimetype be set from out side the m_mimeCheck FEATURE
905 905
906 if( m_shChooser ) 906 if( m_shChooser )
907 currentMimeType = m_mimeCheck->currentText(); 907 currentMimeType = m_mimeCheck->currentText();
908 908
909 } 909 }
910 // now we got our mimetypes we can add the files 910 // now we got our mimetypes we can add the files
911 911
912 currentLister()->reparse( m_currentDir ); 912 currentLister()->reparse( m_currentDir );
913 /* we're done with adding let's sort */ 913 /* we're done with adding let's sort */
914 currentView()->sort(); 914 currentView()->sort();
915 915
916 916
917 if( m_shTool ){ 917 if( m_shTool ){
918 m_location->insertItem( m_currentDir ); 918 m_location->insertItem( m_currentDir );
919 919
920 } 920 }
921 // reenable painting and updates 921 // reenable painting and updates
922} 922}
923/* switch lister to @param lister */ 923/* switch lister to @param lister */
924void OFileSelector::setLister(const QString& lister) { 924void OFileSelector::setLister(const QString& lister) {
925 QStringList listerList = factory()->lister(); 925 QStringList listerList = factory()->lister();
926 926
927 if (listerList.contains(lister) ) { 927 if (listerList.contains(lister) ) {
928 delete (OLister*) m_lister; 928 delete (OLister*) m_lister;
929 m_lister = factory()->lister( lister, this ); 929 m_lister = factory()->lister( lister, this );
930 }else if (!m_lister ) { 930 }else if (!m_lister ) {
931 /* 931 /*
932 * if we do not have a lister 932 * if we do not have a lister
933 * we need to take the default one 933 * we need to take the default one
934 */ 934 */
935 m_lister = new OLocalLister(this); 935 m_lister = new OLocalLister(this);
936 } 936 }
937 m_listerName = lister; 937 m_listerName = lister;
938} 938}
939void OFileSelector::setView( const QString& lis ) { 939void OFileSelector::setView( const QString& lis ) {
940 qWarning("setView "); 940 qWarning("setView ");
941 fillList(); 941 fillList();
942 if ( lis == tr("Documents") ) { 942 if ( lis == tr("Documents") ) {
943 m_selector = Normal; 943 m_selector = Normal;
944 delete m_lister; 944 delete m_lister;
945 delete m_fileView; 945 delete m_fileView;
946 m_lister = 0l; 946 m_lister = 0l;
947 m_fileView = 0l; 947 m_fileView = 0l;
948 initializeOldSelector(); 948 initializeOldSelector();
949 }else { 949 }else {
950 qWarning("lis %s", lis.latin1() ); 950 qWarning("lis %s", lis.latin1() );
951 QString list; 951 QString list;
952 952
953 delete m_lister; 953 delete m_lister;
954 delete m_fileView; 954 delete m_fileView;
955 delete m_select; 955 delete m_select;
956 m_lister =0l; 956 m_lister =0l;
957 m_fileView = 0l; 957 m_fileView = 0l;
958 m_select = 0l; 958 m_select = 0l;
959 if ( lis.startsWith("All") ) { 959 if ( lis.startsWith("All") ) {
960 m_selector = ExtendedAll; 960 m_selector = ExtendedAll;
961 list = lis.mid(4 ).stripWhiteSpace(); 961 list = lis.mid(4 ).stripWhiteSpace();
962 } else{ 962 } else{
963 list = lis; 963 list = lis;
964 m_selector = Extended; 964 m_selector = Extended;
965 } 965 }
966 setLister(m_listerName); 966 setLister(m_listerName);
967 m_fileView = factory()->view( list, this, m_mainView ); 967 m_fileView = factory()->view( list, this, m_mainView );
968 m_mainView->setWidget( m_fileView->widget() ); 968 m_mainView->setWidget( m_fileView->widget() );
969 reparse(); 969 reparse();
970 } 970 }
971} 971}
972/* 972/*
973 * the factory 973 * the factory
974 */ 974 */
975void OFileSelector::initFactory() { 975void OFileSelector::initFactory() {
976 m_fileFactory = new OFileFactory(); 976 m_fileFactory = new OFileFactory();
977 m_fileFactory->addLister(tr("Files"), newLocalLister ); 977 m_fileFactory->addLister(tr("Files"), newLocalLister );
978 m_fileFactory->addView(tr("List View"), newFileListView ); 978 m_fileFactory->addView(tr("List View"), newFileListView );
979 m_fileFactory->addView(tr("Documents"), newFileIconView ); 979 /* dummy entry */
980 m_fileFactory->addView(tr("Documents"), newFileListView );
980} 981}
981 982
982void OFileSelector::fillList() { 983void OFileSelector::fillList() {
983 qWarning("fill list"); 984 qWarning("fill list");
984 if (!m_viewCheck ) 985 if (!m_viewCheck )
985 return; 986 return;
986 987
987 m_viewCheck->clear(); 988 m_viewCheck->clear();
988 QStringList list = factory()->views(); 989 QStringList list = factory()->views();
989 qWarning("views: " + list.join(";") ); 990 qWarning("views: " + list.join(";") );
990 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 991 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
991 qWarning( (*it) ); 992 qWarning( (*it) );
992 if ( (*it) == tr("Documents") ) { 993 if ( (*it) == tr("Documents") ) {
993 m_viewCheck->insertItem( (*it) ); 994 m_viewCheck->insertItem( (*it) );
994 }else{ 995 }else{
995 m_viewCheck->insertItem( (*it) ); 996 m_viewCheck->insertItem( (*it) );
996 m_viewCheck->insertItem( tr("All ") + (*it) ); 997 m_viewCheck->insertItem( tr("All ") + (*it) );
997 } 998 }
998 } 999 }
999} 1000}
1000OFileFactory* OFileSelector::factory() { 1001OFileFactory* OFileSelector::factory() {
1001 return m_fileFactory; 1002 return m_fileFactory;
1002} 1003}
1003 1004
1004 1005
1005OFileView* OFileSelector::currentView() { 1006OFileView* OFileSelector::currentView() {
1006 return m_fileView; 1007 return m_fileView;
1007} 1008}
1008OFileView* OFileSelector::currentView() const{ 1009OFileView* OFileSelector::currentView() const{
1009 return m_fileView; 1010 return m_fileView;
1010} 1011}
1011int OFileSelector::filter() { 1012int OFileSelector::filter() {
1012 int filter; 1013 int filter;
1013 if ( m_selector == ExtendedAll ) 1014 if ( m_selector == ExtendedAll )
1014 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 1015 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
1015 else 1016 else
1016 filter = QDir::Files | QDir::Dirs | QDir::All ; 1017 filter = QDir::Files | QDir::Dirs | QDir::All ;
1017 1018
1018 return filter; 1019 return filter;
1019} 1020}
1020int OFileSelector::sorting() { 1021int OFileSelector::sorting() {
1021 int sort; 1022 int sort;
1022 1023
1023 if (m_case ) 1024 if (m_case )
1024 sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); 1025 sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed );
1025 else 1026 else
1026 sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 1027 sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed );
1027 1028
1028 return sort; 1029 return sort;
1029} 1030}
1030void OFileSelector::internFileSelected( const QString& s) { 1031void OFileSelector::internFileSelected( const QString& s) {
1031 emit fileSelected( s ); 1032 emit fileSelected( s );
1032 DocLnk lnk( s ); 1033 DocLnk lnk( s );
1033 internFileSelected( lnk ); 1034 internFileSelected( lnk );
1034} 1035}
1035void OFileSelector::internFileSelected( const DocLnk& d ) { 1036void OFileSelector::internFileSelected( const DocLnk& d ) {
1036 emit fileSelected( d ); 1037 emit fileSelected( d );
1037} 1038}
1038void OFileSelector::internContextMenu() { 1039void OFileSelector::internContextMenu() {
1039 emit contextMenu(); 1040 emit contextMenu();
1040} 1041}
1041void OFileSelector::internChangedDir( const QString& s) { 1042void OFileSelector::internChangedDir( const QString& s) {
1042 emit dirSelected( s ); 1043 emit dirSelected( s );
1043 cd(s ); 1044 cd(s );
1044} 1045}
1045void OFileSelector::internChangedDir( const QDir& s) { 1046void OFileSelector::internChangedDir( const QDir& s) {
1046 emit dirSelected( s ); 1047 emit dirSelected( s );
1047} 1048}
1048QPixmap OFileSelector::pixmap( const QString& s ) { 1049QPixmap OFileSelector::pixmap( const QString& s ) {
1049 1050
1050 return (*m_pixmaps)[s]; 1051 return (*m_pixmaps)[s];
1051} 1052}
1052OLister* OFileSelector::currentLister()const { 1053OLister* OFileSelector::currentLister()const {
1053 return m_lister; 1054 return m_lister;
1054} 1055}
1055void OFileSelector::initializeOldSelector() { 1056void OFileSelector::initializeOldSelector() {
1056 qWarning("initializeOldSelector"); 1057 qWarning("initializeOldSelector");
1057 1058
1058 delete m_select; 1059 delete m_select;
1059 1060
1060 // we need to initialize but keep the selected mimetype 1061 // we need to initialize but keep the selected mimetype
1061 /* we default not to show close and new buttons */ 1062 /* we default not to show close and new buttons */
1062 QString mime = currentMimeType(); 1063 QString mime = currentMimeType();
1063 qWarning("MimeType " + mime ); 1064 qWarning("MimeType " + mime );
1064 m_select = new FileSelector( mime , 1065 m_select = new FileSelector( mime ,
1065 m_mainView, "fileselector", 1066 m_mainView, "fileselector",
1066 FALSE, FALSE); 1067 FALSE, FALSE);
1067 m_select->setCategorySelectVisible( FALSE ); 1068 m_select->setCategorySelectVisible( FALSE );
1068 m_select->setTypeComboVisible( FALSE ); 1069 m_select->setTypeComboVisible( FALSE );
1069 1070
1070 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 1071 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
1071 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 1072 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
1072 connect(m_select, SIGNAL(closeMe() ), 1073 connect(m_select, SIGNAL(closeMe() ),
1073 this, SIGNAL(closeMe() ) ); 1074 this, SIGNAL(closeMe() ) );
1074 //connect to close me and other signals as well 1075 //connect to close me and other signals as well
1075 m_mainView->setWidget( m_select ); 1076 m_mainView->setWidget( m_select );
1076} 1077}
1077/* 1078/*
1078 * initialize the listview 1079 * initialize the listview
1079 * we will call fillList 1080 * we will call fillList
1080 * setLister 1081 * setLister
1081 * with QString::null to get the default 1082 * with QString::null to get the default
1082 * setView with either Files or All Files 1083 * setView with either Files or All Files
1083 * depending on Extended 1084 * depending on Extended
1084 */ 1085 */
1085void OFileSelector::initializeView() { 1086void OFileSelector::initializeView() {
1086 setLister(QString::null); 1087 setLister(QString::null);
1087 fillList(); 1088 fillList();
1088 if (m_selector == Extended ) { 1089 if (m_selector == Extended ) {
1089 setView( tr("List View") ); 1090 setView( tr("List View") );
1090 }else{ 1091 }else{
1091 setView( tr("All List View") ); 1092 setView( tr("All List View") );
1092 } 1093 }
1093} 1094}
1094 1095
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h
index 0bd2723..4f00bc9 100644
--- a/libopie/pim/opimaccessbackend.h
+++ b/libopie/pim/opimaccessbackend.h
@@ -1,141 +1,141 @@
1#ifndef OPIE_PIM_ACCESS_BACKEND 1#ifndef OPIE_PIM_ACCESS_BACKEND
2#define OPIE_PIM_ACCESS_BACKEND 2#define OPIE_PIM_ACCESS_BACKEND
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/otemplatebase.h> 6#include <opie/otemplatebase.h>
7#include <opie/opimrecord.h> 7#include <opie/opimrecord.h>
8 8
9 9
10/** 10/**
11 * OPimAccessBackend is the base class 11 * OPimAccessBackend is the base class
12 * for all private backends 12 * for all private backends
13 * it operates on OPimRecord as the base class 13 * it operates on OPimRecord as the base class
14 * and it's responsible for fast manipulating 14 * and it's responsible for fast manipulating
15 * the resource the implementation takes care 15 * the resource the implementation takes care
16 * of 16 * of
17 */ 17 */
18template <class T = OPimRecord> 18template <class T = OPimRecord>
19class OPimAccessBackend { 19class OPimAccessBackend {
20public: 20public:
21 typedef OTemplateBase<T> Frontend; 21 typedef OTemplateBase<T> Frontend;
22 OPimAccessBackend(); 22 OPimAccessBackend();
23 virtual ~OPimAccessBackend(); 23 virtual ~OPimAccessBackend();
24 24
25 /** 25 /**
26 * load the resource 26 * load the resource
27 */ 27 */
28 virtual bool load() = 0; 28 virtual bool load() = 0;
29 29
30 /** 30 /**
31 * reload the resource 31 * reload the resource
32 */ 32 */
33 virtual bool reload() = 0; 33 virtual bool reload() = 0;
34 34
35 /** 35 /**
36 * save the resource and 36 * save the resource and
37 * all it's changes 37 * all it's changes
38 */ 38 */
39 virtual bool save() = 0; 39 virtual bool save() = 0;
40 40
41 /** 41 /**
42 * return an array of 42 * return an array of
43 * all available uids 43 * all available uids
44 */ 44 */
45 virtual QArray<int> allRecords()const = 0; 45 virtual QArray<int> allRecords()const = 0;
46 46
47 /** 47 /**
48 * queryByExample for T with the SortOrder 48 * queryByExample for T with the SortOrder
49 * sort 49 * sort
50 */ 50 */
51 virtual QArray<int> queryByExample( const T& t, int sort ) = 0; 51 virtual QArray<int> queryByExample( const T& t, int sort ) = 0;
52 52
53 /** 53 /**
54 * find the OPimRecord with uid @param uid 54 * find the OPimRecord with uid @param uid
55 * returns T and T.isEmpty() if nothing was found 55 * returns T and T.isEmpty() if nothing was found
56 */ 56 */
57 virtual T find(int uid )const = 0; 57 virtual T find(int uid )const = 0;
58 58
59 virtual T find(int uid, const QArray<int>& items, 59 virtual T find(int uid, const QArray<int>& items,
60 uint current, Frontend::CacheDirection )const ; 60 uint current, typename Frontend::CacheDirection )const ;
61 /** 61 /**
62 * clear the back end 62 * clear the back end
63 */ 63 */
64 virtual void clear() = 0; 64 virtual void clear() = 0;
65 65
66 /** 66 /**
67 * add T 67 * add T
68 */ 68 */
69 virtual bool add( const T& t ) = 0; 69 virtual bool add( const T& t ) = 0;
70 70
71 /** 71 /**
72 * remove 72 * remove
73 */ 73 */
74 virtual bool remove( int uid ) = 0; 74 virtual bool remove( int uid ) = 0;
75 75
76 /** 76 /**
77 * replace a record with T.uid() 77 * replace a record with T.uid()
78 */ 78 */
79 virtual bool replace( const T& t ) = 0; 79 virtual bool replace( const T& t ) = 0;
80 80
81 /* 81 /*
82 * setTheFrontEnd!!! 82 * setTheFrontEnd!!!
83 */ 83 */
84 void setFrontend( Frontend* front ); 84 void setFrontend( Frontend* front );
85 85
86 /** 86 /**
87 * set the read ahead count 87 * set the read ahead count
88 */ 88 */
89 void setReadAhead( uint count ); 89 void setReadAhead( uint count );
90protected: 90protected:
91 void cache( const T& t )const; 91 void cache( const T& t )const;
92 92
93 /** 93 /**
94 * use a prime number here! 94 * use a prime number here!
95 */ 95 */
96 void setSaneCacheSize( int ); 96 void setSaneCacheSize( int );
97 97
98 uint readAhead()const; 98 uint readAhead()const;
99 99
100private: 100private:
101 Frontend* m_front; 101 Frontend* m_front;
102 uint m_read; 102 uint m_read;
103 103
104}; 104};
105 105
106template <class T> 106template <class T>
107OPimAccessBackend<T>::OPimAccessBackend() { 107OPimAccessBackend<T>::OPimAccessBackend() {
108 m_front = 0l; 108 m_front = 0l;
109} 109}
110template <class T> 110template <class T>
111OPimAccessBackend<T>::~OPimAccessBackend() { 111OPimAccessBackend<T>::~OPimAccessBackend() {
112 112
113} 113}
114template <class T> 114template <class T>
115void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 115void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
116 m_front = fr; 116 m_front = fr;
117} 117}
118template <class T> 118template <class T>
119void OPimAccessBackend<T>::cache( const T& t )const { 119void OPimAccessBackend<T>::cache( const T& t )const {
120 if (m_front ) 120 if (m_front )
121 m_front->cache( t ); 121 m_front->cache( t );
122} 122}
123template <class T> 123template <class T>
124void OPimAccessBackend<T>::setSaneCacheSize( int size) { 124void OPimAccessBackend<T>::setSaneCacheSize( int size) {
125 if (m_front ) 125 if (m_front )
126 m_front->setSaneCacheSize( size ); 126 m_front->setSaneCacheSize( size );
127} 127}
128template <class T> 128template <class T>
129T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 129T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
130 uint, Frontend::CacheDirection )const { 130 uint, typename Frontend::CacheDirection )const {
131 return find( uid ); 131 return find( uid );
132} 132}
133template <class T> 133template <class T>
134void OPimAccessBackend<T>::setReadAhead( uint count ) { 134void OPimAccessBackend<T>::setReadAhead( uint count ) {
135 m_read = count; 135 m_read = count;
136} 136}
137template <class T> 137template <class T>
138uint OPimAccessBackend<T>::readAhead()const { 138uint OPimAccessBackend<T>::readAhead()const {
139 return m_read; 139 return m_read;
140} 140}
141#endif 141#endif
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h
index c5523a8..6de68b1 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/libopie/pim/opimaccesstemplate.h
@@ -1,259 +1,259 @@
1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H 1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H
2#define OPIE_PIM_ACCESS_TEMPLATE_H 2#define OPIE_PIM_ACCESS_TEMPLATE_H
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/opimrecord.h> 6#include <opie/opimrecord.h>
7#include <opie/opimaccessbackend.h> 7#include <opie/opimaccessbackend.h>
8#include <opie/orecordlist.h> 8#include <opie/orecordlist.h>
9 9
10#include "opimcache.h" 10#include "opimcache.h"
11#include "otemplatebase.h" 11#include "otemplatebase.h"
12 12
13/** 13/**
14 * Thats the frontend to our OPIE PIM 14 * Thats the frontend to our OPIE PIM
15 * Library. Either you want to use it's 15 * Library. Either you want to use it's
16 * interface or you want to implement 16 * interface or you want to implement
17 * your own Access lib 17 * your own Access lib
18 * Just create a OPimRecord and inherit from 18 * Just create a OPimRecord and inherit from
19 * the plugins 19 * the plugins
20 */ 20 */
21 21
22template <class T = OPimRecord > 22template <class T = OPimRecord >
23class OPimAccessTemplate : public OTemplateBase<T> { 23class OPimAccessTemplate : public OTemplateBase<T> {
24public: 24public:
25 typedef ORecordList<T> List; 25 typedef ORecordList<T> List;
26 typedef OPimAccessBackend<T> BackEnd; 26 typedef OPimAccessBackend<T> BackEnd;
27 typedef OPimCache<T> Cache; 27 typedef OPimCache<T> Cache;
28 28
29 /** 29 /**
30 * c'tor BackEnd 30 * c'tor BackEnd
31 */ 31 */
32 OPimAccessTemplate( BackEnd* end); 32 OPimAccessTemplate( BackEnd* end);
33 virtual ~OPimAccessTemplate(); 33 virtual ~OPimAccessTemplate();
34 34
35 /** 35 /**
36 * load from the backend 36 * load from the backend
37 */ 37 */
38 virtual bool load(); 38 virtual bool load();
39 39
40 /** Reload database. 40 /** Reload database.
41 * You should execute this function if the external database 41 * You should execute this function if the external database
42 * was changed. 42 * was changed.
43 * This function will load the external database and afterwards 43 * This function will load the external database and afterwards
44 * rejoin the local changes. Therefore the local database will be set consistent. 44 * rejoin the local changes. Therefore the local database will be set consistent.
45 */ 45 */
46 virtual bool reload(); 46 virtual bool reload();
47 47
48 /** Save contacts database. 48 /** Save contacts database.
49 * Save is more a "commit". After calling this function, all changes are public available. 49 * Save is more a "commit". After calling this function, all changes are public available.
50 * @return true if successful 50 * @return true if successful
51 */ 51 */
52 virtual bool save(); 52 virtual bool save();
53 53
54 /** 54 /**
55 * if the resource was changed externally 55 * if the resource was changed externally
56 * You should use the signal handling instead of polling possible changes ! 56 * You should use the signal handling instead of polling possible changes !
57 * zecke: Do you implement a signal for otodoaccess ? 57 * zecke: Do you implement a signal for otodoaccess ?
58 */ 58 */
59 bool wasChangedExternally()const; 59 bool wasChangedExternally()const;
60 60
61 /** 61 /**
62 * return a List of records 62 * return a List of records
63 * you can iterate over them 63 * you can iterate over them
64 */ 64 */
65 virtual List allRecords()const; 65 virtual List allRecords()const;
66 66
67 /** 67 /**
68 * queryByExample. 68 * queryByExample.
69 * @see otodoaccess, ocontactaccess 69 * @see otodoaccess, ocontactaccess
70 */ 70 */
71 virtual List queryByExample( const T& t, int querySettings ); 71 virtual List queryByExample( const T& t, int querySettings );
72 72
73 /** 73 /**
74 * find the OPimRecord uid 74 * find the OPimRecord uid
75 */ 75 */
76 virtual T find( int uid )const; 76 virtual T find( int uid )const;
77 77
78 /** 78 /**
79 * read ahead cache find method ;) 79 * read ahead cache find method ;)
80 */ 80 */
81 virtual T find( int uid, const QArray<int>&, 81 virtual T find( int uid, const QArray<int>&,
82 uint current, CacheDirection dir = Forward )const; 82 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
83 83
84 /* invalidate cache here */ 84 /* invalidate cache here */
85 /** 85 /**
86 * clears the backend and invalidates the backend 86 * clears the backend and invalidates the backend
87 */ 87 */
88 virtual void clear() ; 88 virtual void clear() ;
89 89
90 /** 90 /**
91 * add T to the backend 91 * add T to the backend
92 * @param t The item to add. 92 * @param t The item to add.
93 * @return <i>true</i> if added successfully. 93 * @return <i>true</i> if added successfully.
94 */ 94 */
95 virtual bool add( const T& t ) ; 95 virtual bool add( const T& t ) ;
96 96
97 /* only the uid matters */ 97 /* only the uid matters */
98 /** 98 /**
99 * remove T from the backend 99 * remove T from the backend
100 * @param t The item to remove 100 * @param t The item to remove
101 * @return <i>true</i> if successful. 101 * @return <i>true</i> if successful.
102 */ 102 */
103 virtual bool remove( const T& t ); 103 virtual bool remove( const T& t );
104 104
105 /** 105 /**
106 * remove the OPimRecord with uid 106 * remove the OPimRecord with uid
107 * @param uid The ID of the item to remove 107 * @param uid The ID of the item to remove
108 * @return <i>true</i> if successful. 108 * @return <i>true</i> if successful.
109 */ 109 */
110 virtual bool remove( int uid ); 110 virtual bool remove( int uid );
111 111
112 /** 112 /**
113 * replace T from backend 113 * replace T from backend
114 * @param t The item to replace 114 * @param t The item to replace
115 * @return <i>true</i> if successful. 115 * @return <i>true</i> if successful.
116 */ 116 */
117 virtual bool replace( const T& t) ; 117 virtual bool replace( const T& t) ;
118 118
119 void setReadAhead( uint count ); 119 void setReadAhead( uint count );
120 /** 120 /**
121 * @internal 121 * @internal
122 */ 122 */
123 void cache( const T& )const; 123 void cache( const T& )const;
124 void setSaneCacheSize( int ); 124 void setSaneCacheSize( int );
125protected: 125protected:
126 /** 126 /**
127 * invalidate the cache 127 * invalidate the cache
128 */ 128 */
129 void invalidateCache(); 129 void invalidateCache();
130 130
131 void setBackEnd( BackEnd* end ); 131 void setBackEnd( BackEnd* end );
132 /** 132 /**
133 * returns the backend 133 * returns the backend
134 */ 134 */
135 BackEnd* backEnd(); 135 BackEnd* backEnd();
136 BackEnd* m_backEnd; 136 BackEnd* m_backEnd;
137 Cache m_cache; 137 Cache m_cache;
138 138
139}; 139};
140 140
141template <class T> 141template <class T>
142OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) 142OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end )
143 : OTemplateBase<T>(), m_backEnd( end ) 143 : OTemplateBase<T>(), m_backEnd( end )
144{ 144{
145 if (end ) 145 if (end )
146 end->setFrontend( this ); 146 end->setFrontend( this );
147} 147}
148template <class T> 148template <class T>
149OPimAccessTemplate<T>::~OPimAccessTemplate() { 149OPimAccessTemplate<T>::~OPimAccessTemplate() {
150 qWarning("~OPimAccessTemplate<T>"); 150 qWarning("~OPimAccessTemplate<T>");
151 delete m_backEnd; 151 delete m_backEnd;
152} 152}
153template <class T> 153template <class T>
154bool OPimAccessTemplate<T>::load() { 154bool OPimAccessTemplate<T>::load() {
155 invalidateCache(); 155 invalidateCache();
156 return m_backEnd->load(); 156 return m_backEnd->load();
157} 157}
158template <class T> 158template <class T>
159bool OPimAccessTemplate<T>::reload() { 159bool OPimAccessTemplate<T>::reload() {
160 invalidateCache(); // zecke: I think this should be added (se) 160 invalidateCache(); // zecke: I think this should be added (se)
161 return m_backEnd->reload(); 161 return m_backEnd->reload();
162} 162}
163template <class T> 163template <class T>
164bool OPimAccessTemplate<T>::save() { 164bool OPimAccessTemplate<T>::save() {
165 return m_backEnd->save(); 165 return m_backEnd->save();
166} 166}
167template <class T> 167template <class T>
168OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { 168typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
169 QArray<int> ints = m_backEnd->allRecords(); 169 QArray<int> ints = m_backEnd->allRecords();
170 List lis(ints, this ); 170 List lis(ints, this );
171 return lis; 171 return lis;
172} 172}
173template <class T> 173template <class T>
174OPimAccessTemplate<T>::List 174typename OPimAccessTemplate<T>::List
175OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) { 175OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) {
176 QArray<int> ints = m_backEnd->queryByExample( t, sortOrder ); 176 QArray<int> ints = m_backEnd->queryByExample( t, sortOrder );
177 177
178 List lis(ints, this ); 178 List lis(ints, this );
179 return lis; 179 return lis;
180} 180}
181template <class T> 181template <class T>
182T OPimAccessTemplate<T>::find( int uid ) const{ 182T OPimAccessTemplate<T>::find( int uid ) const{
183 T t = m_backEnd->find( uid ); 183 T t = m_backEnd->find( uid );
184 cache( t ); 184 cache( t );
185 return t; 185 return t;
186} 186}
187template <class T> 187template <class T>
188T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, 188T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
189 uint current, CacheDirection dir )const { 189 uint current, typename OTemplateBase<T>::CacheDirection dir )const {
190 /* 190 /*
191 * better do T.isEmpty() 191 * better do T.isEmpty()
192 * after a find this way we would 192 * after a find this way we would
193 * avoid two finds in QCache... 193 * avoid two finds in QCache...
194 */ 194 */
195 // qWarning("find it now %d", uid ); 195 // qWarning("find it now %d", uid );
196 if (m_cache.contains( uid ) ) { 196 if (m_cache.contains( uid ) ) {
197 return m_cache.find( uid ); 197 return m_cache.find( uid );
198 } 198 }
199 199
200 T t = m_backEnd->find( uid, ar, current, dir ); 200 T t = m_backEnd->find( uid, ar, current, dir );
201 cache( t ); 201 cache( t );
202 return t; 202 return t;
203} 203}
204template <class T> 204template <class T>
205void OPimAccessTemplate<T>::clear() { 205void OPimAccessTemplate<T>::clear() {
206 invalidateCache(); 206 invalidateCache();
207 m_backEnd->clear(); 207 m_backEnd->clear();
208} 208}
209template <class T> 209template <class T>
210bool OPimAccessTemplate<T>::add( const T& t ) { 210bool OPimAccessTemplate<T>::add( const T& t ) {
211 cache( t ); 211 cache( t );
212 return m_backEnd->add( t ); 212 return m_backEnd->add( t );
213} 213}
214template <class T> 214template <class T>
215bool OPimAccessTemplate<T>::remove( const T& t ) { 215bool OPimAccessTemplate<T>::remove( const T& t ) {
216 return remove( t.uid() ); 216 return remove( t.uid() );
217} 217}
218template <class T> 218template <class T>
219bool OPimAccessTemplate<T>::remove( int uid ) { 219bool OPimAccessTemplate<T>::remove( int uid ) {
220 m_cache.remove( uid ); 220 m_cache.remove( uid );
221 return m_backEnd->remove( uid ); 221 return m_backEnd->remove( uid );
222} 222}
223template <class T> 223template <class T>
224bool OPimAccessTemplate<T>::replace( const T& t ) { 224bool OPimAccessTemplate<T>::replace( const T& t ) {
225 m_cache.replace( t ); 225 m_cache.replace( t );
226 return m_backEnd->replace( t ); 226 return m_backEnd->replace( t );
227} 227}
228template <class T> 228template <class T>
229void OPimAccessTemplate<T>::invalidateCache() { 229void OPimAccessTemplate<T>::invalidateCache() {
230 m_cache.invalidate(); 230 m_cache.invalidate();
231} 231}
232template <class T> 232template <class T>
233OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { 233typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() {
234 return m_backEnd; 234 return m_backEnd;
235} 235}
236template <class T> 236template <class T>
237bool OPimAccessTemplate<T>::wasChangedExternally()const { 237bool OPimAccessTemplate<T>::wasChangedExternally()const {
238 return false; 238 return false;
239} 239}
240template <class T> 240template <class T>
241void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { 241void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) {
242 m_backEnd = end; 242 m_backEnd = end;
243 if (m_backEnd ) 243 if (m_backEnd )
244 m_backEnd->setFrontend( this ); 244 m_backEnd->setFrontend( this );
245} 245}
246template <class T> 246template <class T>
247void OPimAccessTemplate<T>::cache( const T& t ) const{ 247void OPimAccessTemplate<T>::cache( const T& t ) const{
248 /* hacky we need to work around the const*/ 248 /* hacky we need to work around the const*/
249 ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); 249 ((OPimAccessTemplate<T>*)this)->m_cache.add( t );
250} 250}
251template <class T> 251template <class T>
252void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { 252void OPimAccessTemplate<T>::setSaneCacheSize( int size ) {
253 m_cache.setSize( size ); 253 m_cache.setSize( size );
254} 254}
255template <class T> 255template <class T>
256void OPimAccessTemplate<T>::setReadAhead( uint count ) { 256void OPimAccessTemplate<T>::setReadAhead( uint count ) {
257 m_backEnd->setReadAhead( count ); 257 m_backEnd->setReadAhead( count );
258} 258}
259#endif 259#endif
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index 8ed41e2..b77a4ab 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -122,179 +122,179 @@ ORecordList( const QArray<int>& ids,
122 */ 122 */
123private: 123private:
124 QArray<int> m_ids; 124 QArray<int> m_ids;
125 const Base* m_acc; 125 const Base* m_acc;
126}; 126};
127 127
128/* ok now implement it */ 128/* ok now implement it */
129template <class T> 129template <class T>
130ORecordListIterator<T>::ORecordListIterator() { 130ORecordListIterator<T>::ORecordListIterator() {
131 m_current = 0; 131 m_current = 0;
132 m_temp = 0l; 132 m_temp = 0l;
133 m_end = true; 133 m_end = true;
134 m_record = T(); 134 m_record = T();
135 /* forward */ 135 /* forward */
136 m_direction = TRUE; 136 m_direction = TRUE;
137} 137}
138template <class T> 138template <class T>
139ORecordListIterator<T>::~ORecordListIterator() { 139ORecordListIterator<T>::~ORecordListIterator() {
140/* nothing to delete */ 140/* nothing to delete */
141} 141}
142 142
143template <class T> 143template <class T>
144ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 144ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
145// qWarning("ORecordListIterator copy c'tor"); 145// qWarning("ORecordListIterator copy c'tor");
146 m_uids = it.m_uids; 146 m_uids = it.m_uids;
147 m_current = it.m_current; 147 m_current = it.m_current;
148 m_temp = it.m_temp; 148 m_temp = it.m_temp;
149 m_end = it.m_end; 149 m_end = it.m_end;
150 m_record = it.m_record; 150 m_record = it.m_record;
151 m_direction = it.m_direction; 151 m_direction = it.m_direction;
152} 152}
153 153
154template <class T> 154template <class T>
155ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { 155ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
156 m_uids = it.m_uids; 156 m_uids = it.m_uids;
157 m_current = it.m_current; 157 m_current = it.m_current;
158 m_temp = it.m_temp; 158 m_temp = it.m_temp;
159 m_end = it.m_end; 159 m_end = it.m_end;
160 m_record = it.m_record; 160 m_record = it.m_record;
161 161
162 return *this; 162 return *this;
163} 163}
164 164
165template <class T> 165template <class T>
166T ORecordListIterator<T>::operator*() { 166T ORecordListIterator<T>::operator*() {
167 //qWarning("operator* %d %d", m_current, m_uids[m_current] ); 167 //qWarning("operator* %d %d", m_current, m_uids[m_current] );
168 if (!m_end ) 168 if (!m_end )
169 m_record = m_temp->find( m_uids[m_current], m_uids, m_current, 169 m_record = m_temp->find( m_uids[m_current], m_uids, m_current,
170 m_direction ? Base::Forward : 170 m_direction ? Base::Forward :
171 Base::Reverse ); 171 Base::Reverse );
172 else 172 else
173 m_record = T(); 173 m_record = T();
174 174
175 return m_record; 175 return m_record;
176} 176}
177 177
178template <class T> 178template <class T>
179ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 179ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
180 m_direction = true; 180 m_direction = true;
181 if (m_current < m_uids.count() ) { 181 if (m_current < m_uids.count() ) {
182 m_end = false; 182 m_end = false;
183 ++m_current; 183 ++m_current;
184 }else 184 }else
185 m_end = true; 185 m_end = true;
186 186
187 return *this; 187 return *this;
188} 188}
189template <class T> 189template <class T>
190ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 190ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
191 m_direction = false; 191 m_direction = false;
192 if ( m_current > 0 ) { 192 if ( m_current > 0 ) {
193 --m_current; 193 --m_current;
194 m_end = false; 194 m_end = false;
195 } else 195 } else
196 m_end = true; 196 m_end = true;
197 197
198 return *this; 198 return *this;
199} 199}
200 200
201template <class T> 201template <class T>
202bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { 202bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
203 203
204 /* if both are at we're the same.... */ 204 /* if both are at we're the same.... */
205 if ( m_end == it.m_end ) return true; 205 if ( m_end == it.m_end ) return true;
206 206
207 if ( m_uids != it.m_uids ) return false; 207 if ( m_uids != it.m_uids ) return false;
208 if ( m_current != it.m_current ) return false; 208 if ( m_current != it.m_current ) return false;
209 if ( m_temp != it.m_temp ) return false; 209 if ( m_temp != it.m_temp ) return false;
210 210
211 return true; 211 return true;
212} 212}
213template <class T> 213template <class T>
214bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 214bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
215 return !(*this == it ); 215 return !(*this == it );
216} 216}
217template <class T> 217template <class T>
218ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 218ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
219 const Base* t ) 219 const Base* t )
220 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), 220 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ),
221 m_direction( false ) 221 m_direction( false )
222{ 222{
223} 223}
224template <class T> 224template <class T>
225uint ORecordListIterator<T>::current()const { 225uint ORecordListIterator<T>::current()const {
226 return m_current; 226 return m_current;
227} 227}
228template <class T> 228template <class T>
229void ORecordListIterator<T>::setCurrent( uint cur ) { 229void ORecordListIterator<T>::setCurrent( uint cur ) {
230 if( cur < m_uids.count() ) { 230 if( cur < m_uids.count() ) {
231 m_end = false; 231 m_end = false;
232 m_current= cur; 232 m_current= cur;
233 } 233 }
234} 234}
235template <class T> 235template <class T>
236uint ORecordListIterator<T>::count()const { 236uint ORecordListIterator<T>::count()const {
237 return m_uids.count(); 237 return m_uids.count();
238} 238}
239template <class T> 239template <class T>
240ORecordList<T>::ORecordList( const QArray<int>& ids, 240ORecordList<T>::ORecordList( const QArray<int>& ids,
241 const Base* acc ) 241 const Base* acc )
242 : m_ids( ids ), m_acc( acc ) 242 : m_ids( ids ), m_acc( acc )
243{ 243{
244} 244}
245template <class T> 245template <class T>
246ORecordList<T>::~ORecordList() { 246ORecordList<T>::~ORecordList() {
247/* nothing to do here */ 247/* nothing to do here */
248} 248}
249template <class T> 249template <class T>
250ORecordList<T>::Iterator ORecordList<T>::begin() { 250typename ORecordList<T>::Iterator ORecordList<T>::begin() {
251 Iterator it( m_ids, m_acc ); 251 Iterator it( m_ids, m_acc );
252 return it; 252 return it;
253} 253}
254template <class T> 254template <class T>
255ORecordList<T>::Iterator ORecordList<T>::end() { 255typename ORecordList<T>::Iterator ORecordList<T>::end() {
256 Iterator it( m_ids, m_acc ); 256 Iterator it( m_ids, m_acc );
257 it.m_end = true; 257 it.m_end = true;
258 it.m_current = m_ids.count(); 258 it.m_current = m_ids.count();
259 259
260 return it; 260 return it;
261} 261}
262template <class T> 262template <class T>
263uint ORecordList<T>::count()const { 263uint ORecordList<T>::count()const {
264return m_ids.count(); 264return m_ids.count();
265} 265}
266template <class T> 266template <class T>
267T ORecordList<T>::operator[]( uint i ) { 267T ORecordList<T>::operator[]( uint i ) {
268 if ( i < 0 || (i+1) > m_ids.count() ) 268 if ( i < 0 || (i+1) > m_ids.count() )
269 return T(); 269 return T();
270 /* forward */ 270 /* forward */
271 return m_acc->find( m_ids[i], m_ids, i ); 271 return m_acc->find( m_ids[i], m_ids, i );
272} 272}
273template <class T> 273template <class T>
274int ORecordList<T>::uidAt( uint i ) { 274int ORecordList<T>::uidAt( uint i ) {
275 return m_ids[i]; 275 return m_ids[i];
276} 276}
277 277
278template <class T> 278template <class T>
279bool ORecordList<T>::remove( int uid ) { 279bool ORecordList<T>::remove( int uid ) {
280 QArray<int> copy( m_ids.count() ); 280 QArray<int> copy( m_ids.count() );
281 int counter = 0; 281 int counter = 0;
282 bool ret_val = false; 282 bool ret_val = false;
283 283
284 for (uint i = 0; i < m_ids.count(); i++){ 284 for (uint i = 0; i < m_ids.count(); i++){
285 if ( m_ids[i] != uid ){ 285 if ( m_ids[i] != uid ){
286 copy[counter++] = m_ids[i]; 286 copy[counter++] = m_ids[i];
287 287
288 }else 288 }else
289 ret_val = true; 289 ret_val = true;
290 } 290 }
291 291
292 copy.resize( counter ); 292 copy.resize( counter );
293 m_ids = copy; 293 m_ids = copy;
294 294
295 295
296 return ret_val; 296 return ret_val;
297} 297}
298 298
299 299
300#endif 300#endif
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index 0d5b1d3..4d5cb79 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -274,132 +274,132 @@ bool OTodo::operator<=(const OTodo &toDoEvent )const
274 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 274 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
275 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 275 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
276 if( hasDueDate() && toDoEvent.hasDueDate() ){ 276 if( hasDueDate() && toDoEvent.hasDueDate() ){
277 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 277 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
278 return priority() <= toDoEvent.priority(); 278 return priority() <= toDoEvent.priority();
279 }else{ 279 }else{
280 return dueDate() <= toDoEvent.dueDate(); 280 return dueDate() <= toDoEvent.dueDate();
281 } 281 }
282 } 282 }
283 return true; 283 return true;
284} 284}
285bool OTodo::operator>(const OTodo &toDoEvent )const 285bool OTodo::operator>(const OTodo &toDoEvent )const
286{ 286{
287 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 287 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
288 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 288 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
289 if( hasDueDate() && toDoEvent.hasDueDate() ){ 289 if( hasDueDate() && toDoEvent.hasDueDate() ){
290 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 290 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
291 return priority() > toDoEvent.priority(); 291 return priority() > toDoEvent.priority();
292 }else{ 292 }else{
293 return dueDate() > toDoEvent.dueDate(); 293 return dueDate() > toDoEvent.dueDate();
294 } 294 }
295 } 295 }
296 return false; 296 return false;
297} 297}
298bool OTodo::operator>=(const OTodo &toDoEvent )const 298bool OTodo::operator>=(const OTodo &toDoEvent )const
299{ 299{
300 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 300 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
301 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 301 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
302 if( hasDueDate() && toDoEvent.hasDueDate() ){ 302 if( hasDueDate() && toDoEvent.hasDueDate() ){
303 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 303 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
304 return priority() > toDoEvent.priority(); 304 return priority() > toDoEvent.priority();
305 }else{ 305 }else{
306 return dueDate() > toDoEvent.dueDate(); 306 return dueDate() > toDoEvent.dueDate();
307 } 307 }
308 } 308 }
309 return true; 309 return true;
310} 310}
311bool OTodo::operator==(const OTodo &toDoEvent )const 311bool OTodo::operator==(const OTodo &toDoEvent )const
312{ 312{
313 if ( data->priority != toDoEvent.data->priority ) return false; 313 if ( data->priority != toDoEvent.data->priority ) return false;
314 if ( data->priority != toDoEvent.data->prog ) return false; 314 if ( data->priority != toDoEvent.data->prog ) return false;
315 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 315 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
316 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 316 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
317 if ( data->date != toDoEvent.data->date ) return false; 317 if ( data->date != toDoEvent.data->date ) return false;
318 if ( data->sum != toDoEvent.data->sum ) return false; 318 if ( data->sum != toDoEvent.data->sum ) return false;
319 if ( data->desc != toDoEvent.data->desc ) return false; 319 if ( data->desc != toDoEvent.data->desc ) return false;
320 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) 320 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
321 return false; 321 return false;
322 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) 322 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
323 return false; 323 return false;
324 324
325 return OPimRecord::operator==( toDoEvent ); 325 return OPimRecord::operator==( toDoEvent );
326} 326}
327void OTodo::deref() { 327void OTodo::deref() {
328 328
329// qWarning("deref in ToDoEvent"); 329// qWarning("deref in ToDoEvent");
330 if ( data->deref() ) { 330 if ( data->deref() ) {
331// qWarning("deleting"); 331// qWarning("deleting");
332 delete data; 332 delete data;
333 data= 0; 333 data= 0;
334 } 334 }
335} 335}
336OTodo &OTodo::operator=(const OTodo &item ) 336OTodo &OTodo::operator=(const OTodo &item )
337{ 337{
338 OPimRecord::operator=( item ); 338 OPimRecord::operator=( item );
339 //qWarning("operator= ref "); 339 //qWarning("operator= ref ");
340 item.data->ref(); 340 item.data->ref();
341 deref(); 341 deref();
342 data = item.data; 342 data = item.data;
343 343
344 return *this; 344 return *this;
345} 345}
346 346
347QMap<int, QString> OTodo::toMap() const { 347QMap<int, QString> OTodo::toMap() const {
348 QMap<int, QString> map; 348 QMap<int, QString> map;
349 349
350 map.insert( Uid, QString::number( uid() ) ); 350 map.insert( Uid, QString::number( uid() ) );
351 map.insert( Category, idsToString( categories() ) ); 351 map.insert( Category, idsToString( categories() ) );
352 map.insert( HasDate, QString::number( data->hasDate ) ); 352 map.insert( HasDate, QString::number( data->hasDate ) );
353 map.insert( Completed, QString::number( data->isCompleted ) ); 353 map.insert( Completed, QString::number( data->isCompleted ) );
354 map.insert( Description, data->desc ); 354 map.insert( Description, data->desc );
355 map.insert( Summary, data->sum ); 355 map.insert( Summary, data->sum );
356 map.insert( Priority, QString::number( data->priority ) ); 356 map.insert( Priority, QString::number( data->priority ) );
357 map.insert( DateDay, QString::number( data->date.day() ) ); 357 map.insert( DateDay, QString::number( data->date.day() ) );
358 map.insert( DateMonth, QString::number( data->date.month() ) ); 358 map.insert( DateMonth, QString::number( data->date.month() ) );
359 map.insert( DateYear, QString::number( data->date.year() ) ); 359 map.insert( DateYear, QString::number( data->date.year() ) );
360 map.insert( Progress, QString::number( data->prog ) ); 360 map.insert( Progress, QString::number( data->prog ) );
361 map.insert( CrossReference, crossToString() ); 361 map.insert( CrossReference, crossToString() );
362 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); 362 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
363 map.insert( AlarmDateTime, data->alarmDateTime.toString() ); 363 map.insert( AlarmDateTime, data->alarmDateTime.toString() );
364 364
365 return map; 365 return map;
366} 366}
367 367
368QMap<QString, QString> OTodo::toExtraMap()const { 368QMap<QString, QString> OTodo::toExtraMap()const {
369 return data->extra; 369 return data->extra;
370} 370}
371/** 371/**
372 * change or modify looks at the ref count and either 372 * change or modify looks at the ref count and either
373 * creates a new QShared Object or it can modify it 373 * creates a new QShared Object or it can modify it
374 * right in place 374 * right in place
375 */ 375 */
376void OTodo::changeOrModify() { 376void OTodo::changeOrModify() {
377 if ( data->count != 1 ) { 377 if ( data->count != 1 ) {
378 qWarning("changeOrModify"); 378 qWarning("changeOrModify");
379 data->deref(); 379 data->deref();
380 OTodoData* d2 = new OTodoData(); 380 OTodoData* d2 = new OTodoData();
381 copy(data, d2 ); 381 copy(data, d2 );
382 data = d2; 382 data = d2;
383 } 383 }
384} 384}
385void OTodo::copy( OTodoData* src, OTodoData* dest ) { 385void OTodo::copy( OTodoData* src, OTodoData* dest ) {
386 dest->date = src->date; 386 dest->date = src->date;
387 dest->isCompleted = src->isCompleted; 387 dest->isCompleted = src->isCompleted;
388 dest->hasDate = src->hasDate; 388 dest->hasDate = src->hasDate;
389 dest->priority = src->priority; 389 dest->priority = src->priority;
390 dest->desc = src->desc; 390 dest->desc = src->desc;
391 dest->sum = src->sum; 391 dest->sum = src->sum;
392 dest->extra = src->extra; 392 dest->extra = src->extra;
393 dest->prog = src->prog; 393 dest->prog = src->prog;
394 dest->hasAlarmDateTime = src->hasAlarmDateTime; 394 dest->hasAlarmDateTime = src->hasAlarmDateTime;
395 dest->alarmDateTime = src->alarmDateTime; 395 dest->alarmDateTime = src->alarmDateTime;
396 dest->state = src->state; 396 dest->state = src->state;
397 dest->recur = src->recur; 397 dest->recur = src->recur;
398} 398}
399QString OTodo::type() const { 399QString OTodo::type() const {
400 return QString::fromLatin1("OTodo"); 400 return QString::fromLatin1("OTodo");
401} 401}
402QString OTodo::recordField(int id )const { 402QString OTodo::recordField(int /*id*/ )const {
403 return QString::null; 403 return QString::null;
404} 404}
405 405
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 0bd2723..4f00bc9 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -1,141 +1,141 @@
1#ifndef OPIE_PIM_ACCESS_BACKEND 1#ifndef OPIE_PIM_ACCESS_BACKEND
2#define OPIE_PIM_ACCESS_BACKEND 2#define OPIE_PIM_ACCESS_BACKEND
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/otemplatebase.h> 6#include <opie/otemplatebase.h>
7#include <opie/opimrecord.h> 7#include <opie/opimrecord.h>
8 8
9 9
10/** 10/**
11 * OPimAccessBackend is the base class 11 * OPimAccessBackend is the base class
12 * for all private backends 12 * for all private backends
13 * it operates on OPimRecord as the base class 13 * it operates on OPimRecord as the base class
14 * and it's responsible for fast manipulating 14 * and it's responsible for fast manipulating
15 * the resource the implementation takes care 15 * the resource the implementation takes care
16 * of 16 * of
17 */ 17 */
18template <class T = OPimRecord> 18template <class T = OPimRecord>
19class OPimAccessBackend { 19class OPimAccessBackend {
20public: 20public:
21 typedef OTemplateBase<T> Frontend; 21 typedef OTemplateBase<T> Frontend;
22 OPimAccessBackend(); 22 OPimAccessBackend();
23 virtual ~OPimAccessBackend(); 23 virtual ~OPimAccessBackend();
24 24
25 /** 25 /**
26 * load the resource 26 * load the resource
27 */ 27 */
28 virtual bool load() = 0; 28 virtual bool load() = 0;
29 29
30 /** 30 /**
31 * reload the resource 31 * reload the resource
32 */ 32 */
33 virtual bool reload() = 0; 33 virtual bool reload() = 0;
34 34
35 /** 35 /**
36 * save the resource and 36 * save the resource and
37 * all it's changes 37 * all it's changes
38 */ 38 */
39 virtual bool save() = 0; 39 virtual bool save() = 0;
40 40
41 /** 41 /**
42 * return an array of 42 * return an array of
43 * all available uids 43 * all available uids
44 */ 44 */
45 virtual QArray<int> allRecords()const = 0; 45 virtual QArray<int> allRecords()const = 0;
46 46
47 /** 47 /**
48 * queryByExample for T with the SortOrder 48 * queryByExample for T with the SortOrder
49 * sort 49 * sort
50 */ 50 */
51 virtual QArray<int> queryByExample( const T& t, int sort ) = 0; 51 virtual QArray<int> queryByExample( const T& t, int sort ) = 0;
52 52
53 /** 53 /**
54 * find the OPimRecord with uid @param uid 54 * find the OPimRecord with uid @param uid
55 * returns T and T.isEmpty() if nothing was found 55 * returns T and T.isEmpty() if nothing was found
56 */ 56 */
57 virtual T find(int uid )const = 0; 57 virtual T find(int uid )const = 0;
58 58
59 virtual T find(int uid, const QArray<int>& items, 59 virtual T find(int uid, const QArray<int>& items,
60 uint current, Frontend::CacheDirection )const ; 60 uint current, typename Frontend::CacheDirection )const ;
61 /** 61 /**
62 * clear the back end 62 * clear the back end
63 */ 63 */
64 virtual void clear() = 0; 64 virtual void clear() = 0;
65 65
66 /** 66 /**
67 * add T 67 * add T
68 */ 68 */
69 virtual bool add( const T& t ) = 0; 69 virtual bool add( const T& t ) = 0;
70 70
71 /** 71 /**
72 * remove 72 * remove
73 */ 73 */
74 virtual bool remove( int uid ) = 0; 74 virtual bool remove( int uid ) = 0;
75 75
76 /** 76 /**
77 * replace a record with T.uid() 77 * replace a record with T.uid()
78 */ 78 */
79 virtual bool replace( const T& t ) = 0; 79 virtual bool replace( const T& t ) = 0;
80 80
81 /* 81 /*
82 * setTheFrontEnd!!! 82 * setTheFrontEnd!!!
83 */ 83 */
84 void setFrontend( Frontend* front ); 84 void setFrontend( Frontend* front );
85 85
86 /** 86 /**
87 * set the read ahead count 87 * set the read ahead count
88 */ 88 */
89 void setReadAhead( uint count ); 89 void setReadAhead( uint count );
90protected: 90protected:
91 void cache( const T& t )const; 91 void cache( const T& t )const;
92 92
93 /** 93 /**
94 * use a prime number here! 94 * use a prime number here!
95 */ 95 */
96 void setSaneCacheSize( int ); 96 void setSaneCacheSize( int );
97 97
98 uint readAhead()const; 98 uint readAhead()const;
99 99
100private: 100private:
101 Frontend* m_front; 101 Frontend* m_front;
102 uint m_read; 102 uint m_read;
103 103
104}; 104};
105 105
106template <class T> 106template <class T>
107OPimAccessBackend<T>::OPimAccessBackend() { 107OPimAccessBackend<T>::OPimAccessBackend() {
108 m_front = 0l; 108 m_front = 0l;
109} 109}
110template <class T> 110template <class T>
111OPimAccessBackend<T>::~OPimAccessBackend() { 111OPimAccessBackend<T>::~OPimAccessBackend() {
112 112
113} 113}
114template <class T> 114template <class T>
115void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 115void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
116 m_front = fr; 116 m_front = fr;
117} 117}
118template <class T> 118template <class T>
119void OPimAccessBackend<T>::cache( const T& t )const { 119void OPimAccessBackend<T>::cache( const T& t )const {
120 if (m_front ) 120 if (m_front )
121 m_front->cache( t ); 121 m_front->cache( t );
122} 122}
123template <class T> 123template <class T>
124void OPimAccessBackend<T>::setSaneCacheSize( int size) { 124void OPimAccessBackend<T>::setSaneCacheSize( int size) {
125 if (m_front ) 125 if (m_front )
126 m_front->setSaneCacheSize( size ); 126 m_front->setSaneCacheSize( size );
127} 127}
128template <class T> 128template <class T>
129T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 129T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
130 uint, Frontend::CacheDirection )const { 130 uint, typename Frontend::CacheDirection )const {
131 return find( uid ); 131 return find( uid );
132} 132}
133template <class T> 133template <class T>
134void OPimAccessBackend<T>::setReadAhead( uint count ) { 134void OPimAccessBackend<T>::setReadAhead( uint count ) {
135 m_read = count; 135 m_read = count;
136} 136}
137template <class T> 137template <class T>
138uint OPimAccessBackend<T>::readAhead()const { 138uint OPimAccessBackend<T>::readAhead()const {
139 return m_read; 139 return m_read;
140} 140}
141#endif 141#endif
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index c5523a8..6de68b1 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -1,259 +1,259 @@
1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H 1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H
2#define OPIE_PIM_ACCESS_TEMPLATE_H 2#define OPIE_PIM_ACCESS_TEMPLATE_H
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/opimrecord.h> 6#include <opie/opimrecord.h>
7#include <opie/opimaccessbackend.h> 7#include <opie/opimaccessbackend.h>
8#include <opie/orecordlist.h> 8#include <opie/orecordlist.h>
9 9
10#include "opimcache.h" 10#include "opimcache.h"
11#include "otemplatebase.h" 11#include "otemplatebase.h"
12 12
13/** 13/**
14 * Thats the frontend to our OPIE PIM 14 * Thats the frontend to our OPIE PIM
15 * Library. Either you want to use it's 15 * Library. Either you want to use it's
16 * interface or you want to implement 16 * interface or you want to implement
17 * your own Access lib 17 * your own Access lib
18 * Just create a OPimRecord and inherit from 18 * Just create a OPimRecord and inherit from
19 * the plugins 19 * the plugins
20 */ 20 */
21 21
22template <class T = OPimRecord > 22template <class T = OPimRecord >
23class OPimAccessTemplate : public OTemplateBase<T> { 23class OPimAccessTemplate : public OTemplateBase<T> {
24public: 24public:
25 typedef ORecordList<T> List; 25 typedef ORecordList<T> List;
26 typedef OPimAccessBackend<T> BackEnd; 26 typedef OPimAccessBackend<T> BackEnd;
27 typedef OPimCache<T> Cache; 27 typedef OPimCache<T> Cache;
28 28
29 /** 29 /**
30 * c'tor BackEnd 30 * c'tor BackEnd
31 */ 31 */
32 OPimAccessTemplate( BackEnd* end); 32 OPimAccessTemplate( BackEnd* end);
33 virtual ~OPimAccessTemplate(); 33 virtual ~OPimAccessTemplate();
34 34
35 /** 35 /**
36 * load from the backend 36 * load from the backend
37 */ 37 */
38 virtual bool load(); 38 virtual bool load();
39 39
40 /** Reload database. 40 /** Reload database.
41 * You should execute this function if the external database 41 * You should execute this function if the external database
42 * was changed. 42 * was changed.
43 * This function will load the external database and afterwards 43 * This function will load the external database and afterwards
44 * rejoin the local changes. Therefore the local database will be set consistent. 44 * rejoin the local changes. Therefore the local database will be set consistent.
45 */ 45 */
46 virtual bool reload(); 46 virtual bool reload();
47 47
48 /** Save contacts database. 48 /** Save contacts database.
49 * Save is more a "commit". After calling this function, all changes are public available. 49 * Save is more a "commit". After calling this function, all changes are public available.
50 * @return true if successful 50 * @return true if successful
51 */ 51 */
52 virtual bool save(); 52 virtual bool save();
53 53
54 /** 54 /**
55 * if the resource was changed externally 55 * if the resource was changed externally
56 * You should use the signal handling instead of polling possible changes ! 56 * You should use the signal handling instead of polling possible changes !
57 * zecke: Do you implement a signal for otodoaccess ? 57 * zecke: Do you implement a signal for otodoaccess ?
58 */ 58 */
59 bool wasChangedExternally()const; 59 bool wasChangedExternally()const;
60 60
61 /** 61 /**
62 * return a List of records 62 * return a List of records
63 * you can iterate over them 63 * you can iterate over them
64 */ 64 */
65 virtual List allRecords()const; 65 virtual List allRecords()const;
66 66
67 /** 67 /**
68 * queryByExample. 68 * queryByExample.
69 * @see otodoaccess, ocontactaccess 69 * @see otodoaccess, ocontactaccess
70 */ 70 */
71 virtual List queryByExample( const T& t, int querySettings ); 71 virtual List queryByExample( const T& t, int querySettings );
72 72
73 /** 73 /**
74 * find the OPimRecord uid 74 * find the OPimRecord uid
75 */ 75 */
76 virtual T find( int uid )const; 76 virtual T find( int uid )const;
77 77
78 /** 78 /**
79 * read ahead cache find method ;) 79 * read ahead cache find method ;)
80 */ 80 */
81 virtual T find( int uid, const QArray<int>&, 81 virtual T find( int uid, const QArray<int>&,
82 uint current, CacheDirection dir = Forward )const; 82 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
83 83
84 /* invalidate cache here */ 84 /* invalidate cache here */
85 /** 85 /**
86 * clears the backend and invalidates the backend 86 * clears the backend and invalidates the backend
87 */ 87 */
88 virtual void clear() ; 88 virtual void clear() ;
89 89
90 /** 90 /**
91 * add T to the backend 91 * add T to the backend
92 * @param t The item to add. 92 * @param t The item to add.
93 * @return <i>true</i> if added successfully. 93 * @return <i>true</i> if added successfully.
94 */ 94 */
95 virtual bool add( const T& t ) ; 95 virtual bool add( const T& t ) ;
96 96
97 /* only the uid matters */ 97 /* only the uid matters */
98 /** 98 /**
99 * remove T from the backend 99 * remove T from the backend
100 * @param t The item to remove 100 * @param t The item to remove
101 * @return <i>true</i> if successful. 101 * @return <i>true</i> if successful.
102 */ 102 */
103 virtual bool remove( const T& t ); 103 virtual bool remove( const T& t );
104 104
105 /** 105 /**
106 * remove the OPimRecord with uid 106 * remove the OPimRecord with uid
107 * @param uid The ID of the item to remove 107 * @param uid The ID of the item to remove
108 * @return <i>true</i> if successful. 108 * @return <i>true</i> if successful.
109 */ 109 */
110 virtual bool remove( int uid ); 110 virtual bool remove( int uid );
111 111
112 /** 112 /**
113 * replace T from backend 113 * replace T from backend
114 * @param t The item to replace 114 * @param t The item to replace
115 * @return <i>true</i> if successful. 115 * @return <i>true</i> if successful.
116 */ 116 */
117 virtual bool replace( const T& t) ; 117 virtual bool replace( const T& t) ;
118 118
119 void setReadAhead( uint count ); 119 void setReadAhead( uint count );
120 /** 120 /**
121 * @internal 121 * @internal
122 */ 122 */
123 void cache( const T& )const; 123 void cache( const T& )const;
124 void setSaneCacheSize( int ); 124 void setSaneCacheSize( int );
125protected: 125protected:
126 /** 126 /**
127 * invalidate the cache 127 * invalidate the cache
128 */ 128 */
129 void invalidateCache(); 129 void invalidateCache();
130 130
131 void setBackEnd( BackEnd* end ); 131 void setBackEnd( BackEnd* end );
132 /** 132 /**
133 * returns the backend 133 * returns the backend
134 */ 134 */
135 BackEnd* backEnd(); 135 BackEnd* backEnd();
136 BackEnd* m_backEnd; 136 BackEnd* m_backEnd;
137 Cache m_cache; 137 Cache m_cache;
138 138
139}; 139};
140 140
141template <class T> 141template <class T>
142OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) 142OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end )
143 : OTemplateBase<T>(), m_backEnd( end ) 143 : OTemplateBase<T>(), m_backEnd( end )
144{ 144{
145 if (end ) 145 if (end )
146 end->setFrontend( this ); 146 end->setFrontend( this );
147} 147}
148template <class T> 148template <class T>
149OPimAccessTemplate<T>::~OPimAccessTemplate() { 149OPimAccessTemplate<T>::~OPimAccessTemplate() {
150 qWarning("~OPimAccessTemplate<T>"); 150 qWarning("~OPimAccessTemplate<T>");
151 delete m_backEnd; 151 delete m_backEnd;
152} 152}
153template <class T> 153template <class T>
154bool OPimAccessTemplate<T>::load() { 154bool OPimAccessTemplate<T>::load() {
155 invalidateCache(); 155 invalidateCache();
156 return m_backEnd->load(); 156 return m_backEnd->load();
157} 157}
158template <class T> 158template <class T>
159bool OPimAccessTemplate<T>::reload() { 159bool OPimAccessTemplate<T>::reload() {
160 invalidateCache(); // zecke: I think this should be added (se) 160 invalidateCache(); // zecke: I think this should be added (se)
161 return m_backEnd->reload(); 161 return m_backEnd->reload();
162} 162}
163template <class T> 163template <class T>
164bool OPimAccessTemplate<T>::save() { 164bool OPimAccessTemplate<T>::save() {
165 return m_backEnd->save(); 165 return m_backEnd->save();
166} 166}
167template <class T> 167template <class T>
168OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { 168typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
169 QArray<int> ints = m_backEnd->allRecords(); 169 QArray<int> ints = m_backEnd->allRecords();
170 List lis(ints, this ); 170 List lis(ints, this );
171 return lis; 171 return lis;
172} 172}
173template <class T> 173template <class T>
174OPimAccessTemplate<T>::List 174typename OPimAccessTemplate<T>::List
175OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) { 175OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) {
176 QArray<int> ints = m_backEnd->queryByExample( t, sortOrder ); 176 QArray<int> ints = m_backEnd->queryByExample( t, sortOrder );
177 177
178 List lis(ints, this ); 178 List lis(ints, this );
179 return lis; 179 return lis;
180} 180}
181template <class T> 181template <class T>
182T OPimAccessTemplate<T>::find( int uid ) const{ 182T OPimAccessTemplate<T>::find( int uid ) const{
183 T t = m_backEnd->find( uid ); 183 T t = m_backEnd->find( uid );
184 cache( t ); 184 cache( t );
185 return t; 185 return t;
186} 186}
187template <class T> 187template <class T>
188T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, 188T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
189 uint current, CacheDirection dir )const { 189 uint current, typename OTemplateBase<T>::CacheDirection dir )const {
190 /* 190 /*
191 * better do T.isEmpty() 191 * better do T.isEmpty()
192 * after a find this way we would 192 * after a find this way we would
193 * avoid two finds in QCache... 193 * avoid two finds in QCache...
194 */ 194 */
195 // qWarning("find it now %d", uid ); 195 // qWarning("find it now %d", uid );
196 if (m_cache.contains( uid ) ) { 196 if (m_cache.contains( uid ) ) {
197 return m_cache.find( uid ); 197 return m_cache.find( uid );
198 } 198 }
199 199
200 T t = m_backEnd->find( uid, ar, current, dir ); 200 T t = m_backEnd->find( uid, ar, current, dir );
201 cache( t ); 201 cache( t );
202 return t; 202 return t;
203} 203}
204template <class T> 204template <class T>
205void OPimAccessTemplate<T>::clear() { 205void OPimAccessTemplate<T>::clear() {
206 invalidateCache(); 206 invalidateCache();
207 m_backEnd->clear(); 207 m_backEnd->clear();
208} 208}
209template <class T> 209template <class T>
210bool OPimAccessTemplate<T>::add( const T& t ) { 210bool OPimAccessTemplate<T>::add( const T& t ) {
211 cache( t ); 211 cache( t );
212 return m_backEnd->add( t ); 212 return m_backEnd->add( t );
213} 213}
214template <class T> 214template <class T>
215bool OPimAccessTemplate<T>::remove( const T& t ) { 215bool OPimAccessTemplate<T>::remove( const T& t ) {
216 return remove( t.uid() ); 216 return remove( t.uid() );
217} 217}
218template <class T> 218template <class T>
219bool OPimAccessTemplate<T>::remove( int uid ) { 219bool OPimAccessTemplate<T>::remove( int uid ) {
220 m_cache.remove( uid ); 220 m_cache.remove( uid );
221 return m_backEnd->remove( uid ); 221 return m_backEnd->remove( uid );
222} 222}
223template <class T> 223template <class T>
224bool OPimAccessTemplate<T>::replace( const T& t ) { 224bool OPimAccessTemplate<T>::replace( const T& t ) {
225 m_cache.replace( t ); 225 m_cache.replace( t );
226 return m_backEnd->replace( t ); 226 return m_backEnd->replace( t );
227} 227}
228template <class T> 228template <class T>
229void OPimAccessTemplate<T>::invalidateCache() { 229void OPimAccessTemplate<T>::invalidateCache() {
230 m_cache.invalidate(); 230 m_cache.invalidate();
231} 231}
232template <class T> 232template <class T>
233OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { 233typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() {
234 return m_backEnd; 234 return m_backEnd;
235} 235}
236template <class T> 236template <class T>
237bool OPimAccessTemplate<T>::wasChangedExternally()const { 237bool OPimAccessTemplate<T>::wasChangedExternally()const {
238 return false; 238 return false;
239} 239}
240template <class T> 240template <class T>
241void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { 241void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) {
242 m_backEnd = end; 242 m_backEnd = end;
243 if (m_backEnd ) 243 if (m_backEnd )
244 m_backEnd->setFrontend( this ); 244 m_backEnd->setFrontend( this );
245} 245}
246template <class T> 246template <class T>
247void OPimAccessTemplate<T>::cache( const T& t ) const{ 247void OPimAccessTemplate<T>::cache( const T& t ) const{
248 /* hacky we need to work around the const*/ 248 /* hacky we need to work around the const*/
249 ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); 249 ((OPimAccessTemplate<T>*)this)->m_cache.add( t );
250} 250}
251template <class T> 251template <class T>
252void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { 252void OPimAccessTemplate<T>::setSaneCacheSize( int size ) {
253 m_cache.setSize( size ); 253 m_cache.setSize( size );
254} 254}
255template <class T> 255template <class T>
256void OPimAccessTemplate<T>::setReadAhead( uint count ) { 256void OPimAccessTemplate<T>::setReadAhead( uint count ) {
257 m_backEnd->setReadAhead( count ); 257 m_backEnd->setReadAhead( count );
258} 258}
259#endif 259#endif
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index 8ed41e2..b77a4ab 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -122,179 +122,179 @@ ORecordList( const QArray<int>& ids,
122 */ 122 */
123private: 123private:
124 QArray<int> m_ids; 124 QArray<int> m_ids;
125 const Base* m_acc; 125 const Base* m_acc;
126}; 126};
127 127
128/* ok now implement it */ 128/* ok now implement it */
129template <class T> 129template <class T>
130ORecordListIterator<T>::ORecordListIterator() { 130ORecordListIterator<T>::ORecordListIterator() {
131 m_current = 0; 131 m_current = 0;
132 m_temp = 0l; 132 m_temp = 0l;
133 m_end = true; 133 m_end = true;
134 m_record = T(); 134 m_record = T();
135 /* forward */ 135 /* forward */
136 m_direction = TRUE; 136 m_direction = TRUE;
137} 137}
138template <class T> 138template <class T>
139ORecordListIterator<T>::~ORecordListIterator() { 139ORecordListIterator<T>::~ORecordListIterator() {
140/* nothing to delete */ 140/* nothing to delete */
141} 141}
142 142
143template <class T> 143template <class T>
144ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 144ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
145// qWarning("ORecordListIterator copy c'tor"); 145// qWarning("ORecordListIterator copy c'tor");
146 m_uids = it.m_uids; 146 m_uids = it.m_uids;
147 m_current = it.m_current; 147 m_current = it.m_current;
148 m_temp = it.m_temp; 148 m_temp = it.m_temp;
149 m_end = it.m_end; 149 m_end = it.m_end;
150 m_record = it.m_record; 150 m_record = it.m_record;
151 m_direction = it.m_direction; 151 m_direction = it.m_direction;
152} 152}
153 153
154template <class T> 154template <class T>
155ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { 155ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
156 m_uids = it.m_uids; 156 m_uids = it.m_uids;
157 m_current = it.m_current; 157 m_current = it.m_current;
158 m_temp = it.m_temp; 158 m_temp = it.m_temp;
159 m_end = it.m_end; 159 m_end = it.m_end;
160 m_record = it.m_record; 160 m_record = it.m_record;
161 161
162 return *this; 162 return *this;
163} 163}
164 164
165template <class T> 165template <class T>
166T ORecordListIterator<T>::operator*() { 166T ORecordListIterator<T>::operator*() {
167 //qWarning("operator* %d %d", m_current, m_uids[m_current] ); 167 //qWarning("operator* %d %d", m_current, m_uids[m_current] );
168 if (!m_end ) 168 if (!m_end )
169 m_record = m_temp->find( m_uids[m_current], m_uids, m_current, 169 m_record = m_temp->find( m_uids[m_current], m_uids, m_current,
170 m_direction ? Base::Forward : 170 m_direction ? Base::Forward :
171 Base::Reverse ); 171 Base::Reverse );
172 else 172 else
173 m_record = T(); 173 m_record = T();
174 174
175 return m_record; 175 return m_record;
176} 176}
177 177
178template <class T> 178template <class T>
179ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 179ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
180 m_direction = true; 180 m_direction = true;
181 if (m_current < m_uids.count() ) { 181 if (m_current < m_uids.count() ) {
182 m_end = false; 182 m_end = false;
183 ++m_current; 183 ++m_current;
184 }else 184 }else
185 m_end = true; 185 m_end = true;
186 186
187 return *this; 187 return *this;
188} 188}
189template <class T> 189template <class T>
190ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 190ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
191 m_direction = false; 191 m_direction = false;
192 if ( m_current > 0 ) { 192 if ( m_current > 0 ) {
193 --m_current; 193 --m_current;
194 m_end = false; 194 m_end = false;
195 } else 195 } else
196 m_end = true; 196 m_end = true;
197 197
198 return *this; 198 return *this;
199} 199}
200 200
201template <class T> 201template <class T>
202bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { 202bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
203 203
204 /* if both are at we're the same.... */ 204 /* if both are at we're the same.... */
205 if ( m_end == it.m_end ) return true; 205 if ( m_end == it.m_end ) return true;
206 206
207 if ( m_uids != it.m_uids ) return false; 207 if ( m_uids != it.m_uids ) return false;
208 if ( m_current != it.m_current ) return false; 208 if ( m_current != it.m_current ) return false;
209 if ( m_temp != it.m_temp ) return false; 209 if ( m_temp != it.m_temp ) return false;
210 210
211 return true; 211 return true;
212} 212}
213template <class T> 213template <class T>
214bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 214bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
215 return !(*this == it ); 215 return !(*this == it );
216} 216}
217template <class T> 217template <class T>
218ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 218ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
219 const Base* t ) 219 const Base* t )
220 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), 220 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ),
221 m_direction( false ) 221 m_direction( false )
222{ 222{
223} 223}
224template <class T> 224template <class T>
225uint ORecordListIterator<T>::current()const { 225uint ORecordListIterator<T>::current()const {
226 return m_current; 226 return m_current;
227} 227}
228template <class T> 228template <class T>
229void ORecordListIterator<T>::setCurrent( uint cur ) { 229void ORecordListIterator<T>::setCurrent( uint cur ) {
230 if( cur < m_uids.count() ) { 230 if( cur < m_uids.count() ) {
231 m_end = false; 231 m_end = false;
232 m_current= cur; 232 m_current= cur;
233 } 233 }
234} 234}
235template <class T> 235template <class T>
236uint ORecordListIterator<T>::count()const { 236uint ORecordListIterator<T>::count()const {
237 return m_uids.count(); 237 return m_uids.count();
238} 238}
239template <class T> 239template <class T>
240ORecordList<T>::ORecordList( const QArray<int>& ids, 240ORecordList<T>::ORecordList( const QArray<int>& ids,
241 const Base* acc ) 241 const Base* acc )
242 : m_ids( ids ), m_acc( acc ) 242 : m_ids( ids ), m_acc( acc )
243{ 243{
244} 244}
245template <class T> 245template <class T>
246ORecordList<T>::~ORecordList() { 246ORecordList<T>::~ORecordList() {
247/* nothing to do here */ 247/* nothing to do here */
248} 248}
249template <class T> 249template <class T>
250ORecordList<T>::Iterator ORecordList<T>::begin() { 250typename ORecordList<T>::Iterator ORecordList<T>::begin() {
251 Iterator it( m_ids, m_acc ); 251 Iterator it( m_ids, m_acc );
252 return it; 252 return it;
253} 253}
254template <class T> 254template <class T>
255ORecordList<T>::Iterator ORecordList<T>::end() { 255typename ORecordList<T>::Iterator ORecordList<T>::end() {
256 Iterator it( m_ids, m_acc ); 256 Iterator it( m_ids, m_acc );
257 it.m_end = true; 257 it.m_end = true;
258 it.m_current = m_ids.count(); 258 it.m_current = m_ids.count();
259 259
260 return it; 260 return it;
261} 261}
262template <class T> 262template <class T>
263uint ORecordList<T>::count()const { 263uint ORecordList<T>::count()const {
264return m_ids.count(); 264return m_ids.count();
265} 265}
266template <class T> 266template <class T>
267T ORecordList<T>::operator[]( uint i ) { 267T ORecordList<T>::operator[]( uint i ) {
268 if ( i < 0 || (i+1) > m_ids.count() ) 268 if ( i < 0 || (i+1) > m_ids.count() )
269 return T(); 269 return T();
270 /* forward */ 270 /* forward */
271 return m_acc->find( m_ids[i], m_ids, i ); 271 return m_acc->find( m_ids[i], m_ids, i );
272} 272}
273template <class T> 273template <class T>
274int ORecordList<T>::uidAt( uint i ) { 274int ORecordList<T>::uidAt( uint i ) {
275 return m_ids[i]; 275 return m_ids[i];
276} 276}
277 277
278template <class T> 278template <class T>
279bool ORecordList<T>::remove( int uid ) { 279bool ORecordList<T>::remove( int uid ) {
280 QArray<int> copy( m_ids.count() ); 280 QArray<int> copy( m_ids.count() );
281 int counter = 0; 281 int counter = 0;
282 bool ret_val = false; 282 bool ret_val = false;
283 283
284 for (uint i = 0; i < m_ids.count(); i++){ 284 for (uint i = 0; i < m_ids.count(); i++){
285 if ( m_ids[i] != uid ){ 285 if ( m_ids[i] != uid ){
286 copy[counter++] = m_ids[i]; 286 copy[counter++] = m_ids[i];
287 287
288 }else 288 }else
289 ret_val = true; 289 ret_val = true;
290 } 290 }
291 291
292 copy.resize( counter ); 292 copy.resize( counter );
293 m_ids = copy; 293 m_ids = copy;
294 294
295 295
296 return ret_val; 296 return ret_val;
297} 297}
298 298
299 299
300#endif 300#endif
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index 0d5b1d3..4d5cb79 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -274,132 +274,132 @@ bool OTodo::operator<=(const OTodo &toDoEvent )const
274 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 274 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
275 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 275 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
276 if( hasDueDate() && toDoEvent.hasDueDate() ){ 276 if( hasDueDate() && toDoEvent.hasDueDate() ){
277 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 277 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
278 return priority() <= toDoEvent.priority(); 278 return priority() <= toDoEvent.priority();
279 }else{ 279 }else{
280 return dueDate() <= toDoEvent.dueDate(); 280 return dueDate() <= toDoEvent.dueDate();
281 } 281 }
282 } 282 }
283 return true; 283 return true;
284} 284}
285bool OTodo::operator>(const OTodo &toDoEvent )const 285bool OTodo::operator>(const OTodo &toDoEvent )const
286{ 286{
287 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 287 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
288 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 288 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
289 if( hasDueDate() && toDoEvent.hasDueDate() ){ 289 if( hasDueDate() && toDoEvent.hasDueDate() ){
290 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 290 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
291 return priority() > toDoEvent.priority(); 291 return priority() > toDoEvent.priority();
292 }else{ 292 }else{
293 return dueDate() > toDoEvent.dueDate(); 293 return dueDate() > toDoEvent.dueDate();
294 } 294 }
295 } 295 }
296 return false; 296 return false;
297} 297}
298bool OTodo::operator>=(const OTodo &toDoEvent )const 298bool OTodo::operator>=(const OTodo &toDoEvent )const
299{ 299{
300 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 300 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
301 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 301 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
302 if( hasDueDate() && toDoEvent.hasDueDate() ){ 302 if( hasDueDate() && toDoEvent.hasDueDate() ){
303 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 303 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
304 return priority() > toDoEvent.priority(); 304 return priority() > toDoEvent.priority();
305 }else{ 305 }else{
306 return dueDate() > toDoEvent.dueDate(); 306 return dueDate() > toDoEvent.dueDate();
307 } 307 }
308 } 308 }
309 return true; 309 return true;
310} 310}
311bool OTodo::operator==(const OTodo &toDoEvent )const 311bool OTodo::operator==(const OTodo &toDoEvent )const
312{ 312{
313 if ( data->priority != toDoEvent.data->priority ) return false; 313 if ( data->priority != toDoEvent.data->priority ) return false;
314 if ( data->priority != toDoEvent.data->prog ) return false; 314 if ( data->priority != toDoEvent.data->prog ) return false;
315 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 315 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
316 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 316 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
317 if ( data->date != toDoEvent.data->date ) return false; 317 if ( data->date != toDoEvent.data->date ) return false;
318 if ( data->sum != toDoEvent.data->sum ) return false; 318 if ( data->sum != toDoEvent.data->sum ) return false;
319 if ( data->desc != toDoEvent.data->desc ) return false; 319 if ( data->desc != toDoEvent.data->desc ) return false;
320 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) 320 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
321 return false; 321 return false;
322 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) 322 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
323 return false; 323 return false;
324 324
325 return OPimRecord::operator==( toDoEvent ); 325 return OPimRecord::operator==( toDoEvent );
326} 326}
327void OTodo::deref() { 327void OTodo::deref() {
328 328
329// qWarning("deref in ToDoEvent"); 329// qWarning("deref in ToDoEvent");
330 if ( data->deref() ) { 330 if ( data->deref() ) {
331// qWarning("deleting"); 331// qWarning("deleting");
332 delete data; 332 delete data;
333 data= 0; 333 data= 0;
334 } 334 }
335} 335}
336OTodo &OTodo::operator=(const OTodo &item ) 336OTodo &OTodo::operator=(const OTodo &item )
337{ 337{
338 OPimRecord::operator=( item ); 338 OPimRecord::operator=( item );
339 //qWarning("operator= ref "); 339 //qWarning("operator= ref ");
340 item.data->ref(); 340 item.data->ref();
341 deref(); 341 deref();
342 data = item.data; 342 data = item.data;
343 343
344 return *this; 344 return *this;
345} 345}
346 346
347QMap<int, QString> OTodo::toMap() const { 347QMap<int, QString> OTodo::toMap() const {
348 QMap<int, QString> map; 348 QMap<int, QString> map;
349 349
350 map.insert( Uid, QString::number( uid() ) ); 350 map.insert( Uid, QString::number( uid() ) );
351 map.insert( Category, idsToString( categories() ) ); 351 map.insert( Category, idsToString( categories() ) );
352 map.insert( HasDate, QString::number( data->hasDate ) ); 352 map.insert( HasDate, QString::number( data->hasDate ) );
353 map.insert( Completed, QString::number( data->isCompleted ) ); 353 map.insert( Completed, QString::number( data->isCompleted ) );
354 map.insert( Description, data->desc ); 354 map.insert( Description, data->desc );
355 map.insert( Summary, data->sum ); 355 map.insert( Summary, data->sum );
356 map.insert( Priority, QString::number( data->priority ) ); 356 map.insert( Priority, QString::number( data->priority ) );
357 map.insert( DateDay, QString::number( data->date.day() ) ); 357 map.insert( DateDay, QString::number( data->date.day() ) );
358 map.insert( DateMonth, QString::number( data->date.month() ) ); 358 map.insert( DateMonth, QString::number( data->date.month() ) );
359 map.insert( DateYear, QString::number( data->date.year() ) ); 359 map.insert( DateYear, QString::number( data->date.year() ) );
360 map.insert( Progress, QString::number( data->prog ) ); 360 map.insert( Progress, QString::number( data->prog ) );
361 map.insert( CrossReference, crossToString() ); 361 map.insert( CrossReference, crossToString() );
362 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); 362 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
363 map.insert( AlarmDateTime, data->alarmDateTime.toString() ); 363 map.insert( AlarmDateTime, data->alarmDateTime.toString() );
364 364
365 return map; 365 return map;
366} 366}
367 367
368QMap<QString, QString> OTodo::toExtraMap()const { 368QMap<QString, QString> OTodo::toExtraMap()const {
369 return data->extra; 369 return data->extra;
370} 370}
371/** 371/**
372 * change or modify looks at the ref count and either 372 * change or modify looks at the ref count and either
373 * creates a new QShared Object or it can modify it 373 * creates a new QShared Object or it can modify it
374 * right in place 374 * right in place
375 */ 375 */
376void OTodo::changeOrModify() { 376void OTodo::changeOrModify() {
377 if ( data->count != 1 ) { 377 if ( data->count != 1 ) {
378 qWarning("changeOrModify"); 378 qWarning("changeOrModify");
379 data->deref(); 379 data->deref();
380 OTodoData* d2 = new OTodoData(); 380 OTodoData* d2 = new OTodoData();
381 copy(data, d2 ); 381 copy(data, d2 );
382 data = d2; 382 data = d2;
383 } 383 }
384} 384}
385void OTodo::copy( OTodoData* src, OTodoData* dest ) { 385void OTodo::copy( OTodoData* src, OTodoData* dest ) {
386 dest->date = src->date; 386 dest->date = src->date;
387 dest->isCompleted = src->isCompleted; 387 dest->isCompleted = src->isCompleted;
388 dest->hasDate = src->hasDate; 388 dest->hasDate = src->hasDate;
389 dest->priority = src->priority; 389 dest->priority = src->priority;
390 dest->desc = src->desc; 390 dest->desc = src->desc;
391 dest->sum = src->sum; 391 dest->sum = src->sum;
392 dest->extra = src->extra; 392 dest->extra = src->extra;
393 dest->prog = src->prog; 393 dest->prog = src->prog;
394 dest->hasAlarmDateTime = src->hasAlarmDateTime; 394 dest->hasAlarmDateTime = src->hasAlarmDateTime;
395 dest->alarmDateTime = src->alarmDateTime; 395 dest->alarmDateTime = src->alarmDateTime;
396 dest->state = src->state; 396 dest->state = src->state;
397 dest->recur = src->recur; 397 dest->recur = src->recur;
398} 398}
399QString OTodo::type() const { 399QString OTodo::type() const {
400 return QString::fromLatin1("OTodo"); 400 return QString::fromLatin1("OTodo");
401} 401}
402QString OTodo::recordField(int id )const { 402QString OTodo::recordField(int /*id*/ )const {
403 return QString::null; 403 return QString::null;
404} 404}
405 405