summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp1
-rw-r--r--kaddressbook/kabcore.cpp19
-rw-r--r--kaddressbook/mainembedded.cpp26
-rw-r--r--kaddressbook/viewmanager.cpp4
4 files changed, 27 insertions, 23 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index 7577079..b1ffe04 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -31,147 +31,148 @@
31#include <klineedit.h> 31#include <klineedit.h>
32#include <klocale.h> 32#include <klocale.h>
33#include <kglobal.h> 33#include <kglobal.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include "kabprefs.h" 35#include "kabprefs.h"
36 36
37#include "incsearchwidget.h" 37#include "incsearchwidget.h"
38 38
39IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) 39IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
40 : QWidget( parent, name ) 40 : QWidget( parent, name )
41{ 41{
42#ifndef KAB_EMBEDDED 42#ifndef KAB_EMBEDDED
43//US setCaption( i18n( "Incremental Search" ) ); 43//US setCaption( i18n( "Incremental Search" ) );
44#endif //KAB_EMBEDDED 44#endif //KAB_EMBEDDED
45 45
46 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); 46 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() );
47 47
48#ifdef DESKTOP_VERSION 48#ifdef DESKTOP_VERSION
49 QLabel *label = new QLabel( i18n( "Search:" ), this ); 49 QLabel *label = new QLabel( i18n( "Search:" ), this );
50 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); 50 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight );
51 layout->addWidget( label ); 51 layout->addWidget( label );
52#endif //KAB_EMBEDDED 52#endif //KAB_EMBEDDED
53 53
54 mSearchText = new KLineEdit( this ); 54 mSearchText = new KLineEdit( this );
55 layout->addWidget( mSearchText ); 55 layout->addWidget( mSearchText );
56// #ifdef KAB_EMBEDDED 56// #ifdef KAB_EMBEDDED
57// if (KGlobal::getOrientation() == KGlobal::Portrait) 57// if (KGlobal::getOrientation() == KGlobal::Portrait)
58// mSearchText->setMaximumWidth(30); 58// mSearchText->setMaximumWidth(30);
59// #endif //KAB_EMBEDDED 59// #endif //KAB_EMBEDDED
60 //mSearchText->setMaximumWidth(60); 60 //mSearchText->setMaximumWidth(60);
61 61
62 62
63 mFieldCombo = new QComboBox( false, this ); 63 mFieldCombo = new QComboBox( false, this );
64 layout->addWidget( mFieldCombo ); 64 layout->addWidget( mFieldCombo );
65 mFieldCombo->setMaximumHeight( 34 ); 65 mFieldCombo->setMaximumHeight( 34 );
66 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); 66 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) );
67 67
68// #ifndef KAB_EMBEDDED 68// #ifndef KAB_EMBEDDED
69// resize( QSize(420, 50).expandedTo( sizeHint() ) ); 69// resize( QSize(420, 50).expandedTo( sizeHint() ) );
70// #else //KAB_EMBEDDED 70// #else //KAB_EMBEDDED
71// resize( QSize(30, 10).expandedTo( sizeHint() ) ); 71// resize( QSize(30, 10).expandedTo( sizeHint() ) );
72// #endif //KAB_EMBEDDED 72// #endif //KAB_EMBEDDED
73 73
74 74
75 // for performance reasons, we do a search on the pda only after return is pressed 75 // for performance reasons, we do a search on the pda only after return is pressed
76 connect( mSearchText, SIGNAL( textChanged( const QString& ) ), 76 connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
77 SLOT( announceDoSearch2() ) ); 77 SLOT( announceDoSearch2() ) );
78 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 78 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
79 SLOT( announceDoSearch2() ) ); 79 SLOT( announceDoSearch2() ) );
80 80
81 connect( mSearchText, SIGNAL( returnPressed() ), 81 connect( mSearchText, SIGNAL( returnPressed() ),
82 SLOT( announceDoSearch() ) ); 82 SLOT( announceDoSearch() ) );
83 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 83 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
84 SLOT( announceFieldChanged() ) ); 84 SLOT( announceFieldChanged() ) );
85 85
86 86
87 87
88 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() )); 88 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() ));
89 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() )); 89 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() ));
90 90
91 91
92 setFocusProxy( mSearchText ); 92 setFocusProxy( mSearchText );
93} 93}
94 94
95IncSearchWidget::~IncSearchWidget() 95IncSearchWidget::~IncSearchWidget()
96{ 96{
97 97
98} 98}
99void IncSearchWidget::announceDoSearch2() 99void IncSearchWidget::announceDoSearch2()
100{ 100{
101 if ( KABPrefs::instance()->mSearchWithReturn ) 101 if ( KABPrefs::instance()->mSearchWithReturn )
102 return; 102 return;
103 emit doSearch( mSearchText->text() ); 103 emit doSearch( mSearchText->text() );
104 //qDebug("emit dosreach "); 104 //qDebug("emit dosreach ");
105} 105}
106 106
107void IncSearchWidget::announceDoSearch() 107void IncSearchWidget::announceDoSearch()
108{ 108{
109 109
110 emit doSearch( mSearchText->text() ); 110 emit doSearch( mSearchText->text() );
111 // qDebug("emit dosreach "); 111 // qDebug("emit dosreach ");
112} 112}
113 113
114void IncSearchWidget::announceFieldChanged() 114void IncSearchWidget::announceFieldChanged()
115{ 115{
116 emit fieldChanged(); 116 emit fieldChanged();
117} 117}
118void IncSearchWidget::setSize() 118void IncSearchWidget::setSize()
119{ 119{
120 if ( KABPrefs::instance()->mHideSearchOnSwitch && QApplication::desktop()->width() == 480) { 120 if ( KABPrefs::instance()->mHideSearchOnSwitch && QApplication::desktop()->width() == 480) {
121 mFieldCombo->setMaximumWidth( 40 ); 121 mFieldCombo->setMaximumWidth( 40 );
122 mSearchText->setMaximumWidth( 30 ); 122 mSearchText->setMaximumWidth( 30 );
123 } else { 123 } else {
124 QFontMetrics fm ( mFieldCombo->font() ); 124 QFontMetrics fm ( mFieldCombo->font() );
125 int wid = fm.width(i18n( "All Fields" ) ); 125 int wid = fm.width(i18n( "All Fields" ) );
126#ifdef DESKTOP_VERSION 126#ifdef DESKTOP_VERSION
127 mFieldCombo->setMinimumWidth( wid+60 );
127 wid = wid * 2; 128 wid = wid * 2;
128#endif 129#endif
129 mFieldCombo->setMaximumWidth( wid+60 ); 130 mFieldCombo->setMaximumWidth( wid+60 );
130 mSearchText->setMaximumWidth( 1024 ); 131 mSearchText->setMaximumWidth( 1024 );
131 } 132 }
132} 133}
133void IncSearchWidget::setFields( const KABC::Field::List &list ) 134void IncSearchWidget::setFields( const KABC::Field::List &list )
134{ 135{
135 136
136 mFieldCombo->clear(); 137 mFieldCombo->clear();
137 mFieldCombo->insertItem( i18n( "All Fields" ) ); 138 mFieldCombo->insertItem( i18n( "All Fields" ) );
138 139
139 KABC::Field::List::ConstIterator it; 140 KABC::Field::List::ConstIterator it;
140 for ( it = list.begin(); it != list.end(); ++it ) { 141 for ( it = list.begin(); it != list.end(); ++it ) {
141 mFieldCombo->insertItem( (*it)->label() ); 142 mFieldCombo->insertItem( (*it)->label() );
142 } 143 }
143 144
144 mFieldList = list; 145 mFieldList = list;
145 146
146 announceDoSearch(); 147 announceDoSearch();
147 announceFieldChanged(); 148 announceFieldChanged();
148 setSize(); 149 setSize();
149} 150}
150 151
151KABC::Field::List IncSearchWidget::fields() const 152KABC::Field::List IncSearchWidget::fields() const
152{ 153{
153 return mFieldList; 154 return mFieldList;
154} 155}
155 156
156KABC::Field *IncSearchWidget::currentField()const 157KABC::Field *IncSearchWidget::currentField()const
157{ 158{
158 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) 159 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
159 return 0; // for error or 'use all fields' 160 return 0; // for error or 'use all fields'
160 else 161 else
161 return mFieldList[ mFieldCombo->currentItem() - 1 ]; 162 return mFieldList[ mFieldCombo->currentItem() - 1 ];
162} 163}
163 164
164void IncSearchWidget::setCurrentItem( int pos ) 165void IncSearchWidget::setCurrentItem( int pos )
165{ 166{
166 mFieldCombo->setCurrentItem( pos ); 167 mFieldCombo->setCurrentItem( pos );
167 announceFieldChanged(); 168 announceFieldChanged();
168} 169}
169 170
170int IncSearchWidget::currentItem() const 171int IncSearchWidget::currentItem() const
171{ 172{
172 173
173 return mFieldCombo->currentItem(); 174 return mFieldCombo->currentItem();
174} 175}
175#ifndef KAB_EMBEDDED 176#ifndef KAB_EMBEDDED
176#include "incsearchwidget.moc" 177#include "incsearchwidget.moc"
177#endif //KAB_EMBEDDED 178#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index a4f3579..cba5850 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -492,210 +492,193 @@ void KABCore::restoreSettings()
492 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 492 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
493 493
494 bool state; 494 bool state;
495 495
496 if (mMultipleViewsAtOnce) 496 if (mMultipleViewsAtOnce)
497 state = KABPrefs::instance()->mDetailsPageVisible; 497 state = KABPrefs::instance()->mDetailsPageVisible;
498 else 498 else
499 state = false; 499 state = false;
500 500
501 mActionDetails->setChecked( state ); 501 mActionDetails->setChecked( state );
502 setDetailsVisible( state ); 502 setDetailsVisible( state );
503 503
504 state = KABPrefs::instance()->mJumpButtonBarVisible; 504 state = KABPrefs::instance()->mJumpButtonBarVisible;
505 505
506 mActionJumpBar->setChecked( state ); 506 mActionJumpBar->setChecked( state );
507 setJumpButtonBarVisible( state ); 507 setJumpButtonBarVisible( state );
508/*US 508/*US
509 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 509 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
510 if ( splitterSize.count() == 0 ) { 510 if ( splitterSize.count() == 0 ) {
511 splitterSize.append( width() / 2 ); 511 splitterSize.append( width() / 2 );
512 splitterSize.append( width() / 2 ); 512 splitterSize.append( width() / 2 );
513 } 513 }
514 mMiniSplitter->setSizes( splitterSize ); 514 mMiniSplitter->setSizes( splitterSize );
515 if ( mExtensionBarSplitter ) { 515 if ( mExtensionBarSplitter ) {
516 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 516 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
517 if ( splitterSize.count() == 0 ) { 517 if ( splitterSize.count() == 0 ) {
518 splitterSize.append( width() / 2 ); 518 splitterSize.append( width() / 2 );
519 splitterSize.append( width() / 2 ); 519 splitterSize.append( width() / 2 );
520 } 520 }
521 mExtensionBarSplitter->setSizes( splitterSize ); 521 mExtensionBarSplitter->setSizes( splitterSize );
522 522
523 } 523 }
524*/ 524*/
525 mViewManager->restoreSettings(); 525 mViewManager->restoreSettings();
526 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 526 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
527 mExtensionManager->restoreSettings(); 527 mExtensionManager->restoreSettings();
528#ifdef DESKTOP_VERSION 528#ifdef DESKTOP_VERSION
529 int wid = width(); 529 int wid = width();
530 if ( wid < 10 ) 530 if ( wid < 10 )
531 wid = 400; 531 wid = 400;
532#else 532#else
533 int wid = QApplication::desktop()->width(); 533 int wid = QApplication::desktop()->width();
534 if ( wid < 640 ) 534 if ( wid < 640 )
535 wid = QApplication::desktop()->height(); 535 wid = QApplication::desktop()->height();
536#endif 536#endif
537 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 537 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
538 if ( true /*splitterSize.count() == 0*/ ) { 538 if ( true /*splitterSize.count() == 0*/ ) {
539 splitterSize.append( wid / 2 ); 539 splitterSize.append( wid / 2 );
540 splitterSize.append( wid / 2 ); 540 splitterSize.append( wid / 2 );
541 } 541 }
542 mMiniSplitter->setSizes( splitterSize ); 542 mMiniSplitter->setSizes( splitterSize );
543 if ( mExtensionBarSplitter ) { 543 if ( mExtensionBarSplitter ) {
544 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 544 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
545 if ( true /*splitterSize.count() == 0*/ ) { 545 if ( true /*splitterSize.count() == 0*/ ) {
546 splitterSize.append( wid / 2 ); 546 splitterSize.append( wid / 2 );
547 splitterSize.append( wid / 2 ); 547 splitterSize.append( wid / 2 );
548 } 548 }
549 mExtensionBarSplitter->setSizes( splitterSize ); 549 mExtensionBarSplitter->setSizes( splitterSize );
550 550
551 } 551 }
552#ifdef DESKTOP_VERSION 552#ifdef DESKTOP_VERSION
553 KConfig *config = KABPrefs::instance()->getConfig(); 553 KConfig *config = KABPrefs::instance()->getConfig();
554 config->setGroup("WidgetLayout"); 554 config->setGroup("WidgetLayout");
555 QStringList list; 555 QStringList list;
556 list = config->readListEntry("MainLayout"); 556 list = config->readListEntry("MainLayout");
557 int x,y,w,h; 557 int x,y,w,h;
558 if ( ! list.isEmpty() ) { 558 if ( ! list.isEmpty() ) {
559 x = list[0].toInt(); 559 x = list[0].toInt();
560 y = list[1].toInt(); 560 y = list[1].toInt();
561 w = list[2].toInt(); 561 w = list[2].toInt();
562 h = list[3].toInt(); 562 h = list[3].toInt();
563 KApplication::testCoords( &x,&y,&w,&h ); 563 KApplication::testCoords( &x,&y,&w,&h );
564 topLevelWidget()->setGeometry(x,y,w,h); 564 topLevelWidget()->setGeometry(x,y,w,h);
565 565
566 } else { 566 } else {
567 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 567 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
568 } 568 }
569#endif 569#endif
570} 570}
571 571
572void KABCore::saveSettings() 572void KABCore::saveSettings()
573{ 573{
574 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 574 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
575 if ( mExtensionBarSplitter ) 575 if ( mExtensionBarSplitter )
576 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 576 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
577 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 577 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
578 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 578 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
579#ifndef KAB_EMBEDDED 579#ifndef KAB_EMBEDDED
580 580
581 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 581 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
582 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 582 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
583#endif //KAB_EMBEDDED 583#endif //KAB_EMBEDDED
584 mExtensionManager->saveSettings(); 584 mExtensionManager->saveSettings();
585 mViewManager->saveSettings(); 585 mViewManager->saveSettings();
586 586
587 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 587 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
588#ifdef DESKTOP_VERSION 588
589 KConfig *config = KABPrefs::instance()->getConfig();
590 config->setGroup("WidgetLayout");
591 QStringList list ;//= config->readListEntry("MainLayout");
592 int x,y,w,h;
593 QWidget* wid;
594 wid = topLevelWidget();
595 x = wid->geometry().x();
596 y = wid->geometry().y();
597 w = wid->width();
598 h = wid->height();
599 list.clear();
600 list << QString::number( x );
601 list << QString::number( y );
602 list << QString::number( w );
603 list << QString::number( h );
604 config->writeEntry("MainLayout",list );
605#endif
606 KABPrefs::instance()->writeConfig(); 589 KABPrefs::instance()->writeConfig();
607 qDebug("KA: KABCore::saveSettings() "); 590 qDebug("KA: KABCore::saveSettings() ");
608} 591}
609 592
610KABC::AddressBook *KABCore::addressBook() const 593KABC::AddressBook *KABCore::addressBook() const
611{ 594{
612 return mAddressBook; 595 return mAddressBook;
613} 596}
614 597
615KConfig *KABCore::config() 598KConfig *KABCore::config()
616{ 599{
617#ifndef KAB_EMBEDDED 600#ifndef KAB_EMBEDDED
618 return KABPrefs::instance()->config(); 601 return KABPrefs::instance()->config();
619#else //KAB_EMBEDDED 602#else //KAB_EMBEDDED
620 return KABPrefs::instance()->getConfig(); 603 return KABPrefs::instance()->getConfig();
621#endif //KAB_EMBEDDED 604#endif //KAB_EMBEDDED
622} 605}
623 606
624KActionCollection *KABCore::actionCollection() const 607KActionCollection *KABCore::actionCollection() const
625{ 608{
626 return mGUIClient->actionCollection(); 609 return mGUIClient->actionCollection();
627} 610}
628 611
629KABC::Field *KABCore::currentSearchField() const 612KABC::Field *KABCore::currentSearchField() const
630{ 613{
631 if (mIncSearchWidget) 614 if (mIncSearchWidget)
632 return mIncSearchWidget->currentField(); 615 return mIncSearchWidget->currentField();
633 else 616 else
634 return 0; 617 return 0;
635} 618}
636 619
637QStringList KABCore::selectedUIDs() const 620QStringList KABCore::selectedUIDs() const
638{ 621{
639 return mViewManager->selectedUids(); 622 return mViewManager->selectedUids();
640} 623}
641 624
642KABC::Resource *KABCore::requestResource( QWidget *parent ) 625KABC::Resource *KABCore::requestResource( QWidget *parent )
643{ 626{
644 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 627 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
645 628
646 QPtrList<KRES::Resource> kresResources; 629 QPtrList<KRES::Resource> kresResources;
647 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 630 QPtrListIterator<KABC::Resource> resIt( kabcResources );
648 KABC::Resource *resource; 631 KABC::Resource *resource;
649 while ( ( resource = resIt.current() ) != 0 ) { 632 while ( ( resource = resIt.current() ) != 0 ) {
650 ++resIt; 633 ++resIt;
651 if ( !resource->readOnly() ) { 634 if ( !resource->readOnly() ) {
652 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 635 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
653 if ( res ) 636 if ( res )
654 kresResources.append( res ); 637 kresResources.append( res );
655 } 638 }
656 } 639 }
657 640
658 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 641 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
659 return static_cast<KABC::Resource*>( res ); 642 return static_cast<KABC::Resource*>( res );
660} 643}
661 644
662#ifndef KAB_EMBEDDED 645#ifndef KAB_EMBEDDED
663KAboutData *KABCore::createAboutData() 646KAboutData *KABCore::createAboutData()
664#else //KAB_EMBEDDED 647#else //KAB_EMBEDDED
665void KABCore::createAboutData() 648void KABCore::createAboutData()
666#endif //KAB_EMBEDDED 649#endif //KAB_EMBEDDED
667{ 650{
668 651
669 652
670 QString version; 653 QString version;
671#include <../version> 654#include <../version>
672 QMessageBox::about( this, "About KAddressbook/Pi", 655 QMessageBox::about( this, "About KAddressbook/Pi",
673 "KAddressbook/Platform-independent\n" 656 "KAddressbook/Platform-independent\n"
674 "(KA/Pi) " +version + " - " + 657 "(KA/Pi) " +version + " - " +
675#ifdef DESKTOP_VERSION 658#ifdef DESKTOP_VERSION
676 "Desktop Edition\n" 659 "Desktop Edition\n"
677#else 660#else
678 "PDA-Edition\n" 661 "PDA-Edition\n"
679 "for: Zaurus 5500 / 7x0 / 8x0\n" 662 "for: Zaurus 5500 / 7x0 / 8x0\n"
680#endif 663#endif
681 664
682 "(c) 2004 Ulf Schenk\n" 665 "(c) 2004 Ulf Schenk\n"
683 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 666 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
684 "(c) 1997-2003, The KDE PIM Team\n" 667 "(c) 1997-2003, The KDE PIM Team\n"
685 "Tobias Koenig Maintainer\n" 668 "Tobias Koenig Maintainer\n"
686 "Don Sanders Original author\n" 669 "Don Sanders Original author\n"
687 "Cornelius Schumacher Co-maintainer\n" 670 "Cornelius Schumacher Co-maintainer\n"
688 "Mike Pilone GUI and framework redesign\n" 671 "Mike Pilone GUI and framework redesign\n"
689 "Greg Stern DCOP interface\n" 672 "Greg Stern DCOP interface\n"
690 "Mark Westcot Contact pinning\n" 673 "Mark Westcot Contact pinning\n"
691 "Michel Boyer de la Giroday LDAP Lookup\n" 674 "Michel Boyer de la Giroday LDAP Lookup\n"
692 "Steffen Hansen LDAP Lookup" 675 "Steffen Hansen LDAP Lookup"
693#ifdef _WIN32_ 676#ifdef _WIN32_
694 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 677 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
695#endif 678#endif
696 ); 679 );
697} 680}
698 681
699void KABCore::setContactSelected( const QString &uid ) 682void KABCore::setContactSelected( const QString &uid )
700{ 683{
701 KABC::Addressee addr = mAddressBook->findByUid( uid ); 684 KABC::Addressee addr = mAddressBook->findByUid( uid );
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 336e350..50db377 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,103 +1,119 @@
1#ifndef DESKTOP_VERSION 1#ifndef DESKTOP_VERSION
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qcopchannel_qws.h> 3#include <qcopchannel_qws.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#else 5#else
6#include <qapplication.h> 6#include <qapplication.h>
7#include <qwindowsstyle.h> 7#include <qwindowsstyle.h>
8#include <qplatinumstyle.h> 8#include <qplatinumstyle.h>
9#include <qmainwindow.h> 9#include <qmainwindow.h>
10#include <qmessagebox.h> 10#include <qmessagebox.h>
11#include <stdlib.h> 11#include <stdlib.h>
12#endif 12#endif
13 13
14#include <qtextcodec.h> 14#include <qtextcodec.h>
15#include <kstandarddirs.h> 15#include <kstandarddirs.h>
16#include <qregexp.h> 16#include <qregexp.h>
17#include <kglobal.h> 17#include <kglobal.h>
18#include <stdio.h> 18#include <stdio.h>
19#include <qdir.h> 19#include <qdir.h>
20#include "kabprefs.h" 20#include "kabprefs.h"
21#include "kaddressbookmain.h" 21#include "kaddressbookmain.h"
22#include "externalapphandler.h" 22#include "externalapphandler.h"
23#include <libkdepim/kpimglobalprefs.h> 23#include <libkdepim/kpimglobalprefs.h>
24void dumpMissing(); 24void dumpMissing();
25int main( int argc, char **argv ) 25int main( int argc, char **argv )
26{ 26{
27#ifndef DESKTOP_VERSION 27#ifndef DESKTOP_VERSION
28 QPEApplication a( argc, argv ); 28 QPEApplication a( argc, argv );
29 a.setKeepRunning (); 29 a.setKeepRunning ();
30#else 30#else
31 QApplication a( argc, argv ); 31 QApplication a( argc, argv );
32 QApplication::setStyle( new QPlatinumStyle ()); 32 QApplication::setStyle( new QPlatinumStyle ());
33#ifdef _WIN32_ 33#ifdef _WIN32_
34 QString hdir ( getenv( "HOME") ); 34 QString hdir ( getenv( "HOME") );
35 if ( hdir.isEmpty() ) { 35 if ( hdir.isEmpty() ) {
36 QString hd ("C:/" ); 36 QString hd ("C:/" );
37 //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd ); 37 //QMessageBox::information(0,"hh",QDir::homeDirPath()+" xx" +hd );
38 if ( QDir::homeDirPath().lower() == hd.lower() ) { 38 if ( QDir::homeDirPath().lower() == hd.lower() ) {
39 _putenv( "HOME=C:"); 39 _putenv( "HOME=C:");
40 //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) ); 40 //QMessageBox::information(0,"hh",QString ( getenv( "HOME") ) );
41 } 41 }
42 } else { 42 } else {
43 QDir app_dir; 43 QDir app_dir;
44 if ( !app_dir.exists(hdir) ) 44 if ( !app_dir.exists(hdir) )
45 app_dir.mkdir (hdir); 45 app_dir.mkdir (hdir);
46 } 46 }
47#endif 47#endif
48#endif 48#endif
49 49
50 bool exitHelp = false; 50 bool exitHelp = false;
51 if ( argc > 1 ) { 51 if ( argc > 1 ) {
52 QString command = argv[1]; 52 QString command = argv[1];
53 if ( command == "-help" ){ 53 if ( command == "-help" ){
54 printf("KA/E command line commands:\n"); 54 printf("KA/E command line commands:\n");
55 printf(" no command: Start KA/E in usual way\n"); 55 printf(" no command: Start KA/E in usual way\n");
56 printf(" -help: This output\n"); 56 printf(" -help: This output\n");
57 printf(" KA/E is exiting now. Bye!\n"); 57 printf(" KA/E is exiting now. Bye!\n");
58 exitHelp = true; 58 exitHelp = true;
59 } 59 }
60 } 60 }
61 if ( ! exitHelp ) { 61 if ( ! exitHelp ) {
62 62
63 KGlobal::setAppName( "kaddressbook" ); 63 KGlobal::setAppName( "kaddressbook" );
64#ifndef DESKTOP_VERSION 64#ifndef DESKTOP_VERSION
65 if ( QApplication::desktop()->width() > 320 ) 65 if ( QApplication::desktop()->width() > 320 )
66 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 66 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
67 else 67 else
68 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 68 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
69#else 69#else
70 QString fileName ; 70 QString fileName ;
71 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; 71 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
72 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 72 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
73 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 73 QApplication::addLibraryPath ( qApp->applicationDirPath () );
74 74
75#endif 75#endif
76 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 76 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
77 // init language 77 // init language
78 KPimGlobalPrefs::instance()->setGlobalConfig(); 78 KPimGlobalPrefs::instance()->setGlobalConfig();
79 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); 79 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont );
80 KAddressBookMain m ; 80 KAddressBookMain m ;
81//US MainWindow m; 81//US MainWindow m;
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 83 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
84#endif 84#endif
85 85
86 86
87#ifndef DESKTOP_VERSION 87#ifndef DESKTOP_VERSION
88 a.showMainWidget( &m ); 88 a.showMainWidget( &m );
89 89
90#else 90#else
91 a.setMainWidget( &m ); 91 a.setMainWidget( &m );
92 m.resize (640, 480 );
93 m.show(); 92 m.show();
94#endif 93#endif
95 a.exec(); 94 a.exec();
96 95#ifdef DESKTOP_VERSION
97 dumpMissing(); 96 KConfig *config = KABPrefs::instance()->getConfig();
98 97 config->setGroup("WidgetLayout");
99 KPimGlobalPrefs::instance()->writeConfig(); 98 QStringList list ;//= config->readListEntry("MainLayout");
99 int x,y,w,h;
100 QWidget* wid;
101 wid = &m;
102 x = wid->geometry().x();
103 y = wid->geometry().y();
104 w = wid->width();
105 h = wid->height();
106 list.clear();
107 list << QString::number( x );
108 list << QString::number( y );
109 list << QString::number( w );
110 list << QString::number( h );
111 config->writeEntry("MainLayout",list );
112#endif
113 dumpMissing();
114
115 KPimGlobalPrefs::instance()->writeConfig();
100 } 116 }
101 qDebug("KA: Bye! "); 117 qDebug("KA: Bye! ");
102} 118}
103 119
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 0614d06..c738ad8 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -15,192 +15,194 @@
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31 31
32#ifndef KAB_EMBEDDED 32#ifndef KAB_EMBEDDED
33#include <libkdepim/kvcarddrag.h> 33#include <libkdepim/kvcarddrag.h>
34#include <kabc/vcardconverter.h> 34#include <kabc/vcardconverter.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kdeversion.h> 36#include <kdeversion.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40#include <kmultipledrag.h> 40#include <kmultipledrag.h>
41#include <ktrader.h> 41#include <ktrader.h>
42#include <kurldrag.h> 42#include <kurldrag.h>
43 43
44#include "addresseeutil.h" 44#include "addresseeutil.h"
45#else //KAB_EMBEDDED 45#else //KAB_EMBEDDED
46#include "views/kaddressbookiconview.h" 46#include "views/kaddressbookiconview.h"
47#include "views/kaddressbooktableview.h" 47#include "views/kaddressbooktableview.h"
48#include "views/kaddressbookcardview.h" 48#include "views/kaddressbookcardview.h"
49#include "kaddressbookview.h" 49#include "kaddressbookview.h"
50 50
51#include <qaction.h> 51#include <qaction.h>
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qpopupmenu.h> 53#include <qpopupmenu.h>
54#include <kconfigbase.h> 54#include <kconfigbase.h>
55 55
56#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
57 57
58 58
59#include <kdebug.h> 59#include <kdebug.h>
60#include <kactionclasses.h> 60#include <kactionclasses.h>
61 61
62#include <qlayout.h> 62#include <qlayout.h>
63#include <qapplication.h> 63#include <qapplication.h>
64#include <qwidgetstack.h> 64#include <qwidgetstack.h>
65 65
66#include <kabc/addressbook.h> 66#include <kabc/addressbook.h>
67#include "filtereditdialog.h" 67#include "filtereditdialog.h"
68#include "addviewdialog.h" 68#include "addviewdialog.h"
69#include "kabcore.h" 69#include "kabcore.h"
70#include "kabprefs.h" 70#include "kabprefs.h"
71#include "viewmanager.h" 71#include "viewmanager.h"
72 72
73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) 73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name )
74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) 74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 )
75{ 75{
76 initGUI(); 76 initGUI();
77 initActions(); 77 initActions();
78 78
79 mViewDict.setAutoDelete( true ); 79 mViewDict.setAutoDelete( true );
80 80
81 createViewFactories(); 81 createViewFactories();
82} 82}
83 83
84ViewManager::~ViewManager() 84ViewManager::~ViewManager()
85{ 85{
86 unloadViews(); 86 unloadViews();
87 mViewFactoryDict.clear(); 87 mViewFactoryDict.clear();
88} 88}
89void ViewManager::scrollUP() 89void ViewManager::scrollUP()
90{ 90{
91 if ( mActiveView ) 91 if ( mActiveView )
92 mActiveView->scrollUP(); 92 mActiveView->scrollUP();
93} 93}
94void ViewManager::scrollDOWN() 94void ViewManager::scrollDOWN()
95{ 95{
96 if ( mActiveView ) 96 if ( mActiveView )
97 mActiveView->scrollDOWN(); 97 mActiveView->scrollDOWN();
98} 98}
99void ViewManager::restoreSettings() 99void ViewManager::restoreSettings()
100{ 100{
101 mViewNameList = KABPrefs::instance()->mViewNames; 101 mViewNameList = KABPrefs::instance()->mViewNames;
102 QString activeViewName = KABPrefs::instance()->mCurrentView; 102 QString activeViewName = KABPrefs::instance()->mCurrentView;
103 103
104 mActionSelectView->setItems( mViewNameList ); 104 mActionSelectView->setItems( mViewNameList );
105 105
106 // Filter 106 // Filter
107 mFilterList = Filter::restore( mCore->config(), "Filter" ); 107 mFilterList = Filter::restore( mCore->config(), "Filter" );
108 mActionSelectFilter->setItems( filterNames() ); 108 mActionSelectFilter->setItems( filterNames() );
109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); 109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
110 int cw = 150; 110 int cw = 150;
111 if ( QApplication::desktop()->width() >= 800 )
112 cw = 200;
111 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) 113 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch)
112 cw = 0; 114 cw = 0;
113 mActionSelectFilter->setComboWidth( cw ); 115 mActionSelectFilter->setComboWidth( cw );
114 // Tell the views to reread their config, since they may have 116 // Tell the views to reread their config, since they may have
115 // been modified by global settings 117 // been modified by global settings
116 QString _oldgroup = mCore->config()->group(); 118 QString _oldgroup = mCore->config()->group();
117 119
118 QDictIterator<KAddressBookView> it( mViewDict ); 120 QDictIterator<KAddressBookView> it( mViewDict );
119 for ( it.toFirst(); it.current(); ++it ) { 121 for ( it.toFirst(); it.current(); ++it ) {
120 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 122 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
121 it.current()->readConfig( mCore->config() ); 123 it.current()->readConfig( mCore->config() );
122 } 124 }
123 setActiveView( activeViewName ); 125 setActiveView( activeViewName );
124 126
125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 127 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
126} 128}
127 129
128void ViewManager::saveSettings() 130void ViewManager::saveSettings()
129{ 131{
130 QString _oldgroup = mCore->config()->group(); 132 QString _oldgroup = mCore->config()->group();
131 133
132 QDictIterator<KAddressBookView> it( mViewDict ); 134 QDictIterator<KAddressBookView> it( mViewDict );
133 for ( it.toFirst(); it.current(); ++it ) { 135 for ( it.toFirst(); it.current(); ++it ) {
134 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 136 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
135#ifdef DESKTOP_VERSION 137#ifdef DESKTOP_VERSION
136 (*it)->writeConfig( mCore->config() ); 138 (*it)->writeConfig( mCore->config() );
137#else 139#else
138 (*it).writeConfig( mCore->config() ); 140 (*it).writeConfig( mCore->config() );
139#endif 141#endif
140 } 142 }
141 143
142 Filter::save( mCore->config(), "Filter", mFilterList ); 144 Filter::save( mCore->config(), "Filter", mFilterList );
143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 145 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
144 146
145 // write the view name list 147 // write the view name list
146 KABPrefs::instance()->mViewNames = mViewNameList; 148 KABPrefs::instance()->mViewNames = mViewNameList;
147 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 149 KABPrefs::instance()->mCurrentView = mActiveView->caption();
148 150
149} 151}
150 152
151QStringList ViewManager::selectedUids() const 153QStringList ViewManager::selectedUids() const
152{ 154{
153 if ( mActiveView ) 155 if ( mActiveView )
154 return mActiveView->selectedUids(); 156 return mActiveView->selectedUids();
155 else 157 else
156 return QStringList(); 158 return QStringList();
157} 159}
158 160
159QStringList ViewManager::selectedEmails() const 161QStringList ViewManager::selectedEmails() const
160{ 162{
161 if ( mActiveView ) 163 if ( mActiveView )
162 return mActiveView->selectedEmails(); 164 return mActiveView->selectedEmails();
163 else 165 else
164 return QStringList(); 166 return QStringList();
165} 167}
166 168
167KABC::Addressee::List ViewManager::selectedAddressees() const 169KABC::Addressee::List ViewManager::selectedAddressees() const
168{ 170{
169 KABC::Addressee::List list; 171 KABC::Addressee::List list;
170 if ( mActiveView ) { 172 if ( mActiveView ) {
171 QStringList uids = mActiveView->selectedUids(); 173 QStringList uids = mActiveView->selectedUids();
172 QStringList::Iterator it; 174 QStringList::Iterator it;
173 for ( it = uids.begin(); it != uids.end(); ++it ) { 175 for ( it = uids.begin(); it != uids.end(); ++it ) {
174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 176 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
175 if ( !addr.isEmpty() ) 177 if ( !addr.isEmpty() )
176 list.append( addr ); 178 list.append( addr );
177 } 179 }
178 } 180 }
179 181
180 return list; 182 return list;
181} 183}
182//US added another method with no parameter, since my moc compiler does not support default parameters. 184//US added another method with no parameter, since my moc compiler does not support default parameters.
183void ViewManager::setSelected() 185void ViewManager::setSelected()
184{ 186{
185 setSelected( QString::null, true ); 187 setSelected( QString::null, true );
186} 188}
187 189
188void ViewManager::setSelected( const QString &uid, bool selected ) 190void ViewManager::setSelected( const QString &uid, bool selected )
189{ 191{
190 if ( mActiveView ) 192 if ( mActiveView )
191 mActiveView->setSelected( uid, selected ); 193 mActiveView->setSelected( uid, selected );
192} 194}
193 195
194void ViewManager::setListSelected(QStringList list) 196void ViewManager::setListSelected(QStringList list)
195{ 197{
196 int i, count = list.count(); 198 int i, count = list.count();
197 for ( i = 0; i < count;++i ) 199 for ( i = 0; i < count;++i )
198 setSelected( list[i], true ); 200 setSelected( list[i], true );
199 201
200} 202}
201void ViewManager::unloadViews() 203void ViewManager::unloadViews()
202{ 204{
203 mViewDict.clear(); 205 mViewDict.clear();
204 mActiveView = 0; 206 mActiveView = 0;
205} 207}
206 208
@@ -511,192 +513,194 @@ void ViewManager::dropped( QDropEvent *e )
511 } else if ( c == 1 ) 513 } else if ( c == 1 )
512 emit urlDropped( *it ); 514 emit urlDropped( *it );
513 } else if ( KVCardDrag::decode( e, vcards ) ) { 515 } else if ( KVCardDrag::decode( e, vcards ) ) {
514 KABC::Addressee addr; 516 KABC::Addressee addr;
515 KABC::VCardConverter converter; 517 KABC::VCardConverter converter;
516 QStringList list = QStringList::split( "\r\n\r\n", vcards ); 518 QStringList list = QStringList::split( "\r\n\r\n", vcards );
517 QStringList::Iterator it; 519 QStringList::Iterator it;
518 for ( it = list.begin(); it != list.end(); ++it ) { 520 for ( it = list.begin(); it != list.end(); ++it ) {
519 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { 521 if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) {
520 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); 522 KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() );
521 if ( a.isEmpty() ) { 523 if ( a.isEmpty() ) {
522 mCore->addressBook()->insertAddressee( addr ); 524 mCore->addressBook()->insertAddressee( addr );
523 emit modified(); 525 emit modified();
524 } 526 }
525 } 527 }
526 } 528 }
527 529
528 mActiveView->refresh(); 530 mActiveView->refresh();
529 } 531 }
530#else //KAB_EMBEDDED 532#else //KAB_EMBEDDED
531qDebug("ViewManager::dropped() has to be changed!!" ); 533qDebug("ViewManager::dropped() has to be changed!!" );
532#endif //KAB_EMBEDDED 534#endif //KAB_EMBEDDED
533 535
534} 536}
535 537
536void ViewManager::startDrag() 538void ViewManager::startDrag()
537{ 539{
538 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; 540 kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl;
539 541
540#ifndef KAB_EMBEDDED 542#ifndef KAB_EMBEDDED
541 543
542 // Get the list of all the selected addressees 544 // Get the list of all the selected addressees
543 KABC::Addressee::List addrList; 545 KABC::Addressee::List addrList;
544 QStringList uidList = selectedUids(); 546 QStringList uidList = selectedUids();
545 QStringList::Iterator iter; 547 QStringList::Iterator iter;
546 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 548 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
547 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 549 addrList.append( mCore->addressBook()->findByUid( *iter ) );
548 550
549 KMultipleDrag *drag = new KMultipleDrag( this ); 551 KMultipleDrag *drag = new KMultipleDrag( this );
550 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 552 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
551 KABC::Addressee::List::Iterator it; 553 KABC::Addressee::List::Iterator it;
552 QStringList vcards; 554 QStringList vcards;
553 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 555 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
554 QString vcard = QString::null; 556 QString vcard = QString::null;
555 KABC::VCardConverter converter; 557 KABC::VCardConverter converter;
556 if ( converter.addresseeToVCard( *it, vcard ) ) 558 if ( converter.addresseeToVCard( *it, vcard ) )
557 vcards.append( vcard ); 559 vcards.append( vcard );
558 } 560 }
559 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 561 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
560 562
561 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 563 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
562 drag->dragCopy(); 564 drag->dragCopy();
563 565
564#else //KAB_EMBEDDED 566#else //KAB_EMBEDDED
565qDebug("ViewManager::startDrag() has to be changed!!" ); 567qDebug("ViewManager::startDrag() has to be changed!!" );
566#endif //KAB_EMBEDDED 568#endif //KAB_EMBEDDED
567 569
568} 570}
569void ViewManager::doSearch( const QString& s,KABC::Field *field ) 571void ViewManager::doSearch( const QString& s,KABC::Field *field )
570{ 572{
571 if ( mActiveView ) 573 if ( mActiveView )
572 mActiveView->doSearch( s, field ); 574 mActiveView->doSearch( s, field );
573 575
574} 576}
575void ViewManager::setActiveFilter( int index ) 577void ViewManager::setActiveFilter( int index )
576{ 578{
577 Filter currentFilter; 579 Filter currentFilter;
578 580
579 if ( ( index - 1 ) < 0 ) 581 if ( ( index - 1 ) < 0 )
580 currentFilter = Filter(); 582 currentFilter = Filter();
581 else 583 else
582 currentFilter = mFilterList[ index - 1 ]; 584 currentFilter = mFilterList[ index - 1 ];
583 585
584 // Check if we have a view. Since the filter combo is created before 586 // Check if we have a view. Since the filter combo is created before
585 // the view, this slot could be called before there is a valid view. 587 // the view, this slot could be called before there is a valid view.
586 if ( mActiveView ) { 588 if ( mActiveView ) {
587 mActiveView->setFilter( currentFilter ); 589 mActiveView->setFilter( currentFilter );
588 mActiveView->refresh(); 590 mActiveView->refresh();
589 emit selected( QString::null ); 591 emit selected( QString::null );
590 } 592 }
591} 593}
592 594
593void ViewManager::configureFilters() 595void ViewManager::configureFilters()
594{ 596{
595 FilterDialog dlg( this ); 597 FilterDialog dlg( this );
596 598
597 dlg.setFilters( mFilterList ); 599 dlg.setFilters( mFilterList );
598 600
599 if ( dlg.exec() ) 601 if ( dlg.exec() )
600 mFilterList = dlg.filters(); 602 mFilterList = dlg.filters();
601 603
602 uint pos = mActionSelectFilter->currentItem(); 604 uint pos = mActionSelectFilter->currentItem();
603 mActionSelectFilter->setItems( filterNames() ); 605 mActionSelectFilter->setItems( filterNames() );
604 mActionSelectFilter->setCurrentItem( pos ); 606 mActionSelectFilter->setCurrentItem( pos );
605 setActiveFilter( pos ); 607 setActiveFilter( pos );
606 int cw = 150; 608 int cw = 150;
609 if ( QApplication::desktop()->width() >= 800 )
610 cw = 200;
607 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) 611 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch)
608 cw = 0; 612 cw = 0;
609 mActionSelectFilter->setComboWidth( cw ); 613 mActionSelectFilter->setComboWidth( cw );
610 saveSettings(); 614 saveSettings();
611} 615}
612 616
613QStringList ViewManager::filterNames() const 617QStringList ViewManager::filterNames() const
614{ 618{
615 QStringList names( i18n( "No Filter" ) ); 619 QStringList names( i18n( "No Filter" ) );
616 620
617 Filter::List::ConstIterator it; 621 Filter::List::ConstIterator it;
618 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 622 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
619 names.append( (*it).name() ); 623 names.append( (*it).name() );
620 624
621 return names; 625 return names;
622} 626}
623Filter ViewManager::getFilterByName( const QString &name ) const 627Filter ViewManager::getFilterByName( const QString &name ) const
624{ 628{
625 Filter::List::ConstIterator it; 629 Filter::List::ConstIterator it;
626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 630 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
627 if ( name == (*it).name() ) 631 if ( name == (*it).name() )
628 return (*it); 632 return (*it);
629 633
630 return Filter(); 634 return Filter();
631} 635}
632 636
633int ViewManager::filterPosition( const QString &name ) const 637int ViewManager::filterPosition( const QString &name ) const
634{ 638{
635 int pos = 0; 639 int pos = 0;
636 640
637 Filter::List::ConstIterator it; 641 Filter::List::ConstIterator it;
638 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 642 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
639 if ( name == (*it).name() ) 643 if ( name == (*it).name() )
640 return pos + 1; 644 return pos + 1;
641 645
642 return 0; 646 return 0;
643} 647}
644 648
645void ViewManager::initActions() 649void ViewManager::initActions()
646{ 650{
647//US <ActionList name="view_loadedviews"/> 651//US <ActionList name="view_loadedviews"/>
648//US <Separator/> 652//US <Separator/>
649 653
650#ifdef KAB_EMBEDDED 654#ifdef KAB_EMBEDDED
651 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 655 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
652 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 656 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
653 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 657 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
654#endif //KAB_EMBEDDED 658#endif //KAB_EMBEDDED
655 659
656 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 660 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
657#if KDE_VERSION >= 309 661#if KDE_VERSION >= 309
658 mActionSelectView->setMenuAccelsEnabled( false ); 662 mActionSelectView->setMenuAccelsEnabled( false );
659#endif 663#endif
660 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 664 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
661 SLOT( selectView( const QString& ) ) ); 665 SLOT( selectView( const QString& ) ) );
662 666
663 667
664#ifdef KAB_EMBEDDED 668#ifdef KAB_EMBEDDED
665 mActionSelectView->plug(viewmenu); 669 mActionSelectView->plug(viewmenu);
666 viewmenu->insertSeparator(); 670 viewmenu->insertSeparator();
667#endif //KAB_EMBEDDED 671#endif //KAB_EMBEDDED
668 672
669 KAction *action; 673 KAction *action;
670 674
671 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 675 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,
672 SLOT( editView() ), mCore->actionCollection(), "view_modify" ); 676 SLOT( editView() ), mCore->actionCollection(), "view_modify" );
673#ifndef KAB_EMBEDDED 677#ifndef KAB_EMBEDDED
674 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); 678 action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) );
675#else //KAB_EMBEDDED 679#else //KAB_EMBEDDED
676 action->plug(viewmenu); 680 action->plug(viewmenu);
677#endif //KAB_EMBEDDED 681#endif //KAB_EMBEDDED
678 682
679 action = new KAction( i18n( "Add View..." ), "window_new", 0, this, 683 action = new KAction( i18n( "Add View..." ), "window_new", 0, this,
680 SLOT( addView() ), mCore->actionCollection(), "view_add" ); 684 SLOT( addView() ), mCore->actionCollection(), "view_add" );
681#ifndef KAB_EMBEDDED 685#ifndef KAB_EMBEDDED
682 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); 686 action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) );
683#else //KAB_EMBEDDED 687#else //KAB_EMBEDDED
684 action->plug(viewmenu); 688 action->plug(viewmenu);
685#endif //KAB_EMBEDDED 689#endif //KAB_EMBEDDED
686 690
687 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, 691 mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0,
688 this, SLOT( deleteView() ), 692 this, SLOT( deleteView() ),
689 mCore->actionCollection(), "view_delete" ); 693 mCore->actionCollection(), "view_delete" );
690#ifndef KAB_EMBEDDED 694#ifndef KAB_EMBEDDED
691 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); 695 mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) );
692#else //KAB_EMBEDDED 696#else //KAB_EMBEDDED
693 mActionDeleteView->plug(viewmenu); 697 mActionDeleteView->plug(viewmenu);
694 viewmenu->insertSeparator(); 698 viewmenu->insertSeparator();
695#endif //KAB_EMBEDDED 699#endif //KAB_EMBEDDED
696 700
697#ifndef KAB_EMBEDDED 701#ifndef KAB_EMBEDDED
698 action = new KAction( i18n( "Refresh View" ), "reload", 0, this, 702 action = new KAction( i18n( "Refresh View" ), "reload", 0, this,
699 SLOT( refreshView(const QString &) ), mCore->actionCollection(), 703 SLOT( refreshView(const QString &) ), mCore->actionCollection(),
700 "view_refresh" ); 704 "view_refresh" );
701 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); 705 action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) );
702#else //KAB_EMBEDDED 706#else //KAB_EMBEDDED