-rw-r--r-- | kaddressbook/kabcore.cpp | 143 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 4 | ||||
-rw-r--r-- | korganizer/koprefs.h | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 25 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.cpp | 7 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.h | 3 | ||||
-rw-r--r-- | libkdepim/libkdepim.pro | 6 | ||||
-rw-r--r-- | libkdepim/libkdepimE.pro | 6 | ||||
-rw-r--r-- | libkdepim/phoneaccess.cpp | 153 | ||||
-rw-r--r-- | libkdepim/phoneaccess.h | 42 |
11 files changed, 371 insertions, 23 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index f8359de..185cf46 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2662 +1,2805 @@ | |||
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 | 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 | #include <kfiledialog.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | ||
38 | #include <qlineedit.h> | ||
39 | #include <qcheckbox.h> | ||
40 | #include <qpushbutton.h> | ||
37 | #include <qprogressbar.h> | 41 | #include <qprogressbar.h> |
38 | 42 | ||
39 | #ifndef KAB_EMBEDDED | 43 | #ifndef KAB_EMBEDDED |
40 | #include <qclipboard.h> | 44 | #include <qclipboard.h> |
41 | #include <qdir.h> | 45 | #include <qdir.h> |
42 | #include <qfile.h> | 46 | #include <qfile.h> |
43 | #include <qapplicaton.h> | 47 | #include <qapplicaton.h> |
44 | #include <qprogressbar.h> | 48 | #include <qprogressbar.h> |
45 | #include <qlayout.h> | 49 | #include <qlayout.h> |
46 | #include <qregexp.h> | 50 | #include <qregexp.h> |
47 | #include <qvbox.h> | 51 | #include <qvbox.h> |
48 | #include <kabc/addresseelist.h> | 52 | #include <kabc/addresseelist.h> |
49 | #include <kabc/errorhandler.h> | 53 | #include <kabc/errorhandler.h> |
50 | #include <kabc/resource.h> | 54 | #include <kabc/resource.h> |
51 | #include <kabc/vcardconverter.h> | 55 | #include <kabc/vcardconverter.h> |
52 | #include <kapplication.h> | 56 | #include <kapplication.h> |
53 | #include <kactionclasses.h> | 57 | #include <kactionclasses.h> |
54 | #include <kcmultidialog.h> | 58 | #include <kcmultidialog.h> |
55 | #include <kdebug.h> | 59 | #include <kdebug.h> |
56 | #include <kdeversion.h> | 60 | #include <kdeversion.h> |
57 | #include <kkeydialog.h> | 61 | #include <kkeydialog.h> |
58 | #include <kmessagebox.h> | 62 | #include <kmessagebox.h> |
59 | #include <kprinter.h> | 63 | #include <kprinter.h> |
60 | #include <kprotocolinfo.h> | 64 | #include <kprotocolinfo.h> |
61 | #include <kresources/selectdialog.h> | 65 | #include <kresources/selectdialog.h> |
62 | #include <kstandarddirs.h> | 66 | #include <kstandarddirs.h> |
63 | #include <ktempfile.h> | 67 | #include <ktempfile.h> |
64 | #include <kxmlguiclient.h> | 68 | #include <kxmlguiclient.h> |
65 | #include <kaboutdata.h> | 69 | #include <kaboutdata.h> |
66 | #include <libkdepim/categoryselectdialog.h> | 70 | #include <libkdepim/categoryselectdialog.h> |
67 | 71 | ||
68 | #include "addresseeutil.h" | 72 | #include "addresseeutil.h" |
69 | #include "addresseeeditordialog.h" | 73 | #include "addresseeeditordialog.h" |
70 | #include "extensionmanager.h" | 74 | #include "extensionmanager.h" |
71 | #include "kstdaction.h" | 75 | #include "kstdaction.h" |
72 | #include "kaddressbookservice.h" | 76 | #include "kaddressbookservice.h" |
73 | #include "ldapsearchdialog.h" | 77 | #include "ldapsearchdialog.h" |
74 | #include "printing/printingwizard.h" | 78 | #include "printing/printingwizard.h" |
75 | #else // KAB_EMBEDDED | 79 | #else // KAB_EMBEDDED |
76 | 80 | ||
77 | #include <kapplication.h> | 81 | #include <kapplication.h> |
78 | #include "KDGanttMinimizeSplitter.h" | 82 | #include "KDGanttMinimizeSplitter.h" |
79 | #include "kaddressbookmain.h" | 83 | #include "kaddressbookmain.h" |
80 | #include "kactioncollection.h" | 84 | #include "kactioncollection.h" |
81 | #include "addresseedialog.h" | 85 | #include "addresseedialog.h" |
82 | //US | 86 | //US |
83 | #include <addresseeview.h> | 87 | #include <addresseeview.h> |
84 | 88 | ||
85 | #include <qapp.h> | 89 | #include <qapp.h> |
86 | #include <qmenubar.h> | 90 | #include <qmenubar.h> |
87 | //#include <qtoolbar.h> | 91 | //#include <qtoolbar.h> |
88 | #include <qmessagebox.h> | 92 | #include <qmessagebox.h> |
89 | #include <kdebug.h> | 93 | #include <kdebug.h> |
90 | #include <kiconloader.h> // needed for SmallIcon | 94 | #include <kiconloader.h> // needed for SmallIcon |
91 | #include <kresources/kcmkresources.h> | 95 | #include <kresources/kcmkresources.h> |
92 | #include <ktoolbar.h> | 96 | #include <ktoolbar.h> |
93 | 97 | ||
94 | 98 | ||
95 | //#include <qlabel.h> | 99 | //#include <qlabel.h> |
96 | 100 | ||
97 | 101 | ||
98 | #ifndef DESKTOP_VERSION | 102 | #ifndef DESKTOP_VERSION |
99 | #include <qpe/ir.h> | 103 | #include <qpe/ir.h> |
100 | #include <qpe/qpemenubar.h> | 104 | #include <qpe/qpemenubar.h> |
101 | #include <qtopia/qcopenvelope_qws.h> | 105 | #include <qtopia/qcopenvelope_qws.h> |
102 | #else | 106 | #else |
103 | 107 | ||
104 | #include <qmenubar.h> | 108 | #include <qmenubar.h> |
105 | #endif | 109 | #endif |
106 | 110 | ||
107 | #endif // KAB_EMBEDDED | 111 | #endif // KAB_EMBEDDED |
108 | #include "kcmconfigs/kcmkabconfig.h" | 112 | #include "kcmconfigs/kcmkabconfig.h" |
109 | #include "kcmconfigs/kcmkdepimconfig.h" | 113 | #include "kcmconfigs/kcmkdepimconfig.h" |
110 | #include "kpimglobalprefs.h" | 114 | #include "kpimglobalprefs.h" |
111 | #include "externalapphandler.h" | 115 | #include "externalapphandler.h" |
112 | 116 | ||
113 | 117 | ||
114 | #include <kresources/selectdialog.h> | 118 | #include <kresources/selectdialog.h> |
115 | #include <kmessagebox.h> | 119 | #include <kmessagebox.h> |
116 | 120 | ||
117 | #include <picture.h> | 121 | #include <picture.h> |
118 | #include <resource.h> | 122 | #include <resource.h> |
119 | 123 | ||
120 | //US#include <qsplitter.h> | 124 | //US#include <qsplitter.h> |
121 | #include <qmap.h> | 125 | #include <qmap.h> |
122 | #include <qdir.h> | 126 | #include <qdir.h> |
123 | #include <qfile.h> | 127 | #include <qfile.h> |
124 | #include <qvbox.h> | 128 | #include <qvbox.h> |
125 | #include <qlayout.h> | 129 | #include <qlayout.h> |
126 | #include <qclipboard.h> | 130 | #include <qclipboard.h> |
127 | #include <qtextstream.h> | 131 | #include <qtextstream.h> |
128 | 132 | ||
129 | #include <libkdepim/categoryselectdialog.h> | 133 | #include <libkdepim/categoryselectdialog.h> |
130 | #include <kabc/vcardconverter.h> | 134 | #include <kabc/vcardconverter.h> |
131 | 135 | ||
132 | 136 | ||
133 | #include "addresseeutil.h" | 137 | #include "addresseeutil.h" |
134 | #include "undocmds.h" | 138 | #include "undocmds.h" |
135 | #include "addresseeeditordialog.h" | 139 | #include "addresseeeditordialog.h" |
136 | #include "viewmanager.h" | 140 | #include "viewmanager.h" |
137 | #include "details/detailsviewcontainer.h" | 141 | #include "details/detailsviewcontainer.h" |
138 | #include "kabprefs.h" | 142 | #include "kabprefs.h" |
139 | #include "xxportmanager.h" | 143 | #include "xxportmanager.h" |
140 | #include "incsearchwidget.h" | 144 | #include "incsearchwidget.h" |
141 | #include "jumpbuttonbar.h" | 145 | #include "jumpbuttonbar.h" |
142 | #include "extensionmanager.h" | 146 | #include "extensionmanager.h" |
143 | #include "addresseeconfig.h" | 147 | #include "addresseeconfig.h" |
144 | #include <kcmultidialog.h> | 148 | #include <kcmultidialog.h> |
145 | 149 | ||
146 | #ifdef _WIN32_ | 150 | #ifdef _WIN32_ |
147 | 151 | ||
148 | #include "kaimportoldialog.h" | 152 | #include "kaimportoldialog.h" |
149 | #else | 153 | #else |
150 | #include <unistd.h> | 154 | #include <unistd.h> |
151 | #endif | 155 | #endif |
152 | // sync includes | 156 | // sync includes |
153 | #include <libkdepim/ksyncprofile.h> | 157 | #include <libkdepim/ksyncprofile.h> |
154 | #include <libkdepim/ksyncprefsdialog.h> | 158 | #include <libkdepim/ksyncprefsdialog.h> |
155 | 159 | ||
160 | class KAex2phonePrefs : public QDialog | ||
161 | { | ||
162 | public: | ||
163 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | ||
164 | QDialog( parent, name, true ) | ||
165 | { | ||
166 | setCaption( i18n("Export to phone options") ); | ||
167 | QVBoxLayout* lay = new QVBoxLayout( this ); | ||
168 | lay->setSpacing( 3 ); | ||
169 | lay->setMargin( 3 ); | ||
170 | QLabel *lab; | ||
171 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | ||
172 | lab->setAlignment (AlignHCenter ); | ||
173 | QHBox* temphb; | ||
174 | temphb = new QHBox( this ); | ||
175 | new QLabel( i18n("I/O device: "), temphb ); | ||
176 | mPhoneDevice = new QLineEdit( temphb); | ||
177 | lay->addWidget( temphb ); | ||
178 | temphb = new QHBox( this ); | ||
179 | new QLabel( i18n("Connection: "), temphb ); | ||
180 | mPhoneConnection = new QLineEdit( temphb); | ||
181 | lay->addWidget( temphb ); | ||
182 | temphb = new QHBox( this ); | ||
183 | new QLabel( i18n("Model(opt.): "), temphb ); | ||
184 | mPhoneModel = new QLineEdit( temphb); | ||
185 | lay->addWidget( temphb ); | ||
186 | mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | ||
187 | lay->addWidget( mWriteToSim ); | ||
188 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | ||
189 | lab->setAlignment (AlignHCenter ); | ||
190 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | ||
191 | lay->addWidget( ok ); | ||
192 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | ||
193 | lay->addWidget( cancel ); | ||
194 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | ||
195 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | ||
196 | resize( 220, 240 ); | ||
197 | |||
198 | } | ||
199 | |||
200 | public: | ||
201 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | ||
202 | QCheckBox* mWriteToSim; | ||
203 | }; | ||
156 | 204 | ||
157 | bool pasteWithNewUid = true; | 205 | bool pasteWithNewUid = true; |
158 | 206 | ||
159 | #ifdef KAB_EMBEDDED | 207 | #ifdef KAB_EMBEDDED |
160 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 208 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
161 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 209 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
162 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 210 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
163 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 211 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
164 | #else //KAB_EMBEDDED | 212 | #else //KAB_EMBEDDED |
165 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 213 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
166 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 214 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
167 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 215 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
168 | mReadWrite( readWrite ), mModified( false ) | 216 | mReadWrite( readWrite ), mModified( false ) |
169 | #endif //KAB_EMBEDDED | 217 | #endif //KAB_EMBEDDED |
170 | { | 218 | { |
171 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 219 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
172 | // syncManager->setBlockSave(false); | 220 | // syncManager->setBlockSave(false); |
173 | mExtensionBarSplitter = 0; | 221 | mExtensionBarSplitter = 0; |
174 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 222 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
175 | 223 | ||
176 | mAddressBook = KABC::StdAddressBook::self(); | 224 | mAddressBook = KABC::StdAddressBook::self(); |
177 | KABC::StdAddressBook::setAutomaticSave( false ); | 225 | KABC::StdAddressBook::setAutomaticSave( false ); |
178 | 226 | ||
179 | #ifndef KAB_EMBEDDED | 227 | #ifndef KAB_EMBEDDED |
180 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 228 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
181 | #endif //KAB_EMBEDDED | 229 | #endif //KAB_EMBEDDED |
182 | 230 | ||
183 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 231 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
184 | SLOT( addressBookChanged() ) ); | 232 | SLOT( addressBookChanged() ) ); |
185 | 233 | ||
186 | #if 0 | 234 | #if 0 |
187 | // LP moved to addressbook init method | 235 | // LP moved to addressbook init method |
188 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 236 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
189 | "X-Department", "KADDRESSBOOK" ); | 237 | "X-Department", "KADDRESSBOOK" ); |
190 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 238 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
191 | "X-Profession", "KADDRESSBOOK" ); | 239 | "X-Profession", "KADDRESSBOOK" ); |
192 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 240 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
193 | "X-AssistantsName", "KADDRESSBOOK" ); | 241 | "X-AssistantsName", "KADDRESSBOOK" ); |
194 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 242 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
195 | "X-ManagersName", "KADDRESSBOOK" ); | 243 | "X-ManagersName", "KADDRESSBOOK" ); |
196 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 244 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
197 | "X-SpousesName", "KADDRESSBOOK" ); | 245 | "X-SpousesName", "KADDRESSBOOK" ); |
198 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 246 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
199 | "X-Office", "KADDRESSBOOK" ); | 247 | "X-Office", "KADDRESSBOOK" ); |
200 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 248 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
201 | "X-IMAddress", "KADDRESSBOOK" ); | 249 | "X-IMAddress", "KADDRESSBOOK" ); |
202 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 250 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
203 | "X-Anniversary", "KADDRESSBOOK" ); | 251 | "X-Anniversary", "KADDRESSBOOK" ); |
204 | 252 | ||
205 | //US added this field to become compatible with Opie/qtopia addressbook | 253 | //US added this field to become compatible with Opie/qtopia addressbook |
206 | // values can be "female" or "male" or "". An empty field represents undefined. | 254 | // values can be "female" or "male" or "". An empty field represents undefined. |
207 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 255 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
208 | "X-Gender", "KADDRESSBOOK" ); | 256 | "X-Gender", "KADDRESSBOOK" ); |
209 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 257 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
210 | "X-Children", "KADDRESSBOOK" ); | 258 | "X-Children", "KADDRESSBOOK" ); |
211 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 259 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
212 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 260 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
213 | #endif | 261 | #endif |
214 | initGUI(); | 262 | initGUI(); |
215 | 263 | ||
216 | mIncSearchWidget->setFocus(); | 264 | mIncSearchWidget->setFocus(); |
217 | 265 | ||
218 | 266 | ||
219 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 267 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
220 | SLOT( setContactSelected( const QString& ) ) ); | 268 | SLOT( setContactSelected( const QString& ) ) ); |
221 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 269 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
222 | SLOT( executeContact( const QString& ) ) ); | 270 | SLOT( executeContact( const QString& ) ) ); |
223 | 271 | ||
224 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 272 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
225 | SLOT( deleteContacts( ) ) ); | 273 | SLOT( deleteContacts( ) ) ); |
226 | connect( mViewManager, SIGNAL( modified() ), | 274 | connect( mViewManager, SIGNAL( modified() ), |
227 | SLOT( setModified() ) ); | 275 | SLOT( setModified() ) ); |
228 | 276 | ||
229 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 277 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
230 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 278 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
231 | 279 | ||
232 | connect( mXXPortManager, SIGNAL( modified() ), | 280 | connect( mXXPortManager, SIGNAL( modified() ), |
233 | SLOT( setModified() ) ); | 281 | SLOT( setModified() ) ); |
234 | 282 | ||
235 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 283 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
236 | SLOT( incrementalSearch( const QString& ) ) ); | 284 | SLOT( incrementalSearch( const QString& ) ) ); |
237 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 285 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
238 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 286 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
239 | 287 | ||
240 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 288 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
241 | SLOT( sendMail( const QString& ) ) ); | 289 | SLOT( sendMail( const QString& ) ) ); |
242 | 290 | ||
243 | 291 | ||
244 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 292 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
245 | 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&))); | 293 | 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&))); |
246 | 294 | ||
247 | 295 | ||
248 | #ifndef KAB_EMBEDDED | 296 | #ifndef KAB_EMBEDDED |
249 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 297 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
250 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 298 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
251 | 299 | ||
252 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 300 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
253 | SLOT( browse( const QString& ) ) ); | 301 | SLOT( browse( const QString& ) ) ); |
254 | 302 | ||
255 | 303 | ||
256 | mAddressBookService = new KAddressBookService( this ); | 304 | mAddressBookService = new KAddressBookService( this ); |
257 | 305 | ||
258 | #endif //KAB_EMBEDDED | 306 | #endif //KAB_EMBEDDED |
259 | mEditorDialog = 0; | 307 | mEditorDialog = 0; |
260 | createAddresseeEditorDialog( this ); | 308 | createAddresseeEditorDialog( this ); |
261 | setModified( false ); | 309 | setModified( false ); |
262 | } | 310 | } |
263 | 311 | ||
264 | KABCore::~KABCore() | 312 | KABCore::~KABCore() |
265 | { | 313 | { |
266 | // save(); | 314 | // save(); |
267 | //saveSettings(); | 315 | //saveSettings(); |
268 | //KABPrefs::instance()->writeConfig(); | 316 | //KABPrefs::instance()->writeConfig(); |
269 | delete AddresseeConfig::instance(); | 317 | delete AddresseeConfig::instance(); |
270 | mAddressBook = 0; | 318 | mAddressBook = 0; |
271 | KABC::StdAddressBook::close(); | 319 | KABC::StdAddressBook::close(); |
272 | 320 | ||
273 | delete syncManager; | 321 | delete syncManager; |
274 | } | 322 | } |
275 | 323 | ||
276 | void KABCore::restoreSettings() | 324 | void KABCore::restoreSettings() |
277 | { | 325 | { |
278 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 326 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
279 | 327 | ||
280 | bool state; | 328 | bool state; |
281 | 329 | ||
282 | if (mMultipleViewsAtOnce) | 330 | if (mMultipleViewsAtOnce) |
283 | state = KABPrefs::instance()->mDetailsPageVisible; | 331 | state = KABPrefs::instance()->mDetailsPageVisible; |
284 | else | 332 | else |
285 | state = false; | 333 | state = false; |
286 | 334 | ||
287 | mActionDetails->setChecked( state ); | 335 | mActionDetails->setChecked( state ); |
288 | setDetailsVisible( state ); | 336 | setDetailsVisible( state ); |
289 | 337 | ||
290 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 338 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
291 | 339 | ||
292 | mActionJumpBar->setChecked( state ); | 340 | mActionJumpBar->setChecked( state ); |
293 | setJumpButtonBarVisible( state ); | 341 | setJumpButtonBarVisible( state ); |
294 | /*US | 342 | /*US |
295 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 343 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
296 | if ( splitterSize.count() == 0 ) { | 344 | if ( splitterSize.count() == 0 ) { |
297 | splitterSize.append( width() / 2 ); | 345 | splitterSize.append( width() / 2 ); |
298 | splitterSize.append( width() / 2 ); | 346 | splitterSize.append( width() / 2 ); |
299 | } | 347 | } |
300 | mMiniSplitter->setSizes( splitterSize ); | 348 | mMiniSplitter->setSizes( splitterSize ); |
301 | if ( mExtensionBarSplitter ) { | 349 | if ( mExtensionBarSplitter ) { |
302 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 350 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
303 | if ( splitterSize.count() == 0 ) { | 351 | if ( splitterSize.count() == 0 ) { |
304 | splitterSize.append( width() / 2 ); | 352 | splitterSize.append( width() / 2 ); |
305 | splitterSize.append( width() / 2 ); | 353 | splitterSize.append( width() / 2 ); |
306 | } | 354 | } |
307 | mExtensionBarSplitter->setSizes( splitterSize ); | 355 | mExtensionBarSplitter->setSizes( splitterSize ); |
308 | 356 | ||
309 | } | 357 | } |
310 | */ | 358 | */ |
311 | mViewManager->restoreSettings(); | 359 | mViewManager->restoreSettings(); |
312 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 360 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
313 | mExtensionManager->restoreSettings(); | 361 | mExtensionManager->restoreSettings(); |
314 | #ifdef DESKTOP_VERSION | 362 | #ifdef DESKTOP_VERSION |
315 | int wid = width(); | 363 | int wid = width(); |
316 | if ( wid < 10 ) | 364 | if ( wid < 10 ) |
317 | wid = 400; | 365 | wid = 400; |
318 | #else | 366 | #else |
319 | int wid = QApplication::desktop()->width(); | 367 | int wid = QApplication::desktop()->width(); |
320 | if ( wid < 640 ) | 368 | if ( wid < 640 ) |
321 | wid = QApplication::desktop()->height(); | 369 | wid = QApplication::desktop()->height(); |
322 | #endif | 370 | #endif |
323 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 371 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
324 | if ( true /*splitterSize.count() == 0*/ ) { | 372 | if ( true /*splitterSize.count() == 0*/ ) { |
325 | splitterSize.append( wid / 2 ); | 373 | splitterSize.append( wid / 2 ); |
326 | splitterSize.append( wid / 2 ); | 374 | splitterSize.append( wid / 2 ); |
327 | } | 375 | } |
328 | mMiniSplitter->setSizes( splitterSize ); | 376 | mMiniSplitter->setSizes( splitterSize ); |
329 | if ( mExtensionBarSplitter ) { | 377 | if ( mExtensionBarSplitter ) { |
330 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 378 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
331 | if ( true /*splitterSize.count() == 0*/ ) { | 379 | if ( true /*splitterSize.count() == 0*/ ) { |
332 | splitterSize.append( wid / 2 ); | 380 | splitterSize.append( wid / 2 ); |
333 | splitterSize.append( wid / 2 ); | 381 | splitterSize.append( wid / 2 ); |
334 | } | 382 | } |
335 | mExtensionBarSplitter->setSizes( splitterSize ); | 383 | mExtensionBarSplitter->setSizes( splitterSize ); |
336 | 384 | ||
337 | } | 385 | } |
338 | 386 | ||
339 | 387 | ||
340 | } | 388 | } |
341 | 389 | ||
342 | void KABCore::saveSettings() | 390 | void KABCore::saveSettings() |
343 | { | 391 | { |
344 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 392 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
345 | if ( mExtensionBarSplitter ) | 393 | if ( mExtensionBarSplitter ) |
346 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 394 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
347 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 395 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
348 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 396 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
349 | #ifndef KAB_EMBEDDED | 397 | #ifndef KAB_EMBEDDED |
350 | 398 | ||
351 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 399 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
352 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 400 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
353 | #endif //KAB_EMBEDDED | 401 | #endif //KAB_EMBEDDED |
354 | mExtensionManager->saveSettings(); | 402 | mExtensionManager->saveSettings(); |
355 | mViewManager->saveSettings(); | 403 | mViewManager->saveSettings(); |
356 | 404 | ||
357 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 405 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
358 | } | 406 | } |
359 | 407 | ||
360 | KABC::AddressBook *KABCore::addressBook() const | 408 | KABC::AddressBook *KABCore::addressBook() const |
361 | { | 409 | { |
362 | return mAddressBook; | 410 | return mAddressBook; |
363 | } | 411 | } |
364 | 412 | ||
365 | KConfig *KABCore::config() | 413 | KConfig *KABCore::config() |
366 | { | 414 | { |
367 | #ifndef KAB_EMBEDDED | 415 | #ifndef KAB_EMBEDDED |
368 | return KABPrefs::instance()->config(); | 416 | return KABPrefs::instance()->config(); |
369 | #else //KAB_EMBEDDED | 417 | #else //KAB_EMBEDDED |
370 | return KABPrefs::instance()->getConfig(); | 418 | return KABPrefs::instance()->getConfig(); |
371 | #endif //KAB_EMBEDDED | 419 | #endif //KAB_EMBEDDED |
372 | } | 420 | } |
373 | 421 | ||
374 | KActionCollection *KABCore::actionCollection() const | 422 | KActionCollection *KABCore::actionCollection() const |
375 | { | 423 | { |
376 | return mGUIClient->actionCollection(); | 424 | return mGUIClient->actionCollection(); |
377 | } | 425 | } |
378 | 426 | ||
379 | KABC::Field *KABCore::currentSearchField() const | 427 | KABC::Field *KABCore::currentSearchField() const |
380 | { | 428 | { |
381 | if (mIncSearchWidget) | 429 | if (mIncSearchWidget) |
382 | return mIncSearchWidget->currentField(); | 430 | return mIncSearchWidget->currentField(); |
383 | else | 431 | else |
384 | return 0; | 432 | return 0; |
385 | } | 433 | } |
386 | 434 | ||
387 | QStringList KABCore::selectedUIDs() const | 435 | QStringList KABCore::selectedUIDs() const |
388 | { | 436 | { |
389 | return mViewManager->selectedUids(); | 437 | return mViewManager->selectedUids(); |
390 | } | 438 | } |
391 | 439 | ||
392 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 440 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
393 | { | 441 | { |
394 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 442 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
395 | 443 | ||
396 | QPtrList<KRES::Resource> kresResources; | 444 | QPtrList<KRES::Resource> kresResources; |
397 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 445 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
398 | KABC::Resource *resource; | 446 | KABC::Resource *resource; |
399 | while ( ( resource = resIt.current() ) != 0 ) { | 447 | while ( ( resource = resIt.current() ) != 0 ) { |
400 | ++resIt; | 448 | ++resIt; |
401 | if ( !resource->readOnly() ) { | 449 | if ( !resource->readOnly() ) { |
402 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 450 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
403 | if ( res ) | 451 | if ( res ) |
404 | kresResources.append( res ); | 452 | kresResources.append( res ); |
405 | } | 453 | } |
406 | } | 454 | } |
407 | 455 | ||
408 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 456 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
409 | return static_cast<KABC::Resource*>( res ); | 457 | return static_cast<KABC::Resource*>( res ); |
410 | } | 458 | } |
411 | 459 | ||
412 | #ifndef KAB_EMBEDDED | 460 | #ifndef KAB_EMBEDDED |
413 | KAboutData *KABCore::createAboutData() | 461 | KAboutData *KABCore::createAboutData() |
414 | #else //KAB_EMBEDDED | 462 | #else //KAB_EMBEDDED |
415 | void KABCore::createAboutData() | 463 | void KABCore::createAboutData() |
416 | #endif //KAB_EMBEDDED | 464 | #endif //KAB_EMBEDDED |
417 | { | 465 | { |
418 | #ifndef KAB_EMBEDDED | 466 | #ifndef KAB_EMBEDDED |
419 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 467 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
420 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 468 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
421 | KAboutData::License_GPL_V2, | 469 | KAboutData::License_GPL_V2, |
422 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 470 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
423 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 471 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
424 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 472 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
425 | about->addAuthor( "Cornelius Schumacher", | 473 | about->addAuthor( "Cornelius Schumacher", |
426 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 474 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
427 | "schumacher@kde.org" ); | 475 | "schumacher@kde.org" ); |
428 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 476 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
429 | "mpilone@slac.com" ); | 477 | "mpilone@slac.com" ); |
430 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 478 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
431 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 479 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
432 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 480 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
433 | "michel@klaralvdalens-datakonsult.se" ); | 481 | "michel@klaralvdalens-datakonsult.se" ); |
434 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 482 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
435 | "hansen@kde.org" ); | 483 | "hansen@kde.org" ); |
436 | 484 | ||
437 | return about; | 485 | return about; |
438 | #endif //KAB_EMBEDDED | 486 | #endif //KAB_EMBEDDED |
439 | 487 | ||
440 | QString version; | 488 | QString version; |
441 | #include <../version> | 489 | #include <../version> |
442 | QMessageBox::about( this, "About KAddressbook/Pi", | 490 | QMessageBox::about( this, "About KAddressbook/Pi", |
443 | "KAddressbook/Platform-independent\n" | 491 | "KAddressbook/Platform-independent\n" |
444 | "(KA/Pi) " +version + " - " + | 492 | "(KA/Pi) " +version + " - " + |
445 | #ifdef DESKTOP_VERSION | 493 | #ifdef DESKTOP_VERSION |
446 | "Desktop Edition\n" | 494 | "Desktop Edition\n" |
447 | #else | 495 | #else |
448 | "PDA-Edition\n" | 496 | "PDA-Edition\n" |
449 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 497 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
450 | #endif | 498 | #endif |
451 | 499 | ||
452 | "(c) 2004 Ulf Schenk\n" | 500 | "(c) 2004 Ulf Schenk\n" |
453 | "(c) 2004 Lutz Rogowski\n" | 501 | "(c) 2004 Lutz Rogowski\n" |
454 | "(c) 1997-2003, The KDE PIM Team\n" | 502 | "(c) 1997-2003, The KDE PIM Team\n" |
455 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 503 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
456 | "Don Sanders Original author\n" | 504 | "Don Sanders Original author\n" |
457 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 505 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
458 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 506 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
459 | "Greg Stern DCOP interface\n" | 507 | "Greg Stern DCOP interface\n" |
460 | "Mark Westcot Contact pinning\n" | 508 | "Mark Westcot Contact pinning\n" |
461 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 509 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
462 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 510 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
463 | #ifdef _WIN32_ | 511 | #ifdef _WIN32_ |
464 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 512 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
465 | #endif | 513 | #endif |
466 | ); | 514 | ); |
467 | } | 515 | } |
468 | 516 | ||
469 | void KABCore::setContactSelected( const QString &uid ) | 517 | void KABCore::setContactSelected( const QString &uid ) |
470 | { | 518 | { |
471 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 519 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
472 | if ( !mDetails->isHidden() ) | 520 | if ( !mDetails->isHidden() ) |
473 | mDetails->setAddressee( addr ); | 521 | mDetails->setAddressee( addr ); |
474 | 522 | ||
475 | if ( !addr.isEmpty() ) { | 523 | if ( !addr.isEmpty() ) { |
476 | emit contactSelected( addr.formattedName() ); | 524 | emit contactSelected( addr.formattedName() ); |
477 | KABC::Picture pic = addr.photo(); | 525 | KABC::Picture pic = addr.photo(); |
478 | if ( pic.isIntern() ) { | 526 | if ( pic.isIntern() ) { |
479 | //US emit contactSelected( pic.data() ); | 527 | //US emit contactSelected( pic.data() ); |
480 | //US instead use: | 528 | //US instead use: |
481 | QPixmap px; | 529 | QPixmap px; |
482 | if (pic.data().isNull() != true) | 530 | if (pic.data().isNull() != true) |
483 | { | 531 | { |
484 | px.convertFromImage(pic.data()); | 532 | px.convertFromImage(pic.data()); |
485 | } | 533 | } |
486 | 534 | ||
487 | emit contactSelected( px ); | 535 | emit contactSelected( px ); |
488 | } | 536 | } |
489 | } | 537 | } |
490 | 538 | ||
491 | 539 | ||
492 | mExtensionManager->setSelectionChanged(); | 540 | mExtensionManager->setSelectionChanged(); |
493 | 541 | ||
494 | // update the actions | 542 | // update the actions |
495 | bool selected = !uid.isEmpty(); | 543 | bool selected = !uid.isEmpty(); |
496 | 544 | ||
497 | if ( mReadWrite ) { | 545 | if ( mReadWrite ) { |
498 | mActionCut->setEnabled( selected ); | 546 | mActionCut->setEnabled( selected ); |
499 | mActionPaste->setEnabled( selected ); | 547 | mActionPaste->setEnabled( selected ); |
500 | } | 548 | } |
501 | 549 | ||
502 | mActionCopy->setEnabled( selected ); | 550 | mActionCopy->setEnabled( selected ); |
503 | mActionDelete->setEnabled( selected ); | 551 | mActionDelete->setEnabled( selected ); |
504 | mActionEditAddressee->setEnabled( selected ); | 552 | mActionEditAddressee->setEnabled( selected ); |
505 | mActionMail->setEnabled( selected ); | 553 | mActionMail->setEnabled( selected ); |
506 | mActionMailVCard->setEnabled( selected ); | 554 | mActionMailVCard->setEnabled( selected ); |
507 | //if (mActionBeam) | 555 | //if (mActionBeam) |
508 | //mActionBeam->setEnabled( selected ); | 556 | //mActionBeam->setEnabled( selected ); |
509 | 557 | ||
510 | if (mActionBeamVCard) | 558 | if (mActionBeamVCard) |
511 | mActionBeamVCard->setEnabled( selected ); | 559 | mActionBeamVCard->setEnabled( selected ); |
512 | 560 | ||
561 | mActionExport2phone->setEnabled( selected ); | ||
513 | mActionWhoAmI->setEnabled( selected ); | 562 | mActionWhoAmI->setEnabled( selected ); |
514 | mActionCategories->setEnabled( selected ); | 563 | mActionCategories->setEnabled( selected ); |
515 | } | 564 | } |
516 | 565 | ||
517 | void KABCore::sendMail() | 566 | void KABCore::sendMail() |
518 | { | 567 | { |
519 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 568 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
520 | } | 569 | } |
521 | 570 | ||
522 | void KABCore::sendMail( const QString& emaillist ) | 571 | void KABCore::sendMail( const QString& emaillist ) |
523 | { | 572 | { |
524 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 573 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
525 | if (emaillist.contains(",") > 0) | 574 | if (emaillist.contains(",") > 0) |
526 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 575 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
527 | else | 576 | else |
528 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 577 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
529 | } | 578 | } |
530 | 579 | ||
531 | 580 | ||
532 | 581 | ||
533 | void KABCore::mailVCard() | 582 | void KABCore::mailVCard() |
534 | { | 583 | { |
535 | QStringList uids = mViewManager->selectedUids(); | 584 | QStringList uids = mViewManager->selectedUids(); |
536 | if ( !uids.isEmpty() ) | 585 | if ( !uids.isEmpty() ) |
537 | mailVCard( uids ); | 586 | mailVCard( uids ); |
538 | } | 587 | } |
539 | 588 | ||
540 | void KABCore::mailVCard( const QStringList& uids ) | 589 | void KABCore::mailVCard( const QStringList& uids ) |
541 | { | 590 | { |
542 | QStringList urls; | 591 | QStringList urls; |
543 | 592 | ||
544 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 593 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
545 | 594 | ||
546 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 595 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
547 | 596 | ||
548 | 597 | ||
549 | 598 | ||
550 | QDir().mkdir( dirName, true ); | 599 | QDir().mkdir( dirName, true ); |
551 | 600 | ||
552 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 601 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
553 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 602 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
554 | 603 | ||
555 | if ( a.isEmpty() ) | 604 | if ( a.isEmpty() ) |
556 | continue; | 605 | continue; |
557 | 606 | ||
558 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 607 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
559 | 608 | ||
560 | QString fileName = dirName + "/" + name; | 609 | QString fileName = dirName + "/" + name; |
561 | 610 | ||
562 | QFile outFile(fileName); | 611 | QFile outFile(fileName); |
563 | 612 | ||
564 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 613 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
565 | KABC::VCardConverter converter; | 614 | KABC::VCardConverter converter; |
566 | QString vcard; | 615 | QString vcard; |
567 | 616 | ||
568 | converter.addresseeToVCard( a, vcard ); | 617 | converter.addresseeToVCard( a, vcard ); |
569 | 618 | ||
570 | QTextStream t( &outFile ); // use a text stream | 619 | QTextStream t( &outFile ); // use a text stream |
571 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 620 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
572 | t << vcard; | 621 | t << vcard; |
573 | 622 | ||
574 | outFile.close(); | 623 | outFile.close(); |
575 | 624 | ||
576 | urls.append( fileName ); | 625 | urls.append( fileName ); |
577 | } | 626 | } |
578 | } | 627 | } |
579 | 628 | ||
580 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 629 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
581 | 630 | ||
582 | 631 | ||
583 | /*US | 632 | /*US |
584 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 633 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
585 | QString::null, // subject | 634 | QString::null, // subject |
586 | QString::null, // body | 635 | QString::null, // body |
587 | QString::null, | 636 | QString::null, |
588 | urls ); // attachments | 637 | urls ); // attachments |
589 | */ | 638 | */ |
590 | 639 | ||
591 | } | 640 | } |
592 | 641 | ||
593 | /** | 642 | /** |
594 | Beams the "WhoAmI contact. | 643 | Beams the "WhoAmI contact. |
595 | */ | 644 | */ |
596 | void KABCore::beamMySelf() | 645 | void KABCore::beamMySelf() |
597 | { | 646 | { |
598 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 647 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
599 | if (!a.isEmpty()) | 648 | if (!a.isEmpty()) |
600 | { | 649 | { |
601 | QStringList uids; | 650 | QStringList uids; |
602 | uids << a.uid(); | 651 | uids << a.uid(); |
603 | 652 | ||
604 | beamVCard(uids); | 653 | beamVCard(uids); |
605 | } else { | 654 | } else { |
606 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 655 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
607 | 656 | ||
608 | 657 | ||
609 | } | 658 | } |
610 | } | 659 | } |
611 | 660 | ||
661 | void KABCore::export2phone() | ||
662 | { | ||
663 | |||
664 | KAex2phonePrefs ex2phone; | ||
665 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | ||
666 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | ||
667 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | ||
668 | |||
669 | if ( !ex2phone.exec() ) { | ||
670 | return; | ||
671 | } | ||
672 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | ||
673 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | ||
674 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | ||
675 | |||
676 | #if 0 | ||
677 | PhoneFormat::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | ||
678 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | ||
679 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | ||
680 | |||
681 | |||
682 | |||
683 | |||
684 | |||
685 | QString fileName = "/tmp/kapibeamfile.vcf"; | ||
686 | |||
687 | |||
688 | //QDir().mkdir( dirName, true ); | ||
689 | |||
690 | |||
691 | KABC::VCardConverter converter; | ||
692 | QString description; | ||
693 | QString datastream; | ||
694 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | ||
695 | KABC::Addressee a = mAddressBook->findByUid( *it ); | ||
696 | |||
697 | if ( a.isEmpty() ) | ||
698 | continue; | ||
699 | |||
700 | if (description.isEmpty()) | ||
701 | description = a.formattedName(); | ||
702 | |||
703 | QString vcard; | ||
704 | converter.addresseeToVCard( a, vcard ); | ||
705 | int start = 0; | ||
706 | int next; | ||
707 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | ||
708 | int semi = vcard.find(";", next); | ||
709 | int dopp = vcard.find(":", next); | ||
710 | int sep; | ||
711 | if ( semi < dopp && semi >= 0 ) | ||
712 | sep = semi ; | ||
713 | else | ||
714 | sep = dopp; | ||
715 | datastream +=vcard.mid( start, next - start); | ||
716 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | ||
717 | start = sep; | ||
718 | } | ||
719 | datastream += vcard.mid( start,vcard.length() ); | ||
720 | } | ||
721 | #ifndef DESKTOP_VERSION | ||
722 | QFile outFile(fileName); | ||
723 | if ( outFile.open(IO_WriteOnly) ) { | ||
724 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | ||
725 | QTextStream t( &outFile ); // use a text stream | ||
726 | t.setEncoding( QTextStream::UnicodeUTF8 ); | ||
727 | t <<datastream; | ||
728 | outFile.close(); | ||
729 | Ir *ir = new Ir( this ); | ||
730 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | ||
731 | ir->send( fileName, description, "text/x-vCard" ); | ||
732 | } else { | ||
733 | qDebug("Error open temp beam file "); | ||
734 | return; | ||
735 | } | ||
736 | #endif | ||
737 | |||
738 | |||
739 | |||
740 | |||
741 | setCaption( i18n("Writing to phone...")); | ||
742 | if ( PhoneFormat::writeToPhone( cal ) ) | ||
743 | setCaption( i18n("Export to phone successful!")); | ||
744 | else | ||
745 | setCaption( i18n("Error exporting to phone!")); | ||
746 | #endif | ||
747 | |||
748 | |||
749 | } | ||
612 | void KABCore::beamVCard() | 750 | void KABCore::beamVCard() |
613 | { | 751 | { |
614 | QStringList uids = mViewManager->selectedUids(); | 752 | QStringList uids = mViewManager->selectedUids(); |
615 | if ( !uids.isEmpty() ) | 753 | if ( !uids.isEmpty() ) |
616 | beamVCard( uids ); | 754 | beamVCard( uids ); |
617 | } | 755 | } |
618 | 756 | ||
619 | 757 | ||
620 | void KABCore::beamVCard(const QStringList& uids) | 758 | void KABCore::beamVCard(const QStringList& uids) |
621 | { | 759 | { |
622 | /*US | 760 | /*US |
623 | QString beamFilename; | 761 | QString beamFilename; |
624 | Opie::OPimContact c; | 762 | Opie::OPimContact c; |
625 | if ( actionPersonal->isOn() ) { | 763 | if ( actionPersonal->isOn() ) { |
626 | beamFilename = addressbookPersonalVCardName(); | 764 | beamFilename = addressbookPersonalVCardName(); |
627 | if ( !QFile::exists( beamFilename ) ) | 765 | if ( !QFile::exists( beamFilename ) ) |
628 | return; // can't beam a non-existent file | 766 | return; // can't beam a non-existent file |
629 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 767 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
630 | beamFilename ); | 768 | beamFilename ); |
631 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 769 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
632 | Opie::OPimContactAccess::List allList = access->allRecords(); | 770 | Opie::OPimContactAccess::List allList = access->allRecords(); |
633 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 771 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
634 | c = *it; | 772 | c = *it; |
635 | 773 | ||
636 | delete access; | 774 | delete access; |
637 | } else { | 775 | } else { |
638 | unlink( beamfile ); // delete if exists | 776 | unlink( beamfile ); // delete if exists |
639 | mkdir("/tmp/obex/", 0755); | 777 | mkdir("/tmp/obex/", 0755); |
640 | c = m_abView -> currentEntry(); | 778 | c = m_abView -> currentEntry(); |
641 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 779 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
642 | beamfile ); | 780 | beamfile ); |
643 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 781 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
644 | access->add( c ); | 782 | access->add( c ); |
645 | access->save(); | 783 | access->save(); |
646 | delete access; | 784 | delete access; |
647 | 785 | ||
648 | beamFilename = beamfile; | 786 | beamFilename = beamfile; |
649 | } | 787 | } |
650 | 788 | ||
651 | owarn << "Beaming: " << beamFilename << oendl; | 789 | owarn << "Beaming: " << beamFilename << oendl; |
652 | */ | 790 | */ |
653 | 791 | ||
654 | #if 0 | 792 | #if 0 |
655 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 793 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
656 | 794 | ||
657 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 795 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
658 | 796 | ||
659 | QString name = "contact.vcf"; | 797 | QString name = "contact.vcf"; |
660 | 798 | ||
661 | QString fileName = dirName + "/" + name; | 799 | QString fileName = dirName + "/" + name; |
662 | #endif | 800 | #endif |
663 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 801 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
664 | // | 802 | // |
665 | QString fileName = "/tmp/kapibeamfile.vcf"; | 803 | QString fileName = "/tmp/kapibeamfile.vcf"; |
666 | 804 | ||
667 | 805 | ||
668 | //QDir().mkdir( dirName, true ); | 806 | //QDir().mkdir( dirName, true ); |
669 | 807 | ||
670 | 808 | ||
671 | KABC::VCardConverter converter; | 809 | KABC::VCardConverter converter; |
672 | QString description; | 810 | QString description; |
673 | QString datastream; | 811 | QString datastream; |
674 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 812 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
675 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 813 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
676 | 814 | ||
677 | if ( a.isEmpty() ) | 815 | if ( a.isEmpty() ) |
678 | continue; | 816 | continue; |
679 | 817 | ||
680 | if (description.isEmpty()) | 818 | if (description.isEmpty()) |
681 | description = a.formattedName(); | 819 | description = a.formattedName(); |
682 | 820 | ||
683 | QString vcard; | 821 | QString vcard; |
684 | converter.addresseeToVCard( a, vcard ); | 822 | converter.addresseeToVCard( a, vcard ); |
685 | int start = 0; | 823 | int start = 0; |
686 | int next; | 824 | int next; |
687 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 825 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
688 | int semi = vcard.find(";", next); | 826 | int semi = vcard.find(";", next); |
689 | int dopp = vcard.find(":", next); | 827 | int dopp = vcard.find(":", next); |
690 | int sep; | 828 | int sep; |
691 | if ( semi < dopp && semi >= 0 ) | 829 | if ( semi < dopp && semi >= 0 ) |
692 | sep = semi ; | 830 | sep = semi ; |
693 | else | 831 | else |
694 | sep = dopp; | 832 | sep = dopp; |
695 | datastream +=vcard.mid( start, next - start); | 833 | datastream +=vcard.mid( start, next - start); |
696 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 834 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
697 | start = sep; | 835 | start = sep; |
698 | } | 836 | } |
699 | datastream += vcard.mid( start,vcard.length() ); | 837 | datastream += vcard.mid( start,vcard.length() ); |
700 | } | 838 | } |
701 | #ifndef DESKTOP_VERSION | 839 | #ifndef DESKTOP_VERSION |
702 | QFile outFile(fileName); | 840 | QFile outFile(fileName); |
703 | if ( outFile.open(IO_WriteOnly) ) { | 841 | if ( outFile.open(IO_WriteOnly) ) { |
704 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 842 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
705 | QTextStream t( &outFile ); // use a text stream | 843 | QTextStream t( &outFile ); // use a text stream |
706 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 844 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
707 | t <<datastream; | 845 | t <<datastream; |
708 | outFile.close(); | 846 | outFile.close(); |
709 | Ir *ir = new Ir( this ); | 847 | Ir *ir = new Ir( this ); |
710 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 848 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
711 | ir->send( fileName, description, "text/x-vCard" ); | 849 | ir->send( fileName, description, "text/x-vCard" ); |
712 | } else { | 850 | } else { |
713 | qDebug("Error open temp beam file "); | 851 | qDebug("Error open temp beam file "); |
714 | return; | 852 | return; |
715 | } | 853 | } |
716 | #endif | 854 | #endif |
717 | 855 | ||
718 | } | 856 | } |
719 | 857 | ||
720 | void KABCore::beamDone( Ir *ir ) | 858 | void KABCore::beamDone( Ir *ir ) |
721 | { | 859 | { |
722 | #ifndef DESKTOP_VERSION | 860 | #ifndef DESKTOP_VERSION |
723 | delete ir; | 861 | delete ir; |
724 | #endif | 862 | #endif |
725 | } | 863 | } |
726 | 864 | ||
727 | 865 | ||
728 | void KABCore::browse( const QString& url ) | 866 | void KABCore::browse( const QString& url ) |
729 | { | 867 | { |
730 | #ifndef KAB_EMBEDDED | 868 | #ifndef KAB_EMBEDDED |
731 | kapp->invokeBrowser( url ); | 869 | kapp->invokeBrowser( url ); |
732 | #else //KAB_EMBEDDED | 870 | #else //KAB_EMBEDDED |
733 | qDebug("KABCore::browse must be fixed"); | 871 | qDebug("KABCore::browse must be fixed"); |
734 | #endif //KAB_EMBEDDED | 872 | #endif //KAB_EMBEDDED |
735 | } | 873 | } |
736 | 874 | ||
737 | void KABCore::selectAllContacts() | 875 | void KABCore::selectAllContacts() |
738 | { | 876 | { |
739 | mViewManager->setSelected( QString::null, true ); | 877 | mViewManager->setSelected( QString::null, true ); |
740 | } | 878 | } |
741 | 879 | ||
742 | void KABCore::deleteContacts() | 880 | void KABCore::deleteContacts() |
743 | { | 881 | { |
744 | QStringList uidList = mViewManager->selectedUids(); | 882 | QStringList uidList = mViewManager->selectedUids(); |
745 | deleteContacts( uidList ); | 883 | deleteContacts( uidList ); |
746 | } | 884 | } |
747 | 885 | ||
748 | void KABCore::deleteContacts( const QStringList &uids ) | 886 | void KABCore::deleteContacts( const QStringList &uids ) |
749 | { | 887 | { |
750 | if ( uids.count() > 0 ) { | 888 | if ( uids.count() > 0 ) { |
751 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 889 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
752 | UndoStack::instance()->push( command ); | 890 | UndoStack::instance()->push( command ); |
753 | RedoStack::instance()->clear(); | 891 | RedoStack::instance()->clear(); |
754 | 892 | ||
755 | // now if we deleted anything, refresh | 893 | // now if we deleted anything, refresh |
756 | setContactSelected( QString::null ); | 894 | setContactSelected( QString::null ); |
757 | setModified( true ); | 895 | setModified( true ); |
758 | } | 896 | } |
759 | } | 897 | } |
760 | 898 | ||
761 | void KABCore::copyContacts() | 899 | void KABCore::copyContacts() |
762 | { | 900 | { |
763 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 901 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
764 | 902 | ||
765 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 903 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
766 | 904 | ||
767 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 905 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
768 | 906 | ||
769 | QClipboard *cb = QApplication::clipboard(); | 907 | QClipboard *cb = QApplication::clipboard(); |
770 | cb->setText( clipText ); | 908 | cb->setText( clipText ); |
771 | } | 909 | } |
772 | 910 | ||
773 | void KABCore::cutContacts() | 911 | void KABCore::cutContacts() |
774 | { | 912 | { |
775 | QStringList uidList = mViewManager->selectedUids(); | 913 | QStringList uidList = mViewManager->selectedUids(); |
776 | 914 | ||
777 | //US if ( uidList.size() > 0 ) { | 915 | //US if ( uidList.size() > 0 ) { |
778 | if ( uidList.count() > 0 ) { | 916 | if ( uidList.count() > 0 ) { |
779 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 917 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
780 | UndoStack::instance()->push( command ); | 918 | UndoStack::instance()->push( command ); |
781 | RedoStack::instance()->clear(); | 919 | RedoStack::instance()->clear(); |
782 | 920 | ||
783 | setModified( true ); | 921 | setModified( true ); |
784 | } | 922 | } |
785 | } | 923 | } |
786 | 924 | ||
787 | void KABCore::pasteContacts() | 925 | void KABCore::pasteContacts() |
788 | { | 926 | { |
789 | QClipboard *cb = QApplication::clipboard(); | 927 | QClipboard *cb = QApplication::clipboard(); |
790 | 928 | ||
791 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 929 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
792 | 930 | ||
793 | pasteContacts( list ); | 931 | pasteContacts( list ); |
794 | } | 932 | } |
795 | 933 | ||
796 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 934 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
797 | { | 935 | { |
798 | KABC::Resource *resource = requestResource( this ); | 936 | KABC::Resource *resource = requestResource( this ); |
799 | KABC::Addressee::List::Iterator it; | 937 | KABC::Addressee::List::Iterator it; |
800 | for ( it = list.begin(); it != list.end(); ++it ) | 938 | for ( it = list.begin(); it != list.end(); ++it ) |
801 | (*it).setResource( resource ); | 939 | (*it).setResource( resource ); |
802 | 940 | ||
803 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 941 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
804 | UndoStack::instance()->push( command ); | 942 | UndoStack::instance()->push( command ); |
805 | RedoStack::instance()->clear(); | 943 | RedoStack::instance()->clear(); |
806 | 944 | ||
807 | setModified( true ); | 945 | setModified( true ); |
808 | } | 946 | } |
809 | 947 | ||
810 | void KABCore::setWhoAmI() | 948 | void KABCore::setWhoAmI() |
811 | { | 949 | { |
812 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 950 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
813 | 951 | ||
814 | if ( addrList.count() > 1 ) { | 952 | if ( addrList.count() > 1 ) { |
815 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 953 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
816 | return; | 954 | return; |
817 | } | 955 | } |
818 | 956 | ||
819 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 957 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
820 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 958 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
821 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 959 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
822 | } | 960 | } |
823 | 961 | ||
824 | void KABCore::setCategories() | 962 | void KABCore::setCategories() |
825 | { | 963 | { |
826 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 964 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
827 | if ( !dlg.exec() ) | 965 | if ( !dlg.exec() ) |
828 | return; | 966 | return; |
829 | 967 | ||
830 | bool merge = false; | 968 | bool merge = false; |
831 | QString msg = i18n( "Merge with existing categories?" ); | 969 | QString msg = i18n( "Merge with existing categories?" ); |
832 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 970 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
833 | merge = true; | 971 | merge = true; |
834 | 972 | ||
835 | QStringList categories = dlg.selectedCategories(); | 973 | QStringList categories = dlg.selectedCategories(); |
836 | 974 | ||
837 | QStringList uids = mViewManager->selectedUids(); | 975 | QStringList uids = mViewManager->selectedUids(); |
838 | QStringList::Iterator it; | 976 | QStringList::Iterator it; |
839 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 977 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
840 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 978 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
841 | if ( !addr.isEmpty() ) { | 979 | if ( !addr.isEmpty() ) { |
842 | if ( !merge ) | 980 | if ( !merge ) |
843 | addr.setCategories( categories ); | 981 | addr.setCategories( categories ); |
844 | else { | 982 | else { |
845 | QStringList addrCategories = addr.categories(); | 983 | QStringList addrCategories = addr.categories(); |
846 | QStringList::Iterator catIt; | 984 | QStringList::Iterator catIt; |
847 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 985 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
848 | if ( !addrCategories.contains( *catIt ) ) | 986 | if ( !addrCategories.contains( *catIt ) ) |
849 | addrCategories.append( *catIt ); | 987 | addrCategories.append( *catIt ); |
850 | } | 988 | } |
851 | addr.setCategories( addrCategories ); | 989 | addr.setCategories( addrCategories ); |
852 | } | 990 | } |
853 | 991 | ||
854 | mAddressBook->insertAddressee( addr ); | 992 | mAddressBook->insertAddressee( addr ); |
855 | } | 993 | } |
856 | } | 994 | } |
857 | 995 | ||
858 | if ( uids.count() > 0 ) | 996 | if ( uids.count() > 0 ) |
859 | setModified( true ); | 997 | setModified( true ); |
860 | } | 998 | } |
861 | 999 | ||
862 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1000 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
863 | { | 1001 | { |
864 | mIncSearchWidget->setFields( fields ); | 1002 | mIncSearchWidget->setFields( fields ); |
865 | } | 1003 | } |
866 | 1004 | ||
867 | void KABCore::incrementalSearch( const QString& text ) | 1005 | void KABCore::incrementalSearch( const QString& text ) |
868 | { | 1006 | { |
869 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1007 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
870 | } | 1008 | } |
871 | 1009 | ||
872 | void KABCore::setModified() | 1010 | void KABCore::setModified() |
873 | { | 1011 | { |
874 | setModified( true ); | 1012 | setModified( true ); |
875 | } | 1013 | } |
876 | 1014 | ||
877 | void KABCore::setModifiedWOrefresh() | 1015 | void KABCore::setModifiedWOrefresh() |
878 | { | 1016 | { |
879 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1017 | // qDebug("KABCore::setModifiedWOrefresh() "); |
880 | mModified = true; | 1018 | mModified = true; |
881 | mActionSave->setEnabled( mModified ); | 1019 | mActionSave->setEnabled( mModified ); |
882 | #ifdef DESKTOP_VERSION | 1020 | #ifdef DESKTOP_VERSION |
883 | mDetails->refreshView(); | 1021 | mDetails->refreshView(); |
884 | #endif | 1022 | #endif |
885 | 1023 | ||
886 | } | 1024 | } |
887 | void KABCore::setModified( bool modified ) | 1025 | void KABCore::setModified( bool modified ) |
888 | { | 1026 | { |
889 | mModified = modified; | 1027 | mModified = modified; |
890 | mActionSave->setEnabled( mModified ); | 1028 | mActionSave->setEnabled( mModified ); |
891 | 1029 | ||
892 | if ( modified ) | 1030 | if ( modified ) |
893 | mJumpButtonBar->recreateButtons(); | 1031 | mJumpButtonBar->recreateButtons(); |
894 | 1032 | ||
895 | mViewManager->refreshView(); | 1033 | mViewManager->refreshView(); |
896 | mDetails->refreshView(); | 1034 | mDetails->refreshView(); |
897 | 1035 | ||
898 | } | 1036 | } |
899 | 1037 | ||
900 | bool KABCore::modified() const | 1038 | bool KABCore::modified() const |
901 | { | 1039 | { |
902 | return mModified; | 1040 | return mModified; |
903 | } | 1041 | } |
904 | 1042 | ||
905 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1043 | void KABCore::contactModified( const KABC::Addressee &addr ) |
906 | { | 1044 | { |
907 | 1045 | ||
908 | Command *command = 0; | 1046 | Command *command = 0; |
909 | QString uid; | 1047 | QString uid; |
910 | 1048 | ||
911 | // check if it exists already | 1049 | // check if it exists already |
912 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1050 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
913 | if ( origAddr.isEmpty() ) | 1051 | if ( origAddr.isEmpty() ) |
914 | command = new PwNewCommand( mAddressBook, addr ); | 1052 | command = new PwNewCommand( mAddressBook, addr ); |
915 | else { | 1053 | else { |
916 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1054 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
917 | uid = addr.uid(); | 1055 | uid = addr.uid(); |
918 | } | 1056 | } |
919 | 1057 | ||
920 | UndoStack::instance()->push( command ); | 1058 | UndoStack::instance()->push( command ); |
921 | RedoStack::instance()->clear(); | 1059 | RedoStack::instance()->clear(); |
922 | 1060 | ||
923 | setModified( true ); | 1061 | setModified( true ); |
924 | } | 1062 | } |
925 | 1063 | ||
926 | void KABCore::newContact() | 1064 | void KABCore::newContact() |
927 | { | 1065 | { |
928 | 1066 | ||
929 | 1067 | ||
930 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1068 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
931 | 1069 | ||
932 | QPtrList<KRES::Resource> kresResources; | 1070 | QPtrList<KRES::Resource> kresResources; |
933 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1071 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
934 | KABC::Resource *resource; | 1072 | KABC::Resource *resource; |
935 | while ( ( resource = it.current() ) != 0 ) { | 1073 | while ( ( resource = it.current() ) != 0 ) { |
936 | ++it; | 1074 | ++it; |
937 | if ( !resource->readOnly() ) { | 1075 | if ( !resource->readOnly() ) { |
938 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1076 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
939 | if ( res ) | 1077 | if ( res ) |
940 | kresResources.append( res ); | 1078 | kresResources.append( res ); |
941 | } | 1079 | } |
942 | } | 1080 | } |
943 | 1081 | ||
944 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1082 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
945 | resource = static_cast<KABC::Resource*>( res ); | 1083 | resource = static_cast<KABC::Resource*>( res ); |
946 | 1084 | ||
947 | if ( resource ) { | 1085 | if ( resource ) { |
948 | KABC::Addressee addr; | 1086 | KABC::Addressee addr; |
949 | addr.setResource( resource ); | 1087 | addr.setResource( resource ); |
950 | mEditorDialog->setAddressee( addr ); | 1088 | mEditorDialog->setAddressee( addr ); |
951 | KApplication::execDialog ( mEditorDialog ); | 1089 | KApplication::execDialog ( mEditorDialog ); |
952 | 1090 | ||
953 | } else | 1091 | } else |
954 | return; | 1092 | return; |
955 | 1093 | ||
956 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1094 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
957 | 1095 | ||
958 | 1096 | ||
959 | } | 1097 | } |
960 | 1098 | ||
961 | void KABCore::addEmail( QString aStr ) | 1099 | void KABCore::addEmail( QString aStr ) |
962 | { | 1100 | { |
963 | #ifndef KAB_EMBEDDED | 1101 | #ifndef KAB_EMBEDDED |
964 | QString fullName, email; | 1102 | QString fullName, email; |
965 | 1103 | ||
966 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1104 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
967 | 1105 | ||
968 | // Try to lookup the addressee matching the email address | 1106 | // Try to lookup the addressee matching the email address |
969 | bool found = false; | 1107 | bool found = false; |
970 | QStringList emailList; | 1108 | QStringList emailList; |
971 | KABC::AddressBook::Iterator it; | 1109 | KABC::AddressBook::Iterator it; |
972 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1110 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
973 | emailList = (*it).emails(); | 1111 | emailList = (*it).emails(); |
974 | if ( emailList.contains( email ) > 0 ) { | 1112 | if ( emailList.contains( email ) > 0 ) { |
975 | found = true; | 1113 | found = true; |
976 | (*it).setNameFromString( fullName ); | 1114 | (*it).setNameFromString( fullName ); |
977 | editContact( (*it).uid() ); | 1115 | editContact( (*it).uid() ); |
978 | } | 1116 | } |
979 | } | 1117 | } |
980 | 1118 | ||
981 | if ( !found ) { | 1119 | if ( !found ) { |
982 | KABC::Addressee addr; | 1120 | KABC::Addressee addr; |
983 | addr.setNameFromString( fullName ); | 1121 | addr.setNameFromString( fullName ); |
984 | addr.insertEmail( email, true ); | 1122 | addr.insertEmail( email, true ); |
985 | 1123 | ||
986 | mAddressBook->insertAddressee( addr ); | 1124 | mAddressBook->insertAddressee( addr ); |
987 | mViewManager->refreshView( addr.uid() ); | 1125 | mViewManager->refreshView( addr.uid() ); |
988 | editContact( addr.uid() ); | 1126 | editContact( addr.uid() ); |
989 | } | 1127 | } |
990 | #else //KAB_EMBEDDED | 1128 | #else //KAB_EMBEDDED |
991 | qDebug("KABCore::addEmail finsih method"); | 1129 | qDebug("KABCore::addEmail finsih method"); |
992 | #endif //KAB_EMBEDDED | 1130 | #endif //KAB_EMBEDDED |
993 | } | 1131 | } |
994 | 1132 | ||
995 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1133 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
996 | { | 1134 | { |
997 | mXXPortManager->importVCard( url, showPreview ); | 1135 | mXXPortManager->importVCard( url, showPreview ); |
998 | } | 1136 | } |
999 | void KABCore::importFromOL() | 1137 | void KABCore::importFromOL() |
1000 | { | 1138 | { |
1001 | #ifdef _WIN32_ | 1139 | #ifdef _WIN32_ |
1002 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1140 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1003 | idgl->exec(); | 1141 | idgl->exec(); |
1004 | KABC::Addressee::List list = idgl->getAddressList(); | 1142 | KABC::Addressee::List list = idgl->getAddressList(); |
1005 | if ( list.count() > 0 ) { | 1143 | if ( list.count() > 0 ) { |
1006 | KABC::Addressee::List listNew; | 1144 | KABC::Addressee::List listNew; |
1007 | KABC::Addressee::List listExisting; | 1145 | KABC::Addressee::List listExisting; |
1008 | KABC::Addressee::List::Iterator it; | 1146 | KABC::Addressee::List::Iterator it; |
1009 | KABC::AddressBook::Iterator iter; | 1147 | KABC::AddressBook::Iterator iter; |
1010 | for ( it = list.begin(); it != list.end(); ++it ) { | 1148 | for ( it = list.begin(); it != list.end(); ++it ) { |
1011 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1149 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1012 | listNew.append( (*it) ); | 1150 | listNew.append( (*it) ); |
1013 | else | 1151 | else |
1014 | listExisting.append( (*it) ); | 1152 | listExisting.append( (*it) ); |
1015 | } | 1153 | } |
1016 | if ( listExisting.count() > 0 ) | 1154 | if ( listExisting.count() > 0 ) |
1017 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1155 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1018 | if ( listNew.count() > 0 ) { | 1156 | if ( listNew.count() > 0 ) { |
1019 | pasteWithNewUid = false; | 1157 | pasteWithNewUid = false; |
1020 | pasteContacts( listNew ); | 1158 | pasteContacts( listNew ); |
1021 | pasteWithNewUid = true; | 1159 | pasteWithNewUid = true; |
1022 | } | 1160 | } |
1023 | } | 1161 | } |
1024 | delete idgl; | 1162 | delete idgl; |
1025 | #endif | 1163 | #endif |
1026 | } | 1164 | } |
1027 | 1165 | ||
1028 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1166 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1029 | { | 1167 | { |
1030 | mXXPortManager->importVCard( vCard, showPreview ); | 1168 | mXXPortManager->importVCard( vCard, showPreview ); |
1031 | } | 1169 | } |
1032 | 1170 | ||
1033 | //US added a second method without defaultparameter | 1171 | //US added a second method without defaultparameter |
1034 | void KABCore::editContact2() { | 1172 | void KABCore::editContact2() { |
1035 | editContact( QString::null ); | 1173 | editContact( QString::null ); |
1036 | } | 1174 | } |
1037 | 1175 | ||
1038 | void KABCore::editContact( const QString &uid ) | 1176 | void KABCore::editContact( const QString &uid ) |
1039 | { | 1177 | { |
1040 | 1178 | ||
1041 | if ( mExtensionManager->isQuickEditVisible() ) | 1179 | if ( mExtensionManager->isQuickEditVisible() ) |
1042 | return; | 1180 | return; |
1043 | 1181 | ||
1044 | // First, locate the contact entry | 1182 | // First, locate the contact entry |
1045 | QString localUID = uid; | 1183 | QString localUID = uid; |
1046 | if ( localUID.isNull() ) { | 1184 | if ( localUID.isNull() ) { |
1047 | QStringList uidList = mViewManager->selectedUids(); | 1185 | QStringList uidList = mViewManager->selectedUids(); |
1048 | if ( uidList.count() > 0 ) | 1186 | if ( uidList.count() > 0 ) |
1049 | localUID = *( uidList.at( 0 ) ); | 1187 | localUID = *( uidList.at( 0 ) ); |
1050 | } | 1188 | } |
1051 | 1189 | ||
1052 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1190 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1053 | if ( !addr.isEmpty() ) { | 1191 | if ( !addr.isEmpty() ) { |
1054 | mEditorDialog->setAddressee( addr ); | 1192 | mEditorDialog->setAddressee( addr ); |
1055 | KApplication::execDialog ( mEditorDialog ); | 1193 | KApplication::execDialog ( mEditorDialog ); |
1056 | } | 1194 | } |
1057 | } | 1195 | } |
1058 | 1196 | ||
1059 | /** | 1197 | /** |
1060 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1198 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1061 | the method will try to find a selected addressee in the view. | 1199 | the method will try to find a selected addressee in the view. |
1062 | */ | 1200 | */ |
1063 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1201 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1064 | { | 1202 | { |
1065 | if ( mMultipleViewsAtOnce ) | 1203 | if ( mMultipleViewsAtOnce ) |
1066 | { | 1204 | { |
1067 | editContact( uid ); | 1205 | editContact( uid ); |
1068 | } | 1206 | } |
1069 | else | 1207 | else |
1070 | { | 1208 | { |
1071 | setDetailsVisible( true ); | 1209 | setDetailsVisible( true ); |
1072 | mActionDetails->setChecked(true); | 1210 | mActionDetails->setChecked(true); |
1073 | } | 1211 | } |
1074 | 1212 | ||
1075 | } | 1213 | } |
1076 | 1214 | ||
1077 | void KABCore::save() | 1215 | void KABCore::save() |
1078 | { | 1216 | { |
1079 | if (syncManager->blockSave()) | 1217 | if (syncManager->blockSave()) |
1080 | return; | 1218 | return; |
1081 | if ( !mModified ) | 1219 | if ( !mModified ) |
1082 | return; | 1220 | return; |
1083 | 1221 | ||
1084 | syncManager->setBlockSave(true); | 1222 | syncManager->setBlockSave(true); |
1085 | QString text = i18n( "There was an error while attempting to save\n the " | 1223 | QString text = i18n( "There was an error while attempting to save\n the " |
1086 | "address book. Please check that some \nother application is " | 1224 | "address book. Please check that some \nother application is " |
1087 | "not using it. " ); | 1225 | "not using it. " ); |
1088 | statusMessage(i18n("Saving addressbook ... ")); | 1226 | statusMessage(i18n("Saving addressbook ... ")); |
1089 | #ifndef KAB_EMBEDDED | 1227 | #ifndef KAB_EMBEDDED |
1090 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1228 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1091 | if ( !b || !b->save() ) { | 1229 | if ( !b || !b->save() ) { |
1092 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1230 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1093 | } | 1231 | } |
1094 | #else //KAB_EMBEDDED | 1232 | #else //KAB_EMBEDDED |
1095 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1233 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1096 | if ( !b || !b->save() ) { | 1234 | if ( !b || !b->save() ) { |
1097 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1235 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1098 | } | 1236 | } |
1099 | #endif //KAB_EMBEDDED | 1237 | #endif //KAB_EMBEDDED |
1100 | 1238 | ||
1101 | statusMessage(i18n("Addressbook saved!")); | 1239 | statusMessage(i18n("Addressbook saved!")); |
1102 | setModified( false ); | 1240 | setModified( false ); |
1103 | syncManager->setBlockSave(false); | 1241 | syncManager->setBlockSave(false); |
1104 | } | 1242 | } |
1105 | 1243 | ||
1106 | void KABCore::statusMessage(QString mess , int time ) | 1244 | void KABCore::statusMessage(QString mess , int time ) |
1107 | { | 1245 | { |
1108 | //topLevelWidget()->setCaption( mess ); | 1246 | //topLevelWidget()->setCaption( mess ); |
1109 | // pending setting timer to revome message | 1247 | // pending setting timer to revome message |
1110 | } | 1248 | } |
1111 | void KABCore::undo() | 1249 | void KABCore::undo() |
1112 | { | 1250 | { |
1113 | UndoStack::instance()->undo(); | 1251 | UndoStack::instance()->undo(); |
1114 | 1252 | ||
1115 | // Refresh the view | 1253 | // Refresh the view |
1116 | mViewManager->refreshView(); | 1254 | mViewManager->refreshView(); |
1117 | } | 1255 | } |
1118 | 1256 | ||
1119 | void KABCore::redo() | 1257 | void KABCore::redo() |
1120 | { | 1258 | { |
1121 | RedoStack::instance()->redo(); | 1259 | RedoStack::instance()->redo(); |
1122 | 1260 | ||
1123 | // Refresh the view | 1261 | // Refresh the view |
1124 | mViewManager->refreshView(); | 1262 | mViewManager->refreshView(); |
1125 | } | 1263 | } |
1126 | 1264 | ||
1127 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1265 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1128 | { | 1266 | { |
1129 | if (mMultipleViewsAtOnce) | 1267 | if (mMultipleViewsAtOnce) |
1130 | { | 1268 | { |
1131 | if ( visible ) | 1269 | if ( visible ) |
1132 | mJumpButtonBar->show(); | 1270 | mJumpButtonBar->show(); |
1133 | else | 1271 | else |
1134 | mJumpButtonBar->hide(); | 1272 | mJumpButtonBar->hide(); |
1135 | } | 1273 | } |
1136 | else | 1274 | else |
1137 | { | 1275 | { |
1138 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1276 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1139 | if (mViewManager->isVisible()) | 1277 | if (mViewManager->isVisible()) |
1140 | { | 1278 | { |
1141 | if ( visible ) | 1279 | if ( visible ) |
1142 | mJumpButtonBar->show(); | 1280 | mJumpButtonBar->show(); |
1143 | else | 1281 | else |
1144 | mJumpButtonBar->hide(); | 1282 | mJumpButtonBar->hide(); |
1145 | } | 1283 | } |
1146 | else | 1284 | else |
1147 | { | 1285 | { |
1148 | mJumpButtonBar->hide(); | 1286 | mJumpButtonBar->hide(); |
1149 | } | 1287 | } |
1150 | } | 1288 | } |
1151 | } | 1289 | } |
1152 | 1290 | ||
1153 | 1291 | ||
1154 | void KABCore::setDetailsToState() | 1292 | void KABCore::setDetailsToState() |
1155 | { | 1293 | { |
1156 | setDetailsVisible( mActionDetails->isChecked() ); | 1294 | setDetailsVisible( mActionDetails->isChecked() ); |
1157 | } | 1295 | } |
1158 | 1296 | ||
1159 | 1297 | ||
1160 | 1298 | ||
1161 | void KABCore::setDetailsVisible( bool visible ) | 1299 | void KABCore::setDetailsVisible( bool visible ) |
1162 | { | 1300 | { |
1163 | if (visible && mDetails->isHidden()) | 1301 | if (visible && mDetails->isHidden()) |
1164 | { | 1302 | { |
1165 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1303 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1166 | if ( addrList.count() > 0 ) | 1304 | if ( addrList.count() > 0 ) |
1167 | mDetails->setAddressee( addrList[ 0 ] ); | 1305 | mDetails->setAddressee( addrList[ 0 ] ); |
1168 | } | 1306 | } |
1169 | 1307 | ||
1170 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1308 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1171 | // the listview and the detailview. We do that by changing the splitbar size. | 1309 | // the listview and the detailview. We do that by changing the splitbar size. |
1172 | if (mMultipleViewsAtOnce) | 1310 | if (mMultipleViewsAtOnce) |
1173 | { | 1311 | { |
1174 | if ( visible ) | 1312 | if ( visible ) |
1175 | mDetails->show(); | 1313 | mDetails->show(); |
1176 | else | 1314 | else |
1177 | mDetails->hide(); | 1315 | mDetails->hide(); |
1178 | } | 1316 | } |
1179 | else | 1317 | else |
1180 | { | 1318 | { |
1181 | if ( visible ) { | 1319 | if ( visible ) { |
1182 | mViewManager->hide(); | 1320 | mViewManager->hide(); |
1183 | mDetails->show(); | 1321 | mDetails->show(); |
1184 | } | 1322 | } |
1185 | else { | 1323 | else { |
1186 | mViewManager->show(); | 1324 | mViewManager->show(); |
1187 | mDetails->hide(); | 1325 | mDetails->hide(); |
1188 | } | 1326 | } |
1189 | setJumpButtonBarVisible( !visible ); | 1327 | setJumpButtonBarVisible( !visible ); |
1190 | } | 1328 | } |
1191 | 1329 | ||
1192 | } | 1330 | } |
1193 | 1331 | ||
1194 | void KABCore::extensionChanged( int id ) | 1332 | void KABCore::extensionChanged( int id ) |
1195 | { | 1333 | { |
1196 | //change the details view only for non desktop systems | 1334 | //change the details view only for non desktop systems |
1197 | #ifndef DESKTOP_VERSION | 1335 | #ifndef DESKTOP_VERSION |
1198 | 1336 | ||
1199 | if (id == 0) | 1337 | if (id == 0) |
1200 | { | 1338 | { |
1201 | //the user disabled the extension. | 1339 | //the user disabled the extension. |
1202 | 1340 | ||
1203 | if (mMultipleViewsAtOnce) | 1341 | if (mMultipleViewsAtOnce) |
1204 | { // enable detailsview again | 1342 | { // enable detailsview again |
1205 | setDetailsVisible( true ); | 1343 | setDetailsVisible( true ); |
1206 | mActionDetails->setChecked( true ); | 1344 | mActionDetails->setChecked( true ); |
1207 | } | 1345 | } |
1208 | else | 1346 | else |
1209 | { //go back to the listview | 1347 | { //go back to the listview |
1210 | setDetailsVisible( false ); | 1348 | setDetailsVisible( false ); |
1211 | mActionDetails->setChecked( false ); | 1349 | mActionDetails->setChecked( false ); |
1212 | mActionDetails->setEnabled(true); | 1350 | mActionDetails->setEnabled(true); |
1213 | } | 1351 | } |
1214 | 1352 | ||
1215 | } | 1353 | } |
1216 | else | 1354 | else |
1217 | { | 1355 | { |
1218 | //the user enabled the extension. | 1356 | //the user enabled the extension. |
1219 | setDetailsVisible( false ); | 1357 | setDetailsVisible( false ); |
1220 | mActionDetails->setChecked( false ); | 1358 | mActionDetails->setChecked( false ); |
1221 | 1359 | ||
1222 | if (!mMultipleViewsAtOnce) | 1360 | if (!mMultipleViewsAtOnce) |
1223 | { | 1361 | { |
1224 | mActionDetails->setEnabled(false); | 1362 | mActionDetails->setEnabled(false); |
1225 | } | 1363 | } |
1226 | 1364 | ||
1227 | mExtensionManager->setSelectionChanged(); | 1365 | mExtensionManager->setSelectionChanged(); |
1228 | 1366 | ||
1229 | } | 1367 | } |
1230 | 1368 | ||
1231 | #endif// DESKTOP_VERSION | 1369 | #endif// DESKTOP_VERSION |
1232 | 1370 | ||
1233 | } | 1371 | } |
1234 | 1372 | ||
1235 | 1373 | ||
1236 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1374 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1237 | { | 1375 | { |
1238 | 1376 | ||
1239 | if ( list.count() != 0 ) { | 1377 | if ( list.count() != 0 ) { |
1240 | KABC::Addressee::List::ConstIterator it; | 1378 | KABC::Addressee::List::ConstIterator it; |
1241 | for ( it = list.begin(); it != list.end(); ++it ) | 1379 | for ( it = list.begin(); it != list.end(); ++it ) |
1242 | mAddressBook->insertAddressee( *it ); | 1380 | mAddressBook->insertAddressee( *it ); |
1243 | if ( list.count() > 1 ) | 1381 | if ( list.count() > 1 ) |
1244 | setModified(); | 1382 | setModified(); |
1245 | else | 1383 | else |
1246 | setModifiedWOrefresh(); | 1384 | setModifiedWOrefresh(); |
1247 | } | 1385 | } |
1248 | if ( list.count() == 0 ) | 1386 | if ( list.count() == 0 ) |
1249 | mViewManager->refreshView(); | 1387 | mViewManager->refreshView(); |
1250 | else | 1388 | else |
1251 | mViewManager->refreshView( list[ 0 ].uid() ); | 1389 | mViewManager->refreshView( list[ 0 ].uid() ); |
1252 | 1390 | ||
1253 | 1391 | ||
1254 | 1392 | ||
1255 | } | 1393 | } |
1256 | 1394 | ||
1257 | QString KABCore::getNameByPhone( const QString &phone ) | 1395 | QString KABCore::getNameByPhone( const QString &phone ) |
1258 | { | 1396 | { |
1259 | #ifndef KAB_EMBEDDED | 1397 | #ifndef KAB_EMBEDDED |
1260 | QRegExp r( "[/*/-/ ]" ); | 1398 | QRegExp r( "[/*/-/ ]" ); |
1261 | QString localPhone( phone ); | 1399 | QString localPhone( phone ); |
1262 | 1400 | ||
1263 | bool found = false; | 1401 | bool found = false; |
1264 | QString ownerName = ""; | 1402 | QString ownerName = ""; |
1265 | KABC::AddressBook::Iterator iter; | 1403 | KABC::AddressBook::Iterator iter; |
1266 | KABC::PhoneNumber::List::Iterator phoneIter; | 1404 | KABC::PhoneNumber::List::Iterator phoneIter; |
1267 | KABC::PhoneNumber::List phoneList; | 1405 | KABC::PhoneNumber::List phoneList; |
1268 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1406 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1269 | phoneList = (*iter).phoneNumbers(); | 1407 | phoneList = (*iter).phoneNumbers(); |
1270 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1408 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1271 | ++phoneIter) { | 1409 | ++phoneIter) { |
1272 | // Get rid of separator chars so just the numbers are compared. | 1410 | // Get rid of separator chars so just the numbers are compared. |
1273 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1411 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1274 | ownerName = (*iter).formattedName(); | 1412 | ownerName = (*iter).formattedName(); |
1275 | found = true; | 1413 | found = true; |
1276 | } | 1414 | } |
1277 | } | 1415 | } |
1278 | } | 1416 | } |
1279 | 1417 | ||
1280 | return ownerName; | 1418 | return ownerName; |
1281 | #else //KAB_EMBEDDED | 1419 | #else //KAB_EMBEDDED |
1282 | qDebug("KABCore::getNameByPhone finsih method"); | 1420 | qDebug("KABCore::getNameByPhone finsih method"); |
1283 | return ""; | 1421 | return ""; |
1284 | #endif //KAB_EMBEDDED | 1422 | #endif //KAB_EMBEDDED |
1285 | 1423 | ||
1286 | } | 1424 | } |
1287 | 1425 | ||
1288 | void KABCore::openConfigDialog() | 1426 | void KABCore::openConfigDialog() |
1289 | { | 1427 | { |
1290 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1428 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1291 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1429 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1292 | ConfigureDialog->addModule(kabcfg ); | 1430 | ConfigureDialog->addModule(kabcfg ); |
1293 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1431 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1294 | ConfigureDialog->addModule(kdelibcfg ); | 1432 | ConfigureDialog->addModule(kdelibcfg ); |
1295 | 1433 | ||
1296 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1434 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1297 | this, SLOT( configurationChanged() ) ); | 1435 | this, SLOT( configurationChanged() ) ); |
1298 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1436 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1299 | this, SLOT( configurationChanged() ) ); | 1437 | this, SLOT( configurationChanged() ) ); |
1300 | saveSettings(); | 1438 | saveSettings(); |
1301 | #ifndef DESKTOP_VERSION | 1439 | #ifndef DESKTOP_VERSION |
1302 | ConfigureDialog->showMaximized(); | 1440 | ConfigureDialog->showMaximized(); |
1303 | #endif | 1441 | #endif |
1304 | if ( ConfigureDialog->exec() ) | 1442 | if ( ConfigureDialog->exec() ) |
1305 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1443 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1306 | delete ConfigureDialog; | 1444 | delete ConfigureDialog; |
1307 | } | 1445 | } |
1308 | 1446 | ||
1309 | void KABCore::openLDAPDialog() | 1447 | void KABCore::openLDAPDialog() |
1310 | { | 1448 | { |
1311 | #ifndef KAB_EMBEDDED | 1449 | #ifndef KAB_EMBEDDED |
1312 | if ( !mLdapSearchDialog ) { | 1450 | if ( !mLdapSearchDialog ) { |
1313 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1451 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1314 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1452 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1315 | SLOT( refreshView() ) ); | 1453 | SLOT( refreshView() ) ); |
1316 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1454 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1317 | SLOT( setModified() ) ); | 1455 | SLOT( setModified() ) ); |
1318 | } else | 1456 | } else |
1319 | mLdapSearchDialog->restoreSettings(); | 1457 | mLdapSearchDialog->restoreSettings(); |
1320 | 1458 | ||
1321 | if ( mLdapSearchDialog->isOK() ) | 1459 | if ( mLdapSearchDialog->isOK() ) |
1322 | mLdapSearchDialog->exec(); | 1460 | mLdapSearchDialog->exec(); |
1323 | #else //KAB_EMBEDDED | 1461 | #else //KAB_EMBEDDED |
1324 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1462 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1325 | #endif //KAB_EMBEDDED | 1463 | #endif //KAB_EMBEDDED |
1326 | } | 1464 | } |
1327 | 1465 | ||
1328 | void KABCore::print() | 1466 | void KABCore::print() |
1329 | { | 1467 | { |
1330 | #ifndef KAB_EMBEDDED | 1468 | #ifndef KAB_EMBEDDED |
1331 | KPrinter printer; | 1469 | KPrinter printer; |
1332 | if ( !printer.setup( this ) ) | 1470 | if ( !printer.setup( this ) ) |
1333 | return; | 1471 | return; |
1334 | 1472 | ||
1335 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1473 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1336 | mViewManager->selectedUids(), this ); | 1474 | mViewManager->selectedUids(), this ); |
1337 | 1475 | ||
1338 | wizard.exec(); | 1476 | wizard.exec(); |
1339 | #else //KAB_EMBEDDED | 1477 | #else //KAB_EMBEDDED |
1340 | qDebug("KABCore::print() finsih method"); | 1478 | qDebug("KABCore::print() finsih method"); |
1341 | #endif //KAB_EMBEDDED | 1479 | #endif //KAB_EMBEDDED |
1342 | 1480 | ||
1343 | } | 1481 | } |
1344 | 1482 | ||
1345 | 1483 | ||
1346 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1484 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1347 | { | 1485 | { |
1348 | if ( mGUIClient ) | 1486 | if ( mGUIClient ) |
1349 | mGUIClient->insertChildClient( client ); | 1487 | mGUIClient->insertChildClient( client ); |
1350 | else | 1488 | else |
1351 | KMessageBox::error( this, "no KXMLGUICLient"); | 1489 | KMessageBox::error( this, "no KXMLGUICLient"); |
1352 | } | 1490 | } |
1353 | 1491 | ||
1354 | 1492 | ||
1355 | void KABCore::configurationChanged() | 1493 | void KABCore::configurationChanged() |
1356 | { | 1494 | { |
1357 | mExtensionManager->reconfigure(); | 1495 | mExtensionManager->reconfigure(); |
1358 | } | 1496 | } |
1359 | 1497 | ||
1360 | void KABCore::addressBookChanged() | 1498 | void KABCore::addressBookChanged() |
1361 | { | 1499 | { |
1362 | /*US | 1500 | /*US |
1363 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1501 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1364 | while ( it.current() ) { | 1502 | while ( it.current() ) { |
1365 | if ( it.current()->dirty() ) { | 1503 | if ( it.current()->dirty() ) { |
1366 | QString text = i18n( "Data has been changed externally. Unsaved " | 1504 | QString text = i18n( "Data has been changed externally. Unsaved " |
1367 | "changes will be lost." ); | 1505 | "changes will be lost." ); |
1368 | KMessageBox::information( this, text ); | 1506 | KMessageBox::information( this, text ); |
1369 | } | 1507 | } |
1370 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1508 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1371 | ++it; | 1509 | ++it; |
1372 | } | 1510 | } |
1373 | */ | 1511 | */ |
1374 | if (mEditorDialog) | 1512 | if (mEditorDialog) |
1375 | { | 1513 | { |
1376 | if (mEditorDialog->dirty()) | 1514 | if (mEditorDialog->dirty()) |
1377 | { | 1515 | { |
1378 | QString text = i18n( "Data has been changed externally. Unsaved " | 1516 | QString text = i18n( "Data has been changed externally. Unsaved " |
1379 | "changes will be lost." ); | 1517 | "changes will be lost." ); |
1380 | KMessageBox::information( this, text ); | 1518 | KMessageBox::information( this, text ); |
1381 | } | 1519 | } |
1382 | QString currentuid = mEditorDialog->addressee().uid(); | 1520 | QString currentuid = mEditorDialog->addressee().uid(); |
1383 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1521 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1384 | } | 1522 | } |
1385 | mViewManager->refreshView(); | 1523 | mViewManager->refreshView(); |
1386 | // mDetails->refreshView(); | 1524 | // mDetails->refreshView(); |
1387 | 1525 | ||
1388 | 1526 | ||
1389 | } | 1527 | } |
1390 | 1528 | ||
1391 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1529 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1392 | const char *name ) | 1530 | const char *name ) |
1393 | { | 1531 | { |
1394 | 1532 | ||
1395 | if ( mEditorDialog == 0 ) { | 1533 | if ( mEditorDialog == 0 ) { |
1396 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1534 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1397 | name ? name : "editorDialog" ); | 1535 | name ? name : "editorDialog" ); |
1398 | 1536 | ||
1399 | 1537 | ||
1400 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1538 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1401 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1539 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1402 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1540 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1403 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1541 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1404 | } | 1542 | } |
1405 | 1543 | ||
1406 | return mEditorDialog; | 1544 | return mEditorDialog; |
1407 | } | 1545 | } |
1408 | 1546 | ||
1409 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1547 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1410 | { | 1548 | { |
1411 | //mEditorDict.remove( uid ); | 1549 | //mEditorDict.remove( uid ); |
1412 | } | 1550 | } |
1413 | 1551 | ||
1414 | void KABCore::initGUI() | 1552 | void KABCore::initGUI() |
1415 | { | 1553 | { |
1416 | #ifndef KAB_EMBEDDED | 1554 | #ifndef KAB_EMBEDDED |
1417 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1555 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1418 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1556 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1419 | 1557 | ||
1420 | mExtensionBarSplitter = new QSplitter( this ); | 1558 | mExtensionBarSplitter = new QSplitter( this ); |
1421 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1559 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1422 | 1560 | ||
1423 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1561 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1424 | 1562 | ||
1425 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1563 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1426 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1564 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1427 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1565 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1428 | SLOT( incrementalSearch( const QString& ) ) ); | 1566 | SLOT( incrementalSearch( const QString& ) ) ); |
1429 | 1567 | ||
1430 | mViewManager = new ViewManager( this, viewSpace ); | 1568 | mViewManager = new ViewManager( this, viewSpace ); |
1431 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1569 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1432 | 1570 | ||
1433 | mDetails = new ViewContainer( mDetailsSplitter ); | 1571 | mDetails = new ViewContainer( mDetailsSplitter ); |
1434 | 1572 | ||
1435 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1573 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1436 | 1574 | ||
1437 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1575 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1438 | 1576 | ||
1439 | topLayout->addWidget( mExtensionBarSplitter ); | 1577 | topLayout->addWidget( mExtensionBarSplitter ); |
1440 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1578 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1441 | topLayout->addWidget( mJumpButtonBar ); | 1579 | topLayout->addWidget( mJumpButtonBar ); |
1442 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1580 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1443 | 1581 | ||
1444 | mXXPortManager = new XXPortManager( this, this ); | 1582 | mXXPortManager = new XXPortManager( this, this ); |
1445 | 1583 | ||
1446 | #else //KAB_EMBEDDED | 1584 | #else //KAB_EMBEDDED |
1447 | //US initialize viewMenu before settingup viewmanager. | 1585 | //US initialize viewMenu before settingup viewmanager. |
1448 | // Viewmanager needs this menu to plugin submenues. | 1586 | // Viewmanager needs this menu to plugin submenues. |
1449 | viewMenu = new QPopupMenu( this ); | 1587 | viewMenu = new QPopupMenu( this ); |
1450 | settingsMenu = new QPopupMenu( this ); | 1588 | settingsMenu = new QPopupMenu( this ); |
1451 | //filterMenu = new QPopupMenu( this ); | 1589 | //filterMenu = new QPopupMenu( this ); |
1452 | ImportMenu = new QPopupMenu( this ); | 1590 | ImportMenu = new QPopupMenu( this ); |
1453 | ExportMenu = new QPopupMenu( this ); | 1591 | ExportMenu = new QPopupMenu( this ); |
1454 | syncMenu = new QPopupMenu( this ); | 1592 | syncMenu = new QPopupMenu( this ); |
1455 | changeMenu= new QPopupMenu( this ); | 1593 | changeMenu= new QPopupMenu( this ); |
1456 | 1594 | ||
1457 | //US since we have no splitter for the embedded system, setup | 1595 | //US since we have no splitter for the embedded system, setup |
1458 | // a layout with two frames. One left and one right. | 1596 | // a layout with two frames. One left and one right. |
1459 | 1597 | ||
1460 | QBoxLayout *topLayout; | 1598 | QBoxLayout *topLayout; |
1461 | 1599 | ||
1462 | // = new QHBoxLayout( this ); | 1600 | // = new QHBoxLayout( this ); |
1463 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1601 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1464 | 1602 | ||
1465 | // QWidget *mainBox = new QWidget( this ); | 1603 | // QWidget *mainBox = new QWidget( this ); |
1466 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1604 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1467 | 1605 | ||
1468 | #ifdef DESKTOP_VERSION | 1606 | #ifdef DESKTOP_VERSION |
1469 | topLayout = new QHBoxLayout( this ); | 1607 | topLayout = new QHBoxLayout( this ); |
1470 | 1608 | ||
1471 | 1609 | ||
1472 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1610 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1473 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1611 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1474 | 1612 | ||
1475 | topLayout->addWidget(mMiniSplitter ); | 1613 | topLayout->addWidget(mMiniSplitter ); |
1476 | 1614 | ||
1477 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1615 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1478 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1616 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1479 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1617 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1480 | mDetails = new ViewContainer( mMiniSplitter ); | 1618 | mDetails = new ViewContainer( mMiniSplitter ); |
1481 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1619 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1482 | #else | 1620 | #else |
1483 | if ( QApplication::desktop()->width() > 480 ) { | 1621 | if ( QApplication::desktop()->width() > 480 ) { |
1484 | topLayout = new QHBoxLayout( this ); | 1622 | topLayout = new QHBoxLayout( this ); |
1485 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1623 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1486 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1624 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1487 | } else { | 1625 | } else { |
1488 | 1626 | ||
1489 | topLayout = new QHBoxLayout( this ); | 1627 | topLayout = new QHBoxLayout( this ); |
1490 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1628 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1491 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1629 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1492 | } | 1630 | } |
1493 | 1631 | ||
1494 | topLayout->addWidget(mMiniSplitter ); | 1632 | topLayout->addWidget(mMiniSplitter ); |
1495 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1633 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1496 | mDetails = new ViewContainer( mMiniSplitter ); | 1634 | mDetails = new ViewContainer( mMiniSplitter ); |
1497 | 1635 | ||
1498 | 1636 | ||
1499 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1637 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1500 | #endif | 1638 | #endif |
1501 | //eh->hide(); | 1639 | //eh->hide(); |
1502 | // topLayout->addWidget(mExtensionManager ); | 1640 | // topLayout->addWidget(mExtensionManager ); |
1503 | 1641 | ||
1504 | 1642 | ||
1505 | /*US | 1643 | /*US |
1506 | #ifndef KAB_NOSPLITTER | 1644 | #ifndef KAB_NOSPLITTER |
1507 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1645 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1508 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1646 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1509 | topLayout->setSpacing( 10 ); | 1647 | topLayout->setSpacing( 10 ); |
1510 | 1648 | ||
1511 | mDetailsSplitter = new QSplitter( this ); | 1649 | mDetailsSplitter = new QSplitter( this ); |
1512 | 1650 | ||
1513 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1651 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1514 | 1652 | ||
1515 | mViewManager = new ViewManager( this, viewSpace ); | 1653 | mViewManager = new ViewManager( this, viewSpace ); |
1516 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1654 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1517 | 1655 | ||
1518 | mDetails = new ViewContainer( mDetailsSplitter ); | 1656 | mDetails = new ViewContainer( mDetailsSplitter ); |
1519 | 1657 | ||
1520 | topLayout->addWidget( mDetailsSplitter ); | 1658 | topLayout->addWidget( mDetailsSplitter ); |
1521 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1659 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1522 | #else //KAB_NOSPLITTER | 1660 | #else //KAB_NOSPLITTER |
1523 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1661 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1524 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1662 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1525 | topLayout->setSpacing( 10 ); | 1663 | topLayout->setSpacing( 10 ); |
1526 | 1664 | ||
1527 | // mDetailsSplitter = new QSplitter( this ); | 1665 | // mDetailsSplitter = new QSplitter( this ); |
1528 | 1666 | ||
1529 | QVBox *viewSpace = new QVBox( this ); | 1667 | QVBox *viewSpace = new QVBox( this ); |
1530 | 1668 | ||
1531 | mViewManager = new ViewManager( this, viewSpace ); | 1669 | mViewManager = new ViewManager( this, viewSpace ); |
1532 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1670 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1533 | 1671 | ||
1534 | mDetails = new ViewContainer( this ); | 1672 | mDetails = new ViewContainer( this ); |
1535 | 1673 | ||
1536 | topLayout->addWidget( viewSpace ); | 1674 | topLayout->addWidget( viewSpace ); |
1537 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1675 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1538 | topLayout->addWidget( mDetails ); | 1676 | topLayout->addWidget( mDetails ); |
1539 | #endif //KAB_NOSPLITTER | 1677 | #endif //KAB_NOSPLITTER |
1540 | */ | 1678 | */ |
1541 | 1679 | ||
1542 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1680 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1543 | syncManager->setBlockSave(false); | 1681 | syncManager->setBlockSave(false); |
1544 | 1682 | ||
1545 | 1683 | ||
1546 | #endif //KAB_EMBEDDED | 1684 | #endif //KAB_EMBEDDED |
1547 | initActions(); | 1685 | initActions(); |
1548 | 1686 | ||
1549 | #ifdef KAB_EMBEDDED | 1687 | #ifdef KAB_EMBEDDED |
1550 | addActionsManually(); | 1688 | addActionsManually(); |
1551 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1689 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1552 | mXXPortManager = new XXPortManager( this, this ); | 1690 | mXXPortManager = new XXPortManager( this, this ); |
1553 | 1691 | ||
1554 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1692 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1555 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1693 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1556 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1694 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1557 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1695 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1558 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1696 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1559 | // mIncSearchWidget->hide(); | 1697 | // mIncSearchWidget->hide(); |
1560 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1698 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1561 | SLOT( incrementalSearch( const QString& ) ) ); | 1699 | SLOT( incrementalSearch( const QString& ) ) ); |
1562 | 1700 | ||
1563 | 1701 | ||
1564 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1702 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1565 | 1703 | ||
1566 | topLayout->addWidget( mJumpButtonBar ); | 1704 | topLayout->addWidget( mJumpButtonBar ); |
1567 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1705 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1568 | 1706 | ||
1569 | // mMainWindow->getIconToolBar()->raise(); | 1707 | // mMainWindow->getIconToolBar()->raise(); |
1570 | 1708 | ||
1571 | #endif //KAB_EMBEDDED | 1709 | #endif //KAB_EMBEDDED |
1572 | 1710 | ||
1573 | } | 1711 | } |
1574 | void KABCore::initActions() | 1712 | void KABCore::initActions() |
1575 | { | 1713 | { |
1576 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1714 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1577 | 1715 | ||
1578 | #ifndef KAB_EMBEDDED | 1716 | #ifndef KAB_EMBEDDED |
1579 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1717 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1580 | SLOT( clipboardDataChanged() ) ); | 1718 | SLOT( clipboardDataChanged() ) ); |
1581 | #endif //KAB_EMBEDDED | 1719 | #endif //KAB_EMBEDDED |
1582 | 1720 | ||
1583 | // file menu | 1721 | // file menu |
1584 | if ( mIsPart ) { | 1722 | if ( mIsPart ) { |
1585 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1723 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1586 | SLOT( sendMail() ), actionCollection(), | 1724 | SLOT( sendMail() ), actionCollection(), |
1587 | "kaddressbook_mail" ); | 1725 | "kaddressbook_mail" ); |
1588 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1726 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1589 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1727 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1590 | 1728 | ||
1591 | } else { | 1729 | } else { |
1592 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1730 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1593 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1731 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1594 | } | 1732 | } |
1595 | 1733 | ||
1596 | 1734 | ||
1597 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1735 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1598 | SLOT( save() ), actionCollection(), "file_sync" ); | 1736 | SLOT( save() ), actionCollection(), "file_sync" ); |
1599 | 1737 | ||
1600 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1738 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1601 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1739 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1602 | 1740 | ||
1603 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1741 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1604 | this, SLOT( mailVCard() ), | 1742 | this, SLOT( mailVCard() ), |
1605 | actionCollection(), "file_mail_vcard"); | 1743 | actionCollection(), "file_mail_vcard"); |
1606 | 1744 | ||
1745 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | ||
1746 | SLOT( export2phone() ), actionCollection(), | ||
1747 | "kaddressbook_ex2phone" ); | ||
1748 | |||
1607 | mActionBeamVCard = 0; | 1749 | mActionBeamVCard = 0; |
1608 | mActionBeam = 0; | 1750 | mActionBeam = 0; |
1609 | 1751 | ||
1610 | #ifndef DESKTOP_VERSION | 1752 | #ifndef DESKTOP_VERSION |
1611 | if ( Ir::supported() ) { | 1753 | if ( Ir::supported() ) { |
1612 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1754 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1613 | SLOT( beamVCard() ), actionCollection(), | 1755 | SLOT( beamVCard() ), actionCollection(), |
1614 | "kaddressbook_beam_vcard" ); | 1756 | "kaddressbook_beam_vcard" ); |
1615 | 1757 | ||
1616 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1758 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1617 | SLOT( beamMySelf() ), actionCollection(), | 1759 | SLOT( beamMySelf() ), actionCollection(), |
1618 | "kaddressbook_beam_myself" ); | 1760 | "kaddressbook_beam_myself" ); |
1619 | } | 1761 | } |
1620 | #endif | 1762 | #endif |
1621 | 1763 | ||
1622 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1764 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1623 | this, SLOT( editContact2() ), | 1765 | this, SLOT( editContact2() ), |
1624 | actionCollection(), "file_properties" ); | 1766 | actionCollection(), "file_properties" ); |
1625 | 1767 | ||
1626 | #ifdef KAB_EMBEDDED | 1768 | #ifdef KAB_EMBEDDED |
1627 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1769 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1628 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1770 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1629 | mMainWindow, SLOT( exit() ), | 1771 | mMainWindow, SLOT( exit() ), |
1630 | actionCollection(), "quit" ); | 1772 | actionCollection(), "quit" ); |
1631 | #endif //KAB_EMBEDDED | 1773 | #endif //KAB_EMBEDDED |
1632 | 1774 | ||
1633 | // edit menu | 1775 | // edit menu |
1634 | if ( mIsPart ) { | 1776 | if ( mIsPart ) { |
1635 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1777 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1636 | SLOT( copyContacts() ), actionCollection(), | 1778 | SLOT( copyContacts() ), actionCollection(), |
1637 | "kaddressbook_copy" ); | 1779 | "kaddressbook_copy" ); |
1638 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1780 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1639 | SLOT( cutContacts() ), actionCollection(), | 1781 | SLOT( cutContacts() ), actionCollection(), |
1640 | "kaddressbook_cut" ); | 1782 | "kaddressbook_cut" ); |
1641 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1783 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1642 | SLOT( pasteContacts() ), actionCollection(), | 1784 | SLOT( pasteContacts() ), actionCollection(), |
1643 | "kaddressbook_paste" ); | 1785 | "kaddressbook_paste" ); |
1644 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1786 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1645 | SLOT( selectAllContacts() ), actionCollection(), | 1787 | SLOT( selectAllContacts() ), actionCollection(), |
1646 | "kaddressbook_select_all" ); | 1788 | "kaddressbook_select_all" ); |
1647 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1789 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1648 | SLOT( undo() ), actionCollection(), | 1790 | SLOT( undo() ), actionCollection(), |
1649 | "kaddressbook_undo" ); | 1791 | "kaddressbook_undo" ); |
1650 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1792 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1651 | this, SLOT( redo() ), actionCollection(), | 1793 | this, SLOT( redo() ), actionCollection(), |
1652 | "kaddressbook_redo" ); | 1794 | "kaddressbook_redo" ); |
1653 | } else { | 1795 | } else { |
1654 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1796 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1655 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1797 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1656 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1798 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1657 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1799 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1658 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1800 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1659 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1801 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1660 | } | 1802 | } |
1661 | 1803 | ||
1662 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1804 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1663 | Key_Delete, this, SLOT( deleteContacts() ), | 1805 | Key_Delete, this, SLOT( deleteContacts() ), |
1664 | actionCollection(), "edit_delete" ); | 1806 | actionCollection(), "edit_delete" ); |
1665 | 1807 | ||
1666 | mActionUndo->setEnabled( false ); | 1808 | mActionUndo->setEnabled( false ); |
1667 | mActionRedo->setEnabled( false ); | 1809 | mActionRedo->setEnabled( false ); |
1668 | 1810 | ||
1669 | // settings menu | 1811 | // settings menu |
1670 | #ifdef KAB_EMBEDDED | 1812 | #ifdef KAB_EMBEDDED |
1671 | //US special menuentry to configure the addressbook resources. On KDE | 1813 | //US special menuentry to configure the addressbook resources. On KDE |
1672 | // you do that through the control center !!! | 1814 | // you do that through the control center !!! |
1673 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1815 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1674 | SLOT( configureResources() ), actionCollection(), | 1816 | SLOT( configureResources() ), actionCollection(), |
1675 | "kaddressbook_configure_resources" ); | 1817 | "kaddressbook_configure_resources" ); |
1676 | #endif //KAB_EMBEDDED | 1818 | #endif //KAB_EMBEDDED |
1677 | 1819 | ||
1678 | if ( mIsPart ) { | 1820 | if ( mIsPart ) { |
1679 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1821 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1680 | SLOT( openConfigDialog() ), actionCollection(), | 1822 | SLOT( openConfigDialog() ), actionCollection(), |
1681 | "kaddressbook_configure" ); | 1823 | "kaddressbook_configure" ); |
1682 | 1824 | ||
1683 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1825 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1684 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1826 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1685 | "kaddressbook_configure_shortcuts" ); | 1827 | "kaddressbook_configure_shortcuts" ); |
1686 | #ifdef KAB_EMBEDDED | 1828 | #ifdef KAB_EMBEDDED |
1687 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1829 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1688 | mActionConfigureToolbars->setEnabled( false ); | 1830 | mActionConfigureToolbars->setEnabled( false ); |
1689 | #endif //KAB_EMBEDDED | 1831 | #endif //KAB_EMBEDDED |
1690 | 1832 | ||
1691 | } else { | 1833 | } else { |
1692 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1834 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1693 | 1835 | ||
1694 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1836 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1695 | } | 1837 | } |
1696 | 1838 | ||
1697 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1839 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1698 | actionCollection(), "options_show_jump_bar" ); | 1840 | actionCollection(), "options_show_jump_bar" ); |
1699 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1841 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1700 | 1842 | ||
1701 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1843 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1702 | actionCollection(), "options_show_details" ); | 1844 | actionCollection(), "options_show_details" ); |
1703 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1845 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1704 | 1846 | ||
1705 | // misc | 1847 | // misc |
1706 | // only enable LDAP lookup if we can handle the protocol | 1848 | // only enable LDAP lookup if we can handle the protocol |
1707 | #ifndef KAB_EMBEDDED | 1849 | #ifndef KAB_EMBEDDED |
1708 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1850 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1709 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1851 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1710 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1852 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1711 | "ldap_lookup" ); | 1853 | "ldap_lookup" ); |
1712 | } | 1854 | } |
1713 | #else //KAB_EMBEDDED | 1855 | #else //KAB_EMBEDDED |
1714 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1856 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1715 | #endif //KAB_EMBEDDED | 1857 | #endif //KAB_EMBEDDED |
1716 | 1858 | ||
1717 | 1859 | ||
1718 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1860 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1719 | SLOT( setWhoAmI() ), actionCollection(), | 1861 | SLOT( setWhoAmI() ), actionCollection(), |
1720 | "set_personal" ); | 1862 | "set_personal" ); |
1721 | 1863 | ||
1722 | 1864 | ||
1723 | 1865 | ||
1724 | 1866 | ||
1725 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1867 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1726 | SLOT( setCategories() ), actionCollection(), | 1868 | SLOT( setCategories() ), actionCollection(), |
1727 | "edit_set_categories" ); | 1869 | "edit_set_categories" ); |
1728 | 1870 | ||
1729 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1871 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1730 | SLOT( removeVoice() ), actionCollection(), | 1872 | SLOT( removeVoice() ), actionCollection(), |
1731 | "remove_voice" ); | 1873 | "remove_voice" ); |
1732 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1874 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1733 | SLOT( importFromOL() ), actionCollection(), | 1875 | SLOT( importFromOL() ), actionCollection(), |
1734 | "import_OL" ); | 1876 | "import_OL" ); |
1735 | #ifdef KAB_EMBEDDED | 1877 | #ifdef KAB_EMBEDDED |
1736 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1878 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1737 | this, SLOT( showLicence() ), actionCollection(), | 1879 | this, SLOT( showLicence() ), actionCollection(), |
1738 | "licence_about_data" ); | 1880 | "licence_about_data" ); |
1739 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1881 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1740 | this, SLOT( faq() ), actionCollection(), | 1882 | this, SLOT( faq() ), actionCollection(), |
1741 | "faq_about_data" ); | 1883 | "faq_about_data" ); |
1742 | 1884 | ||
1743 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1885 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1744 | this, SLOT( createAboutData() ), actionCollection(), | 1886 | this, SLOT( createAboutData() ), actionCollection(), |
1745 | "kaddressbook_about_data" ); | 1887 | "kaddressbook_about_data" ); |
1746 | #endif //KAB_EMBEDDED | 1888 | #endif //KAB_EMBEDDED |
1747 | 1889 | ||
1748 | clipboardDataChanged(); | 1890 | clipboardDataChanged(); |
1749 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1891 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1750 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1892 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1751 | } | 1893 | } |
1752 | 1894 | ||
1753 | //US we need this function, to plug all actions into the correct menues. | 1895 | //US we need this function, to plug all actions into the correct menues. |
1754 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1896 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1755 | void KABCore::addActionsManually() | 1897 | void KABCore::addActionsManually() |
1756 | { | 1898 | { |
1757 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1899 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1758 | 1900 | ||
1759 | #ifdef KAB_EMBEDDED | 1901 | #ifdef KAB_EMBEDDED |
1760 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1902 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1761 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1903 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1762 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1904 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1763 | 1905 | ||
1764 | KToolBar* tb = mMainWindow->toolBar(); | 1906 | KToolBar* tb = mMainWindow->toolBar(); |
1765 | 1907 | ||
1766 | #ifdef DESKTOP_VERSION | 1908 | #ifdef DESKTOP_VERSION |
1767 | QMenuBar* mb = mMainWindow->menuBar(); | 1909 | QMenuBar* mb = mMainWindow->menuBar(); |
1768 | 1910 | ||
1769 | //US setup menubar. | 1911 | //US setup menubar. |
1770 | //Disable the following block if you do not want to have a menubar. | 1912 | //Disable the following block if you do not want to have a menubar. |
1771 | mb->insertItem( "&File", fileMenu ); | 1913 | mb->insertItem( "&File", fileMenu ); |
1772 | mb->insertItem( "&Edit", editMenu ); | 1914 | mb->insertItem( "&Edit", editMenu ); |
1773 | mb->insertItem( "&View", viewMenu ); | 1915 | mb->insertItem( "&View", viewMenu ); |
1774 | mb->insertItem( "&Settings", settingsMenu ); | 1916 | mb->insertItem( "&Settings", settingsMenu ); |
1775 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1917 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1776 | mb->insertItem( "&Change selected", changeMenu ); | 1918 | mb->insertItem( "&Change selected", changeMenu ); |
1777 | mb->insertItem( "&Help", helpMenu ); | 1919 | mb->insertItem( "&Help", helpMenu ); |
1778 | mIncSearchWidget = new IncSearchWidget( tb ); | 1920 | mIncSearchWidget = new IncSearchWidget( tb ); |
1779 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1921 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1780 | 1922 | ||
1781 | #else | 1923 | #else |
1782 | //US setup toolbar | 1924 | //US setup toolbar |
1783 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1925 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1784 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1926 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1785 | menuBarTB->insertItem( "ME", popupBarTB); | 1927 | menuBarTB->insertItem( "ME", popupBarTB); |
1786 | tb->insertWidget(-1, 0, menuBarTB); | 1928 | tb->insertWidget(-1, 0, menuBarTB); |
1787 | mIncSearchWidget = new IncSearchWidget( tb ); | 1929 | mIncSearchWidget = new IncSearchWidget( tb ); |
1788 | 1930 | ||
1789 | tb->enableMoving(false); | 1931 | tb->enableMoving(false); |
1790 | popupBarTB->insertItem( "&File", fileMenu ); | 1932 | popupBarTB->insertItem( "&File", fileMenu ); |
1791 | popupBarTB->insertItem( "&Edit", editMenu ); | 1933 | popupBarTB->insertItem( "&Edit", editMenu ); |
1792 | popupBarTB->insertItem( "&View", viewMenu ); | 1934 | popupBarTB->insertItem( "&View", viewMenu ); |
1793 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1935 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1794 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1936 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1795 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1937 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1796 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1938 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1797 | popupBarTB->insertItem( "&Help", helpMenu ); | 1939 | popupBarTB->insertItem( "&Help", helpMenu ); |
1798 | if (QApplication::desktop()->width() > 320 ) { | 1940 | if (QApplication::desktop()->width() > 320 ) { |
1799 | // mViewManager->getFilterAction()->plug ( tb); | 1941 | // mViewManager->getFilterAction()->plug ( tb); |
1800 | } | 1942 | } |
1801 | #endif | 1943 | #endif |
1802 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1944 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1803 | 1945 | ||
1804 | 1946 | ||
1805 | 1947 | ||
1806 | //US Now connect the actions with the menue entries. | 1948 | //US Now connect the actions with the menue entries. |
1807 | mActionPrint->plug( fileMenu ); | 1949 | mActionPrint->plug( fileMenu ); |
1808 | mActionMail->plug( fileMenu ); | 1950 | mActionMail->plug( fileMenu ); |
1809 | fileMenu->insertSeparator(); | 1951 | fileMenu->insertSeparator(); |
1810 | 1952 | ||
1811 | mActionNewContact->plug( fileMenu ); | 1953 | mActionNewContact->plug( fileMenu ); |
1812 | mActionNewContact->plug( tb ); | 1954 | mActionNewContact->plug( tb ); |
1813 | 1955 | ||
1814 | mActionEditAddressee->plug( fileMenu ); | 1956 | mActionEditAddressee->plug( fileMenu ); |
1815 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1957 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1816 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1958 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1817 | mActionEditAddressee->plug( tb ); | 1959 | mActionEditAddressee->plug( tb ); |
1818 | 1960 | ||
1819 | fileMenu->insertSeparator(); | 1961 | fileMenu->insertSeparator(); |
1820 | mActionSave->plug( fileMenu ); | 1962 | mActionSave->plug( fileMenu ); |
1821 | fileMenu->insertItem( "&Import", ImportMenu ); | 1963 | fileMenu->insertItem( "&Import", ImportMenu ); |
1822 | fileMenu->insertItem( "&Export", ExportMenu ); | 1964 | fileMenu->insertItem( "&Export", ExportMenu ); |
1823 | fileMenu->insertSeparator(); | 1965 | fileMenu->insertSeparator(); |
1824 | mActionMailVCard->plug( fileMenu ); | 1966 | mActionMailVCard->plug( fileMenu ); |
1825 | #ifndef DESKTOP_VERSION | 1967 | #ifndef DESKTOP_VERSION |
1826 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1968 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1827 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1969 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1828 | #endif | 1970 | #endif |
1829 | fileMenu->insertSeparator(); | 1971 | fileMenu->insertSeparator(); |
1830 | mActionQuit->plug( fileMenu ); | 1972 | mActionQuit->plug( fileMenu ); |
1831 | #ifdef _WIN32_ | 1973 | #ifdef _WIN32_ |
1832 | mActionImportOL->plug( ImportMenu ); | 1974 | mActionImportOL->plug( ImportMenu ); |
1833 | #endif | 1975 | #endif |
1834 | // edit menu | 1976 | // edit menu |
1835 | mActionUndo->plug( editMenu ); | 1977 | mActionUndo->plug( editMenu ); |
1836 | mActionRedo->plug( editMenu ); | 1978 | mActionRedo->plug( editMenu ); |
1837 | editMenu->insertSeparator(); | 1979 | editMenu->insertSeparator(); |
1838 | mActionCut->plug( editMenu ); | 1980 | mActionCut->plug( editMenu ); |
1839 | mActionCopy->plug( editMenu ); | 1981 | mActionCopy->plug( editMenu ); |
1840 | mActionPaste->plug( editMenu ); | 1982 | mActionPaste->plug( editMenu ); |
1841 | mActionDelete->plug( editMenu ); | 1983 | mActionDelete->plug( editMenu ); |
1842 | editMenu->insertSeparator(); | 1984 | editMenu->insertSeparator(); |
1843 | mActionSelectAll->plug( editMenu ); | 1985 | mActionSelectAll->plug( editMenu ); |
1844 | 1986 | ||
1845 | mActionRemoveVoice->plug( changeMenu ); | 1987 | mActionRemoveVoice->plug( changeMenu ); |
1846 | // settings menu | 1988 | // settings menu |
1847 | //US special menuentry to configure the addressbook resources. On KDE | 1989 | //US special menuentry to configure the addressbook resources. On KDE |
1848 | // you do that through the control center !!! | 1990 | // you do that through the control center !!! |
1849 | mActionConfigResources->plug( settingsMenu ); | 1991 | mActionConfigResources->plug( settingsMenu ); |
1850 | settingsMenu->insertSeparator(); | 1992 | settingsMenu->insertSeparator(); |
1851 | 1993 | ||
1852 | mActionConfigKAddressbook->plug( settingsMenu ); | 1994 | mActionConfigKAddressbook->plug( settingsMenu ); |
1853 | 1995 | ||
1854 | if ( mIsPart ) { | 1996 | if ( mIsPart ) { |
1855 | mActionConfigShortcuts->plug( settingsMenu ); | 1997 | mActionConfigShortcuts->plug( settingsMenu ); |
1856 | mActionConfigureToolbars->plug( settingsMenu ); | 1998 | mActionConfigureToolbars->plug( settingsMenu ); |
1857 | 1999 | ||
1858 | } else { | 2000 | } else { |
1859 | mActionKeyBindings->plug( settingsMenu ); | 2001 | mActionKeyBindings->plug( settingsMenu ); |
1860 | } | 2002 | } |
1861 | 2003 | ||
1862 | settingsMenu->insertSeparator(); | 2004 | settingsMenu->insertSeparator(); |
1863 | 2005 | ||
1864 | mActionJumpBar->plug( settingsMenu ); | 2006 | mActionJumpBar->plug( settingsMenu ); |
1865 | mActionDetails->plug( settingsMenu ); | 2007 | mActionDetails->plug( settingsMenu ); |
1866 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2008 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1867 | mActionDetails->plug( tb ); | 2009 | mActionDetails->plug( tb ); |
1868 | settingsMenu->insertSeparator(); | 2010 | settingsMenu->insertSeparator(); |
1869 | 2011 | ||
1870 | mActionWhoAmI->plug( settingsMenu ); | 2012 | mActionWhoAmI->plug( settingsMenu ); |
1871 | mActionCategories->plug( settingsMenu ); | 2013 | mActionCategories->plug( settingsMenu ); |
1872 | 2014 | ||
1873 | mActionLicence->plug( helpMenu ); | 2015 | mActionLicence->plug( helpMenu ); |
1874 | mActionFaq->plug( helpMenu ); | 2016 | mActionFaq->plug( helpMenu ); |
1875 | mActionAboutKAddressbook->plug( helpMenu ); | 2017 | mActionAboutKAddressbook->plug( helpMenu ); |
1876 | 2018 | ||
1877 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2019 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1878 | 2020 | ||
1879 | mActionSave->plug( tb ); | 2021 | mActionSave->plug( tb ); |
1880 | mViewManager->getFilterAction()->plug ( tb); | 2022 | mViewManager->getFilterAction()->plug ( tb); |
1881 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2023 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1882 | mActionUndo->plug( tb ); | 2024 | mActionUndo->plug( tb ); |
1883 | mActionDelete->plug( tb ); | 2025 | mActionDelete->plug( tb ); |
1884 | mActionRedo->plug( tb ); | 2026 | mActionRedo->plug( tb ); |
1885 | } | 2027 | } |
1886 | } | 2028 | } |
1887 | //mActionQuit->plug ( tb ); | 2029 | //mActionQuit->plug ( tb ); |
1888 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2030 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1889 | 2031 | ||
1890 | //US link the searchwidget first to this. | 2032 | //US link the searchwidget first to this. |
1891 | // The real linkage to the toolbar happens later. | 2033 | // The real linkage to the toolbar happens later. |
1892 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2034 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1893 | //US tb->insertItem( mIncSearchWidget ); | 2035 | //US tb->insertItem( mIncSearchWidget ); |
1894 | /*US | 2036 | /*US |
1895 | mIncSearchWidget = new IncSearchWidget( tb ); | 2037 | mIncSearchWidget = new IncSearchWidget( tb ); |
1896 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2038 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1897 | SLOT( incrementalSearch( const QString& ) ) ); | 2039 | SLOT( incrementalSearch( const QString& ) ) ); |
1898 | 2040 | ||
1899 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2041 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1900 | 2042 | ||
1901 | //US topLayout->addWidget( mJumpButtonBar ); | 2043 | //US topLayout->addWidget( mJumpButtonBar ); |
1902 | this->layout()->add( mJumpButtonBar ); | 2044 | this->layout()->add( mJumpButtonBar ); |
1903 | */ | 2045 | */ |
1904 | 2046 | ||
1905 | #endif //KAB_EMBEDDED | 2047 | #endif //KAB_EMBEDDED |
1906 | 2048 | ||
2049 | mActionExport2phone->plug( ExportMenu ); | ||
1907 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2050 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
1908 | syncManager->fillSyncMenu(); | 2051 | syncManager->fillSyncMenu(); |
1909 | 2052 | ||
1910 | } | 2053 | } |
1911 | void KABCore::showLicence() | 2054 | void KABCore::showLicence() |
1912 | { | 2055 | { |
1913 | KApplication::showLicence(); | 2056 | KApplication::showLicence(); |
1914 | } | 2057 | } |
1915 | void KABCore::removeVoice() | 2058 | void KABCore::removeVoice() |
1916 | { | 2059 | { |
1917 | 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 ) | 2060 | 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 ) |
1918 | return; | 2061 | return; |
1919 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2062 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1920 | KABC::Addressee::List::Iterator it; | 2063 | KABC::Addressee::List::Iterator it; |
1921 | for ( it = list.begin(); it != list.end(); ++it ) { | 2064 | for ( it = list.begin(); it != list.end(); ++it ) { |
1922 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 2065 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1923 | PhoneNumber::List::Iterator phoneIt; | 2066 | PhoneNumber::List::Iterator phoneIt; |
1924 | bool found = false; | 2067 | bool found = false; |
1925 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 2068 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1926 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 2069 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1927 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 2070 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1928 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 2071 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1929 | (*it).insertPhoneNumber( (*phoneIt) ); | 2072 | (*it).insertPhoneNumber( (*phoneIt) ); |
1930 | found = true; | 2073 | found = true; |
1931 | } | 2074 | } |
1932 | } | 2075 | } |
1933 | 2076 | ||
1934 | } | 2077 | } |
1935 | if ( found ) | 2078 | if ( found ) |
1936 | contactModified((*it) ); | 2079 | contactModified((*it) ); |
1937 | } | 2080 | } |
1938 | } | 2081 | } |
1939 | 2082 | ||
1940 | 2083 | ||
1941 | 2084 | ||
1942 | void KABCore::clipboardDataChanged() | 2085 | void KABCore::clipboardDataChanged() |
1943 | { | 2086 | { |
1944 | 2087 | ||
1945 | if ( mReadWrite ) | 2088 | if ( mReadWrite ) |
1946 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2089 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1947 | 2090 | ||
1948 | } | 2091 | } |
1949 | 2092 | ||
1950 | void KABCore::updateActionMenu() | 2093 | void KABCore::updateActionMenu() |
1951 | { | 2094 | { |
1952 | UndoStack *undo = UndoStack::instance(); | 2095 | UndoStack *undo = UndoStack::instance(); |
1953 | RedoStack *redo = RedoStack::instance(); | 2096 | RedoStack *redo = RedoStack::instance(); |
1954 | 2097 | ||
1955 | if ( undo->isEmpty() ) | 2098 | if ( undo->isEmpty() ) |
1956 | mActionUndo->setText( i18n( "Undo" ) ); | 2099 | mActionUndo->setText( i18n( "Undo" ) ); |
1957 | else | 2100 | else |
1958 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2101 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1959 | 2102 | ||
1960 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2103 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1961 | 2104 | ||
1962 | if ( !redo->top() ) | 2105 | if ( !redo->top() ) |
1963 | mActionRedo->setText( i18n( "Redo" ) ); | 2106 | mActionRedo->setText( i18n( "Redo" ) ); |
1964 | else | 2107 | else |
1965 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2108 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1966 | 2109 | ||
1967 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2110 | mActionRedo->setEnabled( !redo->isEmpty() ); |
1968 | } | 2111 | } |
1969 | 2112 | ||
1970 | void KABCore::configureKeyBindings() | 2113 | void KABCore::configureKeyBindings() |
1971 | { | 2114 | { |
1972 | #ifndef KAB_EMBEDDED | 2115 | #ifndef KAB_EMBEDDED |
1973 | KKeyDialog::configure( actionCollection(), true ); | 2116 | KKeyDialog::configure( actionCollection(), true ); |
1974 | #else //KAB_EMBEDDED | 2117 | #else //KAB_EMBEDDED |
1975 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2118 | qDebug("KABCore::configureKeyBindings() not implemented"); |
1976 | #endif //KAB_EMBEDDED | 2119 | #endif //KAB_EMBEDDED |
1977 | } | 2120 | } |
1978 | 2121 | ||
1979 | #ifdef KAB_EMBEDDED | 2122 | #ifdef KAB_EMBEDDED |
1980 | void KABCore::configureResources() | 2123 | void KABCore::configureResources() |
1981 | { | 2124 | { |
1982 | KRES::KCMKResources dlg( this, "" , 0 ); | 2125 | KRES::KCMKResources dlg( this, "" , 0 ); |
1983 | 2126 | ||
1984 | if ( !dlg.exec() ) | 2127 | if ( !dlg.exec() ) |
1985 | return; | 2128 | return; |
1986 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2129 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
1987 | } | 2130 | } |
1988 | #endif //KAB_EMBEDDED | 2131 | #endif //KAB_EMBEDDED |
1989 | 2132 | ||
1990 | 2133 | ||
1991 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2134 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
1992 | * for the attendees list of an event. | 2135 | * for the attendees list of an event. |
1993 | */ | 2136 | */ |
1994 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2137 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
1995 | { | 2138 | { |
1996 | QStringList nameList; | 2139 | QStringList nameList; |
1997 | QStringList emailList; | 2140 | QStringList emailList; |
1998 | QStringList uidList; | 2141 | QStringList uidList; |
1999 | 2142 | ||
2000 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2143 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2001 | uint i=0; | 2144 | uint i=0; |
2002 | for (i=0; i < list.count(); i++) | 2145 | for (i=0; i < list.count(); i++) |
2003 | { | 2146 | { |
2004 | nameList.append(list[i].realName()); | 2147 | nameList.append(list[i].realName()); |
2005 | emailList.append(list[i].preferredEmail()); | 2148 | emailList.append(list[i].preferredEmail()); |
2006 | uidList.append(list[i].uid()); | 2149 | uidList.append(list[i].uid()); |
2007 | } | 2150 | } |
2008 | 2151 | ||
2009 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2152 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2010 | 2153 | ||
2011 | } | 2154 | } |
2012 | 2155 | ||
2013 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2156 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2014 | */ | 2157 | */ |
2015 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2158 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2016 | { | 2159 | { |
2017 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2160 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2018 | 2161 | ||
2019 | QString foundUid = QString::null; | 2162 | QString foundUid = QString::null; |
2020 | if ( ! uid.isEmpty() ) { | 2163 | if ( ! uid.isEmpty() ) { |
2021 | Addressee adrr = mAddressBook->findByUid( uid ); | 2164 | Addressee adrr = mAddressBook->findByUid( uid ); |
2022 | if ( !adrr.isEmpty() ) { | 2165 | if ( !adrr.isEmpty() ) { |
2023 | foundUid = uid; | 2166 | foundUid = uid; |
2024 | } | 2167 | } |
2025 | if ( email == "sendbacklist" ) { | 2168 | if ( email == "sendbacklist" ) { |
2026 | //qDebug("ssssssssssssssssssssssend "); | 2169 | //qDebug("ssssssssssssssssssssssend "); |
2027 | QStringList nameList; | 2170 | QStringList nameList; |
2028 | QStringList emailList; | 2171 | QStringList emailList; |
2029 | QStringList uidList; | 2172 | QStringList uidList; |
2030 | nameList.append(adrr.realName()); | 2173 | nameList.append(adrr.realName()); |
2031 | emailList = adrr.emails(); | 2174 | emailList = adrr.emails(); |
2032 | uidList.append( adrr.preferredEmail()); | 2175 | uidList.append( adrr.preferredEmail()); |
2033 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2176 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2034 | return; | 2177 | return; |
2035 | } | 2178 | } |
2036 | 2179 | ||
2037 | } | 2180 | } |
2038 | 2181 | ||
2039 | if ( email == "sendbacklist" ) | 2182 | if ( email == "sendbacklist" ) |
2040 | return; | 2183 | return; |
2041 | if (foundUid.isEmpty()) | 2184 | if (foundUid.isEmpty()) |
2042 | { | 2185 | { |
2043 | //find the uid of the person first | 2186 | //find the uid of the person first |
2044 | Addressee::List namelist; | 2187 | Addressee::List namelist; |
2045 | Addressee::List emaillist; | 2188 | Addressee::List emaillist; |
2046 | 2189 | ||
2047 | if (!name.isEmpty()) | 2190 | if (!name.isEmpty()) |
2048 | namelist = mAddressBook->findByName( name ); | 2191 | namelist = mAddressBook->findByName( name ); |
2049 | 2192 | ||
2050 | if (!email.isEmpty()) | 2193 | if (!email.isEmpty()) |
2051 | emaillist = mAddressBook->findByEmail( email ); | 2194 | emaillist = mAddressBook->findByEmail( email ); |
2052 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2195 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2053 | //check if we have a match in Namelist and Emaillist | 2196 | //check if we have a match in Namelist and Emaillist |
2054 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2197 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2055 | foundUid = emaillist[0].uid(); | 2198 | foundUid = emaillist[0].uid(); |
2056 | } | 2199 | } |
2057 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2200 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2058 | foundUid = namelist[0].uid(); | 2201 | foundUid = namelist[0].uid(); |
2059 | else | 2202 | else |
2060 | { | 2203 | { |
2061 | for (int i = 0; i < namelist.count(); i++) | 2204 | for (int i = 0; i < namelist.count(); i++) |
2062 | { | 2205 | { |
2063 | for (int j = 0; j < emaillist.count(); j++) | 2206 | for (int j = 0; j < emaillist.count(); j++) |
2064 | { | 2207 | { |
2065 | if (namelist[i] == emaillist[j]) | 2208 | if (namelist[i] == emaillist[j]) |
2066 | { | 2209 | { |
2067 | foundUid = namelist[i].uid(); | 2210 | foundUid = namelist[i].uid(); |
2068 | } | 2211 | } |
2069 | } | 2212 | } |
2070 | } | 2213 | } |
2071 | } | 2214 | } |
2072 | } | 2215 | } |
2073 | else | 2216 | else |
2074 | { | 2217 | { |
2075 | foundUid = uid; | 2218 | foundUid = uid; |
2076 | } | 2219 | } |
2077 | 2220 | ||
2078 | if (!foundUid.isEmpty()) | 2221 | if (!foundUid.isEmpty()) |
2079 | { | 2222 | { |
2080 | 2223 | ||
2081 | // raise Ka/Pi if it is in the background | 2224 | // raise Ka/Pi if it is in the background |
2082 | #ifndef DESKTOP_VERSION | 2225 | #ifndef DESKTOP_VERSION |
2083 | #ifndef KORG_NODCOP | 2226 | #ifndef KORG_NODCOP |
2084 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2227 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2085 | #endif | 2228 | #endif |
2086 | #endif | 2229 | #endif |
2087 | 2230 | ||
2088 | mMainWindow->showMaximized(); | 2231 | mMainWindow->showMaximized(); |
2089 | mMainWindow-> raise(); | 2232 | mMainWindow-> raise(); |
2090 | 2233 | ||
2091 | mViewManager->setSelected( "", false); | 2234 | mViewManager->setSelected( "", false); |
2092 | mViewManager->refreshView( "" ); | 2235 | mViewManager->refreshView( "" ); |
2093 | mViewManager->setSelected( foundUid, true ); | 2236 | mViewManager->setSelected( foundUid, true ); |
2094 | mViewManager->refreshView( foundUid ); | 2237 | mViewManager->refreshView( foundUid ); |
2095 | 2238 | ||
2096 | if ( !mMultipleViewsAtOnce ) | 2239 | if ( !mMultipleViewsAtOnce ) |
2097 | { | 2240 | { |
2098 | setDetailsVisible( true ); | 2241 | setDetailsVisible( true ); |
2099 | mActionDetails->setChecked(true); | 2242 | mActionDetails->setChecked(true); |
2100 | } | 2243 | } |
2101 | } | 2244 | } |
2102 | } | 2245 | } |
2103 | 2246 | ||
2104 | 2247 | ||
2105 | void KABCore::faq() | 2248 | void KABCore::faq() |
2106 | { | 2249 | { |
2107 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2250 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2108 | } | 2251 | } |
2109 | 2252 | ||
2110 | #include <libkcal/syncdefines.h> | 2253 | #include <libkcal/syncdefines.h> |
2111 | 2254 | ||
2112 | KABC::Addressee KABCore::getLastSyncAddressee() | 2255 | KABC::Addressee KABCore::getLastSyncAddressee() |
2113 | { | 2256 | { |
2114 | Addressee lse; | 2257 | Addressee lse; |
2115 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2258 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2116 | 2259 | ||
2117 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2260 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2118 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2261 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2119 | if (lse.isEmpty()) { | 2262 | if (lse.isEmpty()) { |
2120 | qDebug("Creating new last-syncAddressee "); | 2263 | qDebug("Creating new last-syncAddressee "); |
2121 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2264 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2122 | QString sum = ""; | 2265 | QString sum = ""; |
2123 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2266 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2124 | sum = "E: "; | 2267 | sum = "E: "; |
2125 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2268 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2126 | lse.setRevision( mLastAddressbookSync ); | 2269 | lse.setRevision( mLastAddressbookSync ); |
2127 | lse.setCategories( i18n("SyncEvent") ); | 2270 | lse.setCategories( i18n("SyncEvent") ); |
2128 | mAddressBook->insertAddressee( lse ); | 2271 | mAddressBook->insertAddressee( lse ); |
2129 | } | 2272 | } |
2130 | return lse; | 2273 | return lse; |
2131 | } | 2274 | } |
2132 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2275 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2133 | { | 2276 | { |
2134 | 2277 | ||
2135 | //void setZaurusId(int id); | 2278 | //void setZaurusId(int id); |
2136 | // int zaurusId() const; | 2279 | // int zaurusId() const; |
2137 | // void setZaurusUid(int id); | 2280 | // void setZaurusUid(int id); |
2138 | // int zaurusUid() const; | 2281 | // int zaurusUid() const; |
2139 | // void setZaurusStat(int id); | 2282 | // void setZaurusStat(int id); |
2140 | // int zaurusStat() const; | 2283 | // int zaurusStat() const; |
2141 | // 0 equal | 2284 | // 0 equal |
2142 | // 1 take local | 2285 | // 1 take local |
2143 | // 2 take remote | 2286 | // 2 take remote |
2144 | // 3 cancel | 2287 | // 3 cancel |
2145 | QDateTime lastSync = mLastAddressbookSync; | 2288 | QDateTime lastSync = mLastAddressbookSync; |
2146 | QDateTime localMod = local->revision(); | 2289 | QDateTime localMod = local->revision(); |
2147 | QDateTime remoteMod = remote->revision(); | 2290 | QDateTime remoteMod = remote->revision(); |
2148 | 2291 | ||
2149 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2292 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2150 | 2293 | ||
2151 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2294 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2152 | bool remCh, locCh; | 2295 | bool remCh, locCh; |
2153 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2296 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2154 | 2297 | ||
2155 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2298 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2156 | locCh = ( localMod > mLastAddressbookSync ); | 2299 | locCh = ( localMod > mLastAddressbookSync ); |
2157 | if ( !remCh && ! locCh ) { | 2300 | if ( !remCh && ! locCh ) { |
2158 | //qDebug("both not changed "); | 2301 | //qDebug("both not changed "); |
2159 | lastSync = localMod.addDays(1); | 2302 | lastSync = localMod.addDays(1); |
2160 | if ( mode <= SYNC_PREF_ASK ) | 2303 | if ( mode <= SYNC_PREF_ASK ) |
2161 | return 0; | 2304 | return 0; |
2162 | } else { | 2305 | } else { |
2163 | if ( locCh ) { | 2306 | if ( locCh ) { |
2164 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2307 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2165 | lastSync = localMod.addDays( -1 ); | 2308 | lastSync = localMod.addDays( -1 ); |
2166 | if ( !remCh ) | 2309 | if ( !remCh ) |
2167 | remoteMod =( lastSync.addDays( -1 ) ); | 2310 | remoteMod =( lastSync.addDays( -1 ) ); |
2168 | } else { | 2311 | } else { |
2169 | //qDebug(" not loc changed "); | 2312 | //qDebug(" not loc changed "); |
2170 | lastSync = localMod.addDays( 1 ); | 2313 | lastSync = localMod.addDays( 1 ); |
2171 | if ( remCh ) | 2314 | if ( remCh ) |
2172 | remoteMod =( lastSync.addDays( 1 ) ); | 2315 | remoteMod =( lastSync.addDays( 1 ) ); |
2173 | 2316 | ||
2174 | } | 2317 | } |
2175 | } | 2318 | } |
2176 | full = true; | 2319 | full = true; |
2177 | if ( mode < SYNC_PREF_ASK ) | 2320 | if ( mode < SYNC_PREF_ASK ) |
2178 | mode = SYNC_PREF_ASK; | 2321 | mode = SYNC_PREF_ASK; |
2179 | } else { | 2322 | } else { |
2180 | if ( localMod == remoteMod ) | 2323 | if ( localMod == remoteMod ) |
2181 | return 0; | 2324 | return 0; |
2182 | 2325 | ||
2183 | } | 2326 | } |
2184 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2327 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2185 | 2328 | ||
2186 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2329 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2187 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2330 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2188 | //full = true; //debug only | 2331 | //full = true; //debug only |
2189 | if ( full ) { | 2332 | if ( full ) { |
2190 | bool equ = ( (*local) == (*remote) ); | 2333 | bool equ = ( (*local) == (*remote) ); |
2191 | if ( equ ) { | 2334 | if ( equ ) { |
2192 | //qDebug("equal "); | 2335 | //qDebug("equal "); |
2193 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2336 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2194 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2337 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2195 | } | 2338 | } |
2196 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2339 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2197 | return 0; | 2340 | return 0; |
2198 | 2341 | ||
2199 | }//else //debug only | 2342 | }//else //debug only |
2200 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2343 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2201 | } | 2344 | } |
2202 | int result; | 2345 | int result; |
2203 | bool localIsNew; | 2346 | bool localIsNew; |
2204 | //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() ); | 2347 | //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() ); |
2205 | 2348 | ||
2206 | if ( full && mode < SYNC_PREF_NEWEST ) | 2349 | if ( full && mode < SYNC_PREF_NEWEST ) |
2207 | mode = SYNC_PREF_ASK; | 2350 | mode = SYNC_PREF_ASK; |
2208 | 2351 | ||
2209 | switch( mode ) { | 2352 | switch( mode ) { |
2210 | case SYNC_PREF_LOCAL: | 2353 | case SYNC_PREF_LOCAL: |
2211 | if ( lastSync > remoteMod ) | 2354 | if ( lastSync > remoteMod ) |
2212 | return 1; | 2355 | return 1; |
2213 | if ( lastSync > localMod ) | 2356 | if ( lastSync > localMod ) |
2214 | return 2; | 2357 | return 2; |
2215 | return 1; | 2358 | return 1; |
2216 | break; | 2359 | break; |
2217 | case SYNC_PREF_REMOTE: | 2360 | case SYNC_PREF_REMOTE: |
2218 | if ( lastSync > remoteMod ) | 2361 | if ( lastSync > remoteMod ) |
2219 | return 1; | 2362 | return 1; |
2220 | if ( lastSync > localMod ) | 2363 | if ( lastSync > localMod ) |
2221 | return 2; | 2364 | return 2; |
2222 | return 2; | 2365 | return 2; |
2223 | break; | 2366 | break; |
2224 | case SYNC_PREF_NEWEST: | 2367 | case SYNC_PREF_NEWEST: |
2225 | if ( localMod > remoteMod ) | 2368 | if ( localMod > remoteMod ) |
2226 | return 1; | 2369 | return 1; |
2227 | else | 2370 | else |
2228 | return 2; | 2371 | return 2; |
2229 | break; | 2372 | break; |
2230 | case SYNC_PREF_ASK: | 2373 | case SYNC_PREF_ASK: |
2231 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2374 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2232 | if ( lastSync > remoteMod ) | 2375 | if ( lastSync > remoteMod ) |
2233 | return 1; | 2376 | return 1; |
2234 | if ( lastSync > localMod ) | 2377 | if ( lastSync > localMod ) |
2235 | return 2; | 2378 | return 2; |
2236 | localIsNew = localMod >= remoteMod; | 2379 | localIsNew = localMod >= remoteMod; |
2237 | //qDebug("conflict! ************************************** "); | 2380 | //qDebug("conflict! ************************************** "); |
2238 | { | 2381 | { |
2239 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2382 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2240 | result = acd.executeD(localIsNew); | 2383 | result = acd.executeD(localIsNew); |
2241 | return result; | 2384 | return result; |
2242 | } | 2385 | } |
2243 | break; | 2386 | break; |
2244 | case SYNC_PREF_FORCE_LOCAL: | 2387 | case SYNC_PREF_FORCE_LOCAL: |
2245 | return 1; | 2388 | return 1; |
2246 | break; | 2389 | break; |
2247 | case SYNC_PREF_FORCE_REMOTE: | 2390 | case SYNC_PREF_FORCE_REMOTE: |
2248 | return 2; | 2391 | return 2; |
2249 | break; | 2392 | break; |
2250 | 2393 | ||
2251 | default: | 2394 | default: |
2252 | // SYNC_PREF_TAKE_BOTH not implemented | 2395 | // SYNC_PREF_TAKE_BOTH not implemented |
2253 | break; | 2396 | break; |
2254 | } | 2397 | } |
2255 | return 0; | 2398 | return 0; |
2256 | } | 2399 | } |
2257 | 2400 | ||
2258 | 2401 | ||
2259 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2402 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2260 | { | 2403 | { |
2261 | bool syncOK = true; | 2404 | bool syncOK = true; |
2262 | int addedAddressee = 0; | 2405 | int addedAddressee = 0; |
2263 | int addedAddresseeR = 0; | 2406 | int addedAddresseeR = 0; |
2264 | int deletedAddresseeR = 0; | 2407 | int deletedAddresseeR = 0; |
2265 | int deletedAddresseeL = 0; | 2408 | int deletedAddresseeL = 0; |
2266 | int changedLocal = 0; | 2409 | int changedLocal = 0; |
2267 | int changedRemote = 0; | 2410 | int changedRemote = 0; |
2268 | 2411 | ||
2269 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2412 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2270 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2413 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2271 | 2414 | ||
2272 | //QPtrList<Addressee> el = local->rawAddressees(); | 2415 | //QPtrList<Addressee> el = local->rawAddressees(); |
2273 | Addressee addresseeR; | 2416 | Addressee addresseeR; |
2274 | QString uid; | 2417 | QString uid; |
2275 | int take; | 2418 | int take; |
2276 | Addressee addresseeL; | 2419 | Addressee addresseeL; |
2277 | Addressee addresseeRSync; | 2420 | Addressee addresseeRSync; |
2278 | Addressee addresseeLSync; | 2421 | Addressee addresseeLSync; |
2279 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2422 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2280 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2423 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2281 | bool fullDateRange = false; | 2424 | bool fullDateRange = false; |
2282 | local->resetTempSyncStat(); | 2425 | local->resetTempSyncStat(); |
2283 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2426 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2284 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2427 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2285 | addresseeLSync = getLastSyncAddressee(); | 2428 | addresseeLSync = getLastSyncAddressee(); |
2286 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2429 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2287 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2430 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2288 | if ( !addresseeR.isEmpty() ) { | 2431 | if ( !addresseeR.isEmpty() ) { |
2289 | addresseeRSync = addresseeR; | 2432 | addresseeRSync = addresseeR; |
2290 | remote->removeAddressee(addresseeR ); | 2433 | remote->removeAddressee(addresseeR ); |
2291 | 2434 | ||
2292 | } else { | 2435 | } else { |
2293 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2436 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2294 | addresseeRSync = addresseeLSync ; | 2437 | addresseeRSync = addresseeLSync ; |
2295 | } else { | 2438 | } else { |
2296 | qDebug("FULLDATE 1"); | 2439 | qDebug("FULLDATE 1"); |
2297 | fullDateRange = true; | 2440 | fullDateRange = true; |
2298 | Addressee newAdd; | 2441 | Addressee newAdd; |
2299 | addresseeRSync = newAdd; | 2442 | addresseeRSync = newAdd; |
2300 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2443 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2301 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2444 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2302 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2445 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2303 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2446 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2304 | } | 2447 | } |
2305 | } | 2448 | } |
2306 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2449 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2307 | qDebug("FULLDATE 2"); | 2450 | qDebug("FULLDATE 2"); |
2308 | fullDateRange = true; | 2451 | fullDateRange = true; |
2309 | } | 2452 | } |
2310 | if ( ! fullDateRange ) { | 2453 | if ( ! fullDateRange ) { |
2311 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2454 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2312 | 2455 | ||
2313 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2456 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2314 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2457 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2315 | fullDateRange = true; | 2458 | fullDateRange = true; |
2316 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2459 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2317 | } | 2460 | } |
2318 | } | 2461 | } |
2319 | // fullDateRange = true; // debug only! | 2462 | // fullDateRange = true; // debug only! |
2320 | if ( fullDateRange ) | 2463 | if ( fullDateRange ) |
2321 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2464 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2322 | else | 2465 | else |
2323 | mLastAddressbookSync = addresseeLSync.revision(); | 2466 | mLastAddressbookSync = addresseeLSync.revision(); |
2324 | // for resyncing if own file has changed | 2467 | // for resyncing if own file has changed |
2325 | // PENDING fixme later when implemented | 2468 | // PENDING fixme later when implemented |
2326 | #if 0 | 2469 | #if 0 |
2327 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2470 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2328 | mLastAddressbookSync = loadedFileVersion; | 2471 | mLastAddressbookSync = loadedFileVersion; |
2329 | qDebug("setting mLastAddressbookSync "); | 2472 | qDebug("setting mLastAddressbookSync "); |
2330 | } | 2473 | } |
2331 | #endif | 2474 | #endif |
2332 | 2475 | ||
2333 | //qDebug("*************************** "); | 2476 | //qDebug("*************************** "); |
2334 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2477 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2335 | QStringList er = remote->uidList(); | 2478 | QStringList er = remote->uidList(); |
2336 | Addressee inR ;//= er.first(); | 2479 | Addressee inR ;//= er.first(); |
2337 | Addressee inL; | 2480 | Addressee inL; |
2338 | 2481 | ||
2339 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2482 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2340 | 2483 | ||
2341 | int modulo = (er.count()/10)+1; | 2484 | int modulo = (er.count()/10)+1; |
2342 | int incCounter = 0; | 2485 | int incCounter = 0; |
2343 | while ( incCounter < er.count()) { | 2486 | while ( incCounter < er.count()) { |
2344 | if (syncManager->isProgressBarCanceled()) | 2487 | if (syncManager->isProgressBarCanceled()) |
2345 | return false; | 2488 | return false; |
2346 | if ( incCounter % modulo == 0 ) | 2489 | if ( incCounter % modulo == 0 ) |
2347 | syncManager->showProgressBar(incCounter); | 2490 | syncManager->showProgressBar(incCounter); |
2348 | 2491 | ||
2349 | uid = er[ incCounter ]; | 2492 | uid = er[ incCounter ]; |
2350 | bool skipIncidence = false; | 2493 | bool skipIncidence = false; |
2351 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2494 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2352 | skipIncidence = true; | 2495 | skipIncidence = true; |
2353 | QString idS,OidS; | 2496 | QString idS,OidS; |
2354 | qApp->processEvents(); | 2497 | qApp->processEvents(); |
2355 | if ( !skipIncidence ) { | 2498 | if ( !skipIncidence ) { |
2356 | inL = local->findByUid( uid ); | 2499 | inL = local->findByUid( uid ); |
2357 | inR = remote->findByUid( uid ); | 2500 | inR = remote->findByUid( uid ); |
2358 | //inL.setResource( 0 ); | 2501 | //inL.setResource( 0 ); |
2359 | //inR.setResource( 0 ); | 2502 | //inR.setResource( 0 ); |
2360 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2503 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2361 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2504 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2362 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2505 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2363 | if ( take == 3 ) | 2506 | if ( take == 3 ) |
2364 | return false; | 2507 | return false; |
2365 | if ( take == 1 ) {// take local | 2508 | if ( take == 1 ) {// take local |
2366 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2509 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2367 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2510 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2368 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2511 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2369 | local->insertAddressee( inL, false ); | 2512 | local->insertAddressee( inL, false ); |
2370 | idS = inR.externalUID(); | 2513 | idS = inR.externalUID(); |
2371 | OidS = inR.originalExternalUID(); | 2514 | OidS = inR.originalExternalUID(); |
2372 | } | 2515 | } |
2373 | else | 2516 | else |
2374 | idS = inR.IDStr(); | 2517 | idS = inR.IDStr(); |
2375 | remote->removeAddressee( inR ); | 2518 | remote->removeAddressee( inR ); |
2376 | inR = inL; | 2519 | inR = inL; |
2377 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2520 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2378 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2521 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2379 | inR.setOriginalExternalUID( OidS ); | 2522 | inR.setOriginalExternalUID( OidS ); |
2380 | inR.setExternalUID( idS ); | 2523 | inR.setExternalUID( idS ); |
2381 | } else { | 2524 | } else { |
2382 | inR.setIDStr( idS ); | 2525 | inR.setIDStr( idS ); |
2383 | } | 2526 | } |
2384 | inR.setResource( 0 ); | 2527 | inR.setResource( 0 ); |
2385 | remote->insertAddressee( inR , false); | 2528 | remote->insertAddressee( inR , false); |
2386 | ++changedRemote; | 2529 | ++changedRemote; |
2387 | } else { // take == 2 take remote | 2530 | } else { // take == 2 take remote |
2388 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2531 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2389 | if ( inR.revision().date().year() < 2004 ) | 2532 | if ( inR.revision().date().year() < 2004 ) |
2390 | inR.setRevision( modifiedCalendar ); | 2533 | inR.setRevision( modifiedCalendar ); |
2391 | } | 2534 | } |
2392 | idS = inL.IDStr(); | 2535 | idS = inL.IDStr(); |
2393 | local->removeAddressee( inL ); | 2536 | local->removeAddressee( inL ); |
2394 | inL = inR; | 2537 | inL = inR; |
2395 | inL.setIDStr( idS ); | 2538 | inL.setIDStr( idS ); |
2396 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2539 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2397 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2540 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2398 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2541 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2399 | } | 2542 | } |
2400 | inL.setResource( 0 ); | 2543 | inL.setResource( 0 ); |
2401 | local->insertAddressee( inL , false ); | 2544 | local->insertAddressee( inL , false ); |
2402 | ++changedLocal; | 2545 | ++changedLocal; |
2403 | } | 2546 | } |
2404 | } | 2547 | } |
2405 | } else { // no conflict | 2548 | } else { // no conflict |
2406 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2549 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2407 | QString des = addresseeLSync.note(); | 2550 | QString des = addresseeLSync.note(); |
2408 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2551 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2409 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2552 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2410 | remote->insertAddressee( inR, false ); | 2553 | remote->insertAddressee( inR, false ); |
2411 | ++deletedAddresseeR; | 2554 | ++deletedAddresseeR; |
2412 | } else { | 2555 | } else { |
2413 | inR.setRevision( modifiedCalendar ); | 2556 | inR.setRevision( modifiedCalendar ); |
2414 | remote->insertAddressee( inR, false ); | 2557 | remote->insertAddressee( inR, false ); |
2415 | inL = inR; | 2558 | inL = inR; |
2416 | inL.setResource( 0 ); | 2559 | inL.setResource( 0 ); |
2417 | local->insertAddressee( inL , false); | 2560 | local->insertAddressee( inL , false); |
2418 | ++addedAddressee; | 2561 | ++addedAddressee; |
2419 | } | 2562 | } |
2420 | } else { | 2563 | } else { |
2421 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2564 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2422 | inR.setRevision( modifiedCalendar ); | 2565 | inR.setRevision( modifiedCalendar ); |
2423 | remote->insertAddressee( inR, false ); | 2566 | remote->insertAddressee( inR, false ); |
2424 | inR.setResource( 0 ); | 2567 | inR.setResource( 0 ); |
2425 | local->insertAddressee( inR, false ); | 2568 | local->insertAddressee( inR, false ); |
2426 | ++addedAddressee; | 2569 | ++addedAddressee; |
2427 | } else { | 2570 | } else { |
2428 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2571 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2429 | remote->removeAddressee( inR ); | 2572 | remote->removeAddressee( inR ); |
2430 | ++deletedAddresseeR; | 2573 | ++deletedAddresseeR; |
2431 | } | 2574 | } |
2432 | } | 2575 | } |
2433 | } | 2576 | } |
2434 | } | 2577 | } |
2435 | ++incCounter; | 2578 | ++incCounter; |
2436 | } | 2579 | } |
2437 | er.clear(); | 2580 | er.clear(); |
2438 | QStringList el = local->uidList(); | 2581 | QStringList el = local->uidList(); |
2439 | modulo = (el.count()/10)+1; | 2582 | modulo = (el.count()/10)+1; |
2440 | 2583 | ||
2441 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2584 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2442 | incCounter = 0; | 2585 | incCounter = 0; |
2443 | while ( incCounter < el.count()) { | 2586 | while ( incCounter < el.count()) { |
2444 | qApp->processEvents(); | 2587 | qApp->processEvents(); |
2445 | if (syncManager->isProgressBarCanceled()) | 2588 | if (syncManager->isProgressBarCanceled()) |
2446 | return false; | 2589 | return false; |
2447 | if ( incCounter % modulo == 0 ) | 2590 | if ( incCounter % modulo == 0 ) |
2448 | syncManager->showProgressBar(incCounter); | 2591 | syncManager->showProgressBar(incCounter); |
2449 | uid = el[ incCounter ]; | 2592 | uid = el[ incCounter ]; |
2450 | bool skipIncidence = false; | 2593 | bool skipIncidence = false; |
2451 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2594 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2452 | skipIncidence = true; | 2595 | skipIncidence = true; |
2453 | if ( !skipIncidence ) { | 2596 | if ( !skipIncidence ) { |
2454 | inL = local->findByUid( uid ); | 2597 | inL = local->findByUid( uid ); |
2455 | inR = remote->findByUid( uid ); | 2598 | inR = remote->findByUid( uid ); |
2456 | if ( inR.isEmpty() ) { | 2599 | if ( inR.isEmpty() ) { |
2457 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2600 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2458 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2601 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2459 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2602 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2460 | local->removeAddressee( inL ); | 2603 | local->removeAddressee( inL ); |
2461 | ++deletedAddresseeL; | 2604 | ++deletedAddresseeL; |
2462 | } else { | 2605 | } else { |
2463 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2606 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2464 | inL.removeID(mCurrentSyncDevice ); | 2607 | inL.removeID(mCurrentSyncDevice ); |
2465 | ++addedAddresseeR; | 2608 | ++addedAddresseeR; |
2466 | inL.setRevision( modifiedCalendar ); | 2609 | inL.setRevision( modifiedCalendar ); |
2467 | local->insertAddressee( inL, false ); | 2610 | local->insertAddressee( inL, false ); |
2468 | inR = inL; | 2611 | inR = inL; |
2469 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2612 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2470 | inR.setResource( 0 ); | 2613 | inR.setResource( 0 ); |
2471 | remote->insertAddressee( inR, false ); | 2614 | remote->insertAddressee( inR, false ); |
2472 | } | 2615 | } |
2473 | } | 2616 | } |
2474 | } else { | 2617 | } else { |
2475 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2618 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2476 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2619 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2477 | local->removeAddressee( inL ); | 2620 | local->removeAddressee( inL ); |
2478 | ++deletedAddresseeL; | 2621 | ++deletedAddresseeL; |
2479 | } else { | 2622 | } else { |
2480 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2623 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2481 | ++addedAddresseeR; | 2624 | ++addedAddresseeR; |
2482 | inL.setRevision( modifiedCalendar ); | 2625 | inL.setRevision( modifiedCalendar ); |
2483 | local->insertAddressee( inL, false ); | 2626 | local->insertAddressee( inL, false ); |
2484 | inR = inL; | 2627 | inR = inL; |
2485 | inR.setResource( 0 ); | 2628 | inR.setResource( 0 ); |
2486 | remote->insertAddressee( inR, false ); | 2629 | remote->insertAddressee( inR, false ); |
2487 | } | 2630 | } |
2488 | } | 2631 | } |
2489 | } | 2632 | } |
2490 | } | 2633 | } |
2491 | } | 2634 | } |
2492 | ++incCounter; | 2635 | ++incCounter; |
2493 | } | 2636 | } |
2494 | el.clear(); | 2637 | el.clear(); |
2495 | syncManager->hideProgressBar(); | 2638 | syncManager->hideProgressBar(); |
2496 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2639 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2497 | // get rid of micro seconds | 2640 | // get rid of micro seconds |
2498 | QTime t = mLastAddressbookSync.time(); | 2641 | QTime t = mLastAddressbookSync.time(); |
2499 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2642 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2500 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2643 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2501 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2644 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2502 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2645 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2503 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2646 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2504 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2647 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2505 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2648 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2506 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2649 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2507 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2650 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2508 | addresseeRSync.setNote( "" ) ; | 2651 | addresseeRSync.setNote( "" ) ; |
2509 | addresseeLSync.setNote( "" ); | 2652 | addresseeLSync.setNote( "" ); |
2510 | 2653 | ||
2511 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2654 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2512 | remote->insertAddressee( addresseeRSync, false ); | 2655 | remote->insertAddressee( addresseeRSync, false ); |
2513 | local->insertAddressee( addresseeLSync, false ); | 2656 | local->insertAddressee( addresseeLSync, false ); |
2514 | QString mes; | 2657 | QString mes; |
2515 | 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2658 | 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2516 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2659 | if ( KABPrefs::instance()->mShowSyncSummary ) { |
2517 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2660 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2518 | } | 2661 | } |
2519 | qDebug( mes ); | 2662 | qDebug( mes ); |
2520 | return syncOK; | 2663 | return syncOK; |
2521 | } | 2664 | } |
2522 | 2665 | ||
2523 | 2666 | ||
2524 | //this is a overwritten callbackmethods from the syncinterface | 2667 | //this is a overwritten callbackmethods from the syncinterface |
2525 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2668 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2526 | { | 2669 | { |
2527 | 2670 | ||
2528 | //pending prepare addresseeview for output | 2671 | //pending prepare addresseeview for output |
2529 | //pending detect, if remote file has REV field. if not switch to external sync | 2672 | //pending detect, if remote file has REV field. if not switch to external sync |
2530 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2673 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2531 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2674 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2532 | 2675 | ||
2533 | AddressBook abLocal(filename,"syncContact"); | 2676 | AddressBook abLocal(filename,"syncContact"); |
2534 | bool syncOK = false; | 2677 | bool syncOK = false; |
2535 | if ( abLocal.load() ) { | 2678 | if ( abLocal.load() ) { |
2536 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2679 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2537 | bool external = false; | 2680 | bool external = false; |
2538 | bool isXML = false; | 2681 | bool isXML = false; |
2539 | if ( filename.right(4) == ".xml") { | 2682 | if ( filename.right(4) == ".xml") { |
2540 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2683 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2541 | isXML = true; | 2684 | isXML = true; |
2542 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2685 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2543 | } else { | 2686 | } else { |
2544 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2687 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2545 | if ( ! lse.isEmpty() ) { | 2688 | if ( ! lse.isEmpty() ) { |
2546 | if ( lse.familyName().left(4) == "!E: " ) | 2689 | if ( lse.familyName().left(4) == "!E: " ) |
2547 | external = true; | 2690 | external = true; |
2548 | } else { | 2691 | } else { |
2549 | bool found = false; | 2692 | bool found = false; |
2550 | AddressBook::Iterator it; | 2693 | AddressBook::Iterator it; |
2551 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2694 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2552 | if ( (*it).revision().date().year() > 2003 ) { | 2695 | if ( (*it).revision().date().year() > 2003 ) { |
2553 | found = true; | 2696 | found = true; |
2554 | break; | 2697 | break; |
2555 | } | 2698 | } |
2556 | } | 2699 | } |
2557 | external = ! found; | 2700 | external = ! found; |
2558 | } | 2701 | } |
2559 | 2702 | ||
2560 | if ( external ) { | 2703 | if ( external ) { |
2561 | qDebug("Setting vcf mode to external "); | 2704 | qDebug("Setting vcf mode to external "); |
2562 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2705 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2563 | AddressBook::Iterator it; | 2706 | AddressBook::Iterator it; |
2564 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2707 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2565 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2708 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2566 | (*it).computeCsum( mCurrentSyncDevice ); | 2709 | (*it).computeCsum( mCurrentSyncDevice ); |
2567 | } | 2710 | } |
2568 | } | 2711 | } |
2569 | } | 2712 | } |
2570 | //AddressBook::Iterator it; | 2713 | //AddressBook::Iterator it; |
2571 | //QStringList vcards; | 2714 | //QStringList vcards; |
2572 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2715 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2573 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2716 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2574 | //} | 2717 | //} |
2575 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2718 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2576 | if ( syncOK ) { | 2719 | if ( syncOK ) { |
2577 | if ( KABPrefs::instance()->mWriteBackFile ) | 2720 | if ( KABPrefs::instance()->mWriteBackFile ) |
2578 | { | 2721 | { |
2579 | if ( external ) | 2722 | if ( external ) |
2580 | abLocal.removeSyncAddressees( !isXML); | 2723 | abLocal.removeSyncAddressees( !isXML); |
2581 | qDebug("Saving remote AB "); | 2724 | qDebug("Saving remote AB "); |
2582 | abLocal.saveAB(); | 2725 | abLocal.saveAB(); |
2583 | if ( isXML ) { | 2726 | if ( isXML ) { |
2584 | // afterwrite processing | 2727 | // afterwrite processing |
2585 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2728 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2586 | } | 2729 | } |
2587 | } | 2730 | } |
2588 | } | 2731 | } |
2589 | setModified(); | 2732 | setModified(); |
2590 | 2733 | ||
2591 | } | 2734 | } |
2592 | if ( syncOK ) | 2735 | if ( syncOK ) |
2593 | mViewManager->refreshView(); | 2736 | mViewManager->refreshView(); |
2594 | return syncOK; | 2737 | return syncOK; |
2595 | #if 0 | 2738 | #if 0 |
2596 | 2739 | ||
2597 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2740 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2598 | getEventViewerDialog()->setSyncMode( true ); | 2741 | getEventViewerDialog()->setSyncMode( true ); |
2599 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2742 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2600 | getEventViewerDialog()->setSyncMode( false ); | 2743 | getEventViewerDialog()->setSyncMode( false ); |
2601 | if ( syncOK ) { | 2744 | if ( syncOK ) { |
2602 | if ( KOPrefs::instance()->mWriteBackFile ) | 2745 | if ( KOPrefs::instance()->mWriteBackFile ) |
2603 | { | 2746 | { |
2604 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2747 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2605 | storage->save(); | 2748 | storage->save(); |
2606 | } | 2749 | } |
2607 | } | 2750 | } |
2608 | setModified(); | 2751 | setModified(); |
2609 | } | 2752 | } |
2610 | 2753 | ||
2611 | #endif | 2754 | #endif |
2612 | } | 2755 | } |
2613 | 2756 | ||
2614 | 2757 | ||
2615 | //this is a overwritten callbackmethods from the syncinterface | 2758 | //this is a overwritten callbackmethods from the syncinterface |
2616 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2759 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2617 | { | 2760 | { |
2618 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2761 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2619 | 2762 | ||
2620 | AddressBook abLocal( resource,"syncContact"); | 2763 | AddressBook abLocal( resource,"syncContact"); |
2621 | bool syncOK = false; | 2764 | bool syncOK = false; |
2622 | if ( abLocal.load() ) { | 2765 | if ( abLocal.load() ) { |
2623 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2766 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2624 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2767 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2625 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2768 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2626 | qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? "); | 2769 | qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? "); |
2627 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs ); | 2770 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs ); |
2628 | if ( syncOK ) { | 2771 | if ( syncOK ) { |
2629 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2772 | if ( KABPrefs::instance()->mWriteBackFile ) { |
2630 | abLocal.saveAB(); | 2773 | abLocal.saveAB(); |
2631 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2774 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2632 | } | 2775 | } |
2633 | } | 2776 | } |
2634 | setModified(); | 2777 | setModified(); |
2635 | } | 2778 | } |
2636 | if ( syncOK ) | 2779 | if ( syncOK ) |
2637 | mViewManager->refreshView(); | 2780 | mViewManager->refreshView(); |
2638 | return syncOK; | 2781 | return syncOK; |
2639 | 2782 | ||
2640 | } | 2783 | } |
2641 | 2784 | ||
2642 | //called by the syncmanager to indicate that the work has to marked as dirty. | 2785 | //called by the syncmanager to indicate that the work has to marked as dirty. |
2643 | void KABCore::sync_setModified() | 2786 | void KABCore::sync_setModified() |
2644 | { | 2787 | { |
2645 | setModified(); | 2788 | setModified(); |
2646 | } | 2789 | } |
2647 | 2790 | ||
2648 | //called by the syncmanager to ask if the dirty flag is set. | 2791 | //called by the syncmanager to ask if the dirty flag is set. |
2649 | bool KABCore::sync_isModified() | 2792 | bool KABCore::sync_isModified() |
2650 | { | 2793 | { |
2651 | return mModified; | 2794 | return mModified; |
2652 | } | 2795 | } |
2653 | 2796 | ||
2654 | 2797 | ||
2655 | //called by the syncmanager to indicate that the work has to be saved. | 2798 | //called by the syncmanager to indicate that the work has to be saved. |
2656 | void KABCore::sync_save() | 2799 | void KABCore::sync_save() |
2657 | { | 2800 | { |
2658 | save(); | 2801 | save(); |
2659 | } | 2802 | } |
2660 | 2803 | ||
2661 | 2804 | ||
2662 | 2805 | ||
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 941458d..e6f286b 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,481 +1,483 @@ | |||
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 | 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 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
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 | #include <ksyncmanager.h> | 35 | #include <ksyncmanager.h> |
36 | 36 | ||
37 | namespace KABC { | 37 | namespace KABC { |
38 | class AddressBook; | 38 | class AddressBook; |
39 | } | 39 | } |
40 | 40 | ||
41 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
42 | class KAboutData; | 42 | class KAboutData; |
43 | class KConfig; | 43 | class KConfig; |
44 | 44 | ||
45 | class KAddressBookService; | 45 | class KAddressBookService; |
46 | class LDAPSearchDialog; | 46 | class LDAPSearchDialog; |
47 | #else //KAB_EMBEDDED | 47 | #else //KAB_EMBEDDED |
48 | class KAddressBookMain; | 48 | class KAddressBookMain; |
49 | //US class QAction; | 49 | //US class QAction; |
50 | #endif //KAB_EMBEDDED | 50 | #endif //KAB_EMBEDDED |
51 | class KCMultiDialog; | 51 | class KCMultiDialog; |
52 | class KXMLGUIClient; | 52 | class KXMLGUIClient; |
53 | class ExtensionManager; | 53 | class ExtensionManager; |
54 | class XXPortManager; | 54 | class XXPortManager; |
55 | class JumpButtonBar; | 55 | class JumpButtonBar; |
56 | class IncSearchWidget; | 56 | class IncSearchWidget; |
57 | class KDGanttMinimizeSplitter; | 57 | class KDGanttMinimizeSplitter; |
58 | class KAction; | 58 | class KAction; |
59 | class KActionCollection; | 59 | class KActionCollection; |
60 | class KToggleAction; | 60 | class KToggleAction; |
61 | class KSyncProfile; | 61 | class KSyncProfile; |
62 | 62 | ||
63 | class QAction; | 63 | class QAction; |
64 | class QMenuBar; | 64 | class QMenuBar; |
65 | class QSplitter; | 65 | class QSplitter; |
66 | class ViewContainer; | 66 | class ViewContainer; |
67 | class ViewManager; | 67 | class ViewManager; |
68 | class AddresseeEditorDialog; | 68 | class AddresseeEditorDialog; |
69 | class Ir; | 69 | class Ir; |
70 | 70 | ||
71 | class KABCore : public QWidget, public KSyncInterface | 71 | class KABCore : public QWidget, public KSyncInterface |
72 | { | 72 | { |
73 | Q_OBJECT | 73 | Q_OBJECT |
74 | 74 | ||
75 | public: | 75 | public: |
76 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 76 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
77 | 77 | ||
78 | 78 | ||
79 | ~KABCore(); | 79 | ~KABCore(); |
80 | 80 | ||
81 | 81 | ||
82 | #ifdef KAB_EMBEDDED | 82 | #ifdef KAB_EMBEDDED |
83 | //US added functionality | 83 | //US added functionality |
84 | QPopupMenu* getViewMenu() {return viewMenu;} | 84 | QPopupMenu* getViewMenu() {return viewMenu;} |
85 | QPopupMenu* getFilterMenu() {return filterMenu;} | 85 | QPopupMenu* getFilterMenu() {return filterMenu;} |
86 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 86 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
87 | void addActionsManually(); | 87 | void addActionsManually(); |
88 | #endif //KAB_EMBEDDED | 88 | #endif //KAB_EMBEDDED |
89 | /** | 89 | /** |
90 | Restores the global settings. | 90 | Restores the global settings. |
91 | */ | 91 | */ |
92 | void restoreSettings(); | 92 | void restoreSettings(); |
93 | 93 | ||
94 | /** | 94 | /** |
95 | Saves the global settings. | 95 | Saves the global settings. |
96 | */ | 96 | */ |
97 | void saveSettings(); | 97 | void saveSettings(); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | Returns a pointer to the StdAddressBook of the application. | 100 | Returns a pointer to the StdAddressBook of the application. |
101 | */ | 101 | */ |
102 | KABC::AddressBook *addressBook() const; | 102 | KABC::AddressBook *addressBook() const; |
103 | 103 | ||
104 | /** | 104 | /** |
105 | Returns a pointer to the KConfig object of the application. | 105 | Returns a pointer to the KConfig object of the application. |
106 | */ | 106 | */ |
107 | static KConfig *config(); | 107 | static KConfig *config(); |
108 | 108 | ||
109 | /** | 109 | /** |
110 | Returns a pointer to the global KActionCollection object. So | 110 | Returns a pointer to the global KActionCollection object. So |
111 | other classes can register their actions easily. | 111 | other classes can register their actions easily. |
112 | */ | 112 | */ |
113 | KActionCollection *actionCollection() const; | 113 | KActionCollection *actionCollection() const; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | Returns the current search field of the Incremental Search Widget. | 116 | Returns the current search field of the Incremental Search Widget. |
117 | */ | 117 | */ |
118 | KABC::Field *currentSearchField() const; | 118 | KABC::Field *currentSearchField() const; |
119 | 119 | ||
120 | /** | 120 | /** |
121 | Returns the uid list of the currently selected contacts. | 121 | Returns the uid list of the currently selected contacts. |
122 | */ | 122 | */ |
123 | QStringList selectedUIDs() const; | 123 | QStringList selectedUIDs() const; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | Displays the ResourceSelectDialog and returns the selected | 126 | Displays the ResourceSelectDialog and returns the selected |
127 | resource or a null pointer if no resource was selected by | 127 | resource or a null pointer if no resource was selected by |
128 | the user. | 128 | the user. |
129 | */ | 129 | */ |
130 | KABC::Resource *requestResource( QWidget *parent ); | 130 | KABC::Resource *requestResource( QWidget *parent ); |
131 | 131 | ||
132 | #ifndef KAB_EMBEDDED | 132 | #ifndef KAB_EMBEDDED |
133 | static KAboutData *createAboutData(); | 133 | static KAboutData *createAboutData(); |
134 | #endif //KAB_EMBEDDED | 134 | #endif //KAB_EMBEDDED |
135 | 135 | ||
136 | #ifdef KAB_EMBEDDED | 136 | #ifdef KAB_EMBEDDED |
137 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 137 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
138 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 138 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
139 | #endif //KAB_EMBEDDED | 139 | #endif //KAB_EMBEDDED |
140 | 140 | ||
141 | public slots: | 141 | public slots: |
142 | #ifdef KAB_EMBEDDED | 142 | #ifdef KAB_EMBEDDED |
143 | void createAboutData(); | 143 | void createAboutData(); |
144 | #endif //KAB_EMBEDDED | 144 | #endif //KAB_EMBEDDED |
145 | 145 | ||
146 | void statusMessage(QString, int time = 0 ); | 146 | void statusMessage(QString, int time = 0 ); |
147 | void showLicence(); | 147 | void showLicence(); |
148 | void faq(); | 148 | void faq(); |
149 | 149 | ||
150 | /** | 150 | /** |
151 | Is called whenever a contact is selected in the view. | 151 | Is called whenever a contact is selected in the view. |
152 | */ | 152 | */ |
153 | void setContactSelected( const QString &uid ); | 153 | void setContactSelected( const QString &uid ); |
154 | 154 | ||
155 | /** | 155 | /** |
156 | Opens the preferred mail composer with all selected contacts as | 156 | Opens the preferred mail composer with all selected contacts as |
157 | arguments. | 157 | arguments. |
158 | */ | 158 | */ |
159 | void sendMail(); | 159 | void sendMail(); |
160 | 160 | ||
161 | /** | 161 | /** |
162 | Opens the preferred mail composer with the given contacts as | 162 | Opens the preferred mail composer with the given contacts as |
163 | arguments. | 163 | arguments. |
164 | */ | 164 | */ |
165 | void sendMail( const QString& email ); | 165 | void sendMail( const QString& email ); |
166 | 166 | ||
167 | 167 | ||
168 | void mailVCard(); | 168 | void mailVCard(); |
169 | void mailVCard(const QStringList& uids); | 169 | void mailVCard(const QStringList& uids); |
170 | 170 | ||
171 | /** | 171 | /** |
172 | Beams the "WhoAmI contact. | 172 | Beams the "WhoAmI contact. |
173 | */ | 173 | */ |
174 | void beamMySelf(); | 174 | void beamMySelf(); |
175 | 175 | ||
176 | void beamVCard(); | 176 | void beamVCard(); |
177 | void export2phone(); | ||
177 | void beamVCard(const QStringList& uids); | 178 | void beamVCard(const QStringList& uids); |
178 | void beamDone( Ir *ir ); | 179 | void beamDone( Ir *ir ); |
179 | 180 | ||
180 | 181 | ||
181 | /** | 182 | /** |
182 | Starts the preferred web browser with the given URL as argument. | 183 | Starts the preferred web browser with the given URL as argument. |
183 | */ | 184 | */ |
184 | void browse( const QString& url ); | 185 | void browse( const QString& url ); |
185 | 186 | ||
186 | /** | 187 | /** |
187 | Select all contacts in the view. | 188 | Select all contacts in the view. |
188 | */ | 189 | */ |
189 | void selectAllContacts(); | 190 | void selectAllContacts(); |
190 | 191 | ||
191 | /** | 192 | /** |
192 | Deletes all selected contacts from the address book. | 193 | Deletes all selected contacts from the address book. |
193 | */ | 194 | */ |
194 | void deleteContacts(); | 195 | void deleteContacts(); |
195 | 196 | ||
196 | /** | 197 | /** |
197 | Deletes given contacts from the address book. | 198 | Deletes given contacts from the address book. |
198 | 199 | ||
199 | @param uids The uids of the contacts, which shall be deleted. | 200 | @param uids The uids of the contacts, which shall be deleted. |
200 | */ | 201 | */ |
201 | void deleteContacts( const QStringList &uids ); | 202 | void deleteContacts( const QStringList &uids ); |
202 | 203 | ||
203 | /** | 204 | /** |
204 | Copys the selected contacts into clipboard for later pasting. | 205 | Copys the selected contacts into clipboard for later pasting. |
205 | */ | 206 | */ |
206 | void copyContacts(); | 207 | void copyContacts(); |
207 | 208 | ||
208 | /** | 209 | /** |
209 | Cuts the selected contacts and stores them for later pasting. | 210 | Cuts the selected contacts and stores them for later pasting. |
210 | */ | 211 | */ |
211 | void cutContacts(); | 212 | void cutContacts(); |
212 | 213 | ||
213 | /** | 214 | /** |
214 | Paste contacts from clipboard into the address book. | 215 | Paste contacts from clipboard into the address book. |
215 | */ | 216 | */ |
216 | void pasteContacts(); | 217 | void pasteContacts(); |
217 | 218 | ||
218 | /** | 219 | /** |
219 | Paste given contacts into the address book. | 220 | Paste given contacts into the address book. |
220 | 221 | ||
221 | @param list The list of addressee, which shall be pasted. | 222 | @param list The list of addressee, which shall be pasted. |
222 | */ | 223 | */ |
223 | void pasteContacts( KABC::Addressee::List &list ); | 224 | void pasteContacts( KABC::Addressee::List &list ); |
224 | 225 | ||
225 | /** | 226 | /** |
226 | Sets the whoAmI contact, that is used by many other programs to | 227 | Sets the whoAmI contact, that is used by many other programs to |
227 | get personal information about the current user. | 228 | get personal information about the current user. |
228 | */ | 229 | */ |
229 | void setWhoAmI(); | 230 | void setWhoAmI(); |
230 | 231 | ||
231 | /** | 232 | /** |
232 | Displays the category dialog and applies the result to all | 233 | Displays the category dialog and applies the result to all |
233 | selected contacts. | 234 | selected contacts. |
234 | */ | 235 | */ |
235 | void setCategories(); | 236 | void setCategories(); |
236 | 237 | ||
237 | /** | 238 | /** |
238 | Sets the field list of the Incremental Search Widget. | 239 | Sets the field list of the Incremental Search Widget. |
239 | */ | 240 | */ |
240 | void setSearchFields( const KABC::Field::List &fields ); | 241 | void setSearchFields( const KABC::Field::List &fields ); |
241 | 242 | ||
242 | /** | 243 | /** |
243 | Search with the current search field for a contact, that matches | 244 | Search with the current search field for a contact, that matches |
244 | the given text, and selects it in the view. | 245 | the given text, and selects it in the view. |
245 | */ | 246 | */ |
246 | void incrementalSearch( const QString& text ); | 247 | void incrementalSearch( const QString& text ); |
247 | 248 | ||
248 | /** | 249 | /** |
249 | Marks the address book as modified. | 250 | Marks the address book as modified. |
250 | */ | 251 | */ |
251 | void setModified(); | 252 | void setModified(); |
252 | /** | 253 | /** |
253 | Marks the address book as modified without refreshing the view. | 254 | Marks the address book as modified without refreshing the view. |
254 | */ | 255 | */ |
255 | void setModifiedWOrefresh(); | 256 | void setModifiedWOrefresh(); |
256 | 257 | ||
257 | /** | 258 | /** |
258 | Marks the address book as modified concerning the argument. | 259 | Marks the address book as modified concerning the argument. |
259 | */ | 260 | */ |
260 | void setModified( bool modified ); | 261 | void setModified( bool modified ); |
261 | 262 | ||
262 | /** | 263 | /** |
263 | Returns whether the address book is modified. | 264 | Returns whether the address book is modified. |
264 | */ | 265 | */ |
265 | bool modified() const; | 266 | bool modified() const; |
266 | 267 | ||
267 | /** | 268 | /** |
268 | Called whenever an contact is modified in the contact editor | 269 | Called whenever an contact is modified in the contact editor |
269 | dialog or the quick edit. | 270 | dialog or the quick edit. |
270 | */ | 271 | */ |
271 | void contactModified( const KABC::Addressee &addr ); | 272 | void contactModified( const KABC::Addressee &addr ); |
272 | 273 | ||
273 | /** | 274 | /** |
274 | DCOP METHODS. | 275 | DCOP METHODS. |
275 | */ | 276 | */ |
276 | void addEmail( QString addr ); | 277 | void addEmail( QString addr ); |
277 | void importVCard( const KURL& url, bool showPreview ); | 278 | void importVCard( const KURL& url, bool showPreview ); |
278 | void importVCard( const QString& vCard, bool showPreview ); | 279 | void importVCard( const QString& vCard, bool showPreview ); |
279 | void newContact(); | 280 | void newContact(); |
280 | QString getNameByPhone( const QString& phone ); | 281 | QString getNameByPhone( const QString& phone ); |
281 | /** | 282 | /** |
282 | END DCOP METHODS | 283 | END DCOP METHODS |
283 | */ | 284 | */ |
284 | 285 | ||
285 | /** | 286 | /** |
286 | Saves the contents of the AddressBook back to disk. | 287 | Saves the contents of the AddressBook back to disk. |
287 | */ | 288 | */ |
288 | void save(); | 289 | void save(); |
289 | 290 | ||
290 | /** | 291 | /** |
291 | Undos the last command using the undo stack. | 292 | Undos the last command using the undo stack. |
292 | */ | 293 | */ |
293 | void undo(); | 294 | void undo(); |
294 | 295 | ||
295 | /** | 296 | /** |
296 | Redos the last command that was undone, using the redo stack. | 297 | Redos the last command that was undone, using the redo stack. |
297 | */ | 298 | */ |
298 | void redo(); | 299 | void redo(); |
299 | 300 | ||
300 | /** | 301 | /** |
301 | Shows the edit dialog for the given uid. If the uid is QString::null, | 302 | Shows the edit dialog for the given uid. If the uid is QString::null, |
302 | the method will try to find a selected addressee in the view. | 303 | the method will try to find a selected addressee in the view. |
303 | */ | 304 | */ |
304 | void editContact( const QString &uid /*US = QString::null*/ ); | 305 | void editContact( const QString &uid /*US = QString::null*/ ); |
305 | //US added a second method without defaultparameter | 306 | //US added a second method without defaultparameter |
306 | void editContact2(); | 307 | void editContact2(); |
307 | 308 | ||
308 | /** | 309 | /** |
309 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 310 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
310 | the method will try to find a selected addressee in the view. | 311 | the method will try to find a selected addressee in the view. |
311 | */ | 312 | */ |
312 | void executeContact( const QString &uid /*US = QString::null*/ ); | 313 | void executeContact( const QString &uid /*US = QString::null*/ ); |
313 | 314 | ||
314 | /** | 315 | /** |
315 | Launches the configuration dialog. | 316 | Launches the configuration dialog. |
316 | */ | 317 | */ |
317 | void openConfigDialog(); | 318 | void openConfigDialog(); |
318 | 319 | ||
319 | /** | 320 | /** |
320 | Launches the ldap search dialog. | 321 | Launches the ldap search dialog. |
321 | */ | 322 | */ |
322 | void openLDAPDialog(); | 323 | void openLDAPDialog(); |
323 | 324 | ||
324 | /** | 325 | /** |
325 | Creates a KAddressBookPrinter, which will display the print | 326 | Creates a KAddressBookPrinter, which will display the print |
326 | dialog and do the printing. | 327 | dialog and do the printing. |
327 | */ | 328 | */ |
328 | void print(); | 329 | void print(); |
329 | 330 | ||
330 | /** | 331 | /** |
331 | Registers a new GUI client, so plugins can register its actions. | 332 | Registers a new GUI client, so plugins can register its actions. |
332 | */ | 333 | */ |
333 | void addGUIClient( KXMLGUIClient *client ); | 334 | void addGUIClient( KXMLGUIClient *client ); |
334 | 335 | ||
335 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 336 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
336 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 337 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
337 | 338 | ||
338 | 339 | ||
339 | signals: | 340 | signals: |
340 | void contactSelected( const QString &name ); | 341 | void contactSelected( const QString &name ); |
341 | void contactSelected( const QPixmap &pixmap ); | 342 | void contactSelected( const QPixmap &pixmap ); |
342 | public slots: | 343 | public slots: |
343 | void setDetailsVisible( bool visible ); | 344 | void setDetailsVisible( bool visible ); |
344 | void setDetailsToState(); | 345 | void setDetailsToState(); |
345 | // void slotSyncMenu( int ); | 346 | // void slotSyncMenu( int ); |
346 | private slots: | 347 | private slots: |
347 | void setJumpButtonBarVisible( bool visible ); | 348 | void setJumpButtonBarVisible( bool visible ); |
348 | void importFromOL(); | 349 | void importFromOL(); |
349 | void extensionModified( const KABC::Addressee::List &list ); | 350 | void extensionModified( const KABC::Addressee::List &list ); |
350 | void extensionChanged( int id ); | 351 | void extensionChanged( int id ); |
351 | void clipboardDataChanged(); | 352 | void clipboardDataChanged(); |
352 | void updateActionMenu(); | 353 | void updateActionMenu(); |
353 | void configureKeyBindings(); | 354 | void configureKeyBindings(); |
354 | void removeVoice(); | 355 | void removeVoice(); |
355 | #ifdef KAB_EMBEDDED | 356 | #ifdef KAB_EMBEDDED |
356 | void configureResources(); | 357 | void configureResources(); |
357 | #endif //KAB_EMBEDDED | 358 | #endif //KAB_EMBEDDED |
358 | 359 | ||
359 | void slotEditorDestroyed( const QString &uid ); | 360 | void slotEditorDestroyed( const QString &uid ); |
360 | void configurationChanged(); | 361 | void configurationChanged(); |
361 | void addressBookChanged(); | 362 | void addressBookChanged(); |
362 | 363 | ||
363 | private: | 364 | private: |
364 | void initGUI(); | 365 | void initGUI(); |
365 | void initActions(); | 366 | void initActions(); |
366 | 367 | ||
367 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 368 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
368 | const char *name = 0 ); | 369 | const char *name = 0 ); |
369 | 370 | ||
370 | KXMLGUIClient *mGUIClient; | 371 | KXMLGUIClient *mGUIClient; |
371 | 372 | ||
372 | KABC::AddressBook *mAddressBook; | 373 | KABC::AddressBook *mAddressBook; |
373 | 374 | ||
374 | ViewManager *mViewManager; | 375 | ViewManager *mViewManager; |
375 | // QSplitter *mDetailsSplitter; | 376 | // QSplitter *mDetailsSplitter; |
376 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 377 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
377 | ViewContainer *mDetails; | 378 | ViewContainer *mDetails; |
378 | KDGanttMinimizeSplitter* mMiniSplitter; | 379 | KDGanttMinimizeSplitter* mMiniSplitter; |
379 | XXPortManager *mXXPortManager; | 380 | XXPortManager *mXXPortManager; |
380 | JumpButtonBar *mJumpButtonBar; | 381 | JumpButtonBar *mJumpButtonBar; |
381 | IncSearchWidget *mIncSearchWidget; | 382 | IncSearchWidget *mIncSearchWidget; |
382 | ExtensionManager *mExtensionManager; | 383 | ExtensionManager *mExtensionManager; |
383 | 384 | ||
384 | KCMultiDialog *mConfigureDialog; | 385 | KCMultiDialog *mConfigureDialog; |
385 | 386 | ||
386 | #ifndef KAB_EMBEDDED | 387 | #ifndef KAB_EMBEDDED |
387 | LDAPSearchDialog *mLdapSearchDialog; | 388 | LDAPSearchDialog *mLdapSearchDialog; |
388 | #endif //KAB_EMBEDDED | 389 | #endif //KAB_EMBEDDED |
389 | // QDict<AddresseeEditorDialog> mEditorDict; | 390 | // QDict<AddresseeEditorDialog> mEditorDict; |
390 | AddresseeEditorDialog *mEditorDialog; | 391 | AddresseeEditorDialog *mEditorDialog; |
391 | bool mReadWrite; | 392 | bool mReadWrite; |
392 | bool mModified; | 393 | bool mModified; |
393 | bool mIsPart; | 394 | bool mIsPart; |
394 | bool mMultipleViewsAtOnce; | 395 | bool mMultipleViewsAtOnce; |
395 | 396 | ||
396 | 397 | ||
397 | //US file menu | 398 | //US file menu |
398 | KAction *mActionMail; | 399 | KAction *mActionMail; |
399 | KAction *mActionBeam; | 400 | KAction *mActionBeam; |
401 | KAction *mActionExport2phone; | ||
400 | KAction* mActionPrint; | 402 | KAction* mActionPrint; |
401 | KAction* mActionNewContact; | 403 | KAction* mActionNewContact; |
402 | KAction *mActionSave; | 404 | KAction *mActionSave; |
403 | KAction *mActionEditAddressee; | 405 | KAction *mActionEditAddressee; |
404 | KAction *mActionMailVCard; | 406 | KAction *mActionMailVCard; |
405 | KAction *mActionBeamVCard; | 407 | KAction *mActionBeamVCard; |
406 | 408 | ||
407 | KAction *mActionQuit; | 409 | KAction *mActionQuit; |
408 | 410 | ||
409 | //US edit menu | 411 | //US edit menu |
410 | KAction *mActionCopy; | 412 | KAction *mActionCopy; |
411 | KAction *mActionCut; | 413 | KAction *mActionCut; |
412 | KAction *mActionPaste; | 414 | KAction *mActionPaste; |
413 | KAction *mActionSelectAll; | 415 | KAction *mActionSelectAll; |
414 | KAction *mActionUndo; | 416 | KAction *mActionUndo; |
415 | KAction *mActionRedo; | 417 | KAction *mActionRedo; |
416 | KAction *mActionDelete; | 418 | KAction *mActionDelete; |
417 | 419 | ||
418 | //US settings menu | 420 | //US settings menu |
419 | KAction *mActionConfigResources; | 421 | KAction *mActionConfigResources; |
420 | KAction *mActionConfigKAddressbook; | 422 | KAction *mActionConfigKAddressbook; |
421 | KAction *mActionConfigShortcuts; | 423 | KAction *mActionConfigShortcuts; |
422 | KAction *mActionConfigureToolbars; | 424 | KAction *mActionConfigureToolbars; |
423 | KAction *mActionKeyBindings; | 425 | KAction *mActionKeyBindings; |
424 | KToggleAction *mActionJumpBar; | 426 | KToggleAction *mActionJumpBar; |
425 | KToggleAction *mActionDetails; | 427 | KToggleAction *mActionDetails; |
426 | KAction *mActionWhoAmI; | 428 | KAction *mActionWhoAmI; |
427 | KAction *mActionCategories; | 429 | KAction *mActionCategories; |
428 | KAction *mActionAboutKAddressbook; | 430 | KAction *mActionAboutKAddressbook; |
429 | KAction *mActionLicence; | 431 | KAction *mActionLicence; |
430 | KAction *mActionFaq; | 432 | KAction *mActionFaq; |
431 | 433 | ||
432 | KAction *mActionDeleteView; | 434 | KAction *mActionDeleteView; |
433 | 435 | ||
434 | QPopupMenu *viewMenu; | 436 | QPopupMenu *viewMenu; |
435 | QPopupMenu *filterMenu; | 437 | QPopupMenu *filterMenu; |
436 | QPopupMenu *settingsMenu; | 438 | QPopupMenu *settingsMenu; |
437 | QPopupMenu *changeMenu; | 439 | QPopupMenu *changeMenu; |
438 | //US QAction *mActionSave; | 440 | //US QAction *mActionSave; |
439 | QPopupMenu *ImportMenu; | 441 | QPopupMenu *ImportMenu; |
440 | QPopupMenu *ExportMenu; | 442 | QPopupMenu *ExportMenu; |
441 | //LR additional methods | 443 | //LR additional methods |
442 | KAction *mActionRemoveVoice; | 444 | KAction *mActionRemoveVoice; |
443 | KAction * mActionImportOL; | 445 | KAction * mActionImportOL; |
444 | 446 | ||
445 | #ifndef KAB_EMBEDDED | 447 | #ifndef KAB_EMBEDDED |
446 | KAddressBookService *mAddressBookService; | 448 | KAddressBookService *mAddressBookService; |
447 | #endif //KAB_EMBEDDED | 449 | #endif //KAB_EMBEDDED |
448 | 450 | ||
449 | class KABCorePrivate; | 451 | class KABCorePrivate; |
450 | KABCorePrivate *d; | 452 | KABCorePrivate *d; |
451 | //US bool mBlockSaveFlag; | 453 | //US bool mBlockSaveFlag; |
452 | 454 | ||
453 | #ifdef KAB_EMBEDDED | 455 | #ifdef KAB_EMBEDDED |
454 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 456 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
455 | #endif //KAB_EMBEDDED | 457 | #endif //KAB_EMBEDDED |
456 | 458 | ||
457 | //this are the overwritten callbackmethods from the syncinterface | 459 | //this are the overwritten callbackmethods from the syncinterface |
458 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 460 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
459 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 461 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
460 | 462 | ||
461 | //called by the syncmanager to indicate that the work has to marked as dirty. | 463 | //called by the syncmanager to indicate that the work has to marked as dirty. |
462 | virtual void sync_setModified(); | 464 | virtual void sync_setModified(); |
463 | //called by the syncmanager to ask if the dirty flag is set. | 465 | //called by the syncmanager to ask if the dirty flag is set. |
464 | virtual bool sync_isModified(); | 466 | virtual bool sync_isModified(); |
465 | //called by the syncmanager to indicate that the work has to be saved. | 467 | //called by the syncmanager to indicate that the work has to be saved. |
466 | virtual void sync_save(); | 468 | virtual void sync_save(); |
467 | 469 | ||
468 | // LR ******************************* | 470 | // LR ******************************* |
469 | // sync stuff! | 471 | // sync stuff! |
470 | QPopupMenu *syncMenu; | 472 | QPopupMenu *syncMenu; |
471 | KSyncManager* syncManager; | 473 | KSyncManager* syncManager; |
472 | int mGlobalSyncMode; | 474 | int mGlobalSyncMode; |
473 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 475 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
474 | KABC::Addressee getLastSyncAddressee(); | 476 | KABC::Addressee getLastSyncAddressee(); |
475 | QDateTime mLastAddressbookSync; | 477 | QDateTime mLastAddressbookSync; |
476 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 478 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
477 | // ********************* | 479 | // ********************* |
478 | 480 | ||
479 | }; | 481 | }; |
480 | 482 | ||
481 | #endif | 483 | #endif |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 716a125..84e3d00 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,579 +1,575 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kemailsettings.h> | 42 | #include <kemailsettings.h> |
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "mainwindow.h" | 47 | #include "mainwindow.h" |
48 | 48 | ||
49 | const char *germanwords[][2] = { | 49 | const char *germanwords[][2] = { |
50 | #include "wordsgerman.h" | 50 | #include "wordsgerman.h" |
51 | "", "" | 51 | "", "" |
52 | }; | 52 | }; |
53 | 53 | ||
54 | KOPrefs *KOPrefs::mInstance = 0; | 54 | KOPrefs *KOPrefs::mInstance = 0; |
55 | static KStaticDeleter<KOPrefs> insd; | 55 | static KStaticDeleter<KOPrefs> insd; |
56 | 56 | ||
57 | KOPrefs::KOPrefs() : | 57 | KOPrefs::KOPrefs() : |
58 | KPimPrefs("korganizerrc") | 58 | KPimPrefs("korganizerrc") |
59 | { | 59 | { |
60 | mCategoryColors.setAutoDelete(true); | 60 | mCategoryColors.setAutoDelete(true); |
61 | mLocaleDict = 0; | 61 | mLocaleDict = 0; |
62 | fillMailDefaults(); | 62 | fillMailDefaults(); |
63 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 63 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
64 | QColor defaultHolidayColor = QColor(255,0,0); | 64 | QColor defaultHolidayColor = QColor(255,0,0); |
65 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 65 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
66 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 66 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
67 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 67 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
68 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 68 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
69 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 69 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
70 | 70 | ||
71 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); | 71 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); |
72 | mDefaultViewFont = QFont("helvetica",10); | 72 | mDefaultViewFont = QFont("helvetica",10); |
73 | mDefaultMonthViewFont = QFont("helvetica",8); | 73 | mDefaultMonthViewFont = QFont("helvetica",8); |
74 | mMarcusBainsFont= QFont("helvetica",10); | 74 | mMarcusBainsFont= QFont("helvetica",10); |
75 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); | 75 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); |
76 | mEditBoxFont = QFont("helvetica",12); | 76 | mEditBoxFont = QFont("helvetica",12); |
77 | mJornalViewFont = QFont("helvetica",12); | 77 | mJornalViewFont = QFont("helvetica",12); |
78 | 78 | ||
79 | KPrefs::setCurrentGroup("General"); | 79 | KPrefs::setCurrentGroup("General"); |
80 | 80 | ||
81 | 81 | ||
82 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); | ||
83 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); | ||
84 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); | ||
85 | |||
86 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 82 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
87 | 83 | ||
88 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 84 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
89 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 85 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
90 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 86 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
91 | addItemBool("ShowIconList",&mShowIconList,true); | 87 | addItemBool("ShowIconList",&mShowIconList,true); |
92 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 88 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
93 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 89 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
94 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 90 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
95 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 91 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
96 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 92 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
97 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 93 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
98 | addItemBool("ShowIconBack",&mShowIconBack,true); | 94 | addItemBool("ShowIconBack",&mShowIconBack,true); |
99 | addItemBool("ShowIconToday",&mShowIconToday,true); | 95 | addItemBool("ShowIconToday",&mShowIconToday,true); |
100 | addItemBool("ShowIconForward",&mShowIconForward,true); | 96 | addItemBool("ShowIconForward",&mShowIconForward,true); |
101 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 97 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
102 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); | 98 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); |
103 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 99 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
104 | addItemBool("ShowIconNext",&mShowIconNext,true); | 100 | addItemBool("ShowIconNext",&mShowIconNext,true); |
105 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 101 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
106 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 102 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
107 | addItemBool("LanguageChanged",&mLanguageChanged,false); | 103 | addItemBool("LanguageChanged",&mLanguageChanged,false); |
108 | 104 | ||
109 | addItemBool("AskForQuit",&mAskForQuit,false); | 105 | addItemBool("AskForQuit",&mAskForQuit,false); |
110 | 106 | ||
111 | #ifndef DESKTOP_VERSION | 107 | #ifndef DESKTOP_VERSION |
112 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 108 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
113 | #else | 109 | #else |
114 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 110 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
115 | #endif | 111 | #endif |
116 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 112 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
117 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 113 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
118 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 114 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
119 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 115 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
120 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 116 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
121 | 117 | ||
122 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 118 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
123 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
124 | addItemInt("AllDay Size",&mAllDaySize,28); | 120 | addItemInt("AllDay Size",&mAllDaySize,28); |
125 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
126 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
127 | 123 | ||
128 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 124 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
129 | addItemStringList("EventSummary User",&mEventSummaryUser); | 125 | addItemStringList("EventSummary User",&mEventSummaryUser); |
130 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
131 | 127 | ||
132 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
133 | addItemBool("Enable Project View",&mEnableProjectView,false); | 129 | addItemBool("Enable Project View",&mEnableProjectView,false); |
134 | addItemBool("Auto Save",&mAutoSave,false); | 130 | addItemBool("Auto Save",&mAutoSave,false); |
135 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
136 | addItemBool("Confirm Deletes",&mConfirm,true); | 132 | addItemBool("Confirm Deletes",&mConfirm,true); |
137 | addItemString("Archive File",&mArchiveFile); | 133 | addItemString("Archive File",&mArchiveFile); |
138 | addItemString("Html Export File",&mHtmlExportFile, | 134 | addItemString("Html Export File",&mHtmlExportFile, |
139 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
140 | addItemBool("Html With Save",&mHtmlWithSave,false); | 136 | addItemBool("Html With Save",&mHtmlWithSave,false); |
141 | 137 | ||
142 | KPrefs::setCurrentGroup("Personal Settings"); | 138 | KPrefs::setCurrentGroup("Personal Settings"); |
143 | 139 | ||
144 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
145 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
146 | addItemBool("Bcc",&mBcc,false); | 142 | addItemBool("Bcc",&mBcc,false); |
147 | 143 | ||
148 | KPrefs::setCurrentGroup("Time & Date"); | 144 | KPrefs::setCurrentGroup("Time & Date"); |
149 | 145 | ||
150 | // addItemString("Time Zone",&mTimeZone,"+0100"); | 146 | // addItemString("Time Zone",&mTimeZone,"+0100"); |
151 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); | 147 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); |
152 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); | 148 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); |
153 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 149 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
154 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 150 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
155 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 151 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
156 | 152 | ||
157 | 153 | ||
158 | addItemInt("Default Start Time",&mStartTime,10); | 154 | addItemInt("Default Start Time",&mStartTime,10); |
159 | addItemInt("Default Duration",&mDefaultDuration,2); | 155 | addItemInt("Default Duration",&mDefaultDuration,2); |
160 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 156 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
161 | addItemInt("Daylight Savings",&mDaylightSavings,0); | 157 | addItemInt("Daylight Savings",&mDaylightSavings,0); |
162 | KPrefs::setCurrentGroup("AlarmSettings"); | 158 | KPrefs::setCurrentGroup("AlarmSettings"); |
163 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 159 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
164 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 160 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
165 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 161 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
166 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 162 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
167 | 163 | ||
168 | 164 | ||
169 | KPrefs::setCurrentGroup("Calendar"); | 165 | KPrefs::setCurrentGroup("Calendar"); |
170 | 166 | ||
171 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 167 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
172 | 168 | ||
173 | KPrefs::setCurrentGroup("Fonts"); | 169 | KPrefs::setCurrentGroup("Fonts"); |
174 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 170 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
175 | addItemFont("TimeBar Font",&mTimeBarFont); | 171 | addItemFont("TimeBar Font",&mTimeBarFont); |
176 | addItemFont("MonthView Font",&mMonthViewFont); | 172 | addItemFont("MonthView Font",&mMonthViewFont); |
177 | addItemFont("AgendaView Font",&mAgendaViewFont); | 173 | addItemFont("AgendaView Font",&mAgendaViewFont); |
178 | addItemFont("MarcusBains Font",&mMarcusBainsFont); | 174 | addItemFont("MarcusBains Font",&mMarcusBainsFont); |
179 | addItemFont("TimeLabels Font",&mTimeLabelsFont); | 175 | addItemFont("TimeLabels Font",&mTimeLabelsFont); |
180 | addItemFont("TodoView Font",&mTodoViewFont); | 176 | addItemFont("TodoView Font",&mTodoViewFont); |
181 | addItemFont("ListView Font",&mListViewFont); | 177 | addItemFont("ListView Font",&mListViewFont); |
182 | addItemFont("DateNavigator Font",&mDateNavigatorFont); | 178 | addItemFont("DateNavigator Font",&mDateNavigatorFont); |
183 | addItemFont("EditBox Font",&mEditBoxFont); | 179 | addItemFont("EditBox Font",&mEditBoxFont); |
184 | addItemFont("JournalView Font",&mJornalViewFont); | 180 | addItemFont("JournalView Font",&mJornalViewFont); |
185 | addItemFont("WhatsNextView Font",&mWhatsNextFont); | 181 | addItemFont("WhatsNextView Font",&mWhatsNextFont); |
186 | addItemFont("EventView Font",&mEventViewFont); | 182 | addItemFont("EventView Font",&mEventViewFont); |
187 | 183 | ||
188 | // KPrefs::setCurrentGroup("SyncProfiles"); | 184 | // KPrefs::setCurrentGroup("SyncProfiles"); |
189 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); | 185 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); |
190 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); | 186 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); |
191 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); | 187 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); |
192 | 188 | ||
193 | KPrefs::setCurrentGroup("RemoteSyncing"); | 189 | KPrefs::setCurrentGroup("RemoteSyncing"); |
194 | // addItemBool("UsePasswd",&mUsePassWd,false); | 190 | // addItemBool("UsePasswd",&mUsePassWd,false); |
195 | // addItemBool("WriteBackFile",&mWriteBackFile,true); | 191 | // addItemBool("WriteBackFile",&mWriteBackFile,true); |
196 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); | 192 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); |
197 | // addItemBool("AskForPreferences",&mAskForPreferences,true); | 193 | // addItemBool("AskForPreferences",&mAskForPreferences,true); |
198 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); | 194 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); |
199 | addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); | 195 | addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); |
200 | addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); | 196 | addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); |
201 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 197 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
202 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 198 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
203 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 199 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
204 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 200 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
205 | addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); | 201 | addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); |
206 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); | 202 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); |
207 | 203 | ||
208 | #ifdef _WIN32_ | 204 | #ifdef _WIN32_ |
209 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 205 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
210 | #else | 206 | #else |
211 | QString hdp= locateLocal("data","korganizer")+"/"; | 207 | QString hdp= locateLocal("data","korganizer")+"/"; |
212 | #endif | 208 | #endif |
213 | // addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); | 209 | // addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); |
214 | // addItemString("RemoteUser",&mRemoteUser, "zaurus"); | 210 | // addItemString("RemoteUser",&mRemoteUser, "zaurus"); |
215 | // addItemString("RemotePassWd",&mRemotePassWd, ""); | 211 | // addItemString("RemotePassWd",&mRemotePassWd, ""); |
216 | // addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); | 212 | // addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); |
217 | // addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); | 213 | // addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); |
218 | 214 | ||
219 | 215 | ||
220 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 216 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
221 | 217 | ||
222 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 218 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
223 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 219 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
224 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 220 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
225 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 221 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
226 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); | 222 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); |
227 | 223 | ||
228 | 224 | ||
229 | KPrefs::setCurrentGroup("Locale"); | 225 | KPrefs::setCurrentGroup("Locale"); |
230 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 226 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
231 | addItemInt("PreferredTime",&mPreferredTime,0); | 227 | addItemInt("PreferredTime",&mPreferredTime,0); |
232 | addItemInt("PreferredDate",&mPreferredDate,0); | 228 | addItemInt("PreferredDate",&mPreferredDate,0); |
233 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 229 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
234 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 230 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
235 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | 231 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); |
236 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 232 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
237 | 233 | ||
238 | 234 | ||
239 | KPrefs::setCurrentGroup("Colors"); | 235 | KPrefs::setCurrentGroup("Colors"); |
240 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 236 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
241 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 237 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
242 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 238 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
243 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 239 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
244 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 240 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
245 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 241 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
246 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 242 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
247 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 243 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
248 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 244 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
249 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 245 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
250 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 246 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
251 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 247 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
252 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 248 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
253 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 249 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
254 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 250 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
255 | addItemBool("UseAppColors",&mUseAppColors,false); | 251 | addItemBool("UseAppColors",&mUseAppColors,false); |
256 | 252 | ||
257 | 253 | ||
258 | 254 | ||
259 | KPrefs::setCurrentGroup("Views"); | 255 | KPrefs::setCurrentGroup("Views"); |
260 | addItemInt("Hour Size",&mHourSize,8); | 256 | addItemInt("Hour Size",&mHourSize,8); |
261 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 257 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
262 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 258 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
263 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 259 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
264 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 260 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
265 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 261 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
266 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 262 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
267 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 263 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
268 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 264 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
269 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 265 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
270 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 266 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
271 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 267 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
272 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); | 268 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); |
273 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 269 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
274 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 270 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
275 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 271 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
276 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 272 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
277 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); | 273 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); |
278 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 274 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
279 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 275 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
280 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 276 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
281 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 277 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
282 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 278 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
283 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); | 279 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); |
284 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 280 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
285 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 281 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
286 | #ifdef DESKTOP_VERSION | 282 | #ifdef DESKTOP_VERSION |
287 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 283 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
288 | #else | 284 | #else |
289 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 285 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
290 | #endif | 286 | #endif |
291 | addItemInt("Day Begins",&mDayBegins,7); | 287 | addItemInt("Day Begins",&mDayBegins,7); |
292 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 288 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
293 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 289 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
294 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 290 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
295 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 291 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
296 | 292 | ||
297 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 293 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
298 | addItemBool("Full View Month",&mFullViewMonth,true); | 294 | addItemBool("Full View Month",&mFullViewMonth,true); |
299 | addItemBool("Full View Todo",&mFullViewTodo,true); | 295 | addItemBool("Full View Todo",&mFullViewTodo,true); |
300 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 296 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
301 | 297 | ||
302 | addItemInt("Next X Days",&mNextXDays,3); | 298 | addItemInt("Next X Days",&mNextXDays,3); |
303 | 299 | ||
304 | KPrefs::setCurrentGroup("Printer"); | 300 | KPrefs::setCurrentGroup("Printer"); |
305 | 301 | ||
306 | KPrefs::setCurrentGroup("Layout"); | 302 | KPrefs::setCurrentGroup("Layout"); |
307 | 303 | ||
308 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 304 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
309 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 305 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
310 | 306 | ||
311 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 307 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
312 | 308 | ||
313 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 309 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
314 | 310 | ||
315 | KPrefs::setCurrentGroup("Group Scheduling"); | 311 | KPrefs::setCurrentGroup("Group Scheduling"); |
316 | 312 | ||
317 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 313 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
318 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 314 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
319 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 315 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
320 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 316 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
321 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 317 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
322 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 318 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
323 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 319 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
324 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 320 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
325 | 321 | ||
326 | KPrefs::setCurrentGroup( "Editors" ); | 322 | KPrefs::setCurrentGroup( "Editors" ); |
327 | 323 | ||
328 | addItemStringList( "EventTemplates", &mEventTemplates ); | 324 | addItemStringList( "EventTemplates", &mEventTemplates ); |
329 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 325 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
330 | 326 | ||
331 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 327 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
332 | 328 | ||
333 | 329 | ||
334 | 330 | ||
335 | } | 331 | } |
336 | 332 | ||
337 | 333 | ||
338 | KOPrefs::~KOPrefs() | 334 | KOPrefs::~KOPrefs() |
339 | { | 335 | { |
340 | if (mInstance == this) | 336 | if (mInstance == this) |
341 | mInstance = insd.setObject(0); | 337 | mInstance = insd.setObject(0); |
342 | setLocaleDict( 0 ); | 338 | setLocaleDict( 0 ); |
343 | if ( mLocaleDict ) | 339 | if ( mLocaleDict ) |
344 | delete mLocaleDict; | 340 | delete mLocaleDict; |
345 | //qDebug("KOPrefs::~KOPrefs() "); | 341 | //qDebug("KOPrefs::~KOPrefs() "); |
346 | } | 342 | } |
347 | 343 | ||
348 | 344 | ||
349 | KOPrefs *KOPrefs::instance() | 345 | KOPrefs *KOPrefs::instance() |
350 | { | 346 | { |
351 | if (!mInstance) { | 347 | if (!mInstance) { |
352 | mInstance = insd.setObject(new KOPrefs()); | 348 | mInstance = insd.setObject(new KOPrefs()); |
353 | mInstance->readConfig(); | 349 | mInstance->readConfig(); |
354 | } | 350 | } |
355 | 351 | ||
356 | return mInstance; | 352 | return mInstance; |
357 | } | 353 | } |
358 | 354 | ||
359 | void KOPrefs::usrSetDefaults() | 355 | void KOPrefs::usrSetDefaults() |
360 | { | 356 | { |
361 | 357 | ||
362 | } | 358 | } |
363 | 359 | ||
364 | void KOPrefs::fillMailDefaults() | 360 | void KOPrefs::fillMailDefaults() |
365 | { | 361 | { |
366 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 362 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
367 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 363 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
368 | } | 364 | } |
369 | 365 | ||
370 | void KOPrefs::setTimeZoneIdDefault() | 366 | void KOPrefs::setTimeZoneIdDefault() |
371 | { | 367 | { |
372 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); | 368 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); |
373 | } | 369 | } |
374 | 370 | ||
375 | void KOPrefs::setCategoryDefaults() | 371 | void KOPrefs::setCategoryDefaults() |
376 | { | 372 | { |
377 | mCustomCategories.clear(); | 373 | mCustomCategories.clear(); |
378 | mCustomCategories = getDefaultList(); | 374 | mCustomCategories = getDefaultList(); |
379 | 375 | ||
380 | QStringList::Iterator it; | 376 | QStringList::Iterator it; |
381 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 377 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
382 | setCategoryColor(*it,mDefaultCategoryColor); | 378 | setCategoryColor(*it,mDefaultCategoryColor); |
383 | } | 379 | } |
384 | } | 380 | } |
385 | 381 | ||
386 | QStringList KOPrefs::getDefaultList() | 382 | QStringList KOPrefs::getDefaultList() |
387 | { | 383 | { |
388 | QStringList retval ; | 384 | QStringList retval ; |
389 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") | 385 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") |
390 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") | 386 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") |
391 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") | 387 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") |
392 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") | 388 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") |
393 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") | 389 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") |
394 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") | 390 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") |
395 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") | 391 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") |
396 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; | 392 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; |
397 | retval.sort(); | 393 | retval.sort(); |
398 | return retval; | 394 | return retval; |
399 | } | 395 | } |
400 | 396 | ||
401 | void KOPrefs::usrReadConfig() | 397 | void KOPrefs::usrReadConfig() |
402 | { | 398 | { |
403 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 399 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
404 | mLocaleDict = 0; | 400 | mLocaleDict = 0; |
405 | // pending LR fix translation | 401 | // pending LR fix translation |
406 | // qDebug("KOPrefs::usrReadConfig() fix translation "); | 402 | // qDebug("KOPrefs::usrReadConfig() fix translation "); |
407 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { | 403 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { |
408 | if ( mPreferredLanguage == 1 ) { | 404 | if ( mPreferredLanguage == 1 ) { |
409 | mLocaleDict = new QDict<QString>; | 405 | mLocaleDict = new QDict<QString>; |
410 | int i = 0; | 406 | int i = 0; |
411 | QString fw ( germanwords[i] [0]); | 407 | QString fw ( germanwords[i] [0]); |
412 | while ( !fw.isEmpty() ) { | 408 | while ( !fw.isEmpty() ) { |
413 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); | 409 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); |
414 | ++i; | 410 | ++i; |
415 | fw = germanwords[i] [0]; | 411 | fw = germanwords[i] [0]; |
416 | } | 412 | } |
417 | 413 | ||
418 | setLocaleDict( mLocaleDict ); | 414 | setLocaleDict( mLocaleDict ); |
419 | } else { | 415 | } else { |
420 | QString fileName ; | 416 | QString fileName ; |
421 | if ( mPreferredLanguage == 3 ) | 417 | if ( mPreferredLanguage == 3 ) |
422 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; | 418 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; |
423 | else if ( mPreferredLanguage == 2 ) | 419 | else if ( mPreferredLanguage == 2 ) |
424 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; | 420 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; |
425 | QFile file( fileName ); | 421 | QFile file( fileName ); |
426 | if (file.open( IO_ReadOnly ) ) { | 422 | if (file.open( IO_ReadOnly ) ) { |
427 | QTextStream ts( &file ); | 423 | QTextStream ts( &file ); |
428 | ts.setEncoding( QTextStream::Latin1 ); | 424 | ts.setEncoding( QTextStream::Latin1 ); |
429 | //ts.setCodec( QTextCodec::latin1 ); | 425 | //ts.setCodec( QTextCodec::latin1 ); |
430 | QString text = ts.read(); | 426 | QString text = ts.read(); |
431 | file.close(); | 427 | file.close(); |
432 | text.replace( QRegExp("\\\\n"), "\n" ); | 428 | text.replace( QRegExp("\\\\n"), "\n" ); |
433 | QString line; | 429 | QString line; |
434 | QString we; | 430 | QString we; |
435 | QString wt; | 431 | QString wt; |
436 | int br = 0; | 432 | int br = 0; |
437 | int nbr; | 433 | int nbr; |
438 | nbr = text.find ( "},", br ); | 434 | nbr = text.find ( "},", br ); |
439 | line = text.mid( br, nbr - br ); | 435 | line = text.mid( br, nbr - br ); |
440 | br = nbr+1; | 436 | br = nbr+1; |
441 | int se, ee, st, et; | 437 | int se, ee, st, et; |
442 | mLocaleDict = new QDict<QString>; | 438 | mLocaleDict = new QDict<QString>; |
443 | QString end = "{ \"\",\"\" }"; | 439 | QString end = "{ \"\",\"\" }"; |
444 | while ( (line != end) && (br > 1) ) { | 440 | while ( (line != end) && (br > 1) ) { |
445 | //qDebug("%d *%s* ", br, line.latin1()); | 441 | //qDebug("%d *%s* ", br, line.latin1()); |
446 | se = line.find("\"")+1; | 442 | se = line.find("\"")+1; |
447 | et = line.findRev("\"",-1); | 443 | et = line.findRev("\"",-1); |
448 | ee = line.find("\",\""); | 444 | ee = line.find("\",\""); |
449 | st = ee+3; | 445 | st = ee+3; |
450 | we = line.mid( se, ee-se ); | 446 | we = line.mid( se, ee-se ); |
451 | wt = line.mid( st, et-st ); | 447 | wt = line.mid( st, et-st ); |
452 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | 448 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); |
453 | mLocaleDict->insert( we, new QString (wt) ); | 449 | mLocaleDict->insert( we, new QString (wt) ); |
454 | nbr = text.find ( "}", br ); | 450 | nbr = text.find ( "}", br ); |
455 | line = text.mid( br, nbr - br ); | 451 | line = text.mid( br, nbr - br ); |
456 | br = nbr+1; | 452 | br = nbr+1; |
457 | } | 453 | } |
458 | //qDebug("end *%s* ", end.latin1()); | 454 | //qDebug("end *%s* ", end.latin1()); |
459 | 455 | ||
460 | setLocaleDict( mLocaleDict ); | 456 | setLocaleDict( mLocaleDict ); |
461 | } else { | 457 | } else { |
462 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 458 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); |
463 | } | 459 | } |
464 | 460 | ||
465 | } | 461 | } |
466 | } | 462 | } |
467 | config()->setGroup("General"); | 463 | config()->setGroup("General"); |
468 | 464 | ||
469 | mCustomCategories = config()->readListEntry("Custom Categories"); | 465 | mCustomCategories = config()->readListEntry("Custom Categories"); |
470 | if ( KOPrefs::instance()->mLanguageChanged ) { | 466 | if ( KOPrefs::instance()->mLanguageChanged ) { |
471 | mLocationDefaults.clear(); | 467 | mLocationDefaults.clear(); |
472 | mEventSummaryUser.clear(); | 468 | mEventSummaryUser.clear(); |
473 | mTodoSummaryUser.clear(); | 469 | mTodoSummaryUser.clear(); |
474 | } | 470 | } |
475 | if (mLocationDefaults.isEmpty()) { | 471 | if (mLocationDefaults.isEmpty()) { |
476 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 472 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
477 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 473 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
478 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 474 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
479 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 475 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
480 | mLocationDefaults.sort(); | 476 | mLocationDefaults.sort(); |
481 | } | 477 | } |
482 | 478 | ||
483 | if (mEventSummaryUser.isEmpty()) { | 479 | if (mEventSummaryUser.isEmpty()) { |
484 | mEventSummaryUser = getDefaultList() ; | 480 | mEventSummaryUser = getDefaultList() ; |
485 | } | 481 | } |
486 | if (mTodoSummaryUser.isEmpty()) { | 482 | if (mTodoSummaryUser.isEmpty()) { |
487 | mTodoSummaryUser = getDefaultList() ; | 483 | mTodoSummaryUser = getDefaultList() ; |
488 | } | 484 | } |
489 | 485 | ||
490 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 486 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
491 | 487 | ||
492 | config()->setGroup("Personal Settings"); | 488 | config()->setGroup("Personal Settings"); |
493 | mName = config()->readEntry("user_name",""); | 489 | mName = config()->readEntry("user_name",""); |
494 | mEmail = config()->readEntry("user_email",""); | 490 | mEmail = config()->readEntry("user_email",""); |
495 | fillMailDefaults(); | 491 | fillMailDefaults(); |
496 | 492 | ||
497 | config()->setGroup("Category Colors"); | 493 | config()->setGroup("Category Colors"); |
498 | QStringList::Iterator it; | 494 | QStringList::Iterator it; |
499 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 495 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
500 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 496 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
501 | 497 | ||
502 | } | 498 | } |
503 | 499 | ||
504 | if (mTimeZoneId.isEmpty()) { | 500 | if (mTimeZoneId.isEmpty()) { |
505 | setTimeZoneIdDefault(); | 501 | setTimeZoneIdDefault(); |
506 | } | 502 | } |
507 | KPimPrefs::usrReadConfig(); | 503 | KPimPrefs::usrReadConfig(); |
508 | } | 504 | } |
509 | 505 | ||
510 | 506 | ||
511 | void KOPrefs::usrWriteConfig() | 507 | void KOPrefs::usrWriteConfig() |
512 | { | 508 | { |
513 | config()->setGroup("General"); | 509 | config()->setGroup("General"); |
514 | config()->writeEntry("Custom Categories",mCustomCategories); | 510 | config()->writeEntry("Custom Categories",mCustomCategories); |
515 | 511 | ||
516 | config()->setGroup("Personal Settings"); | 512 | config()->setGroup("Personal Settings"); |
517 | config()->writeEntry("user_name",mName); | 513 | config()->writeEntry("user_name",mName); |
518 | config()->writeEntry("user_email",mEmail); | 514 | config()->writeEntry("user_email",mEmail); |
519 | 515 | ||
520 | config()->setGroup("Category Colors"); | 516 | config()->setGroup("Category Colors"); |
521 | QDictIterator<QColor> it(mCategoryColors); | 517 | QDictIterator<QColor> it(mCategoryColors); |
522 | while (it.current()) { | 518 | while (it.current()) { |
523 | config()->writeEntry(it.currentKey(),*(it.current())); | 519 | config()->writeEntry(it.currentKey(),*(it.current())); |
524 | ++it; | 520 | ++it; |
525 | } | 521 | } |
526 | 522 | ||
527 | 523 | ||
528 | KPimPrefs::usrWriteConfig(); | 524 | KPimPrefs::usrWriteConfig(); |
529 | } | 525 | } |
530 | 526 | ||
531 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 527 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
532 | { | 528 | { |
533 | mCategoryColors.replace(cat,new QColor(color)); | 529 | mCategoryColors.replace(cat,new QColor(color)); |
534 | } | 530 | } |
535 | 531 | ||
536 | QColor *KOPrefs::categoryColor(QString cat) | 532 | QColor *KOPrefs::categoryColor(QString cat) |
537 | { | 533 | { |
538 | QColor *color = 0; | 534 | QColor *color = 0; |
539 | 535 | ||
540 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 536 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
541 | 537 | ||
542 | if (color) return color; | 538 | if (color) return color; |
543 | else return &mDefaultCategoryColor; | 539 | else return &mDefaultCategoryColor; |
544 | } | 540 | } |
545 | 541 | ||
546 | void KOPrefs::setFullName(const QString &name) | 542 | void KOPrefs::setFullName(const QString &name) |
547 | { | 543 | { |
548 | mName = name; | 544 | mName = name; |
549 | } | 545 | } |
550 | 546 | ||
551 | void KOPrefs::setEmail(const QString &email) | 547 | void KOPrefs::setEmail(const QString &email) |
552 | { | 548 | { |
553 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 549 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
554 | mEmail = email; | 550 | mEmail = email; |
555 | } | 551 | } |
556 | 552 | ||
557 | QString KOPrefs::fullName() | 553 | QString KOPrefs::fullName() |
558 | { | 554 | { |
559 | if (mEmailControlCenter) { | 555 | if (mEmailControlCenter) { |
560 | KEMailSettings settings; | 556 | KEMailSettings settings; |
561 | return settings.getSetting(KEMailSettings::RealName); | 557 | return settings.getSetting(KEMailSettings::RealName); |
562 | } else { | 558 | } else { |
563 | return mName; | 559 | return mName; |
564 | } | 560 | } |
565 | } | 561 | } |
566 | 562 | ||
567 | QString KOPrefs::email() | 563 | QString KOPrefs::email() |
568 | { | 564 | { |
569 | if (mEmailControlCenter) { | 565 | if (mEmailControlCenter) { |
570 | KEMailSettings settings; | 566 | KEMailSettings settings; |
571 | return settings.getSetting(KEMailSettings::EmailAddress); | 567 | return settings.getSetting(KEMailSettings::EmailAddress); |
572 | } else { | 568 | } else { |
573 | return mEmail; | 569 | return mEmail; |
574 | } | 570 | } |
575 | } | 571 | } |
576 | KConfig* KOPrefs::getConfig() | 572 | KConfig* KOPrefs::getConfig() |
577 | { | 573 | { |
578 | return config(); | 574 | return config(); |
579 | } | 575 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index a1ba8b3..d9ac851 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,316 +1,313 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@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 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | #include <qdict.h> | 26 | #include <qdict.h> |
27 | 27 | ||
28 | #include <libkdepim/kpimprefs.h> | 28 | #include <libkdepim/kpimprefs.h> |
29 | 29 | ||
30 | class KConfig; | 30 | class KConfig; |
31 | class QFont; | 31 | class QFont; |
32 | class QColor; | 32 | class QColor; |
33 | class QStringList; | 33 | class QStringList; |
34 | 34 | ||
35 | class KOPrefs : public KPimPrefs | 35 | class KOPrefs : public KPimPrefs |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | enum { FormatVCalendar, FormatICalendar }; | 38 | enum { FormatVCalendar, FormatICalendar }; |
39 | enum { MailClientKMail, MailClientSendmail }; | 39 | enum { MailClientKMail, MailClientSendmail }; |
40 | enum { IMIPDummy, IMIPKMail }; | 40 | enum { IMIPDummy, IMIPKMail }; |
41 | enum { IMIPOutbox, IMIPdirectsend }; | 41 | enum { IMIPOutbox, IMIPdirectsend }; |
42 | enum { neverAuto, addressbookAuto, selectedAuto }; | 42 | enum { neverAuto, addressbookAuto, selectedAuto }; |
43 | enum { standardDestination, askDestination }; | 43 | enum { standardDestination, askDestination }; |
44 | 44 | ||
45 | virtual ~KOPrefs(); | 45 | virtual ~KOPrefs(); |
46 | 46 | ||
47 | /** Get instance of KOPrefs. It is made sure that there is only one | 47 | /** Get instance of KOPrefs. It is made sure that there is only one |
48 | instance. */ | 48 | instance. */ |
49 | static KOPrefs *instance(); | 49 | static KOPrefs *instance(); |
50 | 50 | ||
51 | /** Set preferences to default values */ | 51 | /** Set preferences to default values */ |
52 | void usrSetDefaults(); | 52 | void usrSetDefaults(); |
53 | 53 | ||
54 | /** Read preferences from config file */ | 54 | /** Read preferences from config file */ |
55 | void usrReadConfig(); | 55 | void usrReadConfig(); |
56 | 56 | ||
57 | /** Write preferences to config file */ | 57 | /** Write preferences to config file */ |
58 | void usrWriteConfig(); | 58 | void usrWriteConfig(); |
59 | void setCategoryDefaults(); | 59 | void setCategoryDefaults(); |
60 | 60 | ||
61 | protected: | 61 | protected: |
62 | void setTimeZoneIdDefault(); | 62 | void setTimeZoneIdDefault(); |
63 | 63 | ||
64 | /** Fill empty mail fields with default values. */ | 64 | /** Fill empty mail fields with default values. */ |
65 | void fillMailDefaults(); | 65 | void fillMailDefaults(); |
66 | 66 | ||
67 | private: | 67 | private: |
68 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 68 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
69 | object. */ | 69 | object. */ |
70 | KOPrefs(); | 70 | KOPrefs(); |
71 | 71 | ||
72 | static KOPrefs *mInstance; | 72 | static KOPrefs *mInstance; |
73 | QDict<QString> *mLocaleDict; | 73 | QDict<QString> *mLocaleDict; |
74 | QStringList getDefaultList(); | 74 | QStringList getDefaultList(); |
75 | public: | 75 | public: |
76 | // preferences data | 76 | // preferences data |
77 | KConfig* getConfig(); | 77 | KConfig* getConfig(); |
78 | void setFullName(const QString &); | 78 | void setFullName(const QString &); |
79 | QString fullName(); | 79 | QString fullName(); |
80 | void setEmail(const QString &); | 80 | void setEmail(const QString &); |
81 | QString email(); | 81 | QString email(); |
82 | 82 | ||
83 | QString mAdditional; | 83 | QString mAdditional; |
84 | 84 | ||
85 | bool mEmailControlCenter; | 85 | bool mEmailControlCenter; |
86 | 86 | ||
87 | bool mBcc; | 87 | bool mBcc; |
88 | bool mAutoSave; | 88 | bool mAutoSave; |
89 | int mAutoSaveInterval; | 89 | int mAutoSaveInterval; |
90 | bool mConfirm; | 90 | bool mConfirm; |
91 | 91 | ||
92 | bool mEnableGroupScheduling; | 92 | bool mEnableGroupScheduling; |
93 | bool mEnableProjectView; | 93 | bool mEnableProjectView; |
94 | 94 | ||
95 | int mDefaultFormat; | 95 | int mDefaultFormat; |
96 | int mMailClient; | 96 | int mMailClient; |
97 | 97 | ||
98 | QString mTimeZone; | 98 | QString mTimeZone; |
99 | //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius | 99 | //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius |
100 | //int mTimeZoneOffset; // e.g. -240 min | 100 | //int mTimeZoneOffset; // e.g. -240 min |
101 | int mStartTime; | 101 | int mStartTime; |
102 | int mDefaultDuration; | 102 | int mDefaultDuration; |
103 | int mAlarmTime; | 103 | int mAlarmTime; |
104 | int mDaylightSavings; | 104 | int mDaylightSavings; |
105 | 105 | ||
106 | int mWorkingHoursStart; | 106 | int mWorkingHoursStart; |
107 | int mWorkingHoursEnd; | 107 | int mWorkingHoursEnd; |
108 | bool mExcludeHolidays; | 108 | bool mExcludeHolidays; |
109 | bool mExcludeSaturdays; | 109 | bool mExcludeSaturdays; |
110 | bool mMarcusBainsShowSeconds; | 110 | bool mMarcusBainsShowSeconds; |
111 | 111 | ||
112 | QFont mTimeBarFont; | 112 | QFont mTimeBarFont; |
113 | QFont mMonthViewFont; | 113 | QFont mMonthViewFont; |
114 | QFont mAgendaViewFont; | 114 | QFont mAgendaViewFont; |
115 | QFont mMarcusBainsFont; | 115 | QFont mMarcusBainsFont; |
116 | QFont mTimeLabelsFont; | 116 | QFont mTimeLabelsFont; |
117 | QFont mTodoViewFont; | 117 | QFont mTodoViewFont; |
118 | QFont mListViewFont; | 118 | QFont mListViewFont; |
119 | QFont mDateNavigatorFont; | 119 | QFont mDateNavigatorFont; |
120 | QFont mEditBoxFont; | 120 | QFont mEditBoxFont; |
121 | QFont mJornalViewFont; | 121 | QFont mJornalViewFont; |
122 | QFont mWhatsNextFont; | 122 | QFont mWhatsNextFont; |
123 | QFont mEventViewFont; | 123 | QFont mEventViewFont; |
124 | 124 | ||
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | QColor mHolidayColor; | 128 | QColor mHolidayColor; |
129 | QColor mHighlightColor; | 129 | QColor mHighlightColor; |
130 | QColor mEventColor; | 130 | QColor mEventColor; |
131 | QColor mAgendaBgColor; | 131 | QColor mAgendaBgColor; |
132 | QColor mWorkingHoursColor; | 132 | QColor mWorkingHoursColor; |
133 | QColor mTodoDueTodayColor; | 133 | QColor mTodoDueTodayColor; |
134 | QColor mTodoOverdueColor; | 134 | QColor mTodoOverdueColor; |
135 | QColor mMonthViewEvenColor; | 135 | QColor mMonthViewEvenColor; |
136 | QColor mMonthViewOddColor; | 136 | QColor mMonthViewOddColor; |
137 | QColor mMonthViewHolidayColor; | 137 | QColor mMonthViewHolidayColor; |
138 | bool mMonthViewUsesDayColors; | 138 | bool mMonthViewUsesDayColors; |
139 | bool mMonthViewSatSunTog; | 139 | bool mMonthViewSatSunTog; |
140 | QColor mAppColor1; | 140 | QColor mAppColor1; |
141 | QColor mAppColor2; | 141 | QColor mAppColor2; |
142 | bool mUseAppColors; | 142 | bool mUseAppColors; |
143 | 143 | ||
144 | int mDayBegins; | 144 | int mDayBegins; |
145 | int mHourSize; | 145 | int mHourSize; |
146 | int mAllDaySize; | 146 | int mAllDaySize; |
147 | bool mShowFullMenu; | 147 | bool mShowFullMenu; |
148 | bool mDailyRecur; | 148 | bool mDailyRecur; |
149 | bool mWeeklyRecur; | 149 | bool mWeeklyRecur; |
150 | bool mMonthDailyRecur; | 150 | bool mMonthDailyRecur; |
151 | bool mMonthWeeklyRecur; | 151 | bool mMonthWeeklyRecur; |
152 | bool mMonthShowIcons; | 152 | bool mMonthShowIcons; |
153 | bool mMonthShowShort; | 153 | bool mMonthShowShort; |
154 | bool mEnableToolTips; | 154 | bool mEnableToolTips; |
155 | bool mEnableMonthScroll; | 155 | bool mEnableMonthScroll; |
156 | bool mFullViewMonth; | 156 | bool mFullViewMonth; |
157 | bool mMonthViewUsesCategoryColor; | 157 | bool mMonthViewUsesCategoryColor; |
158 | bool mFullViewTodo; | 158 | bool mFullViewTodo; |
159 | bool mShowCompletedTodo; | 159 | bool mShowCompletedTodo; |
160 | bool mMarcusBainsEnabled; | 160 | bool mMarcusBainsEnabled; |
161 | int mNextXDays; | 161 | int mNextXDays; |
162 | int mWhatsNextDays; | 162 | int mWhatsNextDays; |
163 | int mWhatsNextPrios; | 163 | int mWhatsNextPrios; |
164 | bool mEnableQuickTodo; | 164 | bool mEnableQuickTodo; |
165 | bool mLanguageChanged; | 165 | bool mLanguageChanged; |
166 | 166 | ||
167 | bool mCompactDialogs; | 167 | bool mCompactDialogs; |
168 | bool mVerticalScreen; | 168 | bool mVerticalScreen; |
169 | 169 | ||
170 | bool mShowIconNewTodo; | 170 | bool mShowIconNewTodo; |
171 | bool mShowIconNewEvent; | 171 | bool mShowIconNewEvent; |
172 | bool mShowIconSearch; | 172 | bool mShowIconSearch; |
173 | bool mShowIconList; | 173 | bool mShowIconList; |
174 | bool mShowIconDay1; | 174 | bool mShowIconDay1; |
175 | bool mShowIconDay5; | 175 | bool mShowIconDay5; |
176 | bool mShowIconDay7; | 176 | bool mShowIconDay7; |
177 | bool mShowIconMonth; | 177 | bool mShowIconMonth; |
178 | bool mShowIconTodoview; | 178 | bool mShowIconTodoview; |
179 | bool mShowIconBackFast; | 179 | bool mShowIconBackFast; |
180 | bool mShowIconBack; | 180 | bool mShowIconBack; |
181 | bool mShowIconToday; | 181 | bool mShowIconToday; |
182 | bool mShowIconForward; | 182 | bool mShowIconForward; |
183 | bool mShowIconForwardFast; | 183 | bool mShowIconForwardFast; |
184 | bool mShowIconWhatsThis; | 184 | bool mShowIconWhatsThis; |
185 | bool mShowIconNextDays; | 185 | bool mShowIconNextDays; |
186 | bool mShowIconNext; | 186 | bool mShowIconNext; |
187 | bool mShowIconJournal; | 187 | bool mShowIconJournal; |
188 | 188 | ||
189 | bool mShowIconStretch; | 189 | bool mShowIconStretch; |
190 | 190 | ||
191 | bool mToolBarHor; | 191 | bool mToolBarHor; |
192 | bool mToolBarUp; | 192 | bool mToolBarUp; |
193 | bool mToolBarMiniIcons; | 193 | bool mToolBarMiniIcons; |
194 | 194 | ||
195 | bool mAskForQuit; | 195 | bool mAskForQuit; |
196 | bool mUsePassWd; | 196 | bool mUsePassWd; |
197 | bool mWriteBackFile; | 197 | bool mWriteBackFile; |
198 | int mWriteBackInFuture; | 198 | int mWriteBackInFuture; |
199 | bool mAskForPreferences; | 199 | bool mAskForPreferences; |
200 | bool mShowSyncSummary; | 200 | bool mShowSyncSummary; |
201 | bool mShowSyncEvents; | 201 | bool mShowSyncEvents; |
202 | bool mShowTodoInAgenda; | 202 | bool mShowTodoInAgenda; |
203 | bool mWriteBackExistingOnly; | 203 | bool mWriteBackExistingOnly; |
204 | 204 | ||
205 | QString mRemoteIP; | 205 | QString mRemoteIP; |
206 | QString mRemoteUser; | 206 | QString mRemoteUser; |
207 | QString mRemotePassWd; | 207 | QString mRemotePassWd; |
208 | QString mRemoteFile; | 208 | QString mRemoteFile; |
209 | QString mLocalTempFile; | 209 | QString mLocalTempFile; |
210 | QString mPhoneDevice; | 210 | QString mPhoneDevice; |
211 | QString mPhoneConnection; | 211 | QString mPhoneConnection; |
212 | QString mPhoneModel; | 212 | QString mPhoneModel; |
213 | QString mEx2PhoneDevice; | ||
214 | QString mEx2PhoneConnection; | ||
215 | QString mEx2PhoneModel; | ||
216 | 213 | ||
217 | int mLastSyncTime; | 214 | int mLastSyncTime; |
218 | int mSyncAlgoPrefs; | 215 | int mSyncAlgoPrefs; |
219 | int mRingSyncAlgoPrefs; | 216 | int mRingSyncAlgoPrefs; |
220 | QStringList mSyncProfileNames; | 217 | QStringList mSyncProfileNames; |
221 | QStringList mExternSyncProfiles; | 218 | QStringList mExternSyncProfiles; |
222 | QString mLocalMachineName; | 219 | QString mLocalMachineName; |
223 | void setCategoryColor(QString cat,const QColor & color); | 220 | void setCategoryColor(QString cat,const QColor & color); |
224 | QColor *categoryColor(QString cat); | 221 | QColor *categoryColor(QString cat); |
225 | 222 | ||
226 | QString mArchiveFile; | 223 | QString mArchiveFile; |
227 | QString mHtmlExportFile; | 224 | QString mHtmlExportFile; |
228 | bool mHtmlWithSave; | 225 | bool mHtmlWithSave; |
229 | 226 | ||
230 | QStringList mSelectedPlugins; | 227 | QStringList mSelectedPlugins; |
231 | 228 | ||
232 | QString mLastImportFile; | 229 | QString mLastImportFile; |
233 | QString mLastVcalFile; | 230 | QString mLastVcalFile; |
234 | QString mLastSaveFile; | 231 | QString mLastSaveFile; |
235 | QString mLastLoadFile; | 232 | QString mLastLoadFile; |
236 | QString mLastSyncedLocalFile; | 233 | QString mLastSyncedLocalFile; |
237 | 234 | ||
238 | 235 | ||
239 | QString mDefaultAlarmFile; | 236 | QString mDefaultAlarmFile; |
240 | int mIMIPScheduler; | 237 | int mIMIPScheduler; |
241 | int mIMIPSend; | 238 | int mIMIPSend; |
242 | QStringList mAdditionalMails; | 239 | QStringList mAdditionalMails; |
243 | int mIMIPAutoRefresh; | 240 | int mIMIPAutoRefresh; |
244 | int mIMIPAutoInsertReply; | 241 | int mIMIPAutoInsertReply; |
245 | int mIMIPAutoInsertRequest; | 242 | int mIMIPAutoInsertRequest; |
246 | int mIMIPAutoFreeBusy; | 243 | int mIMIPAutoFreeBusy; |
247 | int mIMIPAutoFreeBusyReply; | 244 | int mIMIPAutoFreeBusyReply; |
248 | 245 | ||
249 | QStringList mTodoTemplates; | 246 | QStringList mTodoTemplates; |
250 | QStringList mEventTemplates; | 247 | QStringList mEventTemplates; |
251 | 248 | ||
252 | int mDestination; | 249 | int mDestination; |
253 | 250 | ||
254 | 251 | ||
255 | bool mEditOnDoubleClick; | 252 | bool mEditOnDoubleClick; |
256 | bool mViewChangeHoldFullscreen; | 253 | bool mViewChangeHoldFullscreen; |
257 | bool mViewChangeHoldNonFullscreen; | 254 | bool mViewChangeHoldNonFullscreen; |
258 | bool mCenterOnCurrentTime; | 255 | bool mCenterOnCurrentTime; |
259 | bool mSetTimeToDayStartAt; | 256 | bool mSetTimeToDayStartAt; |
260 | bool mHighlightCurrentDay; | 257 | bool mHighlightCurrentDay; |
261 | bool mUseHighlightLightColor; | 258 | bool mUseHighlightLightColor; |
262 | bool mListViewMonthTimespan; | 259 | bool mListViewMonthTimespan; |
263 | bool mWNViewShowsParents; | 260 | bool mWNViewShowsParents; |
264 | bool mWNViewShowLocation; | 261 | bool mWNViewShowLocation; |
265 | bool mTodoViewShowsPercentage; | 262 | bool mTodoViewShowsPercentage; |
266 | bool mTodoViewUsesCatColors; | 263 | bool mTodoViewUsesCatColors; |
267 | bool mTodoViewUsesSmallFont; | 264 | bool mTodoViewUsesSmallFont; |
268 | bool mTodoViewUsesForegroundColor; | 265 | bool mTodoViewUsesForegroundColor; |
269 | bool mMonthViewUsesForegroundColor; | 266 | bool mMonthViewUsesForegroundColor; |
270 | 267 | ||
271 | bool mHightlightDateTimeEdit; | 268 | bool mHightlightDateTimeEdit; |
272 | bool mShortDateInViewer; | 269 | bool mShortDateInViewer; |
273 | 270 | ||
274 | QStringList mLocationDefaults; | 271 | QStringList mLocationDefaults; |
275 | QStringList mEventSummaryUser; | 272 | QStringList mEventSummaryUser; |
276 | QStringList mTodoSummaryUser; | 273 | QStringList mTodoSummaryUser; |
277 | 274 | ||
278 | bool mUseInternalAlarmNotification; | 275 | bool mUseInternalAlarmNotification; |
279 | int mAlarmPlayBeeps; | 276 | int mAlarmPlayBeeps; |
280 | int mAlarmSuspendTime; | 277 | int mAlarmSuspendTime; |
281 | int mAlarmSuspendCount; | 278 | int mAlarmSuspendCount; |
282 | int mAlarmBeepInterval; | 279 | int mAlarmBeepInterval; |
283 | 280 | ||
284 | QString mPassiveSyncPort; | 281 | QString mPassiveSyncPort; |
285 | QString mPassiveSyncPw; | 282 | QString mPassiveSyncPw; |
286 | QString mActiveSyncPort; | 283 | QString mActiveSyncPort; |
287 | QString mActiveSyncIP; | 284 | QString mActiveSyncIP; |
288 | 285 | ||
289 | 286 | ||
290 | //US I copied the following settings into KPimGlobalPrefs | 287 | //US I copied the following settings into KPimGlobalPrefs |
291 | // that allows us later to easily remove the settings from here. | 288 | // that allows us later to easily remove the settings from here. |
292 | int mPreferredDate; | 289 | int mPreferredDate; |
293 | QString mUserDateFormatLong; | 290 | QString mUserDateFormatLong; |
294 | QString mUserDateFormatShort; | 291 | QString mUserDateFormatShort; |
295 | int mPreferredLanguage; | 292 | int mPreferredLanguage; |
296 | int mPreferredTime; | 293 | int mPreferredTime; |
297 | bool mWeekStartsOnSunday; | 294 | bool mWeekStartsOnSunday; |
298 | QString mTimeZoneId; | 295 | QString mTimeZoneId; |
299 | bool mUseDaylightsaving; | 296 | bool mUseDaylightsaving; |
300 | int mDaylightsavingStart; | 297 | int mDaylightsavingStart; |
301 | int mDaylightsavingEnd; | 298 | int mDaylightsavingEnd; |
302 | 299 | ||
303 | 300 | ||
304 | private: | 301 | private: |
305 | QDict<QColor> mCategoryColors; | 302 | QDict<QColor> mCategoryColors; |
306 | QColor mDefaultCategoryColor; | 303 | QColor mDefaultCategoryColor; |
307 | 304 | ||
308 | QFont mDefaultTimeBarFont; | 305 | QFont mDefaultTimeBarFont; |
309 | QFont mDefaultViewFont; | 306 | QFont mDefaultViewFont; |
310 | QFont mDefaultMonthViewFont; | 307 | QFont mDefaultMonthViewFont; |
311 | 308 | ||
312 | QString mName; | 309 | QString mName; |
313 | QString mEmail; | 310 | QString mEmail; |
314 | }; | 311 | }; |
315 | 312 | ||
316 | #endif | 313 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index bd14fbf..2f286e0 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,2668 +1,2669 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkcal/kincidenceformatter.h> | 42 | #include <libkcal/kincidenceformatter.h> |
43 | #include <libkdepim/kpimglobalprefs.h> | 43 | #include <libkdepim/kpimglobalprefs.h> |
44 | 44 | ||
45 | #include "calendarview.h" | 45 | #include "calendarview.h" |
46 | #include "koviewmanager.h" | 46 | #include "koviewmanager.h" |
47 | #include "datenavigator.h" | 47 | #include "datenavigator.h" |
48 | #include "koagendaview.h" | 48 | #include "koagendaview.h" |
49 | #include "koagenda.h" | 49 | #include "koagenda.h" |
50 | #include "kodialogmanager.h" | 50 | #include "kodialogmanager.h" |
51 | #include "kdialogbase.h" | 51 | #include "kdialogbase.h" |
52 | #include "kapplication.h" | 52 | #include "kapplication.h" |
53 | #include "kofilterview.h" | 53 | #include "kofilterview.h" |
54 | #include "kstandarddirs.h" | 54 | #include "kstandarddirs.h" |
55 | #include "koprefs.h" | 55 | #include "koprefs.h" |
56 | #include "kfiledialog.h" | 56 | #include "kfiledialog.h" |
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #include "kglobal.h" | 58 | #include "kglobal.h" |
59 | #include "klocale.h" | 59 | #include "klocale.h" |
60 | #include "kconfig.h" | 60 | #include "kconfig.h" |
61 | #include "simplealarmclient.h" | 61 | #include "simplealarmclient.h" |
62 | #include "externalapphandler.h" | 62 | #include "externalapphandler.h" |
63 | 63 | ||
64 | using namespace KCal; | 64 | using namespace KCal; |
65 | #ifndef _WIN32_ | 65 | #ifndef _WIN32_ |
66 | #include <unistd.h> | 66 | #include <unistd.h> |
67 | #else | 67 | #else |
68 | #include "koimportoldialog.h" | 68 | #include "koimportoldialog.h" |
69 | #endif | 69 | #endif |
70 | #include "mainwindow.h" | 70 | #include "mainwindow.h" |
71 | 71 | ||
72 | class KOex2phonePrefs : public QDialog | 72 | class KOex2phonePrefs : public QDialog |
73 | { | 73 | { |
74 | public: | 74 | public: |
75 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 75 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
76 | QDialog( parent, name, true ) | 76 | QDialog( parent, name, true ) |
77 | { | 77 | { |
78 | setCaption( i18n("Export to phone options") ); | 78 | setCaption( i18n("Export to phone options") ); |
79 | QVBoxLayout* lay = new QVBoxLayout( this ); | 79 | QVBoxLayout* lay = new QVBoxLayout( this ); |
80 | lay->setSpacing( 3 ); | 80 | lay->setSpacing( 3 ); |
81 | lay->setMargin( 3 ); | 81 | lay->setMargin( 3 ); |
82 | QLabel *lab; | 82 | QLabel *lab; |
83 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 83 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
84 | lab->setAlignment (AlignHCenter ); | 84 | lab->setAlignment (AlignHCenter ); |
85 | QHBox* temphb; | 85 | QHBox* temphb; |
86 | temphb = new QHBox( this ); | 86 | temphb = new QHBox( this ); |
87 | new QLabel( i18n("I/O device: "), temphb ); | 87 | new QLabel( i18n("I/O device: "), temphb ); |
88 | mPhoneDevice = new QLineEdit( temphb); | 88 | mPhoneDevice = new QLineEdit( temphb); |
89 | lay->addWidget( temphb ); | 89 | lay->addWidget( temphb ); |
90 | temphb = new QHBox( this ); | 90 | temphb = new QHBox( this ); |
91 | new QLabel( i18n("Connection: "), temphb ); | 91 | new QLabel( i18n("Connection: "), temphb ); |
92 | mPhoneConnection = new QLineEdit( temphb); | 92 | mPhoneConnection = new QLineEdit( temphb); |
93 | lay->addWidget( temphb ); | 93 | lay->addWidget( temphb ); |
94 | temphb = new QHBox( this ); | 94 | temphb = new QHBox( this ); |
95 | new QLabel( i18n("Model(opt.): "), temphb ); | 95 | new QLabel( i18n("Model(opt.): "), temphb ); |
96 | mPhoneModel = new QLineEdit( temphb); | 96 | mPhoneModel = new QLineEdit( temphb); |
97 | lay->addWidget( temphb ); | 97 | lay->addWidget( temphb ); |
98 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 98 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
99 | mWriteBackFuture->setChecked( true ); | 99 | mWriteBackFuture->setChecked( true ); |
100 | lay->addWidget( mWriteBackFuture ); | 100 | lay->addWidget( mWriteBackFuture ); |
101 | temphb = new QHBox( this ); | 101 | temphb = new QHBox( this ); |
102 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 102 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
103 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 103 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
104 | mWriteBackFutureWeeks->setValue( 8 ); | 104 | mWriteBackFutureWeeks->setValue( 8 ); |
105 | lay->addWidget( temphb ); | 105 | lay->addWidget( temphb ); |
106 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\n todo/calendar data on phone!"), this ) ); | 106 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
107 | lab->setAlignment (AlignHCenter ); | 107 | lab->setAlignment (AlignHCenter ); |
108 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 108 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
109 | lay->addWidget( ok ); | 109 | lay->addWidget( ok ); |
110 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 110 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
111 | lay->addWidget( cancel ); | 111 | lay->addWidget( cancel ); |
112 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 112 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
113 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 113 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
114 | resize( 220, 240 ); | 114 | resize( 220, 240 ); |
115 | 115 | ||
116 | } | 116 | } |
117 | 117 | ||
118 | public: | 118 | public: |
119 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 119 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
120 | QCheckBox* mWriteBackFuture; | 120 | QCheckBox* mWriteBackFuture; |
121 | QSpinBox* mWriteBackFutureWeeks; | 121 | QSpinBox* mWriteBackFutureWeeks; |
122 | }; | 122 | }; |
123 | 123 | ||
124 | int globalFlagBlockStartup; | 124 | int globalFlagBlockStartup; |
125 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 125 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
126 | QMainWindow( parent, name ) | 126 | QMainWindow( parent, name ) |
127 | { | 127 | { |
128 | mPassWordPiSync = "abc"; | 128 | mPassWordPiSync = "abc"; |
129 | #ifdef DESKTOP_VERSION | 129 | #ifdef DESKTOP_VERSION |
130 | setFont( QFont("Arial"), 14 ); | 130 | setFont( QFont("Arial"), 14 ); |
131 | #endif | 131 | #endif |
132 | mSyncActionDialog = 0; | 132 | mSyncActionDialog = 0; |
133 | mServerSocket = 0; | 133 | mServerSocket = 0; |
134 | mClosed = false; | 134 | mClosed = false; |
135 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 135 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
136 | QString confFile = locateLocal("config","korganizerrc"); | 136 | QString confFile = locateLocal("config","korganizerrc"); |
137 | QFileInfo finf ( confFile ); | 137 | QFileInfo finf ( confFile ); |
138 | bool showWarning = !finf.exists(); | 138 | bool showWarning = !finf.exists(); |
139 | setIcon(SmallIcon( "ko24" ) ); | 139 | setIcon(SmallIcon( "ko24" ) ); |
140 | mBlockAtStartup = true; | 140 | mBlockAtStartup = true; |
141 | mFlagKeyPressed = false; | 141 | mFlagKeyPressed = false; |
142 | setCaption("KOrganizer/Pi"); | 142 | setCaption("KOrganizer/Pi"); |
143 | KOPrefs *p = KOPrefs::instance(); | 143 | KOPrefs *p = KOPrefs::instance(); |
144 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 144 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
145 | // if ( QApplication::desktop()->height() > 480 ) { | 145 | // if ( QApplication::desktop()->height() > 480 ) { |
146 | // if ( p->mHourSize == 4 ) | 146 | // if ( p->mHourSize == 4 ) |
147 | // p->mHourSize = 6; | 147 | // p->mHourSize = 6; |
148 | // } | 148 | // } |
149 | if ( p->mHourSize > 18 ) | 149 | if ( p->mHourSize > 18 ) |
150 | p->mHourSize = 18; | 150 | p->mHourSize = 18; |
151 | QMainWindow::ToolBarDock tbd; | 151 | QMainWindow::ToolBarDock tbd; |
152 | if ( p->mToolBarHor ) { | 152 | if ( p->mToolBarHor ) { |
153 | if ( p->mToolBarUp ) | 153 | if ( p->mToolBarUp ) |
154 | tbd = Bottom; | 154 | tbd = Bottom; |
155 | else | 155 | else |
156 | tbd = Top; | 156 | tbd = Top; |
157 | } | 157 | } |
158 | else { | 158 | else { |
159 | if ( p->mToolBarUp ) | 159 | if ( p->mToolBarUp ) |
160 | tbd = Right; | 160 | tbd = Right; |
161 | else | 161 | else |
162 | tbd = Left; | 162 | tbd = Left; |
163 | } | 163 | } |
164 | if ( KOPrefs::instance()->mUseAppColors ) | 164 | if ( KOPrefs::instance()->mUseAppColors ) |
165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
166 | globalFlagBlockStartup = 1; | 166 | globalFlagBlockStartup = 1; |
167 | iconToolBar = new QPEToolBar( this ); | 167 | iconToolBar = new QPEToolBar( this ); |
168 | addToolBar (iconToolBar , tbd ); | 168 | addToolBar (iconToolBar , tbd ); |
169 | mBlockSaveFlag = false; | 169 | mBlockSaveFlag = false; |
170 | mCalendarModifiedFlag = false; | 170 | mCalendarModifiedFlag = false; |
171 | 171 | ||
172 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 172 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
173 | splash->setAlignment ( AlignCenter ); | 173 | splash->setAlignment ( AlignCenter ); |
174 | setCentralWidget( splash ); | 174 | setCentralWidget( splash ); |
175 | #ifndef DESKTOP_VERSION | 175 | #ifndef DESKTOP_VERSION |
176 | showMaximized(); | 176 | showMaximized(); |
177 | #endif | 177 | #endif |
178 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 178 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
179 | setDefaultPreferences(); | 179 | setDefaultPreferences(); |
180 | mCalendar = new CalendarLocal(); | 180 | mCalendar = new CalendarLocal(); |
181 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 181 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
182 | mView->hide(); | 182 | mView->hide(); |
183 | //mView->resize(splash->size() ); | 183 | //mView->resize(splash->size() ); |
184 | initActions(); | 184 | initActions(); |
185 | #ifndef DESKTOP_VERSION | 185 | #ifndef DESKTOP_VERSION |
186 | iconToolBar->show(); | 186 | iconToolBar->show(); |
187 | qApp->processEvents(); | 187 | qApp->processEvents(); |
188 | #endif | 188 | #endif |
189 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 189 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
190 | int vh = height() ; | 190 | int vh = height() ; |
191 | int vw = width(); | 191 | int vw = width(); |
192 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 192 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
193 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 193 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
194 | vh -= iconToolBar->height(); | 194 | vh -= iconToolBar->height(); |
195 | } else { | 195 | } else { |
196 | vw -= iconToolBar->height(); | 196 | vw -= iconToolBar->height(); |
197 | } | 197 | } |
198 | //mView->setMaximumSize( splash->size() ); | 198 | //mView->setMaximumSize( splash->size() ); |
199 | //mView->resize( splash->size() ); | 199 | //mView->resize( splash->size() ); |
200 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 200 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
201 | mView->readSettings(); | 201 | mView->readSettings(); |
202 | bool newFile = false; | 202 | bool newFile = false; |
203 | if( !QFile::exists( defaultFileName() ) ) { | 203 | if( !QFile::exists( defaultFileName() ) ) { |
204 | QFileInfo finfo ( defaultFileName() ); | 204 | QFileInfo finfo ( defaultFileName() ); |
205 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 205 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
206 | qDebug("oldfile %s ", oldFile.latin1()); | 206 | qDebug("oldfile %s ", oldFile.latin1()); |
207 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 207 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
208 | finfo.setFile( oldFile ); | 208 | finfo.setFile( oldFile ); |
209 | if (finfo.exists() ) { | 209 | if (finfo.exists() ) { |
210 | KMessageBox::information( this, message); | 210 | KMessageBox::information( this, message); |
211 | mView->openCalendar( oldFile ); | 211 | mView->openCalendar( oldFile ); |
212 | qApp->processEvents(); | 212 | qApp->processEvents(); |
213 | } else { | 213 | } else { |
214 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 214 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
215 | finfo.setFile( oldFile ); | 215 | finfo.setFile( oldFile ); |
216 | if (finfo.exists() ) { | 216 | if (finfo.exists() ) { |
217 | KMessageBox::information( this, message); | 217 | KMessageBox::information( this, message); |
218 | mView->openCalendar( oldFile ); | 218 | mView->openCalendar( oldFile ); |
219 | qApp->processEvents(); | 219 | qApp->processEvents(); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | mView->saveCalendar( defaultFileName() ); | 222 | mView->saveCalendar( defaultFileName() ); |
223 | newFile = true; | 223 | newFile = true; |
224 | } | 224 | } |
225 | 225 | ||
226 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 226 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
227 | mView->openCalendar( defaultFileName() ); | 227 | mView->openCalendar( defaultFileName() ); |
228 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 228 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
229 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 229 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
230 | 230 | ||
231 | if ( KOPrefs::instance()->mLanguageChanged ) { | 231 | if ( KOPrefs::instance()->mLanguageChanged ) { |
232 | KOPrefs::instance()->setCategoryDefaults(); | 232 | KOPrefs::instance()->setCategoryDefaults(); |
233 | int count = mView->addCategories(); | 233 | int count = mView->addCategories(); |
234 | KOPrefs::instance()->mLanguageChanged = false; | 234 | KOPrefs::instance()->mLanguageChanged = false; |
235 | } | 235 | } |
236 | processIncidenceSelection( 0 ); | 236 | processIncidenceSelection( 0 ); |
237 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 237 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
238 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 238 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
239 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 239 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
240 | SLOT( slotModifiedChanged( bool ) ) ); | 240 | SLOT( slotModifiedChanged( bool ) ) ); |
241 | 241 | ||
242 | 242 | ||
243 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 243 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
244 | mView->setModified( false ); | 244 | mView->setModified( false ); |
245 | mBlockAtStartup = false; | 245 | mBlockAtStartup = false; |
246 | mView->setModified( false ); | 246 | mView->setModified( false ); |
247 | setCentralWidget( mView ); | 247 | setCentralWidget( mView ); |
248 | globalFlagBlockStartup = 0; | 248 | globalFlagBlockStartup = 0; |
249 | mView->show(); | 249 | mView->show(); |
250 | delete splash; | 250 | delete splash; |
251 | if ( newFile ) | 251 | if ( newFile ) |
252 | mView->updateConfig(); | 252 | mView->updateConfig(); |
253 | // qApp->processEvents(); | 253 | // qApp->processEvents(); |
254 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 254 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
255 | fillSyncMenu(); | 255 | fillSyncMenu(); |
256 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 256 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
257 | if ( showWarning ) { | 257 | if ( showWarning ) { |
258 | KMessageBox::information( this, | 258 | KMessageBox::information( this, |
259 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 259 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
260 | qApp->processEvents(); | 260 | qApp->processEvents(); |
261 | mView->dialogManager()->showSyncOptions(); | 261 | mView->dialogManager()->showSyncOptions(); |
262 | } | 262 | } |
263 | 263 | ||
264 | //US listen for result adressed from Ka/Pi | 264 | //US listen for result adressed from Ka/Pi |
265 | #ifndef DESKTOP_VERSION | 265 | #ifndef DESKTOP_VERSION |
266 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 266 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
267 | #endif | 267 | #endif |
268 | } | 268 | } |
269 | MainWindow::~MainWindow() | 269 | MainWindow::~MainWindow() |
270 | { | 270 | { |
271 | //qDebug("MainWindow::~MainWindow() "); | 271 | //qDebug("MainWindow::~MainWindow() "); |
272 | //save toolbar location | 272 | //save toolbar location |
273 | delete mServerSocket; | 273 | delete mServerSocket; |
274 | delete mCalendar; | 274 | delete mCalendar; |
275 | delete KOPrefs::instance(); | 275 | delete KOPrefs::instance(); |
276 | delete KIncidenceFormatter::instance(); | 276 | delete KIncidenceFormatter::instance(); |
277 | 277 | ||
278 | 278 | ||
279 | } | 279 | } |
280 | void MainWindow::showMaximized () | 280 | void MainWindow::showMaximized () |
281 | { | 281 | { |
282 | #ifndef DESKTOP_VERSION | 282 | #ifndef DESKTOP_VERSION |
283 | if ( ! globalFlagBlockStartup ) | 283 | if ( ! globalFlagBlockStartup ) |
284 | if ( mClosed ) | 284 | if ( mClosed ) |
285 | mView->goToday(); | 285 | mView->goToday(); |
286 | #endif | 286 | #endif |
287 | QWidget::showMaximized () ; | 287 | QWidget::showMaximized () ; |
288 | mClosed = false; | 288 | mClosed = false; |
289 | } | 289 | } |
290 | void MainWindow::closeEvent( QCloseEvent* ce ) | 290 | void MainWindow::closeEvent( QCloseEvent* ce ) |
291 | { | 291 | { |
292 | 292 | ||
293 | 293 | ||
294 | 294 | ||
295 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 295 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
296 | saveOnClose(); | 296 | saveOnClose(); |
297 | mClosed = true; | 297 | mClosed = true; |
298 | ce->accept(); | 298 | ce->accept(); |
299 | return; | 299 | return; |
300 | 300 | ||
301 | } | 301 | } |
302 | 302 | ||
303 | switch( QMessageBox::information( this, "KO/Pi", | 303 | switch( QMessageBox::information( this, "KO/Pi", |
304 | i18n("Do you really want\nto close KO/Pi?"), | 304 | i18n("Do you really want\nto close KO/Pi?"), |
305 | i18n("Close"), i18n("No"), | 305 | i18n("Close"), i18n("No"), |
306 | 0, 0 ) ) { | 306 | 0, 0 ) ) { |
307 | case 0: | 307 | case 0: |
308 | saveOnClose(); | 308 | saveOnClose(); |
309 | mClosed = true; | 309 | mClosed = true; |
310 | ce->accept(); | 310 | ce->accept(); |
311 | break; | 311 | break; |
312 | case 1: | 312 | case 1: |
313 | ce->ignore(); | 313 | ce->ignore(); |
314 | break; | 314 | break; |
315 | case 2: | 315 | case 2: |
316 | 316 | ||
317 | default: | 317 | default: |
318 | break; | 318 | break; |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | } | 322 | } |
323 | 323 | ||
324 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 324 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
325 | { | 325 | { |
326 | QDataStream stream( data, IO_ReadOnly ); | 326 | QDataStream stream( data, IO_ReadOnly ); |
327 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 327 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
328 | //QString datamess; | 328 | //QString datamess; |
329 | //qDebug("message "); | 329 | //qDebug("message "); |
330 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 330 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
331 | 331 | ||
332 | if ( cmsg == "-writeFile" ) { | 332 | if ( cmsg == "-writeFile" ) { |
333 | // I made from the "-writeFile" an "-writeAlarm" | 333 | // I made from the "-writeFile" an "-writeAlarm" |
334 | mView->viewManager()->showWhatsNextView(); | 334 | mView->viewManager()->showWhatsNextView(); |
335 | mCalendar->checkAlarmForIncidence( 0, true); | 335 | mCalendar->checkAlarmForIncidence( 0, true); |
336 | showMaximized(); | 336 | showMaximized(); |
337 | raise(); | 337 | raise(); |
338 | return; | 338 | return; |
339 | } | 339 | } |
340 | 340 | ||
341 | if ( cmsg == "-writeFile" ) { | 341 | if ( cmsg == "-writeFile" ) { |
342 | // I made from the "-writeFile" an "-writeAlarm" | 342 | // I made from the "-writeFile" an "-writeAlarm" |
343 | mView->viewManager()->showWhatsNextView(); | 343 | mView->viewManager()->showWhatsNextView(); |
344 | mCalendar->checkAlarmForIncidence( 0, true); | 344 | mCalendar->checkAlarmForIncidence( 0, true); |
345 | showMaximized(); | 345 | showMaximized(); |
346 | raise(); | 346 | raise(); |
347 | return; | 347 | return; |
348 | 348 | ||
349 | } | 349 | } |
350 | if ( cmsg == "-writeFileSilent" ) { | 350 | if ( cmsg == "-writeFileSilent" ) { |
351 | // I made from the "-writeFile" an "-writeAlarm" | 351 | // I made from the "-writeFile" an "-writeAlarm" |
352 | // mView->viewManager()->showWhatsNextView(); | 352 | // mView->viewManager()->showWhatsNextView(); |
353 | mCalendar->checkAlarmForIncidence( 0, true); | 353 | mCalendar->checkAlarmForIncidence( 0, true); |
354 | //showMaximized(); | 354 | //showMaximized(); |
355 | //raise(); | 355 | //raise(); |
356 | hide(); | 356 | hide(); |
357 | return; | 357 | return; |
358 | } | 358 | } |
359 | if ( cmsg == "-newCountdown" ) { | 359 | if ( cmsg == "-newCountdown" ) { |
360 | qDebug("newCountdown "); | 360 | qDebug("newCountdown "); |
361 | 361 | ||
362 | } | 362 | } |
363 | QString msg ; | 363 | QString msg ; |
364 | QString allmsg = cmsg; | 364 | QString allmsg = cmsg; |
365 | while ( allmsg.length() > 0 ) { | 365 | while ( allmsg.length() > 0 ) { |
366 | int nextC = allmsg.find( "-", 1 ); | 366 | int nextC = allmsg.find( "-", 1 ); |
367 | if ( nextC == -1 ) { | 367 | if ( nextC == -1 ) { |
368 | msg = allmsg; | 368 | msg = allmsg; |
369 | allmsg = ""; | 369 | allmsg = ""; |
370 | } else{ | 370 | } else{ |
371 | msg = allmsg.left( nextC ); | 371 | msg = allmsg.left( nextC ); |
372 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 372 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
373 | } | 373 | } |
374 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 374 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
375 | if ( msg == "-newEvent" ) { | 375 | if ( msg == "-newEvent" ) { |
376 | mView->newEvent(); | 376 | mView->newEvent(); |
377 | } | 377 | } |
378 | if ( msg == "-newTodo" ) { | 378 | if ( msg == "-newTodo" ) { |
379 | mView->newTodo(); | 379 | mView->newTodo(); |
380 | 380 | ||
381 | } | 381 | } |
382 | if ( msg == "-showWN" ) { | 382 | if ( msg == "-showWN" ) { |
383 | mView->viewManager()->showWhatsNextView(); | 383 | mView->viewManager()->showWhatsNextView(); |
384 | } | 384 | } |
385 | if ( msg == "-showTodo" ) { | 385 | if ( msg == "-showTodo" ) { |
386 | mView->viewManager()->showTodoView(); | 386 | mView->viewManager()->showTodoView(); |
387 | } | 387 | } |
388 | if ( msg == "-showList" ) { | 388 | if ( msg == "-showList" ) { |
389 | mView->viewManager()->showListView(); | 389 | mView->viewManager()->showListView(); |
390 | } | 390 | } |
391 | else if ( msg == "-showDay" ) { | 391 | else if ( msg == "-showDay" ) { |
392 | mView->viewManager()->showDayView(); | 392 | mView->viewManager()->showDayView(); |
393 | } | 393 | } |
394 | else if ( msg == "-showWWeek" ) { | 394 | else if ( msg == "-showWWeek" ) { |
395 | mView->viewManager()->showWorkWeekView(); | 395 | mView->viewManager()->showWorkWeekView(); |
396 | } | 396 | } |
397 | else if ( msg == "-ringSync" ) { | 397 | else if ( msg == "-ringSync" ) { |
398 | multiSync( false ); | 398 | multiSync( false ); |
399 | } | 399 | } |
400 | else if ( msg == "-showWeek" ) { | 400 | else if ( msg == "-showWeek" ) { |
401 | mView->viewManager()->showWeekView(); | 401 | mView->viewManager()->showWeekView(); |
402 | } | 402 | } |
403 | else if ( msg == "-showTodo" ) { | 403 | else if ( msg == "-showTodo" ) { |
404 | mView->viewManager()->showTodoView(); | 404 | mView->viewManager()->showTodoView(); |
405 | } | 405 | } |
406 | else if ( msg == "-showJournal" ) { | 406 | else if ( msg == "-showJournal" ) { |
407 | mView->dateNavigator()->selectDates( 1 ); | 407 | mView->dateNavigator()->selectDates( 1 ); |
408 | mView->dateNavigator()->selectToday(); | 408 | mView->dateNavigator()->selectToday(); |
409 | mView->viewManager()->showJournalView(); | 409 | mView->viewManager()->showJournalView(); |
410 | } | 410 | } |
411 | else if ( msg == "-showKO" ) { | 411 | else if ( msg == "-showKO" ) { |
412 | mView->viewManager()->showNextXView(); | 412 | mView->viewManager()->showNextXView(); |
413 | } | 413 | } |
414 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 414 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
415 | mView->viewManager()->showWhatsNextView(); | 415 | mView->viewManager()->showWhatsNextView(); |
416 | } | 416 | } |
417 | else if ( msg == "-showNextXView" ) { | 417 | else if ( msg == "-showNextXView" ) { |
418 | mView->viewManager()->showNextXView(); | 418 | mView->viewManager()->showNextXView(); |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | } | 422 | } |
423 | 423 | ||
424 | showMaximized(); | 424 | showMaximized(); |
425 | raise(); | 425 | raise(); |
426 | } | 426 | } |
427 | 427 | ||
428 | QPixmap MainWindow::loadPixmap( QString name ) | 428 | QPixmap MainWindow::loadPixmap( QString name ) |
429 | { | 429 | { |
430 | return SmallIcon( name ); | 430 | return SmallIcon( name ); |
431 | 431 | ||
432 | } | 432 | } |
433 | void MainWindow::initActions() | 433 | void MainWindow::initActions() |
434 | { | 434 | { |
435 | //KOPrefs::instance()->mShowFullMenu | 435 | //KOPrefs::instance()->mShowFullMenu |
436 | iconToolBar->clear(); | 436 | iconToolBar->clear(); |
437 | KOPrefs *p = KOPrefs::instance(); | 437 | KOPrefs *p = KOPrefs::instance(); |
438 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 438 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
439 | 439 | ||
440 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 440 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
441 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 441 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
442 | QPopupMenu *importMenu = new QPopupMenu( this ); | 442 | QPopupMenu *importMenu = new QPopupMenu( this ); |
443 | selectFilterMenu = new QPopupMenu( this ); | 443 | selectFilterMenu = new QPopupMenu( this ); |
444 | selectFilterMenu->setCheckable( true ); | 444 | selectFilterMenu->setCheckable( true ); |
445 | syncMenu = new QPopupMenu( this ); | 445 | syncMenu = new QPopupMenu( this ); |
446 | configureAgendaMenu = new QPopupMenu( this ); | 446 | configureAgendaMenu = new QPopupMenu( this ); |
447 | configureToolBarMenu = new QPopupMenu( this ); | 447 | configureToolBarMenu = new QPopupMenu( this ); |
448 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 448 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
449 | if ( KOPrefs::instance()->mShowFullMenu ) { | 449 | if ( KOPrefs::instance()->mShowFullMenu ) { |
450 | QMenuBar *menuBar1; | 450 | QMenuBar *menuBar1; |
451 | menuBar1 = menuBar(); | 451 | menuBar1 = menuBar(); |
452 | menuBar1->insertItem( i18n("File"), importMenu ); | 452 | menuBar1->insertItem( i18n("File"), importMenu ); |
453 | menuBar1->insertItem( i18n("View"), viewMenu ); | 453 | menuBar1->insertItem( i18n("View"), viewMenu ); |
454 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 454 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
455 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 455 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
456 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 456 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
457 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 457 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
458 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 458 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
459 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 459 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
460 | } else { | 460 | } else { |
461 | QPEMenuBar *menuBar1; | 461 | QPEMenuBar *menuBar1; |
462 | menuBar1 = new QPEMenuBar( iconToolBar ); | 462 | menuBar1 = new QPEMenuBar( iconToolBar ); |
463 | QPopupMenu *menuBar = new QPopupMenu( this ); | 463 | QPopupMenu *menuBar = new QPopupMenu( this ); |
464 | menuBar1->insertItem( i18n("ME"), menuBar); | 464 | menuBar1->insertItem( i18n("ME"), menuBar); |
465 | menuBar->insertItem( i18n("File"), importMenu ); | 465 | menuBar->insertItem( i18n("File"), importMenu ); |
466 | menuBar->insertItem( i18n("View"), viewMenu ); | 466 | menuBar->insertItem( i18n("View"), viewMenu ); |
467 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 467 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
468 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 468 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
469 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 469 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
470 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 470 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
471 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 471 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
472 | menuBar->insertItem( i18n("Help"), helpMenu ); | 472 | menuBar->insertItem( i18n("Help"), helpMenu ); |
473 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 473 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
474 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 474 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
475 | } | 475 | } |
476 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 476 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
477 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 477 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
478 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 478 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
479 | 479 | ||
480 | // ****************** | 480 | // ****************** |
481 | QAction *action; | 481 | QAction *action; |
482 | QIconSet icon; | 482 | QIconSet icon; |
483 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 483 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
484 | configureToolBarMenu->setCheckable( true ); | 484 | configureToolBarMenu->setCheckable( true ); |
485 | 485 | ||
486 | QString pathString = ""; | 486 | QString pathString = ""; |
487 | if ( !p->mToolBarMiniIcons ) { | 487 | if ( !p->mToolBarMiniIcons ) { |
488 | if ( QApplication::desktop()->width() < 480 ) | 488 | if ( QApplication::desktop()->width() < 480 ) |
489 | pathString += "icons16/"; | 489 | pathString += "icons16/"; |
490 | } else | 490 | } else |
491 | pathString += "iconsmini/"; | 491 | pathString += "iconsmini/"; |
492 | configureAgendaMenu->setCheckable( true ); | 492 | configureAgendaMenu->setCheckable( true ); |
493 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | 493 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); |
494 | configureAgendaMenu->insertSeparator(); | 494 | configureAgendaMenu->insertSeparator(); |
495 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 495 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
496 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 496 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
497 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 497 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
498 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 498 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
499 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 499 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
500 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 500 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
501 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 501 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
502 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 502 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
503 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 503 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
504 | 504 | ||
505 | icon = loadPixmap( pathString + "configure" ); | 505 | icon = loadPixmap( pathString + "configure" ); |
506 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 506 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
507 | action->addTo( actionMenu ); | 507 | action->addTo( actionMenu ); |
508 | connect( action, SIGNAL( activated() ), | 508 | connect( action, SIGNAL( activated() ), |
509 | mView, SLOT( edit_options() ) ); | 509 | mView, SLOT( edit_options() ) ); |
510 | actionMenu->insertSeparator(); | 510 | actionMenu->insertSeparator(); |
511 | icon = loadPixmap( pathString + "newevent" ); | 511 | icon = loadPixmap( pathString + "newevent" ); |
512 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 512 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
513 | configureToolBarMenu->insertSeparator(); | 513 | configureToolBarMenu->insertSeparator(); |
514 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 514 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
515 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 515 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
516 | ne_action->addTo( actionMenu ); | 516 | ne_action->addTo( actionMenu ); |
517 | connect( ne_action, SIGNAL( activated() ), | 517 | connect( ne_action, SIGNAL( activated() ), |
518 | mView, SLOT( newEvent() ) ); | 518 | mView, SLOT( newEvent() ) ); |
519 | icon = loadPixmap( pathString + "newtodo" ); | 519 | icon = loadPixmap( pathString + "newtodo" ); |
520 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 520 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
521 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 521 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
522 | nt_action->addTo( actionMenu ); | 522 | nt_action->addTo( actionMenu ); |
523 | connect( nt_action, SIGNAL( activated() ), | 523 | connect( nt_action, SIGNAL( activated() ), |
524 | mView, SLOT( newTodo() ) ); | 524 | mView, SLOT( newTodo() ) ); |
525 | icon = loadPixmap( pathString + "navi" ); | 525 | icon = loadPixmap( pathString + "navi" ); |
526 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 526 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
527 | action->addTo( viewMenu ); | 527 | action->addTo( viewMenu ); |
528 | connect( action, SIGNAL( activated() ), | 528 | connect( action, SIGNAL( activated() ), |
529 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 529 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
530 | icon = loadPixmap( pathString + "filter" ); | 530 | icon = loadPixmap( pathString + "filter" ); |
531 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 531 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
532 | action->addTo( viewMenu ); | 532 | action->addTo( viewMenu ); |
533 | connect( action, SIGNAL( activated() ), | 533 | connect( action, SIGNAL( activated() ), |
534 | mView, SLOT( toggleFilter() ) ); | 534 | mView, SLOT( toggleFilter() ) ); |
535 | 535 | ||
536 | 536 | ||
537 | viewMenu->insertSeparator(); | 537 | viewMenu->insertSeparator(); |
538 | icon = loadPixmap( pathString + "picker" ); | 538 | icon = loadPixmap( pathString + "picker" ); |
539 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 539 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
540 | action->addTo( viewMenu ); | 540 | action->addTo( viewMenu ); |
541 | connect( action, SIGNAL( activated() ), | 541 | connect( action, SIGNAL( activated() ), |
542 | mView, SLOT( showDatePicker() ) ); | 542 | mView, SLOT( showDatePicker() ) ); |
543 | action->addTo( iconToolBar ); | 543 | action->addTo( iconToolBar ); |
544 | viewMenu->insertSeparator(); | 544 | viewMenu->insertSeparator(); |
545 | icon = loadPixmap( pathString + "list" ); | 545 | icon = loadPixmap( pathString + "list" ); |
546 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 546 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
547 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 547 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
548 | showlist_action->addTo( viewMenu ); | 548 | showlist_action->addTo( viewMenu ); |
549 | connect( showlist_action, SIGNAL( activated() ), | 549 | connect( showlist_action, SIGNAL( activated() ), |
550 | mView->viewManager(), SLOT( showListView() ) ); | 550 | mView->viewManager(), SLOT( showListView() ) ); |
551 | 551 | ||
552 | 552 | ||
553 | icon = loadPixmap( pathString + "day" ); | 553 | icon = loadPixmap( pathString + "day" ); |
554 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 554 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
555 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 555 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
556 | day1_action->addTo( viewMenu ); | 556 | day1_action->addTo( viewMenu ); |
557 | // action->addTo( toolBar ); | 557 | // action->addTo( toolBar ); |
558 | connect( day1_action, SIGNAL( activated() ), | 558 | connect( day1_action, SIGNAL( activated() ), |
559 | mView->viewManager(), SLOT( showDayView() ) ); | 559 | mView->viewManager(), SLOT( showDayView() ) ); |
560 | 560 | ||
561 | icon = loadPixmap( pathString + "workweek" ); | 561 | icon = loadPixmap( pathString + "workweek" ); |
562 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 562 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
563 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 563 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
564 | day5_action->addTo( viewMenu ); | 564 | day5_action->addTo( viewMenu ); |
565 | connect( day5_action, SIGNAL( activated() ), | 565 | connect( day5_action, SIGNAL( activated() ), |
566 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 566 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
567 | 567 | ||
568 | icon = loadPixmap( pathString + "week" ); | 568 | icon = loadPixmap( pathString + "week" ); |
569 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 569 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
570 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 570 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
571 | day7_action->addTo( viewMenu ); | 571 | day7_action->addTo( viewMenu ); |
572 | connect( day7_action, SIGNAL( activated() ), | 572 | connect( day7_action, SIGNAL( activated() ), |
573 | mView->viewManager(), SLOT( showWeekView() ) ); | 573 | mView->viewManager(), SLOT( showWeekView() ) ); |
574 | 574 | ||
575 | icon = loadPixmap( pathString + "month" ); | 575 | icon = loadPixmap( pathString + "month" ); |
576 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 576 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
577 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 577 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
578 | month_action->addTo( viewMenu ); | 578 | month_action->addTo( viewMenu ); |
579 | connect( month_action, SIGNAL( activated() ), | 579 | connect( month_action, SIGNAL( activated() ), |
580 | mView->viewManager(), SLOT( showMonthView() ) ); | 580 | mView->viewManager(), SLOT( showMonthView() ) ); |
581 | 581 | ||
582 | icon = loadPixmap( pathString + "todo" ); | 582 | icon = loadPixmap( pathString + "todo" ); |
583 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 583 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
584 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 584 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
585 | todoview_action->addTo( viewMenu ); | 585 | todoview_action->addTo( viewMenu ); |
586 | connect( todoview_action, SIGNAL( activated() ), | 586 | connect( todoview_action, SIGNAL( activated() ), |
587 | mView->viewManager(), SLOT( showTodoView() ) ); | 587 | mView->viewManager(), SLOT( showTodoView() ) ); |
588 | 588 | ||
589 | icon = loadPixmap( pathString + "journal" ); | 589 | icon = loadPixmap( pathString + "journal" ); |
590 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 590 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
591 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 591 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
592 | viewjournal_action->addTo( viewMenu ); | 592 | viewjournal_action->addTo( viewMenu ); |
593 | connect( viewjournal_action, SIGNAL( activated() ), | 593 | connect( viewjournal_action, SIGNAL( activated() ), |
594 | mView->viewManager(), SLOT( showJournalView() ) ); | 594 | mView->viewManager(), SLOT( showJournalView() ) ); |
595 | 595 | ||
596 | icon = loadPixmap( pathString + "xdays" ); | 596 | icon = loadPixmap( pathString + "xdays" ); |
597 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 597 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
598 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 598 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
599 | xdays_action->addTo( viewMenu ); | 599 | xdays_action->addTo( viewMenu ); |
600 | connect( xdays_action, SIGNAL( activated() ), | 600 | connect( xdays_action, SIGNAL( activated() ), |
601 | mView->viewManager(), SLOT( showNextXView() ) ); | 601 | mView->viewManager(), SLOT( showNextXView() ) ); |
602 | 602 | ||
603 | icon = loadPixmap( pathString + "whatsnext" ); | 603 | icon = loadPixmap( pathString + "whatsnext" ); |
604 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 604 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
605 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 605 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
606 | whatsnext_action->addTo( viewMenu ); | 606 | whatsnext_action->addTo( viewMenu ); |
607 | connect( whatsnext_action, SIGNAL( activated() ), | 607 | connect( whatsnext_action, SIGNAL( activated() ), |
608 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 608 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
609 | 609 | ||
610 | #if 0 | 610 | #if 0 |
611 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 611 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
612 | action->addTo( viewMenu ); | 612 | action->addTo( viewMenu ); |
613 | connect( action, SIGNAL( activated() ), | 613 | connect( action, SIGNAL( activated() ), |
614 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 614 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
615 | #endif | 615 | #endif |
616 | 616 | ||
617 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 617 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
618 | this ); | 618 | this ); |
619 | mNewSubTodoAction->addTo( actionMenu ); | 619 | mNewSubTodoAction->addTo( actionMenu ); |
620 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 620 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
621 | mView, SLOT( newSubTodo() ) ); | 621 | mView, SLOT( newSubTodo() ) ); |
622 | 622 | ||
623 | actionMenu->insertSeparator(); | 623 | actionMenu->insertSeparator(); |
624 | 624 | ||
625 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 625 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
626 | mShowAction->addTo( actionMenu ); | 626 | mShowAction->addTo( actionMenu ); |
627 | connect( mShowAction, SIGNAL( activated() ), | 627 | connect( mShowAction, SIGNAL( activated() ), |
628 | mView, SLOT( showIncidence() ) ); | 628 | mView, SLOT( showIncidence() ) ); |
629 | 629 | ||
630 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 630 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
631 | mEditAction->addTo( actionMenu ); | 631 | mEditAction->addTo( actionMenu ); |
632 | connect( mEditAction, SIGNAL( activated() ), | 632 | connect( mEditAction, SIGNAL( activated() ), |
633 | mView, SLOT( editIncidence() ) ); | 633 | mView, SLOT( editIncidence() ) ); |
634 | 634 | ||
635 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 635 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
636 | mDeleteAction->addTo( actionMenu ); | 636 | mDeleteAction->addTo( actionMenu ); |
637 | connect( mDeleteAction, SIGNAL( activated() ), | 637 | connect( mDeleteAction, SIGNAL( activated() ), |
638 | mView, SLOT( deleteIncidence() ) ); | 638 | mView, SLOT( deleteIncidence() ) ); |
639 | 639 | ||
640 | 640 | ||
641 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 641 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
642 | mCloneAction->addTo( actionMenu ); | 642 | mCloneAction->addTo( actionMenu ); |
643 | connect( mCloneAction, SIGNAL( activated() ), | 643 | connect( mCloneAction, SIGNAL( activated() ), |
644 | mView, SLOT( cloneIncidence() ) ); | 644 | mView, SLOT( cloneIncidence() ) ); |
645 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 645 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
646 | mMoveAction->addTo( actionMenu ); | 646 | mMoveAction->addTo( actionMenu ); |
647 | connect( mMoveAction, SIGNAL( activated() ), | 647 | connect( mMoveAction, SIGNAL( activated() ), |
648 | mView, SLOT( moveIncidence() ) ); | 648 | mView, SLOT( moveIncidence() ) ); |
649 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 649 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
650 | mBeamAction->addTo( actionMenu ); | 650 | mBeamAction->addTo( actionMenu ); |
651 | connect( mBeamAction, SIGNAL( activated() ), | 651 | connect( mBeamAction, SIGNAL( activated() ), |
652 | mView, SLOT( beamIncidence() ) ); | 652 | mView, SLOT( beamIncidence() ) ); |
653 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 653 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
654 | mCancelAction->addTo( actionMenu ); | 654 | mCancelAction->addTo( actionMenu ); |
655 | connect( mCancelAction, SIGNAL( activated() ), | 655 | connect( mCancelAction, SIGNAL( activated() ), |
656 | mView, SLOT( toggleCancelIncidence() ) ); | 656 | mView, SLOT( toggleCancelIncidence() ) ); |
657 | 657 | ||
658 | actionMenu->insertSeparator(); | 658 | actionMenu->insertSeparator(); |
659 | 659 | ||
660 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 660 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
661 | this ); | 661 | this ); |
662 | action->addTo( actionMenu ); | 662 | action->addTo( actionMenu ); |
663 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 663 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
664 | 664 | ||
665 | icon = loadPixmap( pathString + "search" ); | 665 | icon = loadPixmap( pathString + "search" ); |
666 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 666 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
667 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 667 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
668 | search_action->addTo( actionMenu ); | 668 | search_action->addTo( actionMenu ); |
669 | connect( search_action, SIGNAL( activated() ), | 669 | connect( search_action, SIGNAL( activated() ), |
670 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 670 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
671 | 671 | ||
672 | icon = loadPixmap( pathString + "today" ); | 672 | icon = loadPixmap( pathString + "today" ); |
673 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 673 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
674 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 674 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
675 | today_action->addTo( actionMenu ); | 675 | today_action->addTo( actionMenu ); |
676 | connect( today_action, SIGNAL( activated() ), | 676 | connect( today_action, SIGNAL( activated() ), |
677 | mView, SLOT( goToday() ) ); | 677 | mView, SLOT( goToday() ) ); |
678 | 678 | ||
679 | if ( KOPrefs::instance()->mShowFullMenu ) { | 679 | if ( KOPrefs::instance()->mShowFullMenu ) { |
680 | actionMenu->insertSeparator(); | 680 | actionMenu->insertSeparator(); |
681 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 681 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
682 | 682 | ||
683 | } | 683 | } |
684 | // actionMenu->insertSeparator(); | 684 | // actionMenu->insertSeparator(); |
685 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 685 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
686 | this ); | 686 | this ); |
687 | action->addTo( importMenu ); | 687 | action->addTo( importMenu ); |
688 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 688 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
689 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 689 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
690 | this ); | 690 | this ); |
691 | action->addTo( importMenu ); | 691 | action->addTo( importMenu ); |
692 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 692 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
693 | importMenu->insertSeparator(); | 693 | importMenu->insertSeparator(); |
694 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 694 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
695 | this ); | 695 | this ); |
696 | action->addTo( importMenu ); | 696 | action->addTo( importMenu ); |
697 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 697 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
698 | #ifndef DESKTOP_VERSION | 698 | #ifndef DESKTOP_VERSION |
699 | importMenu->insertSeparator(); | 699 | importMenu->insertSeparator(); |
700 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 700 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
701 | this ); | 701 | this ); |
702 | action->addTo( importMenu ); | 702 | action->addTo( importMenu ); |
703 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 703 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
704 | #else | 704 | #else |
705 | #ifdef _WIN32_ | 705 | #ifdef _WIN32_ |
706 | importMenu->insertSeparator(); | 706 | importMenu->insertSeparator(); |
707 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 707 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
708 | this ); | 708 | this ); |
709 | action->addTo( importMenu ); | 709 | action->addTo( importMenu ); |
710 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 710 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
711 | #endif | 711 | #endif |
712 | #endif | 712 | #endif |
713 | 713 | ||
714 | importMenu->insertSeparator(); | 714 | importMenu->insertSeparator(); |
715 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 715 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
716 | this ); | 716 | this ); |
717 | action->addTo( importMenu ); | 717 | action->addTo( importMenu ); |
718 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 718 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
719 | 719 | ||
720 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 720 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
721 | this ); | 721 | this ); |
722 | action->addTo( importMenu ); | 722 | action->addTo( importMenu ); |
723 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 723 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
724 | 724 | ||
725 | importMenu->insertSeparator(); | 725 | importMenu->insertSeparator(); |
726 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 726 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
727 | this ); | 727 | this ); |
728 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 728 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
729 | 729 | ||
730 | 730 | ||
731 | //LR | 731 | //LR |
732 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 732 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
733 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 733 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
734 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 734 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
735 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 735 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
736 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 736 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
737 | 737 | ||
738 | importMenu->insertSeparator(); | 738 | importMenu->insertSeparator(); |
739 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 739 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
740 | this ); | 740 | this ); |
741 | action->addTo( importMenu ); | 741 | action->addTo( importMenu ); |
742 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 742 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
743 | #ifndef DESKTOP_VERSION | 743 | #ifndef DESKTOP_VERSION |
744 | importMenu->insertSeparator(); | 744 | importMenu->insertSeparator(); |
745 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 745 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
746 | this ); | 746 | this ); |
747 | action->addTo( importMenu ); | 747 | action->addTo( importMenu ); |
748 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 748 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
749 | 749 | ||
750 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 750 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
751 | this ); | 751 | this ); |
752 | action->addTo( importMenu ); | 752 | action->addTo( importMenu ); |
753 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 753 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
754 | #else | 754 | #else |
755 | importMenu->insertSeparator(); | 755 | importMenu->insertSeparator(); |
756 | icon = loadPixmap( pathString + "print" ); | 756 | icon = loadPixmap( pathString + "print" ); |
757 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 757 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
758 | action->addTo( importMenu ); | 758 | action->addTo( importMenu ); |
759 | connect( action, SIGNAL( activated() ), | 759 | connect( action, SIGNAL( activated() ), |
760 | this, SLOT( printCal() ) ); | 760 | this, SLOT( printCal() ) ); |
761 | 761 | ||
762 | icon = loadPixmap( pathString + "print" ); | 762 | icon = loadPixmap( pathString + "print" ); |
763 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 763 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
764 | action->addTo( importMenu ); | 764 | action->addTo( importMenu ); |
765 | connect( action, SIGNAL( activated() ), | 765 | connect( action, SIGNAL( activated() ), |
766 | this, SLOT( printSel() ) ); | 766 | this, SLOT( printSel() ) ); |
767 | #endif | 767 | #endif |
768 | importMenu->insertSeparator(); | 768 | importMenu->insertSeparator(); |
769 | action = new QAction( "beam all", i18n("Save"), 0, | 769 | action = new QAction( "beam all", i18n("Save"), 0, |
770 | this ); | 770 | this ); |
771 | action->addTo( importMenu ); | 771 | action->addTo( importMenu ); |
772 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 772 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
773 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 773 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
774 | this ); | 774 | this ); |
775 | action->addTo( importMenu ); | 775 | action->addTo( importMenu ); |
776 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 776 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
777 | 777 | ||
778 | //menuBar->insertItem( "Configure",configureMenu ); | 778 | //menuBar->insertItem( "Configure",configureMenu ); |
779 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 779 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
780 | icon = loadPixmap( "korganizer/korganizer" ); | 780 | icon = loadPixmap( "korganizer/korganizer" ); |
781 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 781 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
782 | action->addTo( helpMenu ); | 782 | action->addTo( helpMenu ); |
783 | connect( action, SIGNAL( activated() ), | 783 | connect( action, SIGNAL( activated() ), |
784 | SLOT( keyBindings() ) ); | 784 | SLOT( keyBindings() ) ); |
785 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 785 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
786 | action->addTo( helpMenu ); | 786 | action->addTo( helpMenu ); |
787 | connect( action, SIGNAL( activated() ), | 787 | connect( action, SIGNAL( activated() ), |
788 | SLOT( features() ) ); | 788 | SLOT( features() ) ); |
789 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 789 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
790 | action->addTo( helpMenu ); | 790 | action->addTo( helpMenu ); |
791 | connect( action, SIGNAL( activated() ), | 791 | connect( action, SIGNAL( activated() ), |
792 | SLOT( aboutAutoSaving() ) ); | 792 | SLOT( aboutAutoSaving() ) ); |
793 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 793 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
794 | action->addTo( helpMenu ); | 794 | action->addTo( helpMenu ); |
795 | connect( action, SIGNAL( activated() ), | 795 | connect( action, SIGNAL( activated() ), |
796 | SLOT( aboutKnownBugs() ) ); | 796 | SLOT( aboutKnownBugs() ) ); |
797 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 797 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
798 | action->addTo( helpMenu ); | 798 | action->addTo( helpMenu ); |
799 | connect( action, SIGNAL( activated() ), | 799 | connect( action, SIGNAL( activated() ), |
800 | SLOT( usertrans() ) ); | 800 | SLOT( usertrans() ) ); |
801 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 801 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
802 | action->addTo( helpMenu ); | 802 | action->addTo( helpMenu ); |
803 | connect( action, SIGNAL( activated() ), | 803 | connect( action, SIGNAL( activated() ), |
804 | SLOT( synchowto() ) ); | 804 | SLOT( synchowto() ) ); |
805 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 805 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
806 | action->addTo( helpMenu ); | 806 | action->addTo( helpMenu ); |
807 | connect( action, SIGNAL( activated() ), | 807 | connect( action, SIGNAL( activated() ), |
808 | SLOT( whatsNew() ) ); | 808 | SLOT( whatsNew() ) ); |
809 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 809 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
810 | action->addTo( helpMenu ); | 810 | action->addTo( helpMenu ); |
811 | connect( action, SIGNAL( activated() ), | 811 | connect( action, SIGNAL( activated() ), |
812 | SLOT( faq() ) ); | 812 | SLOT( faq() ) ); |
813 | 813 | ||
814 | 814 | ||
815 | action = new QAction( "about", i18n("About..."), 0, this ); | 815 | action = new QAction( "about", i18n("About..."), 0, this ); |
816 | action->addTo( helpMenu ); | 816 | action->addTo( helpMenu ); |
817 | connect( action, SIGNAL( activated() ), | 817 | connect( action, SIGNAL( activated() ), |
818 | SLOT( about() ) ); | 818 | SLOT( about() ) ); |
819 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 819 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
820 | action->addTo( helpMenu ); | 820 | action->addTo( helpMenu ); |
821 | connect( action, SIGNAL( activated() ), | 821 | connect( action, SIGNAL( activated() ), |
822 | SLOT( licence() ) ); | 822 | SLOT( licence() ) ); |
823 | //menuBar->insertSeparator(); | 823 | //menuBar->insertSeparator(); |
824 | 824 | ||
825 | // ****************************************************** | 825 | // ****************************************************** |
826 | // menubar icons | 826 | // menubar icons |
827 | 827 | ||
828 | 828 | ||
829 | iconToolBar->setHorizontalStretchable (true ); | 829 | iconToolBar->setHorizontalStretchable (true ); |
830 | //menuBar->insertItem( iconToolBar ); | 830 | //menuBar->insertItem( iconToolBar ); |
831 | //xdays_action | 831 | //xdays_action |
832 | if (p-> mShowIconNewEvent) | 832 | if (p-> mShowIconNewEvent) |
833 | ne_action->addTo( iconToolBar ); | 833 | ne_action->addTo( iconToolBar ); |
834 | if (p->mShowIconNewTodo ) | 834 | if (p->mShowIconNewTodo ) |
835 | nt_action->addTo( iconToolBar ); | 835 | nt_action->addTo( iconToolBar ); |
836 | if (p-> mShowIconSearch) | 836 | if (p-> mShowIconSearch) |
837 | search_action->addTo( iconToolBar ); | 837 | search_action->addTo( iconToolBar ); |
838 | if (p-> mShowIconNext) | 838 | if (p-> mShowIconNext) |
839 | whatsnext_action->addTo( iconToolBar ); | 839 | whatsnext_action->addTo( iconToolBar ); |
840 | if (p-> mShowIconNextDays) | 840 | if (p-> mShowIconNextDays) |
841 | xdays_action->addTo( iconToolBar ); | 841 | xdays_action->addTo( iconToolBar ); |
842 | if (p-> mShowIconList) | 842 | if (p-> mShowIconList) |
843 | showlist_action->addTo( iconToolBar ); | 843 | showlist_action->addTo( iconToolBar ); |
844 | if (p-> mShowIconDay1) | 844 | if (p-> mShowIconDay1) |
845 | day1_action->addTo( iconToolBar ); | 845 | day1_action->addTo( iconToolBar ); |
846 | if (p-> mShowIconDay5) | 846 | if (p-> mShowIconDay5) |
847 | day5_action->addTo( iconToolBar ); | 847 | day5_action->addTo( iconToolBar ); |
848 | if (p-> mShowIconDay7) | 848 | if (p-> mShowIconDay7) |
849 | day7_action->addTo( iconToolBar ); | 849 | day7_action->addTo( iconToolBar ); |
850 | if (p-> mShowIconMonth) | 850 | if (p-> mShowIconMonth) |
851 | month_action->addTo( iconToolBar ); | 851 | month_action->addTo( iconToolBar ); |
852 | if (p-> mShowIconTodoview) | 852 | if (p-> mShowIconTodoview) |
853 | todoview_action->addTo( iconToolBar ); | 853 | todoview_action->addTo( iconToolBar ); |
854 | if (p-> mShowIconJournal) | 854 | if (p-> mShowIconJournal) |
855 | viewjournal_action->addTo( iconToolBar ); | 855 | viewjournal_action->addTo( iconToolBar ); |
856 | icon = loadPixmap( pathString + "2leftarrowB" ); | 856 | icon = loadPixmap( pathString + "2leftarrowB" ); |
857 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 857 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
858 | if (p-> mShowIconBackFast) { | 858 | if (p-> mShowIconBackFast) { |
859 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 859 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
860 | connect( action, SIGNAL( activated() ), | 860 | connect( action, SIGNAL( activated() ), |
861 | mView, SLOT( goPreviousMonth() ) ); | 861 | mView, SLOT( goPreviousMonth() ) ); |
862 | action->addTo( iconToolBar ); | 862 | action->addTo( iconToolBar ); |
863 | } | 863 | } |
864 | icon = loadPixmap( pathString + "1leftarrowB" ); | 864 | icon = loadPixmap( pathString + "1leftarrowB" ); |
865 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 865 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
866 | if (p-> mShowIconBack) { | 866 | if (p-> mShowIconBack) { |
867 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 867 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
868 | connect( action, SIGNAL( activated() ), | 868 | connect( action, SIGNAL( activated() ), |
869 | mView, SLOT( goPrevious() ) ); | 869 | mView, SLOT( goPrevious() ) ); |
870 | action->addTo( iconToolBar ); | 870 | action->addTo( iconToolBar ); |
871 | } | 871 | } |
872 | if (p-> mShowIconToday) | 872 | if (p-> mShowIconToday) |
873 | today_action->addTo( iconToolBar ); | 873 | today_action->addTo( iconToolBar ); |
874 | icon = loadPixmap( pathString + "1rightarrowB" ); | 874 | icon = loadPixmap( pathString + "1rightarrowB" ); |
875 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 875 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
876 | if (p-> mShowIconForward) { | 876 | if (p-> mShowIconForward) { |
877 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 877 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
878 | connect( action, SIGNAL( activated() ), | 878 | connect( action, SIGNAL( activated() ), |
879 | mView, SLOT( goNext() ) ); | 879 | mView, SLOT( goNext() ) ); |
880 | action->addTo( iconToolBar ); | 880 | action->addTo( iconToolBar ); |
881 | } | 881 | } |
882 | icon = loadPixmap( pathString + "2rightarrowB" ); | 882 | icon = loadPixmap( pathString + "2rightarrowB" ); |
883 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 883 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
884 | if (p-> mShowIconForwardFast) { | 884 | if (p-> mShowIconForwardFast) { |
885 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 885 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
886 | connect( action, SIGNAL( activated() ), | 886 | connect( action, SIGNAL( activated() ), |
887 | mView, SLOT( goNextMonth() ) ); | 887 | mView, SLOT( goNextMonth() ) ); |
888 | action->addTo( iconToolBar ); | 888 | action->addTo( iconToolBar ); |
889 | } | 889 | } |
890 | 890 | ||
891 | 891 | ||
892 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 892 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
893 | 893 | ||
894 | if (p-> mShowIconNewEvent) | 894 | if (p-> mShowIconNewEvent) |
895 | configureToolBarMenu->setItemChecked( 10, true ); | 895 | configureToolBarMenu->setItemChecked( 10, true ); |
896 | if (p->mShowIconNewTodo ) | 896 | if (p->mShowIconNewTodo ) |
897 | configureToolBarMenu->setItemChecked( 20, true ); | 897 | configureToolBarMenu->setItemChecked( 20, true ); |
898 | if (p-> mShowIconSearch) | 898 | if (p-> mShowIconSearch) |
899 | configureToolBarMenu->setItemChecked( 120, true ); | 899 | configureToolBarMenu->setItemChecked( 120, true ); |
900 | if (p-> mShowIconList) | 900 | if (p-> mShowIconList) |
901 | configureToolBarMenu->setItemChecked( 30, true ); | 901 | configureToolBarMenu->setItemChecked( 30, true ); |
902 | if (p-> mShowIconDay1) | 902 | if (p-> mShowIconDay1) |
903 | configureToolBarMenu->setItemChecked( 40, true ); | 903 | configureToolBarMenu->setItemChecked( 40, true ); |
904 | if (p-> mShowIconDay5) | 904 | if (p-> mShowIconDay5) |
905 | configureToolBarMenu->setItemChecked( 50, true ); | 905 | configureToolBarMenu->setItemChecked( 50, true ); |
906 | if (p-> mShowIconDay7) | 906 | if (p-> mShowIconDay7) |
907 | configureToolBarMenu->setItemChecked( 60, true ); | 907 | configureToolBarMenu->setItemChecked( 60, true ); |
908 | if (p-> mShowIconMonth) | 908 | if (p-> mShowIconMonth) |
909 | configureToolBarMenu->setItemChecked( 70, true ); | 909 | configureToolBarMenu->setItemChecked( 70, true ); |
910 | if (p-> mShowIconTodoview) | 910 | if (p-> mShowIconTodoview) |
911 | configureToolBarMenu->setItemChecked( 80, true ); | 911 | configureToolBarMenu->setItemChecked( 80, true ); |
912 | if (p-> mShowIconBackFast) | 912 | if (p-> mShowIconBackFast) |
913 | configureToolBarMenu->setItemChecked( 200, true ); | 913 | configureToolBarMenu->setItemChecked( 200, true ); |
914 | if (p-> mShowIconBack) | 914 | if (p-> mShowIconBack) |
915 | configureToolBarMenu->setItemChecked( 210, true ); | 915 | configureToolBarMenu->setItemChecked( 210, true ); |
916 | if (p-> mShowIconToday) | 916 | if (p-> mShowIconToday) |
917 | configureToolBarMenu->setItemChecked( 130, true ); | 917 | configureToolBarMenu->setItemChecked( 130, true ); |
918 | if (p-> mShowIconForward) | 918 | if (p-> mShowIconForward) |
919 | configureToolBarMenu->setItemChecked( 220, true ); | 919 | configureToolBarMenu->setItemChecked( 220, true ); |
920 | if (p-> mShowIconForwardFast) | 920 | if (p-> mShowIconForwardFast) |
921 | configureToolBarMenu->setItemChecked( 230, true ); | 921 | configureToolBarMenu->setItemChecked( 230, true ); |
922 | if (p-> mShowIconNextDays) | 922 | if (p-> mShowIconNextDays) |
923 | configureToolBarMenu->setItemChecked( 100, true ); | 923 | configureToolBarMenu->setItemChecked( 100, true ); |
924 | if (p-> mShowIconNext) | 924 | if (p-> mShowIconNext) |
925 | configureToolBarMenu->setItemChecked( 110, true ); | 925 | configureToolBarMenu->setItemChecked( 110, true ); |
926 | if (p-> mShowIconJournal) | 926 | if (p-> mShowIconJournal) |
927 | configureToolBarMenu->setItemChecked( 90, true ); | 927 | configureToolBarMenu->setItemChecked( 90, true ); |
928 | if (p-> mShowIconWhatsThis) | 928 | if (p-> mShowIconWhatsThis) |
929 | configureToolBarMenu->setItemChecked( 300, true ); | 929 | configureToolBarMenu->setItemChecked( 300, true ); |
930 | 930 | ||
931 | QLabel* dummy = new QLabel( iconToolBar ); | 931 | QLabel* dummy = new QLabel( iconToolBar ); |
932 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 932 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
933 | if (!p-> mShowIconStretch) | 933 | if (!p-> mShowIconStretch) |
934 | iconToolBar->setStretchableWidget ( dummy ) ; | 934 | iconToolBar->setStretchableWidget ( dummy ) ; |
935 | else | 935 | else |
936 | configureToolBarMenu->setItemChecked( 5, true ); | 936 | configureToolBarMenu->setItemChecked( 5, true ); |
937 | if (p-> mShowIconWhatsThis) | 937 | if (p-> mShowIconWhatsThis) |
938 | QWhatsThis::whatsThisButton ( iconToolBar ); | 938 | QWhatsThis::whatsThisButton ( iconToolBar ); |
939 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 939 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
940 | configureAgenda( p->mHourSize ); | 940 | configureAgenda( p->mHourSize ); |
941 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 941 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
942 | } | 942 | } |
943 | void MainWindow::fillSyncMenu() | 943 | void MainWindow::fillSyncMenu() |
944 | { | 944 | { |
945 | if ( syncMenu->count() ) | 945 | if ( syncMenu->count() ) |
946 | syncMenu->clear(); | 946 | syncMenu->clear(); |
947 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 947 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
948 | syncMenu->insertSeparator(); | 948 | syncMenu->insertSeparator(); |
949 | if ( mServerSocket == 0 ) { | 949 | if ( mServerSocket == 0 ) { |
950 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 950 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
951 | } else { | 951 | } else { |
952 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 952 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
953 | } | 953 | } |
954 | syncMenu->insertSeparator(); | 954 | syncMenu->insertSeparator(); |
955 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 955 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
956 | syncMenu->insertSeparator(); | 956 | syncMenu->insertSeparator(); |
957 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 957 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
958 | config.setGroup("General"); | 958 | config.setGroup("General"); |
959 | QStringList prof = config.readListEntry("SyncProfileNames"); | 959 | QStringList prof = config.readListEntry("SyncProfileNames"); |
960 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 960 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
961 | if ( prof.count() < 3 ) { | 961 | if ( prof.count() < 3 ) { |
962 | prof.clear(); | 962 | prof.clear(); |
963 | prof << i18n("Sharp_DTM"); | 963 | prof << i18n("Sharp_DTM"); |
964 | prof << i18n("Local_file"); | 964 | prof << i18n("Local_file"); |
965 | prof << i18n("Last_file"); | 965 | prof << i18n("Last_file"); |
966 | KSyncProfile* temp = new KSyncProfile (); | 966 | KSyncProfile* temp = new KSyncProfile (); |
967 | temp->setName( prof[0] ); | 967 | temp->setName( prof[0] ); |
968 | temp->writeConfig(&config); | 968 | temp->writeConfig(&config); |
969 | temp->setName( prof[1] ); | 969 | temp->setName( prof[1] ); |
970 | temp->writeConfig(&config); | 970 | temp->writeConfig(&config); |
971 | temp->setName( prof[2] ); | 971 | temp->setName( prof[2] ); |
972 | temp->writeConfig(&config); | 972 | temp->writeConfig(&config); |
973 | config.setGroup("General"); | 973 | config.setGroup("General"); |
974 | config.writeEntry("SyncProfileNames",prof); | 974 | config.writeEntry("SyncProfileNames",prof); |
975 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 975 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
976 | config.sync(); | 976 | config.sync(); |
977 | delete temp; | 977 | delete temp; |
978 | } | 978 | } |
979 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 979 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
980 | KOPrefs::instance()->mSyncProfileNames = prof; | 980 | KOPrefs::instance()->mSyncProfileNames = prof; |
981 | int i; | 981 | int i; |
982 | for ( i = 0; i < prof.count(); ++i ) { | 982 | for ( i = 0; i < prof.count(); ++i ) { |
983 | 983 | ||
984 | syncMenu->insertItem( prof[i], 1000+i ); | 984 | syncMenu->insertItem( prof[i], 1000+i ); |
985 | if ( i == 2 ) | 985 | if ( i == 2 ) |
986 | syncMenu->insertSeparator(); | 986 | syncMenu->insertSeparator(); |
987 | } | 987 | } |
988 | QDir app_dir; | 988 | QDir app_dir; |
989 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 989 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
990 | syncMenu->setItemEnabled( false , 1000 ); | 990 | syncMenu->setItemEnabled( false , 1000 ); |
991 | } | 991 | } |
992 | mView->setupExternSyncProfiles(); | 992 | mView->setupExternSyncProfiles(); |
993 | } | 993 | } |
994 | 994 | ||
995 | int MainWindow::ringSync() | 995 | int MainWindow::ringSync() |
996 | { | 996 | { |
997 | int syncedProfiles = 0; | 997 | int syncedProfiles = 0; |
998 | int i; | 998 | int i; |
999 | QTime timer; | 999 | QTime timer; |
1000 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1000 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1001 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | 1001 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; |
1002 | KSyncProfile* temp = new KSyncProfile (); | 1002 | KSyncProfile* temp = new KSyncProfile (); |
1003 | KOPrefs::instance()->mAskForPreferences = false; | 1003 | KOPrefs::instance()->mAskForPreferences = false; |
1004 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 1004 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
1005 | mCurrentSyncProfile = i; | 1005 | mCurrentSyncProfile = i; |
1006 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 1006 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
1007 | temp->readConfig(&config); | 1007 | temp->readConfig(&config); |
1008 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 1008 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { |
1009 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 1009 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
1010 | ++syncedProfiles; | 1010 | ++syncedProfiles; |
1011 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1011 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1012 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1012 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1013 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1013 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1014 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1014 | KOPrefs::instance()->mWriteBackInFuture = 0; |
1015 | if ( temp->getWriteBackFuture() ) | 1015 | if ( temp->getWriteBackFuture() ) |
1016 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1016 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
1017 | KOPrefs::instance()->mShowSyncSummary = false; | 1017 | KOPrefs::instance()->mShowSyncSummary = false; |
1018 | mView->setSyncDevice(syncProfileNames[i] ); | 1018 | mView->setSyncDevice(syncProfileNames[i] ); |
1019 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1019 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1020 | if ( i == 0 ) { | 1020 | if ( i == 0 ) { |
1021 | syncSharp(); | 1021 | syncSharp(); |
1022 | } else { | 1022 | } else { |
1023 | if ( temp->getIsLocalFileSync() ) { | 1023 | if ( temp->getIsLocalFileSync() ) { |
1024 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | 1024 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) |
1025 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1025 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1026 | } else { | 1026 | } else { |
1027 | if ( temp->getIsPhoneSync() ) { | 1027 | if ( temp->getIsPhoneSync() ) { |
1028 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1028 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1029 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1029 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1030 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1030 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1031 | syncPhone(); | 1031 | syncPhone(); |
1032 | } else if ( temp->getIsPiSync() ) { | 1032 | } else if ( temp->getIsPiSync() ) { |
1033 | mPassWordPiSync = temp->getRemotePw(); | 1033 | mPassWordPiSync = temp->getRemotePw(); |
1034 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | 1034 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); |
1035 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | 1035 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); |
1036 | syncPi(); | 1036 | syncPi(); |
1037 | } else | 1037 | } else |
1038 | syncRemote( temp, false ); | 1038 | syncRemote( temp, false ); |
1039 | 1039 | ||
1040 | } | 1040 | } |
1041 | } | 1041 | } |
1042 | timer.start(); | 1042 | timer.start(); |
1043 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 1043 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
1044 | while ( timer.elapsed () < 2000 ) { | 1044 | while ( timer.elapsed () < 2000 ) { |
1045 | qApp->processEvents(); | 1045 | qApp->processEvents(); |
1046 | #ifndef _WIN32_ | 1046 | #ifndef _WIN32_ |
1047 | sleep (1); | 1047 | sleep (1); |
1048 | #endif | 1048 | #endif |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | } | 1051 | } |
1052 | 1052 | ||
1053 | } | 1053 | } |
1054 | delete temp; | 1054 | delete temp; |
1055 | return syncedProfiles; | 1055 | return syncedProfiles; |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | void MainWindow::multiSync( bool askforPrefs ) | 1058 | void MainWindow::multiSync( bool askforPrefs ) |
1059 | { | 1059 | { |
1060 | if (mBlockSaveFlag) | 1060 | if (mBlockSaveFlag) |
1061 | return; | 1061 | return; |
1062 | mBlockSaveFlag = true; | 1062 | mBlockSaveFlag = true; |
1063 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 1063 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
1064 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 1064 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
1065 | question, | 1065 | question, |
1066 | i18n("Yes"), i18n("No"), | 1066 | i18n("Yes"), i18n("No"), |
1067 | 0, 0 ) != 0 ) { | 1067 | 0, 0 ) != 0 ) { |
1068 | mBlockSaveFlag = false; | 1068 | mBlockSaveFlag = false; |
1069 | setCaption(i18n("Aborted! Nothing synced!")); | 1069 | setCaption(i18n("Aborted! Nothing synced!")); |
1070 | return; | 1070 | return; |
1071 | } | 1071 | } |
1072 | mView->setSyncDevice(i18n("Multiple profiles") ); | 1072 | mView->setSyncDevice(i18n("Multiple profiles") ); |
1073 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | 1073 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; |
1074 | if ( askforPrefs ) { | 1074 | if ( askforPrefs ) { |
1075 | mView->edit_sync_options(); | 1075 | mView->edit_sync_options(); |
1076 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | 1076 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; |
1077 | } | 1077 | } |
1078 | setCaption(i18n("Multiple sync started.") ); | 1078 | setCaption(i18n("Multiple sync started.") ); |
1079 | qApp->processEvents(); | 1079 | qApp->processEvents(); |
1080 | int num = ringSync() ; | 1080 | int num = ringSync() ; |
1081 | if ( num > 1 ) | 1081 | if ( num > 1 ) |
1082 | ringSync(); | 1082 | ringSync(); |
1083 | mBlockSaveFlag = false; | 1083 | mBlockSaveFlag = false; |
1084 | if ( num ) | 1084 | if ( num ) |
1085 | save(); | 1085 | save(); |
1086 | if ( num ) | 1086 | if ( num ) |
1087 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 1087 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
1088 | else | 1088 | else |
1089 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 1089 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
1090 | return; | 1090 | return; |
1091 | } | 1091 | } |
1092 | void MainWindow::slotSyncMenu( int action ) | 1092 | void MainWindow::slotSyncMenu( int action ) |
1093 | { | 1093 | { |
1094 | qDebug("syncaction %d ", action); | 1094 | qDebug("syncaction %d ", action); |
1095 | if ( action == 0 ) { | 1095 | if ( action == 0 ) { |
1096 | 1096 | ||
1097 | // seems to be a Qt2 event handling bug | 1097 | // seems to be a Qt2 event handling bug |
1098 | // syncmenu.clear causes a segfault at first time | 1098 | // syncmenu.clear causes a segfault at first time |
1099 | // when we call it after the main event loop, it is ok | 1099 | // when we call it after the main event loop, it is ok |
1100 | // same behaviour when calling OM/Pi via QCOP for the first time | 1100 | // same behaviour when calling OM/Pi via QCOP for the first time |
1101 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 1101 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
1102 | //confSync(); | 1102 | //confSync(); |
1103 | 1103 | ||
1104 | return; | 1104 | return; |
1105 | } | 1105 | } |
1106 | if ( action == 1 ) { | 1106 | if ( action == 1 ) { |
1107 | multiSync( true ); | 1107 | multiSync( true ); |
1108 | return; | 1108 | return; |
1109 | } | 1109 | } |
1110 | if ( action == 2 ) { | 1110 | if ( action == 2 ) { |
1111 | enableQuick(); | 1111 | enableQuick(); |
1112 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 1112 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
1113 | return; | 1113 | return; |
1114 | } | 1114 | } |
1115 | if ( action == 3 ) { | 1115 | if ( action == 3 ) { |
1116 | delete mServerSocket; | 1116 | delete mServerSocket; |
1117 | mServerSocket = 0; | 1117 | mServerSocket = 0; |
1118 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 1118 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
1119 | return; | 1119 | return; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | if (mBlockSaveFlag) | 1122 | if (mBlockSaveFlag) |
1123 | return; | 1123 | return; |
1124 | mBlockSaveFlag = true; | 1124 | mBlockSaveFlag = true; |
1125 | mCurrentSyncProfile = action - 1000 ; | 1125 | mCurrentSyncProfile = action - 1000 ; |
1126 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 1126 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
1127 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1127 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1128 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1128 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1129 | KSyncProfile* temp = new KSyncProfile (); | 1129 | KSyncProfile* temp = new KSyncProfile (); |
1130 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 1130 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
1131 | temp->readConfig(&config); | 1131 | temp->readConfig(&config); |
1132 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1132 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1133 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 1133 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
1134 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1134 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1135 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1135 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1136 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1136 | KOPrefs::instance()->mWriteBackInFuture = 0; |
1137 | if ( temp->getWriteBackFuture() ) | 1137 | if ( temp->getWriteBackFuture() ) |
1138 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1138 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
1139 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 1139 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
1140 | if ( action == 1000 ) { | 1140 | if ( action == 1000 ) { |
1141 | syncSharp(); | 1141 | syncSharp(); |
1142 | 1142 | ||
1143 | } else if ( action == 1001 ) { | 1143 | } else if ( action == 1001 ) { |
1144 | syncLocalFile(); | 1144 | syncLocalFile(); |
1145 | 1145 | ||
1146 | } else if ( action == 1002 ) { | 1146 | } else if ( action == 1002 ) { |
1147 | quickSyncLocalFile(); | 1147 | quickSyncLocalFile(); |
1148 | 1148 | ||
1149 | } else if ( action >= 1003 ) { | 1149 | } else if ( action >= 1003 ) { |
1150 | if ( temp->getIsLocalFileSync() ) { | 1150 | if ( temp->getIsLocalFileSync() ) { |
1151 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 1151 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
1152 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1152 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1153 | } else { | 1153 | } else { |
1154 | if ( temp->getIsPhoneSync() ) { | 1154 | if ( temp->getIsPhoneSync() ) { |
1155 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1155 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1156 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1156 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1157 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1157 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1158 | syncPhone(); | 1158 | syncPhone(); |
1159 | } else if ( temp->getIsPiSync() ) { | 1159 | } else if ( temp->getIsPiSync() ) { |
1160 | mPassWordPiSync = temp->getRemotePw(); | 1160 | mPassWordPiSync = temp->getRemotePw(); |
1161 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | 1161 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); |
1162 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | 1162 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); |
1163 | syncPi(); | 1163 | syncPi(); |
1164 | } else | 1164 | } else |
1165 | syncRemote( temp ); | 1165 | syncRemote( temp ); |
1166 | 1166 | ||
1167 | } | 1167 | } |
1168 | } | 1168 | } |
1169 | delete temp; | 1169 | delete temp; |
1170 | mBlockSaveFlag = false; | 1170 | mBlockSaveFlag = false; |
1171 | } | 1171 | } |
1172 | void MainWindow::exportToPhone( int mode ) | 1172 | void MainWindow::exportToPhone( int mode ) |
1173 | { | 1173 | { |
1174 | 1174 | ||
1175 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1175 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1176 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1176 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1177 | KOex2phonePrefs ex2phone; | 1177 | KOex2phonePrefs ex2phone; |
1178 | ex2phone.mPhoneConnection->setText( KOPrefs::instance()->mEx2PhoneConnection ); | 1178 | |
1179 | ex2phone.mPhoneDevice->setText( KOPrefs::instance()->mEx2PhoneDevice ); | 1179 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1180 | ex2phone.mPhoneModel->setText( KOPrefs::instance()->mEx2PhoneModel ); | 1180 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1181 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | ||
1181 | if ( mode == 1 ) | 1182 | if ( mode == 1 ) |
1182 | ex2phone.setCaption(i18n("Export complete calendar")); | 1183 | ex2phone.setCaption(i18n("Export complete calendar")); |
1183 | if ( mode == 2 ) | 1184 | if ( mode == 2 ) |
1184 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1185 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1185 | 1186 | ||
1186 | if ( !ex2phone.exec() ) { | 1187 | if ( !ex2phone.exec() ) { |
1187 | return; | 1188 | return; |
1188 | } | 1189 | } |
1189 | KOPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1190 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1190 | KOPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1191 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1191 | KOPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1192 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1192 | 1193 | ||
1193 | int inFuture = 0; | 1194 | int inFuture = 0; |
1194 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1195 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1195 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1196 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1196 | QPtrList<Incidence> delSel; | 1197 | QPtrList<Incidence> delSel; |
1197 | if ( mode == 1 ) | 1198 | if ( mode == 1 ) |
1198 | delSel = mCalendar->rawIncidences(); | 1199 | delSel = mCalendar->rawIncidences(); |
1199 | if ( mode == 2 ) | 1200 | if ( mode == 2 ) |
1200 | delSel = mCalendar->incidences(); | 1201 | delSel = mCalendar->incidences(); |
1201 | CalendarLocal* cal = new CalendarLocal(); | 1202 | CalendarLocal* cal = new CalendarLocal(); |
1202 | cal->setLocalTime(); | 1203 | cal->setLocalTime(); |
1203 | Incidence *incidence = delSel.first(); | 1204 | Incidence *incidence = delSel.first(); |
1204 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1205 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1205 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1206 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1206 | while ( incidence ) { | 1207 | while ( incidence ) { |
1207 | if ( incidence->type() != "Journal" ) { | 1208 | if ( incidence->type() != "Journal" ) { |
1208 | bool add = true; | 1209 | bool add = true; |
1209 | if ( inFuture ) { | 1210 | if ( inFuture ) { |
1210 | QDateTime dt; | 1211 | QDateTime dt; |
1211 | if ( incidence->type() == "Todo" ) { | 1212 | if ( incidence->type() == "Todo" ) { |
1212 | Todo * t = (Todo*)incidence; | 1213 | Todo * t = (Todo*)incidence; |
1213 | if ( t->hasDueDate() ) | 1214 | if ( t->hasDueDate() ) |
1214 | dt = t->dtDue(); | 1215 | dt = t->dtDue(); |
1215 | else | 1216 | else |
1216 | dt = cur.addSecs( 62 ); | 1217 | dt = cur.addSecs( 62 ); |
1217 | } | 1218 | } |
1218 | else { | 1219 | else { |
1219 | bool ok; | 1220 | bool ok; |
1220 | dt = incidence->getNextOccurence( cur, &ok ); | 1221 | dt = incidence->getNextOccurence( cur, &ok ); |
1221 | if ( !ok ) | 1222 | if ( !ok ) |
1222 | dt = cur.addSecs( -62 ); | 1223 | dt = cur.addSecs( -62 ); |
1223 | } | 1224 | } |
1224 | if ( dt < cur || dt > end ) { | 1225 | if ( dt < cur || dt > end ) { |
1225 | add = false; | 1226 | add = false; |
1226 | } | 1227 | } |
1227 | } | 1228 | } |
1228 | if ( add ) { | 1229 | if ( add ) { |
1229 | Incidence *in = incidence->clone(); | 1230 | Incidence *in = incidence->clone(); |
1230 | cal->addIncidence( in ); | 1231 | cal->addIncidence( in ); |
1231 | } | 1232 | } |
1232 | } | 1233 | } |
1233 | incidence = delSel.next(); | 1234 | incidence = delSel.next(); |
1234 | } | 1235 | } |
1235 | PhoneFormat::writeConfig( KOPrefs::instance()->mEx2PhoneDevice, | 1236 | PhoneFormat::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1236 | KOPrefs::instance()->mEx2PhoneConnection, | 1237 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1237 | KOPrefs::instance()->mEx2PhoneModel ); | 1238 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1238 | 1239 | ||
1239 | setCaption( i18n("Writing to phone...")); | 1240 | setCaption( i18n("Writing to phone...")); |
1240 | if ( PhoneFormat::writeToPhone( cal ) ) | 1241 | if ( PhoneFormat::writeToPhone( cal ) ) |
1241 | setCaption( i18n("Export to phone successful!")); | 1242 | setCaption( i18n("Export to phone successful!")); |
1242 | else | 1243 | else |
1243 | setCaption( i18n("Error exporting to phone!")); | 1244 | setCaption( i18n("Error exporting to phone!")); |
1244 | delete cal; | 1245 | delete cal; |
1245 | } | 1246 | } |
1246 | 1247 | ||
1247 | 1248 | ||
1248 | void MainWindow::setDefaultPreferences() | 1249 | void MainWindow::setDefaultPreferences() |
1249 | { | 1250 | { |
1250 | KOPrefs *p = KOPrefs::instance(); | 1251 | KOPrefs *p = KOPrefs::instance(); |
1251 | 1252 | ||
1252 | p->mCompactDialogs = true; | 1253 | p->mCompactDialogs = true; |
1253 | p->mConfirm = true; | 1254 | p->mConfirm = true; |
1254 | // p->mEnableQuickTodo = false; | 1255 | // p->mEnableQuickTodo = false; |
1255 | 1256 | ||
1256 | } | 1257 | } |
1257 | 1258 | ||
1258 | QString MainWindow::resourcePath() | 1259 | QString MainWindow::resourcePath() |
1259 | { | 1260 | { |
1260 | return KGlobal::iconLoader()->iconPath(); | 1261 | return KGlobal::iconLoader()->iconPath(); |
1261 | } | 1262 | } |
1262 | 1263 | ||
1263 | void MainWindow::displayText( QString text ,QString cap ) | 1264 | void MainWindow::displayText( QString text ,QString cap ) |
1264 | { | 1265 | { |
1265 | QDialog dia( this, "name", true ); ; | 1266 | QDialog dia( this, "name", true ); ; |
1266 | dia.setCaption( cap ); | 1267 | dia.setCaption( cap ); |
1267 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1268 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1268 | lay->setSpacing( 3 ); | 1269 | lay->setSpacing( 3 ); |
1269 | lay->setMargin( 3 ); | 1270 | lay->setMargin( 3 ); |
1270 | QTextBrowser tb ( &dia ); | 1271 | QTextBrowser tb ( &dia ); |
1271 | lay->addWidget( &tb ); | 1272 | lay->addWidget( &tb ); |
1272 | tb.setText( text ); | 1273 | tb.setText( text ); |
1273 | #ifdef DESKTOP_VERSION | 1274 | #ifdef DESKTOP_VERSION |
1274 | dia.resize( 640, 480); | 1275 | dia.resize( 640, 480); |
1275 | #else | 1276 | #else |
1276 | dia.showMaximized(); | 1277 | dia.showMaximized(); |
1277 | #endif | 1278 | #endif |
1278 | dia.exec(); | 1279 | dia.exec(); |
1279 | } | 1280 | } |
1280 | void MainWindow::displayFile( QString fn, QString cap ) | 1281 | void MainWindow::displayFile( QString fn, QString cap ) |
1281 | { | 1282 | { |
1282 | QString fileName = resourcePath() + fn; | 1283 | QString fileName = resourcePath() + fn; |
1283 | QString text; | 1284 | QString text; |
1284 | QFile file( fileName ); | 1285 | QFile file( fileName ); |
1285 | if (!file.open( IO_ReadOnly ) ) { | 1286 | if (!file.open( IO_ReadOnly ) ) { |
1286 | return ; | 1287 | return ; |
1287 | 1288 | ||
1288 | } | 1289 | } |
1289 | QTextStream ts( &file ); | 1290 | QTextStream ts( &file ); |
1290 | text = ts.read(); | 1291 | text = ts.read(); |
1291 | file.close(); | 1292 | file.close(); |
1292 | displayText( text, cap); | 1293 | displayText( text, cap); |
1293 | } | 1294 | } |
1294 | void MainWindow::features() | 1295 | void MainWindow::features() |
1295 | { | 1296 | { |
1296 | 1297 | ||
1297 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1298 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1298 | } | 1299 | } |
1299 | 1300 | ||
1300 | void MainWindow::usertrans() | 1301 | void MainWindow::usertrans() |
1301 | { | 1302 | { |
1302 | 1303 | ||
1303 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1304 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1304 | } | 1305 | } |
1305 | 1306 | ||
1306 | void MainWindow::synchowto() | 1307 | void MainWindow::synchowto() |
1307 | { | 1308 | { |
1308 | #if 0 | 1309 | #if 0 |
1309 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | 1310 | QPtrList<Incidence> er = mCalendar->rawIncidences(); |
1310 | Incidence* inR = er.first(); | 1311 | Incidence* inR = er.first(); |
1311 | VCalFormat vf; | 1312 | VCalFormat vf; |
1312 | QString strout; | 1313 | QString strout; |
1313 | while ( inR ) { | 1314 | while ( inR ) { |
1314 | if ( inR->type() == "Todo" ) | 1315 | if ( inR->type() == "Todo" ) |
1315 | strout = vf.todoToString( (Todo *) inR ); | 1316 | strout = vf.todoToString( (Todo *) inR ); |
1316 | if ( inR->type() == "Event" ) | 1317 | if ( inR->type() == "Event" ) |
1317 | strout = vf.eventToString( (Event *) inR ); | 1318 | strout = vf.eventToString( (Event *) inR ); |
1318 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); | 1319 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); |
1319 | inR = er.next(); | 1320 | inR = er.next(); |
1320 | } | 1321 | } |
1321 | #endif | 1322 | #endif |
1322 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1323 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1323 | } | 1324 | } |
1324 | void MainWindow::faq() | 1325 | void MainWindow::faq() |
1325 | { | 1326 | { |
1326 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1327 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1327 | 1328 | ||
1328 | } | 1329 | } |
1329 | void MainWindow::whatsNew() | 1330 | void MainWindow::whatsNew() |
1330 | { | 1331 | { |
1331 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | 1332 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); |
1332 | 1333 | ||
1333 | } | 1334 | } |
1334 | void MainWindow::licence() | 1335 | void MainWindow::licence() |
1335 | { | 1336 | { |
1336 | KApplication::showLicence(); | 1337 | KApplication::showLicence(); |
1337 | 1338 | ||
1338 | } | 1339 | } |
1339 | void MainWindow::about() | 1340 | void MainWindow::about() |
1340 | { | 1341 | { |
1341 | QString version; | 1342 | QString version; |
1342 | #include <../version> | 1343 | #include <../version> |
1343 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1344 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1344 | i18n("KOrganizer/Platform-independent\n") + | 1345 | i18n("KOrganizer/Platform-independent\n") + |
1345 | "(KO/Pi) " + version + " - " + | 1346 | "(KO/Pi) " + version + " - " + |
1346 | 1347 | ||
1347 | #ifdef DESKTOP_VERSION | 1348 | #ifdef DESKTOP_VERSION |
1348 | i18n("Desktop Edition\n") + | 1349 | i18n("Desktop Edition\n") + |
1349 | #else | 1350 | #else |
1350 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1351 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1351 | #endif | 1352 | #endif |
1352 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1353 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1353 | } | 1354 | } |
1354 | void MainWindow::keyBindings() | 1355 | void MainWindow::keyBindings() |
1355 | { | 1356 | { |
1356 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1357 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1357 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1358 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1358 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1359 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1359 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1360 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1360 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1361 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1361 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1362 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1362 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1363 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1363 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1364 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1364 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1365 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1365 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1366 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1366 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1367 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1367 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1368 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1368 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1369 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1369 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1370 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1370 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1371 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1371 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1372 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1372 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1373 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1373 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1374 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1374 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1375 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1375 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1376 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1376 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1377 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1377 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1378 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1378 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1379 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1379 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1380 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1380 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1381 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1381 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1382 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1382 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1383 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1383 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1384 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1384 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1385 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1385 | i18n("<p><h3>In list view:</h3></p>\n") + | 1386 | i18n("<p><h3>In list view:</h3></p>\n") + |
1386 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1387 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1387 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1388 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1388 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1389 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1389 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1390 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1390 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1391 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1391 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1392 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1392 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1393 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1393 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1394 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1394 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1395 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1395 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1396 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1396 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1397 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1397 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1398 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1398 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1399 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1399 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1400 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1400 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1401 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1401 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1402 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1402 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1403 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1403 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1404 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1404 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1405 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1405 | displayText( text, cap); | 1406 | displayText( text, cap); |
1406 | 1407 | ||
1407 | } | 1408 | } |
1408 | void MainWindow::aboutAutoSaving() | 1409 | void MainWindow::aboutAutoSaving() |
1409 | { | 1410 | { |
1410 | QMessageBox* msg; | 1411 | QMessageBox* msg; |
1411 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1412 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1412 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1413 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1413 | QMessageBox::Ok, | 1414 | QMessageBox::Ok, |
1414 | QMessageBox::NoButton, | 1415 | QMessageBox::NoButton, |
1415 | QMessageBox::NoButton); | 1416 | QMessageBox::NoButton); |
1416 | msg->exec(); | 1417 | msg->exec(); |
1417 | delete msg; | 1418 | delete msg; |
1418 | 1419 | ||
1419 | 1420 | ||
1420 | } | 1421 | } |
1421 | void MainWindow::aboutKnownBugs() | 1422 | void MainWindow::aboutKnownBugs() |
1422 | { | 1423 | { |
1423 | QMessageBox* msg; | 1424 | QMessageBox* msg; |
1424 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1425 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1425 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1426 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1426 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1427 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1427 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1428 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1428 | i18n("\nor report them in the bugtracker on\n") + | 1429 | i18n("\nor report them in the bugtracker on\n") + |
1429 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1430 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1430 | QMessageBox::NoIcon, | 1431 | QMessageBox::NoIcon, |
1431 | QMessageBox::Ok, | 1432 | QMessageBox::Ok, |
1432 | QMessageBox::NoButton, | 1433 | QMessageBox::NoButton, |
1433 | QMessageBox::NoButton); | 1434 | QMessageBox::NoButton); |
1434 | msg->exec(); | 1435 | msg->exec(); |
1435 | delete msg; | 1436 | delete msg; |
1436 | 1437 | ||
1437 | } | 1438 | } |
1438 | 1439 | ||
1439 | QString MainWindow::defaultFileName() | 1440 | QString MainWindow::defaultFileName() |
1440 | { | 1441 | { |
1441 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1442 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1442 | } | 1443 | } |
1443 | QString MainWindow::syncFileName() | 1444 | QString MainWindow::syncFileName() |
1444 | { | 1445 | { |
1445 | #ifdef _WIN32_ | 1446 | #ifdef _WIN32_ |
1446 | return locateLocal( "tmp", "synccalendar.ics" ); | 1447 | return locateLocal( "tmp", "synccalendar.ics" ); |
1447 | #else | 1448 | #else |
1448 | return QString( "/tmp/kopitempfile.ics" ); | 1449 | return QString( "/tmp/kopitempfile.ics" ); |
1449 | #endif | 1450 | #endif |
1450 | } | 1451 | } |
1451 | 1452 | ||
1452 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1453 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1453 | { | 1454 | { |
1454 | if ( !incidence ) { | 1455 | if ( !incidence ) { |
1455 | enableIncidenceActions( false ); | 1456 | enableIncidenceActions( false ); |
1456 | 1457 | ||
1457 | mNewSubTodoAction->setEnabled( false ); | 1458 | mNewSubTodoAction->setEnabled( false ); |
1458 | setCaptionToDates(); | 1459 | setCaptionToDates(); |
1459 | return; | 1460 | return; |
1460 | 1461 | ||
1461 | } | 1462 | } |
1462 | 1463 | ||
1463 | //KGlobal::locale()->formatDateTime(nextA, true); | 1464 | //KGlobal::locale()->formatDateTime(nextA, true); |
1464 | QString startString = ""; | 1465 | QString startString = ""; |
1465 | if ( incidence->type() != "Todo" ) { | 1466 | if ( incidence->type() != "Todo" ) { |
1466 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1467 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1467 | if ( incidence->doesFloat() ) { | 1468 | if ( incidence->doesFloat() ) { |
1468 | startString += ": "+incidence->dtStartDateStr( true ); | 1469 | startString += ": "+incidence->dtStartDateStr( true ); |
1469 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1470 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1470 | 1471 | ||
1471 | } else { | 1472 | } else { |
1472 | startString = ": "+incidence->dtStartStr(true); | 1473 | startString = ": "+incidence->dtStartStr(true); |
1473 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1474 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1474 | 1475 | ||
1475 | } | 1476 | } |
1476 | 1477 | ||
1477 | } else { | 1478 | } else { |
1478 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1479 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1479 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1480 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1480 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1481 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1481 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1482 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1482 | } | 1483 | } |
1483 | 1484 | ||
1484 | } | 1485 | } |
1485 | else | 1486 | else |
1486 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1487 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1487 | if ( !incidence->location().isEmpty() ) | 1488 | if ( !incidence->location().isEmpty() ) |
1488 | startString += " (" +incidence->location()+")"; | 1489 | startString += " (" +incidence->location()+")"; |
1489 | setCaption( incidence->summary()+startString); | 1490 | setCaption( incidence->summary()+startString); |
1490 | 1491 | ||
1491 | enableIncidenceActions( true ); | 1492 | enableIncidenceActions( true ); |
1492 | 1493 | ||
1493 | if ( incidence->type() == "Event" ) { | 1494 | if ( incidence->type() == "Event" ) { |
1494 | mShowAction->setText( i18n("Show Event...") ); | 1495 | mShowAction->setText( i18n("Show Event...") ); |
1495 | mEditAction->setText( i18n("Edit Event...") ); | 1496 | mEditAction->setText( i18n("Edit Event...") ); |
1496 | mDeleteAction->setText( i18n("Delete Event...") ); | 1497 | mDeleteAction->setText( i18n("Delete Event...") ); |
1497 | 1498 | ||
1498 | mNewSubTodoAction->setEnabled( false ); | 1499 | mNewSubTodoAction->setEnabled( false ); |
1499 | } else if ( incidence->type() == "Todo" ) { | 1500 | } else if ( incidence->type() == "Todo" ) { |
1500 | mShowAction->setText( i18n("Show Todo...") ); | 1501 | mShowAction->setText( i18n("Show Todo...") ); |
1501 | mEditAction->setText( i18n("Edit Todo...") ); | 1502 | mEditAction->setText( i18n("Edit Todo...") ); |
1502 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1503 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1503 | 1504 | ||
1504 | mNewSubTodoAction->setEnabled( true ); | 1505 | mNewSubTodoAction->setEnabled( true ); |
1505 | } else { | 1506 | } else { |
1506 | mShowAction->setText( i18n("Show...") ); | 1507 | mShowAction->setText( i18n("Show...") ); |
1507 | mShowAction->setText( i18n("Edit...") ); | 1508 | mShowAction->setText( i18n("Edit...") ); |
1508 | mShowAction->setText( i18n("Delete...") ); | 1509 | mShowAction->setText( i18n("Delete...") ); |
1509 | 1510 | ||
1510 | mNewSubTodoAction->setEnabled( false ); | 1511 | mNewSubTodoAction->setEnabled( false ); |
1511 | } | 1512 | } |
1512 | } | 1513 | } |
1513 | 1514 | ||
1514 | void MainWindow::enableIncidenceActions( bool enabled ) | 1515 | void MainWindow::enableIncidenceActions( bool enabled ) |
1515 | { | 1516 | { |
1516 | mShowAction->setEnabled( enabled ); | 1517 | mShowAction->setEnabled( enabled ); |
1517 | mEditAction->setEnabled( enabled ); | 1518 | mEditAction->setEnabled( enabled ); |
1518 | mDeleteAction->setEnabled( enabled ); | 1519 | mDeleteAction->setEnabled( enabled ); |
1519 | 1520 | ||
1520 | mCloneAction->setEnabled( enabled ); | 1521 | mCloneAction->setEnabled( enabled ); |
1521 | mMoveAction->setEnabled( enabled ); | 1522 | mMoveAction->setEnabled( enabled ); |
1522 | mBeamAction->setEnabled( enabled ); | 1523 | mBeamAction->setEnabled( enabled ); |
1523 | mCancelAction->setEnabled( enabled ); | 1524 | mCancelAction->setEnabled( enabled ); |
1524 | } | 1525 | } |
1525 | 1526 | ||
1526 | void MainWindow::importOL() | 1527 | void MainWindow::importOL() |
1527 | { | 1528 | { |
1528 | #ifdef _WIN32_ | 1529 | #ifdef _WIN32_ |
1529 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1530 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1530 | id->exec(); | 1531 | id->exec(); |
1531 | delete id; | 1532 | delete id; |
1532 | mView->updateView(); | 1533 | mView->updateView(); |
1533 | #endif | 1534 | #endif |
1534 | } | 1535 | } |
1535 | void MainWindow::importBday() | 1536 | void MainWindow::importBday() |
1536 | { | 1537 | { |
1537 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1538 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1538 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1539 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1539 | i18n("Import!"), i18n("Cancel"), 0, | 1540 | i18n("Import!"), i18n("Cancel"), 0, |
1540 | 0, 1 ); | 1541 | 0, 1 ); |
1541 | if ( result == 0 ) { | 1542 | if ( result == 0 ) { |
1542 | mView->importBday(); | 1543 | mView->importBday(); |
1543 | 1544 | ||
1544 | } | 1545 | } |
1545 | 1546 | ||
1546 | 1547 | ||
1547 | } | 1548 | } |
1548 | void MainWindow::importQtopia() | 1549 | void MainWindow::importQtopia() |
1549 | { | 1550 | { |
1550 | #ifndef DESKTOP_VERSION | 1551 | #ifndef DESKTOP_VERSION |
1551 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1552 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1552 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1553 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1553 | i18n("Import!"), i18n("Cancel"), 0, | 1554 | i18n("Import!"), i18n("Cancel"), 0, |
1554 | 0, 1 ); | 1555 | 0, 1 ); |
1555 | if ( result == 0 ) { | 1556 | if ( result == 0 ) { |
1556 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1557 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1557 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1558 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1558 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1559 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1559 | mView->importQtopia( categories, datebook, todolist ); | 1560 | mView->importQtopia( categories, datebook, todolist ); |
1560 | } | 1561 | } |
1561 | #else | 1562 | #else |
1562 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1563 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1563 | i18n("Not supported \non desktop!\n"), | 1564 | i18n("Not supported \non desktop!\n"), |
1564 | i18n("Ok"), i18n("Cancel"), 0, | 1565 | i18n("Ok"), i18n("Cancel"), 0, |
1565 | 0, 1 ); | 1566 | 0, 1 ); |
1566 | 1567 | ||
1567 | #endif | 1568 | #endif |
1568 | } | 1569 | } |
1569 | 1570 | ||
1570 | void MainWindow::saveOnClose() | 1571 | void MainWindow::saveOnClose() |
1571 | { | 1572 | { |
1572 | KOPrefs *p = KOPrefs::instance(); | 1573 | KOPrefs *p = KOPrefs::instance(); |
1573 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1574 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1574 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1575 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1575 | iconToolBar->y() > height()/2; | 1576 | iconToolBar->y() > height()/2; |
1576 | mView->writeSettings(); | 1577 | mView->writeSettings(); |
1577 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1578 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1578 | save(); | 1579 | save(); |
1579 | } | 1580 | } |
1580 | void MainWindow::slotModifiedChanged( bool changed ) | 1581 | void MainWindow::slotModifiedChanged( bool changed ) |
1581 | { | 1582 | { |
1582 | if ( mBlockAtStartup ) | 1583 | if ( mBlockAtStartup ) |
1583 | return; | 1584 | return; |
1584 | int msec; | 1585 | int msec; |
1585 | // we store the changes after 1 minute, | 1586 | // we store the changes after 1 minute, |
1586 | // and for safety reasons after 10 minutes again | 1587 | // and for safety reasons after 10 minutes again |
1587 | if ( !mBlockSaveFlag ) | 1588 | if ( !mBlockSaveFlag ) |
1588 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1589 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1589 | else | 1590 | else |
1590 | msec = 1000 * 600; | 1591 | msec = 1000 * 600; |
1591 | mSaveTimer.start( msec, true ); // 1 minute | 1592 | mSaveTimer.start( msec, true ); // 1 minute |
1592 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1593 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1593 | mCalendarModifiedFlag = true; | 1594 | mCalendarModifiedFlag = true; |
1594 | } | 1595 | } |
1595 | void MainWindow::save() | 1596 | void MainWindow::save() |
1596 | { | 1597 | { |
1597 | if ( mBlockSaveFlag ) | 1598 | if ( mBlockSaveFlag ) |
1598 | return; | 1599 | return; |
1599 | bool store = mBlockSaveFlag; | 1600 | bool store = mBlockSaveFlag; |
1600 | mBlockSaveFlag = true; | 1601 | mBlockSaveFlag = true; |
1601 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1602 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1602 | 1603 | ||
1603 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1604 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1604 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1605 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1605 | qDebug("KO: Start saving data to file!"); | 1606 | qDebug("KO: Start saving data to file!"); |
1606 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1607 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1607 | mView->saveCalendar( defaultFileName() ); | 1608 | mView->saveCalendar( defaultFileName() ); |
1608 | 1609 | ||
1609 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1610 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1610 | mView->watchSavedFile(); | 1611 | mView->watchSavedFile(); |
1611 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1612 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1612 | QString savemes; | 1613 | QString savemes; |
1613 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1614 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1614 | setCaption(savemes); | 1615 | setCaption(savemes); |
1615 | } else | 1616 | } else |
1616 | setCaption(i18n("Saving cancelled!")); | 1617 | setCaption(i18n("Saving cancelled!")); |
1617 | mCalendarModifiedFlag = false; | 1618 | mCalendarModifiedFlag = false; |
1618 | mBlockSaveFlag = store; | 1619 | mBlockSaveFlag = store; |
1619 | } | 1620 | } |
1620 | 1621 | ||
1621 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1622 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1622 | { | 1623 | { |
1623 | if ( !e->isAutoRepeat() ) { | 1624 | if ( !e->isAutoRepeat() ) { |
1624 | mFlagKeyPressed = false; | 1625 | mFlagKeyPressed = false; |
1625 | } | 1626 | } |
1626 | } | 1627 | } |
1627 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1628 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1628 | { | 1629 | { |
1629 | qApp->processEvents(); | 1630 | qApp->processEvents(); |
1630 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1631 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1631 | e->ignore(); | 1632 | e->ignore(); |
1632 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1633 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1633 | return; | 1634 | return; |
1634 | } | 1635 | } |
1635 | if (! e->isAutoRepeat() ) | 1636 | if (! e->isAutoRepeat() ) |
1636 | mFlagKeyPressed = true; | 1637 | mFlagKeyPressed = true; |
1637 | KOPrefs *p = KOPrefs::instance(); | 1638 | KOPrefs *p = KOPrefs::instance(); |
1638 | bool showSelectedDates = false; | 1639 | bool showSelectedDates = false; |
1639 | int size; | 1640 | int size; |
1640 | int pro = 0; | 1641 | int pro = 0; |
1641 | //qDebug("MainWindow::keyPressEvent "); | 1642 | //qDebug("MainWindow::keyPressEvent "); |
1642 | switch ( e->key() ) { | 1643 | switch ( e->key() ) { |
1643 | case Qt::Key_Right: | 1644 | case Qt::Key_Right: |
1644 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1645 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1645 | mView->goNextMonth(); | 1646 | mView->goNextMonth(); |
1646 | else | 1647 | else |
1647 | mView->goNext(); | 1648 | mView->goNext(); |
1648 | showSelectedDates = true; | 1649 | showSelectedDates = true; |
1649 | break; | 1650 | break; |
1650 | case Qt::Key_Left: | 1651 | case Qt::Key_Left: |
1651 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1652 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1652 | mView->goPreviousMonth(); | 1653 | mView->goPreviousMonth(); |
1653 | else | 1654 | else |
1654 | mView->goPrevious(); | 1655 | mView->goPrevious(); |
1655 | showSelectedDates = true; | 1656 | showSelectedDates = true; |
1656 | break; | 1657 | break; |
1657 | case Qt::Key_Down: | 1658 | case Qt::Key_Down: |
1658 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1659 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1659 | break; | 1660 | break; |
1660 | case Qt::Key_Up: | 1661 | case Qt::Key_Up: |
1661 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1662 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1662 | break; | 1663 | break; |
1663 | case Qt::Key_I: | 1664 | case Qt::Key_I: |
1664 | mView->showIncidence(); | 1665 | mView->showIncidence(); |
1665 | break; | 1666 | break; |
1666 | case Qt::Key_Delete: | 1667 | case Qt::Key_Delete: |
1667 | case Qt::Key_Backspace: | 1668 | case Qt::Key_Backspace: |
1668 | mView->deleteIncidence(); | 1669 | mView->deleteIncidence(); |
1669 | break; | 1670 | break; |
1670 | case Qt::Key_D: | 1671 | case Qt::Key_D: |
1671 | mView->viewManager()->showDayView(); | 1672 | mView->viewManager()->showDayView(); |
1672 | showSelectedDates = true; | 1673 | showSelectedDates = true; |
1673 | break; | 1674 | break; |
1674 | case Qt::Key_O: | 1675 | case Qt::Key_O: |
1675 | mView->toggleFilerEnabled( ); | 1676 | mView->toggleFilerEnabled( ); |
1676 | break; | 1677 | break; |
1677 | case Qt::Key_0: | 1678 | case Qt::Key_0: |
1678 | case Qt::Key_1: | 1679 | case Qt::Key_1: |
1679 | case Qt::Key_2: | 1680 | case Qt::Key_2: |
1680 | case Qt::Key_3: | 1681 | case Qt::Key_3: |
1681 | case Qt::Key_4: | 1682 | case Qt::Key_4: |
1682 | case Qt::Key_5: | 1683 | case Qt::Key_5: |
1683 | case Qt::Key_6: | 1684 | case Qt::Key_6: |
1684 | case Qt::Key_7: | 1685 | case Qt::Key_7: |
1685 | case Qt::Key_8: | 1686 | case Qt::Key_8: |
1686 | case Qt::Key_9: | 1687 | case Qt::Key_9: |
1687 | pro = e->key()-48; | 1688 | pro = e->key()-48; |
1688 | if ( pro == 0 ) | 1689 | if ( pro == 0 ) |
1689 | pro = 10; | 1690 | pro = 10; |
1690 | if ( e->state() == Qt::ControlButton) | 1691 | if ( e->state() == Qt::ControlButton) |
1691 | pro += 10; | 1692 | pro += 10; |
1692 | break; | 1693 | break; |
1693 | case Qt::Key_M: | 1694 | case Qt::Key_M: |
1694 | mView->viewManager()->showMonthView(); | 1695 | mView->viewManager()->showMonthView(); |
1695 | showSelectedDates = true; | 1696 | showSelectedDates = true; |
1696 | break; | 1697 | break; |
1697 | case Qt::Key_Insert: | 1698 | case Qt::Key_Insert: |
1698 | mView->newEvent(); | 1699 | mView->newEvent(); |
1699 | break; | 1700 | break; |
1700 | case Qt::Key_S : | 1701 | case Qt::Key_S : |
1701 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1702 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1702 | mView->newSubTodo(); | 1703 | mView->newSubTodo(); |
1703 | else | 1704 | else |
1704 | mView->dialogManager()->showSearchDialog(); | 1705 | mView->dialogManager()->showSearchDialog(); |
1705 | break; | 1706 | break; |
1706 | case Qt::Key_Y : | 1707 | case Qt::Key_Y : |
1707 | case Qt::Key_Z : | 1708 | case Qt::Key_Z : |
1708 | mView->viewManager()->showWorkWeekView(); | 1709 | mView->viewManager()->showWorkWeekView(); |
1709 | showSelectedDates = true; | 1710 | showSelectedDates = true; |
1710 | break; | 1711 | break; |
1711 | case Qt::Key_U : | 1712 | case Qt::Key_U : |
1712 | mView->viewManager()->showWeekView(); | 1713 | mView->viewManager()->showWeekView(); |
1713 | showSelectedDates = true; | 1714 | showSelectedDates = true; |
1714 | break; | 1715 | break; |
1715 | case Qt::Key_H : | 1716 | case Qt::Key_H : |
1716 | keyBindings(); | 1717 | keyBindings(); |
1717 | break; | 1718 | break; |
1718 | case Qt::Key_W: | 1719 | case Qt::Key_W: |
1719 | mView->viewManager()->showWhatsNextView(); | 1720 | mView->viewManager()->showWhatsNextView(); |
1720 | break; | 1721 | break; |
1721 | case Qt::Key_L: | 1722 | case Qt::Key_L: |
1722 | mView->viewManager()->showListView(); | 1723 | mView->viewManager()->showListView(); |
1723 | break; | 1724 | break; |
1724 | case Qt::Key_N: | 1725 | case Qt::Key_N: |
1725 | mView->viewManager()->showNextXView(); | 1726 | mView->viewManager()->showNextXView(); |
1726 | showSelectedDates = true; | 1727 | showSelectedDates = true; |
1727 | break; | 1728 | break; |
1728 | case Qt::Key_V: | 1729 | case Qt::Key_V: |
1729 | mView->viewManager()->showTodoView(); | 1730 | mView->viewManager()->showTodoView(); |
1730 | break; | 1731 | break; |
1731 | case Qt::Key_C: | 1732 | case Qt::Key_C: |
1732 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1733 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1733 | break; | 1734 | break; |
1734 | case Qt::Key_P: | 1735 | case Qt::Key_P: |
1735 | mView->showDatePicker( ); | 1736 | mView->showDatePicker( ); |
1736 | break; | 1737 | break; |
1737 | case Qt::Key_F: | 1738 | case Qt::Key_F: |
1738 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1739 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1739 | mView->editFilters(); | 1740 | mView->editFilters(); |
1740 | else | 1741 | else |
1741 | mView->toggleFilter(); | 1742 | mView->toggleFilter(); |
1742 | break; | 1743 | break; |
1743 | case Qt::Key_X: | 1744 | case Qt::Key_X: |
1744 | mView->toggleDateNavigatorWidget(); | 1745 | mView->toggleDateNavigatorWidget(); |
1745 | break; | 1746 | break; |
1746 | case Qt::Key_Space: | 1747 | case Qt::Key_Space: |
1747 | mView->toggleExpand(); | 1748 | mView->toggleExpand(); |
1748 | break; | 1749 | break; |
1749 | case Qt::Key_A: | 1750 | case Qt::Key_A: |
1750 | mView->toggleAllDaySize(); | 1751 | mView->toggleAllDaySize(); |
1751 | break; | 1752 | break; |
1752 | case Qt::Key_T: | 1753 | case Qt::Key_T: |
1753 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1754 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1754 | mView->newTodo(); | 1755 | mView->newTodo(); |
1755 | else { | 1756 | else { |
1756 | mView->goToday(); | 1757 | mView->goToday(); |
1757 | showSelectedDates = true; | 1758 | showSelectedDates = true; |
1758 | } | 1759 | } |
1759 | break; | 1760 | break; |
1760 | case Qt::Key_J: | 1761 | case Qt::Key_J: |
1761 | mView->viewManager()->showJournalView(); | 1762 | mView->viewManager()->showJournalView(); |
1762 | break; | 1763 | break; |
1763 | case Qt::Key_B: | 1764 | case Qt::Key_B: |
1764 | mView->editIncidenceDescription();; | 1765 | mView->editIncidenceDescription();; |
1765 | break; | 1766 | break; |
1766 | // case Qt::Key_Return: | 1767 | // case Qt::Key_Return: |
1767 | case Qt::Key_E: | 1768 | case Qt::Key_E: |
1768 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1769 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1769 | mView->newEvent(); | 1770 | mView->newEvent(); |
1770 | else | 1771 | else |
1771 | mView->editIncidence(); | 1772 | mView->editIncidence(); |
1772 | break; | 1773 | break; |
1773 | case Qt::Key_Plus: | 1774 | case Qt::Key_Plus: |
1774 | size = p->mHourSize +2; | 1775 | size = p->mHourSize +2; |
1775 | if ( size <= 18 ) | 1776 | if ( size <= 18 ) |
1776 | configureAgenda( size ); | 1777 | configureAgenda( size ); |
1777 | break; | 1778 | break; |
1778 | case Qt::Key_Minus: | 1779 | case Qt::Key_Minus: |
1779 | size = p->mHourSize - 2; | 1780 | size = p->mHourSize - 2; |
1780 | if ( size >= 4 ) | 1781 | if ( size >= 4 ) |
1781 | configureAgenda( size ); | 1782 | configureAgenda( size ); |
1782 | break; | 1783 | break; |
1783 | 1784 | ||
1784 | 1785 | ||
1785 | default: | 1786 | default: |
1786 | e->ignore(); | 1787 | e->ignore(); |
1787 | } | 1788 | } |
1788 | if ( pro > 0 ) { | 1789 | if ( pro > 0 ) { |
1789 | mView->selectFilter( pro-1 ); | 1790 | mView->selectFilter( pro-1 ); |
1790 | } | 1791 | } |
1791 | if ( showSelectedDates ) { | 1792 | if ( showSelectedDates ) { |
1792 | ;// setCaptionToDates(); | 1793 | ;// setCaptionToDates(); |
1793 | } | 1794 | } |
1794 | 1795 | ||
1795 | } | 1796 | } |
1796 | 1797 | ||
1797 | void MainWindow::fillFilterMenu() | 1798 | void MainWindow::fillFilterMenu() |
1798 | { | 1799 | { |
1799 | selectFilterMenu->clear(); | 1800 | selectFilterMenu->clear(); |
1800 | bool disable = false; | 1801 | bool disable = false; |
1801 | if ( mView->filterView()->filtersEnabled() ) { | 1802 | if ( mView->filterView()->filtersEnabled() ) { |
1802 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1803 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1803 | } | 1804 | } |
1804 | else { | 1805 | else { |
1805 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1806 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1806 | disable = true; | 1807 | disable = true; |
1807 | } | 1808 | } |
1808 | selectFilterMenu->insertSeparator(); | 1809 | selectFilterMenu->insertSeparator(); |
1809 | QPtrList<CalFilter> fili = mView->filters(); | 1810 | QPtrList<CalFilter> fili = mView->filters(); |
1810 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1811 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1811 | CalFilter *filter = fili.first(); | 1812 | CalFilter *filter = fili.first(); |
1812 | int iii = 1; | 1813 | int iii = 1; |
1813 | while(filter) { | 1814 | while(filter) { |
1814 | selectFilterMenu->insertItem( filter->name(), iii ); | 1815 | selectFilterMenu->insertItem( filter->name(), iii ); |
1815 | if ( filter == curfilter) | 1816 | if ( filter == curfilter) |
1816 | selectFilterMenu->setItemChecked( iii, true ); | 1817 | selectFilterMenu->setItemChecked( iii, true ); |
1817 | if ( disable ) | 1818 | if ( disable ) |
1818 | selectFilterMenu->setItemEnabled( iii, false ); | 1819 | selectFilterMenu->setItemEnabled( iii, false ); |
1819 | filter = fili.next(); | 1820 | filter = fili.next(); |
1820 | ++iii; | 1821 | ++iii; |
1821 | } | 1822 | } |
1822 | } | 1823 | } |
1823 | void MainWindow::selectFilter( int fil ) | 1824 | void MainWindow::selectFilter( int fil ) |
1824 | { | 1825 | { |
1825 | if ( fil == 0 ) { | 1826 | if ( fil == 0 ) { |
1826 | mView->toggleFilerEnabled( ); | 1827 | mView->toggleFilerEnabled( ); |
1827 | } else { | 1828 | } else { |
1828 | mView->selectFilter( fil-1 ); | 1829 | mView->selectFilter( fil-1 ); |
1829 | } | 1830 | } |
1830 | } | 1831 | } |
1831 | void MainWindow::configureToolBar( int item ) | 1832 | void MainWindow::configureToolBar( int item ) |
1832 | { | 1833 | { |
1833 | 1834 | ||
1834 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1835 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1835 | KOPrefs *p = KOPrefs::instance(); | 1836 | KOPrefs *p = KOPrefs::instance(); |
1836 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1837 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1837 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1838 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1838 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1839 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1839 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1840 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1840 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1841 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1841 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1842 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1842 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1843 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1843 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1844 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1844 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1845 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1845 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1846 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1846 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1847 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1847 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1848 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1848 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1849 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1849 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1850 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1850 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1851 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1851 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1852 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1852 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1853 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1853 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1854 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1854 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1855 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1855 | // initActions(); | 1856 | // initActions(); |
1856 | } | 1857 | } |
1857 | 1858 | ||
1858 | void MainWindow::setCaptionToDates() | 1859 | void MainWindow::setCaptionToDates() |
1859 | { | 1860 | { |
1860 | QString selDates; | 1861 | QString selDates; |
1861 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1862 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1862 | if (mView->startDate() < mView->endDate() ) | 1863 | if (mView->startDate() < mView->endDate() ) |
1863 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1864 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1864 | setCaption( i18n("Dates: ") + selDates ); | 1865 | setCaption( i18n("Dates: ") + selDates ); |
1865 | 1866 | ||
1866 | } | 1867 | } |
1867 | // parameter item == 0: reinit | 1868 | // parameter item == 0: reinit |
1868 | void MainWindow::configureAgenda( int item ) | 1869 | void MainWindow::configureAgenda( int item ) |
1869 | { | 1870 | { |
1870 | 1871 | ||
1871 | KOPrefs *p = KOPrefs::instance(); | 1872 | KOPrefs *p = KOPrefs::instance(); |
1872 | 1873 | ||
1873 | int i; | 1874 | int i; |
1874 | if ( item == 1 ) { | 1875 | if ( item == 1 ) { |
1875 | mView->toggleAllDaySize(); | 1876 | mView->toggleAllDaySize(); |
1876 | return; | 1877 | return; |
1877 | } | 1878 | } |
1878 | // do not allow 4 for widgets higher than 480 | 1879 | // do not allow 4 for widgets higher than 480 |
1879 | // if ( QApplication::desktop()->height() > 480 ) { | 1880 | // if ( QApplication::desktop()->height() > 480 ) { |
1880 | // if ( item == 4 ) | 1881 | // if ( item == 4 ) |
1881 | // item = 6; | 1882 | // item = 6; |
1882 | // } | 1883 | // } |
1883 | for ( i = 4; i <= 18; i= i+2 ) | 1884 | for ( i = 4; i <= 18; i= i+2 ) |
1884 | configureAgendaMenu->setItemChecked( i, false ); | 1885 | configureAgendaMenu->setItemChecked( i, false ); |
1885 | configureAgendaMenu->setItemChecked( item, true ); | 1886 | configureAgendaMenu->setItemChecked( item, true ); |
1886 | if ( p->mHourSize == item ) | 1887 | if ( p->mHourSize == item ) |
1887 | return; | 1888 | return; |
1888 | p->mHourSize=item; | 1889 | p->mHourSize=item; |
1889 | mView->viewManager()->agendaView()->updateConfig(); | 1890 | mView->viewManager()->agendaView()->updateConfig(); |
1890 | } | 1891 | } |
1891 | 1892 | ||
1892 | void MainWindow::saveCalendar() | 1893 | void MainWindow::saveCalendar() |
1893 | { | 1894 | { |
1894 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1895 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1895 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1896 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1896 | 1897 | ||
1897 | if ( fn == "" ) | 1898 | if ( fn == "" ) |
1898 | return; | 1899 | return; |
1899 | QFileInfo info; | 1900 | QFileInfo info; |
1900 | info.setFile( fn ); | 1901 | info.setFile( fn ); |
1901 | QString mes; | 1902 | QString mes; |
1902 | bool createbup = true; | 1903 | bool createbup = true; |
1903 | if ( info. exists() ) { | 1904 | if ( info. exists() ) { |
1904 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1905 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1905 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1906 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1906 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1907 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1907 | 0, 1 ); | 1908 | 0, 1 ); |
1908 | if ( result != 0 ) { | 1909 | if ( result != 0 ) { |
1909 | createbup = false; | 1910 | createbup = false; |
1910 | } | 1911 | } |
1911 | } | 1912 | } |
1912 | if ( createbup ) { | 1913 | if ( createbup ) { |
1913 | mView->saveCalendar( fn ); | 1914 | mView->saveCalendar( fn ); |
1914 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1915 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1915 | KOPrefs::instance()->mLastSaveFile = fn; | 1916 | KOPrefs::instance()->mLastSaveFile = fn; |
1916 | setCaption(mes); | 1917 | setCaption(mes); |
1917 | } | 1918 | } |
1918 | } | 1919 | } |
1919 | void MainWindow::loadCalendar() | 1920 | void MainWindow::loadCalendar() |
1920 | { | 1921 | { |
1921 | 1922 | ||
1922 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1923 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1923 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1924 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1924 | 1925 | ||
1925 | if ( fn == "" ) | 1926 | if ( fn == "" ) |
1926 | return; | 1927 | return; |
1927 | QFileInfo info; | 1928 | QFileInfo info; |
1928 | info.setFile( fn ); | 1929 | info.setFile( fn ); |
1929 | QString mess; | 1930 | QString mess; |
1930 | bool loadbup = true; | 1931 | bool loadbup = true; |
1931 | if ( info. exists() ) { | 1932 | if ( info. exists() ) { |
1932 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1933 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1933 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1934 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1934 | mess, | 1935 | mess, |
1935 | i18n("Load!"), i18n("Cancel"), 0, | 1936 | i18n("Load!"), i18n("Cancel"), 0, |
1936 | 0, 1 ); | 1937 | 0, 1 ); |
1937 | if ( result != 0 ) { | 1938 | if ( result != 0 ) { |
1938 | loadbup = false; | 1939 | loadbup = false; |
1939 | } | 1940 | } |
1940 | } else { | 1941 | } else { |
1941 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1942 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1942 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1943 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1943 | 0, 1 ); | 1944 | 0, 1 ); |
1944 | 1945 | ||
1945 | return; | 1946 | return; |
1946 | } | 1947 | } |
1947 | if ( loadbup ) { | 1948 | if ( loadbup ) { |
1948 | mView->openCalendar( fn ); | 1949 | mView->openCalendar( fn ); |
1949 | KOPrefs::instance()->mLastLoadFile = fn; | 1950 | KOPrefs::instance()->mLastLoadFile = fn; |
1950 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1951 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1951 | setCaption(mess); | 1952 | setCaption(mess); |
1952 | } | 1953 | } |
1953 | 1954 | ||
1954 | } | 1955 | } |
1955 | void MainWindow::quickImportIcal() | 1956 | void MainWindow::quickImportIcal() |
1956 | { | 1957 | { |
1957 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1958 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1958 | } | 1959 | } |
1959 | void MainWindow::importFile( QString fn, bool quick ) | 1960 | void MainWindow::importFile( QString fn, bool quick ) |
1960 | { | 1961 | { |
1961 | QFileInfo info; | 1962 | QFileInfo info; |
1962 | info.setFile( fn ); | 1963 | info.setFile( fn ); |
1963 | QString mess; | 1964 | QString mess; |
1964 | bool loadbup = true; | 1965 | bool loadbup = true; |
1965 | if ( !info. exists() ) { | 1966 | if ( !info. exists() ) { |
1966 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1967 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1967 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1968 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1968 | mess ); | 1969 | mess ); |
1969 | return; | 1970 | return; |
1970 | } | 1971 | } |
1971 | int result = 0; | 1972 | int result = 0; |
1972 | if ( !quick ) { | 1973 | if ( !quick ) { |
1973 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1974 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1974 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1975 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1975 | mess, | 1976 | mess, |
1976 | "Import", "Cancel", 0, | 1977 | "Import", "Cancel", 0, |
1977 | 0, 1 ); | 1978 | 0, 1 ); |
1978 | } | 1979 | } |
1979 | if ( result == 0 ) { | 1980 | if ( result == 0 ) { |
1980 | if ( mView->openCalendar( fn, true )) { | 1981 | if ( mView->openCalendar( fn, true )) { |
1981 | KOPrefs::instance()->mLastImportFile = fn; | 1982 | KOPrefs::instance()->mLastImportFile = fn; |
1982 | setCaption(i18n("Imported file successfully")); | 1983 | setCaption(i18n("Imported file successfully")); |
1983 | } else { | 1984 | } else { |
1984 | setCaption(i18n("Error importing file")); | 1985 | setCaption(i18n("Error importing file")); |
1985 | } | 1986 | } |
1986 | } | 1987 | } |
1987 | } | 1988 | } |
1988 | 1989 | ||
1989 | void MainWindow::importIcal() | 1990 | void MainWindow::importIcal() |
1990 | { | 1991 | { |
1991 | 1992 | ||
1992 | QString fn =KOPrefs::instance()->mLastImportFile; | 1993 | QString fn =KOPrefs::instance()->mLastImportFile; |
1993 | 1994 | ||
1994 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1995 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1995 | if ( fn == "" ) | 1996 | if ( fn == "" ) |
1996 | return; | 1997 | return; |
1997 | importFile( fn, true ); | 1998 | importFile( fn, true ); |
1998 | 1999 | ||
1999 | } | 2000 | } |
2000 | 2001 | ||
2001 | void MainWindow::exportVCalendar() | 2002 | void MainWindow::exportVCalendar() |
2002 | { | 2003 | { |
2003 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2004 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2004 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2005 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2005 | if ( fn == "" ) | 2006 | if ( fn == "" ) |
2006 | return; | 2007 | return; |
2007 | QFileInfo info; | 2008 | QFileInfo info; |
2008 | info.setFile( fn ); | 2009 | info.setFile( fn ); |
2009 | QString mes; | 2010 | QString mes; |
2010 | bool createbup = true; | 2011 | bool createbup = true; |
2011 | if ( info. exists() ) { | 2012 | if ( info. exists() ) { |
2012 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2013 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2013 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2014 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2014 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2015 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2015 | 0, 1 ); | 2016 | 0, 1 ); |
2016 | if ( result != 0 ) { | 2017 | if ( result != 0 ) { |
2017 | createbup = false; | 2018 | createbup = false; |
2018 | } | 2019 | } |
2019 | } | 2020 | } |
2020 | if ( createbup ) { | 2021 | if ( createbup ) { |
2021 | if ( mView->exportVCalendar( fn ) ) { | 2022 | if ( mView->exportVCalendar( fn ) ) { |
2022 | KOPrefs::instance()->mLastVcalFile = fn; | 2023 | KOPrefs::instance()->mLastVcalFile = fn; |
2023 | if ( fn.length() > 20 ) | 2024 | if ( fn.length() > 20 ) |
2024 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2025 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2025 | else | 2026 | else |
2026 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2027 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2027 | setCaption(mes); | 2028 | setCaption(mes); |
2028 | } | 2029 | } |
2029 | } | 2030 | } |
2030 | 2031 | ||
2031 | } | 2032 | } |
2032 | QString MainWindow::getPassword( ) | 2033 | QString MainWindow::getPassword( ) |
2033 | { | 2034 | { |
2034 | QString retfile = ""; | 2035 | QString retfile = ""; |
2035 | QDialog dia ( this, "input-dialog", true ); | 2036 | QDialog dia ( this, "input-dialog", true ); |
2036 | QLineEdit lab ( &dia ); | 2037 | QLineEdit lab ( &dia ); |
2037 | lab.setEchoMode( QLineEdit::Password ); | 2038 | lab.setEchoMode( QLineEdit::Password ); |
2038 | QVBoxLayout lay( &dia ); | 2039 | QVBoxLayout lay( &dia ); |
2039 | lay.setMargin(7); | 2040 | lay.setMargin(7); |
2040 | lay.setSpacing(7); | 2041 | lay.setSpacing(7); |
2041 | lay.addWidget( &lab); | 2042 | lay.addWidget( &lab); |
2042 | dia.setFixedSize( 230,50 ); | 2043 | dia.setFixedSize( 230,50 ); |
2043 | dia.setCaption( i18n("Enter password") ); | 2044 | dia.setCaption( i18n("Enter password") ); |
2044 | QPushButton pb ( "OK", &dia); | 2045 | QPushButton pb ( "OK", &dia); |
2045 | lay.addWidget( &pb ); | 2046 | lay.addWidget( &pb ); |
2046 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2047 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2047 | dia.show(); | 2048 | dia.show(); |
2048 | int res = dia.exec(); | 2049 | int res = dia.exec(); |
2049 | if ( res ) | 2050 | if ( res ) |
2050 | retfile = lab.text(); | 2051 | retfile = lab.text(); |
2051 | dia.hide(); | 2052 | dia.hide(); |
2052 | qApp->processEvents(); | 2053 | qApp->processEvents(); |
2053 | return retfile; | 2054 | return retfile; |
2054 | 2055 | ||
2055 | } | 2056 | } |
2056 | 2057 | ||
2057 | void MainWindow::enableQuick() | 2058 | void MainWindow::enableQuick() |
2058 | { | 2059 | { |
2059 | QDialog dia ( this, "input-dialog", true ); | 2060 | QDialog dia ( this, "input-dialog", true ); |
2060 | QLineEdit lab ( &dia ); | 2061 | QLineEdit lab ( &dia ); |
2061 | QVBoxLayout lay( &dia ); | 2062 | QVBoxLayout lay( &dia ); |
2062 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | 2063 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); |
2063 | lay.setMargin(7); | 2064 | lay.setMargin(7); |
2064 | lay.setSpacing(7); | 2065 | lay.setSpacing(7); |
2065 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | 2066 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); |
2066 | lay.addWidget( &label); | 2067 | lay.addWidget( &label); |
2067 | lay.addWidget( &lab); | 2068 | lay.addWidget( &lab); |
2068 | 2069 | ||
2069 | QLineEdit lepw ( &dia ); | 2070 | QLineEdit lepw ( &dia ); |
2070 | lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); | 2071 | lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); |
2071 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 2072 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
2072 | lay.addWidget( &label2); | 2073 | lay.addWidget( &label2); |
2073 | lay.addWidget( &lepw); | 2074 | lay.addWidget( &lepw); |
2074 | dia.setFixedSize( 230,80 ); | 2075 | dia.setFixedSize( 230,80 ); |
2075 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 2076 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
2076 | QPushButton pb ( "OK", &dia); | 2077 | QPushButton pb ( "OK", &dia); |
2077 | lay.addWidget( &pb ); | 2078 | lay.addWidget( &pb ); |
2078 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2079 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2079 | dia.show(); | 2080 | dia.show(); |
2080 | if ( ! dia.exec() ) | 2081 | if ( ! dia.exec() ) |
2081 | return; | 2082 | return; |
2082 | dia.hide(); | 2083 | dia.hide(); |
2083 | qApp->processEvents(); | 2084 | qApp->processEvents(); |
2084 | KOPrefs::instance()->mPassiveSyncPw = lepw.text(); | 2085 | KOPrefs::instance()->mPassiveSyncPw = lepw.text(); |
2085 | KOPrefs::instance()->mPassiveSyncPort = lab.text(); | 2086 | KOPrefs::instance()->mPassiveSyncPort = lab.text(); |
2086 | bool ok; | 2087 | bool ok; |
2087 | Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); | 2088 | Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); |
2088 | if ( ! ok ) { | 2089 | if ( ! ok ) { |
2089 | KMessageBox::information( this, i18n("No valid port")); | 2090 | KMessageBox::information( this, i18n("No valid port")); |
2090 | return; | 2091 | return; |
2091 | } | 2092 | } |
2092 | //qDebug("port %d ", port); | 2093 | //qDebug("port %d ", port); |
2093 | mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); | 2094 | mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); |
2094 | mServerSocket->setFileName( defaultFileName() ); | 2095 | mServerSocket->setFileName( defaultFileName() ); |
2095 | //qDebug("connected "); | 2096 | //qDebug("connected "); |
2096 | if ( !mServerSocket->ok() ) { | 2097 | if ( !mServerSocket->ok() ) { |
2097 | KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); | 2098 | KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); |
2098 | delete mServerSocket; | 2099 | delete mServerSocket; |
2099 | mServerSocket = 0; | 2100 | mServerSocket = 0; |
2100 | return; | 2101 | return; |
2101 | } | 2102 | } |
2102 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); | 2103 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); |
2103 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); | 2104 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); |
2104 | } | 2105 | } |
2105 | 2106 | ||
2106 | void MainWindow::getFile( bool success ) | 2107 | void MainWindow::getFile( bool success ) |
2107 | { | 2108 | { |
2108 | if ( ! success ) { | 2109 | if ( ! success ) { |
2109 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2110 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2110 | return; | 2111 | return; |
2111 | } | 2112 | } |
2112 | mView->watchSavedFile(); | 2113 | mView->watchSavedFile(); |
2113 | mView->openCalendar( defaultFileName() ); | 2114 | mView->openCalendar( defaultFileName() ); |
2114 | setCaption( i18n("Pi-Sync successful!") ); | 2115 | setCaption( i18n("Pi-Sync successful!") ); |
2115 | 2116 | ||
2116 | } | 2117 | } |
2117 | 2118 | ||
2118 | 2119 | ||
2119 | void MainWindow::syncPi() | 2120 | void MainWindow::syncPi() |
2120 | { | 2121 | { |
2121 | qApp->processEvents(); | 2122 | qApp->processEvents(); |
2122 | bool ok; | 2123 | bool ok; |
2123 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 2124 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
2124 | if ( ! ok ) { | 2125 | if ( ! ok ) { |
2125 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 2126 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
2126 | return; | 2127 | return; |
2127 | } | 2128 | } |
2128 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); | 2129 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); |
2129 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 2130 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
2130 | setCaption( i18n("Sending request for remote file ...") ); | 2131 | setCaption( i18n("Sending request for remote file ...") ); |
2131 | commandSocket->readFile( syncFileName() ); | 2132 | commandSocket->readFile( syncFileName() ); |
2132 | } | 2133 | } |
2133 | 2134 | ||
2134 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) | 2135 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) |
2135 | { | 2136 | { |
2136 | qDebug("MainWindow::deleteCommandSocket %d", state); | 2137 | qDebug("MainWindow::deleteCommandSocket %d", state); |
2137 | 2138 | ||
2138 | //enum { success, errorW, errorR, quiet }; | 2139 | //enum { success, errorW, errorR, quiet }; |
2139 | if ( state == KCommandSocket::errorR ) { | 2140 | if ( state == KCommandSocket::errorR ) { |
2140 | setCaption( i18n("ERROR: Receiving remote file failed.") ); | 2141 | setCaption( i18n("ERROR: Receiving remote file failed.") ); |
2141 | delete s; | 2142 | delete s; |
2142 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | 2143 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
2143 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 2144 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
2144 | commandSocket->sendStop(); | 2145 | commandSocket->sendStop(); |
2145 | return; | 2146 | return; |
2146 | 2147 | ||
2147 | } else if ( state == KCommandSocket::errorW ) { | 2148 | } else if ( state == KCommandSocket::errorW ) { |
2148 | setCaption( i18n("ERROR:Writing back file failed.") ); | 2149 | setCaption( i18n("ERROR:Writing back file failed.") ); |
2149 | 2150 | ||
2150 | } else if ( state == KCommandSocket::successR ) { | 2151 | } else if ( state == KCommandSocket::successR ) { |
2151 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 2152 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
2152 | 2153 | ||
2153 | } else if ( state == KCommandSocket::successW ) { | 2154 | } else if ( state == KCommandSocket::successW ) { |
2154 | setCaption( i18n("Pi-Sync succesful!") ); | 2155 | setCaption( i18n("Pi-Sync succesful!") ); |
2155 | } | 2156 | } |
2156 | 2157 | ||
2157 | delete s; | 2158 | delete s; |
2158 | } | 2159 | } |
2159 | 2160 | ||
2160 | void MainWindow::readFileFromSocket() | 2161 | void MainWindow::readFileFromSocket() |
2161 | { | 2162 | { |
2162 | QString fileName = syncFileName(); | 2163 | QString fileName = syncFileName(); |
2163 | setCaption( i18n("Remote file saved to temp file.") ); | 2164 | setCaption( i18n("Remote file saved to temp file.") ); |
2164 | if ( ! syncWithFile( fileName , true ) ) { | 2165 | if ( ! syncWithFile( fileName , true ) ) { |
2165 | setCaption( i18n("Syncing failed.") ); | 2166 | setCaption( i18n("Syncing failed.") ); |
2166 | qDebug("Syncing failed "); | 2167 | qDebug("Syncing failed "); |
2167 | return; | 2168 | return; |
2168 | } | 2169 | } |
2169 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | 2170 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
2170 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 2171 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
2171 | if ( KOPrefs::instance()->mWriteBackFile ) | 2172 | if ( KOPrefs::instance()->mWriteBackFile ) |
2172 | commandSocket->writeFile( fileName ); | 2173 | commandSocket->writeFile( fileName ); |
2173 | else { | 2174 | else { |
2174 | commandSocket->sendStop(); | 2175 | commandSocket->sendStop(); |
2175 | setCaption( i18n("Pi-Sync succesful!") ); | 2176 | setCaption( i18n("Pi-Sync succesful!") ); |
2176 | } | 2177 | } |
2177 | } | 2178 | } |
2178 | 2179 | ||
2179 | void MainWindow::syncLocalFile() | 2180 | void MainWindow::syncLocalFile() |
2180 | { | 2181 | { |
2181 | 2182 | ||
2182 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2183 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2183 | 2184 | ||
2184 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2185 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2185 | if ( fn == "" ) | 2186 | if ( fn == "" ) |
2186 | return; | 2187 | return; |
2187 | //mView->setSyncDevice("local-file" ); | 2188 | //mView->setSyncDevice("local-file" ); |
2188 | if ( syncWithFile( fn, false ) ) { | 2189 | if ( syncWithFile( fn, false ) ) { |
2189 | // Event* e = mView->getLastSyncEvent(); | 2190 | // Event* e = mView->getLastSyncEvent(); |
2190 | // e->setReadOnly( false ); | 2191 | // e->setReadOnly( false ); |
2191 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2192 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2192 | // e->setReadOnly( true ); | 2193 | // e->setReadOnly( true ); |
2193 | } | 2194 | } |
2194 | 2195 | ||
2195 | } | 2196 | } |
2196 | 2197 | ||
2197 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2198 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2198 | { | 2199 | { |
2199 | bool ret = false; | 2200 | bool ret = false; |
2200 | QFileInfo info; | 2201 | QFileInfo info; |
2201 | info.setFile( fn ); | 2202 | info.setFile( fn ); |
2202 | QString mess; | 2203 | QString mess; |
2203 | bool loadbup = true; | 2204 | bool loadbup = true; |
2204 | if ( !info. exists() ) { | 2205 | if ( !info. exists() ) { |
2205 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2206 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2206 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2207 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2207 | mess ); | 2208 | mess ); |
2208 | return ret; | 2209 | return ret; |
2209 | } | 2210 | } |
2210 | int result = 0; | 2211 | int result = 0; |
2211 | if ( !quick ) { | 2212 | if ( !quick ) { |
2212 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2213 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2213 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2214 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2214 | mess, | 2215 | mess, |
2215 | i18n("Sync"), i18n("Cancel"), 0, | 2216 | i18n("Sync"), i18n("Cancel"), 0, |
2216 | 0, 1 ); | 2217 | 0, 1 ); |
2217 | if ( result ) | 2218 | if ( result ) |
2218 | return false; | 2219 | return false; |
2219 | } | 2220 | } |
2220 | if ( KOPrefs::instance()->mAskForPreferences ) | 2221 | if ( KOPrefs::instance()->mAskForPreferences ) |
2221 | mView->edit_sync_options(); | 2222 | mView->edit_sync_options(); |
2222 | if ( result == 0 ) { | 2223 | if ( result == 0 ) { |
2223 | //qDebug("Now sycing ... "); | 2224 | //qDebug("Now sycing ... "); |
2224 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | 2225 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) |
2225 | setCaption( i18n("Synchronization successful") ); | 2226 | setCaption( i18n("Synchronization successful") ); |
2226 | else | 2227 | else |
2227 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2228 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2228 | if ( ! quick ) | 2229 | if ( ! quick ) |
2229 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | 2230 | KOPrefs::instance()->mLastSyncedLocalFile = fn; |
2230 | slotModifiedChanged( true ); | 2231 | slotModifiedChanged( true ); |
2231 | } | 2232 | } |
2232 | return ret; | 2233 | return ret; |
2233 | } | 2234 | } |
2234 | void MainWindow::quickSyncLocalFile() | 2235 | void MainWindow::quickSyncLocalFile() |
2235 | { | 2236 | { |
2236 | //mView->setSyncDevice("local-file" ); | 2237 | //mView->setSyncDevice("local-file" ); |
2237 | //qDebug("quickSyncLocalFile() "); | 2238 | //qDebug("quickSyncLocalFile() "); |
2238 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2239 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2239 | // Event* e = mView->getLastSyncEvent(); | 2240 | // Event* e = mView->getLastSyncEvent(); |
2240 | // e->setReadOnly( false ); | 2241 | // e->setReadOnly( false ); |
2241 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2242 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2242 | // e->setReadOnly( true ); | 2243 | // e->setReadOnly( true ); |
2243 | 2244 | ||
2244 | } | 2245 | } |
2245 | } | 2246 | } |
2246 | 2247 | ||
2247 | void MainWindow::confSync() | 2248 | void MainWindow::confSync() |
2248 | { | 2249 | { |
2249 | mView->confSync(); | 2250 | mView->confSync(); |
2250 | fillSyncMenu(); | 2251 | fillSyncMenu(); |
2251 | } | 2252 | } |
2252 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) | 2253 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) |
2253 | { | 2254 | { |
2254 | QString question; | 2255 | QString question; |
2255 | if ( ask ) { | 2256 | if ( ask ) { |
2256 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2257 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2257 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2258 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2258 | question, | 2259 | question, |
2259 | i18n("Yes"), i18n("No"), | 2260 | i18n("Yes"), i18n("No"), |
2260 | 0, 0 ) != 0 ) | 2261 | 0, 0 ) != 0 ) |
2261 | return; | 2262 | return; |
2262 | } | 2263 | } |
2263 | QString command = prof->getPreSyncCommand(); | 2264 | QString command = prof->getPreSyncCommand(); |
2264 | int fi; | 2265 | int fi; |
2265 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2266 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2266 | QString pwd = getPassword(); | 2267 | QString pwd = getPassword(); |
2267 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2268 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2268 | 2269 | ||
2269 | } | 2270 | } |
2270 | int maxlen = 30; | 2271 | int maxlen = 30; |
2271 | if ( QApplication::desktop()->width() > 320 ) | 2272 | if ( QApplication::desktop()->width() > 320 ) |
2272 | maxlen += 25; | 2273 | maxlen += 25; |
2273 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2274 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2274 | int fileSize = 0; | 2275 | int fileSize = 0; |
2275 | int result = system ( command ); | 2276 | int result = system ( command ); |
2276 | // 0 : okay | 2277 | // 0 : okay |
2277 | // 256: no such file or dir | 2278 | // 256: no such file or dir |
2278 | // | 2279 | // |
2279 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2280 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2280 | if ( result != 0 ) { | 2281 | if ( result != 0 ) { |
2281 | int len = maxlen; | 2282 | int len = maxlen; |
2282 | while ( len < command.length() ) { | 2283 | while ( len < command.length() ) { |
2283 | command.insert( len , "\n" ); | 2284 | command.insert( len , "\n" ); |
2284 | len += maxlen +2; | 2285 | len += maxlen +2; |
2285 | } | 2286 | } |
2286 | 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) ; | 2287 | 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) ; |
2287 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2288 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2288 | question, | 2289 | question, |
2289 | i18n("Okay!")) ; | 2290 | i18n("Okay!")) ; |
2290 | setCaption ("KO/Pi"); | 2291 | setCaption ("KO/Pi"); |
2291 | return; | 2292 | return; |
2292 | } | 2293 | } |
2293 | setCaption ( i18n( "Copying succeed." ) ); | 2294 | setCaption ( i18n( "Copying succeed." ) ); |
2294 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2295 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2295 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { | 2296 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { |
2296 | // Event* e = mView->getLastSyncEvent(); | 2297 | // Event* e = mView->getLastSyncEvent(); |
2297 | // e->setReadOnly( false ); | 2298 | // e->setReadOnly( false ); |
2298 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2299 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2299 | // e->setReadOnly( true ); | 2300 | // e->setReadOnly( true ); |
2300 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2301 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2301 | command = prof->getPostSyncCommand(); | 2302 | command = prof->getPostSyncCommand(); |
2302 | int fi; | 2303 | int fi; |
2303 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2304 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2304 | QString pwd = getPassword(); | 2305 | QString pwd = getPassword(); |
2305 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2306 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2306 | 2307 | ||
2307 | } | 2308 | } |
2308 | setCaption ( i18n( "Writing back file ..." ) ); | 2309 | setCaption ( i18n( "Writing back file ..." ) ); |
2309 | result = system ( command ); | 2310 | result = system ( command ); |
2310 | qDebug("KO: Writing back file result: %d ", result); | 2311 | qDebug("KO: Writing back file result: %d ", result); |
2311 | if ( result != 0 ) { | 2312 | if ( result != 0 ) { |
2312 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2313 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2313 | return; | 2314 | return; |
2314 | } else { | 2315 | } else { |
2315 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2316 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2316 | } | 2317 | } |
2317 | } | 2318 | } |
2318 | } | 2319 | } |
2319 | return; | 2320 | return; |
2320 | } | 2321 | } |
2321 | 2322 | ||
2322 | void MainWindow::syncSharp() | 2323 | void MainWindow::syncSharp() |
2323 | { | 2324 | { |
2324 | if ( mCalendarModifiedFlag ) | 2325 | if ( mCalendarModifiedFlag ) |
2325 | save(); | 2326 | save(); |
2326 | mView->syncSharp(); | 2327 | mView->syncSharp(); |
2327 | slotModifiedChanged( true ); | 2328 | slotModifiedChanged( true ); |
2328 | 2329 | ||
2329 | } | 2330 | } |
2330 | void MainWindow::syncPhone() | 2331 | void MainWindow::syncPhone() |
2331 | { | 2332 | { |
2332 | if ( mCalendarModifiedFlag ) | 2333 | if ( mCalendarModifiedFlag ) |
2333 | save(); | 2334 | save(); |
2334 | mView->syncPhone(); | 2335 | mView->syncPhone(); |
2335 | slotModifiedChanged( true ); | 2336 | slotModifiedChanged( true ); |
2336 | 2337 | ||
2337 | } | 2338 | } |
2338 | 2339 | ||
2339 | void MainWindow::printSel( ) | 2340 | void MainWindow::printSel( ) |
2340 | { | 2341 | { |
2341 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2342 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2342 | } | 2343 | } |
2343 | 2344 | ||
2344 | void MainWindow::printCal() | 2345 | void MainWindow::printCal() |
2345 | { | 2346 | { |
2346 | mView->print();//mCp->showDialog(); | 2347 | mView->print();//mCp->showDialog(); |
2347 | } | 2348 | } |
2348 | 2349 | ||
2349 | 2350 | ||
2350 | 2351 | ||
2351 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 2352 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
2352 | { | 2353 | { |
2353 | mPassWord = pw; | 2354 | mPassWord = pw; |
2354 | mSocket = 0; | 2355 | mSocket = 0; |
2355 | mSyncActionDialog = 0; | 2356 | mSyncActionDialog = 0; |
2356 | blockRC = false; | 2357 | blockRC = false; |
2357 | }; | 2358 | }; |
2358 | 2359 | ||
2359 | void KServerSocket::newConnection ( int socket ) | 2360 | void KServerSocket::newConnection ( int socket ) |
2360 | { | 2361 | { |
2361 | // qDebug("KServerSocket:New connection %d ", socket); | 2362 | // qDebug("KServerSocket:New connection %d ", socket); |
2362 | if ( mSocket ) { | 2363 | if ( mSocket ) { |
2363 | qDebug("KServerSocket::newConnection Socket deleted! "); | 2364 | qDebug("KServerSocket::newConnection Socket deleted! "); |
2364 | delete mSocket; | 2365 | delete mSocket; |
2365 | mSocket = 0; | 2366 | mSocket = 0; |
2366 | } | 2367 | } |
2367 | mSocket = new QSocket( this ); | 2368 | mSocket = new QSocket( this ); |
2368 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 2369 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
2369 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 2370 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
2370 | mSocket->setSocket( socket ); | 2371 | mSocket->setSocket( socket ); |
2371 | } | 2372 | } |
2372 | 2373 | ||
2373 | void KServerSocket::discardClient() | 2374 | void KServerSocket::discardClient() |
2374 | { | 2375 | { |
2375 | //qDebug(" KServerSocket::discardClient()"); | 2376 | //qDebug(" KServerSocket::discardClient()"); |
2376 | if ( mSocket ) { | 2377 | if ( mSocket ) { |
2377 | delete mSocket; | 2378 | delete mSocket; |
2378 | mSocket = 0; | 2379 | mSocket = 0; |
2379 | } | 2380 | } |
2380 | //emit endConnect(); | 2381 | //emit endConnect(); |
2381 | } | 2382 | } |
2382 | void KServerSocket::readClient() | 2383 | void KServerSocket::readClient() |
2383 | { | 2384 | { |
2384 | if ( blockRC ) | 2385 | if ( blockRC ) |
2385 | return; | 2386 | return; |
2386 | if ( mSocket == 0 ) { | 2387 | if ( mSocket == 0 ) { |
2387 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 2388 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
2388 | return; | 2389 | return; |
2389 | } | 2390 | } |
2390 | qDebug("KServerSocket readClient()"); | 2391 | qDebug("KServerSocket readClient()"); |
2391 | if ( mSocket->canReadLine() ) { | 2392 | if ( mSocket->canReadLine() ) { |
2392 | QString line = mSocket->readLine(); | 2393 | QString line = mSocket->readLine(); |
2393 | qDebug("KServerSocket readline: %s ", line.latin1()); | 2394 | qDebug("KServerSocket readline: %s ", line.latin1()); |
2394 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 2395 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
2395 | if ( tokens[0] == "GET" ) { | 2396 | if ( tokens[0] == "GET" ) { |
2396 | if ( tokens[1] == mPassWord ) | 2397 | if ( tokens[1] == mPassWord ) |
2397 | //emit sendFile( mSocket ); | 2398 | //emit sendFile( mSocket ); |
2398 | send_file(); | 2399 | send_file(); |
2399 | else { | 2400 | else { |
2400 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); | 2401 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); |
2401 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 2402 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
2402 | } | 2403 | } |
2403 | } | 2404 | } |
2404 | if ( tokens[0] == "PUT" ) { | 2405 | if ( tokens[0] == "PUT" ) { |
2405 | if ( tokens[1] == mPassWord ) { | 2406 | if ( tokens[1] == mPassWord ) { |
2406 | //emit getFile( mSocket ); | 2407 | //emit getFile( mSocket ); |
2407 | blockRC = true; | 2408 | blockRC = true; |
2408 | get_file(); | 2409 | get_file(); |
2409 | } | 2410 | } |
2410 | else { | 2411 | else { |
2411 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | 2412 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); |
2412 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 2413 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
2413 | } | 2414 | } |
2414 | } | 2415 | } |
2415 | if ( tokens[0] == "STOP" ) { | 2416 | if ( tokens[0] == "STOP" ) { |
2416 | //emit endConnect(); | 2417 | //emit endConnect(); |
2417 | end_connect(); | 2418 | end_connect(); |
2418 | } | 2419 | } |
2419 | } | 2420 | } |
2420 | } | 2421 | } |
2421 | void KServerSocket::end_connect() | 2422 | void KServerSocket::end_connect() |
2422 | { | 2423 | { |
2423 | delete mSyncActionDialog; | 2424 | delete mSyncActionDialog; |
2424 | mSyncActionDialog = 0; | 2425 | mSyncActionDialog = 0; |
2425 | } | 2426 | } |
2426 | void KServerSocket::send_file() | 2427 | void KServerSocket::send_file() |
2427 | { | 2428 | { |
2428 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 2429 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
2429 | if ( mSyncActionDialog ) | 2430 | if ( mSyncActionDialog ) |
2430 | delete mSyncActionDialog; | 2431 | delete mSyncActionDialog; |
2431 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 2432 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
2432 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 2433 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
2433 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 2434 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
2434 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 2435 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
2435 | lay->addWidget( label); | 2436 | lay->addWidget( label); |
2436 | lay->setMargin(7); | 2437 | lay->setMargin(7); |
2437 | lay->setSpacing(7); | 2438 | lay->setSpacing(7); |
2438 | mSyncActionDialog->setFixedSize( 230, 120); | 2439 | mSyncActionDialog->setFixedSize( 230, 120); |
2439 | mSyncActionDialog->show(); | 2440 | mSyncActionDialog->show(); |
2440 | qDebug("KSS::saving ... "); | 2441 | qDebug("KSS::saving ... "); |
2441 | emit saveFile(); | 2442 | emit saveFile(); |
2442 | qApp->processEvents(); | 2443 | qApp->processEvents(); |
2443 | QString fileName = mFileName; | 2444 | QString fileName = mFileName; |
2444 | QFile file( fileName ); | 2445 | QFile file( fileName ); |
2445 | if (!file.open( IO_ReadOnly ) ) { | 2446 | if (!file.open( IO_ReadOnly ) ) { |
2446 | delete mSyncActionDialog; | 2447 | delete mSyncActionDialog; |
2447 | mSyncActionDialog = 0; | 2448 | mSyncActionDialog = 0; |
2448 | qDebug("KSS::error open file "); | 2449 | qDebug("KSS::error open file "); |
2449 | mSocket->close(); | 2450 | mSocket->close(); |
2450 | if ( mSocket->state() == QSocket::Idle ) | 2451 | if ( mSocket->state() == QSocket::Idle ) |
2451 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2452 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2452 | return ; | 2453 | return ; |
2453 | 2454 | ||
2454 | } | 2455 | } |
2455 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 2456 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
2456 | QTextStream ts( &file ); | 2457 | QTextStream ts( &file ); |
2457 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2458 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2458 | QTextStream os( mSocket ); | 2459 | QTextStream os( mSocket ); |
2459 | os.setCodec( QTextCodec::codecForName("utf8") ); | 2460 | os.setCodec( QTextCodec::codecForName("utf8") ); |
2460 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 2461 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
2461 | while ( ! ts.atEnd() ) { | 2462 | while ( ! ts.atEnd() ) { |
2462 | os << ts.readLine() << "\n"; | 2463 | os << ts.readLine() << "\n"; |
2463 | } | 2464 | } |
2464 | //os << ts.read(); | 2465 | //os << ts.read(); |
2465 | file.close(); | 2466 | file.close(); |
2466 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 2467 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
2467 | mSocket->close(); | 2468 | mSocket->close(); |
2468 | if ( mSocket->state() == QSocket::Idle ) | 2469 | if ( mSocket->state() == QSocket::Idle ) |
2469 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2470 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2470 | } | 2471 | } |
2471 | void KServerSocket::get_file() | 2472 | void KServerSocket::get_file() |
2472 | { | 2473 | { |
2473 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 2474 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
2474 | 2475 | ||
2475 | piTime.start(); | 2476 | piTime.start(); |
2476 | piFileString = ""; | 2477 | piFileString = ""; |
2477 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 2478 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
2478 | } | 2479 | } |
2479 | 2480 | ||
2480 | 2481 | ||
2481 | void KServerSocket::readBackFileFromSocket() | 2482 | void KServerSocket::readBackFileFromSocket() |
2482 | { | 2483 | { |
2483 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 2484 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
2484 | while ( mSocket->canReadLine () ) { | 2485 | while ( mSocket->canReadLine () ) { |
2485 | piTime.restart(); | 2486 | piTime.restart(); |
2486 | QString line = mSocket->readLine (); | 2487 | QString line = mSocket->readLine (); |
2487 | piFileString += line; | 2488 | piFileString += line; |
2488 | //qDebug("readline: %s ", line.latin1()); | 2489 | //qDebug("readline: %s ", line.latin1()); |
2489 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 2490 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
2490 | 2491 | ||
2491 | } | 2492 | } |
2492 | if ( piTime.elapsed () < 3000 ) { | 2493 | if ( piTime.elapsed () < 3000 ) { |
2493 | // wait for more | 2494 | // wait for more |
2494 | //qDebug("waitformore "); | 2495 | //qDebug("waitformore "); |
2495 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 2496 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
2496 | return; | 2497 | return; |
2497 | } | 2498 | } |
2498 | QString fileName = mFileName; | 2499 | QString fileName = mFileName; |
2499 | QFile file ( fileName ); | 2500 | QFile file ( fileName ); |
2500 | if (!file.open( IO_WriteOnly ) ) { | 2501 | if (!file.open( IO_WriteOnly ) ) { |
2501 | delete mSyncActionDialog; | 2502 | delete mSyncActionDialog; |
2502 | mSyncActionDialog = 0; | 2503 | mSyncActionDialog = 0; |
2503 | qDebug("error open cal file "); | 2504 | qDebug("error open cal file "); |
2504 | piFileString = ""; | 2505 | piFileString = ""; |
2505 | emit file_received( false ); | 2506 | emit file_received( false ); |
2506 | blockRC = false; | 2507 | blockRC = false; |
2507 | return ; | 2508 | return ; |
2508 | 2509 | ||
2509 | } | 2510 | } |
2510 | 2511 | ||
2511 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 2512 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
2512 | QTextStream ts ( &file ); | 2513 | QTextStream ts ( &file ); |
2513 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2514 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2514 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 2515 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
2515 | ts << piFileString; | 2516 | ts << piFileString; |
2516 | mSocket->close(); | 2517 | mSocket->close(); |
2517 | if ( mSocket->state() == QSocket::Idle ) | 2518 | if ( mSocket->state() == QSocket::Idle ) |
2518 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2519 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2519 | file.close(); | 2520 | file.close(); |
2520 | delete mSyncActionDialog; | 2521 | delete mSyncActionDialog; |
2521 | mSyncActionDialog = 0; | 2522 | mSyncActionDialog = 0; |
2522 | piFileString = ""; | 2523 | piFileString = ""; |
2523 | blockRC = false; | 2524 | blockRC = false; |
2524 | emit file_received( true ); | 2525 | emit file_received( true ); |
2525 | 2526 | ||
2526 | } | 2527 | } |
2527 | 2528 | ||
2528 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 2529 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
2529 | { | 2530 | { |
2530 | mPassWord = password; | 2531 | mPassWord = password; |
2531 | mSocket = 0; | 2532 | mSocket = 0; |
2532 | mPort = port; | 2533 | mPort = port; |
2533 | mHost = host; | 2534 | mHost = host; |
2534 | 2535 | ||
2535 | mRetVal = quiet; | 2536 | mRetVal = quiet; |
2536 | mTimerSocket = new QTimer ( this ); | 2537 | mTimerSocket = new QTimer ( this ); |
2537 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 2538 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
2538 | } | 2539 | } |
2539 | void KCommandSocket::readFile( QString fn ) | 2540 | void KCommandSocket::readFile( QString fn ) |
2540 | { | 2541 | { |
2541 | if ( !mSocket ) { | 2542 | if ( !mSocket ) { |
2542 | mSocket = new QSocket( this ); | 2543 | mSocket = new QSocket( this ); |
2543 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 2544 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
2544 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2545 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2545 | } | 2546 | } |
2546 | mFileString = ""; | 2547 | mFileString = ""; |
2547 | mFileName = fn; | 2548 | mFileName = fn; |
2548 | mFirst = true; | 2549 | mFirst = true; |
2549 | mSocket->connectToHost( mHost, mPort ); | 2550 | mSocket->connectToHost( mHost, mPort ); |
2550 | QTextStream os( mSocket ); | 2551 | QTextStream os( mSocket ); |
2551 | os.setEncoding( QTextStream::UnicodeUTF8 ); | 2552 | os.setEncoding( QTextStream::UnicodeUTF8 ); |
2552 | os << "GET " << mPassWord << "\r\n"; | 2553 | os << "GET " << mPassWord << "\r\n"; |
2553 | mTimerSocket->start( 10000 ); | 2554 | mTimerSocket->start( 10000 ); |
2554 | } | 2555 | } |
2555 | 2556 | ||
2556 | void KCommandSocket::writeFile( QString fileName ) | 2557 | void KCommandSocket::writeFile( QString fileName ) |
2557 | { | 2558 | { |
2558 | if ( !mSocket ) { | 2559 | if ( !mSocket ) { |
2559 | mSocket = new QSocket( this ); | 2560 | mSocket = new QSocket( this ); |
2560 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2561 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2561 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 2562 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
2562 | } | 2563 | } |
2563 | mFileName = fileName ; | 2564 | mFileName = fileName ; |
2564 | mSocket->connectToHost( mHost, mPort ); | 2565 | mSocket->connectToHost( mHost, mPort ); |
2565 | } | 2566 | } |
2566 | void KCommandSocket::writeFileToSocket() | 2567 | void KCommandSocket::writeFileToSocket() |
2567 | { | 2568 | { |
2568 | QFile file2( mFileName ); | 2569 | QFile file2( mFileName ); |
2569 | if (!file2.open( IO_ReadOnly ) ) { | 2570 | if (!file2.open( IO_ReadOnly ) ) { |
2570 | mRetVal= errorW; | 2571 | mRetVal= errorW; |
2571 | mSocket->close(); | 2572 | mSocket->close(); |
2572 | if ( mSocket->state() == QSocket::Idle ) | 2573 | if ( mSocket->state() == QSocket::Idle ) |
2573 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 2574 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
2574 | return ; | 2575 | return ; |
2575 | } | 2576 | } |
2576 | QTextStream ts2( &file2 ); | 2577 | QTextStream ts2( &file2 ); |
2577 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | 2578 | ts2.setCodec( QTextCodec::codecForName("utf8") ); |
2578 | QTextStream os2( mSocket ); | 2579 | QTextStream os2( mSocket ); |
2579 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2580 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2580 | os2 << "PUT " << mPassWord << "\r\n";; | 2581 | os2 << "PUT " << mPassWord << "\r\n";; |
2581 | while ( ! ts2.atEnd() ) { | 2582 | while ( ! ts2.atEnd() ) { |
2582 | os2 << ts2.readLine() << "\n"; | 2583 | os2 << ts2.readLine() << "\n"; |
2583 | } | 2584 | } |
2584 | mRetVal= successW; | 2585 | mRetVal= successW; |
2585 | file2.close(); | 2586 | file2.close(); |
2586 | mSocket->close(); | 2587 | mSocket->close(); |
2587 | if ( mSocket->state() == QSocket::Idle ) | 2588 | if ( mSocket->state() == QSocket::Idle ) |
2588 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 2589 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
2589 | } | 2590 | } |
2590 | void KCommandSocket::sendStop() | 2591 | void KCommandSocket::sendStop() |
2591 | { | 2592 | { |
2592 | if ( !mSocket ) { | 2593 | if ( !mSocket ) { |
2593 | mSocket = new QSocket( this ); | 2594 | mSocket = new QSocket( this ); |
2594 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2595 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2595 | } | 2596 | } |
2596 | mSocket->connectToHost( mHost, mPort ); | 2597 | mSocket->connectToHost( mHost, mPort ); |
2597 | QTextStream os2( mSocket ); | 2598 | QTextStream os2( mSocket ); |
2598 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2599 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2599 | os2 << "STOP\r\n"; | 2600 | os2 << "STOP\r\n"; |
2600 | mSocket->close(); | 2601 | mSocket->close(); |
2601 | if ( mSocket->state() == QSocket::Idle ) | 2602 | if ( mSocket->state() == QSocket::Idle ) |
2602 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 2603 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
2603 | } | 2604 | } |
2604 | 2605 | ||
2605 | void KCommandSocket::startReadFileFromSocket() | 2606 | void KCommandSocket::startReadFileFromSocket() |
2606 | { | 2607 | { |
2607 | if ( ! mFirst ) | 2608 | if ( ! mFirst ) |
2608 | return; | 2609 | return; |
2609 | mFirst = false; | 2610 | mFirst = false; |
2610 | mTimerSocket->stop(); | 2611 | mTimerSocket->stop(); |
2611 | mFileString = ""; | 2612 | mFileString = ""; |
2612 | mTime.start(); | 2613 | mTime.start(); |
2613 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 2614 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
2614 | 2615 | ||
2615 | } | 2616 | } |
2616 | void KCommandSocket::readFileFromSocket() | 2617 | void KCommandSocket::readFileFromSocket() |
2617 | { | 2618 | { |
2618 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 2619 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
2619 | while ( mSocket->canReadLine () ) { | 2620 | while ( mSocket->canReadLine () ) { |
2620 | mTime.restart(); | 2621 | mTime.restart(); |
2621 | QString line = mSocket->readLine (); | 2622 | QString line = mSocket->readLine (); |
2622 | mFileString += line; | 2623 | mFileString += line; |
2623 | //qDebug("readline: %s ", line.latin1()); | 2624 | //qDebug("readline: %s ", line.latin1()); |
2624 | } | 2625 | } |
2625 | if ( mTime.elapsed () < 3000 ) { | 2626 | if ( mTime.elapsed () < 3000 ) { |
2626 | // wait for more | 2627 | // wait for more |
2627 | //qDebug("waitformore "); | 2628 | //qDebug("waitformore "); |
2628 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 2629 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
2629 | return; | 2630 | return; |
2630 | } | 2631 | } |
2631 | QString fileName = mFileName; | 2632 | QString fileName = mFileName; |
2632 | QFile file ( fileName ); | 2633 | QFile file ( fileName ); |
2633 | if (!file.open( IO_WriteOnly ) ) { | 2634 | if (!file.open( IO_WriteOnly ) ) { |
2634 | mFileString = ""; | 2635 | mFileString = ""; |
2635 | mRetVal = errorR; | 2636 | mRetVal = errorR; |
2636 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | 2637 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
2637 | deleteSocket(); | 2638 | deleteSocket(); |
2638 | return ; | 2639 | return ; |
2639 | 2640 | ||
2640 | } | 2641 | } |
2641 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 2642 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
2642 | QTextStream ts ( &file ); | 2643 | QTextStream ts ( &file ); |
2643 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2644 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2644 | ts << mFileString; | 2645 | ts << mFileString; |
2645 | file.close(); | 2646 | file.close(); |
2646 | mFileString = ""; | 2647 | mFileString = ""; |
2647 | mRetVal = successR; | 2648 | mRetVal = successR; |
2648 | mSocket->close(); | 2649 | mSocket->close(); |
2649 | // if state is not idle, deleteSocket(); is called via | 2650 | // if state is not idle, deleteSocket(); is called via |
2650 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2651 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2651 | if ( mSocket->state() == QSocket::Idle ) | 2652 | if ( mSocket->state() == QSocket::Idle ) |
2652 | deleteSocket(); | 2653 | deleteSocket(); |
2653 | } | 2654 | } |
2654 | 2655 | ||
2655 | void KCommandSocket::deleteSocket() | 2656 | void KCommandSocket::deleteSocket() |
2656 | { | 2657 | { |
2657 | if ( mTimerSocket->isActive () ) { | 2658 | if ( mTimerSocket->isActive () ) { |
2658 | mTimerSocket->stop(); | 2659 | mTimerSocket->stop(); |
2659 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 2660 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
2660 | mRetVal = errorR; | 2661 | mRetVal = errorR; |
2661 | } | 2662 | } |
2662 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 2663 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
2663 | if ( mSocket) | 2664 | if ( mSocket) |
2664 | delete mSocket; | 2665 | delete mSocket; |
2665 | mSocket = 0; | 2666 | mSocket = 0; |
2666 | emit commandFinished( this, mRetVal ); | 2667 | emit commandFinished( this, mRetVal ); |
2667 | } | 2668 | } |
2668 | 2669 | ||
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp index b2b7663..b71e18d 100644 --- a/libkdepim/kpimglobalprefs.cpp +++ b/libkdepim/kpimglobalprefs.cpp | |||
@@ -1,133 +1,140 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@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 <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <kstaticdeleter.h> | 35 | #include <kstaticdeleter.h> |
36 | 36 | ||
37 | #include <qregexp.h> | 37 | #include <qregexp.h> |
38 | #include "kpimglobalprefs.h" | 38 | #include "kpimglobalprefs.h" |
39 | 39 | ||
40 | KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; | 40 | KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; |
41 | static KStaticDeleter<KPimGlobalPrefs> staticDeleter; | 41 | static KStaticDeleter<KPimGlobalPrefs> staticDeleter; |
42 | 42 | ||
43 | 43 | ||
44 | KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) | 44 | KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) |
45 | : KPrefs("microkdeglobalrc") | 45 | : KPrefs("microkdeglobalrc") |
46 | { | 46 | { |
47 | 47 | ||
48 | KPrefs::setCurrentGroup("Locale"); | 48 | KPrefs::setCurrentGroup("Locale"); |
49 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 49 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
50 | addItemInt("PreferredTime",&mPreferredTime,0); | 50 | addItemInt("PreferredTime",&mPreferredTime,0); |
51 | addItemInt("PreferredDate",&mPreferredDate,0); | 51 | addItemInt("PreferredDate",&mPreferredDate,0); |
52 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 52 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
53 | //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); | 53 | //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); |
54 | // addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 54 | // addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
55 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | 55 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); |
56 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 56 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
57 | 57 | ||
58 | KPrefs::setCurrentGroup("Time & Date"); | 58 | KPrefs::setCurrentGroup("Time & Date"); |
59 | 59 | ||
60 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); | 60 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); |
61 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 61 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
62 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 62 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
63 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 63 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | KPrefs::setCurrentGroup( "ExternalApplications" ); | 68 | KPrefs::setCurrentGroup( "ExternalApplications" ); |
69 | 69 | ||
70 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); | 70 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); |
71 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); | 71 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); |
72 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); | 72 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); |
73 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); | 73 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); |
74 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); | 74 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); |
75 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); | 75 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); |
76 | 76 | ||
77 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); | 77 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); |
78 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); | 78 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); |
79 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); | 79 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); |
80 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); | 80 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); |
81 | 81 | ||
82 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); | 82 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); |
83 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); | 83 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); |
84 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); | 84 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); |
85 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); | 85 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); |
86 | 86 | ||
87 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); | 87 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); |
88 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); | 88 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); |
89 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); | 89 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); |
90 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); | 90 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); |
91 | 91 | ||
92 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); | 92 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); |
93 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); | 93 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); |
94 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); | 94 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); |
95 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); | 95 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); |
96 | 96 | ||
97 | addItemInt( "SIPChannelType", &mSipClient, NONE_SIC ); | 97 | addItemInt( "SIPChannelType", &mSipClient, NONE_SIC ); |
98 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); | 98 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); |
99 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); | 99 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); |
100 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); | 100 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); |
101 | 101 | ||
102 | |||
103 | KPrefs::setCurrentGroup( "PhoneAccess" ); | ||
104 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); | ||
105 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); | ||
106 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); | ||
107 | |||
108 | |||
102 | } | 109 | } |
103 | 110 | ||
104 | void KPimGlobalPrefs::setGlobalConfig() | 111 | void KPimGlobalPrefs::setGlobalConfig() |
105 | { | 112 | { |
106 | 113 | ||
107 | KGlobal::locale()->setHore24Format( !mPreferredTime ); | 114 | KGlobal::locale()->setHore24Format( !mPreferredTime ); |
108 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); | 115 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); |
109 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); | 116 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); |
110 | KGlobal::locale()->setLanguage( mPreferredLanguage ); | 117 | KGlobal::locale()->setLanguage( mPreferredLanguage ); |
111 | QString dummy = mUserDateFormatLong; | 118 | QString dummy = mUserDateFormatLong; |
112 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 119 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
113 | dummy = mUserDateFormatShort; | 120 | dummy = mUserDateFormatShort; |
114 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 121 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
115 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, | 122 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, |
116 | mDaylightsavingStart, | 123 | mDaylightsavingStart, |
117 | mDaylightsavingEnd ); | 124 | mDaylightsavingEnd ); |
118 | KGlobal::locale()->setTimezone( mTimeZoneId ); | 125 | KGlobal::locale()->setTimezone( mTimeZoneId ); |
119 | 126 | ||
120 | } | 127 | } |
121 | KPimGlobalPrefs::~KPimGlobalPrefs() | 128 | KPimGlobalPrefs::~KPimGlobalPrefs() |
122 | { | 129 | { |
123 | } | 130 | } |
124 | 131 | ||
125 | KPimGlobalPrefs *KPimGlobalPrefs::instance() | 132 | KPimGlobalPrefs *KPimGlobalPrefs::instance() |
126 | { | 133 | { |
127 | if ( !sInstance ) { | 134 | if ( !sInstance ) { |
128 | sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); | 135 | sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); |
129 | sInstance->readConfig(); | 136 | sInstance->readConfig(); |
130 | } | 137 | } |
131 | 138 | ||
132 | return sInstance; | 139 | return sInstance; |
133 | } | 140 | } |
diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h index 84ba689..f6b6628 100644 --- a/libkdepim/kpimglobalprefs.h +++ b/libkdepim/kpimglobalprefs.h | |||
@@ -1,135 +1,138 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
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 | #ifndef KPIMGLOBALPREFS_H | 31 | #ifndef KPIMGLOBALPREFS_H |
32 | #define KPIMGLOBALPREFS_H | 32 | #define KPIMGLOBALPREFS_H |
33 | 33 | ||
34 | #include "kprefs.h" | 34 | #include "kprefs.h" |
35 | 35 | ||
36 | class KPimGlobalPrefs : public KPrefs | 36 | class KPimGlobalPrefs : public KPrefs |
37 | { | 37 | { |
38 | public: | 38 | public: |
39 | 39 | ||
40 | void setGlobalConfig(); | 40 | void setGlobalConfig(); |
41 | static KPimGlobalPrefs *instance(); | 41 | static KPimGlobalPrefs *instance(); |
42 | 42 | ||
43 | 43 | ||
44 | virtual ~KPimGlobalPrefs(); | 44 | virtual ~KPimGlobalPrefs(); |
45 | 45 | ||
46 | 46 | ||
47 | enum EMailClients { | 47 | enum EMailClients { |
48 | NONE_EMC = 0, | 48 | NONE_EMC = 0, |
49 | OTHER_EMC = 1, | 49 | OTHER_EMC = 1, |
50 | OMPI_EMC = 2, | 50 | OMPI_EMC = 2, |
51 | QTOPIA_EMC = 3, | 51 | QTOPIA_EMC = 3, |
52 | OPIE_EMC = 4 | 52 | OPIE_EMC = 4 |
53 | }; | 53 | }; |
54 | 54 | ||
55 | enum PhoneClients { | 55 | enum PhoneClients { |
56 | NONE_PHC = 0, | 56 | NONE_PHC = 0, |
57 | OTHER_PHC = 1, | 57 | OTHER_PHC = 1, |
58 | KPPI_PHC = 2 | 58 | KPPI_PHC = 2 |
59 | }; | 59 | }; |
60 | 60 | ||
61 | enum FaxClients { | 61 | enum FaxClients { |
62 | NONE_FAC = 0, | 62 | NONE_FAC = 0, |
63 | OTHER_FAC = 1 | 63 | OTHER_FAC = 1 |
64 | }; | 64 | }; |
65 | 65 | ||
66 | enum SMSClients { | 66 | enum SMSClients { |
67 | NONE_SMC = 0, | 67 | NONE_SMC = 0, |
68 | OTHER_SMC = 1 | 68 | OTHER_SMC = 1 |
69 | }; | 69 | }; |
70 | 70 | ||
71 | enum PagerClients { | 71 | enum PagerClients { |
72 | NONE_PAC = 0, | 72 | NONE_PAC = 0, |
73 | OTHER_PAC = 1 | 73 | OTHER_PAC = 1 |
74 | }; | 74 | }; |
75 | 75 | ||
76 | enum SIPClients { | 76 | enum SIPClients { |
77 | NONE_SIC = 0, | 77 | NONE_SIC = 0, |
78 | OTHER_SIC = 1 | 78 | OTHER_SIC = 1 |
79 | }; | 79 | }; |
80 | 80 | ||
81 | private: | 81 | private: |
82 | KPimGlobalPrefs( const QString &name = QString::null ); | 82 | KPimGlobalPrefs( const QString &name = QString::null ); |
83 | 83 | ||
84 | static KPimGlobalPrefs *sInstance; | 84 | static KPimGlobalPrefs *sInstance; |
85 | 85 | ||
86 | 86 | ||
87 | public: | 87 | public: |
88 | //US I copied the following "locale" settings from KOPrefs | 88 | //US I copied the following "locale" settings from KOPrefs |
89 | int mPreferredDate; | 89 | int mPreferredDate; |
90 | QString mUserDateFormatLong; | 90 | QString mUserDateFormatLong; |
91 | QString mUserDateFormatShort; | 91 | QString mUserDateFormatShort; |
92 | int mPreferredLanguage; | 92 | int mPreferredLanguage; |
93 | int mPreferredTime; | 93 | int mPreferredTime; |
94 | bool mWeekStartsOnSunday; | 94 | bool mWeekStartsOnSunday; |
95 | QString mTimeZoneId; | 95 | QString mTimeZoneId; |
96 | bool mUseDaylightsaving; | 96 | bool mUseDaylightsaving; |
97 | int mDaylightsavingStart; | 97 | int mDaylightsavingStart; |
98 | int mDaylightsavingEnd; | 98 | int mDaylightsavingEnd; |
99 | 99 | ||
100 | int mEmailClient; | 100 | int mEmailClient; |
101 | QString mEmailOtherChannel; | 101 | QString mEmailOtherChannel; |
102 | QString mEmailOtherMessage; | 102 | QString mEmailOtherMessage; |
103 | QString mEmailOtherMessageParameters; | 103 | QString mEmailOtherMessageParameters; |
104 | QString mEmailOtherMessage2; | 104 | QString mEmailOtherMessage2; |
105 | QString mEmailOtherMessageParameters2; | 105 | QString mEmailOtherMessageParameters2; |
106 | 106 | ||
107 | int mPhoneClient; | 107 | int mPhoneClient; |
108 | QString mPhoneOtherChannel; | 108 | QString mPhoneOtherChannel; |
109 | QString mPhoneOtherMessage; | 109 | QString mPhoneOtherMessage; |
110 | QString mPhoneOtherMessageParameters; | 110 | QString mPhoneOtherMessageParameters; |
111 | 111 | ||
112 | int mFaxClient; | 112 | int mFaxClient; |
113 | QString mFaxOtherChannel; | 113 | QString mFaxOtherChannel; |
114 | QString mFaxOtherMessage; | 114 | QString mFaxOtherMessage; |
115 | QString mFaxOtherMessageParameters; | 115 | QString mFaxOtherMessageParameters; |
116 | 116 | ||
117 | int mSMSClient; | 117 | int mSMSClient; |
118 | QString mSMSOtherChannel; | 118 | QString mSMSOtherChannel; |
119 | QString mSMSOtherMessage; | 119 | QString mSMSOtherMessage; |
120 | QString mSMSOtherMessageParameters; | 120 | QString mSMSOtherMessageParameters; |
121 | 121 | ||
122 | int mPagerClient; | 122 | int mPagerClient; |
123 | QString mPagerOtherChannel; | 123 | QString mPagerOtherChannel; |
124 | QString mPagerOtherMessage; | 124 | QString mPagerOtherMessage; |
125 | QString mPagerOtherMessageParameters; | 125 | QString mPagerOtherMessageParameters; |
126 | 126 | ||
127 | int mSipClient; | 127 | int mSipClient; |
128 | QString mSipOtherChannel; | 128 | QString mSipOtherChannel; |
129 | QString mSipOtherMessage; | 129 | QString mSipOtherMessage; |
130 | QString mSipOtherMessageParameters; | 130 | QString mSipOtherMessageParameters; |
131 | 131 | ||
132 | QString mEx2PhoneDevice; | ||
133 | QString mEx2PhoneConnection; | ||
134 | QString mEx2PhoneModel; | ||
132 | 135 | ||
133 | }; | 136 | }; |
134 | 137 | ||
135 | #endif | 138 | #endif |
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro index eac19ea..84af7ad 100644 --- a/libkdepim/libkdepim.pro +++ b/libkdepim/libkdepim.pro | |||
@@ -1,59 +1,61 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG = qt warn_on | 2 | CONFIG = qt warn_on |
3 | DEFINES +=KORG_NOKABC | 3 | DEFINES +=KORG_NOKABC |
4 | TARGET = microkdepim | 4 | TARGET = microkdepim |
5 | INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. | 5 | INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. |
6 | DESTDIR=../bin | 6 | DESTDIR=../bin |
7 | 7 | ||
8 | DEFINES += DESKTOP_VERSION | 8 | DEFINES += DESKTOP_VERSION |
9 | include( ../variables.pri ) | 9 | include( ../variables.pri ) |
10 | unix : { | 10 | unix : { |
11 | OBJECTS_DIR = obj/unix | 11 | OBJECTS_DIR = obj/unix |
12 | MOC_DIR = moc/unix | 12 | MOC_DIR = moc/unix |
13 | } | 13 | } |
14 | win32: { | 14 | win32: { |
15 | DEFINES += _WIN32_ | 15 | DEFINES += _WIN32_ |
16 | OBJECTS_DIR = obj/win | 16 | OBJECTS_DIR = obj/win |
17 | MOC_DIR = moc/win | 17 | MOC_DIR = moc/win |
18 | } | 18 | } |
19 | INTERFACES = \ | 19 | INTERFACES = \ |
20 | 20 | ||
21 | HEADERS = \ | 21 | HEADERS = \ |
22 | categoryeditdialog.h \ | 22 | categoryeditdialog.h \ |
23 | categoryeditdialog_base.h \ | 23 | categoryeditdialog_base.h \ |
24 | categoryselectdialog.h \ | 24 | categoryselectdialog.h \ |
25 | categoryselectdialog_base.h \ | 25 | categoryselectdialog_base.h \ |
26 | externalapphandler.h \ | 26 | externalapphandler.h \ |
27 | kdateedit.h \ | 27 | kdateedit.h \ |
28 | kdatepicker.h \ | 28 | kdatepicker.h \ |
29 | kinputdialog.h \ | 29 | kinputdialog.h \ |
30 | kpimprefs.h \ | 30 | kpimprefs.h \ |
31 | kpimglobalprefs.h \ | 31 | kpimglobalprefs.h \ |
32 | kprefsdialog.h \ | 32 | kprefsdialog.h \ |
33 | kprefswidget.h \ | 33 | kprefswidget.h \ |
34 | ksyncmanager.h \ | 34 | ksyncmanager.h \ |
35 | ksyncprofile.h \ | 35 | ksyncprofile.h \ |
36 | ksyncprefsdialog.h \ | 36 | ksyncprefsdialog.h \ |
37 | kcmconfigs/kcmkdepimconfig.h \ | 37 | kcmconfigs/kcmkdepimconfig.h \ |
38 | kcmconfigs/kdepimconfigwidget.h | 38 | kcmconfigs/kdepimconfigwidget.h \ |
39 | phoneaccess.h | ||
39 | 40 | ||
40 | SOURCES = \ | 41 | SOURCES = \ |
41 | categoryeditdialog.cpp \ | 42 | categoryeditdialog.cpp \ |
42 | categoryeditdialog_base.cpp \ | 43 | categoryeditdialog_base.cpp \ |
43 | categoryselectdialog.cpp \ | 44 | categoryselectdialog.cpp \ |
44 | categoryselectdialog_base.cpp \ | 45 | categoryselectdialog_base.cpp \ |
45 | externalapphandler.cpp \ | 46 | externalapphandler.cpp \ |
46 | kdateedit.cpp \ | 47 | kdateedit.cpp \ |
47 | kdatepicker.cpp \ | 48 | kdatepicker.cpp \ |
48 | kinputdialog.cpp \ | 49 | kinputdialog.cpp \ |
49 | kpimprefs.cpp \ | 50 | kpimprefs.cpp \ |
50 | kpimglobalprefs.cpp \ | 51 | kpimglobalprefs.cpp \ |
51 | kprefsdialog.cpp \ | 52 | kprefsdialog.cpp \ |
52 | kprefswidget.cpp \ | 53 | kprefswidget.cpp \ |
53 | ksyncmanager.cpp \ | 54 | ksyncmanager.cpp \ |
54 | ksyncprofile.cpp \ | 55 | ksyncprofile.cpp \ |
55 | ksyncprefsdialog.cpp \ | 56 | ksyncprefsdialog.cpp \ |
56 | kcmconfigs/kcmkdepimconfig.cpp \ | 57 | kcmconfigs/kcmkdepimconfig.cpp \ |
57 | kcmconfigs/kdepimconfigwidget.cpp | 58 | kcmconfigs/kdepimconfigwidget.cpp \ |
59 | phoneaccess.cpp | ||
58 | 60 | ||
59 | 61 | ||
diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro index 156e247..f3db68e 100644 --- a/libkdepim/libkdepimE.pro +++ b/libkdepim/libkdepimE.pro | |||
@@ -1,55 +1,57 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = microkdepim | 3 | TARGET = microkdepim |
4 | INCLUDEPATH += . $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(QPEDIR)/include | 4 | INCLUDEPATH += . $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(QPEDIR)/include |
5 | LIBS += -lmicrokde | 5 | LIBS += -lmicrokde |
6 | #LIBS += -lmicrokcal | 6 | #LIBS += -lmicrokcal |
7 | LIBS += -L$(QPEDIR)/lib | 7 | LIBS += -L$(QPEDIR)/lib |
8 | OBJECTS_DIR = obj/$(PLATFORM) | 8 | OBJECTS_DIR = obj/$(PLATFORM) |
9 | MOC_DIR = moc/$(PLATFORM) | 9 | MOC_DIR = moc/$(PLATFORM) |
10 | DESTDIR=$(QPEDIR)/lib | 10 | DESTDIR=$(QPEDIR)/lib |
11 | 11 | ||
12 | 12 | ||
13 | INTERFACES = \ | 13 | INTERFACES = \ |
14 | 14 | ||
15 | HEADERS = \ | 15 | HEADERS = \ |
16 | categoryeditdialog.h \ | 16 | categoryeditdialog.h \ |
17 | categoryeditdialog_base.h \ | 17 | categoryeditdialog_base.h \ |
18 | categoryselectdialog.h \ | 18 | categoryselectdialog.h \ |
19 | categoryselectdialog_base.h \ | 19 | categoryselectdialog_base.h \ |
20 | externalapphandler.h \ | 20 | externalapphandler.h \ |
21 | kdateedit.h \ | 21 | kdateedit.h \ |
22 | kdatepicker.h \ | 22 | kdatepicker.h \ |
23 | kinputdialog.h \ | 23 | kinputdialog.h \ |
24 | kpimprefs.h \ | 24 | kpimprefs.h \ |
25 | kpimglobalprefs.h \ | 25 | kpimglobalprefs.h \ |
26 | kprefsdialog.h \ | 26 | kprefsdialog.h \ |
27 | kprefswidget.h \ | 27 | kprefswidget.h \ |
28 | ksyncmanager.h \ | 28 | ksyncmanager.h \ |
29 | ksyncprofile.h \ | 29 | ksyncprofile.h \ |
30 | ksyncprefsdialog.h \ | 30 | ksyncprefsdialog.h \ |
31 | kcmconfigs/kcmkdepimconfig.h \ | 31 | kcmconfigs/kcmkdepimconfig.h \ |
32 | kcmconfigs/kdepimconfigwidget.h | 32 | kcmconfigs/kdepimconfigwidget.h \ |
33 | phoneaccess.h | ||
33 | 34 | ||
34 | 35 | ||
35 | 36 | ||
36 | SOURCES = \ | 37 | SOURCES = \ |
37 | categoryeditdialog.cpp \ | 38 | categoryeditdialog.cpp \ |
38 | categoryeditdialog_base.cpp \ | 39 | categoryeditdialog_base.cpp \ |
39 | categoryselectdialog.cpp \ | 40 | categoryselectdialog.cpp \ |
40 | categoryselectdialog_base.cpp \ | 41 | categoryselectdialog_base.cpp \ |
41 | externalapphandler.cpp \ | 42 | externalapphandler.cpp \ |
42 | kdateedit.cpp \ | 43 | kdateedit.cpp \ |
43 | kinputdialog.cpp \ | 44 | kinputdialog.cpp \ |
44 | kdatepicker.cpp \ | 45 | kdatepicker.cpp \ |
45 | kpimprefs.cpp \ | 46 | kpimprefs.cpp \ |
46 | kpimglobalprefs.cpp \ | 47 | kpimglobalprefs.cpp \ |
47 | kprefsdialog.cpp \ | 48 | kprefsdialog.cpp \ |
48 | kprefswidget.cpp \ | 49 | kprefswidget.cpp \ |
49 | ksyncmanager.cpp \ | 50 | ksyncmanager.cpp \ |
50 | ksyncprofile.cpp \ | 51 | ksyncprofile.cpp \ |
51 | ksyncprefsdialog.cpp \ | 52 | ksyncprefsdialog.cpp \ |
52 | kcmconfigs/kcmkdepimconfig.cpp \ | 53 | kcmconfigs/kcmkdepimconfig.cpp \ |
53 | kcmconfigs/kdepimconfigwidget.cpp | 54 | kcmconfigs/kdepimconfigwidget.cpp \ |
55 | phoneaccess.cpp | ||
54 | 56 | ||
55 | 57 | ||
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp new file mode 100644 index 0000000..c0bd6cc --- a/dev/null +++ b/libkdepim/phoneaccess.cpp | |||
@@ -0,0 +1,153 @@ | |||
1 | /* | ||
2 | This file is part of libkdepim. | ||
3 | |||
4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | ||
5 | |||
6 | This library is free software; you can redistribute it and/or | ||
7 | modify it under the terms of the GNU Library General Public | ||
8 | License as published by the Free Software Foundation; either | ||
9 | version 2 of the License, or (at your option) any later version. | ||
10 | |||
11 | This library is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | Library General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU Library General Public License | ||
17 | along with this library; see the file COPYING.LIB. If not, write to | ||
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
19 | Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | |||
23 | #include <qstring.h> | ||
24 | #include <qapplication.h> | ||
25 | #include <qptrlist.h> | ||
26 | #include <qregexp.h> | ||
27 | #include <qfile.h> | ||
28 | #include <qtextstream.h> | ||
29 | #include <qtextcodec.h> | ||
30 | #include <qdir.h> | ||
31 | #include <kmessagebox.h> | ||
32 | #include <stdlib.h> | ||
33 | #include "phoneaccess.h" | ||
34 | |||
35 | void PhoneAccess::writeConfig( QString device, QString connection, QString model ) | ||
36 | { | ||
37 | #ifdef _WIN32_ | ||
38 | QString fileName = qApp->applicationDirPath () +"\\gammurc"; | ||
39 | #else | ||
40 | QString fileName = QDir::homeDirPath() +"/.gammurc"; | ||
41 | #endif | ||
42 | //qDebug("save %d ", load ); | ||
43 | QString content; | ||
44 | bool write = false; | ||
45 | bool addPort = true, addConnection = true, addModel = true; | ||
46 | QFile file( fileName ); | ||
47 | if ( QFile::exists( fileName) ) { | ||
48 | if (!file.open( IO_ReadOnly ) ) { | ||
49 | qDebug("Error: cannot open %s ", fileName.latin1() ); | ||
50 | return; | ||
51 | } | ||
52 | QString line; | ||
53 | while ( file.readLine( line, 1024 ) > 0 ) { | ||
54 | //qDebug("*%s* ", line.latin1() ); | ||
55 | if ( line.left(7 ) == "[gammu]" ) { | ||
56 | ; | ||
57 | } else | ||
58 | if ( line.left(4 ) == "port" ) { | ||
59 | if ( line == "port = " + device+"\n" ) { | ||
60 | content += line ; | ||
61 | addPort = false; | ||
62 | //qDebug("port found" ); | ||
63 | } | ||
64 | |||
65 | } else if ( line.left(5 ) == "model" ) { | ||
66 | if ( line == "model = " + model +"\n") { | ||
67 | content += line ; | ||
68 | addModel = false; | ||
69 | //qDebug("model found" ); | ||
70 | } | ||
71 | |||
72 | } else if ( line.left( 10 ) == "connection" ) { | ||
73 | if ( line == "connection = " + connection +"\n") { | ||
74 | addConnection = false; | ||
75 | content += line ; | ||
76 | //qDebug("con found" ); | ||
77 | } | ||
78 | |||
79 | } else { | ||
80 | content += line ; | ||
81 | } | ||
82 | } | ||
83 | file.close(); | ||
84 | } else { | ||
85 | if ( ! connection.isEmpty() ) { | ||
86 | addConnection = true; | ||
87 | } | ||
88 | if ( ! device.isEmpty() ) { | ||
89 | addPort = true; | ||
90 | |||
91 | } | ||
92 | if ( ! model.isEmpty() ) { | ||
93 | addModel = true; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | if ( addConnection ) { | ||
98 | if ( ! write ) | ||
99 | content += "[gammu]\n"; | ||
100 | write = true; | ||
101 | content += "connection = "; | ||
102 | content += connection; | ||
103 | content += "\n"; | ||
104 | } | ||
105 | if ( addPort ) { | ||
106 | if ( ! write ) | ||
107 | content += "[gammu]\n"; | ||
108 | write = true; | ||
109 | content += "port = "; | ||
110 | content += device; | ||
111 | content += "\n"; | ||
112 | |||
113 | } | ||
114 | if ( addModel ) { | ||
115 | if ( ! write ) | ||
116 | content += "[gammu]\n"; | ||
117 | write = true; | ||
118 | content += "model = "; | ||
119 | content += model; | ||
120 | content += "\n"; | ||
121 | } | ||
122 | if ( write ) { | ||
123 | if (!file.open( IO_WriteOnly ) ) { | ||
124 | qDebug("Error: cannot write file %s ", fileName.latin1() ); | ||
125 | return; | ||
126 | } | ||
127 | qDebug("Writing file %s ", fileName.latin1() ); | ||
128 | QTextStream ts( &file ); | ||
129 | ts << content ; | ||
130 | file.close(); | ||
131 | } | ||
132 | |||
133 | } | ||
134 | |||
135 | |||
136 | bool PhoneAccess::writeToPhone( QString fileName) | ||
137 | { | ||
138 | |||
139 | #ifdef DESKTOP_VERSION | ||
140 | QString command ="./kammu --restore " + fileName ; | ||
141 | #else | ||
142 | QString command ="kammu --restore " + fileName ; | ||
143 | #endif | ||
144 | int ret; | ||
145 | while ( (ret = system ( command.latin1())) != 0 ) { | ||
146 | qDebug("Error S::command returned %d. asking users", ret); | ||
147 | int retval = KMessageBox::warningContinueCancel(0, | ||
148 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel")); | ||
149 | if ( retval != KMessageBox::Continue ) | ||
150 | return false; | ||
151 | } | ||
152 | return true; | ||
153 | } | ||
diff --git a/libkdepim/phoneaccess.h b/libkdepim/phoneaccess.h new file mode 100644 index 0000000..b7c4732 --- a/dev/null +++ b/libkdepim/phoneaccess.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | This file is part of libkcal. | ||
3 | |||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | ||
5 | |||
6 | This library is free software; you can redistribute it and/or | ||
7 | modify it under the terms of the GNU Library General Public | ||
8 | License as published by the Free Software Foundation; either | ||
9 | version 2 of the License, or (at your option) any later version. | ||
10 | |||
11 | This library is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | Library General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU Library General Public License | ||
17 | along with this library; see the file COPYING.LIB. If not, write to | ||
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
19 | Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | #ifndef PHONEACCESS_H | ||
22 | #define PHONEACCESS_H | ||
23 | |||
24 | #include <qstring.h> | ||
25 | |||
26 | |||
27 | |||
28 | /** | ||
29 | This class implements the calendar format used by Phone. | ||
30 | */ | ||
31 | |||
32 | class PhoneAccess : public QObject { | ||
33 | public: | ||
34 | |||
35 | static void writeConfig( QString device,QString connection, QString model ); | ||
36 | static bool writeToPhone( QString fileName ); | ||
37 | |||
38 | }; | ||
39 | |||
40 | |||
41 | |||
42 | #endif | ||