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