summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp7
-rw-r--r--kaddressbook/kabcore.cpp1
2 files changed, 6 insertions, 2 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index b1ffe04..5f8b83d 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -1,178 +1,181 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qapplication.h> 27#include <qapplication.h>
28#include <qcombobox.h> 28#include <qcombobox.h>
29 29
30#include <kdialog.h> 30#include <kdialog.h>
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 setCurrentItem( 0 );
122 mSearchText->setMaximumWidth( 30 ); 122 //mFieldCombo->setMaximumWidth( 0 );
123 mFieldCombo->hide();
124 mSearchText->setMaximumWidth( 200 );
123 } else { 125 } else {
126 mFieldCombo->show();
124 QFontMetrics fm ( mFieldCombo->font() ); 127 QFontMetrics fm ( mFieldCombo->font() );
125 int wid = fm.width(i18n( "All Fields" ) ); 128 int wid = fm.width(i18n( "All Fields" ) );
126#ifdef DESKTOP_VERSION 129#ifdef DESKTOP_VERSION
127 mFieldCombo->setMinimumWidth( wid+60 ); 130 mFieldCombo->setMinimumWidth( wid+60 );
128 wid = wid * 2; 131 wid = wid * 2;
129#endif 132#endif
130 mFieldCombo->setMaximumWidth( wid+60 ); 133 mFieldCombo->setMaximumWidth( wid+60 );
131 mSearchText->setMaximumWidth( 1024 ); 134 mSearchText->setMaximumWidth( 1024 );
132 } 135 }
133} 136}
134void IncSearchWidget::setFields( const KABC::Field::List &list ) 137void IncSearchWidget::setFields( const KABC::Field::List &list )
135{ 138{
136 139
137 mFieldCombo->clear(); 140 mFieldCombo->clear();
138 mFieldCombo->insertItem( i18n( "All Fields" ) ); 141 mFieldCombo->insertItem( i18n( "All Fields" ) );
139 142
140 KABC::Field::List::ConstIterator it; 143 KABC::Field::List::ConstIterator it;
141 for ( it = list.begin(); it != list.end(); ++it ) { 144 for ( it = list.begin(); it != list.end(); ++it ) {
142 mFieldCombo->insertItem( (*it)->label() ); 145 mFieldCombo->insertItem( (*it)->label() );
143 } 146 }
144 147
145 mFieldList = list; 148 mFieldList = list;
146 149
147 announceDoSearch(); 150 announceDoSearch();
148 announceFieldChanged(); 151 announceFieldChanged();
149 setSize(); 152 setSize();
150} 153}
151 154
152KABC::Field::List IncSearchWidget::fields() const 155KABC::Field::List IncSearchWidget::fields() const
153{ 156{
154 return mFieldList; 157 return mFieldList;
155} 158}
156 159
157KABC::Field *IncSearchWidget::currentField()const 160KABC::Field *IncSearchWidget::currentField()const
158{ 161{
159 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) 162 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
160 return 0; // for error or 'use all fields' 163 return 0; // for error or 'use all fields'
161 else 164 else
162 return mFieldList[ mFieldCombo->currentItem() - 1 ]; 165 return mFieldList[ mFieldCombo->currentItem() - 1 ];
163} 166}
164 167
165void IncSearchWidget::setCurrentItem( int pos ) 168void IncSearchWidget::setCurrentItem( int pos )
166{ 169{
167 mFieldCombo->setCurrentItem( pos ); 170 mFieldCombo->setCurrentItem( pos );
168 announceFieldChanged(); 171 announceFieldChanged();
169} 172}
170 173
171int IncSearchWidget::currentItem() const 174int IncSearchWidget::currentItem() const
172{ 175{
173 176
174 return mFieldCombo->currentItem(); 177 return mFieldCombo->currentItem();
175} 178}
176#ifndef KAB_EMBEDDED 179#ifndef KAB_EMBEDDED
177#include "incsearchwidget.moc" 180#include "incsearchwidget.moc"
178#endif //KAB_EMBEDDED 181#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 046cb63..b4e0b07 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3443 +1,3444 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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 Async a special exception, permission is given to link this program 19 Async 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/*s 24/*s
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#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99#include <kprefsdialog.h> 99#include <kprefsdialog.h>
100 100
101 101
102//#include <qlabel.h> 102//#include <qlabel.h>
103 103
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106#include <qpe/ir.h> 106#include <qpe/ir.h>
107#include <qpe/qpemenubar.h> 107#include <qpe/qpemenubar.h>
108#include <qtopia/qcopenvelope_qws.h> 108#include <qtopia/qcopenvelope_qws.h>
109#else 109#else
110 110
111#include <qmenubar.h> 111#include <qmenubar.h>
112#endif 112#endif
113 113
114#endif // KAB_EMBEDDED 114#endif // KAB_EMBEDDED
115#include "kcmconfigs/kcmkabconfig.h" 115#include "kcmconfigs/kcmkabconfig.h"
116#include "kcmconfigs/kcmkdepimconfig.h" 116#include "kcmconfigs/kcmkdepimconfig.h"
117#include "kpimglobalprefs.h" 117#include "kpimglobalprefs.h"
118#include "externalapphandler.h" 118#include "externalapphandler.h"
119#include "xxportselectdialog.h" 119#include "xxportselectdialog.h"
120 120
121 121
122#include <kresources/selectdialog.h> 122#include <kresources/selectdialog.h>
123#include <kmessagebox.h> 123#include <kmessagebox.h>
124 124
125#include <picture.h> 125#include <picture.h>
126#include <resource.h> 126#include <resource.h>
127 127
128//US#include <qsplitter.h> 128//US#include <qsplitter.h>
129#include <qmap.h> 129#include <qmap.h>
130#include <qdir.h> 130#include <qdir.h>
131#include <qfile.h> 131#include <qfile.h>
132#include <qvbox.h> 132#include <qvbox.h>
133#include <qlayout.h> 133#include <qlayout.h>
134#include <qclipboard.h> 134#include <qclipboard.h>
135#include <qtextstream.h> 135#include <qtextstream.h>
136#include <qradiobutton.h> 136#include <qradiobutton.h>
137#include <qbuttongroup.h> 137#include <qbuttongroup.h>
138 138
139#include <libkdepim/categoryselectdialog.h> 139#include <libkdepim/categoryselectdialog.h>
140#include <libkdepim/categoryeditdialog.h> 140#include <libkdepim/categoryeditdialog.h>
141#include <kabc/vcardconverter.h> 141#include <kabc/vcardconverter.h>
142 142
143 143
144#include "addresseeutil.h" 144#include "addresseeutil.h"
145#include "undocmds.h" 145#include "undocmds.h"
146#include "addresseeeditordialog.h" 146#include "addresseeeditordialog.h"
147#include "viewmanager.h" 147#include "viewmanager.h"
148#include "details/detailsviewcontainer.h" 148#include "details/detailsviewcontainer.h"
149#include "kabprefs.h" 149#include "kabprefs.h"
150#include "xxportmanager.h" 150#include "xxportmanager.h"
151#include "incsearchwidget.h" 151#include "incsearchwidget.h"
152#include "jumpbuttonbar.h" 152#include "jumpbuttonbar.h"
153#include "extensionmanager.h" 153#include "extensionmanager.h"
154#include "addresseeconfig.h" 154#include "addresseeconfig.h"
155#include "nameeditdialog.h" 155#include "nameeditdialog.h"
156#include <kcmultidialog.h> 156#include <kcmultidialog.h>
157 157
158#ifdef _WIN32_ 158#ifdef _WIN32_
159#ifdef _OL_IMPORT_ 159#ifdef _OL_IMPORT_
160#include "kaimportoldialog.h" 160#include "kaimportoldialog.h"
161#endif 161#endif
162#else 162#else
163#include <unistd.h> 163#include <unistd.h>
164#endif 164#endif
165// sync includes 165// sync includes
166#include <libkdepim/ksyncprofile.h> 166#include <libkdepim/ksyncprofile.h>
167#include <libkdepim/ksyncprefsdialog.h> 167#include <libkdepim/ksyncprefsdialog.h>
168 168
169 169
170class KABCatPrefs : public QDialog 170class KABCatPrefs : public QDialog
171{ 171{
172 public: 172 public:
173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
175 { 175 {
176 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
179 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab ); 181 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format ); 183 lay->addWidget( format );
184 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from addressees"), format ); 186 new QRadioButton(i18n("Remove from addressees"), format );
187 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok ); 189 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 ); 194 resize( 200, 200 );
195 } 195 }
196 196
197 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
198private: 198private:
199 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
200}; 200};
201 201
202class KABFormatPrefs : public QDialog 202class KABFormatPrefs : public QDialog
203{ 203{
204 public: 204 public:
205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
206 QDialog( parent, name, true ) 206 QDialog( parent, name, true )
207 { 207 {
208 setCaption( i18n("Set formatted name") ); 208 setCaption( i18n("Set formatted name") );
209 QVBoxLayout* lay = new QVBoxLayout( this ); 209 QVBoxLayout* lay = new QVBoxLayout( this );
210 lay->setSpacing( 3 ); 210 lay->setSpacing( 3 );
211 lay->setMargin( 3 ); 211 lay->setMargin( 3 );
212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
213 lay->addWidget( lab ); 213 lay->addWidget( lab );
214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
215 lay->addWidget( format ); 215 lay->addWidget( format );
216 format->setExclusive ( true ) ; 216 format->setExclusive ( true ) ;
217 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 217 simple = new QRadioButton(i18n("Simple: James Bond"), format );
218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
220 company = new QRadioButton(i18n("Organization: MI6"), format ); 220 company = new QRadioButton(i18n("Organization: MI6"), format );
221 simple->setChecked( true ); 221 simple->setChecked( true );
222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
223 lay->addWidget( setCompany ); 223 lay->addWidget( setCompany );
224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
225 lay->addWidget( ok ); 225 lay->addWidget( ok );
226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
227 lay->addWidget( cancel ); 227 lay->addWidget( cancel );
228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
230 //resize( 200, 200 ); 230 //resize( 200, 200 );
231 231
232 } 232 }
233public: 233public:
234 QRadioButton* simple, *full, *reverse, *company; 234 QRadioButton* simple, *full, *reverse, *company;
235 QCheckBox* setCompany; 235 QCheckBox* setCompany;
236}; 236};
237 237
238 238
239 239
240class KAex2phonePrefs : public QDialog 240class KAex2phonePrefs : public QDialog
241{ 241{
242 public: 242 public:
243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
244 QDialog( parent, name, true ) 244 QDialog( parent, name, true )
245 { 245 {
246 setCaption( i18n("Export to phone options") ); 246 setCaption( i18n("Export to phone options") );
247 QVBoxLayout* lay = new QVBoxLayout( this ); 247 QVBoxLayout* lay = new QVBoxLayout( this );
248 lay->setSpacing( 3 ); 248 lay->setSpacing( 3 );
249 lay->setMargin( 3 ); 249 lay->setMargin( 3 );
250 QLabel *lab; 250 QLabel *lab;
251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
252 lab->setAlignment (AlignHCenter ); 252 lab->setAlignment (AlignHCenter );
253 QHBox* temphb; 253 QHBox* temphb;
254 temphb = new QHBox( this ); 254 temphb = new QHBox( this );
255 new QLabel( i18n("I/O device: "), temphb ); 255 new QLabel( i18n("I/O device: "), temphb );
256 mPhoneDevice = new QLineEdit( temphb); 256 mPhoneDevice = new QLineEdit( temphb);
257 lay->addWidget( temphb ); 257 lay->addWidget( temphb );
258 temphb = new QHBox( this ); 258 temphb = new QHBox( this );
259 new QLabel( i18n("Connection: "), temphb ); 259 new QLabel( i18n("Connection: "), temphb );
260 mPhoneConnection = new QLineEdit( temphb); 260 mPhoneConnection = new QLineEdit( temphb);
261 lay->addWidget( temphb ); 261 lay->addWidget( temphb );
262 temphb = new QHBox( this ); 262 temphb = new QHBox( this );
263 new QLabel( i18n("Model(opt.): "), temphb ); 263 new QLabel( i18n("Model(opt.): "), temphb );
264 mPhoneModel = new QLineEdit( temphb); 264 mPhoneModel = new QLineEdit( temphb);
265 lay->addWidget( temphb ); 265 lay->addWidget( temphb );
266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
267 // lay->addWidget( mWriteToSim ); 267 // lay->addWidget( mWriteToSim );
268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
269 lab->setAlignment (AlignHCenter); 269 lab->setAlignment (AlignHCenter);
270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
271 lay->addWidget( ok ); 271 lay->addWidget( ok );
272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
273 lay->addWidget( cancel ); 273 lay->addWidget( cancel );
274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
276 resize( 220, 240 ); 276 resize( 220, 240 );
277 277
278 } 278 }
279 279
280public: 280public:
281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
282 QCheckBox* mWriteToSim; 282 QCheckBox* mWriteToSim;
283}; 283};
284 284
285 285
286bool pasteWithNewUid = true; 286bool pasteWithNewUid = true;
287 287
288#ifdef KAB_EMBEDDED 288#ifdef KAB_EMBEDDED
289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
293#else //KAB_EMBEDDED 293#else //KAB_EMBEDDED
294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
297 mReadWrite( readWrite ), mModified( false ) 297 mReadWrite( readWrite ), mModified( false )
298#endif //KAB_EMBEDDED 298#endif //KAB_EMBEDDED
299{ 299{
300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
301 // syncManager->setBlockSave(false); 301 // syncManager->setBlockSave(false);
302 mIncSearchWidget = 0; 302 mIncSearchWidget = 0;
303 mMiniSplitter = 0; 303 mMiniSplitter = 0;
304 mExtensionBarSplitter = 0; 304 mExtensionBarSplitter = 0;
305 mIsPart = !parent->inherits( "KAddressBookMain" ); 305 mIsPart = !parent->inherits( "KAddressBookMain" );
306 mAddressBook = KABC::StdAddressBook::self(); 306 mAddressBook = KABC::StdAddressBook::self();
307 KABC::StdAddressBook::setAutomaticSave( false ); 307 KABC::StdAddressBook::setAutomaticSave( false );
308 308
309#ifndef KAB_EMBEDDED 309#ifndef KAB_EMBEDDED
310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
311#endif //KAB_EMBEDDED 311#endif //KAB_EMBEDDED
312 312
313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
314 SLOT( addressBookChanged() ) ); 314 SLOT( addressBookChanged() ) );
315 315
316#if 0 316#if 0
317 // LR moved to addressbook init method 317 // LR moved to addressbook init method
318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
319 "X-Department", "KADDRESSBOOK" ); 319 "X-Department", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
321 "X-Profession", "KADDRESSBOOK" ); 321 "X-Profession", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
323 "X-AssistantsName", "KADDRESSBOOK" ); 323 "X-AssistantsName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
325 "X-ManagersName", "KADDRESSBOOK" ); 325 "X-ManagersName", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
327 "X-SpousesName", "KADDRESSBOOK" ); 327 "X-SpousesName", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
329 "X-Office", "KADDRESSBOOK" ); 329 "X-Office", "KADDRESSBOOK" );
330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
331 "X-IMAddress", "KADDRESSBOOK" ); 331 "X-IMAddress", "KADDRESSBOOK" );
332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
333 "X-Anniversary", "KADDRESSBOOK" ); 333 "X-Anniversary", "KADDRESSBOOK" );
334 334
335 //US added this field to become compatible with Opie/qtopia addressbook 335 //US added this field to become compatible with Opie/qtopia addressbook
336 // values can be "female" or "male" or "". An empty field represents undefined. 336 // values can be "female" or "male" or "". An empty field represents undefined.
337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
338 "X-Gender", "KADDRESSBOOK" ); 338 "X-Gender", "KADDRESSBOOK" );
339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
340 "X-Children", "KADDRESSBOOK" ); 340 "X-Children", "KADDRESSBOOK" );
341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
342 "X-FreeBusyUrl", "KADDRESSBOOK" ); 342 "X-FreeBusyUrl", "KADDRESSBOOK" );
343#endif 343#endif
344 initGUI(); 344 initGUI();
345 345
346 mIncSearchWidget->setFocus(); 346 mIncSearchWidget->setFocus();
347 347
348 348
349 connect( mViewManager, SIGNAL( selected( const QString& ) ), 349 connect( mViewManager, SIGNAL( selected( const QString& ) ),
350 SLOT( setContactSelected( const QString& ) ) ); 350 SLOT( setContactSelected( const QString& ) ) );
351 connect( mViewManager, SIGNAL( executed( const QString& ) ), 351 connect( mViewManager, SIGNAL( executed( const QString& ) ),
352 SLOT( executeContact( const QString& ) ) ); 352 SLOT( executeContact( const QString& ) ) );
353 353
354 connect( mViewManager, SIGNAL( deleteRequest( ) ), 354 connect( mViewManager, SIGNAL( deleteRequest( ) ),
355 SLOT( deleteContacts( ) ) ); 355 SLOT( deleteContacts( ) ) );
356 connect( mViewManager, SIGNAL( modified() ), 356 connect( mViewManager, SIGNAL( modified() ),
357 SLOT( setModified() ) ); 357 SLOT( setModified() ) );
358 358
359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
361 361
362 connect( mXXPortManager, SIGNAL( modified() ), 362 connect( mXXPortManager, SIGNAL( modified() ),
363 SLOT( setModified() ) ); 363 SLOT( setModified() ) );
364 364
365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
366 SLOT( incrementalSearchJump( const QString& ) ) ); 366 SLOT( incrementalSearchJump( const QString& ) ) );
367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
368 mJumpButtonBar, SLOT( recreateButtons() ) ); 368 mJumpButtonBar, SLOT( recreateButtons() ) );
369 369
370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
371 SLOT( sendMail( const QString& ) ) ); 371 SLOT( sendMail( const QString& ) ) );
372 372
373 373
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
375 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 375 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); 378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync()));
379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
380 380
381 381
382#ifndef KAB_EMBEDDED 382#ifndef KAB_EMBEDDED
383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
384 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 384 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
385 385
386 connect( mDetails, SIGNAL( browse( const QString& ) ), 386 connect( mDetails, SIGNAL( browse( const QString& ) ),
387 SLOT( browse( const QString& ) ) ); 387 SLOT( browse( const QString& ) ) );
388 388
389 389
390 mAddressBookService = new KAddressBookService( this ); 390 mAddressBookService = new KAddressBookService( this );
391 391
392#endif //KAB_EMBEDDED 392#endif //KAB_EMBEDDED
393 393
394 mMessageTimer = new QTimer( this ); 394 mMessageTimer = new QTimer( this );
395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
396 mEditorDialog = 0; 396 mEditorDialog = 0;
397 createAddresseeEditorDialog( this ); 397 createAddresseeEditorDialog( this );
398 setModified( false ); 398 setModified( false );
399 mBRdisabled = false; 399 mBRdisabled = false;
400#ifndef DESKTOP_VERSION 400#ifndef DESKTOP_VERSION
401 infrared = 0; 401 infrared = 0;
402#endif 402#endif
403 //toggleBeamReceive( ); 403 //toggleBeamReceive( );
404 mMainWindow->toolBar()->show(); 404 mMainWindow->toolBar()->show();
405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
406 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 406 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
407} 407}
408 408
409void KABCore::updateToolBar() 409void KABCore::updateToolBar()
410{ 410{
411 static int iii = 0; 411 static int iii = 0;
412 ++iii; 412 ++iii;
413 mMainWindow->toolBar()->repaintMe(); 413 mMainWindow->toolBar()->repaintMe();
414 if ( iii < 4 ) 414 if ( iii < 4 )
415 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 415 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
416} 416}
417KABCore::~KABCore() 417KABCore::~KABCore()
418{ 418{
419 // save(); 419 // save();
420 //saveSettings(); 420 //saveSettings();
421 //KABPrefs::instance()->writeConfig(); 421 //KABPrefs::instance()->writeConfig();
422 delete AddresseeConfig::instance(); 422 delete AddresseeConfig::instance();
423 mAddressBook = 0; 423 mAddressBook = 0;
424 KABC::StdAddressBook::close(); 424 KABC::StdAddressBook::close();
425 425
426 delete syncManager; 426 delete syncManager;
427#ifndef DESKTOP_VERSION 427#ifndef DESKTOP_VERSION
428 if ( infrared ) 428 if ( infrared )
429 delete infrared; 429 delete infrared;
430#endif 430#endif
431} 431}
432void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 432void KABCore::receive( const QCString& cmsg, const QByteArray& data )
433{ 433{
434 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 434 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
435 if ( cmsg == "setDocument(QString)" ) { 435 if ( cmsg == "setDocument(QString)" ) {
436 QDataStream stream( data, IO_ReadOnly ); 436 QDataStream stream( data, IO_ReadOnly );
437 QString fileName; 437 QString fileName;
438 stream >> fileName; 438 stream >> fileName;
439 recieve( fileName ); 439 recieve( fileName );
440 return; 440 return;
441 } 441 }
442} 442}
443void KABCore::toggleBeamReceive( ) 443void KABCore::toggleBeamReceive( )
444{ 444{
445 if ( mBRdisabled ) 445 if ( mBRdisabled )
446 return; 446 return;
447#ifndef DESKTOP_VERSION 447#ifndef DESKTOP_VERSION
448 if ( infrared ) { 448 if ( infrared ) {
449 qDebug("KA: AB disable BeamReceive "); 449 qDebug("KA: AB disable BeamReceive ");
450 delete infrared; 450 delete infrared;
451 infrared = 0; 451 infrared = 0;
452 mActionBR->setChecked(false); 452 mActionBR->setChecked(false);
453 return; 453 return;
454 } 454 }
455 qDebug("KA: AB enable BeamReceive "); 455 qDebug("KA: AB enable BeamReceive ");
456 mActionBR->setChecked(true); 456 mActionBR->setChecked(true);
457 457
458 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 458 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
459 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 459 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
460#endif 460#endif
461} 461}
462 462
463 463
464void KABCore::disableBR(bool b) 464void KABCore::disableBR(bool b)
465{ 465{
466#ifndef DESKTOP_VERSION 466#ifndef DESKTOP_VERSION
467 if ( b ) { 467 if ( b ) {
468 if ( infrared ) { 468 if ( infrared ) {
469 toggleBeamReceive( ); 469 toggleBeamReceive( );
470 } 470 }
471 mBRdisabled = true; 471 mBRdisabled = true;
472 } else { 472 } else {
473 if ( mBRdisabled ) { 473 if ( mBRdisabled ) {
474 mBRdisabled = false; 474 mBRdisabled = false;
475 //toggleBeamReceive( ); 475 //toggleBeamReceive( );
476 } 476 }
477 } 477 }
478#endif 478#endif
479 479
480} 480}
481void KABCore::recieve( QString fn ) 481void KABCore::recieve( QString fn )
482{ 482{
483 //qDebug("KABCore::recieve "); 483 //qDebug("KABCore::recieve ");
484 int count = mAddressBook->importFromFile( fn, true ); 484 int count = mAddressBook->importFromFile( fn, true );
485 if ( count ) 485 if ( count )
486 setModified( true ); 486 setModified( true );
487 mViewManager->refreshView(); 487 mViewManager->refreshView();
488 message(i18n("%1 contact(s) received!").arg( count )); 488 message(i18n("%1 contact(s) received!").arg( count ));
489 topLevelWidget()->showMaximized(); 489 topLevelWidget()->showMaximized();
490 topLevelWidget()->raise(); 490 topLevelWidget()->raise();
491} 491}
492void KABCore::restoreSettings() 492void KABCore::restoreSettings()
493{ 493{
494 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 494 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
495 495
496 bool state; 496 bool state;
497 497
498 if (mMultipleViewsAtOnce) 498 if (mMultipleViewsAtOnce)
499 state = KABPrefs::instance()->mDetailsPageVisible; 499 state = KABPrefs::instance()->mDetailsPageVisible;
500 else 500 else
501 state = false; 501 state = false;
502 502
503 mActionDetails->setChecked( state ); 503 mActionDetails->setChecked( state );
504 setDetailsVisible( state ); 504 setDetailsVisible( state );
505 505
506 state = KABPrefs::instance()->mJumpButtonBarVisible; 506 state = KABPrefs::instance()->mJumpButtonBarVisible;
507 507
508 mActionJumpBar->setChecked( state ); 508 mActionJumpBar->setChecked( state );
509 setJumpButtonBarVisible( state ); 509 setJumpButtonBarVisible( state );
510/*US 510/*US
511 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 511 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
512 if ( splitterSize.count() == 0 ) { 512 if ( splitterSize.count() == 0 ) {
513 splitterSize.append( width() / 2 ); 513 splitterSize.append( width() / 2 );
514 splitterSize.append( width() / 2 ); 514 splitterSize.append( width() / 2 );
515 } 515 }
516 mMiniSplitter->setSizes( splitterSize ); 516 mMiniSplitter->setSizes( splitterSize );
517 if ( mExtensionBarSplitter ) { 517 if ( mExtensionBarSplitter ) {
518 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 518 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
519 if ( splitterSize.count() == 0 ) { 519 if ( splitterSize.count() == 0 ) {
520 splitterSize.append( width() / 2 ); 520 splitterSize.append( width() / 2 );
521 splitterSize.append( width() / 2 ); 521 splitterSize.append( width() / 2 );
522 } 522 }
523 mExtensionBarSplitter->setSizes( splitterSize ); 523 mExtensionBarSplitter->setSizes( splitterSize );
524 524
525 } 525 }
526*/ 526*/
527 mViewManager->restoreSettings(); 527 mViewManager->restoreSettings();
528 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 528 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
529 mExtensionManager->restoreSettings(); 529 mExtensionManager->restoreSettings();
530#ifdef DESKTOP_VERSION 530#ifdef DESKTOP_VERSION
531 int wid = width(); 531 int wid = width();
532 if ( wid < 10 ) 532 if ( wid < 10 )
533 wid = 400; 533 wid = 400;
534#else 534#else
535 int wid = QApplication::desktop()->width(); 535 int wid = QApplication::desktop()->width();
536 if ( wid < 640 ) 536 if ( wid < 640 )
537 wid = QApplication::desktop()->height(); 537 wid = QApplication::desktop()->height();
538#endif 538#endif
539 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 539 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
540 if ( true /*splitterSize.count() == 0*/ ) { 540 if ( true /*splitterSize.count() == 0*/ ) {
541 splitterSize.append( wid / 2 ); 541 splitterSize.append( wid / 2 );
542 splitterSize.append( wid / 2 ); 542 splitterSize.append( wid / 2 );
543 } 543 }
544 mMiniSplitter->setSizes( splitterSize ); 544 mMiniSplitter->setSizes( splitterSize );
545 if ( mExtensionBarSplitter ) { 545 if ( mExtensionBarSplitter ) {
546 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 546 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
547 if ( true /*splitterSize.count() == 0*/ ) { 547 if ( true /*splitterSize.count() == 0*/ ) {
548 splitterSize.append( wid / 2 ); 548 splitterSize.append( wid / 2 );
549 splitterSize.append( wid / 2 ); 549 splitterSize.append( wid / 2 );
550 } 550 }
551 mExtensionBarSplitter->setSizes( splitterSize ); 551 mExtensionBarSplitter->setSizes( splitterSize );
552 552
553 } 553 }
554#ifdef DESKTOP_VERSION 554#ifdef DESKTOP_VERSION
555 KConfig *config = KABPrefs::instance()->getConfig(); 555 KConfig *config = KABPrefs::instance()->getConfig();
556 config->setGroup("WidgetLayout"); 556 config->setGroup("WidgetLayout");
557 QStringList list; 557 QStringList list;
558 list = config->readListEntry("MainLayout"); 558 list = config->readListEntry("MainLayout");
559 int x,y,w,h; 559 int x,y,w,h;
560 if ( ! list.isEmpty() ) { 560 if ( ! list.isEmpty() ) {
561 x = list[0].toInt(); 561 x = list[0].toInt();
562 y = list[1].toInt(); 562 y = list[1].toInt();
563 w = list[2].toInt(); 563 w = list[2].toInt();
564 h = list[3].toInt(); 564 h = list[3].toInt();
565 KApplication::testCoords( &x,&y,&w,&h ); 565 KApplication::testCoords( &x,&y,&w,&h );
566 topLevelWidget()->setGeometry(x,y,w,h); 566 topLevelWidget()->setGeometry(x,y,w,h);
567 567
568 } else { 568 } else {
569 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 569 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
570 } 570 }
571#endif 571#endif
572} 572}
573 573
574void KABCore::saveSettings() 574void KABCore::saveSettings()
575{ 575{
576 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 576 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
577 if ( mExtensionBarSplitter ) 577 if ( mExtensionBarSplitter )
578 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 578 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
579 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 579 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
580 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 580 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
581#ifndef KAB_EMBEDDED 581#ifndef KAB_EMBEDDED
582 582
583 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 583 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
584 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 584 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
585#endif //KAB_EMBEDDED 585#endif //KAB_EMBEDDED
586 mExtensionManager->saveSettings(); 586 mExtensionManager->saveSettings();
587 mViewManager->saveSettings(); 587 mViewManager->saveSettings();
588 588
589 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 589 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
590 590
591 KABPrefs::instance()->writeConfig(); 591 KABPrefs::instance()->writeConfig();
592 qDebug("KA: KABCore::saveSettings() "); 592 qDebug("KA: KABCore::saveSettings() ");
593} 593}
594 594
595KABC::AddressBook *KABCore::addressBook() const 595KABC::AddressBook *KABCore::addressBook() const
596{ 596{
597 return mAddressBook; 597 return mAddressBook;
598} 598}
599 599
600KConfig *KABCore::config() 600KConfig *KABCore::config()
601{ 601{
602#ifndef KAB_EMBEDDED 602#ifndef KAB_EMBEDDED
603 return KABPrefs::instance()->config(); 603 return KABPrefs::instance()->config();
604#else //KAB_EMBEDDED 604#else //KAB_EMBEDDED
605 return KABPrefs::instance()->getConfig(); 605 return KABPrefs::instance()->getConfig();
606#endif //KAB_EMBEDDED 606#endif //KAB_EMBEDDED
607} 607}
608 608
609KActionCollection *KABCore::actionCollection() const 609KActionCollection *KABCore::actionCollection() const
610{ 610{
611 return mGUIClient->actionCollection(); 611 return mGUIClient->actionCollection();
612} 612}
613 613
614KABC::Field *KABCore::currentSearchField() const 614KABC::Field *KABCore::currentSearchField() const
615{ 615{
616 if (mIncSearchWidget) 616 if (mIncSearchWidget)
617 return mIncSearchWidget->currentField(); 617 return mIncSearchWidget->currentField();
618 else 618 else
619 return 0; 619 return 0;
620} 620}
621 621
622QStringList KABCore::selectedUIDs() const 622QStringList KABCore::selectedUIDs() const
623{ 623{
624 return mViewManager->selectedUids(); 624 return mViewManager->selectedUids();
625} 625}
626 626
627KABC::Resource *KABCore::requestResource( QWidget *parent ) 627KABC::Resource *KABCore::requestResource( QWidget *parent )
628{ 628{
629 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 629 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
630 630
631 QPtrList<KRES::Resource> kresResources; 631 QPtrList<KRES::Resource> kresResources;
632 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 632 QPtrListIterator<KABC::Resource> resIt( kabcResources );
633 KABC::Resource *resource; 633 KABC::Resource *resource;
634 while ( ( resource = resIt.current() ) != 0 ) { 634 while ( ( resource = resIt.current() ) != 0 ) {
635 ++resIt; 635 ++resIt;
636 if ( !resource->readOnly() ) { 636 if ( !resource->readOnly() ) {
637 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 637 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
638 if ( res ) 638 if ( res )
639 kresResources.append( res ); 639 kresResources.append( res );
640 } 640 }
641 } 641 }
642 642
643 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 643 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
644 return static_cast<KABC::Resource*>( res ); 644 return static_cast<KABC::Resource*>( res );
645} 645}
646 646
647#ifndef KAB_EMBEDDED 647#ifndef KAB_EMBEDDED
648KAboutData *KABCore::createAboutData() 648KAboutData *KABCore::createAboutData()
649#else //KAB_EMBEDDED 649#else //KAB_EMBEDDED
650void KABCore::createAboutData() 650void KABCore::createAboutData()
651#endif //KAB_EMBEDDED 651#endif //KAB_EMBEDDED
652{ 652{
653 653
654 654
655 QString version; 655 QString version;
656#include <../version> 656#include <../version>
657 QMessageBox::about( this, "About KAddressbook/Pi", 657 QMessageBox::about( this, "About KAddressbook/Pi",
658 "KAddressbook/Platform-independent\n" 658 "KAddressbook/Platform-independent\n"
659 "(KA/Pi) " +version + " - " + 659 "(KA/Pi) " +version + " - " +
660#ifdef DESKTOP_VERSION 660#ifdef DESKTOP_VERSION
661 "Desktop Edition\n" 661 "Desktop Edition\n"
662#else 662#else
663 "PDA-Edition\n" 663 "PDA-Edition\n"
664 "for: Zaurus 5500 / 7x0 / 8x0\n" 664 "for: Zaurus 5500 / 7x0 / 8x0\n"
665#endif 665#endif
666 666
667 "(c) 2004 Ulf Schenk\n" 667 "(c) 2004 Ulf Schenk\n"
668 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 668 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
669 "(c) 1997-2003, The KDE PIM Team\n" 669 "(c) 1997-2003, The KDE PIM Team\n"
670 "Tobias Koenig Maintainer\n" 670 "Tobias Koenig Maintainer\n"
671 "Don Sanders Original author\n" 671 "Don Sanders Original author\n"
672 "Cornelius Schumacher Co-maintainer\n" 672 "Cornelius Schumacher Co-maintainer\n"
673 "Mike Pilone GUI and framework redesign\n" 673 "Mike Pilone GUI and framework redesign\n"
674 "Greg Stern DCOP interface\n" 674 "Greg Stern DCOP interface\n"
675 "Mark Westcot Contact pinning\n" 675 "Mark Westcot Contact pinning\n"
676 "Michel Boyer de la Giroday LDAP Lookup\n" 676 "Michel Boyer de la Giroday LDAP Lookup\n"
677 "Steffen Hansen LDAP Lookup" 677 "Steffen Hansen LDAP Lookup"
678#ifdef _WIN32_ 678#ifdef _WIN32_
679 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 679 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
680#endif 680#endif
681 ); 681 );
682} 682}
683 683
684void KABCore::setContactSelected( const QString &uid ) 684void KABCore::setContactSelected( const QString &uid )
685{ 685{
686 KABC::Addressee addr = mAddressBook->findByUid( uid ); 686 KABC::Addressee addr = mAddressBook->findByUid( uid );
687 if ( !mDetails->isHidden() ) 687 if ( !mDetails->isHidden() )
688 mDetails->setAddressee( addr ); 688 mDetails->setAddressee( addr );
689 689
690 if ( !addr.isEmpty() ) { 690 if ( !addr.isEmpty() ) {
691 emit contactSelected( addr.formattedName() ); 691 emit contactSelected( addr.formattedName() );
692 KABC::Picture pic = addr.photo(); 692 KABC::Picture pic = addr.photo();
693 if ( pic.isIntern() ) { 693 if ( pic.isIntern() ) {
694//US emit contactSelected( pic.data() ); 694//US emit contactSelected( pic.data() );
695//US instead use: 695//US instead use:
696 QPixmap px; 696 QPixmap px;
697 if (pic.data().isNull() != true) 697 if (pic.data().isNull() != true)
698 { 698 {
699 px.convertFromImage(pic.data()); 699 px.convertFromImage(pic.data());
700 } 700 }
701 701
702 emit contactSelected( px ); 702 emit contactSelected( px );
703 } 703 }
704 } 704 }
705 705
706 706
707 mExtensionManager->setSelectionChanged(); 707 mExtensionManager->setSelectionChanged();
708 708
709 // update the actions 709 // update the actions
710 bool selected = !uid.isEmpty(); 710 bool selected = !uid.isEmpty();
711 711
712 if ( mReadWrite ) { 712 if ( mReadWrite ) {
713 mActionCut->setEnabled( selected ); 713 mActionCut->setEnabled( selected );
714 mActionPaste->setEnabled( selected ); 714 mActionPaste->setEnabled( selected );
715 } 715 }
716 716
717 mActionCopy->setEnabled( selected ); 717 mActionCopy->setEnabled( selected );
718 mActionDelete->setEnabled( selected ); 718 mActionDelete->setEnabled( selected );
719 mActionEditAddressee->setEnabled( selected ); 719 mActionEditAddressee->setEnabled( selected );
720 mActionMail->setEnabled( selected ); 720 mActionMail->setEnabled( selected );
721 mActionMailVCard->setEnabled( selected ); 721 mActionMailVCard->setEnabled( selected );
722 //if (mActionBeam) 722 //if (mActionBeam)
723 //mActionBeam->setEnabled( selected ); 723 //mActionBeam->setEnabled( selected );
724 mActionWhoAmI->setEnabled( selected ); 724 mActionWhoAmI->setEnabled( selected );
725} 725}
726 726
727void KABCore::sendMail() 727void KABCore::sendMail()
728{ 728{
729 sendMail( mViewManager->selectedEmails().join( ", " ) ); 729 sendMail( mViewManager->selectedEmails().join( ", " ) );
730} 730}
731 731
732void KABCore::sendMail( const QString& emaillist ) 732void KABCore::sendMail( const QString& emaillist )
733{ 733{
734 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 734 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
735 if (emaillist.contains(",") > 0) 735 if (emaillist.contains(",") > 0)
736 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 736 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
737 else 737 else
738 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 738 ExternalAppHandler::instance()->mailToOneContact( emaillist );
739} 739}
740 740
741 741
742 742
743void KABCore::mailVCard() 743void KABCore::mailVCard()
744{ 744{
745 QStringList uids = mViewManager->selectedUids(); 745 QStringList uids = mViewManager->selectedUids();
746 if ( !uids.isEmpty() ) 746 if ( !uids.isEmpty() )
747 mailVCard( uids ); 747 mailVCard( uids );
748} 748}
749 749
750void KABCore::mailVCard( const QStringList& uids ) 750void KABCore::mailVCard( const QStringList& uids )
751{ 751{
752 QStringList urls; 752 QStringList urls;
753 753
754// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 754// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
755 755
756 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 756 QString dirName = "/tmp/" + KApplication::randomString( 8 );
757 757
758 758
759 759
760 QDir().mkdir( dirName, true ); 760 QDir().mkdir( dirName, true );
761 761
762 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 762 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
763 KABC::Addressee a = mAddressBook->findByUid( *it ); 763 KABC::Addressee a = mAddressBook->findByUid( *it );
764 764
765 if ( a.isEmpty() ) 765 if ( a.isEmpty() )
766 continue; 766 continue;
767 767
768 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 768 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
769 769
770 QString fileName = dirName + "/" + name; 770 QString fileName = dirName + "/" + name;
771 771
772 QFile outFile(fileName); 772 QFile outFile(fileName);
773 773
774 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 774 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
775 KABC::VCardConverter converter; 775 KABC::VCardConverter converter;
776 QString vcard; 776 QString vcard;
777 777
778 converter.addresseeToVCard( a, vcard ); 778 converter.addresseeToVCard( a, vcard );
779 779
780 QTextStream t( &outFile ); // use a text stream 780 QTextStream t( &outFile ); // use a text stream
781 t.setEncoding( QTextStream::UnicodeUTF8 ); 781 t.setEncoding( QTextStream::UnicodeUTF8 );
782 t << vcard; 782 t << vcard;
783 783
784 outFile.close(); 784 outFile.close();
785 785
786 urls.append( fileName ); 786 urls.append( fileName );
787 } 787 }
788 } 788 }
789 789
790 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 790 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
791 791
792 792
793/*US 793/*US
794 kapp->invokeMailer( QString::null, QString::null, QString::null, 794 kapp->invokeMailer( QString::null, QString::null, QString::null,
795 QString::null, // subject 795 QString::null, // subject
796 QString::null, // body 796 QString::null, // body
797 QString::null, 797 QString::null,
798 urls ); // attachments 798 urls ); // attachments
799*/ 799*/
800 800
801} 801}
802 802
803/** 803/**
804 Beams the "WhoAmI contact. 804 Beams the "WhoAmI contact.
805*/ 805*/
806void KABCore::beamMySelf() 806void KABCore::beamMySelf()
807{ 807{
808 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 808 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
809 if (!a.isEmpty()) 809 if (!a.isEmpty())
810 { 810 {
811 QStringList uids; 811 QStringList uids;
812 uids << a.uid(); 812 uids << a.uid();
813 813
814 beamVCard(uids); 814 beamVCard(uids);
815 } else { 815 } else {
816 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 816 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
817 817
818 818
819 } 819 }
820} 820}
821void KABCore::updateMainWindow() 821void KABCore::updateMainWindow()
822{ 822{
823 mMainWindow->showMaximized(); 823 mMainWindow->showMaximized();
824 mMainWindow->update(); 824 mMainWindow->update();
825} 825}
826void KABCore::resizeEvent(QResizeEvent* e ) 826void KABCore::resizeEvent(QResizeEvent* e )
827{ 827{
828 if ( !mMiniSplitter ) 828 if ( !mMiniSplitter )
829 return; 829 return;
830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
831 if ( e->oldSize().width() != e->size().width() )
831 if ( QApplication::desktop()->width() >= 480 ) { 832 if ( QApplication::desktop()->width() >= 480 ) {
832 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 833 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
833 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 834 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
834 mMiniSplitter->setOrientation( Qt::Horizontal); 835 mMiniSplitter->setOrientation( Qt::Horizontal);
835 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 836 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
836 } 837 }
837 if ( QApplication::desktop()->width() <= 640 ) { 838 if ( QApplication::desktop()->width() <= 640 ) {
838 mMainWindow->showMinimized(); 839 mMainWindow->showMinimized();
839 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 840 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
840 mViewManager->getFilterAction()->setComboWidth( 150 ); 841 mViewManager->getFilterAction()->setComboWidth( 150 );
841 if ( mIncSearchWidget ) 842 if ( mIncSearchWidget )
842 mIncSearchWidget->setSize(); 843 mIncSearchWidget->setSize();
843 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 844 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
844 } 845 }
845 846
846 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 847 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
847 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 848 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
848 mMiniSplitter->setOrientation( Qt::Vertical ); 849 mMiniSplitter->setOrientation( Qt::Vertical );
849 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 850 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
850 } 851 }
851 if ( QApplication::desktop()->width() <= 640 ) { 852 if ( QApplication::desktop()->width() <= 640 ) {
852 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 853 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
853 mMainWindow->showMinimized(); 854 mMainWindow->showMinimized();
854 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 855 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
855 if ( mIncSearchWidget ) { 856 if ( mIncSearchWidget ) {
856 mIncSearchWidget->setSize(); 857 mIncSearchWidget->setSize();
857 } 858 }
858 } else { 859 } else {
859 mViewManager->getFilterAction()->setComboWidth( 0 ); 860 mViewManager->getFilterAction()->setComboWidth( 0 );
860 } 861 }
861 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 862 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
862 } 863 }
863 } 864 }
864 } 865 }
865 QWidget::resizeEvent( e ); 866 QWidget::resizeEvent( e );
866 867
867} 868}
868void KABCore::export2phone() 869void KABCore::export2phone()
869{ 870{
870 871
871 QStringList uids; 872 QStringList uids;
872 XXPortSelectDialog dlg( this, false, this ); 873 XXPortSelectDialog dlg( this, false, this );
873 if ( dlg.exec() ) 874 if ( dlg.exec() )
874 uids = dlg.uids(); 875 uids = dlg.uids();
875 else 876 else
876 return; 877 return;
877 if ( uids.isEmpty() ) 878 if ( uids.isEmpty() )
878 return; 879 return;
879 // qDebug("count %d ", uids.count()); 880 // qDebug("count %d ", uids.count());
880 881
881 KAex2phonePrefs ex2phone; 882 KAex2phonePrefs ex2phone;
882 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 883 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
883 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 884 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
884 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 885 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
885 886
886 if ( !ex2phone.exec() ) { 887 if ( !ex2phone.exec() ) {
887 return; 888 return;
888 } 889 }
889 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 890 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
890 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 891 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
891 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 892 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
892 893
893 894
894 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 895 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
895 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 896 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
896 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 897 KPimGlobalPrefs::instance()->mEx2PhoneModel );
897 898
898 QString fileName = getPhoneFile(); 899 QString fileName = getPhoneFile();
899 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 900 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
900 return; 901 return;
901 902
902 message(i18n("Exporting to phone...")); 903 message(i18n("Exporting to phone..."));
903 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 904 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
904 905
905} 906}
906QString KABCore::getPhoneFile() 907QString KABCore::getPhoneFile()
907{ 908{
908#ifdef DESKTOP_VERSION 909#ifdef DESKTOP_VERSION
909 return locateLocal("tmp", "phonefile.vcf"); 910 return locateLocal("tmp", "phonefile.vcf");
910#else 911#else
911 return "/tmp/phonefile.vcf"; 912 return "/tmp/phonefile.vcf";
912#endif 913#endif
913 914
914} 915}
915void KABCore::writeToPhone( ) 916void KABCore::writeToPhone( )
916{ 917{
917 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 918 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
918 message(i18n("Export to phone finished!")); 919 message(i18n("Export to phone finished!"));
919 else 920 else
920 qDebug(i18n("KA: Error exporting to phone")); 921 qDebug(i18n("KA: Error exporting to phone"));
921} 922}
922void KABCore::beamVCard() 923void KABCore::beamVCard()
923{ 924{
924 QStringList uids; 925 QStringList uids;
925 XXPortSelectDialog dlg( this, false, this ); 926 XXPortSelectDialog dlg( this, false, this );
926 if ( dlg.exec() ) 927 if ( dlg.exec() )
927 uids = dlg.uids(); 928 uids = dlg.uids();
928 else 929 else
929 return; 930 return;
930 if ( uids.isEmpty() ) 931 if ( uids.isEmpty() )
931 return; 932 return;
932 beamVCard( uids ); 933 beamVCard( uids );
933} 934}
934 935
935 936
936void KABCore::beamVCard(const QStringList& uids) 937void KABCore::beamVCard(const QStringList& uids)
937{ 938{
938 939
939 // LR: we should use the /tmp dir on the Zaurus, 940 // LR: we should use the /tmp dir on the Zaurus,
940 // because: /tmp = RAM, (HOME)/kdepim = flash memory 941 // because: /tmp = RAM, (HOME)/kdepim = flash memory
941 942
942#ifdef DESKTOP_VERSION 943#ifdef DESKTOP_VERSION
943 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 944 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
944#else 945#else
945 QString fileName = "/tmp/kapibeamfile.vcf"; 946 QString fileName = "/tmp/kapibeamfile.vcf";
946#endif 947#endif
947 948
948 KABC::VCardConverter converter; 949 KABC::VCardConverter converter;
949 QString description; 950 QString description;
950 QString datastream; 951 QString datastream;
951 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 952 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
952 KABC::Addressee a = mAddressBook->findByUid( *it ); 953 KABC::Addressee a = mAddressBook->findByUid( *it );
953 954
954 if ( a.isEmpty() ) 955 if ( a.isEmpty() )
955 continue; 956 continue;
956 957
957 if (description.isEmpty()) 958 if (description.isEmpty())
958 description = a.formattedName(); 959 description = a.formattedName();
959 960
960 QString vcard; 961 QString vcard;
961 converter.addresseeToVCard( a, vcard ); 962 converter.addresseeToVCard( a, vcard );
962 int start = 0; 963 int start = 0;
963 int next; 964 int next;
964 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 965 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
965 int semi = vcard.find(";", next); 966 int semi = vcard.find(";", next);
966 int dopp = vcard.find(":", next); 967 int dopp = vcard.find(":", next);
967 int sep; 968 int sep;
968 if ( semi < dopp && semi >= 0 ) 969 if ( semi < dopp && semi >= 0 )
969 sep = semi ; 970 sep = semi ;
970 else 971 else
971 sep = dopp; 972 sep = dopp;
972 datastream +=vcard.mid( start, next - start); 973 datastream +=vcard.mid( start, next - start);
973 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 974 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
974 start = sep; 975 start = sep;
975 } 976 }
976 datastream += vcard.mid( start,vcard.length() ); 977 datastream += vcard.mid( start,vcard.length() );
977 } 978 }
978#ifndef DESKTOP_VERSION 979#ifndef DESKTOP_VERSION
979 QFile outFile(fileName); 980 QFile outFile(fileName);
980 if ( outFile.open(IO_WriteOnly) ) { 981 if ( outFile.open(IO_WriteOnly) ) {
981 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 982 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
982 QTextStream t( &outFile ); // use a text stream 983 QTextStream t( &outFile ); // use a text stream
983 //t.setEncoding( QTextStream::UnicodeUTF8 ); 984 //t.setEncoding( QTextStream::UnicodeUTF8 );
984 t.setEncoding( QTextStream::Latin1 ); 985 t.setEncoding( QTextStream::Latin1 );
985 t <<datastream.latin1(); 986 t <<datastream.latin1();
986 outFile.close(); 987 outFile.close();
987 Ir *ir = new Ir( this ); 988 Ir *ir = new Ir( this );
988 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 989 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
989 ir->send( fileName, description, "text/x-vCard" ); 990 ir->send( fileName, description, "text/x-vCard" );
990 } else { 991 } else {
991 qDebug("KA: Error open temp beam file "); 992 qDebug("KA: Error open temp beam file ");
992 return; 993 return;
993 } 994 }
994#endif 995#endif
995 996
996} 997}
997 998
998void KABCore::beamDone( Ir *ir ) 999void KABCore::beamDone( Ir *ir )
999{ 1000{
1000#ifndef DESKTOP_VERSION 1001#ifndef DESKTOP_VERSION
1001 delete ir; 1002 delete ir;
1002#endif 1003#endif
1003 topLevelWidget()->raise(); 1004 topLevelWidget()->raise();
1004 message( i18n("Beaming finished!") ); 1005 message( i18n("Beaming finished!") );
1005} 1006}
1006 1007
1007 1008
1008void KABCore::browse( const QString& url ) 1009void KABCore::browse( const QString& url )
1009{ 1010{
1010#ifndef KAB_EMBEDDED 1011#ifndef KAB_EMBEDDED
1011 kapp->invokeBrowser( url ); 1012 kapp->invokeBrowser( url );
1012#else //KAB_EMBEDDED 1013#else //KAB_EMBEDDED
1013 qDebug("KABCore::browse must be fixed"); 1014 qDebug("KABCore::browse must be fixed");
1014#endif //KAB_EMBEDDED 1015#endif //KAB_EMBEDDED
1015} 1016}
1016 1017
1017void KABCore::selectAllContacts() 1018void KABCore::selectAllContacts()
1018{ 1019{
1019 mViewManager->setSelected( QString::null, true ); 1020 mViewManager->setSelected( QString::null, true );
1020} 1021}
1021 1022
1022void KABCore::deleteContacts() 1023void KABCore::deleteContacts()
1023{ 1024{
1024 QStringList uidList = mViewManager->selectedUids(); 1025 QStringList uidList = mViewManager->selectedUids();
1025 deleteContacts( uidList ); 1026 deleteContacts( uidList );
1026} 1027}
1027 1028
1028void KABCore::deleteContacts( const QStringList &uids ) 1029void KABCore::deleteContacts( const QStringList &uids )
1029{ 1030{
1030 if ( uids.count() > 0 ) { 1031 if ( uids.count() > 0 ) {
1031 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1032 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1032 UndoStack::instance()->push( command ); 1033 UndoStack::instance()->push( command );
1033 RedoStack::instance()->clear(); 1034 RedoStack::instance()->clear();
1034 1035
1035 // now if we deleted anything, refresh 1036 // now if we deleted anything, refresh
1036 setContactSelected( QString::null ); 1037 setContactSelected( QString::null );
1037 setModified( true ); 1038 setModified( true );
1038 } 1039 }
1039} 1040}
1040 1041
1041void KABCore::copyContacts() 1042void KABCore::copyContacts()
1042{ 1043{
1043 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1044 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1044 1045
1045 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1046 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1046 1047
1047 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1048 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1048 1049
1049 QClipboard *cb = QApplication::clipboard(); 1050 QClipboard *cb = QApplication::clipboard();
1050 cb->setText( clipText ); 1051 cb->setText( clipText );
1051} 1052}
1052 1053
1053void KABCore::cutContacts() 1054void KABCore::cutContacts()
1054{ 1055{
1055 QStringList uidList = mViewManager->selectedUids(); 1056 QStringList uidList = mViewManager->selectedUids();
1056 1057
1057//US if ( uidList.size() > 0 ) { 1058//US if ( uidList.size() > 0 ) {
1058 if ( uidList.count() > 0 ) { 1059 if ( uidList.count() > 0 ) {
1059 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1060 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1060 UndoStack::instance()->push( command ); 1061 UndoStack::instance()->push( command );
1061 RedoStack::instance()->clear(); 1062 RedoStack::instance()->clear();
1062 1063
1063 setModified( true ); 1064 setModified( true );
1064 } 1065 }
1065} 1066}
1066 1067
1067void KABCore::pasteContacts() 1068void KABCore::pasteContacts()
1068{ 1069{
1069 QClipboard *cb = QApplication::clipboard(); 1070 QClipboard *cb = QApplication::clipboard();
1070 1071
1071 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1072 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1072 1073
1073 pasteContacts( list ); 1074 pasteContacts( list );
1074} 1075}
1075 1076
1076void KABCore::pasteContacts( KABC::Addressee::List &list ) 1077void KABCore::pasteContacts( KABC::Addressee::List &list )
1077{ 1078{
1078 KABC::Resource *resource = requestResource( this ); 1079 KABC::Resource *resource = requestResource( this );
1079 KABC::Addressee::List::Iterator it; 1080 KABC::Addressee::List::Iterator it;
1080 for ( it = list.begin(); it != list.end(); ++it ) 1081 for ( it = list.begin(); it != list.end(); ++it )
1081 (*it).setResource( resource ); 1082 (*it).setResource( resource );
1082 1083
1083 PwPasteCommand *command = new PwPasteCommand( this, list ); 1084 PwPasteCommand *command = new PwPasteCommand( this, list );
1084 UndoStack::instance()->push( command ); 1085 UndoStack::instance()->push( command );
1085 RedoStack::instance()->clear(); 1086 RedoStack::instance()->clear();
1086 1087
1087 setModified( true ); 1088 setModified( true );
1088} 1089}
1089 1090
1090void KABCore::setWhoAmI() 1091void KABCore::setWhoAmI()
1091{ 1092{
1092 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1093 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1093 1094
1094 if ( addrList.count() > 1 ) { 1095 if ( addrList.count() > 1 ) {
1095 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1096 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1096 return; 1097 return;
1097 } 1098 }
1098 1099
1099 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1100 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1100 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1101 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1101 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1102 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1102} 1103}
1103void KABCore::editCategories() 1104void KABCore::editCategories()
1104{ 1105{
1105 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1106 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1106 dlg.exec(); 1107 dlg.exec();
1107} 1108}
1108void KABCore::setCategories() 1109void KABCore::setCategories()
1109{ 1110{
1110 1111
1111 QStringList uids; 1112 QStringList uids;
1112 XXPortSelectDialog dlgx( this, false, this ); 1113 XXPortSelectDialog dlgx( this, false, this );
1113 if ( dlgx.exec() ) 1114 if ( dlgx.exec() )
1114 uids = dlgx.uids(); 1115 uids = dlgx.uids();
1115 else 1116 else
1116 return; 1117 return;
1117 if ( uids.isEmpty() ) 1118 if ( uids.isEmpty() )
1118 return; 1119 return;
1119 // qDebug("count %d ", uids.count()); 1120 // qDebug("count %d ", uids.count());
1120 1121
1121 1122
1122 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1123 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1123 if ( !dlg.exec() ) { 1124 if ( !dlg.exec() ) {
1124 message( i18n("Setting categories cancelled") ); 1125 message( i18n("Setting categories cancelled") );
1125 return; 1126 return;
1126 } 1127 }
1127 bool merge = false; 1128 bool merge = false;
1128 QString msg = i18n( "Merge with existing categories?" ); 1129 QString msg = i18n( "Merge with existing categories?" );
1129 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1130 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1130 merge = true; 1131 merge = true;
1131 1132
1132 message( i18n("Setting categories ... please wait!") ); 1133 message( i18n("Setting categories ... please wait!") );
1133 QStringList categories = dlg.selectedCategories(); 1134 QStringList categories = dlg.selectedCategories();
1134 1135
1135 //QStringList uids = mViewManager->selectedUids(); 1136 //QStringList uids = mViewManager->selectedUids();
1136 QStringList::Iterator it; 1137 QStringList::Iterator it;
1137 for ( it = uids.begin(); it != uids.end(); ++it ) { 1138 for ( it = uids.begin(); it != uids.end(); ++it ) {
1138 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1139 KABC::Addressee addr = mAddressBook->findByUid( *it );
1139 if ( !addr.isEmpty() ) { 1140 if ( !addr.isEmpty() ) {
1140 if ( !merge ) 1141 if ( !merge )
1141 addr.setCategories( categories ); 1142 addr.setCategories( categories );
1142 else { 1143 else {
1143 QStringList addrCategories = addr.categories(); 1144 QStringList addrCategories = addr.categories();
1144 QStringList::Iterator catIt; 1145 QStringList::Iterator catIt;
1145 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1146 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1146 if ( !addrCategories.contains( *catIt ) ) 1147 if ( !addrCategories.contains( *catIt ) )
1147 addrCategories.append( *catIt ); 1148 addrCategories.append( *catIt );
1148 } 1149 }
1149 addr.setCategories( addrCategories ); 1150 addr.setCategories( addrCategories );
1150 } 1151 }
1151 mAddressBook->insertAddressee( addr ); 1152 mAddressBook->insertAddressee( addr );
1152 } 1153 }
1153 } 1154 }
1154 1155
1155 if ( uids.count() > 0 ) 1156 if ( uids.count() > 0 )
1156 setModified( true ); 1157 setModified( true );
1157 message( i18n("Setting categories completed!") ); 1158 message( i18n("Setting categories completed!") );
1158} 1159}
1159 1160
1160void KABCore::setSearchFields( const KABC::Field::List &fields ) 1161void KABCore::setSearchFields( const KABC::Field::List &fields )
1161{ 1162{
1162 mIncSearchWidget->setFields( fields ); 1163 mIncSearchWidget->setFields( fields );
1163} 1164}
1164 1165
1165void KABCore::incrementalSearch( const QString& text ) 1166void KABCore::incrementalSearch( const QString& text )
1166{ 1167{
1167 QString stext; 1168 QString stext;
1168 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1169 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1169 stext = "*" + text; 1170 stext = "*" + text;
1170 } else { 1171 } else {
1171 stext = text; 1172 stext = text;
1172 } 1173 }
1173 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1174 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1174} 1175}
1175void KABCore::incrementalSearchJump( const QString& text ) 1176void KABCore::incrementalSearchJump( const QString& text )
1176{ 1177{
1177 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1178 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1178} 1179}
1179 1180
1180void KABCore::setModified() 1181void KABCore::setModified()
1181{ 1182{
1182 setModified( true ); 1183 setModified( true );
1183} 1184}
1184 1185
1185void KABCore::setModifiedWOrefresh() 1186void KABCore::setModifiedWOrefresh()
1186{ 1187{
1187 // qDebug("KABCore::setModifiedWOrefresh() "); 1188 // qDebug("KABCore::setModifiedWOrefresh() ");
1188 mModified = true; 1189 mModified = true;
1189 mActionSave->setEnabled( mModified ); 1190 mActionSave->setEnabled( mModified );
1190 1191
1191 1192
1192} 1193}
1193void KABCore::setModified( bool modified ) 1194void KABCore::setModified( bool modified )
1194{ 1195{
1195 mModified = modified; 1196 mModified = modified;
1196 mActionSave->setEnabled( mModified ); 1197 mActionSave->setEnabled( mModified );
1197 1198
1198 if ( modified ) 1199 if ( modified )
1199 mJumpButtonBar->recreateButtons(); 1200 mJumpButtonBar->recreateButtons();
1200 1201
1201 mViewManager->refreshView(); 1202 mViewManager->refreshView();
1202 1203
1203} 1204}
1204 1205
1205bool KABCore::modified() const 1206bool KABCore::modified() const
1206{ 1207{
1207 return mModified; 1208 return mModified;
1208} 1209}
1209 1210
1210void KABCore::contactModified( const KABC::Addressee &addr ) 1211void KABCore::contactModified( const KABC::Addressee &addr )
1211{ 1212{
1212 addrModified( addr ); 1213 addrModified( addr );
1213#if 0 // debug only 1214#if 0 // debug only
1214 KABC::Addressee ad = addr; 1215 KABC::Addressee ad = addr;
1215 ad.computeCsum( "123"); 1216 ad.computeCsum( "123");
1216#endif 1217#endif
1217} 1218}
1218 1219
1219void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1220void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1220{ 1221{
1221 1222
1222 Command *command = 0; 1223 Command *command = 0;
1223 QString uid; 1224 QString uid;
1224 1225
1225 // check if it exists already 1226 // check if it exists already
1226 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1227 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1227 if ( origAddr.isEmpty() ) 1228 if ( origAddr.isEmpty() )
1228 command = new PwNewCommand( mAddressBook, addr ); 1229 command = new PwNewCommand( mAddressBook, addr );
1229 else { 1230 else {
1230 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1231 command = new PwEditCommand( mAddressBook, origAddr, addr );
1231 uid = addr.uid(); 1232 uid = addr.uid();
1232 } 1233 }
1233 1234
1234 UndoStack::instance()->push( command ); 1235 UndoStack::instance()->push( command );
1235 RedoStack::instance()->clear(); 1236 RedoStack::instance()->clear();
1236 if ( updateDetails ) 1237 if ( updateDetails )
1237 mDetails->setAddressee( addr ); 1238 mDetails->setAddressee( addr );
1238 setModified( true ); 1239 setModified( true );
1239} 1240}
1240 1241
1241void KABCore::newContact() 1242void KABCore::newContact()
1242{ 1243{
1243 1244
1244 1245
1245 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1246 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1246 1247
1247 QPtrList<KRES::Resource> kresResources; 1248 QPtrList<KRES::Resource> kresResources;
1248 QPtrListIterator<KABC::Resource> it( kabcResources ); 1249 QPtrListIterator<KABC::Resource> it( kabcResources );
1249 KABC::Resource *resource; 1250 KABC::Resource *resource;
1250 while ( ( resource = it.current() ) != 0 ) { 1251 while ( ( resource = it.current() ) != 0 ) {
1251 ++it; 1252 ++it;
1252 if ( !resource->readOnly() ) { 1253 if ( !resource->readOnly() ) {
1253 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1254 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1254 if ( res ) 1255 if ( res )
1255 kresResources.append( res ); 1256 kresResources.append( res );
1256 } 1257 }
1257 } 1258 }
1258 1259
1259 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1260 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1260 resource = static_cast<KABC::Resource*>( res ); 1261 resource = static_cast<KABC::Resource*>( res );
1261 1262
1262 if ( resource ) { 1263 if ( resource ) {
1263 KABC::Addressee addr; 1264 KABC::Addressee addr;
1264 addr.setResource( resource ); 1265 addr.setResource( resource );
1265 mEditorDialog->setAddressee( addr ); 1266 mEditorDialog->setAddressee( addr );
1266 mEditorDialog->setCaption( i18n("Edit new contact")); 1267 mEditorDialog->setCaption( i18n("Edit new contact"));
1267 KApplication::execDialog ( mEditorDialog ); 1268 KApplication::execDialog ( mEditorDialog );
1268 1269
1269 } else 1270 } else
1270 return; 1271 return;
1271 1272
1272 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1273 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1273 1274
1274 1275
1275} 1276}
1276 1277
1277void KABCore::addEmail( QString aStr ) 1278void KABCore::addEmail( QString aStr )
1278{ 1279{
1279#ifndef KAB_EMBEDDED 1280#ifndef KAB_EMBEDDED
1280 QString fullName, email; 1281 QString fullName, email;
1281 1282
1282 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1283 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1283 1284
1284 // Try to lookup the addressee matching the email address 1285 // Try to lookup the addressee matching the email address
1285 bool found = false; 1286 bool found = false;
1286 QStringList emailList; 1287 QStringList emailList;
1287 KABC::AddressBook::Iterator it; 1288 KABC::AddressBook::Iterator it;
1288 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1289 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1289 emailList = (*it).emails(); 1290 emailList = (*it).emails();
1290 if ( emailList.contains( email ) > 0 ) { 1291 if ( emailList.contains( email ) > 0 ) {
1291 found = true; 1292 found = true;
1292 (*it).setNameFromString( fullName ); 1293 (*it).setNameFromString( fullName );
1293 editContact( (*it).uid() ); 1294 editContact( (*it).uid() );
1294 } 1295 }
1295 } 1296 }
1296 1297
1297 if ( !found ) { 1298 if ( !found ) {
1298 KABC::Addressee addr; 1299 KABC::Addressee addr;
1299 addr.setNameFromString( fullName ); 1300 addr.setNameFromString( fullName );
1300 addr.insertEmail( email, true ); 1301 addr.insertEmail( email, true );
1301 1302
1302 mAddressBook->insertAddressee( addr ); 1303 mAddressBook->insertAddressee( addr );
1303 mViewManager->refreshView( addr.uid() ); 1304 mViewManager->refreshView( addr.uid() );
1304 editContact( addr.uid() ); 1305 editContact( addr.uid() );
1305 } 1306 }
1306#else //KAB_EMBEDDED 1307#else //KAB_EMBEDDED
1307 qDebug("KABCore::addEmail finsih method"); 1308 qDebug("KABCore::addEmail finsih method");
1308#endif //KAB_EMBEDDED 1309#endif //KAB_EMBEDDED
1309} 1310}
1310 1311
1311void KABCore::importVCard( const KURL &url, bool showPreview ) 1312void KABCore::importVCard( const KURL &url, bool showPreview )
1312{ 1313{
1313 mXXPortManager->importVCard( url, showPreview ); 1314 mXXPortManager->importVCard( url, showPreview );
1314} 1315}
1315void KABCore::importFromOL() 1316void KABCore::importFromOL()
1316{ 1317{
1317#ifdef _OL_IMPORT_ 1318#ifdef _OL_IMPORT_
1318 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1319 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1319 idgl->exec(); 1320 idgl->exec();
1320 KABC::Addressee::List list = idgl->getAddressList(); 1321 KABC::Addressee::List list = idgl->getAddressList();
1321 if ( list.count() > 0 ) { 1322 if ( list.count() > 0 ) {
1322 KABC::Addressee::List listNew; 1323 KABC::Addressee::List listNew;
1323 KABC::Addressee::List listExisting; 1324 KABC::Addressee::List listExisting;
1324 KABC::Addressee::List::Iterator it; 1325 KABC::Addressee::List::Iterator it;
1325 KABC::AddressBook::Iterator iter; 1326 KABC::AddressBook::Iterator iter;
1326 for ( it = list.begin(); it != list.end(); ++it ) { 1327 for ( it = list.begin(); it != list.end(); ++it ) {
1327 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1328 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1328 listNew.append( (*it) ); 1329 listNew.append( (*it) );
1329 else 1330 else
1330 listExisting.append( (*it) ); 1331 listExisting.append( (*it) );
1331 } 1332 }
1332 if ( listExisting.count() > 0 ) 1333 if ( listExisting.count() > 0 )
1333 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1334 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1334 if ( listNew.count() > 0 ) { 1335 if ( listNew.count() > 0 ) {
1335 pasteWithNewUid = false; 1336 pasteWithNewUid = false;
1336 pasteContacts( listNew ); 1337 pasteContacts( listNew );
1337 pasteWithNewUid = true; 1338 pasteWithNewUid = true;
1338 } 1339 }
1339 } 1340 }
1340 delete idgl; 1341 delete idgl;
1341#endif 1342#endif
1342} 1343}
1343 1344
1344void KABCore::importVCard( const QString &vCard, bool showPreview ) 1345void KABCore::importVCard( const QString &vCard, bool showPreview )
1345{ 1346{
1346 mXXPortManager->importVCard( vCard, showPreview ); 1347 mXXPortManager->importVCard( vCard, showPreview );
1347} 1348}
1348 1349
1349//US added a second method without defaultparameter 1350//US added a second method without defaultparameter
1350void KABCore::editContact2() { 1351void KABCore::editContact2() {
1351 editContact( QString::null ); 1352 editContact( QString::null );
1352} 1353}
1353 1354
1354void KABCore::editContact( const QString &uid ) 1355void KABCore::editContact( const QString &uid )
1355{ 1356{
1356 1357
1357 if ( mExtensionManager->isQuickEditVisible() ) 1358 if ( mExtensionManager->isQuickEditVisible() )
1358 return; 1359 return;
1359 1360
1360 // First, locate the contact entry 1361 // First, locate the contact entry
1361 QString localUID = uid; 1362 QString localUID = uid;
1362 if ( localUID.isNull() ) { 1363 if ( localUID.isNull() ) {
1363 QStringList uidList = mViewManager->selectedUids(); 1364 QStringList uidList = mViewManager->selectedUids();
1364 if ( uidList.count() > 0 ) 1365 if ( uidList.count() > 0 )
1365 localUID = *( uidList.at( 0 ) ); 1366 localUID = *( uidList.at( 0 ) );
1366 } 1367 }
1367 1368
1368 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1369 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1369 if ( !addr.isEmpty() ) { 1370 if ( !addr.isEmpty() ) {
1370 mEditorDialog->setAddressee( addr ); 1371 mEditorDialog->setAddressee( addr );
1371 KApplication::execDialog ( mEditorDialog ); 1372 KApplication::execDialog ( mEditorDialog );
1372 } 1373 }
1373} 1374}
1374 1375
1375/** 1376/**
1376 Shows or edits the detail view for the given uid. If the uid is QString::null, 1377 Shows or edits the detail view for the given uid. If the uid is QString::null,
1377 the method will try to find a selected addressee in the view. 1378 the method will try to find a selected addressee in the view.
1378 */ 1379 */
1379void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1380void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1380{ 1381{
1381 if ( mMultipleViewsAtOnce ) 1382 if ( mMultipleViewsAtOnce )
1382 { 1383 {
1383 editContact( uid ); 1384 editContact( uid );
1384 } 1385 }
1385 else 1386 else
1386 { 1387 {
1387 setDetailsVisible( true ); 1388 setDetailsVisible( true );
1388 mActionDetails->setChecked(true); 1389 mActionDetails->setChecked(true);
1389 } 1390 }
1390 1391
1391} 1392}
1392 1393
1393void KABCore::save() 1394void KABCore::save()
1394{ 1395{
1395 if (syncManager->blockSave()) 1396 if (syncManager->blockSave())
1396 return; 1397 return;
1397 if ( !mModified ) 1398 if ( !mModified )
1398 return; 1399 return;
1399 1400
1400 syncManager->setBlockSave(true); 1401 syncManager->setBlockSave(true);
1401 QString text = i18n( "There was an error while attempting to save\n the " 1402 QString text = i18n( "There was an error while attempting to save\n the "
1402 "address book. Please check that some \nother application is " 1403 "address book. Please check that some \nother application is "
1403 "not using it. " ); 1404 "not using it. " );
1404 message(i18n("Saving ... please wait! "), false); 1405 message(i18n("Saving ... please wait! "), false);
1405 //qApp->processEvents(); 1406 //qApp->processEvents();
1406#ifndef KAB_EMBEDDED 1407#ifndef KAB_EMBEDDED
1407 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1408 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1408 if ( !b || !b->save() ) { 1409 if ( !b || !b->save() ) {
1409 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1410 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1410 } 1411 }
1411#else //KAB_EMBEDDED 1412#else //KAB_EMBEDDED
1412 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1413 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1413 if ( !b || !b->save() ) { 1414 if ( !b || !b->save() ) {
1414 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1415 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1415 } 1416 }
1416#endif //KAB_EMBEDDED 1417#endif //KAB_EMBEDDED
1417 1418
1418 message(i18n("Addressbook saved!")); 1419 message(i18n("Addressbook saved!"));
1419 setModified( false ); 1420 setModified( false );
1420 syncManager->setBlockSave(false); 1421 syncManager->setBlockSave(false);
1421} 1422}
1422 1423
1423 1424
1424void KABCore::undo() 1425void KABCore::undo()
1425{ 1426{
1426 UndoStack::instance()->undo(); 1427 UndoStack::instance()->undo();
1427 1428
1428 // Refresh the view 1429 // Refresh the view
1429 mViewManager->refreshView(); 1430 mViewManager->refreshView();
1430} 1431}
1431 1432
1432void KABCore::redo() 1433void KABCore::redo()
1433{ 1434{
1434 RedoStack::instance()->redo(); 1435 RedoStack::instance()->redo();
1435 1436
1436 // Refresh the view 1437 // Refresh the view
1437 mViewManager->refreshView(); 1438 mViewManager->refreshView();
1438} 1439}
1439void KABCore::setJumpButtonBar( bool visible ) 1440void KABCore::setJumpButtonBar( bool visible )
1440{ 1441{
1441 setJumpButtonBarVisible(visible ); 1442 setJumpButtonBarVisible(visible );
1442 saveSettings(); 1443 saveSettings();
1443} 1444}
1444void KABCore::setJumpButtonBarVisible( bool visible ) 1445void KABCore::setJumpButtonBarVisible( bool visible )
1445{ 1446{
1446 if (mMultipleViewsAtOnce) 1447 if (mMultipleViewsAtOnce)
1447 { 1448 {
1448 if ( visible ) 1449 if ( visible )
1449 mJumpButtonBar->show(); 1450 mJumpButtonBar->show();
1450 else 1451 else
1451 mJumpButtonBar->hide(); 1452 mJumpButtonBar->hide();
1452 } 1453 }
1453 else 1454 else
1454 { 1455 {
1455 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1456 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1456 if (mViewManager->isVisible()) 1457 if (mViewManager->isVisible())
1457 { 1458 {
1458 if ( visible ) 1459 if ( visible )
1459 mJumpButtonBar->show(); 1460 mJumpButtonBar->show();
1460 else 1461 else
1461 mJumpButtonBar->hide(); 1462 mJumpButtonBar->hide();
1462 } 1463 }
1463 else 1464 else
1464 { 1465 {
1465 mJumpButtonBar->hide(); 1466 mJumpButtonBar->hide();
1466 } 1467 }
1467 } 1468 }
1468 if ( visible ) { 1469 if ( visible ) {
1469 if ( mIncSearchWidget->currentItem() == 0 ) { 1470 if ( mIncSearchWidget->currentItem() == 0 ) {
1470 message( i18n("Change search field enable jump bar") ); 1471 message( i18n("Change search field enable jump bar") );
1471 } 1472 }
1472 } 1473 }
1473} 1474}
1474 1475
1475 1476
1476void KABCore::setDetailsToState() 1477void KABCore::setDetailsToState()
1477{ 1478{
1478 setDetailsVisible( mActionDetails->isChecked() ); 1479 setDetailsVisible( mActionDetails->isChecked() );
1479} 1480}
1480void KABCore::setDetailsToggle() 1481void KABCore::setDetailsToggle()
1481{ 1482{
1482 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1483 mActionDetails->setChecked( !mActionDetails->isChecked() );
1483 setDetailsToState(); 1484 setDetailsToState();
1484} 1485}
1485 1486
1486 1487
1487 1488
1488void KABCore::setDetailsVisible( bool visible ) 1489void KABCore::setDetailsVisible( bool visible )
1489{ 1490{
1490 if (visible && mDetails->isHidden()) 1491 if (visible && mDetails->isHidden())
1491 { 1492 {
1492 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1493 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1493 if ( addrList.count() > 0 ) 1494 if ( addrList.count() > 0 )
1494 mDetails->setAddressee( addrList[ 0 ] ); 1495 mDetails->setAddressee( addrList[ 0 ] );
1495 } 1496 }
1496 1497
1497 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1498 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1498 // the listview and the detailview. We do that by changing the splitbar size. 1499 // the listview and the detailview. We do that by changing the splitbar size.
1499 if (mMultipleViewsAtOnce) 1500 if (mMultipleViewsAtOnce)
1500 { 1501 {
1501 if ( visible ) 1502 if ( visible )
1502 mDetails->show(); 1503 mDetails->show();
1503 else 1504 else
1504 mDetails->hide(); 1505 mDetails->hide();
1505 } 1506 }
1506 else 1507 else
1507 { 1508 {
1508 if ( visible ) { 1509 if ( visible ) {
1509 mViewManager->hide(); 1510 mViewManager->hide();
1510 mDetails->show(); 1511 mDetails->show();
1511 mIncSearchWidget->setFocus(); 1512 mIncSearchWidget->setFocus();
1512 } 1513 }
1513 else { 1514 else {
1514 mViewManager->show(); 1515 mViewManager->show();
1515 mDetails->hide(); 1516 mDetails->hide();
1516 mViewManager->setFocusAV(); 1517 mViewManager->setFocusAV();
1517 } 1518 }
1518 setJumpButtonBarVisible( !visible ); 1519 setJumpButtonBarVisible( !visible );
1519 } 1520 }
1520 1521
1521} 1522}
1522 1523
1523void KABCore::extensionChanged( int id ) 1524void KABCore::extensionChanged( int id )
1524{ 1525{
1525 //change the details view only for non desktop systems 1526 //change the details view only for non desktop systems
1526#ifndef DESKTOP_VERSION 1527#ifndef DESKTOP_VERSION
1527 1528
1528 if (id == 0) 1529 if (id == 0)
1529 { 1530 {
1530 //the user disabled the extension. 1531 //the user disabled the extension.
1531 1532
1532 if (mMultipleViewsAtOnce) 1533 if (mMultipleViewsAtOnce)
1533 { // enable detailsview again 1534 { // enable detailsview again
1534 setDetailsVisible( true ); 1535 setDetailsVisible( true );
1535 mActionDetails->setChecked( true ); 1536 mActionDetails->setChecked( true );
1536 } 1537 }
1537 else 1538 else
1538 { //go back to the listview 1539 { //go back to the listview
1539 setDetailsVisible( false ); 1540 setDetailsVisible( false );
1540 mActionDetails->setChecked( false ); 1541 mActionDetails->setChecked( false );
1541 mActionDetails->setEnabled(true); 1542 mActionDetails->setEnabled(true);
1542 } 1543 }
1543 1544
1544 } 1545 }
1545 else 1546 else
1546 { 1547 {
1547 //the user enabled the extension. 1548 //the user enabled the extension.
1548 setDetailsVisible( false ); 1549 setDetailsVisible( false );
1549 mActionDetails->setChecked( false ); 1550 mActionDetails->setChecked( false );
1550 1551
1551 if (!mMultipleViewsAtOnce) 1552 if (!mMultipleViewsAtOnce)
1552 { 1553 {
1553 mActionDetails->setEnabled(false); 1554 mActionDetails->setEnabled(false);
1554 } 1555 }
1555 1556
1556 mExtensionManager->setSelectionChanged(); 1557 mExtensionManager->setSelectionChanged();
1557 1558
1558 } 1559 }
1559 1560
1560#endif// DESKTOP_VERSION 1561#endif// DESKTOP_VERSION
1561 1562
1562} 1563}
1563 1564
1564 1565
1565void KABCore::extensionModified( const KABC::Addressee::List &list ) 1566void KABCore::extensionModified( const KABC::Addressee::List &list )
1566{ 1567{
1567 1568
1568 if ( list.count() != 0 ) { 1569 if ( list.count() != 0 ) {
1569 KABC::Addressee::List::ConstIterator it; 1570 KABC::Addressee::List::ConstIterator it;
1570 for ( it = list.begin(); it != list.end(); ++it ) 1571 for ( it = list.begin(); it != list.end(); ++it )
1571 mAddressBook->insertAddressee( *it ); 1572 mAddressBook->insertAddressee( *it );
1572 if ( list.count() > 1 ) 1573 if ( list.count() > 1 )
1573 setModified(); 1574 setModified();
1574 else 1575 else
1575 setModifiedWOrefresh(); 1576 setModifiedWOrefresh();
1576 } 1577 }
1577 if ( list.count() == 0 ) 1578 if ( list.count() == 0 )
1578 mViewManager->refreshView(); 1579 mViewManager->refreshView();
1579 else 1580 else
1580 mViewManager->refreshView( list[ 0 ].uid() ); 1581 mViewManager->refreshView( list[ 0 ].uid() );
1581 1582
1582 1583
1583 1584
1584} 1585}
1585 1586
1586QString KABCore::getNameByPhone( const QString &phone ) 1587QString KABCore::getNameByPhone( const QString &phone )
1587{ 1588{
1588#ifndef KAB_EMBEDDED 1589#ifndef KAB_EMBEDDED
1589 QRegExp r( "[/*/-/ ]" ); 1590 QRegExp r( "[/*/-/ ]" );
1590 QString localPhone( phone ); 1591 QString localPhone( phone );
1591 1592
1592 bool found = false; 1593 bool found = false;
1593 QString ownerName = ""; 1594 QString ownerName = "";
1594 KABC::AddressBook::Iterator iter; 1595 KABC::AddressBook::Iterator iter;
1595 KABC::PhoneNumber::List::Iterator phoneIter; 1596 KABC::PhoneNumber::List::Iterator phoneIter;
1596 KABC::PhoneNumber::List phoneList; 1597 KABC::PhoneNumber::List phoneList;
1597 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1598 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1598 phoneList = (*iter).phoneNumbers(); 1599 phoneList = (*iter).phoneNumbers();
1599 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1600 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1600 ++phoneIter) { 1601 ++phoneIter) {
1601 // Get rid of separator chars so just the numbers are compared. 1602 // Get rid of separator chars so just the numbers are compared.
1602 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1603 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1603 ownerName = (*iter).formattedName(); 1604 ownerName = (*iter).formattedName();
1604 found = true; 1605 found = true;
1605 } 1606 }
1606 } 1607 }
1607 } 1608 }
1608 1609
1609 return ownerName; 1610 return ownerName;
1610#else //KAB_EMBEDDED 1611#else //KAB_EMBEDDED
1611 qDebug("KABCore::getNameByPhone finsih method"); 1612 qDebug("KABCore::getNameByPhone finsih method");
1612 return ""; 1613 return "";
1613#endif //KAB_EMBEDDED 1614#endif //KAB_EMBEDDED
1614 1615
1615} 1616}
1616void KABCore::openConfigGlobalDialog() 1617void KABCore::openConfigGlobalDialog()
1617{ 1618{
1618 KPimPrefsGlobalDialog gc ( this ); 1619 KPimPrefsGlobalDialog gc ( this );
1619 gc.exec(); 1620 gc.exec();
1620} 1621}
1621void KABCore::openConfigDialog() 1622void KABCore::openConfigDialog()
1622{ 1623{
1623 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 1624 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
1624 1625
1625 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); 1626 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" );
1626 ConfigureDialog->setMainWidget( kabcfg ); 1627 ConfigureDialog->setMainWidget( kabcfg );
1627 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1628 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1628 this, SLOT( configurationChanged() ) ); 1629 this, SLOT( configurationChanged() ) );
1629 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1630 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1630 kabcfg, SLOT( save() ) ); 1631 kabcfg, SLOT( save() ) );
1631 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1632 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1632 this, SLOT( configurationChanged() ) ); 1633 this, SLOT( configurationChanged() ) );
1633 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1634 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1634 kabcfg, SLOT( save() ) ); 1635 kabcfg, SLOT( save() ) );
1635 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 1636 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
1636 kabcfg, SLOT( defaults() ) ); 1637 kabcfg, SLOT( defaults() ) );
1637 saveSettings(); 1638 saveSettings();
1638 kabcfg->load(); 1639 kabcfg->load();
1639#ifndef DESKTOP_VERSION 1640#ifndef DESKTOP_VERSION
1640 if ( QApplication::desktop()->height() <= 480 ) 1641 if ( QApplication::desktop()->height() <= 480 )
1641 ConfigureDialog->hideButtons(); 1642 ConfigureDialog->hideButtons();
1642 ConfigureDialog->showMaximized(); 1643 ConfigureDialog->showMaximized();
1643#endif 1644#endif
1644 if ( ConfigureDialog->exec() ) 1645 if ( ConfigureDialog->exec() )
1645 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1646 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1646 delete ConfigureDialog; 1647 delete ConfigureDialog;
1647} 1648}
1648 1649
1649void KABCore::openLDAPDialog() 1650void KABCore::openLDAPDialog()
1650{ 1651{
1651#ifndef KAB_EMBEDDED 1652#ifndef KAB_EMBEDDED
1652 if ( !mLdapSearchDialog ) { 1653 if ( !mLdapSearchDialog ) {
1653 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1654 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1654 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1655 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1655 SLOT( refreshView() ) ); 1656 SLOT( refreshView() ) );
1656 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1657 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1657 SLOT( setModified() ) ); 1658 SLOT( setModified() ) );
1658 } else 1659 } else
1659 mLdapSearchDialog->restoreSettings(); 1660 mLdapSearchDialog->restoreSettings();
1660 1661
1661 if ( mLdapSearchDialog->isOK() ) 1662 if ( mLdapSearchDialog->isOK() )
1662 mLdapSearchDialog->exec(); 1663 mLdapSearchDialog->exec();
1663#else //KAB_EMBEDDED 1664#else //KAB_EMBEDDED
1664 qDebug("KABCore::openLDAPDialog() finsih method"); 1665 qDebug("KABCore::openLDAPDialog() finsih method");
1665#endif //KAB_EMBEDDED 1666#endif //KAB_EMBEDDED
1666} 1667}
1667 1668
1668void KABCore::print() 1669void KABCore::print()
1669{ 1670{
1670#ifndef KAB_EMBEDDED 1671#ifndef KAB_EMBEDDED
1671 KPrinter printer; 1672 KPrinter printer;
1672 if ( !printer.setup( this ) ) 1673 if ( !printer.setup( this ) )
1673 return; 1674 return;
1674 1675
1675 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1676 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1676 mViewManager->selectedUids(), this ); 1677 mViewManager->selectedUids(), this );
1677 1678
1678 wizard.exec(); 1679 wizard.exec();
1679#else //KAB_EMBEDDED 1680#else //KAB_EMBEDDED
1680 qDebug("KABCore::print() finsih method"); 1681 qDebug("KABCore::print() finsih method");
1681#endif //KAB_EMBEDDED 1682#endif //KAB_EMBEDDED
1682 1683
1683} 1684}
1684 1685
1685 1686
1686void KABCore::addGUIClient( KXMLGUIClient *client ) 1687void KABCore::addGUIClient( KXMLGUIClient *client )
1687{ 1688{
1688 if ( mGUIClient ) 1689 if ( mGUIClient )
1689 mGUIClient->insertChildClient( client ); 1690 mGUIClient->insertChildClient( client );
1690 else 1691 else
1691 KMessageBox::error( this, "no KXMLGUICLient"); 1692 KMessageBox::error( this, "no KXMLGUICLient");
1692} 1693}
1693 1694
1694 1695
1695void KABCore::configurationChanged() 1696void KABCore::configurationChanged()
1696{ 1697{
1697 mExtensionManager->reconfigure(); 1698 mExtensionManager->reconfigure();
1698} 1699}
1699 1700
1700void KABCore::addressBookChanged() 1701void KABCore::addressBookChanged()
1701{ 1702{
1702/*US 1703/*US
1703 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1704 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1704 while ( it.current() ) { 1705 while ( it.current() ) {
1705 if ( it.current()->dirty() ) { 1706 if ( it.current()->dirty() ) {
1706 QString text = i18n( "Data has been changed externally. Unsaved " 1707 QString text = i18n( "Data has been changed externally. Unsaved "
1707 "changes will be lost." ); 1708 "changes will be lost." );
1708 KMessageBox::information( this, text ); 1709 KMessageBox::information( this, text );
1709 } 1710 }
1710 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1711 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1711 ++it; 1712 ++it;
1712 } 1713 }
1713*/ 1714*/
1714 if (mEditorDialog) 1715 if (mEditorDialog)
1715 { 1716 {
1716 if (mEditorDialog->dirty()) 1717 if (mEditorDialog->dirty())
1717 { 1718 {
1718 QString text = i18n( "Data has been changed externally. Unsaved " 1719 QString text = i18n( "Data has been changed externally. Unsaved "
1719 "changes will be lost." ); 1720 "changes will be lost." );
1720 KMessageBox::information( this, text ); 1721 KMessageBox::information( this, text );
1721 } 1722 }
1722 QString currentuid = mEditorDialog->addressee().uid(); 1723 QString currentuid = mEditorDialog->addressee().uid();
1723 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1724 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1724 } 1725 }
1725 mViewManager->refreshView(); 1726 mViewManager->refreshView();
1726 1727
1727 1728
1728} 1729}
1729 1730
1730AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1731AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1731 const char *name ) 1732 const char *name )
1732{ 1733{
1733 1734
1734 if ( mEditorDialog == 0 ) { 1735 if ( mEditorDialog == 0 ) {
1735 mEditorDialog = new AddresseeEditorDialog( this, parent, 1736 mEditorDialog = new AddresseeEditorDialog( this, parent,
1736 name ? name : "editorDialog" ); 1737 name ? name : "editorDialog" );
1737 1738
1738 1739
1739 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1740 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1740 SLOT( contactModified( const KABC::Addressee& ) ) ); 1741 SLOT( contactModified( const KABC::Addressee& ) ) );
1741 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1742 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1742 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1743 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1743 } 1744 }
1744 1745
1745 return mEditorDialog; 1746 return mEditorDialog;
1746} 1747}
1747 1748
1748void KABCore::slotEditorDestroyed( const QString &uid ) 1749void KABCore::slotEditorDestroyed( const QString &uid )
1749{ 1750{
1750 //mEditorDict.remove( uid ); 1751 //mEditorDict.remove( uid );
1751} 1752}
1752 1753
1753void KABCore::initGUI() 1754void KABCore::initGUI()
1754{ 1755{
1755#ifndef KAB_EMBEDDED 1756#ifndef KAB_EMBEDDED
1756 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1757 QHBoxLayout *topLayout = new QHBoxLayout( this );
1757 topLayout->setSpacing( KDialogBase::spacingHint() ); 1758 topLayout->setSpacing( KDialogBase::spacingHint() );
1758 1759
1759 mExtensionBarSplitter = new QSplitter( this ); 1760 mExtensionBarSplitter = new QSplitter( this );
1760 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1761 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1761 1762
1762 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1763 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1763 1764
1764 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1765 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1765 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1766 mIncSearchWidget = new IncSearchWidget( viewSpace );
1766 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1767 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1767 SLOT( incrementalSearch( const QString& ) ) ); 1768 SLOT( incrementalSearch( const QString& ) ) );
1768 1769
1769 mViewManager = new ViewManager( this, viewSpace ); 1770 mViewManager = new ViewManager( this, viewSpace );
1770 viewSpace->setStretchFactor( mViewManager, 1 ); 1771 viewSpace->setStretchFactor( mViewManager, 1 );
1771 1772
1772 mDetails = new ViewContainer( mDetailsSplitter ); 1773 mDetails = new ViewContainer( mDetailsSplitter );
1773 1774
1774 mJumpButtonBar = new JumpButtonBar( this, this ); 1775 mJumpButtonBar = new JumpButtonBar( this, this );
1775 1776
1776 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1777 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1777 1778
1778 topLayout->addWidget( mExtensionBarSplitter ); 1779 topLayout->addWidget( mExtensionBarSplitter );
1779 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1780 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1780 topLayout->addWidget( mJumpButtonBar ); 1781 topLayout->addWidget( mJumpButtonBar );
1781 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1782 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1782 1783
1783 mXXPortManager = new XXPortManager( this, this ); 1784 mXXPortManager = new XXPortManager( this, this );
1784 1785
1785#else //KAB_EMBEDDED 1786#else //KAB_EMBEDDED
1786 //US initialize viewMenu before settingup viewmanager. 1787 //US initialize viewMenu before settingup viewmanager.
1787 // Viewmanager needs this menu to plugin submenues. 1788 // Viewmanager needs this menu to plugin submenues.
1788 viewMenu = new QPopupMenu( this ); 1789 viewMenu = new QPopupMenu( this );
1789 settingsMenu = new QPopupMenu( this ); 1790 settingsMenu = new QPopupMenu( this );
1790 //filterMenu = new QPopupMenu( this ); 1791 //filterMenu = new QPopupMenu( this );
1791 ImportMenu = new QPopupMenu( this ); 1792 ImportMenu = new QPopupMenu( this );
1792 ExportMenu = new QPopupMenu( this ); 1793 ExportMenu = new QPopupMenu( this );
1793 syncMenu = new QPopupMenu( this ); 1794 syncMenu = new QPopupMenu( this );
1794 changeMenu= new QPopupMenu( this ); 1795 changeMenu= new QPopupMenu( this );
1795 beamMenu= new QPopupMenu( this ); 1796 beamMenu= new QPopupMenu( this );
1796 1797
1797//US since we have no splitter for the embedded system, setup 1798//US since we have no splitter for the embedded system, setup
1798// a layout with two frames. One left and one right. 1799// a layout with two frames. One left and one right.
1799 1800
1800 QBoxLayout *topLayout; 1801 QBoxLayout *topLayout;
1801 1802
1802 // = new QHBoxLayout( this ); 1803 // = new QHBoxLayout( this );
1803// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1804// QBoxLayout *topLayout = (QBoxLayout*)layout();
1804 1805
1805// QWidget *mainBox = new QWidget( this ); 1806// QWidget *mainBox = new QWidget( this );
1806// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1807// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1807 1808
1808#ifdef DESKTOP_VERSION 1809#ifdef DESKTOP_VERSION
1809 topLayout = new QHBoxLayout( this ); 1810 topLayout = new QHBoxLayout( this );
1810 1811
1811 1812
1812 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1813 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1813 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1814 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1814 1815
1815 topLayout->addWidget(mMiniSplitter ); 1816 topLayout->addWidget(mMiniSplitter );
1816 1817
1817 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1818 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1818 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1819 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1819 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1820 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1820 mDetails = new ViewContainer( mMiniSplitter ); 1821 mDetails = new ViewContainer( mMiniSplitter );
1821 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1822 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1822#else 1823#else
1823 if ( QApplication::desktop()->width() > 480 ) { 1824 if ( QApplication::desktop()->width() > 480 ) {
1824 topLayout = new QHBoxLayout( this ); 1825 topLayout = new QHBoxLayout( this );
1825 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1826 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1826 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1827 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1827 } else { 1828 } else {
1828 1829
1829 topLayout = new QHBoxLayout( this ); 1830 topLayout = new QHBoxLayout( this );
1830 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1831 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1831 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1832 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1832 } 1833 }
1833 1834
1834 topLayout->addWidget(mMiniSplitter ); 1835 topLayout->addWidget(mMiniSplitter );
1835 mViewManager = new ViewManager( this, mMiniSplitter ); 1836 mViewManager = new ViewManager( this, mMiniSplitter );
1836 mDetails = new ViewContainer( mMiniSplitter ); 1837 mDetails = new ViewContainer( mMiniSplitter );
1837 1838
1838 1839
1839 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1840 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1840#endif 1841#endif
1841 //eh->hide(); 1842 //eh->hide();
1842 // topLayout->addWidget(mExtensionManager ); 1843 // topLayout->addWidget(mExtensionManager );
1843 1844
1844 1845
1845/*US 1846/*US
1846#ifndef KAB_NOSPLITTER 1847#ifndef KAB_NOSPLITTER
1847 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1848 QHBoxLayout *topLayout = new QHBoxLayout( this );
1848//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1849//US topLayout->setSpacing( KDialogBase::spacingHint() );
1849 topLayout->setSpacing( 10 ); 1850 topLayout->setSpacing( 10 );
1850 1851
1851 mDetailsSplitter = new QSplitter( this ); 1852 mDetailsSplitter = new QSplitter( this );
1852 1853
1853 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1854 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1854 1855
1855 mViewManager = new ViewManager( this, viewSpace ); 1856 mViewManager = new ViewManager( this, viewSpace );
1856 viewSpace->setStretchFactor( mViewManager, 1 ); 1857 viewSpace->setStretchFactor( mViewManager, 1 );
1857 1858
1858 mDetails = new ViewContainer( mDetailsSplitter ); 1859 mDetails = new ViewContainer( mDetailsSplitter );
1859 1860
1860 topLayout->addWidget( mDetailsSplitter ); 1861 topLayout->addWidget( mDetailsSplitter );
1861 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1862 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1862#else //KAB_NOSPLITTER 1863#else //KAB_NOSPLITTER
1863 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1864 QHBoxLayout *topLayout = new QHBoxLayout( this );
1864//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1865//US topLayout->setSpacing( KDialogBase::spacingHint() );
1865 topLayout->setSpacing( 10 ); 1866 topLayout->setSpacing( 10 );
1866 1867
1867// mDetailsSplitter = new QSplitter( this ); 1868// mDetailsSplitter = new QSplitter( this );
1868 1869
1869 QVBox *viewSpace = new QVBox( this ); 1870 QVBox *viewSpace = new QVBox( this );
1870 1871
1871 mViewManager = new ViewManager( this, viewSpace ); 1872 mViewManager = new ViewManager( this, viewSpace );
1872 viewSpace->setStretchFactor( mViewManager, 1 ); 1873 viewSpace->setStretchFactor( mViewManager, 1 );
1873 1874
1874 mDetails = new ViewContainer( this ); 1875 mDetails = new ViewContainer( this );
1875 1876
1876 topLayout->addWidget( viewSpace ); 1877 topLayout->addWidget( viewSpace );
1877// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1878// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1878 topLayout->addWidget( mDetails ); 1879 topLayout->addWidget( mDetails );
1879#endif //KAB_NOSPLITTER 1880#endif //KAB_NOSPLITTER
1880*/ 1881*/
1881 1882
1882 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1883 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1883 syncManager->setBlockSave(false); 1884 syncManager->setBlockSave(false);
1884 1885
1885 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1886 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1886 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1887 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1887 QString sync_file = sentSyncFile(); 1888 QString sync_file = sentSyncFile();
1888 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1889 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1889 syncManager->setDefaultFileName( sync_file ); 1890 syncManager->setDefaultFileName( sync_file );
1890 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1891 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1891 1892
1892#endif //KAB_EMBEDDED 1893#endif //KAB_EMBEDDED
1893 initActions(); 1894 initActions();
1894 1895
1895#ifdef KAB_EMBEDDED 1896#ifdef KAB_EMBEDDED
1896 addActionsManually(); 1897 addActionsManually();
1897 //US make sure the export and import menues are initialized before creating the xxPortManager. 1898 //US make sure the export and import menues are initialized before creating the xxPortManager.
1898 mXXPortManager = new XXPortManager( this, this ); 1899 mXXPortManager = new XXPortManager( this, this );
1899 1900
1900 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1901 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1901 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1902 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1902 // mActionQuit->plug ( mMainWindow->toolBar()); 1903 // mActionQuit->plug ( mMainWindow->toolBar());
1903 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1904 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1904 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1905 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1905 // mIncSearchWidget->hide(); 1906 // mIncSearchWidget->hide();
1906 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1907 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1907 SLOT( incrementalSearch( const QString& ) ) ); 1908 SLOT( incrementalSearch( const QString& ) ) );
1908 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1909 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1909 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1910 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1910 1911
1911 mJumpButtonBar = new JumpButtonBar( this, this ); 1912 mJumpButtonBar = new JumpButtonBar( this, this );
1912 1913
1913 topLayout->addWidget( mJumpButtonBar ); 1914 topLayout->addWidget( mJumpButtonBar );
1914//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1915//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1915 1916
1916// mMainWindow->getIconToolBar()->raise(); 1917// mMainWindow->getIconToolBar()->raise();
1917 1918
1918#endif //KAB_EMBEDDED 1919#endif //KAB_EMBEDDED
1919 1920
1920} 1921}
1921void KABCore::initActions() 1922void KABCore::initActions()
1922{ 1923{
1923//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1924//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1924 1925
1925#ifndef KAB_EMBEDDED 1926#ifndef KAB_EMBEDDED
1926 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1927 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1927 SLOT( clipboardDataChanged() ) ); 1928 SLOT( clipboardDataChanged() ) );
1928#endif //KAB_EMBEDDED 1929#endif //KAB_EMBEDDED
1929 1930
1930 // file menu 1931 // file menu
1931 1932
1932 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1933 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1933 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1934 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1934 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1935 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1935 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1936 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1936 1937
1937 1938
1938 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1939 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1939 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1940 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1940 1941
1941 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1942 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1942 SLOT( save() ), actionCollection(), "file_sync" ); 1943 SLOT( save() ), actionCollection(), "file_sync" );
1943 1944
1944 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1945 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1945 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1946 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1946 1947
1947 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1948 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1948 this, SLOT( mailVCard() ), 1949 this, SLOT( mailVCard() ),
1949 actionCollection(), "file_mail_vcard"); 1950 actionCollection(), "file_mail_vcard");
1950 1951
1951 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1952 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1952 SLOT( export2phone() ), actionCollection(), 1953 SLOT( export2phone() ), actionCollection(),
1953 "kaddressbook_ex2phone" ); 1954 "kaddressbook_ex2phone" );
1954 1955
1955 mActionBeamVCard = 0; 1956 mActionBeamVCard = 0;
1956 mActionBeam = 0; 1957 mActionBeam = 0;
1957 1958
1958#ifndef DESKTOP_VERSION 1959#ifndef DESKTOP_VERSION
1959 if ( Ir::supported() ) { 1960 if ( Ir::supported() ) {
1960 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1961 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1961 SLOT( beamVCard() ), actionCollection(), 1962 SLOT( beamVCard() ), actionCollection(),
1962 "kaddressbook_beam_vcard" ); 1963 "kaddressbook_beam_vcard" );
1963 1964
1964 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1965 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1965 SLOT( beamMySelf() ), actionCollection(), 1966 SLOT( beamMySelf() ), actionCollection(),
1966 "kaddressbook_beam_myself" ); 1967 "kaddressbook_beam_myself" );
1967 } 1968 }
1968#endif 1969#endif
1969 1970
1970 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1971 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1971 this, SLOT( editContact2() ), 1972 this, SLOT( editContact2() ),
1972 actionCollection(), "file_properties" ); 1973 actionCollection(), "file_properties" );
1973 1974
1974#ifdef KAB_EMBEDDED 1975#ifdef KAB_EMBEDDED
1975 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1976 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1976 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1977 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1977 mMainWindow, SLOT( exit() ), 1978 mMainWindow, SLOT( exit() ),
1978 actionCollection(), "quit" ); 1979 actionCollection(), "quit" );
1979#endif //KAB_EMBEDDED 1980#endif //KAB_EMBEDDED
1980 1981
1981 // edit menu 1982 // edit menu
1982 if ( mIsPart ) { 1983 if ( mIsPart ) {
1983 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1984 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1984 SLOT( copyContacts() ), actionCollection(), 1985 SLOT( copyContacts() ), actionCollection(),
1985 "kaddressbook_copy" ); 1986 "kaddressbook_copy" );
1986 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1987 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1987 SLOT( cutContacts() ), actionCollection(), 1988 SLOT( cutContacts() ), actionCollection(),
1988 "kaddressbook_cut" ); 1989 "kaddressbook_cut" );
1989 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1990 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1990 SLOT( pasteContacts() ), actionCollection(), 1991 SLOT( pasteContacts() ), actionCollection(),
1991 "kaddressbook_paste" ); 1992 "kaddressbook_paste" );
1992 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1993 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1993 SLOT( selectAllContacts() ), actionCollection(), 1994 SLOT( selectAllContacts() ), actionCollection(),
1994 "kaddressbook_select_all" ); 1995 "kaddressbook_select_all" );
1995 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1996 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1996 SLOT( undo() ), actionCollection(), 1997 SLOT( undo() ), actionCollection(),
1997 "kaddressbook_undo" ); 1998 "kaddressbook_undo" );
1998 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1999 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1999 this, SLOT( redo() ), actionCollection(), 2000 this, SLOT( redo() ), actionCollection(),
2000 "kaddressbook_redo" ); 2001 "kaddressbook_redo" );
2001 } else { 2002 } else {
2002 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 2003 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
2003 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 2004 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
2004 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 2005 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
2005 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 2006 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
2006 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 2007 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
2007 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 2008 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
2008 } 2009 }
2009 2010
2010 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2011 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
2011 Key_Delete, this, SLOT( deleteContacts() ), 2012 Key_Delete, this, SLOT( deleteContacts() ),
2012 actionCollection(), "edit_delete" ); 2013 actionCollection(), "edit_delete" );
2013 2014
2014 mActionUndo->setEnabled( false ); 2015 mActionUndo->setEnabled( false );
2015 mActionRedo->setEnabled( false ); 2016 mActionRedo->setEnabled( false );
2016 2017
2017 // settings menu 2018 // settings menu
2018#ifdef KAB_EMBEDDED 2019#ifdef KAB_EMBEDDED
2019//US special menuentry to configure the addressbook resources. On KDE 2020//US special menuentry to configure the addressbook resources. On KDE
2020// you do that through the control center !!! 2021// you do that through the control center !!!
2021 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2022 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
2022 SLOT( configureResources() ), actionCollection(), 2023 SLOT( configureResources() ), actionCollection(),
2023 "kaddressbook_configure_resources" ); 2024 "kaddressbook_configure_resources" );
2024#endif //KAB_EMBEDDED 2025#endif //KAB_EMBEDDED
2025 2026
2026 if ( mIsPart ) { 2027 if ( mIsPart ) {
2027 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2028 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
2028 SLOT( openConfigDialog() ), actionCollection(), 2029 SLOT( openConfigDialog() ), actionCollection(),
2029 "kaddressbook_configure" ); 2030 "kaddressbook_configure" );
2030 2031
2031 //US not implemented yet 2032 //US not implemented yet
2032 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2033 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2033 // this, SLOT( configureKeyBindings() ), actionCollection(), 2034 // this, SLOT( configureKeyBindings() ), actionCollection(),
2034 // "kaddressbook_configure_shortcuts" ); 2035 // "kaddressbook_configure_shortcuts" );
2035#ifdef KAB_EMBEDDED 2036#ifdef KAB_EMBEDDED
2036 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2037 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2037 mActionConfigureToolbars->setEnabled( false ); 2038 mActionConfigureToolbars->setEnabled( false );
2038#endif //KAB_EMBEDDED 2039#endif //KAB_EMBEDDED
2039 2040
2040 } else { 2041 } else {
2041 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, 2042 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this,
2042 SLOT( openConfigDialog() ), actionCollection(), 2043 SLOT( openConfigDialog() ), actionCollection(),
2043 "kaddressbook_configure" ); 2044 "kaddressbook_configure" );
2044 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, 2045 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this,
2045 SLOT( openConfigGlobalDialog() ), actionCollection(), 2046 SLOT( openConfigGlobalDialog() ), actionCollection(),
2046 "kaddressbook_configure" ); 2047 "kaddressbook_configure" );
2047 } 2048 }
2048 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2049 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2049 actionCollection(), "options_show_jump_bar" ); 2050 actionCollection(), "options_show_jump_bar" );
2050 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2051 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2051 2052
2052 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2053 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2053 actionCollection(), "options_show_details" ); 2054 actionCollection(), "options_show_details" );
2054 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2055 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2055 2056
2056 2057
2057 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2058 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2058 SLOT( toggleBeamReceive() ), actionCollection(), 2059 SLOT( toggleBeamReceive() ), actionCollection(),
2059 "kaddressbook_beam_rec" ); 2060 "kaddressbook_beam_rec" );
2060 2061
2061 2062
2062 // misc 2063 // misc
2063 // only enable LDAP lookup if we can handle the protocol 2064 // only enable LDAP lookup if we can handle the protocol
2064#ifndef KAB_EMBEDDED 2065#ifndef KAB_EMBEDDED
2065 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2066 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2066 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2067 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2067 this, SLOT( openLDAPDialog() ), actionCollection(), 2068 this, SLOT( openLDAPDialog() ), actionCollection(),
2068 "ldap_lookup" ); 2069 "ldap_lookup" );
2069 } 2070 }
2070#else //KAB_EMBEDDED 2071#else //KAB_EMBEDDED
2071 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2072 //qDebug("KABCore::initActions() LDAP has to be implemented");
2072#endif //KAB_EMBEDDED 2073#endif //KAB_EMBEDDED
2073 2074
2074 2075
2075 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2076 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2076 SLOT( setWhoAmI() ), actionCollection(), 2077 SLOT( setWhoAmI() ), actionCollection(),
2077 "set_personal" ); 2078 "set_personal" );
2078 2079
2079 2080
2080 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2081 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2081 SLOT( setCategories() ), actionCollection(), 2082 SLOT( setCategories() ), actionCollection(),
2082 "edit_set_categories" ); 2083 "edit_set_categories" );
2083 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2084 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2084 SLOT( editCategories() ), actionCollection(), 2085 SLOT( editCategories() ), actionCollection(),
2085 "edit__categories" ); 2086 "edit__categories" );
2086 2087
2087 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2088 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2088 SLOT( removeVoice() ), actionCollection(), 2089 SLOT( removeVoice() ), actionCollection(),
2089 "remove_voice" ); 2090 "remove_voice" );
2090 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2091 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2091 SLOT( setFormattedName() ), actionCollection(), 2092 SLOT( setFormattedName() ), actionCollection(),
2092 "set_formatted" ); 2093 "set_formatted" );
2093 2094
2094 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2095 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2095 SLOT( manageCategories() ), actionCollection(), 2096 SLOT( manageCategories() ), actionCollection(),
2096 "remove_voice" ); 2097 "remove_voice" );
2097 2098
2098 2099
2099 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2100 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2100 SLOT( importFromOL() ), actionCollection(), 2101 SLOT( importFromOL() ), actionCollection(),
2101 "import_OL" ); 2102 "import_OL" );
2102#ifdef KAB_EMBEDDED 2103#ifdef KAB_EMBEDDED
2103 mActionLicence = new KAction( i18n( "Licence" ), 0, 2104 mActionLicence = new KAction( i18n( "Licence" ), 0,
2104 this, SLOT( showLicence() ), actionCollection(), 2105 this, SLOT( showLicence() ), actionCollection(),
2105 "licence_about_data" ); 2106 "licence_about_data" );
2106 mActionFaq = new KAction( i18n( "Faq" ), 0, 2107 mActionFaq = new KAction( i18n( "Faq" ), 0,
2107 this, SLOT( faq() ), actionCollection(), 2108 this, SLOT( faq() ), actionCollection(),
2108 "faq_about_data" ); 2109 "faq_about_data" );
2109 mActionWN = new KAction( i18n( "What's New?" ), 0, 2110 mActionWN = new KAction( i18n( "What's New?" ), 0,
2110 this, SLOT( whatsnew() ), actionCollection(), 2111 this, SLOT( whatsnew() ), actionCollection(),
2111 "wn" ); 2112 "wn" );
2112 2113
2113 2114
2114 2115
2115 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, 2116 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0,
2116 this, SLOT( storagehowto() ), actionCollection(), 2117 this, SLOT( storagehowto() ), actionCollection(),
2117 "storage" ); 2118 "storage" );
2118 2119
2119 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2120 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2120 this, SLOT( synchowto() ), actionCollection(), 2121 this, SLOT( synchowto() ), actionCollection(),
2121 "sync" ); 2122 "sync" );
2122 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2123 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2123 this, SLOT( kdesynchowto() ), actionCollection(), 2124 this, SLOT( kdesynchowto() ), actionCollection(),
2124 "kdesync" ); 2125 "kdesync" );
2125 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2126 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2126 this, SLOT( multisynchowto() ), actionCollection(), 2127 this, SLOT( multisynchowto() ), actionCollection(),
2127 "multisync" ); 2128 "multisync" );
2128 2129
2129 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2130 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2130 this, SLOT( createAboutData() ), actionCollection(), 2131 this, SLOT( createAboutData() ), actionCollection(),
2131 "kaddressbook_about_data" ); 2132 "kaddressbook_about_data" );
2132#endif //KAB_EMBEDDED 2133#endif //KAB_EMBEDDED
2133 2134
2134 clipboardDataChanged(); 2135 clipboardDataChanged();
2135 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2136 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2136 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2137 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2137} 2138}
2138 2139
2139//US we need this function, to plug all actions into the correct menues. 2140//US we need this function, to plug all actions into the correct menues.
2140// KDE uses a XML format to plug the actions, but we work her without this overhead. 2141// KDE uses a XML format to plug the actions, but we work her without this overhead.
2141void KABCore::addActionsManually() 2142void KABCore::addActionsManually()
2142{ 2143{
2143//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2144//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2144 2145
2145#ifdef KAB_EMBEDDED 2146#ifdef KAB_EMBEDDED
2146 QPopupMenu *fileMenu = new QPopupMenu( this ); 2147 QPopupMenu *fileMenu = new QPopupMenu( this );
2147 QPopupMenu *editMenu = new QPopupMenu( this ); 2148 QPopupMenu *editMenu = new QPopupMenu( this );
2148 QPopupMenu *helpMenu = new QPopupMenu( this ); 2149 QPopupMenu *helpMenu = new QPopupMenu( this );
2149 2150
2150 KToolBar* tb = mMainWindow->toolBar(); 2151 KToolBar* tb = mMainWindow->toolBar();
2151 mMainWindow->setToolBarsMovable (false ); 2152 mMainWindow->setToolBarsMovable (false );
2152#ifndef DESKTOP_VERSION 2153#ifndef DESKTOP_VERSION
2153 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2154 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2154#endif 2155#endif
2155 QMenuBar* mb = mMainWindow->menuBar(); 2156 QMenuBar* mb = mMainWindow->menuBar();
2156 2157
2157 //US setup menubar. 2158 //US setup menubar.
2158 //Disable the following block if you do not want to have a menubar. 2159 //Disable the following block if you do not want to have a menubar.
2159 mb->insertItem( i18n("&File"), fileMenu ); 2160 mb->insertItem( i18n("&File"), fileMenu );
2160 mb->insertItem( i18n("&Edit"), editMenu ); 2161 mb->insertItem( i18n("&Edit"), editMenu );
2161 mb->insertItem( i18n("&View"), viewMenu ); 2162 mb->insertItem( i18n("&View"), viewMenu );
2162 mb->insertItem( i18n("&Settings"), settingsMenu ); 2163 mb->insertItem( i18n("&Settings"), settingsMenu );
2163#ifdef DESKTOP_VERSION 2164#ifdef DESKTOP_VERSION
2164 mb->insertItem( i18n("Synchronize"), syncMenu ); 2165 mb->insertItem( i18n("Synchronize"), syncMenu );
2165#else 2166#else
2166 mb->insertItem( i18n("Sync"), syncMenu ); 2167 mb->insertItem( i18n("Sync"), syncMenu );
2167#endif 2168#endif
2168 //mb->insertItem( i18n("&Change"), changeMenu ); 2169 //mb->insertItem( i18n("&Change"), changeMenu );
2169 mb->insertItem( i18n("&Help"), helpMenu ); 2170 mb->insertItem( i18n("&Help"), helpMenu );
2170 mIncSearchWidget = new IncSearchWidget( tb ); 2171 mIncSearchWidget = new IncSearchWidget( tb );
2171 // tb->insertWidget(-1, 0, mIncSearchWidget); 2172 // tb->insertWidget(-1, 0, mIncSearchWidget);
2172#ifndef DESKTOP_VERSION 2173#ifndef DESKTOP_VERSION
2173 } else { 2174 } else {
2174 //US setup toolbar 2175 //US setup toolbar
2175 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2176 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2176 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2177 QPopupMenu *popupBarTB = new QPopupMenu( this );
2177 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2178 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2178 tb->insertWidget(-1, 0, menuBarTB); 2179 tb->insertWidget(-1, 0, menuBarTB);
2179 mIncSearchWidget = new IncSearchWidget( tb ); 2180 mIncSearchWidget = new IncSearchWidget( tb );
2180 tb->enableMoving(false); 2181 tb->enableMoving(false);
2181 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2182 popupBarTB->insertItem( i18n("&File"), fileMenu );
2182 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2183 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2183 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2184 popupBarTB->insertItem( i18n("&View"), viewMenu );
2184 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2185 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2185 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2186 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2186 mViewManager->getFilterAction()->plug ( popupBarTB); 2187 mViewManager->getFilterAction()->plug ( popupBarTB);
2187 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2188 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2188 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2189 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2189 if (QApplication::desktop()->width() > 320 ) { 2190 if (QApplication::desktop()->width() > 320 ) {
2190 // mViewManager->getFilterAction()->plug ( tb); 2191 // mViewManager->getFilterAction()->plug ( tb);
2191 } 2192 }
2192 } 2193 }
2193#endif 2194#endif
2194 mIncSearchWidget->setSize(); 2195 mIncSearchWidget->setSize();
2195 // mActionQuit->plug ( mMainWindow->toolBar()); 2196 // mActionQuit->plug ( mMainWindow->toolBar());
2196 2197
2197 2198
2198 2199
2199 //US Now connect the actions with the menue entries. 2200 //US Now connect the actions with the menue entries.
2200#ifdef DESKTOP_VERSION 2201#ifdef DESKTOP_VERSION
2201 mActionPrint->plug( fileMenu ); 2202 mActionPrint->plug( fileMenu );
2202 mActionPrintDetails->plug( fileMenu ); 2203 mActionPrintDetails->plug( fileMenu );
2203 fileMenu->insertSeparator(); 2204 fileMenu->insertSeparator();
2204#endif 2205#endif
2205 mActionMail->plug( fileMenu ); 2206 mActionMail->plug( fileMenu );
2206 fileMenu->insertSeparator(); 2207 fileMenu->insertSeparator();
2207 2208
2208 mActionNewContact->plug( editMenu ); 2209 mActionNewContact->plug( editMenu );
2209 mActionNewContact->plug( tb ); 2210 mActionNewContact->plug( tb );
2210 2211
2211 mActionEditAddressee->plug( editMenu ); 2212 mActionEditAddressee->plug( editMenu );
2212 editMenu->insertSeparator(); 2213 editMenu->insertSeparator();
2213 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2214 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2214 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2215 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2215 mActionEditAddressee->plug( tb ); 2216 mActionEditAddressee->plug( tb );
2216 2217
2217 // fileMenu->insertSeparator(); 2218 // fileMenu->insertSeparator();
2218 mActionSave->plug( fileMenu ); 2219 mActionSave->plug( fileMenu );
2219 fileMenu->insertItem( "&Import", ImportMenu ); 2220 fileMenu->insertItem( "&Import", ImportMenu );
2220 fileMenu->insertItem( "&Export", ExportMenu ); 2221 fileMenu->insertItem( "&Export", ExportMenu );
2221 editMenu->insertItem( i18n("&Change"), changeMenu ); 2222 editMenu->insertItem( i18n("&Change"), changeMenu );
2222 editMenu->insertSeparator(); 2223 editMenu->insertSeparator();
2223#ifndef DESKTOP_VERSION 2224#ifndef DESKTOP_VERSION
2224 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2225 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2225#endif 2226#endif
2226#if 0 2227#if 0
2227 // PENDING fix MailVCard 2228 // PENDING fix MailVCard
2228 fileMenu->insertSeparator(); 2229 fileMenu->insertSeparator();
2229 mActionMailVCard->plug( fileMenu ); 2230 mActionMailVCard->plug( fileMenu );
2230#endif 2231#endif
2231#ifndef DESKTOP_VERSION 2232#ifndef DESKTOP_VERSION
2232 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2233 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2233 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2234 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2234 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2235 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2235#endif 2236#endif
2236 fileMenu->insertSeparator(); 2237 fileMenu->insertSeparator();
2237 mActionQuit->plug( fileMenu ); 2238 mActionQuit->plug( fileMenu );
2238#ifdef _OL_IMPORT_ 2239#ifdef _OL_IMPORT_
2239 mActionImportOL->plug( ImportMenu ); 2240 mActionImportOL->plug( ImportMenu );
2240#endif 2241#endif
2241 // edit menu 2242 // edit menu
2242 mActionUndo->plug( editMenu ); 2243 mActionUndo->plug( editMenu );
2243 mActionRedo->plug( editMenu ); 2244 mActionRedo->plug( editMenu );
2244 editMenu->insertSeparator(); 2245 editMenu->insertSeparator();
2245 mActionCut->plug( editMenu ); 2246 mActionCut->plug( editMenu );
2246 mActionCopy->plug( editMenu ); 2247 mActionCopy->plug( editMenu );
2247 mActionPaste->plug( editMenu ); 2248 mActionPaste->plug( editMenu );
2248 mActionDelete->plug( editMenu ); 2249 mActionDelete->plug( editMenu );
2249 editMenu->insertSeparator(); 2250 editMenu->insertSeparator();
2250 mActionSelectAll->plug( editMenu ); 2251 mActionSelectAll->plug( editMenu );
2251 2252
2252 mActionSetFormattedName->plug( changeMenu ); 2253 mActionSetFormattedName->plug( changeMenu );
2253 mActionRemoveVoice->plug( changeMenu ); 2254 mActionRemoveVoice->plug( changeMenu );
2254 // settingsmings menu 2255 // settingsmings menu
2255//US special menuentry to configure the addressbook resources. On KDE 2256//US special menuentry to configure the addressbook resources. On KDE
2256// you do that through the control center !!! 2257// you do that through the control center !!!
2257 // settingsMenu->insertSeparator(); 2258 // settingsMenu->insertSeparator();
2258 2259
2259 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2260 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2260 mActionConfigGlobal->plug( settingsMenu, 1 ); 2261 mActionConfigGlobal->plug( settingsMenu, 1 );
2261 mActionConfigResources->plug( settingsMenu,2 ); 2262 mActionConfigResources->plug( settingsMenu,2 );
2262 settingsMenu->insertSeparator(3); 2263 settingsMenu->insertSeparator(3);
2263 2264
2264 if ( mIsPart ) { 2265 if ( mIsPart ) {
2265 //US not implemented yet 2266 //US not implemented yet
2266 //mActionConfigShortcuts->plug( settingsMenu ); 2267 //mActionConfigShortcuts->plug( settingsMenu );
2267 //mActionConfigureToolbars->plug( settingsMenu ); 2268 //mActionConfigureToolbars->plug( settingsMenu );
2268 2269
2269 } else { 2270 } else {
2270 //US not implemented yet 2271 //US not implemented yet
2271 //mActionKeyBindings->plug( settingsMenu ); 2272 //mActionKeyBindings->plug( settingsMenu );
2272 } 2273 }
2273 2274
2274 mActionEditCategories->plug( settingsMenu ); 2275 mActionEditCategories->plug( settingsMenu );
2275 mActionManageCategories->plug( settingsMenu ); 2276 mActionManageCategories->plug( settingsMenu );
2276 mActionJumpBar->plug( viewMenu,0 ); 2277 mActionJumpBar->plug( viewMenu,0 );
2277 mActionDetails->plug( viewMenu,0 ); 2278 mActionDetails->plug( viewMenu,0 );
2278 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2279 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2279 mActionDetails->plug( tb ); 2280 mActionDetails->plug( tb );
2280 settingsMenu->insertSeparator(); 2281 settingsMenu->insertSeparator();
2281#ifndef DESKTOP_VERSION 2282#ifndef DESKTOP_VERSION
2282 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2283 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2283 settingsMenu->insertSeparator(); 2284 settingsMenu->insertSeparator();
2284#endif 2285#endif
2285 2286
2286 mActionWhoAmI->plug( settingsMenu ); 2287 mActionWhoAmI->plug( settingsMenu );
2287 //mActionEditCategories->plug( changeMenu ); 2288 //mActionEditCategories->plug( changeMenu );
2288 mActionCategories->plug( changeMenu ); 2289 mActionCategories->plug( changeMenu );
2289 //mActionManageCategories->plug( changeMenu ); 2290 //mActionManageCategories->plug( changeMenu );
2290 2291
2291 //mActionCategories->plug( settingsMenu ); 2292 //mActionCategories->plug( settingsMenu );
2292 2293
2293 2294
2294 mActionWN->plug( helpMenu ); 2295 mActionWN->plug( helpMenu );
2295 mActionStorageHowto->plug( helpMenu ); 2296 mActionStorageHowto->plug( helpMenu );
2296 mActionSyncHowto->plug( helpMenu ); 2297 mActionSyncHowto->plug( helpMenu );
2297 mActionKdeSyncHowto->plug( helpMenu ); 2298 mActionKdeSyncHowto->plug( helpMenu );
2298 mActionMultiSyncHowto->plug( helpMenu ); 2299 mActionMultiSyncHowto->plug( helpMenu );
2299 mActionFaq->plug( helpMenu ); 2300 mActionFaq->plug( helpMenu );
2300 mActionLicence->plug( helpMenu ); 2301 mActionLicence->plug( helpMenu );
2301 mActionAboutKAddressbook->plug( helpMenu ); 2302 mActionAboutKAddressbook->plug( helpMenu );
2302 2303
2303 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2304 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2304 2305
2305 mActionSave->plug( tb ); 2306 mActionSave->plug( tb );
2306 mViewManager->getFilterAction()->plug ( tb); 2307 mViewManager->getFilterAction()->plug ( tb);
2307 //LR hide filteraction on started in 480x640 2308 //LR hide filteraction on started in 480x640
2308 if (QApplication::desktop()->width() == 480 ) { 2309 if (QApplication::desktop()->width() == 480 ) {
2309 mViewManager->getFilterAction()->setComboWidth( 0 ); 2310 mViewManager->getFilterAction()->setComboWidth( 0 );
2310 } 2311 }
2311 mActionUndo->plug( tb ); 2312 mActionUndo->plug( tb );
2312 mActionDelete->plug( tb ); 2313 mActionDelete->plug( tb );
2313 mActionRedo->plug( tb ); 2314 mActionRedo->plug( tb );
2314 } else { 2315 } else {
2315 mActionSave->plug( tb ); 2316 mActionSave->plug( tb );
2316 tb->enableMoving(false); 2317 tb->enableMoving(false);
2317 } 2318 }
2318 //mActionQuit->plug ( tb ); 2319 //mActionQuit->plug ( tb );
2319 //tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2320 //tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2320 2321
2321 //US link the searchwidget first to this. 2322 //US link the searchwidget first to this.
2322 // The real linkage to the toolbar happens later. 2323 // The real linkage to the toolbar happens later.
2323//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2324//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2324//US tb->insertItem( mIncSearchWidget ); 2325//US tb->insertItem( mIncSearchWidget );
2325/*US 2326/*US
2326 mIncSearchWidget = new IncSearchWidget( tb ); 2327 mIncSearchWidget = new IncSearchWidget( tb );
2327 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2328 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2328 SLOT( incrementalSearch( const QString& ) ) ); 2329 SLOT( incrementalSearch( const QString& ) ) );
2329 2330
2330 mJumpButtonBar = new JumpButtonBar( this, this ); 2331 mJumpButtonBar = new JumpButtonBar( this, this );
2331 2332
2332//US topLayout->addWidget( mJumpButtonBar ); 2333//US topLayout->addWidget( mJumpButtonBar );
2333 this->layout()->add( mJumpButtonBar ); 2334 this->layout()->add( mJumpButtonBar );
2334*/ 2335*/
2335 2336
2336#endif //KAB_EMBEDDED 2337#endif //KAB_EMBEDDED
2337 2338
2338 mActionExport2phone->plug( ExportMenu ); 2339 mActionExport2phone->plug( ExportMenu );
2339 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2340 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2340 syncManager->fillSyncMenu(); 2341 syncManager->fillSyncMenu();
2341 2342
2342} 2343}
2343void KABCore::showLicence() 2344void KABCore::showLicence()
2344{ 2345{
2345 KApplication::showLicence(); 2346 KApplication::showLicence();
2346} 2347}
2347 2348
2348void KABCore::manageCategories( ) 2349void KABCore::manageCategories( )
2349{ 2350{
2350 KABCatPrefs* cp = new KABCatPrefs(); 2351 KABCatPrefs* cp = new KABCatPrefs();
2351 cp->show(); 2352 cp->show();
2352 int w =cp->sizeHint().width() ; 2353 int w =cp->sizeHint().width() ;
2353 int h = cp->sizeHint().height() ; 2354 int h = cp->sizeHint().height() ;
2354 int dw = QApplication::desktop()->width(); 2355 int dw = QApplication::desktop()->width();
2355 int dh = QApplication::desktop()->height(); 2356 int dh = QApplication::desktop()->height();
2356 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2357 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2357 if ( !cp->exec() ) { 2358 if ( !cp->exec() ) {
2358 delete cp; 2359 delete cp;
2359 return; 2360 return;
2360 } 2361 }
2361 int count = 0; 2362 int count = 0;
2362 int cc = 0; 2363 int cc = 0;
2363 message( i18n("Please wait, processing categories...")); 2364 message( i18n("Please wait, processing categories..."));
2364 if ( cp->addCat() ) { 2365 if ( cp->addCat() ) {
2365 KABC::AddressBook::Iterator it; 2366 KABC::AddressBook::Iterator it;
2366 QStringList catList = KABPrefs::instance()->mCustomCategories; 2367 QStringList catList = KABPrefs::instance()->mCustomCategories;
2367 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2368 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2368 ++cc; 2369 ++cc;
2369 if ( cc %10 == 0) 2370 if ( cc %10 == 0)
2370 message(i18n("Processing contact #%1").arg(cc)); 2371 message(i18n("Processing contact #%1").arg(cc));
2371 QStringList catIncList = (*it).categories(); 2372 QStringList catIncList = (*it).categories();
2372 int i; 2373 int i;
2373 for( i = 0; i< catIncList.count(); ++i ) { 2374 for( i = 0; i< catIncList.count(); ++i ) {
2374 if ( !catList.contains (catIncList[i])) { 2375 if ( !catList.contains (catIncList[i])) {
2375 catList.append( catIncList[i] ); 2376 catList.append( catIncList[i] );
2376 //qDebug("add cat %s ", catIncList[i].latin1()); 2377 //qDebug("add cat %s ", catIncList[i].latin1());
2377 ++count; 2378 ++count;
2378 } 2379 }
2379 } 2380 }
2380 } 2381 }
2381 catList.sort(); 2382 catList.sort();
2382 KABPrefs::instance()->mCustomCategories = catList; 2383 KABPrefs::instance()->mCustomCategories = catList;
2383 KABPrefs::instance()->writeConfig(); 2384 KABPrefs::instance()->writeConfig();
2384 message(QString::number( count )+ i18n(" categories added to list! ")); 2385 message(QString::number( count )+ i18n(" categories added to list! "));
2385 } else { 2386 } else {
2386 QStringList catList = KABPrefs::instance()->mCustomCategories; 2387 QStringList catList = KABPrefs::instance()->mCustomCategories;
2387 QStringList catIncList; 2388 QStringList catIncList;
2388 QStringList newCatList; 2389 QStringList newCatList;
2389 KABC::AddressBook::Iterator it; 2390 KABC::AddressBook::Iterator it;
2390 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2391 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2391 ++cc; 2392 ++cc;
2392 if ( cc %10 == 0) 2393 if ( cc %10 == 0)
2393 message(i18n("Processing contact #%1").arg(cc)); 2394 message(i18n("Processing contact #%1").arg(cc));
2394 QStringList catIncList = (*it).categories(); 2395 QStringList catIncList = (*it).categories();
2395 int i; 2396 int i;
2396 if ( catIncList.count() ) { 2397 if ( catIncList.count() ) {
2397 newCatList.clear(); 2398 newCatList.clear();
2398 for( i = 0; i< catIncList.count(); ++i ) { 2399 for( i = 0; i< catIncList.count(); ++i ) {
2399 if ( catList.contains (catIncList[i])) { 2400 if ( catList.contains (catIncList[i])) {
2400 newCatList.append( catIncList[i] ); 2401 newCatList.append( catIncList[i] );
2401 } 2402 }
2402 } 2403 }
2403 newCatList.sort(); 2404 newCatList.sort();
2404 (*it).setCategories( newCatList ); 2405 (*it).setCategories( newCatList );
2405 mAddressBook->insertAddressee( (*it) ); 2406 mAddressBook->insertAddressee( (*it) );
2406 } 2407 }
2407 } 2408 }
2408 setModified( true ); 2409 setModified( true );
2409 mViewManager->refreshView(); 2410 mViewManager->refreshView();
2410 message( i18n("Removing categories done!")); 2411 message( i18n("Removing categories done!"));
2411 } 2412 }
2412 delete cp; 2413 delete cp;
2413} 2414}
2414void KABCore::removeVoice() 2415void KABCore::removeVoice()
2415{ 2416{
2416 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2417 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2417 return; 2418 return;
2418 XXPortSelectDialog dlg( this, false, this ); 2419 XXPortSelectDialog dlg( this, false, this );
2419 if ( !dlg.exec() ) 2420 if ( !dlg.exec() )
2420 return; 2421 return;
2421 mAddressBook->setUntagged(); 2422 mAddressBook->setUntagged();
2422 dlg.tagSelected(); 2423 dlg.tagSelected();
2423 message(i18n("Removing voice..."), false ); 2424 message(i18n("Removing voice..."), false );
2424 KABC::AddressBook::Iterator it; 2425 KABC::AddressBook::Iterator it;
2425 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2426 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2426 if ( (*it).tagged() ) { 2427 if ( (*it).tagged() ) {
2427 (*it).removeVoice(); 2428 (*it).removeVoice();
2428 } 2429 }
2429 } 2430 }
2430 message(i18n("Refreshing view...") ); 2431 message(i18n("Refreshing view...") );
2431 qApp->processEvents(); 2432 qApp->processEvents();
2432 mViewManager->refreshView( "" ); 2433 mViewManager->refreshView( "" );
2433 Addressee add; 2434 Addressee add;
2434 mDetails->setAddressee( add ); 2435 mDetails->setAddressee( add );
2435 message(i18n("Remove voice completed!") ); 2436 message(i18n("Remove voice completed!") );
2436 2437
2437 2438
2438 2439
2439} 2440}
2440 2441
2441void KABCore::setFormattedName() 2442void KABCore::setFormattedName()
2442{ 2443{
2443 KABFormatPrefs setpref; 2444 KABFormatPrefs setpref;
2444 if ( !setpref.exec() ) { 2445 if ( !setpref.exec() ) {
2445 return; 2446 return;
2446 } 2447 }
2447 XXPortSelectDialog dlg( this, false, this ); 2448 XXPortSelectDialog dlg( this, false, this );
2448 if ( !dlg.exec() ) 2449 if ( !dlg.exec() )
2449 return; 2450 return;
2450 mAddressBook->setUntagged(); 2451 mAddressBook->setUntagged();
2451 dlg.tagSelected(); 2452 dlg.tagSelected();
2452 int count = 0; 2453 int count = 0;
2453 KABC::AddressBook::Iterator it; 2454 KABC::AddressBook::Iterator it;
2454 bool modified = false; 2455 bool modified = false;
2455 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2456 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2456 if ( (*it).tagged() ) { 2457 if ( (*it).tagged() ) {
2457 if ( (*it).uid().left( 2 ) == "la" ) 2458 if ( (*it).uid().left( 2 ) == "la" )
2458 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) 2459 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") )
2459 continue; 2460 continue;
2460 ++count; 2461 ++count;
2461 if ( count %10 == 0 ) 2462 if ( count %10 == 0 )
2462 message(i18n("Changing contact #%1").arg( count ) ); 2463 message(i18n("Changing contact #%1").arg( count ) );
2463 qApp->processEvents(); 2464 qApp->processEvents();
2464 QString fName; 2465 QString fName;
2465 if ( setpref.simple->isChecked() ) 2466 if ( setpref.simple->isChecked() )
2466 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2467 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2467 else if ( setpref.full->isChecked() ) 2468 else if ( setpref.full->isChecked() )
2468 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2469 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2469 else if ( setpref.reverse->isChecked() ) 2470 else if ( setpref.reverse->isChecked() )
2470 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2471 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2471 else 2472 else
2472 fName = (*it).organization(); 2473 fName = (*it).organization();
2473 if ( setpref.setCompany->isChecked() ) 2474 if ( setpref.setCompany->isChecked() )
2474 if ( fName.isEmpty() || fName =="," ) 2475 if ( fName.isEmpty() || fName =="," )
2475 fName = (*it).organization(); 2476 fName = (*it).organization();
2476 (*it).setFormattedName( fName ); 2477 (*it).setFormattedName( fName );
2477 (*it).setChanged( true ); 2478 (*it).setChanged( true );
2478 modified = true; 2479 modified = true;
2479 (*it).setRevision( QDateTime::currentDateTime() ); 2480 (*it).setRevision( QDateTime::currentDateTime() );
2480 } 2481 }
2481 } 2482 }
2482 message(i18n("Refreshing view...") ); 2483 message(i18n("Refreshing view...") );
2483 qApp->processEvents(); 2484 qApp->processEvents();
2484 if ( modified ) 2485 if ( modified )
2485 setModified( true ); 2486 setModified( true );
2486 Addressee add; 2487 Addressee add;
2487 mDetails->setAddressee( add ); 2488 mDetails->setAddressee( add );
2488 if ( count == 0 ) 2489 if ( count == 0 )
2489 message(i18n("No contact changed!") ); 2490 message(i18n("No contact changed!") );
2490 else 2491 else
2491 message(i18n("%1 contacts changed!").arg( count ) ); 2492 message(i18n("%1 contacts changed!").arg( count ) );
2492} 2493}
2493 2494
2494void KABCore::clipboardDataChanged() 2495void KABCore::clipboardDataChanged()
2495{ 2496{
2496 2497
2497 if ( mReadWrite ) 2498 if ( mReadWrite )
2498 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2499 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2499 2500
2500} 2501}
2501 2502
2502void KABCore::updateActionMenu() 2503void KABCore::updateActionMenu()
2503{ 2504{
2504 UndoStack *undo = UndoStack::instance(); 2505 UndoStack *undo = UndoStack::instance();
2505 RedoStack *redo = RedoStack::instance(); 2506 RedoStack *redo = RedoStack::instance();
2506 2507
2507 if ( undo->isEmpty() ) 2508 if ( undo->isEmpty() )
2508 mActionUndo->setText( i18n( "Undo" ) ); 2509 mActionUndo->setText( i18n( "Undo" ) );
2509 else 2510 else
2510 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2511 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2511 2512
2512 mActionUndo->setEnabled( !undo->isEmpty() ); 2513 mActionUndo->setEnabled( !undo->isEmpty() );
2513 2514
2514 if ( !redo->top() ) 2515 if ( !redo->top() )
2515 mActionRedo->setText( i18n( "Redo" ) ); 2516 mActionRedo->setText( i18n( "Redo" ) );
2516 else 2517 else
2517 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2518 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2518 2519
2519 mActionRedo->setEnabled( !redo->isEmpty() ); 2520 mActionRedo->setEnabled( !redo->isEmpty() );
2520} 2521}
2521 2522
2522void KABCore::configureKeyBindings() 2523void KABCore::configureKeyBindings()
2523{ 2524{
2524#ifndef KAB_EMBEDDED 2525#ifndef KAB_EMBEDDED
2525 KKeyDialog::configure( actionCollection(), true ); 2526 KKeyDialog::configure( actionCollection(), true );
2526#else //KAB_EMBEDDED 2527#else //KAB_EMBEDDED
2527 qDebug("KABCore::configureKeyBindings() not implemented"); 2528 qDebug("KABCore::configureKeyBindings() not implemented");
2528#endif //KAB_EMBEDDED 2529#endif //KAB_EMBEDDED
2529} 2530}
2530 2531
2531#ifdef KAB_EMBEDDED 2532#ifdef KAB_EMBEDDED
2532void KABCore::configureResources() 2533void KABCore::configureResources()
2533{ 2534{
2534 KRES::KCMKResources dlg( this, "" , 0 ); 2535 KRES::KCMKResources dlg( this, "" , 0 );
2535 2536
2536 if ( !dlg.exec() ) 2537 if ( !dlg.exec() )
2537 return; 2538 return;
2538 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2539 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2539} 2540}
2540#endif //KAB_EMBEDDED 2541#endif //KAB_EMBEDDED
2541 2542
2542 2543
2543/* this method will be called through the QCop interface from Ko/Pi to select addresses 2544/* this method will be called through the QCop interface from Ko/Pi to select addresses
2544 * for the attendees list of an event. 2545 * for the attendees list of an event.
2545 */ 2546 */
2546void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2547void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2547{ 2548{
2548 qDebug("KABCore::requestForNameEmailUidList "); 2549 qDebug("KABCore::requestForNameEmailUidList ");
2549 bool ok = false; 2550 bool ok = false;
2550 mEmailSourceChannel = sourceChannel; 2551 mEmailSourceChannel = sourceChannel;
2551 mEmailSourceUID = uid; 2552 mEmailSourceUID = uid;
2552 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2553 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2553 //callContactdialog(); 2554 //callContactdialog();
2554#if 0 2555#if 0
2555 int wid = uid.toInt( &ok ); 2556 int wid = uid.toInt( &ok );
2556 qDebug("UID %s ", uid.latin1()); 2557 qDebug("UID %s ", uid.latin1());
2557 if ( ok ) { 2558 if ( ok ) {
2558 if ( wid != QApplication::desktop()->width() ) { 2559 if ( wid != QApplication::desktop()->width() ) {
2559 qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); 2560 qDebug("KA/Pi: Request from different desktop geometry. Resizing ...");
2560 message( i18n("Resizing, please wait...") ); 2561 message( i18n("Resizing, please wait...") );
2561 mMainWindow->showMinimized(); 2562 mMainWindow->showMinimized();
2562 /* 2563 /*
2563 { 2564 {
2564 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2565 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2565 } 2566 }
2566 */ 2567 */
2567 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); 2568 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) );
2568 return; 2569 return;
2569 } 2570 }
2570 2571
2571 } else { 2572 } else {
2572 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); 2573 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid ");
2573 } 2574 }
2574 callContactdialog(); 2575 callContactdialog();
2575 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2576 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2576#endif 2577#endif
2577} 2578}
2578void KABCore::resizeAndCallContactdialog() 2579void KABCore::resizeAndCallContactdialog()
2579{ 2580{
2580 updateMainWindow(); 2581 updateMainWindow();
2581 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2582 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2582} 2583}
2583 2584
2584void KABCore::doRingSync() 2585void KABCore::doRingSync()
2585{ 2586{
2586 syncManager->multiSync( false ); 2587 syncManager->multiSync( false );
2587} 2588}
2588void KABCore::callContactdialog() 2589void KABCore::callContactdialog()
2589{ 2590{
2590 static bool running = false; 2591 static bool running = false;
2591 if (running) return; 2592 if (running) return;
2592 running = true; 2593 running = true;
2593 QStringList nameList; 2594 QStringList nameList;
2594 QStringList emailList; 2595 QStringList emailList;
2595 QStringList uidList; 2596 QStringList uidList;
2596 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); 2597 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() );
2597 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2598 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2598 uint i=0; 2599 uint i=0;
2599 for (i=0; i < list.count(); i++) 2600 for (i=0; i < list.count(); i++)
2600 { 2601 {
2601 nameList.append(list[i].realName()); 2602 nameList.append(list[i].realName());
2602 emailList.append(list[i].preferredEmail()); 2603 emailList.append(list[i].preferredEmail());
2603 uidList.append(list[i].uid()); 2604 uidList.append(list[i].uid());
2604 } 2605 }
2605 QString uid = mEmailSourceUID; 2606 QString uid = mEmailSourceUID;
2606 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); 2607 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1());
2607 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); 2608 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList);
2608 running = false; 2609 running = false;
2609} 2610}
2610/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2611/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2611 * to put them into the calendar. 2612 * to put them into the calendar.
2612 */ 2613 */
2613void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2614void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2614{ 2615{
2615 // qDebug("KABCore::requestForBirthdayList"); 2616 // qDebug("KABCore::requestForBirthdayList");
2616 QStringList birthdayList; 2617 QStringList birthdayList;
2617 QStringList anniversaryList; 2618 QStringList anniversaryList;
2618 QStringList realNameList; 2619 QStringList realNameList;
2619 QStringList preferredEmailList; 2620 QStringList preferredEmailList;
2620 QStringList assembledNameList; 2621 QStringList assembledNameList;
2621 QStringList uidList; 2622 QStringList uidList;
2622 2623
2623 KABC::AddressBook::Iterator it; 2624 KABC::AddressBook::Iterator it;
2624 2625
2625 int count = 0; 2626 int count = 0;
2626 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2627 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2627 ++count; 2628 ++count;
2628 } 2629 }
2629 QProgressBar bar(count,0 ); 2630 QProgressBar bar(count,0 );
2630 int w = 300; 2631 int w = 300;
2631 if ( QApplication::desktop()->width() < 320 ) 2632 if ( QApplication::desktop()->width() < 320 )
2632 w = 220; 2633 w = 220;
2633 int h = bar.sizeHint().height() ; 2634 int h = bar.sizeHint().height() ;
2634 int dw = QApplication::desktop()->width(); 2635 int dw = QApplication::desktop()->width();
2635 int dh = QApplication::desktop()->height(); 2636 int dh = QApplication::desktop()->height();
2636 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2637 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2637 bar.show(); 2638 bar.show();
2638 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2639 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2639 qApp->processEvents(); 2640 qApp->processEvents();
2640 2641
2641 QDate bday; 2642 QDate bday;
2642 QString anni; 2643 QString anni;
2643 QString formattedbday; 2644 QString formattedbday;
2644 2645
2645 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2646 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2646 { 2647 {
2647 if ( ! bar.isVisible() ) 2648 if ( ! bar.isVisible() )
2648 return; 2649 return;
2649 bar.setProgress( count++ ); 2650 bar.setProgress( count++ );
2650 qApp->processEvents(); 2651 qApp->processEvents();
2651 bday = (*it).birthday().date(); 2652 bday = (*it).birthday().date();
2652 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2653 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2653 2654
2654 if ( bday.isValid() || !anni.isEmpty()) 2655 if ( bday.isValid() || !anni.isEmpty())
2655 { 2656 {
2656 if (bday.isValid()) 2657 if (bday.isValid())
2657 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2658 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2658 else 2659 else
2659 formattedbday = "NOTVALID"; 2660 formattedbday = "NOTVALID";
2660 if (anni.isEmpty()) 2661 if (anni.isEmpty())
2661 anni = "INVALID"; 2662 anni = "INVALID";
2662 2663
2663 birthdayList.append(formattedbday); 2664 birthdayList.append(formattedbday);
2664 anniversaryList.append(anni); //should be ISODate 2665 anniversaryList.append(anni); //should be ISODate
2665 realNameList.append((*it).realName()); 2666 realNameList.append((*it).realName());
2666 preferredEmailList.append((*it).preferredEmail()); 2667 preferredEmailList.append((*it).preferredEmail());
2667 assembledNameList.append((*it).assembledName()); 2668 assembledNameList.append((*it).assembledName());
2668 uidList.append((*it).uid()); 2669 uidList.append((*it).uid());
2669 2670
2670 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2671 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2671 } 2672 }
2672 } 2673 }
2673 2674
2674 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2675 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2675 2676
2676} 2677}
2677 2678
2678/* this method will be called through the QCop interface from other apps to show details of a contact. 2679/* this method will be called through the QCop interface from other apps to show details of a contact.
2679 */ 2680 */
2680void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2681void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2681{ 2682{
2682 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2683 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2683 2684
2684 QString foundUid = QString::null; 2685 QString foundUid = QString::null;
2685 if ( ! uid.isEmpty() ) { 2686 if ( ! uid.isEmpty() ) {
2686 Addressee adrr = mAddressBook->findByUid( uid ); 2687 Addressee adrr = mAddressBook->findByUid( uid );
2687 if ( !adrr.isEmpty() ) { 2688 if ( !adrr.isEmpty() ) {
2688 foundUid = uid; 2689 foundUid = uid;
2689 } 2690 }
2690 if ( email == "sendbacklist" ) { 2691 if ( email == "sendbacklist" ) {
2691 //qDebug("ssssssssssssssssssssssend "); 2692 //qDebug("ssssssssssssssssssssssend ");
2692 QStringList nameList; 2693 QStringList nameList;
2693 QStringList emailList; 2694 QStringList emailList;
2694 QStringList uidList; 2695 QStringList uidList;
2695 nameList.append(adrr.realName()); 2696 nameList.append(adrr.realName());
2696 emailList = adrr.emails(); 2697 emailList = adrr.emails();
2697 uidList.append( adrr.preferredEmail()); 2698 uidList.append( adrr.preferredEmail());
2698 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2699 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2699 return; 2700 return;
2700 } 2701 }
2701 2702
2702 } 2703 }
2703 2704
2704 if ( email == "sendbacklist" ) 2705 if ( email == "sendbacklist" )
2705 return; 2706 return;
2706 if (foundUid.isEmpty()) 2707 if (foundUid.isEmpty())
2707 { 2708 {
2708 //find the uid of the person first 2709 //find the uid of the person first
2709 Addressee::List namelist; 2710 Addressee::List namelist;
2710 Addressee::List emaillist; 2711 Addressee::List emaillist;
2711 2712
2712 if (!name.isEmpty()) 2713 if (!name.isEmpty())
2713 namelist = mAddressBook->findByName( name ); 2714 namelist = mAddressBook->findByName( name );
2714 2715
2715 if (!email.isEmpty()) 2716 if (!email.isEmpty())
2716 emaillist = mAddressBook->findByEmail( email ); 2717 emaillist = mAddressBook->findByEmail( email );
2717 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2718 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2718 //check if we have a match in Namelist and Emaillist 2719 //check if we have a match in Namelist and Emaillist
2719 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2720 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2720 foundUid = emaillist[0].uid(); 2721 foundUid = emaillist[0].uid();
2721 } 2722 }
2722 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2723 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2723 foundUid = namelist[0].uid(); 2724 foundUid = namelist[0].uid();
2724 else 2725 else
2725 { 2726 {
2726 for (int i = 0; i < namelist.count(); i++) 2727 for (int i = 0; i < namelist.count(); i++)
2727 { 2728 {
2728 for (int j = 0; j < emaillist.count(); j++) 2729 for (int j = 0; j < emaillist.count(); j++)
2729 { 2730 {
2730 if (namelist[i] == emaillist[j]) 2731 if (namelist[i] == emaillist[j])
2731 { 2732 {
2732 foundUid = namelist[i].uid(); 2733 foundUid = namelist[i].uid();
2733 } 2734 }
2734 } 2735 }
2735 } 2736 }
2736 } 2737 }
2737 } 2738 }
2738 else 2739 else
2739 { 2740 {
2740 foundUid = uid; 2741 foundUid = uid;
2741 } 2742 }
2742 2743
2743 if (!foundUid.isEmpty()) 2744 if (!foundUid.isEmpty())
2744 { 2745 {
2745 2746
2746 // raise Ka/Pi if it is in the background 2747 // raise Ka/Pi if it is in the background
2747#ifndef DESKTOP_VERSION 2748#ifndef DESKTOP_VERSION
2748#ifndef KORG_NODCOP 2749#ifndef KORG_NODCOP
2749 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2750 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2750#endif 2751#endif
2751#endif 2752#endif
2752 2753
2753 mMainWindow->showMaximized(); 2754 mMainWindow->showMaximized();
2754 mMainWindow-> raise(); 2755 mMainWindow-> raise();
2755 2756
2756 mViewManager->setSelected( "", false); 2757 mViewManager->setSelected( "", false);
2757 mViewManager->refreshView( "" ); 2758 mViewManager->refreshView( "" );
2758 mViewManager->setSelected( foundUid, true ); 2759 mViewManager->setSelected( foundUid, true );
2759 mViewManager->refreshView( foundUid ); 2760 mViewManager->refreshView( foundUid );
2760 2761
2761 if ( !mMultipleViewsAtOnce ) 2762 if ( !mMultipleViewsAtOnce )
2762 { 2763 {
2763 setDetailsVisible( true ); 2764 setDetailsVisible( true );
2764 mActionDetails->setChecked(true); 2765 mActionDetails->setChecked(true);
2765 } 2766 }
2766 } 2767 }
2767} 2768}
2768void KABCore::storagehowto() 2769void KABCore::storagehowto()
2769{ 2770{
2770 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 2771 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
2771} 2772}
2772void KABCore::whatsnew() 2773void KABCore::whatsnew()
2773{ 2774{
2774 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2775 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2775} 2776}
2776void KABCore::synchowto() 2777void KABCore::synchowto()
2777{ 2778{
2778 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2779 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2779} 2780}
2780void KABCore::kdesynchowto() 2781void KABCore::kdesynchowto()
2781{ 2782{
2782 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2783 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2783} 2784}
2784void KABCore::multisynchowto() 2785void KABCore::multisynchowto()
2785{ 2786{
2786 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2787 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2787} 2788}
2788void KABCore::faq() 2789void KABCore::faq()
2789{ 2790{
2790 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2791 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2791} 2792}
2792 2793
2793#include <libkcal/syncdefines.h> 2794#include <libkcal/syncdefines.h>
2794 2795
2795KABC::Addressee KABCore::getLastSyncAddressee() 2796KABC::Addressee KABCore::getLastSyncAddressee()
2796{ 2797{
2797 Addressee lse; 2798 Addressee lse;
2798 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2799 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2799 2800
2800 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2801 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2801 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2802 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2802 if (lse.isEmpty()) { 2803 if (lse.isEmpty()) {
2803 qDebug("KA: Creating new last-syncAddressee "); 2804 qDebug("KA: Creating new last-syncAddressee ");
2804 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2805 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2805 QString sum = ""; 2806 QString sum = "";
2806 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2807 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2807 sum = "E: "; 2808 sum = "E: ";
2808 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2809 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2809 lse.setRevision( mLastAddressbookSync ); 2810 lse.setRevision( mLastAddressbookSync );
2810 lse.setCategories( i18n("SyncEvent") ); 2811 lse.setCategories( i18n("SyncEvent") );
2811 mAddressBook->insertAddressee( lse ); 2812 mAddressBook->insertAddressee( lse );
2812 } 2813 }
2813 return lse; 2814 return lse;
2814} 2815}
2815int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2816int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2816{ 2817{
2817 2818
2818 //void setZaurusId(int id); 2819 //void setZaurusId(int id);
2819 // int zaurusId() const; 2820 // int zaurusId() const;
2820 // void setZaurusUid(int id); 2821 // void setZaurusUid(int id);
2821 // int zaurusUid() const; 2822 // int zaurusUid() const;
2822 // void setZaurusStat(int id); 2823 // void setZaurusStat(int id);
2823 // int zaurusStat() const; 2824 // int zaurusStat() const;
2824 // 0 equal 2825 // 0 equal
2825 // 1 take local 2826 // 1 take local
2826 // 2 take remote 2827 // 2 take remote
2827 // 3 cancel 2828 // 3 cancel
2828 QDateTime lastSync = mLastAddressbookSync; 2829 QDateTime lastSync = mLastAddressbookSync;
2829 QDateTime localMod = local->revision(); 2830 QDateTime localMod = local->revision();
2830 QDateTime remoteMod = remote->revision(); 2831 QDateTime remoteMod = remote->revision();
2831 2832
2832 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2833 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2833 2834
2834 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2835 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2835 bool remCh, locCh; 2836 bool remCh, locCh;
2836 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2837 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2837 //if ( remCh ) 2838 //if ( remCh )
2838 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2839 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2839 locCh = ( localMod > mLastAddressbookSync ); 2840 locCh = ( localMod > mLastAddressbookSync );
2840 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2841 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2841 if ( !remCh && ! locCh ) { 2842 if ( !remCh && ! locCh ) {
2842 //qDebug("both not changed "); 2843 //qDebug("both not changed ");
2843 lastSync = localMod.addDays(1); 2844 lastSync = localMod.addDays(1);
2844 if ( mode <= SYNC_PREF_ASK ) 2845 if ( mode <= SYNC_PREF_ASK )
2845 return 0; 2846 return 0;
2846 } else { 2847 } else {
2847 if ( locCh ) { 2848 if ( locCh ) {
2848 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2849 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2849 lastSync = localMod.addDays( -1 ); 2850 lastSync = localMod.addDays( -1 );
2850 if ( !remCh ) 2851 if ( !remCh )
2851 remoteMod =( lastSync.addDays( -1 ) ); 2852 remoteMod =( lastSync.addDays( -1 ) );
2852 } else { 2853 } else {
2853 //qDebug(" not loc changed "); 2854 //qDebug(" not loc changed ");
2854 lastSync = localMod.addDays( 1 ); 2855 lastSync = localMod.addDays( 1 );
2855 if ( remCh ) { 2856 if ( remCh ) {
2856 //qDebug("rem changed "); 2857 //qDebug("rem changed ");
2857 remoteMod =( lastSync.addDays( 1 ) ); 2858 remoteMod =( lastSync.addDays( 1 ) );
2858 } 2859 }
2859 2860
2860 } 2861 }
2861 } 2862 }
2862 full = true; 2863 full = true;
2863 if ( mode < SYNC_PREF_ASK ) 2864 if ( mode < SYNC_PREF_ASK )
2864 mode = SYNC_PREF_ASK; 2865 mode = SYNC_PREF_ASK;
2865 } else { 2866 } else {
2866 if ( localMod == remoteMod ) 2867 if ( localMod == remoteMod )
2867 return 0; 2868 return 0;
2868 2869
2869 } 2870 }
2870 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2871 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2871 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2872 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2872 //full = true; //debug only 2873 //full = true; //debug only
2873 if ( full ) { 2874 if ( full ) {
2874 bool equ = ( (*local) == (*remote) ); 2875 bool equ = ( (*local) == (*remote) );
2875 if ( equ ) { 2876 if ( equ ) {
2876 //qDebug("equal "); 2877 //qDebug("equal ");
2877 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2878 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2878 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2879 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2879 } 2880 }
2880 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2881 if ( mode < SYNC_PREF_FORCE_LOCAL )
2881 return 0; 2882 return 0;
2882 2883
2883 }//else //debug only 2884 }//else //debug only
2884 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2885 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2885 } 2886 }
2886 int result; 2887 int result;
2887 bool localIsNew; 2888 bool localIsNew;
2888 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2889 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2889 2890
2890 if ( full && mode < SYNC_PREF_NEWEST ) 2891 if ( full && mode < SYNC_PREF_NEWEST )
2891 mode = SYNC_PREF_ASK; 2892 mode = SYNC_PREF_ASK;
2892 2893
2893 switch( mode ) { 2894 switch( mode ) {
2894 case SYNC_PREF_LOCAL: 2895 case SYNC_PREF_LOCAL:
2895 if ( lastSync > remoteMod ) 2896 if ( lastSync > remoteMod )
2896 return 1; 2897 return 1;
2897 if ( lastSync > localMod ) 2898 if ( lastSync > localMod )
2898 return 2; 2899 return 2;
2899 return 1; 2900 return 1;
2900 break; 2901 break;
2901 case SYNC_PREF_REMOTE: 2902 case SYNC_PREF_REMOTE:
2902 if ( lastSync > localMod ) 2903 if ( lastSync > localMod )
2903 return 2; 2904 return 2;
2904 if ( lastSync > remoteMod ) 2905 if ( lastSync > remoteMod )
2905 return 1; 2906 return 1;
2906 return 2; 2907 return 2;
2907 break; 2908 break;
2908 case SYNC_PREF_NEWEST: 2909 case SYNC_PREF_NEWEST:
2909 if ( localMod > remoteMod ) 2910 if ( localMod > remoteMod )
2910 return 1; 2911 return 1;
2911 else 2912 else
2912 return 2; 2913 return 2;
2913 break; 2914 break;
2914 case SYNC_PREF_ASK: 2915 case SYNC_PREF_ASK:
2915 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2916 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2916 if ( lastSync > remoteMod && lastSync > localMod) 2917 if ( lastSync > remoteMod && lastSync > localMod)
2917 return 0; 2918 return 0;
2918 if ( lastSync > remoteMod ) 2919 if ( lastSync > remoteMod )
2919 return 1; 2920 return 1;
2920 if ( lastSync > localMod ) { 2921 if ( lastSync > localMod ) {
2921 return 2; 2922 return 2;
2922 } 2923 }
2923 localIsNew = localMod >= remoteMod; 2924 localIsNew = localMod >= remoteMod;
2924 //qDebug("conflict! ************************************** "); 2925 //qDebug("conflict! ************************************** ");
2925 { 2926 {
2926 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2927 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2927 result = acd.executeD(localIsNew); 2928 result = acd.executeD(localIsNew);
2928 return result; 2929 return result;
2929 } 2930 }
2930 break; 2931 break;
2931 case SYNC_PREF_FORCE_LOCAL: 2932 case SYNC_PREF_FORCE_LOCAL:
2932 return 1; 2933 return 1;
2933 break; 2934 break;
2934 case SYNC_PREF_FORCE_REMOTE: 2935 case SYNC_PREF_FORCE_REMOTE:
2935 return 2; 2936 return 2;
2936 break; 2937 break;
2937 2938
2938 default: 2939 default:
2939 // SYNC_PREF_TAKE_BOTH not implemented 2940 // SYNC_PREF_TAKE_BOTH not implemented
2940 break; 2941 break;
2941 } 2942 }
2942 return 0; 2943 return 0;
2943} 2944}
2944 2945
2945 2946
2946bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2947bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2947{ 2948{
2948 bool syncOK = true; 2949 bool syncOK = true;
2949 int addedAddressee = 0; 2950 int addedAddressee = 0;
2950 int addedAddresseeR = 0; 2951 int addedAddresseeR = 0;
2951 int deletedAddresseeR = 0; 2952 int deletedAddresseeR = 0;
2952 int deletedAddresseeL = 0; 2953 int deletedAddresseeL = 0;
2953 int changedLocal = 0; 2954 int changedLocal = 0;
2954 int changedRemote = 0; 2955 int changedRemote = 0;
2955 int filteredIN = 0; 2956 int filteredIN = 0;
2956 int filteredOUT = 0; 2957 int filteredOUT = 0;
2957 2958
2958 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2959 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2959 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2960 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2960 2961
2961 //QPtrList<Addressee> el = local->rawAddressees(); 2962 //QPtrList<Addressee> el = local->rawAddressees();
2962 Addressee addresseeR; 2963 Addressee addresseeR;
2963 QString uid; 2964 QString uid;
2964 int take; 2965 int take;
2965 Addressee addresseeL; 2966 Addressee addresseeL;
2966 Addressee addresseeRSync; 2967 Addressee addresseeRSync;
2967 Addressee addresseeLSync; 2968 Addressee addresseeLSync;
2968 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2969 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2969 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2970 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2970 bool fullDateRange = false; 2971 bool fullDateRange = false;
2971 local->resetTempSyncStat(); 2972 local->resetTempSyncStat();
2972 mLastAddressbookSync = QDateTime::currentDateTime(); 2973 mLastAddressbookSync = QDateTime::currentDateTime();
2973 if ( syncManager->syncWithDesktop() ) { 2974 if ( syncManager->syncWithDesktop() ) {
2974 // remote->removeSyncInfo( QString());//remove all info 2975 // remote->removeSyncInfo( QString());//remove all info
2975 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2976 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2976 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2977 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2977 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2978 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2978 } else { 2979 } else {
2979 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); 2980 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
2980 } 2981 }
2981 } 2982 }
2982 QDateTime modifiedCalendar = mLastAddressbookSync; 2983 QDateTime modifiedCalendar = mLastAddressbookSync;
2983 addresseeLSync = getLastSyncAddressee(); 2984 addresseeLSync = getLastSyncAddressee();
2984 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2985 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
2985 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2986 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2986 if ( !addresseeR.isEmpty() ) { 2987 if ( !addresseeR.isEmpty() ) {
2987 addresseeRSync = addresseeR; 2988 addresseeRSync = addresseeR;
2988 remote->removeAddressee(addresseeR ); 2989 remote->removeAddressee(addresseeR );
2989 2990
2990 } else { 2991 } else {
2991 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2992 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2992 addresseeRSync = addresseeLSync ; 2993 addresseeRSync = addresseeLSync ;
2993 } else { 2994 } else {
2994 //qDebug("FULLDATE 1"); 2995 //qDebug("FULLDATE 1");
2995 fullDateRange = true; 2996 fullDateRange = true;
2996 Addressee newAdd; 2997 Addressee newAdd;
2997 addresseeRSync = newAdd; 2998 addresseeRSync = newAdd;
2998 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2999 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2999 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 3000 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
3000 addresseeRSync.setRevision( mLastAddressbookSync ); 3001 addresseeRSync.setRevision( mLastAddressbookSync );
3001 addresseeRSync.setCategories( i18n("SyncAddressee") ); 3002 addresseeRSync.setCategories( i18n("SyncAddressee") );
3002 } 3003 }
3003 } 3004 }
3004 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 3005 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
3005 // qDebug("FULLDATE 2"); 3006 // qDebug("FULLDATE 2");
3006 fullDateRange = true; 3007 fullDateRange = true;
3007 } 3008 }
3008 if ( ! fullDateRange ) { 3009 if ( ! fullDateRange ) {
3009 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 3010 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
3010 3011
3011 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 3012 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
3012 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 3013 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
3013 fullDateRange = true; 3014 fullDateRange = true;
3014 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 3015 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
3015 } 3016 }
3016 } 3017 }
3017 // fullDateRange = true; // debug only! 3018 // fullDateRange = true; // debug only!
3018 if ( fullDateRange ) 3019 if ( fullDateRange )
3019 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 3020 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
3020 else 3021 else
3021 mLastAddressbookSync = addresseeLSync.revision(); 3022 mLastAddressbookSync = addresseeLSync.revision();
3022 // for resyncing if own file has changed 3023 // for resyncing if own file has changed
3023 // PENDING fixme later when implemented 3024 // PENDING fixme later when implemented
3024#if 0 3025#if 0
3025 if ( mCurrentSyncDevice == "deleteaftersync" ) { 3026 if ( mCurrentSyncDevice == "deleteaftersync" ) {
3026 mLastAddressbookSync = loadedFileVersion; 3027 mLastAddressbookSync = loadedFileVersion;
3027 qDebug("setting mLastAddressbookSync "); 3028 qDebug("setting mLastAddressbookSync ");
3028 } 3029 }
3029#endif 3030#endif
3030 3031
3031 3032
3032 // ********** setting filters **************** 3033 // ********** setting filters ****************
3033 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 3034 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
3034 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 3035 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
3035 3036
3036 //qDebug("*************************** "); 3037 //qDebug("*************************** ");
3037 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 3038 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
3038 QStringList er = remote->uidList(); 3039 QStringList er = remote->uidList();
3039 Addressee inR ;//= er.first(); 3040 Addressee inR ;//= er.first();
3040 Addressee inL; 3041 Addressee inL;
3041 3042
3042 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3043 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3043 3044
3044 int modulo = (er.count()/10)+1; 3045 int modulo = (er.count()/10)+1;
3045 int incCounter = 0; 3046 int incCounter = 0;
3046 while ( incCounter < er.count()) { 3047 while ( incCounter < er.count()) {
3047 if (syncManager->isProgressBarCanceled()) 3048 if (syncManager->isProgressBarCanceled())
3048 return false; 3049 return false;
3049 if ( incCounter % modulo == 0 ) 3050 if ( incCounter % modulo == 0 )
3050 syncManager->showProgressBar(incCounter); 3051 syncManager->showProgressBar(incCounter);
3051 3052
3052 uid = er[ incCounter ]; 3053 uid = er[ incCounter ];
3053 bool skipIncidence = false; 3054 bool skipIncidence = false;
3054 if ( uid.left(19) == QString("last-syncAddressee-") ) 3055 if ( uid.left(19) == QString("last-syncAddressee-") )
3055 skipIncidence = true; 3056 skipIncidence = true;
3056 QString idS,OidS; 3057 QString idS,OidS;
3057 qApp->processEvents(); 3058 qApp->processEvents();
3058 if ( !skipIncidence ) { 3059 if ( !skipIncidence ) {
3059 inL = local->findByUid( uid ); 3060 inL = local->findByUid( uid );
3060 inR = remote->findByUid( uid ); 3061 inR = remote->findByUid( uid );
3061 //inL.setResource( 0 ); 3062 //inL.setResource( 0 );
3062 //inR.setResource( 0 ); 3063 //inR.setResource( 0 );
3063 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 3064 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
3064 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3065 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3065 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3066 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3066 //qDebug("take %d %s ", take, inL.summary().latin1()); 3067 //qDebug("take %d %s ", take, inL.summary().latin1());
3067 if ( take == 3 ) 3068 if ( take == 3 )
3068 return false; 3069 return false;
3069 if ( take == 1 ) {// take local ********************** 3070 if ( take == 1 ) {// take local **********************
3070 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3071 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3071 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3072 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3072 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3073 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3073 local->insertAddressee( inL, false ); 3074 local->insertAddressee( inL, false );
3074 idS = inR.externalUID(); 3075 idS = inR.externalUID();
3075 OidS = inR.originalExternalUID(); 3076 OidS = inR.originalExternalUID();
3076 } 3077 }
3077 else 3078 else
3078 idS = inR.IDStr(); 3079 idS = inR.IDStr();
3079 remote->removeAddressee( inR ); 3080 remote->removeAddressee( inR );
3080 inR = inL; 3081 inR = inL;
3081 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3082 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3082 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3083 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3083 inR.setOriginalExternalUID( OidS ); 3084 inR.setOriginalExternalUID( OidS );
3084 inR.setExternalUID( idS ); 3085 inR.setExternalUID( idS );
3085 if ( syncManager->syncWithDesktop() ) { 3086 if ( syncManager->syncWithDesktop() ) {
3086 inR.setIDStr("changed" ); 3087 inR.setIDStr("changed" );
3087 } 3088 }
3088 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3089 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3089 } else { 3090 } else {
3090 inR.setIDStr( idS ); 3091 inR.setIDStr( idS );
3091 } 3092 }
3092 inR.setResource( 0 ); 3093 inR.setResource( 0 );
3093 remote->insertAddressee( inR , false); 3094 remote->insertAddressee( inR , false);
3094 ++changedRemote; 3095 ++changedRemote;
3095 } else { // take == 2 take remote ********************** 3096 } else { // take == 2 take remote **********************
3096 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3097 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3097 if ( inR.revision().date().year() < 2004 ) 3098 if ( inR.revision().date().year() < 2004 )
3098 inR.setRevision( modifiedCalendar ); 3099 inR.setRevision( modifiedCalendar );
3099 } 3100 }
3100 idS = inL.IDStr(); 3101 idS = inL.IDStr();
3101 local->removeAddressee( inL ); 3102 local->removeAddressee( inL );
3102 inL = inR; 3103 inL = inR;
3103 inL.setIDStr( idS ); 3104 inL.setIDStr( idS );
3104 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3105 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3105 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3106 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3106 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3107 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3107 } 3108 }
3108 inL.setResource( 0 ); 3109 inL.setResource( 0 );
3109 local->insertAddressee( inL , false ); 3110 local->insertAddressee( inL , false );
3110 ++changedLocal; 3111 ++changedLocal;
3111 } 3112 }
3112 } 3113 }
3113 } 3114 }
3114 } else { // no conflict ********** add or delete remote 3115 } else { // no conflict ********** add or delete remote
3115 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3116 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3116 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3117 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3117 QString des = addresseeLSync.note(); 3118 QString des = addresseeLSync.note();
3118 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3119 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3119 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3120 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3120 remote->insertAddressee( inR, false ); 3121 remote->insertAddressee( inR, false );
3121 ++deletedAddresseeR; 3122 ++deletedAddresseeR;
3122 } else { 3123 } else {
3123 inR.setRevision( modifiedCalendar ); 3124 inR.setRevision( modifiedCalendar );
3124 remote->insertAddressee( inR, false ); 3125 remote->insertAddressee( inR, false );
3125 inL = inR; 3126 inL = inR;
3126 inL.setIDStr( ":" ); 3127 inL.setIDStr( ":" );
3127 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3128 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3128 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3129 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3129 inL.setResource( 0 ); 3130 inL.setResource( 0 );
3130 local->insertAddressee( inL , false); 3131 local->insertAddressee( inL , false);
3131 ++addedAddressee; 3132 ++addedAddressee;
3132 } 3133 }
3133 } else { 3134 } else {
3134 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3135 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3135 inR.setRevision( modifiedCalendar ); 3136 inR.setRevision( modifiedCalendar );
3136 remote->insertAddressee( inR, false ); 3137 remote->insertAddressee( inR, false );
3137 inR.setResource( 0 ); 3138 inR.setResource( 0 );
3138 local->insertAddressee( inR, false ); 3139 local->insertAddressee( inR, false );
3139 ++addedAddressee; 3140 ++addedAddressee;
3140 } else { 3141 } else {
3141 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3142 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3142 remote->removeAddressee( inR ); 3143 remote->removeAddressee( inR );
3143 ++deletedAddresseeR; 3144 ++deletedAddresseeR;
3144 } 3145 }
3145 } 3146 }
3146 } else { 3147 } else {
3147 ++filteredIN; 3148 ++filteredIN;
3148 } 3149 }
3149 } 3150 }
3150 } 3151 }
3151 ++incCounter; 3152 ++incCounter;
3152 } 3153 }
3153 er.clear(); 3154 er.clear();
3154 QStringList el = local->uidList(); 3155 QStringList el = local->uidList();
3155 modulo = (el.count()/10)+1; 3156 modulo = (el.count()/10)+1;
3156 3157
3157 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3158 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3158 incCounter = 0; 3159 incCounter = 0;
3159 while ( incCounter < el.count()) { 3160 while ( incCounter < el.count()) {
3160 qApp->processEvents(); 3161 qApp->processEvents();
3161 if (syncManager->isProgressBarCanceled()) 3162 if (syncManager->isProgressBarCanceled())
3162 return false; 3163 return false;
3163 if ( incCounter % modulo == 0 ) 3164 if ( incCounter % modulo == 0 )
3164 syncManager->showProgressBar(incCounter); 3165 syncManager->showProgressBar(incCounter);
3165 uid = el[ incCounter ]; 3166 uid = el[ incCounter ];
3166 bool skipIncidence = false; 3167 bool skipIncidence = false;
3167 if ( uid.left(19) == QString("last-syncAddressee-") ) 3168 if ( uid.left(19) == QString("last-syncAddressee-") )
3168 skipIncidence = true; 3169 skipIncidence = true;
3169 if ( !skipIncidence ) { 3170 if ( !skipIncidence ) {
3170 inL = local->findByUid( uid ); 3171 inL = local->findByUid( uid );
3171 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3172 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3172 inR = remote->findByUid( uid ); 3173 inR = remote->findByUid( uid );
3173 if ( inR.isEmpty() ){ 3174 if ( inR.isEmpty() ){
3174 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3175 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3175 // no conflict ********** add or delete local 3176 // no conflict ********** add or delete local
3176 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3177 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3177 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3178 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3178 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3179 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3179 local->removeAddressee( inL ); 3180 local->removeAddressee( inL );
3180 ++deletedAddresseeL; 3181 ++deletedAddresseeL;
3181 } else { 3182 } else {
3182 if ( ! syncManager->mWriteBackExistingOnly ) { 3183 if ( ! syncManager->mWriteBackExistingOnly ) {
3183 inL.removeID(mCurrentSyncDevice ); 3184 inL.removeID(mCurrentSyncDevice );
3184 ++addedAddresseeR; 3185 ++addedAddresseeR;
3185 inL.setRevision( modifiedCalendar ); 3186 inL.setRevision( modifiedCalendar );
3186 local->insertAddressee( inL, false ); 3187 local->insertAddressee( inL, false );
3187 inR = inL; 3188 inR = inL;
3188 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3189 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3189 inR.setResource( 0 ); 3190 inR.setResource( 0 );
3190 remote->insertAddressee( inR, false ); 3191 remote->insertAddressee( inR, false );
3191 } 3192 }
3192 } 3193 }
3193 } else { 3194 } else {
3194 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3195 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3195 //qDebug("data %s ", inL.revision().toString().latin1()); 3196 //qDebug("data %s ", inL.revision().toString().latin1());
3196 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3197 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3197 local->removeAddressee( inL ); 3198 local->removeAddressee( inL );
3198 ++deletedAddresseeL; 3199 ++deletedAddresseeL;
3199 } else { 3200 } else {
3200 if ( ! syncManager->mWriteBackExistingOnly ) { 3201 if ( ! syncManager->mWriteBackExistingOnly ) {
3201 ++addedAddresseeR; 3202 ++addedAddresseeR;
3202 inL.setRevision( modifiedCalendar ); 3203 inL.setRevision( modifiedCalendar );
3203 local->insertAddressee( inL, false ); 3204 local->insertAddressee( inL, false );
3204 inR = inL; 3205 inR = inL;
3205 inR.setIDStr( ":" ); 3206 inR.setIDStr( ":" );
3206 inR.setResource( 0 ); 3207 inR.setResource( 0 );
3207 remote->insertAddressee( inR, false ); 3208 remote->insertAddressee( inR, false );
3208 } 3209 }
3209 } 3210 }
3210 } 3211 }
3211 } else { 3212 } else {
3212 ++filteredOUT; 3213 ++filteredOUT;
3213 } 3214 }
3214 } 3215 }
3215 } 3216 }
3216 } 3217 }
3217 ++incCounter; 3218 ++incCounter;
3218 } 3219 }
3219 el.clear(); 3220 el.clear();
3220 syncManager->hideProgressBar(); 3221 syncManager->hideProgressBar();
3221 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3222 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3222 // get rid of micro seconds 3223 // get rid of micro seconds
3223 QTime t = mLastAddressbookSync.time(); 3224 QTime t = mLastAddressbookSync.time();
3224 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3225 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3225 addresseeLSync.setRevision( mLastAddressbookSync ); 3226 addresseeLSync.setRevision( mLastAddressbookSync );
3226 addresseeRSync.setRevision( mLastAddressbookSync ); 3227 addresseeRSync.setRevision( mLastAddressbookSync );
3227 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3228 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3228 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3229 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3229 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3230 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3230 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3231 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3231 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3232 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3232 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3233 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3233 addresseeRSync.setNote( "" ) ; 3234 addresseeRSync.setNote( "" ) ;
3234 addresseeLSync.setNote( "" ); 3235 addresseeLSync.setNote( "" );
3235 3236
3236 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3237 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3237 remote->insertAddressee( addresseeRSync, false ); 3238 remote->insertAddressee( addresseeRSync, false );
3238 local->insertAddressee( addresseeLSync, false ); 3239 local->insertAddressee( addresseeLSync, false );
3239 QString mes; 3240 QString mes;
3240 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3241 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3241 qDebug( mes ); 3242 qDebug( mes );
3242 mes = i18n("Local addressbook changed!\n") +mes; 3243 mes = i18n("Local addressbook changed!\n") +mes;
3243 if ( syncManager->mShowSyncSummary ) { 3244 if ( syncManager->mShowSyncSummary ) {
3244 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3245 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3245 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3246 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3246 qDebug("KA: WB cancelled "); 3247 qDebug("KA: WB cancelled ");
3247 syncManager->mWriteBackFile = false; 3248 syncManager->mWriteBackFile = false;
3248 return syncOK; 3249 return syncOK;
3249 } 3250 }
3250 } 3251 }
3251 return syncOK; 3252 return syncOK;
3252} 3253}
3253 3254
3254 3255
3255//this is a overwritten callbackmethods from the syncinterface 3256//this is a overwritten callbackmethods from the syncinterface
3256bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3257bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3257{ 3258{
3258 3259
3259 //pending prepare addresseeview for output 3260 //pending prepare addresseeview for output
3260 //pending detect, if remote file has REV field. if not switch to external sync 3261 //pending detect, if remote file has REV field. if not switch to external sync
3261 mGlobalSyncMode = SYNC_MODE_NORMAL; 3262 mGlobalSyncMode = SYNC_MODE_NORMAL;
3262 if ( manager != syncManager ) 3263 if ( manager != syncManager )
3263 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3264 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3264 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3265 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3265 3266
3266 AddressBook abLocal(filename,"syncContact"); 3267 AddressBook abLocal(filename,"syncContact");
3267 bool syncOK = false; 3268 bool syncOK = false;
3268 if ( abLocal.load() ) { 3269 if ( abLocal.load() ) {
3269 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3270 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3270 bool external = false; 3271 bool external = false;
3271 bool isXML = false; 3272 bool isXML = false;
3272 if ( filename.right(4) == ".xml") { 3273 if ( filename.right(4) == ".xml") {
3273 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3274 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3274 isXML = true; 3275 isXML = true;
3275 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3276 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3276 } else { 3277 } else {
3277 external = !manager->mIsKapiFile; 3278 external = !manager->mIsKapiFile;
3278 if ( external ) { 3279 if ( external ) {
3279 qDebug("KA: Sync::Setting vcf mode to external "); 3280 qDebug("KA: Sync::Setting vcf mode to external ");
3280 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3281 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3281 AddressBook::Iterator it; 3282 AddressBook::Iterator it;
3282 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3283 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3283 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3284 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3284 (*it).computeCsum( mCurrentSyncDevice ); 3285 (*it).computeCsum( mCurrentSyncDevice );
3285 } 3286 }
3286 } 3287 }
3287 } 3288 }
3288 //AddressBook::Iterator it; 3289 //AddressBook::Iterator it;
3289 //QStringList vcards; 3290 //QStringList vcards;
3290 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3291 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3291 // qDebug("Name %s ", (*it).familyName().latin1()); 3292 // qDebug("Name %s ", (*it).familyName().latin1());
3292 //} 3293 //}
3293 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3294 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3294 syncManager->hideProgressBar(); 3295 syncManager->hideProgressBar();
3295 if ( syncOK ) { 3296 if ( syncOK ) {
3296 if ( syncManager->mWriteBackFile ) 3297 if ( syncManager->mWriteBackFile )
3297 { 3298 {
3298 if ( external ) 3299 if ( external )
3299 abLocal.removeSyncAddressees( !isXML); 3300 abLocal.removeSyncAddressees( !isXML);
3300 qDebug("KA: Sync::Saving remote AB "); 3301 qDebug("KA: Sync::Saving remote AB ");
3301 if ( ! abLocal.saveAB()) 3302 if ( ! abLocal.saveAB())
3302 qDebug("KA: sync::Error writing back AB to file "); 3303 qDebug("KA: sync::Error writing back AB to file ");
3303 if ( external ) { 3304 if ( external ) {
3304 // afterwrite processing 3305 // afterwrite processing
3305 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3306 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3306 } 3307 }
3307 } 3308 }
3308 } 3309 }
3309 setModified(); 3310 setModified();
3310 3311
3311 } 3312 }
3312 abLocal.removeResources(); 3313 abLocal.removeResources();
3313 if ( syncOK ) 3314 if ( syncOK )
3314 mViewManager->refreshView(); 3315 mViewManager->refreshView();
3315 return syncOK; 3316 return syncOK;
3316 3317
3317} 3318}
3318void KABCore::removeSyncInfo( QString syncProfile) 3319void KABCore::removeSyncInfo( QString syncProfile)
3319{ 3320{
3320 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3321 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3321 mAddressBook->removeSyncInfo( syncProfile ); 3322 mAddressBook->removeSyncInfo( syncProfile );
3322 setModified(); 3323 setModified();
3323} 3324}
3324 3325
3325 3326
3326//this is a overwritten callbackmethods from the syncinterface 3327//this is a overwritten callbackmethods from the syncinterface
3327bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3328bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3328{ 3329{
3329 if ( resource == "phone" ) 3330 if ( resource == "phone" )
3330 return syncPhone(); 3331 return syncPhone();
3331 disableBR( true ); 3332 disableBR( true );
3332 if ( manager != syncManager ) 3333 if ( manager != syncManager )
3333 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3334 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3334 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3335 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3335 3336
3336 AddressBook abLocal( resource,"syncContact"); 3337 AddressBook abLocal( resource,"syncContact");
3337 bool syncOK = false; 3338 bool syncOK = false;
3338 message(i18n("Loading DTM address data..."), false); 3339 message(i18n("Loading DTM address data..."), false);
3339 if ( abLocal.load() ) { 3340 if ( abLocal.load() ) {
3340 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3341 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3341 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3342 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3342 message(i18n("Sync preprocessing..."),false); 3343 message(i18n("Sync preprocessing..."),false);
3343 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3344 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3344 message(i18n("Synchronizing..."),false); 3345 message(i18n("Synchronizing..."),false);
3345 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3346 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3346 syncManager->hideProgressBar(); 3347 syncManager->hideProgressBar();
3347 if ( syncOK ) { 3348 if ( syncOK ) {
3348 if ( syncManager->mWriteBackFile ) { 3349 if ( syncManager->mWriteBackFile ) {
3349 abLocal.removeSyncAddressees( false ); 3350 abLocal.removeSyncAddressees( false );
3350 message(i18n("Saving DTM address data..."),false); 3351 message(i18n("Saving DTM address data..."),false);
3351 abLocal.saveAB(); 3352 abLocal.saveAB();
3352 message(i18n("Sync postprocessing..."),false); 3353 message(i18n("Sync postprocessing..."),false);
3353 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3354 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3354 } 3355 }
3355 } else 3356 } else
3356 message( i18n("Sync cancelled or failed.") ); 3357 message( i18n("Sync cancelled or failed.") );
3357 setModified(); 3358 setModified();
3358 } 3359 }
3359 abLocal.removeResources(); 3360 abLocal.removeResources();
3360 if ( syncOK ) { 3361 if ( syncOK ) {
3361 mViewManager->refreshView(); 3362 mViewManager->refreshView();
3362 message(i18n("DTM syncing finished.")); 3363 message(i18n("DTM syncing finished."));
3363 } 3364 }
3364 disableBR( false ); 3365 disableBR( false );
3365 return syncOK; 3366 return syncOK;
3366 3367
3367} 3368}
3368void KABCore::message( QString m, bool startTimer) 3369void KABCore::message( QString m, bool startTimer)
3369{ 3370{
3370 topLevelWidget()->setCaption( m ); 3371 topLevelWidget()->setCaption( m );
3371 qApp->processEvents(); 3372 qApp->processEvents();
3372 if ( startTimer ) 3373 if ( startTimer )
3373 mMessageTimer->start( 15000, true ); 3374 mMessageTimer->start( 15000, true );
3374 else 3375 else
3375 mMessageTimer->stop(); 3376 mMessageTimer->stop();
3376} 3377}
3377bool KABCore::syncPhone() 3378bool KABCore::syncPhone()
3378{ 3379{
3379 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3380 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3380 QString fileName = getPhoneFile(); 3381 QString fileName = getPhoneFile();
3381 if ( !PhoneAccess::readFromPhone( fileName) ) { 3382 if ( !PhoneAccess::readFromPhone( fileName) ) {
3382 message(i18n("Phone access failed!")); 3383 message(i18n("Phone access failed!"));
3383 return false; 3384 return false;
3384 } 3385 }
3385 AddressBook abLocal( fileName,"syncContact"); 3386 AddressBook abLocal( fileName,"syncContact");
3386 bool syncOK = false; 3387 bool syncOK = false;
3387 { 3388 {
3388 abLocal.importFromFile( fileName ); 3389 abLocal.importFromFile( fileName );
3389 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3390 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3390 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3391 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3391 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3392 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3392 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3393 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3393 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3394 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3394 syncManager->hideProgressBar(); 3395 syncManager->hideProgressBar();
3395 if ( syncOK ) { 3396 if ( syncOK ) {
3396 if ( syncManager->mWriteBackFile ) { 3397 if ( syncManager->mWriteBackFile ) {
3397 abLocal.removeSyncAddressees( true ); 3398 abLocal.removeSyncAddressees( true );
3398 abLocal.saveABphone( fileName ); 3399 abLocal.saveABphone( fileName );
3399 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3400 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3400 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3401 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3401 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3402 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3402 } 3403 }
3403 } 3404 }
3404 setModified(); 3405 setModified();
3405 } 3406 }
3406 abLocal.removeResources(); 3407 abLocal.removeResources();
3407 if ( syncOK ) 3408 if ( syncOK )
3408 mViewManager->refreshView(); 3409 mViewManager->refreshView();
3409 return syncOK; 3410 return syncOK;
3410} 3411}
3411void KABCore::getFile( bool success ) 3412void KABCore::getFile( bool success )
3412{ 3413{
3413 if ( ! success ) { 3414 if ( ! success ) {
3414 message( i18n("Error receiving file. Nothing changed!") ); 3415 message( i18n("Error receiving file. Nothing changed!") );
3415 return; 3416 return;
3416 } 3417 }
3417 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3418 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3418 if ( count ) 3419 if ( count )
3419 setModified( true ); 3420 setModified( true );
3420 message( i18n("Pi-Sync successful!") ); 3421 message( i18n("Pi-Sync successful!") );
3421 mViewManager->refreshView(); 3422 mViewManager->refreshView();
3422} 3423}
3423void KABCore::syncFileRequest() 3424void KABCore::syncFileRequest()
3424{ 3425{
3425 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3426 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3426 syncManager->slotSyncMenu( 999 ); 3427 syncManager->slotSyncMenu( 999 );
3427 } 3428 }
3428 mAddressBook->export2File( sentSyncFile() ); 3429 mAddressBook->export2File( sentSyncFile() );
3429} 3430}
3430QString KABCore::sentSyncFile() 3431QString KABCore::sentSyncFile()
3431{ 3432{
3432#ifdef DESKTOP_VERSION 3433#ifdef DESKTOP_VERSION
3433 return locateLocal( "tmp", "copysyncab.vcf" ); 3434 return locateLocal( "tmp", "copysyncab.vcf" );
3434#else 3435#else
3435 return QString( "/tmp/copysyncab.vcf" ); 3436 return QString( "/tmp/copysyncab.vcf" );
3436#endif 3437#endif
3437} 3438}
3438 3439
3439void KABCore::setCaptionBack() 3440void KABCore::setCaptionBack()
3440{ 3441{
3441 mMessageTimer->stop(); 3442 mMessageTimer->stop();
3442 topLevelWidget()->setCaption( i18n("KA/Pi") ); 3443 topLevelWidget()->setCaption( i18n("KA/Pi") );
3443} 3444}