-rw-r--r-- | kaddressbook/kabcore.cpp | 460 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 24 | ||||
-rw-r--r-- | kaddressbook/kabprefs.h | 18 |
3 files changed, 496 insertions, 6 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 32dd43a..49c3b19 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -3,64 +3,65 @@ | |||
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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (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 | 36 | ||
36 | #ifndef KAB_EMBEDDED | 37 | #ifndef KAB_EMBEDDED |
37 | #include <qclipboard.h> | 38 | #include <qclipboard.h> |
38 | #include <qdir.h> | 39 | #include <qdir.h> |
39 | #include <qfile.h> | 40 | #include <qfile.h> |
40 | #include <qapplicaton.h> | 41 | #include <qapplicaton.h> |
41 | #include <qlayout.h> | 42 | #include <qlayout.h> |
42 | #include <qregexp.h> | 43 | #include <qregexp.h> |
43 | #include <qvbox.h> | 44 | #include <qvbox.h> |
44 | #include <kabc/addresseelist.h> | 45 | #include <kabc/addresseelist.h> |
45 | #include <kabc/errorhandler.h> | 46 | #include <kabc/errorhandler.h> |
46 | #include <kabc/resource.h> | 47 | #include <kabc/resource.h> |
47 | #include <kabc/vcardconverter.h> | 48 | #include <kabc/vcardconverter.h> |
48 | #include <kapplication.h> | 49 | #include <kapplication.h> |
49 | #include <kactionclasses.h> | 50 | #include <kactionclasses.h> |
50 | #include <kcmultidialog.h> | 51 | #include <kcmultidialog.h> |
51 | #include <kdebug.h> | 52 | #include <kdebug.h> |
52 | #include <kdeversion.h> | 53 | #include <kdeversion.h> |
53 | #include <kkeydialog.h> | 54 | #include <kkeydialog.h> |
54 | #include <kmessagebox.h> | 55 | #include <kmessagebox.h> |
55 | #include <kprinter.h> | 56 | #include <kprinter.h> |
56 | #include <kprotocolinfo.h> | 57 | #include <kprotocolinfo.h> |
57 | #include <kresources/selectdialog.h> | 58 | #include <kresources/selectdialog.h> |
58 | #include <kstandarddirs.h> | 59 | #include <kstandarddirs.h> |
59 | #include <ktempfile.h> | 60 | #include <ktempfile.h> |
60 | #include <kxmlguiclient.h> | 61 | #include <kxmlguiclient.h> |
61 | #include <kaboutdata.h> | 62 | #include <kaboutdata.h> |
62 | #include <libkdepim/categoryselectdialog.h> | 63 | #include <libkdepim/categoryselectdialog.h> |
63 | 64 | ||
64 | #include "addresseeutil.h" | 65 | #include "addresseeutil.h" |
65 | #include "addresseeeditordialog.h" | 66 | #include "addresseeeditordialog.h" |
66 | #include "extensionmanager.h" | 67 | #include "extensionmanager.h" |
@@ -113,81 +114,87 @@ $Id$ | |||
113 | #include <picture.h> | 114 | #include <picture.h> |
114 | #include <resource.h> | 115 | #include <resource.h> |
115 | 116 | ||
116 | //US#include <qsplitter.h> | 117 | //US#include <qsplitter.h> |
117 | #include <qmap.h> | 118 | #include <qmap.h> |
118 | #include <qdir.h> | 119 | #include <qdir.h> |
119 | #include <qfile.h> | 120 | #include <qfile.h> |
120 | #include <qvbox.h> | 121 | #include <qvbox.h> |
121 | #include <qlayout.h> | 122 | #include <qlayout.h> |
122 | #include <qclipboard.h> | 123 | #include <qclipboard.h> |
123 | #include <qtextstream.h> | 124 | #include <qtextstream.h> |
124 | 125 | ||
125 | #include <libkdepim/categoryselectdialog.h> | 126 | #include <libkdepim/categoryselectdialog.h> |
126 | #include <kabc/vcardconverter.h> | 127 | #include <kabc/vcardconverter.h> |
127 | 128 | ||
128 | 129 | ||
129 | #include "addresseeutil.h" | 130 | #include "addresseeutil.h" |
130 | #include "undocmds.h" | 131 | #include "undocmds.h" |
131 | #include "addresseeeditordialog.h" | 132 | #include "addresseeeditordialog.h" |
132 | #include "viewmanager.h" | 133 | #include "viewmanager.h" |
133 | #include "details/detailsviewcontainer.h" | 134 | #include "details/detailsviewcontainer.h" |
134 | #include "kabprefs.h" | 135 | #include "kabprefs.h" |
135 | #include "xxportmanager.h" | 136 | #include "xxportmanager.h" |
136 | #include "incsearchwidget.h" | 137 | #include "incsearchwidget.h" |
137 | #include "jumpbuttonbar.h" | 138 | #include "jumpbuttonbar.h" |
138 | #include "extensionmanager.h" | 139 | #include "extensionmanager.h" |
139 | #include "addresseeconfig.h" | 140 | #include "addresseeconfig.h" |
140 | #include <kcmultidialog.h> | 141 | #include <kcmultidialog.h> |
141 | 142 | ||
142 | #ifdef _WIN32_ | 143 | #ifdef _WIN32_ |
143 | 144 | ||
144 | #include "kaimportoldialog.h" | 145 | #include "kaimportoldialog.h" |
146 | #else | ||
147 | #include <unistd.h> | ||
145 | #endif | 148 | #endif |
149 | // sync includes | ||
150 | #include <libkdepim/ksyncprofile.h> | ||
151 | |||
146 | 152 | ||
147 | bool pasteWithNewUid = true; | 153 | bool pasteWithNewUid = true; |
148 | 154 | ||
149 | #ifdef KAB_EMBEDDED | 155 | #ifdef KAB_EMBEDDED |
150 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 156 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
151 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 157 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
152 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 158 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
153 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 159 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
154 | #else //KAB_EMBEDDED | 160 | #else //KAB_EMBEDDED |
155 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 161 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
156 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 162 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
157 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 163 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
158 | mReadWrite( readWrite ), mModified( false ) | 164 | mReadWrite( readWrite ), mModified( false ) |
159 | #endif //KAB_EMBEDDED | 165 | #endif //KAB_EMBEDDED |
160 | { | 166 | { |
161 | 167 | ||
168 | mBlockSaveFlag = false; | ||
162 | mExtensionBarSplitter = 0; | 169 | mExtensionBarSplitter = 0; |
163 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 170 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
164 | 171 | ||
165 | mAddressBook = KABC::StdAddressBook::self(); | 172 | mAddressBook = KABC::StdAddressBook::self(); |
166 | KABC::StdAddressBook::setAutomaticSave( false ); | 173 | KABC::StdAddressBook::setAutomaticSave( false ); |
167 | 174 | ||
168 | #ifndef KAB_EMBEDDED | 175 | #ifndef KAB_EMBEDDED |
169 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 176 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
170 | #endif //KAB_EMBEDDED | 177 | #endif //KAB_EMBEDDED |
171 | 178 | ||
172 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 179 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
173 | SLOT( addressBookChanged() ) ); | 180 | SLOT( addressBookChanged() ) ); |
174 | 181 | ||
175 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 182 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
176 | "X-Department", "KADDRESSBOOK" ); | 183 | "X-Department", "KADDRESSBOOK" ); |
177 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 184 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
178 | "X-Profession", "KADDRESSBOOK" ); | 185 | "X-Profession", "KADDRESSBOOK" ); |
179 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 186 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
180 | "X-AssistantsName", "KADDRESSBOOK" ); | 187 | "X-AssistantsName", "KADDRESSBOOK" ); |
181 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 188 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
182 | "X-ManagersName", "KADDRESSBOOK" ); | 189 | "X-ManagersName", "KADDRESSBOOK" ); |
183 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 190 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
184 | "X-SpousesName", "KADDRESSBOOK" ); | 191 | "X-SpousesName", "KADDRESSBOOK" ); |
185 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 192 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
186 | "X-Office", "KADDRESSBOOK" ); | 193 | "X-Office", "KADDRESSBOOK" ); |
187 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 194 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
188 | "X-IMAddress", "KADDRESSBOOK" ); | 195 | "X-IMAddress", "KADDRESSBOOK" ); |
189 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 196 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
190 | "X-Anniversary", "KADDRESSBOOK" ); | 197 | "X-Anniversary", "KADDRESSBOOK" ); |
191 | 198 | ||
192 | //US added this field to become compatible with Opie/qtopia addressbook | 199 | //US added this field to become compatible with Opie/qtopia addressbook |
193 | // values can be "female" or "male" or "". An empty field represents undefined. | 200 | // values can be "female" or "male" or "". An empty field represents undefined. |
@@ -1032,84 +1039,88 @@ void KABCore::editContact( const QString &uid ) | |||
1032 | QStringList uidList = mViewManager->selectedUids(); | 1039 | QStringList uidList = mViewManager->selectedUids(); |
1033 | if ( uidList.count() > 0 ) | 1040 | if ( uidList.count() > 0 ) |
1034 | localUID = *( uidList.at( 0 ) ); | 1041 | localUID = *( uidList.at( 0 ) ); |
1035 | } | 1042 | } |
1036 | 1043 | ||
1037 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1044 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1038 | if ( !addr.isEmpty() ) { | 1045 | if ( !addr.isEmpty() ) { |
1039 | mEditorDialog->setAddressee( addr ); | 1046 | mEditorDialog->setAddressee( addr ); |
1040 | KApplication::execDialog ( mEditorDialog ); | 1047 | KApplication::execDialog ( mEditorDialog ); |
1041 | } | 1048 | } |
1042 | } | 1049 | } |
1043 | 1050 | ||
1044 | /** | 1051 | /** |
1045 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1052 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1046 | the method will try to find a selected addressee in the view. | 1053 | the method will try to find a selected addressee in the view. |
1047 | */ | 1054 | */ |
1048 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1055 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1049 | { | 1056 | { |
1050 | if ( mMultipleViewsAtOnce ) | 1057 | if ( mMultipleViewsAtOnce ) |
1051 | { | 1058 | { |
1052 | editContact( uid ); | 1059 | editContact( uid ); |
1053 | } | 1060 | } |
1054 | else | 1061 | else |
1055 | { | 1062 | { |
1056 | setDetailsVisible( true ); | 1063 | setDetailsVisible( true ); |
1057 | mActionDetails->setChecked(true); | 1064 | mActionDetails->setChecked(true); |
1058 | } | 1065 | } |
1059 | 1066 | ||
1060 | } | 1067 | } |
1061 | 1068 | ||
1062 | void KABCore::save() | 1069 | void KABCore::save() |
1063 | { | 1070 | { |
1071 | if (mBlockSaveFlag) | ||
1072 | return; | ||
1073 | mBlockSaveFlag = true; | ||
1064 | if ( !mModified ) | 1074 | if ( !mModified ) |
1065 | return; | 1075 | return; |
1066 | QString text = i18n( "There was an error while attempting to save\n the " | 1076 | QString text = i18n( "There was an error while attempting to save\n the " |
1067 | "address book. Please check that some \nother application is " | 1077 | "address book. Please check that some \nother application is " |
1068 | "not using it. " ); | 1078 | "not using it. " ); |
1069 | statusMessage(i18n("Saving addressbook ... ")); | 1079 | statusMessage(i18n("Saving addressbook ... ")); |
1070 | #ifndef KAB_EMBEDDED | 1080 | #ifndef KAB_EMBEDDED |
1071 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1081 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1072 | if ( !b || !b->save() ) { | 1082 | if ( !b || !b->save() ) { |
1073 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1083 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1074 | } | 1084 | } |
1075 | #else //KAB_EMBEDDED | 1085 | #else //KAB_EMBEDDED |
1076 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1086 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1077 | if ( !b || !b->save() ) { | 1087 | if ( !b || !b->save() ) { |
1078 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1088 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1079 | } | 1089 | } |
1080 | #endif //KAB_EMBEDDED | 1090 | #endif //KAB_EMBEDDED |
1081 | 1091 | ||
1082 | statusMessage(i18n("Addressbook saved!")); | 1092 | statusMessage(i18n("Addressbook saved!")); |
1083 | setModified( false ); | 1093 | setModified( false ); |
1094 | mBlockSaveFlag = false; | ||
1084 | } | 1095 | } |
1085 | 1096 | ||
1086 | void KABCore::statusMessage(QString mess , int time ) | 1097 | void KABCore::statusMessage(QString mess , int time ) |
1087 | { | 1098 | { |
1088 | //topLevelWidget()->setCaption( mess ); | 1099 | //topLevelWidget()->setCaption( mess ); |
1089 | // pending setting timer to revome message | 1100 | // pending setting timer to revome message |
1090 | } | 1101 | } |
1091 | void KABCore::undo() | 1102 | void KABCore::undo() |
1092 | { | 1103 | { |
1093 | UndoStack::instance()->undo(); | 1104 | UndoStack::instance()->undo(); |
1094 | 1105 | ||
1095 | // Refresh the view | 1106 | // Refresh the view |
1096 | mViewManager->refreshView(); | 1107 | mViewManager->refreshView(); |
1097 | } | 1108 | } |
1098 | 1109 | ||
1099 | void KABCore::redo() | 1110 | void KABCore::redo() |
1100 | { | 1111 | { |
1101 | RedoStack::instance()->redo(); | 1112 | RedoStack::instance()->redo(); |
1102 | 1113 | ||
1103 | // Refresh the view | 1114 | // Refresh the view |
1104 | mViewManager->refreshView(); | 1115 | mViewManager->refreshView(); |
1105 | } | 1116 | } |
1106 | 1117 | ||
1107 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1118 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1108 | { | 1119 | { |
1109 | if (mMultipleViewsAtOnce) | 1120 | if (mMultipleViewsAtOnce) |
1110 | { | 1121 | { |
1111 | if ( visible ) | 1122 | if ( visible ) |
1112 | mJumpButtonBar->show(); | 1123 | mJumpButtonBar->show(); |
1113 | else | 1124 | else |
1114 | mJumpButtonBar->hide(); | 1125 | mJumpButtonBar->hide(); |
1115 | } | 1126 | } |
@@ -1407,65 +1418,65 @@ void KABCore::initGUI() | |||
1407 | 1418 | ||
1408 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1419 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1409 | 1420 | ||
1410 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1421 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1411 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1422 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1412 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1423 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1413 | SLOT( incrementalSearch( const QString& ) ) ); | 1424 | SLOT( incrementalSearch( const QString& ) ) ); |
1414 | 1425 | ||
1415 | mViewManager = new ViewManager( this, viewSpace ); | 1426 | mViewManager = new ViewManager( this, viewSpace ); |
1416 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1427 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1417 | 1428 | ||
1418 | mDetails = new ViewContainer( mDetailsSplitter ); | 1429 | mDetails = new ViewContainer( mDetailsSplitter ); |
1419 | 1430 | ||
1420 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1431 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1421 | 1432 | ||
1422 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1433 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1423 | 1434 | ||
1424 | topLayout->addWidget( mExtensionBarSplitter ); | 1435 | topLayout->addWidget( mExtensionBarSplitter ); |
1425 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1436 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1426 | topLayout->addWidget( mJumpButtonBar ); | 1437 | topLayout->addWidget( mJumpButtonBar ); |
1427 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1438 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1428 | 1439 | ||
1429 | mXXPortManager = new XXPortManager( this, this ); | 1440 | mXXPortManager = new XXPortManager( this, this ); |
1430 | 1441 | ||
1431 | #else //KAB_EMBEDDED | 1442 | #else //KAB_EMBEDDED |
1432 | //US initialize viewMenu before settingup viewmanager. | 1443 | //US initialize viewMenu before settingup viewmanager. |
1433 | // Viewmanager needs this menu to plugin submenues. | 1444 | // Viewmanager needs this menu to plugin submenues. |
1434 | viewMenu = new QPopupMenu( this ); | 1445 | viewMenu = new QPopupMenu( this ); |
1435 | settingsMenu = new QPopupMenu( this ); | 1446 | settingsMenu = new QPopupMenu( this ); |
1436 | //filterMenu = new QPopupMenu( this ); | 1447 | //filterMenu = new QPopupMenu( this ); |
1437 | ImportMenu = new QPopupMenu( this ); | 1448 | ImportMenu = new QPopupMenu( this ); |
1438 | ExportMenu = new QPopupMenu( this ); | 1449 | ExportMenu = new QPopupMenu( this ); |
1439 | 1450 | syncMenu = new QPopupMenu( this ); | |
1440 | changeMenu= new QPopupMenu( this ); | 1451 | changeMenu= new QPopupMenu( this ); |
1441 | 1452 | ||
1442 | //US since we have no splitter for the embedded system, setup | 1453 | //US since we have no splitter for the embedded system, setup |
1443 | // a layout with two frames. One left and one right. | 1454 | // a layout with two frames. One left and one right. |
1444 | 1455 | ||
1445 | QBoxLayout *topLayout; | 1456 | QBoxLayout *topLayout; |
1446 | 1457 | ||
1447 | // = new QHBoxLayout( this ); | 1458 | // = new QHBoxLayout( this ); |
1448 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1459 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1449 | 1460 | ||
1450 | // QWidget *mainBox = new QWidget( this ); | 1461 | // QWidget *mainBox = new QWidget( this ); |
1451 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1462 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1452 | 1463 | ||
1453 | #ifdef DESKTOP_VERSION | 1464 | #ifdef DESKTOP_VERSION |
1454 | topLayout = new QHBoxLayout( this ); | 1465 | topLayout = new QHBoxLayout( this ); |
1455 | 1466 | ||
1456 | 1467 | ||
1457 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1468 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1458 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1469 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1459 | 1470 | ||
1460 | topLayout->addWidget(mMiniSplitter ); | 1471 | topLayout->addWidget(mMiniSplitter ); |
1461 | 1472 | ||
1462 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1473 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1463 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1474 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1464 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1475 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1465 | mDetails = new ViewContainer( mMiniSplitter ); | 1476 | mDetails = new ViewContainer( mMiniSplitter ); |
1466 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1477 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1467 | #else | 1478 | #else |
1468 | if ( QApplication::desktop()->width() > 480 ) { | 1479 | if ( QApplication::desktop()->width() > 480 ) { |
1469 | topLayout = new QHBoxLayout( this ); | 1480 | topLayout = new QHBoxLayout( this ); |
1470 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1481 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1471 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1482 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
@@ -1725,82 +1736,84 @@ void KABCore::initActions() | |||
1725 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1736 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1726 | this, SLOT( createAboutData() ), actionCollection(), | 1737 | this, SLOT( createAboutData() ), actionCollection(), |
1727 | "kaddressbook_about_data" ); | 1738 | "kaddressbook_about_data" ); |
1728 | #endif //KAB_EMBEDDED | 1739 | #endif //KAB_EMBEDDED |
1729 | 1740 | ||
1730 | clipboardDataChanged(); | 1741 | clipboardDataChanged(); |
1731 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1742 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1732 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1743 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1733 | } | 1744 | } |
1734 | 1745 | ||
1735 | //US we need this function, to plug all actions into the correct menues. | 1746 | //US we need this function, to plug all actions into the correct menues. |
1736 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1747 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1737 | void KABCore::addActionsManually() | 1748 | void KABCore::addActionsManually() |
1738 | { | 1749 | { |
1739 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1750 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1740 | 1751 | ||
1741 | #ifdef KAB_EMBEDDED | 1752 | #ifdef KAB_EMBEDDED |
1742 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1753 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1743 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1754 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1744 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1755 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1745 | 1756 | ||
1746 | KToolBar* tb = mMainWindow->toolBar(); | 1757 | KToolBar* tb = mMainWindow->toolBar(); |
1747 | 1758 | ||
1748 | #ifdef DESKTOP_VERSION | 1759 | #ifdef DESKTOP_VERSION |
1749 | QMenuBar* mb = mMainWindow->menuBar(); | 1760 | QMenuBar* mb = mMainWindow->menuBar(); |
1750 | 1761 | ||
1751 | //US setup menubar. | 1762 | //US setup menubar. |
1752 | //Disable the following block if you do not want to have a menubar. | 1763 | //Disable the following block if you do not want to have a menubar. |
1753 | mb->insertItem( "&File", fileMenu ); | 1764 | mb->insertItem( "&File", fileMenu ); |
1754 | mb->insertItem( "&Edit", editMenu ); | 1765 | mb->insertItem( "&Edit", editMenu ); |
1755 | mb->insertItem( "&View", viewMenu ); | 1766 | mb->insertItem( "&View", viewMenu ); |
1756 | mb->insertItem( "&Settings", settingsMenu ); | 1767 | mb->insertItem( "&Settings", settingsMenu ); |
1768 | mb->insertItem( i18n("Synchronize"), syncMenu ); | ||
1757 | mb->insertItem( "&Change selected", changeMenu ); | 1769 | mb->insertItem( "&Change selected", changeMenu ); |
1758 | mb->insertItem( "&Help", helpMenu ); | 1770 | mb->insertItem( "&Help", helpMenu ); |
1759 | mIncSearchWidget = new IncSearchWidget( tb ); | 1771 | mIncSearchWidget = new IncSearchWidget( tb ); |
1760 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1772 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1761 | 1773 | ||
1762 | #else | 1774 | #else |
1763 | //US setup toolbar | 1775 | //US setup toolbar |
1764 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1776 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1765 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1777 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1766 | menuBarTB->insertItem( "ME", popupBarTB); | 1778 | menuBarTB->insertItem( "ME", popupBarTB); |
1767 | tb->insertWidget(-1, 0, menuBarTB); | 1779 | tb->insertWidget(-1, 0, menuBarTB); |
1768 | mIncSearchWidget = new IncSearchWidget( tb ); | 1780 | mIncSearchWidget = new IncSearchWidget( tb ); |
1769 | 1781 | ||
1770 | tb->enableMoving(false); | 1782 | tb->enableMoving(false); |
1771 | popupBarTB->insertItem( "&File", fileMenu ); | 1783 | popupBarTB->insertItem( "&File", fileMenu ); |
1772 | popupBarTB->insertItem( "&Edit", editMenu ); | 1784 | popupBarTB->insertItem( "&Edit", editMenu ); |
1773 | popupBarTB->insertItem( "&View", viewMenu ); | 1785 | popupBarTB->insertItem( "&View", viewMenu ); |
1774 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1786 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1787 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | ||
1775 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1788 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1776 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1789 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1777 | popupBarTB->insertItem( "&Help", helpMenu ); | 1790 | popupBarTB->insertItem( "&Help", helpMenu ); |
1778 | if (QApplication::desktop()->width() > 320 ) { | 1791 | if (QApplication::desktop()->width() > 320 ) { |
1779 | // mViewManager->getFilterAction()->plug ( tb); | 1792 | // mViewManager->getFilterAction()->plug ( tb); |
1780 | } | 1793 | } |
1781 | #endif | 1794 | #endif |
1782 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1795 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1783 | 1796 | ||
1784 | 1797 | ||
1785 | 1798 | ||
1786 | //US Now connect the actions with the menue entries. | 1799 | //US Now connect the actions with the menue entries. |
1787 | mActionPrint->plug( fileMenu ); | 1800 | mActionPrint->plug( fileMenu ); |
1788 | mActionMail->plug( fileMenu ); | 1801 | mActionMail->plug( fileMenu ); |
1789 | fileMenu->insertSeparator(); | 1802 | fileMenu->insertSeparator(); |
1790 | 1803 | ||
1791 | mActionNewContact->plug( fileMenu ); | 1804 | mActionNewContact->plug( fileMenu ); |
1792 | mActionNewContact->plug( tb ); | 1805 | mActionNewContact->plug( tb ); |
1793 | 1806 | ||
1794 | mActionEditAddressee->plug( fileMenu ); | 1807 | mActionEditAddressee->plug( fileMenu ); |
1795 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1808 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1796 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1809 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1797 | mActionEditAddressee->plug( tb ); | 1810 | mActionEditAddressee->plug( tb ); |
1798 | 1811 | ||
1799 | fileMenu->insertSeparator(); | 1812 | fileMenu->insertSeparator(); |
1800 | mActionSave->plug( fileMenu ); | 1813 | mActionSave->plug( fileMenu ); |
1801 | fileMenu->insertItem( "&Import", ImportMenu ); | 1814 | fileMenu->insertItem( "&Import", ImportMenu ); |
1802 | fileMenu->insertItem( "&Export", ExportMenu ); | 1815 | fileMenu->insertItem( "&Export", ExportMenu ); |
1803 | fileMenu->insertSeparator(); | 1816 | fileMenu->insertSeparator(); |
1804 | mActionMailVCard->plug( fileMenu ); | 1817 | mActionMailVCard->plug( fileMenu ); |
1805 | #ifndef DESKTOP_VERSION | 1818 | #ifndef DESKTOP_VERSION |
1806 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1819 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
@@ -1854,64 +1867,68 @@ void KABCore::addActionsManually() | |||
1854 | mActionFaq->plug( helpMenu ); | 1867 | mActionFaq->plug( helpMenu ); |
1855 | mActionAboutKAddressbook->plug( helpMenu ); | 1868 | mActionAboutKAddressbook->plug( helpMenu ); |
1856 | 1869 | ||
1857 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1870 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1858 | 1871 | ||
1859 | mActionSave->plug( tb ); | 1872 | mActionSave->plug( tb ); |
1860 | mViewManager->getFilterAction()->plug ( tb); | 1873 | mViewManager->getFilterAction()->plug ( tb); |
1861 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1874 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1862 | mActionUndo->plug( tb ); | 1875 | mActionUndo->plug( tb ); |
1863 | mActionDelete->plug( tb ); | 1876 | mActionDelete->plug( tb ); |
1864 | mActionRedo->plug( tb ); | 1877 | mActionRedo->plug( tb ); |
1865 | } | 1878 | } |
1866 | } | 1879 | } |
1867 | //mActionQuit->plug ( tb ); | 1880 | //mActionQuit->plug ( tb ); |
1868 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1881 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1869 | 1882 | ||
1870 | //US link the searchwidget first to this. | 1883 | //US link the searchwidget first to this. |
1871 | // The real linkage to the toolbar happens later. | 1884 | // The real linkage to the toolbar happens later. |
1872 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1885 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1873 | //US tb->insertItem( mIncSearchWidget ); | 1886 | //US tb->insertItem( mIncSearchWidget ); |
1874 | /*US | 1887 | /*US |
1875 | mIncSearchWidget = new IncSearchWidget( tb ); | 1888 | mIncSearchWidget = new IncSearchWidget( tb ); |
1876 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1889 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1877 | SLOT( incrementalSearch( const QString& ) ) ); | 1890 | SLOT( incrementalSearch( const QString& ) ) ); |
1878 | 1891 | ||
1879 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1892 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1880 | 1893 | ||
1881 | //US topLayout->addWidget( mJumpButtonBar ); | 1894 | //US topLayout->addWidget( mJumpButtonBar ); |
1882 | this->layout()->add( mJumpButtonBar ); | 1895 | this->layout()->add( mJumpButtonBar ); |
1883 | */ | 1896 | */ |
1884 | 1897 | ||
1885 | #endif //KAB_EMBEDDED | 1898 | #endif //KAB_EMBEDDED |
1899 | |||
1900 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | ||
1901 | fillSyncMenu(); | ||
1902 | |||
1886 | } | 1903 | } |
1887 | void KABCore::showLicence() | 1904 | void KABCore::showLicence() |
1888 | { | 1905 | { |
1889 | KApplication::showLicence(); | 1906 | KApplication::showLicence(); |
1890 | } | 1907 | } |
1891 | void KABCore::removeVoice() | 1908 | void KABCore::removeVoice() |
1892 | { | 1909 | { |
1893 | 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 ) | 1910 | 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 ) |
1894 | return; | 1911 | return; |
1895 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1912 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1896 | KABC::Addressee::List::Iterator it; | 1913 | KABC::Addressee::List::Iterator it; |
1897 | for ( it = list.begin(); it != list.end(); ++it ) { | 1914 | for ( it = list.begin(); it != list.end(); ++it ) { |
1898 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1915 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1899 | PhoneNumber::List::Iterator phoneIt; | 1916 | PhoneNumber::List::Iterator phoneIt; |
1900 | bool found = false; | 1917 | bool found = false; |
1901 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1918 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1902 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1919 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1903 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1920 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1904 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1921 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1905 | (*it).insertPhoneNumber( (*phoneIt) ); | 1922 | (*it).insertPhoneNumber( (*phoneIt) ); |
1906 | found = true; | 1923 | found = true; |
1907 | } | 1924 | } |
1908 | } | 1925 | } |
1909 | 1926 | ||
1910 | } | 1927 | } |
1911 | if ( found ) | 1928 | if ( found ) |
1912 | contactModified((*it) ); | 1929 | contactModified((*it) ); |
1913 | } | 1930 | } |
1914 | } | 1931 | } |
1915 | 1932 | ||
1916 | 1933 | ||
1917 | 1934 | ||
@@ -2055,37 +2072,472 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses | |||
2055 | { | 2072 | { |
2056 | 2073 | ||
2057 | // raise Ka/Pi if it is in the background | 2074 | // raise Ka/Pi if it is in the background |
2058 | #ifndef DESKTOP_VERSION | 2075 | #ifndef DESKTOP_VERSION |
2059 | #ifndef KORG_NODCOP | 2076 | #ifndef KORG_NODCOP |
2060 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2077 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2061 | #endif | 2078 | #endif |
2062 | #endif | 2079 | #endif |
2063 | 2080 | ||
2064 | mMainWindow->showMaximized(); | 2081 | mMainWindow->showMaximized(); |
2065 | mMainWindow-> raise(); | 2082 | mMainWindow-> raise(); |
2066 | 2083 | ||
2067 | mViewManager->setSelected( "", false); | 2084 | mViewManager->setSelected( "", false); |
2068 | mViewManager->refreshView( "" ); | 2085 | mViewManager->refreshView( "" ); |
2069 | mViewManager->setSelected( foundUid, true ); | 2086 | mViewManager->setSelected( foundUid, true ); |
2070 | mViewManager->refreshView( foundUid ); | 2087 | mViewManager->refreshView( foundUid ); |
2071 | 2088 | ||
2072 | if ( !mMultipleViewsAtOnce ) | 2089 | if ( !mMultipleViewsAtOnce ) |
2073 | { | 2090 | { |
2074 | setDetailsVisible( true ); | 2091 | setDetailsVisible( true ); |
2075 | mActionDetails->setChecked(true); | 2092 | mActionDetails->setChecked(true); |
2076 | } | 2093 | } |
2077 | } | 2094 | } |
2078 | } | 2095 | } |
2079 | 2096 | ||
2080 | 2097 | ||
2081 | void KABCore::faq() | 2098 | void KABCore::faq() |
2082 | { | 2099 | { |
2083 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2100 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2084 | } | 2101 | } |
2085 | 2102 | ||
2086 | 2103 | ||
2104 | void KABCore::fillSyncMenu() | ||
2105 | { | ||
2106 | if ( syncMenu->count() ) | ||
2107 | syncMenu->clear(); | ||
2108 | syncMenu->insertItem( i18n("Configure..."), 0 ); | ||
2109 | syncMenu->insertSeparator(); | ||
2110 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | ||
2111 | syncMenu->insertSeparator(); | ||
2112 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
2113 | config.setGroup("General"); | ||
2114 | QStringList prof = config.readListEntry("SyncProfileNames"); | ||
2115 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | ||
2116 | if ( prof.count() < 3 ) { | ||
2117 | prof.clear(); | ||
2118 | prof << i18n("Sharp_DTM"); | ||
2119 | prof << i18n("Local_file"); | ||
2120 | prof << i18n("Last_file"); | ||
2121 | KSyncProfile* temp = new KSyncProfile (); | ||
2122 | temp->setName( prof[0] ); | ||
2123 | temp->writeConfig(&config); | ||
2124 | temp->setName( prof[1] ); | ||
2125 | temp->writeConfig(&config); | ||
2126 | temp->setName( prof[2] ); | ||
2127 | temp->writeConfig(&config); | ||
2128 | config.setGroup("General"); | ||
2129 | config.writeEntry("SyncProfileNames",prof); | ||
2130 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | ||
2131 | config.sync(); | ||
2132 | delete temp; | ||
2133 | } | ||
2134 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | ||
2135 | KABPrefs::instance()->mSyncProfileNames = prof; | ||
2136 | int i; | ||
2137 | for ( i = 0; i < prof.count(); ++i ) { | ||
2138 | |||
2139 | syncMenu->insertItem( prof[i], 1000+i ); | ||
2140 | if ( i == 2 ) | ||
2141 | syncMenu->insertSeparator(); | ||
2142 | } | ||
2143 | QDir app_dir; | ||
2144 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | ||
2145 | syncMenu->setItemEnabled( false , 1000 ); | ||
2146 | } | ||
2147 | //probaly useless | ||
2148 | //mView->setupExternSyncProfiles(); | ||
2149 | } | ||
2150 | void KABCore::slotSyncMenu( int action ) | ||
2151 | { | ||
2152 | //qDebug("syncaction %d ", action); | ||
2153 | if ( action == 0 ) { | ||
2087 | 2154 | ||
2155 | // seems to be a Qt2 event handling bug | ||
2156 | // syncmenu.clear causes a segfault at first time | ||
2157 | // when we call it after the main event loop, it is ok | ||
2158 | // same behaviour when calling OM/Pi via QCOP for the first time | ||
2159 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | ||
2160 | //confSync(); | ||
2088 | 2161 | ||
2089 | #ifndef KAB_EMBEDDED | 2162 | return; |
2090 | #include "kabcore.moc" | 2163 | } |
2091 | #endif //KAB_EMBEDDED | 2164 | if ( action == 1 ) { |
2165 | multiSync( true ); | ||
2166 | return; | ||
2167 | } | ||
2168 | |||
2169 | if (mBlockSaveFlag) | ||
2170 | return; | ||
2171 | mBlockSaveFlag = true; | ||
2172 | mCurrentSyncProfile = action - 1000 ; | ||
2173 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; | ||
2174 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; | ||
2175 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
2176 | KSyncProfile* temp = new KSyncProfile (); | ||
2177 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
2178 | temp->readConfig(&config); | ||
2179 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
2180 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | ||
2181 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
2182 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
2183 | KABPrefs::instance()->mWriteBackInFuture = 0; | ||
2184 | if ( temp->getWriteBackFuture() ) | ||
2185 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
2186 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | ||
2187 | if ( action == 1000 ) { | ||
2188 | syncSharp(); | ||
2189 | |||
2190 | } else if ( action == 1001 ) { | ||
2191 | syncLocalFile(); | ||
2192 | |||
2193 | } else if ( action == 1002 ) { | ||
2194 | quickSyncLocalFile(); | ||
2195 | |||
2196 | } else if ( action >= 1003 ) { | ||
2197 | if ( temp->getIsLocalFileSync() ) { | ||
2198 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | ||
2199 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | ||
2200 | } else { | ||
2201 | if ( temp->getIsPhoneSync() ) { | ||
2202 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | ||
2203 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | ||
2204 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | ||
2205 | syncPhone(); | ||
2206 | } else | ||
2207 | syncRemote( temp ); | ||
2208 | |||
2209 | } | ||
2210 | } | ||
2211 | delete temp; | ||
2212 | mBlockSaveFlag = false; | ||
2213 | } | ||
2214 | |||
2215 | void KABCore::syncLocalFile() | ||
2216 | { | ||
2217 | |||
2218 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; | ||
2219 | |||
2220 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | ||
2221 | if ( fn == "" ) | ||
2222 | return; | ||
2223 | if ( syncWithFile( fn, false ) ) { | ||
2224 | qDebug("syncLocalFile() successful "); | ||
2225 | } | ||
2226 | |||
2227 | } | ||
2228 | bool KABCore::syncWithFile( QString fn , bool quick ) | ||
2229 | { | ||
2230 | bool ret = false; | ||
2231 | QFileInfo info; | ||
2232 | info.setFile( fn ); | ||
2233 | QString mess; | ||
2234 | bool loadbup = true; | ||
2235 | if ( !info. exists() ) { | ||
2236 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | ||
2237 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
2238 | mess ); | ||
2239 | return ret; | ||
2240 | } | ||
2241 | int result = 0; | ||
2242 | if ( !quick ) { | ||
2243 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | ||
2244 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
2245 | mess, | ||
2246 | i18n("Sync"), i18n("Cancel"), 0, | ||
2247 | 0, 1 ); | ||
2248 | if ( result ) | ||
2249 | return false; | ||
2250 | } | ||
2251 | if ( KABPrefs::instance()->mAskForPreferences ) | ||
2252 | edit_sync_options(); | ||
2253 | if ( result == 0 ) { | ||
2254 | //qDebug("Now sycing ... "); | ||
2255 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) | ||
2256 | setCaption( i18n("Synchronization successful") ); | ||
2257 | else | ||
2258 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | ||
2259 | if ( ! quick ) | ||
2260 | KABPrefs::instance()->mLastSyncedLocalFile = fn; | ||
2261 | setModified(); | ||
2262 | } | ||
2263 | return ret; | ||
2264 | } | ||
2265 | void KABCore::quickSyncLocalFile() | ||
2266 | { | ||
2267 | |||
2268 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { | ||
2269 | qDebug("quick syncLocalFile() successful "); | ||
2270 | |||
2271 | } | ||
2272 | } | ||
2273 | void KABCore::multiSync( bool askforPrefs ) | ||
2274 | { | ||
2275 | if (mBlockSaveFlag) | ||
2276 | return; | ||
2277 | mBlockSaveFlag = true; | ||
2278 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | ||
2279 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | ||
2280 | question, | ||
2281 | i18n("Yes"), i18n("No"), | ||
2282 | 0, 0 ) != 0 ) { | ||
2283 | mBlockSaveFlag = false; | ||
2284 | setCaption(i18n("Aborted! Nothing synced!")); | ||
2285 | return; | ||
2286 | } | ||
2287 | mCurrentSyncDevice = i18n("Multiple profiles") ; | ||
2288 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; | ||
2289 | if ( askforPrefs ) { | ||
2290 | edit_sync_options(); | ||
2291 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; | ||
2292 | } | ||
2293 | setCaption(i18n("Multiple sync started.") ); | ||
2294 | qApp->processEvents(); | ||
2295 | int num = ringSync() ; | ||
2296 | if ( num > 1 ) | ||
2297 | ringSync(); | ||
2298 | mBlockSaveFlag = false; | ||
2299 | if ( num ) | ||
2300 | save(); | ||
2301 | if ( num ) | ||
2302 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | ||
2303 | else | ||
2304 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | ||
2305 | return; | ||
2306 | } | ||
2307 | int KABCore::ringSync() | ||
2308 | { | ||
2309 | int syncedProfiles = 0; | ||
2310 | int i; | ||
2311 | QTime timer; | ||
2312 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
2313 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; | ||
2314 | KSyncProfile* temp = new KSyncProfile (); | ||
2315 | KABPrefs::instance()->mAskForPreferences = false; | ||
2316 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | ||
2317 | mCurrentSyncProfile = i; | ||
2318 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | ||
2319 | temp->readConfig(&config); | ||
2320 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | ||
2321 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | ||
2322 | ++syncedProfiles; | ||
2323 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
2324 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
2325 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
2326 | KABPrefs::instance()->mWriteBackInFuture = 0; | ||
2327 | if ( temp->getWriteBackFuture() ) | ||
2328 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
2329 | KABPrefs::instance()->mShowSyncSummary = false; | ||
2330 | mCurrentSyncDevice = syncProfileNames[i] ; | ||
2331 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; | ||
2332 | if ( i == 0 ) { | ||
2333 | syncSharp(); | ||
2334 | } else { | ||
2335 | if ( temp->getIsLocalFileSync() ) { | ||
2336 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | ||
2337 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | ||
2338 | } else { | ||
2339 | if ( temp->getIsPhoneSync() ) { | ||
2340 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | ||
2341 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | ||
2342 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | ||
2343 | syncPhone(); | ||
2344 | } else | ||
2345 | syncRemote( temp, false ); | ||
2346 | |||
2347 | } | ||
2348 | } | ||
2349 | timer.start(); | ||
2350 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | ||
2351 | while ( timer.elapsed () < 2000 ) { | ||
2352 | qApp->processEvents(); | ||
2353 | #ifndef _WIN32_ | ||
2354 | sleep (1); | ||
2355 | #endif | ||
2356 | } | ||
2357 | |||
2358 | } | ||
2359 | |||
2360 | } | ||
2361 | delete temp; | ||
2362 | return syncedProfiles; | ||
2363 | } | ||
2364 | |||
2365 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) | ||
2366 | { | ||
2367 | QString question; | ||
2368 | if ( ask ) { | ||
2369 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | ||
2370 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | ||
2371 | question, | ||
2372 | i18n("Yes"), i18n("No"), | ||
2373 | 0, 0 ) != 0 ) | ||
2374 | return; | ||
2375 | } | ||
2376 | QString command = prof->getPreSyncCommand(); | ||
2377 | int fi; | ||
2378 | if ( (fi = command.find("$PWD$")) > 0 ) { | ||
2379 | QString pwd = getPassword(); | ||
2380 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | ||
2381 | |||
2382 | } | ||
2383 | int maxlen = 30; | ||
2384 | if ( QApplication::desktop()->width() > 320 ) | ||
2385 | maxlen += 25; | ||
2386 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | ||
2387 | int fileSize = 0; | ||
2388 | int result = system ( command ); | ||
2389 | // 0 : okay | ||
2390 | // 256: no such file or dir | ||
2391 | // | ||
2392 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | ||
2393 | if ( result != 0 ) { | ||
2394 | int len = maxlen; | ||
2395 | while ( len < command.length() ) { | ||
2396 | command.insert( len , "\n" ); | ||
2397 | len += maxlen +2; | ||
2398 | } | ||
2399 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | ||
2400 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | ||
2401 | question, | ||
2402 | i18n("Okay!")) ; | ||
2403 | setCaption ("KO/Pi"); | ||
2404 | return; | ||
2405 | } | ||
2406 | setCaption ( i18n( "Copying succeed." ) ); | ||
2407 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | ||
2408 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { | ||
2409 | // Event* e = mView->getLastSyncEvent(); | ||
2410 | // e->setReadOnly( false ); | ||
2411 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
2412 | // e->setReadOnly( true ); | ||
2413 | if ( KABPrefs::instance()->mWriteBackFile ) { | ||
2414 | command = prof->getPostSyncCommand(); | ||
2415 | int fi; | ||
2416 | if ( (fi = command.find("$PWD$")) > 0 ) { | ||
2417 | QString pwd = getPassword(); | ||
2418 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | ||
2419 | |||
2420 | } | ||
2421 | setCaption ( i18n( "Writing back file ..." ) ); | ||
2422 | result = system ( command ); | ||
2423 | qDebug("KO: Writing back file result: %d ", result); | ||
2424 | if ( result != 0 ) { | ||
2425 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | ||
2426 | return; | ||
2427 | } else { | ||
2428 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | ||
2429 | } | ||
2430 | } | ||
2431 | } | ||
2432 | return; | ||
2433 | } | ||
2434 | #include <qpushbutton.h> | ||
2435 | #include <qradiobutton.h> | ||
2436 | #include <qbuttongroup.h> | ||
2437 | void KABCore::edit_sync_options() | ||
2438 | { | ||
2439 | //mDialogManager->showSyncOptions(); | ||
2440 | //KABPrefs::instance()->mSyncAlgoPrefs | ||
2441 | QDialog dia( this, "dia", true ); | ||
2442 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | ||
2443 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | ||
2444 | QVBoxLayout lay ( &dia ); | ||
2445 | lay.setSpacing( 2 ); | ||
2446 | lay.setMargin( 3 ); | ||
2447 | lay.addWidget(&gr); | ||
2448 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | ||
2449 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | ||
2450 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | ||
2451 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | ||
2452 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | ||
2453 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | ||
2454 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | ||
2455 | QPushButton pb ( "OK", &dia); | ||
2456 | lay.addWidget( &pb ); | ||
2457 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
2458 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { | ||
2459 | case 0: | ||
2460 | loc.setChecked( true); | ||
2461 | break; | ||
2462 | case 1: | ||
2463 | rem.setChecked( true ); | ||
2464 | break; | ||
2465 | case 2: | ||
2466 | newest.setChecked( true); | ||
2467 | break; | ||
2468 | case 3: | ||
2469 | ask.setChecked( true); | ||
2470 | break; | ||
2471 | case 4: | ||
2472 | f_loc.setChecked( true); | ||
2473 | break; | ||
2474 | case 5: | ||
2475 | f_rem.setChecked( true); | ||
2476 | break; | ||
2477 | case 6: | ||
2478 | // both.setChecked( true); | ||
2479 | break; | ||
2480 | default: | ||
2481 | break; | ||
2482 | } | ||
2483 | if ( dia.exec() ) { | ||
2484 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | ||
2485 | } | ||
2486 | |||
2487 | |||
2488 | } | ||
2489 | QString KABCore::getPassword( ) | ||
2490 | { | ||
2491 | QString retfile = ""; | ||
2492 | QDialog dia ( this, "input-dialog", true ); | ||
2493 | QLineEdit lab ( &dia ); | ||
2494 | lab.setEchoMode( QLineEdit::Password ); | ||
2495 | QVBoxLayout lay( &dia ); | ||
2496 | lay.setMargin(7); | ||
2497 | lay.setSpacing(7); | ||
2498 | lay.addWidget( &lab); | ||
2499 | dia.setFixedSize( 230,50 ); | ||
2500 | dia.setCaption( i18n("Enter password") ); | ||
2501 | QPushButton pb ( "OK", &dia); | ||
2502 | lay.addWidget( &pb ); | ||
2503 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
2504 | dia.show(); | ||
2505 | int res = dia.exec(); | ||
2506 | if ( res ) | ||
2507 | retfile = lab.text(); | ||
2508 | dia.hide(); | ||
2509 | qApp->processEvents(); | ||
2510 | return retfile; | ||
2511 | |||
2512 | } | ||
2513 | |||
2514 | bool KABCore::syncAB(QString filename, int mode) | ||
2515 | { | ||
2516 | |||
2517 | } | ||
2518 | |||
2519 | |||
2520 | void KABCore::confSync() | ||
2521 | { | ||
2522 | //mView->confSync(); | ||
2523 | qDebug("pending KABCore::confSync() "); | ||
2524 | fillSyncMenu(); | ||
2525 | } | ||
2526 | void KABCore::syncSharp() | ||
2527 | { | ||
2528 | if ( mModified ) | ||
2529 | save(); | ||
2530 | qDebug("pending syncSharp() "); | ||
2531 | //mView->syncSharp(); | ||
2532 | mModified = true ; | ||
2533 | |||
2534 | } | ||
2535 | void KABCore::syncPhone() | ||
2536 | { | ||
2537 | if ( mModified ) | ||
2538 | save(); | ||
2539 | qDebug("pending syncPhone(); "); | ||
2540 | //mView->syncPhone(); | ||
2541 | setModified(); | ||
2542 | |||
2543 | } | ||
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 39d043f..10ce8f4 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -28,64 +28,65 @@ | |||
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | 35 | ||
36 | namespace KABC { | 36 | namespace KABC { |
37 | class AddressBook; | 37 | class AddressBook; |
38 | } | 38 | } |
39 | 39 | ||
40 | #ifndef KAB_EMBEDDED | 40 | #ifndef KAB_EMBEDDED |
41 | class KAboutData; | 41 | class KAboutData; |
42 | class KConfig; | 42 | class KConfig; |
43 | 43 | ||
44 | class KAddressBookService; | 44 | class KAddressBookService; |
45 | class LDAPSearchDialog; | 45 | class LDAPSearchDialog; |
46 | #else //KAB_EMBEDDED | 46 | #else //KAB_EMBEDDED |
47 | class KAddressBookMain; | 47 | class KAddressBookMain; |
48 | //US class QAction; | 48 | //US class QAction; |
49 | #endif //KAB_EMBEDDED | 49 | #endif //KAB_EMBEDDED |
50 | class KCMultiDialog; | 50 | class KCMultiDialog; |
51 | class KXMLGUIClient; | 51 | class KXMLGUIClient; |
52 | class ExtensionManager; | 52 | class ExtensionManager; |
53 | class XXPortManager; | 53 | class XXPortManager; |
54 | class JumpButtonBar; | 54 | class JumpButtonBar; |
55 | class IncSearchWidget; | 55 | class IncSearchWidget; |
56 | class KDGanttMinimizeSplitter; | 56 | class KDGanttMinimizeSplitter; |
57 | class KAction; | 57 | class KAction; |
58 | class KActionCollection; | 58 | class KActionCollection; |
59 | class KToggleAction; | 59 | class KToggleAction; |
60 | class KSyncProfile; | ||
60 | 61 | ||
61 | class QAction; | 62 | class QAction; |
62 | class QMenuBar; | 63 | class QMenuBar; |
63 | class QSplitter; | 64 | class QSplitter; |
64 | class ViewContainer; | 65 | class ViewContainer; |
65 | class ViewManager; | 66 | class ViewManager; |
66 | class AddresseeEditorDialog; | 67 | class AddresseeEditorDialog; |
67 | class Ir; | 68 | class Ir; |
68 | 69 | ||
69 | class KABCore : public QWidget | 70 | class KABCore : public QWidget |
70 | { | 71 | { |
71 | Q_OBJECT | 72 | Q_OBJECT |
72 | 73 | ||
73 | public: | 74 | public: |
74 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 75 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
75 | 76 | ||
76 | 77 | ||
77 | ~KABCore(); | 78 | ~KABCore(); |
78 | 79 | ||
79 | 80 | ||
80 | #ifdef KAB_EMBEDDED | 81 | #ifdef KAB_EMBEDDED |
81 | //US added functionality | 82 | //US added functionality |
82 | QPopupMenu* getViewMenu() {return viewMenu;} | 83 | QPopupMenu* getViewMenu() {return viewMenu;} |
83 | QPopupMenu* getFilterMenu() {return filterMenu;} | 84 | QPopupMenu* getFilterMenu() {return filterMenu;} |
84 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 85 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
85 | void addActionsManually(); | 86 | void addActionsManually(); |
86 | #endif //KAB_EMBEDDED | 87 | #endif //KAB_EMBEDDED |
87 | /** | 88 | /** |
88 | Restores the global settings. | 89 | Restores the global settings. |
89 | */ | 90 | */ |
90 | void restoreSettings(); | 91 | void restoreSettings(); |
91 | 92 | ||
@@ -311,64 +312,65 @@ class KABCore : public QWidget | |||
311 | 312 | ||
312 | /** | 313 | /** |
313 | Launches the configuration dialog. | 314 | Launches the configuration dialog. |
314 | */ | 315 | */ |
315 | void openConfigDialog(); | 316 | void openConfigDialog(); |
316 | 317 | ||
317 | /** | 318 | /** |
318 | Launches the ldap search dialog. | 319 | Launches the ldap search dialog. |
319 | */ | 320 | */ |
320 | void openLDAPDialog(); | 321 | void openLDAPDialog(); |
321 | 322 | ||
322 | /** | 323 | /** |
323 | Creates a KAddressBookPrinter, which will display the print | 324 | Creates a KAddressBookPrinter, which will display the print |
324 | dialog and do the printing. | 325 | dialog and do the printing. |
325 | */ | 326 | */ |
326 | void print(); | 327 | void print(); |
327 | 328 | ||
328 | /** | 329 | /** |
329 | Registers a new GUI client, so plugins can register its actions. | 330 | Registers a new GUI client, so plugins can register its actions. |
330 | */ | 331 | */ |
331 | void addGUIClient( KXMLGUIClient *client ); | 332 | void addGUIClient( KXMLGUIClient *client ); |
332 | 333 | ||
333 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 334 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
334 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 335 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
335 | 336 | ||
336 | 337 | ||
337 | signals: | 338 | signals: |
338 | void contactSelected( const QString &name ); | 339 | void contactSelected( const QString &name ); |
339 | void contactSelected( const QPixmap &pixmap ); | 340 | void contactSelected( const QPixmap &pixmap ); |
340 | public slots: | 341 | public slots: |
341 | void setDetailsVisible( bool visible ); | 342 | void setDetailsVisible( bool visible ); |
342 | void setDetailsToState(); | 343 | void setDetailsToState(); |
344 | void slotSyncMenu( int ); | ||
343 | private slots: | 345 | private slots: |
344 | void setJumpButtonBarVisible( bool visible ); | 346 | void setJumpButtonBarVisible( bool visible ); |
345 | void importFromOL(); | 347 | void importFromOL(); |
346 | void extensionModified( const KABC::Addressee::List &list ); | 348 | void extensionModified( const KABC::Addressee::List &list ); |
347 | void extensionChanged( int id ); | 349 | void extensionChanged( int id ); |
348 | void clipboardDataChanged(); | 350 | void clipboardDataChanged(); |
349 | void updateActionMenu(); | 351 | void updateActionMenu(); |
350 | void configureKeyBindings(); | 352 | void configureKeyBindings(); |
351 | void removeVoice(); | 353 | void removeVoice(); |
352 | #ifdef KAB_EMBEDDED | 354 | #ifdef KAB_EMBEDDED |
353 | void configureResources(); | 355 | void configureResources(); |
354 | #endif //KAB_EMBEDDED | 356 | #endif //KAB_EMBEDDED |
355 | 357 | ||
356 | void slotEditorDestroyed( const QString &uid ); | 358 | void slotEditorDestroyed( const QString &uid ); |
357 | void configurationChanged(); | 359 | void configurationChanged(); |
358 | void addressBookChanged(); | 360 | void addressBookChanged(); |
359 | 361 | ||
360 | private: | 362 | private: |
361 | void initGUI(); | 363 | void initGUI(); |
362 | void initActions(); | 364 | void initActions(); |
363 | 365 | ||
364 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 366 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
365 | const char *name = 0 ); | 367 | const char *name = 0 ); |
366 | 368 | ||
367 | KXMLGUIClient *mGUIClient; | 369 | KXMLGUIClient *mGUIClient; |
368 | 370 | ||
369 | KABC::AddressBook *mAddressBook; | 371 | KABC::AddressBook *mAddressBook; |
370 | 372 | ||
371 | ViewManager *mViewManager; | 373 | ViewManager *mViewManager; |
372 | // QSplitter *mDetailsSplitter; | 374 | // QSplitter *mDetailsSplitter; |
373 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 375 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
374 | ViewContainer *mDetails; | 376 | ViewContainer *mDetails; |
@@ -403,54 +405,74 @@ class KABCore : public QWidget | |||
403 | 405 | ||
404 | KAction *mActionQuit; | 406 | KAction *mActionQuit; |
405 | 407 | ||
406 | //US edit menu | 408 | //US edit menu |
407 | KAction *mActionCopy; | 409 | KAction *mActionCopy; |
408 | KAction *mActionCut; | 410 | KAction *mActionCut; |
409 | KAction *mActionPaste; | 411 | KAction *mActionPaste; |
410 | KAction *mActionSelectAll; | 412 | KAction *mActionSelectAll; |
411 | KAction *mActionUndo; | 413 | KAction *mActionUndo; |
412 | KAction *mActionRedo; | 414 | KAction *mActionRedo; |
413 | KAction *mActionDelete; | 415 | KAction *mActionDelete; |
414 | 416 | ||
415 | //US settings menu | 417 | //US settings menu |
416 | KAction *mActionConfigResources; | 418 | KAction *mActionConfigResources; |
417 | KAction *mActionConfigKAddressbook; | 419 | KAction *mActionConfigKAddressbook; |
418 | KAction *mActionConfigShortcuts; | 420 | KAction *mActionConfigShortcuts; |
419 | KAction *mActionConfigureToolbars; | 421 | KAction *mActionConfigureToolbars; |
420 | KAction *mActionKeyBindings; | 422 | KAction *mActionKeyBindings; |
421 | KToggleAction *mActionJumpBar; | 423 | KToggleAction *mActionJumpBar; |
422 | KToggleAction *mActionDetails; | 424 | KToggleAction *mActionDetails; |
423 | KAction *mActionWhoAmI; | 425 | KAction *mActionWhoAmI; |
424 | KAction *mActionCategories; | 426 | KAction *mActionCategories; |
425 | KAction *mActionAboutKAddressbook; | 427 | KAction *mActionAboutKAddressbook; |
426 | KAction *mActionLicence; | 428 | KAction *mActionLicence; |
427 | KAction *mActionFaq; | 429 | KAction *mActionFaq; |
428 | 430 | ||
429 | KAction *mActionDeleteView; | 431 | KAction *mActionDeleteView; |
430 | 432 | ||
431 | QPopupMenu *viewMenu; | 433 | QPopupMenu *viewMenu; |
432 | QPopupMenu *filterMenu; | 434 | QPopupMenu *filterMenu; |
433 | QPopupMenu *settingsMenu; | 435 | QPopupMenu *settingsMenu; |
434 | QPopupMenu *changeMenu; | 436 | QPopupMenu *changeMenu; |
435 | |||
436 | //US QAction *mActionSave; | 437 | //US QAction *mActionSave; |
437 | QPopupMenu *ImportMenu; | 438 | QPopupMenu *ImportMenu; |
438 | QPopupMenu *ExportMenu; | 439 | QPopupMenu *ExportMenu; |
439 | //LR additional methods | 440 | //LR additional methods |
440 | KAction *mActionRemoveVoice; | 441 | KAction *mActionRemoveVoice; |
441 | KAction * mActionImportOL; | 442 | KAction * mActionImportOL; |
442 | 443 | ||
443 | #ifndef KAB_EMBEDDED | 444 | #ifndef KAB_EMBEDDED |
444 | KAddressBookService *mAddressBookService; | 445 | KAddressBookService *mAddressBookService; |
445 | #endif //KAB_EMBEDDED | 446 | #endif //KAB_EMBEDDED |
446 | 447 | ||
447 | class KABCorePrivate; | 448 | class KABCorePrivate; |
448 | KABCorePrivate *d; | 449 | KABCorePrivate *d; |
450 | bool mBlockSaveFlag; | ||
449 | 451 | ||
450 | #ifdef KAB_EMBEDDED | 452 | #ifdef KAB_EMBEDDED |
451 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 453 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
452 | #endif //KAB_EMBEDDED | 454 | #endif //KAB_EMBEDDED |
455 | // LR ******************************* | ||
456 | // sync stuff! | ||
457 | QPopupMenu *syncMenu; | ||
458 | void fillSyncMenu(); | ||
459 | void confSync(); | ||
460 | QString mCurrentSyncDevice; | ||
461 | QString mCurrentSyncName; | ||
462 | void quickSyncLocalFile(); | ||
463 | bool syncWithFile( QString fn , bool quick ); | ||
464 | void KABCore::syncLocalFile(); | ||
465 | void KABCore::syncPhone(); | ||
466 | void KABCore::syncSharp(); | ||
467 | void multiSync( bool askforPrefs ); | ||
468 | int mCurrentSyncProfile ; | ||
469 | void syncRemote( KSyncProfile* prof, bool ask = true); | ||
470 | void edit_sync_options(); | ||
471 | bool syncAB(QString filename, int mode); | ||
472 | int ringSync(); | ||
473 | QString getPassword( ); | ||
474 | // ********************* | ||
453 | 475 | ||
454 | }; | 476 | }; |
455 | 477 | ||
456 | #endif | 478 | #endif |
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h index e4f359c..9926aa0 100644 --- a/kaddressbook/kabprefs.h +++ b/kaddressbook/kabprefs.h | |||
@@ -53,40 +53,56 @@ class KABPrefs : public KPimPrefs | |||
53 | 53 | ||
54 | /** Set preferences to default values */ | 54 | /** Set preferences to default values */ |
55 | // void usrSetDefaults(); | 55 | // void usrSetDefaults(); |
56 | 56 | ||
57 | /** Read preferences from config file */ | 57 | /** Read preferences from config file */ |
58 | // void usrReadConfig(); | 58 | // void usrReadConfig(); |
59 | 59 | ||
60 | /** Write preferences to config file */ | 60 | /** Write preferences to config file */ |
61 | // void usrWriteConfig(); | 61 | // void usrWriteConfig(); |
62 | #endif //KAB_EMBEDDED | 62 | #endif //KAB_EMBEDDED |
63 | 63 | ||
64 | 64 | ||
65 | // GUI | 65 | // GUI |
66 | bool mJumpButtonBarVisible; | 66 | bool mJumpButtonBarVisible; |
67 | bool mDetailsPageVisible; | 67 | bool mDetailsPageVisible; |
68 | bool mMultipleViewsAtOnce; | 68 | bool mMultipleViewsAtOnce; |
69 | bool mSearchWithReturn; | 69 | bool mSearchWithReturn; |
70 | QValueList<int> mExtensionsSplitter; | 70 | QValueList<int> mExtensionsSplitter; |
71 | QValueList<int> mDetailsSplitter; | 71 | QValueList<int> mDetailsSplitter; |
72 | 72 | ||
73 | // Extensions stuff | 73 | // Extensions stuff |
74 | int mCurrentExtension; | 74 | int mCurrentExtension; |
75 | QStringList mActiveExtensions; | 75 | QStringList mActiveExtensions; |
76 | 76 | ||
77 | // Views stuff | 77 | // Views stuff |
78 | QString mCurrentView; | 78 | QString mCurrentView; |
79 | QStringList mViewNames; | 79 | QStringList mViewNames; |
80 | 80 | ||
81 | // Filter | 81 | // Filter |
82 | int mCurrentFilter; | 82 | int mCurrentFilter; |
83 | 83 | ||
84 | void setCategoryDefaults(); | 84 | void setCategoryDefaults(); |
85 | 85 | // sync stuff | |
86 | QString mLocalMachineName; | ||
87 | QStringList mExternSyncProfiles; | ||
88 | QStringList mSyncProfileNames; | ||
89 | bool mAskForPreferences; | ||
90 | bool mShowSyncSummary; | ||
91 | bool mShowSyncEvents; | ||
92 | bool mShowTodoInAgenda; | ||
93 | bool mWriteBackExistingOnly; | ||
94 | int mSyncAlgoPrefs; | ||
95 | int mRingSyncAlgoPrefs; | ||
96 | bool mWriteBackFile; | ||
97 | int mWriteBackInFuture; | ||
98 | QString mPhoneDevice; | ||
99 | QString mPhoneConnection; | ||
100 | QString mPhoneModel; | ||
101 | QString mLastSyncedLocalFile; // save! | ||
86 | private: | 102 | private: |
87 | KABPrefs(); | 103 | KABPrefs(); |
88 | 104 | ||
89 | static KABPrefs *sInstance; | 105 | static KABPrefs *sInstance; |
90 | }; | 106 | }; |
91 | 107 | ||
92 | #endif | 108 | #endif |