summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (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
@@ -79,96 +79,97 @@ IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
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}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index a4f3579..cba5850 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -540,114 +540,97 @@ void KABCore::restoreSettings()
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 )
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 336e350..50db377 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -44,60 +44,76 @@ int main( int argc, char **argv )
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
@@ -63,96 +63,98 @@ $Id$
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
@@ -559,96 +561,98 @@ void ViewManager::startDrag()
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