-rw-r--r-- | kaddressbook/kabcore.cpp | 34 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 11 |
2 files changed, 16 insertions, 29 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index fa9f130..9c40142 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2726 +1,2706 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | Async a special exception, permission is given to link this program | 19 | Async a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /*s | 24 | /*s |
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> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | #include "xxportselectdialog.h" | 118 | #include "xxportselectdialog.h" |
119 | 119 | ||
120 | 120 | ||
121 | #include <kresources/selectdialog.h> | 121 | #include <kresources/selectdialog.h> |
122 | #include <kmessagebox.h> | 122 | #include <kmessagebox.h> |
123 | 123 | ||
124 | #include <picture.h> | 124 | #include <picture.h> |
125 | #include <resource.h> | 125 | #include <resource.h> |
126 | 126 | ||
127 | //US#include <qsplitter.h> | 127 | //US#include <qsplitter.h> |
128 | #include <qmap.h> | 128 | #include <qmap.h> |
129 | #include <qdir.h> | 129 | #include <qdir.h> |
130 | #include <qfile.h> | 130 | #include <qfile.h> |
131 | #include <qvbox.h> | 131 | #include <qvbox.h> |
132 | #include <qlayout.h> | 132 | #include <qlayout.h> |
133 | #include <qclipboard.h> | 133 | #include <qclipboard.h> |
134 | #include <qtextstream.h> | 134 | #include <qtextstream.h> |
135 | #include <qradiobutton.h> | 135 | #include <qradiobutton.h> |
136 | #include <qbuttongroup.h> | 136 | #include <qbuttongroup.h> |
137 | 137 | ||
138 | #include <libkdepim/categoryselectdialog.h> | 138 | #include <libkdepim/categoryselectdialog.h> |
139 | #include <libkdepim/categoryeditdialog.h> | 139 | #include <libkdepim/categoryeditdialog.h> |
140 | #include <kabc/vcardconverter.h> | 140 | #include <kabc/vcardconverter.h> |
141 | 141 | ||
142 | 142 | ||
143 | #include "addresseeutil.h" | 143 | #include "addresseeutil.h" |
144 | #include "undocmds.h" | 144 | #include "undocmds.h" |
145 | #include "addresseeeditordialog.h" | 145 | #include "addresseeeditordialog.h" |
146 | #include "viewmanager.h" | 146 | #include "viewmanager.h" |
147 | #include "details/detailsviewcontainer.h" | 147 | #include "details/detailsviewcontainer.h" |
148 | #include "kabprefs.h" | 148 | #include "kabprefs.h" |
149 | #include "xxportmanager.h" | 149 | #include "xxportmanager.h" |
150 | #include "incsearchwidget.h" | 150 | #include "incsearchwidget.h" |
151 | #include "jumpbuttonbar.h" | 151 | #include "jumpbuttonbar.h" |
152 | #include "extensionmanager.h" | 152 | #include "extensionmanager.h" |
153 | #include "addresseeconfig.h" | 153 | #include "addresseeconfig.h" |
154 | #include "nameeditdialog.h" | 154 | #include "nameeditdialog.h" |
155 | #include <kcmultidialog.h> | 155 | #include <kcmultidialog.h> |
156 | 156 | ||
157 | #ifdef _WIN32_ | 157 | #ifdef _WIN32_ |
158 | #ifdef _OL_IMPORT_ | 158 | #ifdef _OL_IMPORT_ |
159 | #include "kaimportoldialog.h" | 159 | #include "kaimportoldialog.h" |
160 | #endif | 160 | #endif |
161 | #else | 161 | #else |
162 | #include <unistd.h> | 162 | #include <unistd.h> |
163 | #endif | 163 | #endif |
164 | // sync includes | 164 | // sync includes |
165 | #include <libkdepim/ksyncprofile.h> | 165 | #include <libkdepim/ksyncprofile.h> |
166 | #include <libkdepim/ksyncprefsdialog.h> | 166 | #include <libkdepim/ksyncprefsdialog.h> |
167 | 167 | ||
168 | 168 | ||
169 | class KABCatPrefs : public QDialog | 169 | class KABCatPrefs : public QDialog |
170 | { | 170 | { |
171 | public: | 171 | public: |
172 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : | 172 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : |
173 | QDialog( parent, name, true ) | 173 | QDialog( parent, name, true ) |
174 | { | 174 | { |
175 | setCaption( i18n("Manage new Categories") ); | 175 | setCaption( i18n("Manage new Categories") ); |
176 | QVBoxLayout* lay = new QVBoxLayout( this ); | 176 | QVBoxLayout* lay = new QVBoxLayout( this ); |
177 | lay->setSpacing( 3 ); | 177 | lay->setSpacing( 3 ); |
178 | lay->setMargin( 3 ); | 178 | lay->setMargin( 3 ); |
179 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 179 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
180 | lay->addWidget( lab ); | 180 | lay->addWidget( lab ); |
181 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 181 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
182 | lay->addWidget( format ); | 182 | lay->addWidget( format ); |
183 | format->setExclusive ( true ) ; | 183 | format->setExclusive ( true ) ; |
184 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 184 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
185 | new QRadioButton(i18n("Remove from addressees"), format ); | 185 | new QRadioButton(i18n("Remove from addressees"), format ); |
186 | addCatBut->setChecked( true ); | 186 | addCatBut->setChecked( true ); |
187 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 187 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
188 | lay->addWidget( ok ); | 188 | lay->addWidget( ok ); |
189 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 189 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
190 | lay->addWidget( cancel ); | 190 | lay->addWidget( cancel ); |
191 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 191 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
192 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 192 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
193 | resize( 200, 200 ); | 193 | resize( 200, 200 ); |
194 | } | 194 | } |
195 | 195 | ||
196 | bool addCat() { return addCatBut->isChecked(); } | 196 | bool addCat() { return addCatBut->isChecked(); } |
197 | private: | 197 | private: |
198 | QRadioButton* addCatBut; | 198 | QRadioButton* addCatBut; |
199 | }; | 199 | }; |
200 | 200 | ||
201 | class KABFormatPrefs : public QDialog | 201 | class KABFormatPrefs : public QDialog |
202 | { | 202 | { |
203 | public: | 203 | public: |
204 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : | 204 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : |
205 | QDialog( parent, name, true ) | 205 | QDialog( parent, name, true ) |
206 | { | 206 | { |
207 | setCaption( i18n("Set formatted name") ); | 207 | setCaption( i18n("Set formatted name") ); |
208 | QVBoxLayout* lay = new QVBoxLayout( this ); | 208 | QVBoxLayout* lay = new QVBoxLayout( this ); |
209 | lay->setSpacing( 3 ); | 209 | lay->setSpacing( 3 ); |
210 | lay->setMargin( 3 ); | 210 | lay->setMargin( 3 ); |
211 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); | 211 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); |
212 | lay->addWidget( lab ); | 212 | lay->addWidget( lab ); |
213 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); | 213 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); |
214 | lay->addWidget( format ); | 214 | lay->addWidget( format ); |
215 | format->setExclusive ( true ) ; | 215 | format->setExclusive ( true ) ; |
216 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); | 216 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); |
217 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); | 217 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); |
218 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); | 218 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); |
219 | company = new QRadioButton(i18n("Organization: MI6"), format ); | 219 | company = new QRadioButton(i18n("Organization: MI6"), format ); |
220 | simple->setChecked( true ); | 220 | simple->setChecked( true ); |
221 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); | 221 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); |
222 | lay->addWidget( setCompany ); | 222 | lay->addWidget( setCompany ); |
223 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); | 223 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); |
224 | lay->addWidget( ok ); | 224 | lay->addWidget( ok ); |
225 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 225 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
226 | lay->addWidget( cancel ); | 226 | lay->addWidget( cancel ); |
227 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 227 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
228 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 228 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
229 | //resize( 200, 200 ); | 229 | //resize( 200, 200 ); |
230 | 230 | ||
231 | } | 231 | } |
232 | public: | 232 | public: |
233 | QRadioButton* simple, *full, *reverse, *company; | 233 | QRadioButton* simple, *full, *reverse, *company; |
234 | QCheckBox* setCompany; | 234 | QCheckBox* setCompany; |
235 | }; | 235 | }; |
236 | 236 | ||
237 | 237 | ||
238 | 238 | ||
239 | class KAex2phonePrefs : public QDialog | 239 | class KAex2phonePrefs : public QDialog |
240 | { | 240 | { |
241 | public: | 241 | public: |
242 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 242 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
243 | QDialog( parent, name, true ) | 243 | QDialog( parent, name, true ) |
244 | { | 244 | { |
245 | setCaption( i18n("Export to phone options") ); | 245 | setCaption( i18n("Export to phone options") ); |
246 | QVBoxLayout* lay = new QVBoxLayout( this ); | 246 | QVBoxLayout* lay = new QVBoxLayout( this ); |
247 | lay->setSpacing( 3 ); | 247 | lay->setSpacing( 3 ); |
248 | lay->setMargin( 3 ); | 248 | lay->setMargin( 3 ); |
249 | QLabel *lab; | 249 | QLabel *lab; |
250 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 250 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
251 | lab->setAlignment (AlignHCenter ); | 251 | lab->setAlignment (AlignHCenter ); |
252 | QHBox* temphb; | 252 | QHBox* temphb; |
253 | temphb = new QHBox( this ); | 253 | temphb = new QHBox( this ); |
254 | new QLabel( i18n("I/O device: "), temphb ); | 254 | new QLabel( i18n("I/O device: "), temphb ); |
255 | mPhoneDevice = new QLineEdit( temphb); | 255 | mPhoneDevice = new QLineEdit( temphb); |
256 | lay->addWidget( temphb ); | 256 | lay->addWidget( temphb ); |
257 | temphb = new QHBox( this ); | 257 | temphb = new QHBox( this ); |
258 | new QLabel( i18n("Connection: "), temphb ); | 258 | new QLabel( i18n("Connection: "), temphb ); |
259 | mPhoneConnection = new QLineEdit( temphb); | 259 | mPhoneConnection = new QLineEdit( temphb); |
260 | lay->addWidget( temphb ); | 260 | lay->addWidget( temphb ); |
261 | temphb = new QHBox( this ); | 261 | temphb = new QHBox( this ); |
262 | new QLabel( i18n("Model(opt.): "), temphb ); | 262 | new QLabel( i18n("Model(opt.): "), temphb ); |
263 | mPhoneModel = new QLineEdit( temphb); | 263 | mPhoneModel = new QLineEdit( temphb); |
264 | lay->addWidget( temphb ); | 264 | lay->addWidget( temphb ); |
265 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 265 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
266 | // lay->addWidget( mWriteToSim ); | 266 | // lay->addWidget( mWriteToSim ); |
267 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 267 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
268 | lab->setAlignment (AlignHCenter); | 268 | lab->setAlignment (AlignHCenter); |
269 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 269 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
270 | lay->addWidget( ok ); | 270 | lay->addWidget( ok ); |
271 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 271 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
272 | lay->addWidget( cancel ); | 272 | lay->addWidget( cancel ); |
273 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 273 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
274 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 274 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
275 | resize( 220, 240 ); | 275 | resize( 220, 240 ); |
276 | 276 | ||
277 | } | 277 | } |
278 | 278 | ||
279 | public: | 279 | public: |
280 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 280 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
281 | QCheckBox* mWriteToSim; | 281 | QCheckBox* mWriteToSim; |
282 | }; | 282 | }; |
283 | 283 | ||
284 | 284 | ||
285 | bool pasteWithNewUid = true; | 285 | bool pasteWithNewUid = true; |
286 | 286 | ||
287 | #ifdef KAB_EMBEDDED | 287 | #ifdef KAB_EMBEDDED |
288 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 288 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
289 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 289 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
290 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 290 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
291 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 291 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
292 | #else //KAB_EMBEDDED | 292 | #else //KAB_EMBEDDED |
293 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 293 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
294 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 294 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
295 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 295 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
296 | mReadWrite( readWrite ), mModified( false ) | 296 | mReadWrite( readWrite ), mModified( false ) |
297 | #endif //KAB_EMBEDDED | 297 | #endif //KAB_EMBEDDED |
298 | { | 298 | { |
299 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 299 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
300 | // syncManager->setBlockSave(false); | 300 | // syncManager->setBlockSave(false); |
301 | mIncSearchWidget = 0; | 301 | mIncSearchWidget = 0; |
302 | mMiniSplitter = 0; | 302 | mMiniSplitter = 0; |
303 | mExtensionBarSplitter = 0; | 303 | mExtensionBarSplitter = 0; |
304 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 304 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
305 | mAddressBook = KABC::StdAddressBook::self(); | 305 | mAddressBook = KABC::StdAddressBook::self(); |
306 | KABC::StdAddressBook::setAutomaticSave( false ); | 306 | KABC::StdAddressBook::setAutomaticSave( false ); |
307 | 307 | ||
308 | #ifndef KAB_EMBEDDED | 308 | #ifndef KAB_EMBEDDED |
309 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 309 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
310 | #endif //KAB_EMBEDDED | 310 | #endif //KAB_EMBEDDED |
311 | 311 | ||
312 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 312 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
313 | SLOT( addressBookChanged() ) ); | 313 | SLOT( addressBookChanged() ) ); |
314 | 314 | ||
315 | #if 0 | 315 | #if 0 |
316 | // LR moved to addressbook init method | 316 | // LR moved to addressbook init method |
317 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 317 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
318 | "X-Department", "KADDRESSBOOK" ); | 318 | "X-Department", "KADDRESSBOOK" ); |
319 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 319 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
320 | "X-Profession", "KADDRESSBOOK" ); | 320 | "X-Profession", "KADDRESSBOOK" ); |
321 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 321 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
322 | "X-AssistantsName", "KADDRESSBOOK" ); | 322 | "X-AssistantsName", "KADDRESSBOOK" ); |
323 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 323 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
324 | "X-ManagersName", "KADDRESSBOOK" ); | 324 | "X-ManagersName", "KADDRESSBOOK" ); |
325 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 325 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
326 | "X-SpousesName", "KADDRESSBOOK" ); | 326 | "X-SpousesName", "KADDRESSBOOK" ); |
327 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 327 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
328 | "X-Office", "KADDRESSBOOK" ); | 328 | "X-Office", "KADDRESSBOOK" ); |
329 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 329 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
330 | "X-IMAddress", "KADDRESSBOOK" ); | 330 | "X-IMAddress", "KADDRESSBOOK" ); |
331 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 331 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
332 | "X-Anniversary", "KADDRESSBOOK" ); | 332 | "X-Anniversary", "KADDRESSBOOK" ); |
333 | 333 | ||
334 | //US added this field to become compatible with Opie/qtopia addressbook | 334 | //US added this field to become compatible with Opie/qtopia addressbook |
335 | // values can be "female" or "male" or "". An empty field represents undefined. | 335 | // values can be "female" or "male" or "". An empty field represents undefined. |
336 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 336 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
337 | "X-Gender", "KADDRESSBOOK" ); | 337 | "X-Gender", "KADDRESSBOOK" ); |
338 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 338 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
339 | "X-Children", "KADDRESSBOOK" ); | 339 | "X-Children", "KADDRESSBOOK" ); |
340 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 340 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
341 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 341 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
342 | #endif | 342 | #endif |
343 | initGUI(); | 343 | initGUI(); |
344 | 344 | ||
345 | mIncSearchWidget->setFocus(); | 345 | mIncSearchWidget->setFocus(); |
346 | 346 | ||
347 | 347 | ||
348 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 348 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
349 | SLOT( setContactSelected( const QString& ) ) ); | 349 | SLOT( setContactSelected( const QString& ) ) ); |
350 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 350 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
351 | SLOT( executeContact( const QString& ) ) ); | 351 | SLOT( executeContact( const QString& ) ) ); |
352 | 352 | ||
353 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 353 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
354 | SLOT( deleteContacts( ) ) ); | 354 | SLOT( deleteContacts( ) ) ); |
355 | connect( mViewManager, SIGNAL( modified() ), | 355 | connect( mViewManager, SIGNAL( modified() ), |
356 | SLOT( setModified() ) ); | 356 | SLOT( setModified() ) ); |
357 | 357 | ||
358 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 358 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
359 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 359 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
360 | 360 | ||
361 | connect( mXXPortManager, SIGNAL( modified() ), | 361 | connect( mXXPortManager, SIGNAL( modified() ), |
362 | SLOT( setModified() ) ); | 362 | SLOT( setModified() ) ); |
363 | 363 | ||
364 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 364 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
365 | SLOT( incrementalSearchJump( const QString& ) ) ); | 365 | SLOT( incrementalSearchJump( const QString& ) ) ); |
366 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 366 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
367 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 367 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
368 | 368 | ||
369 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 369 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
370 | SLOT( sendMail( const QString& ) ) ); | 370 | SLOT( sendMail( const QString& ) ) ); |
371 | 371 | ||
372 | 372 | ||
373 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 373 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
374 | 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&))); | 374 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
375 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 375 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
376 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | 376 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); |
377 | connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); | 377 | connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); |
378 | 378 | ||
379 | 379 | ||
380 | #ifndef KAB_EMBEDDED | 380 | #ifndef KAB_EMBEDDED |
381 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 381 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
382 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 382 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
383 | 383 | ||
384 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 384 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
385 | SLOT( browse( const QString& ) ) ); | 385 | SLOT( browse( const QString& ) ) ); |
386 | 386 | ||
387 | 387 | ||
388 | mAddressBookService = new KAddressBookService( this ); | 388 | mAddressBookService = new KAddressBookService( this ); |
389 | 389 | ||
390 | #endif //KAB_EMBEDDED | 390 | #endif //KAB_EMBEDDED |
391 | 391 | ||
392 | mMessageTimer = new QTimer( this ); | 392 | mMessageTimer = new QTimer( this ); |
393 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 393 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
394 | mEditorDialog = 0; | 394 | mEditorDialog = 0; |
395 | createAddresseeEditorDialog( this ); | 395 | createAddresseeEditorDialog( this ); |
396 | setModified( false ); | 396 | setModified( false ); |
397 | mBRdisabled = false; | 397 | mBRdisabled = false; |
398 | #ifndef DESKTOP_VERSION | 398 | #ifndef DESKTOP_VERSION |
399 | infrared = 0; | 399 | infrared = 0; |
400 | #endif | 400 | #endif |
401 | //toggleBeamReceive( ); | 401 | //toggleBeamReceive( ); |
402 | mMainWindow->toolBar()->show(); | 402 | mMainWindow->toolBar()->show(); |
403 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 403 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
404 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 404 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
405 | } | 405 | } |
406 | 406 | ||
407 | void KABCore::updateToolBar() | 407 | void KABCore::updateToolBar() |
408 | { | 408 | { |
409 | static int iii = 0; | 409 | static int iii = 0; |
410 | ++iii; | 410 | ++iii; |
411 | mMainWindow->toolBar()->repaintMe(); | 411 | mMainWindow->toolBar()->repaintMe(); |
412 | if ( iii < 4 ) | 412 | if ( iii < 4 ) |
413 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); | 413 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); |
414 | } | 414 | } |
415 | KABCore::~KABCore() | 415 | KABCore::~KABCore() |
416 | { | 416 | { |
417 | // save(); | 417 | // save(); |
418 | //saveSettings(); | 418 | //saveSettings(); |
419 | //KABPrefs::instance()->writeConfig(); | 419 | //KABPrefs::instance()->writeConfig(); |
420 | delete AddresseeConfig::instance(); | 420 | delete AddresseeConfig::instance(); |
421 | mAddressBook = 0; | 421 | mAddressBook = 0; |
422 | KABC::StdAddressBook::close(); | 422 | KABC::StdAddressBook::close(); |
423 | 423 | ||
424 | delete syncManager; | 424 | delete syncManager; |
425 | #ifndef DESKTOP_VERSION | 425 | #ifndef DESKTOP_VERSION |
426 | if ( infrared ) | 426 | if ( infrared ) |
427 | delete infrared; | 427 | delete infrared; |
428 | #endif | 428 | #endif |
429 | } | 429 | } |
430 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 430 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
431 | { | 431 | { |
432 | //qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 432 | //qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
433 | if ( cmsg == "setDocument(QString)" ) { | 433 | if ( cmsg == "setDocument(QString)" ) { |
434 | QDataStream stream( data, IO_ReadOnly ); | 434 | QDataStream stream( data, IO_ReadOnly ); |
435 | QString fileName; | 435 | QString fileName; |
436 | stream >> fileName; | 436 | stream >> fileName; |
437 | recieve( fileName ); | 437 | recieve( fileName ); |
438 | return; | 438 | return; |
439 | } | 439 | } |
440 | } | 440 | } |
441 | void KABCore::toggleBeamReceive( ) | 441 | void KABCore::toggleBeamReceive( ) |
442 | { | 442 | { |
443 | if ( mBRdisabled ) | 443 | if ( mBRdisabled ) |
444 | return; | 444 | return; |
445 | #ifndef DESKTOP_VERSION | 445 | #ifndef DESKTOP_VERSION |
446 | if ( infrared ) { | 446 | if ( infrared ) { |
447 | qDebug("KA: AB disable BeamReceive "); | 447 | qDebug("KA: AB disable BeamReceive "); |
448 | delete infrared; | 448 | delete infrared; |
449 | infrared = 0; | 449 | infrared = 0; |
450 | mActionBR->setChecked(false); | 450 | mActionBR->setChecked(false); |
451 | return; | 451 | return; |
452 | } | 452 | } |
453 | qDebug("KA: AB enable BeamReceive "); | 453 | qDebug("KA: AB enable BeamReceive "); |
454 | mActionBR->setChecked(true); | 454 | mActionBR->setChecked(true); |
455 | 455 | ||
456 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 456 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
457 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 457 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
458 | #endif | 458 | #endif |
459 | } | 459 | } |
460 | 460 | ||
461 | 461 | ||
462 | void KABCore::disableBR(bool b) | 462 | void KABCore::disableBR(bool b) |
463 | { | 463 | { |
464 | #ifndef DESKTOP_VERSION | 464 | #ifndef DESKTOP_VERSION |
465 | if ( b ) { | 465 | if ( b ) { |
466 | if ( infrared ) { | 466 | if ( infrared ) { |
467 | toggleBeamReceive( ); | 467 | toggleBeamReceive( ); |
468 | } | 468 | } |
469 | mBRdisabled = true; | 469 | mBRdisabled = true; |
470 | } else { | 470 | } else { |
471 | if ( mBRdisabled ) { | 471 | if ( mBRdisabled ) { |
472 | mBRdisabled = false; | 472 | mBRdisabled = false; |
473 | //toggleBeamReceive( ); | 473 | //toggleBeamReceive( ); |
474 | } | 474 | } |
475 | } | 475 | } |
476 | #endif | 476 | #endif |
477 | 477 | ||
478 | } | 478 | } |
479 | void KABCore::recieve( QString fn ) | 479 | void KABCore::recieve( QString fn ) |
480 | { | 480 | { |
481 | //qDebug("KABCore::recieve "); | 481 | //qDebug("KABCore::recieve "); |
482 | int count = mAddressBook->importFromFile( fn, true ); | 482 | int count = mAddressBook->importFromFile( fn, true ); |
483 | if ( count ) | 483 | if ( count ) |
484 | setModified( true ); | 484 | setModified( true ); |
485 | mViewManager->refreshView(); | 485 | mViewManager->refreshView(); |
486 | message(i18n("%1 contact(s) received!").arg( count )); | 486 | message(i18n("%1 contact(s) received!").arg( count )); |
487 | topLevelWidget()->showMaximized(); | 487 | topLevelWidget()->showMaximized(); |
488 | topLevelWidget()->raise(); | 488 | topLevelWidget()->raise(); |
489 | } | 489 | } |
490 | void KABCore::restoreSettings() | 490 | void KABCore::restoreSettings() |
491 | { | 491 | { |
492 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 492 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
493 | 493 | ||
494 | bool state; | 494 | bool state; |
495 | 495 | ||
496 | if (mMultipleViewsAtOnce) | 496 | if (mMultipleViewsAtOnce) |
497 | state = KABPrefs::instance()->mDetailsPageVisible; | 497 | state = KABPrefs::instance()->mDetailsPageVisible; |
498 | else | 498 | else |
499 | state = false; | 499 | state = false; |
500 | 500 | ||
501 | mActionDetails->setChecked( state ); | 501 | mActionDetails->setChecked( state ); |
502 | setDetailsVisible( state ); | 502 | setDetailsVisible( state ); |
503 | 503 | ||
504 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 504 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
505 | 505 | ||
506 | mActionJumpBar->setChecked( state ); | 506 | mActionJumpBar->setChecked( state ); |
507 | setJumpButtonBarVisible( state ); | 507 | setJumpButtonBarVisible( state ); |
508 | /*US | 508 | /*US |
509 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 509 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
510 | if ( splitterSize.count() == 0 ) { | 510 | if ( splitterSize.count() == 0 ) { |
511 | splitterSize.append( width() / 2 ); | 511 | splitterSize.append( width() / 2 ); |
512 | splitterSize.append( width() / 2 ); | 512 | splitterSize.append( width() / 2 ); |
513 | } | 513 | } |
514 | mMiniSplitter->setSizes( splitterSize ); | 514 | mMiniSplitter->setSizes( splitterSize ); |
515 | if ( mExtensionBarSplitter ) { | 515 | if ( mExtensionBarSplitter ) { |
516 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 516 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
517 | if ( splitterSize.count() == 0 ) { | 517 | if ( splitterSize.count() == 0 ) { |
518 | splitterSize.append( width() / 2 ); | 518 | splitterSize.append( width() / 2 ); |
519 | splitterSize.append( width() / 2 ); | 519 | splitterSize.append( width() / 2 ); |
520 | } | 520 | } |
521 | mExtensionBarSplitter->setSizes( splitterSize ); | 521 | mExtensionBarSplitter->setSizes( splitterSize ); |
522 | 522 | ||
523 | } | 523 | } |
524 | */ | 524 | */ |
525 | mViewManager->restoreSettings(); | 525 | mViewManager->restoreSettings(); |
526 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 526 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
527 | mExtensionManager->restoreSettings(); | 527 | mExtensionManager->restoreSettings(); |
528 | #ifdef DESKTOP_VERSION | 528 | #ifdef DESKTOP_VERSION |
529 | int wid = width(); | 529 | int wid = width(); |
530 | if ( wid < 10 ) | 530 | if ( wid < 10 ) |
531 | wid = 400; | 531 | wid = 400; |
532 | #else | 532 | #else |
533 | int wid = QApplication::desktop()->width(); | 533 | int wid = QApplication::desktop()->width(); |
534 | if ( wid < 640 ) | 534 | if ( wid < 640 ) |
535 | wid = QApplication::desktop()->height(); | 535 | wid = QApplication::desktop()->height(); |
536 | #endif | 536 | #endif |
537 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 537 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
538 | if ( true /*splitterSize.count() == 0*/ ) { | 538 | if ( true /*splitterSize.count() == 0*/ ) { |
539 | splitterSize.append( wid / 2 ); | 539 | splitterSize.append( wid / 2 ); |
540 | splitterSize.append( wid / 2 ); | 540 | splitterSize.append( wid / 2 ); |
541 | } | 541 | } |
542 | mMiniSplitter->setSizes( splitterSize ); | 542 | mMiniSplitter->setSizes( splitterSize ); |
543 | if ( mExtensionBarSplitter ) { | 543 | if ( mExtensionBarSplitter ) { |
544 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 544 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
545 | if ( true /*splitterSize.count() == 0*/ ) { | 545 | if ( true /*splitterSize.count() == 0*/ ) { |
546 | splitterSize.append( wid / 2 ); | 546 | splitterSize.append( wid / 2 ); |
547 | splitterSize.append( wid / 2 ); | 547 | splitterSize.append( wid / 2 ); |
548 | } | 548 | } |
549 | mExtensionBarSplitter->setSizes( splitterSize ); | 549 | mExtensionBarSplitter->setSizes( splitterSize ); |
550 | 550 | ||
551 | } | 551 | } |
552 | 552 | ||
553 | 553 | ||
554 | } | 554 | } |
555 | 555 | ||
556 | void KABCore::saveSettings() | 556 | void KABCore::saveSettings() |
557 | { | 557 | { |
558 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 558 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
559 | if ( mExtensionBarSplitter ) | 559 | if ( mExtensionBarSplitter ) |
560 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 560 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
561 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 561 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
562 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 562 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
563 | #ifndef KAB_EMBEDDED | 563 | #ifndef KAB_EMBEDDED |
564 | 564 | ||
565 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 565 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
566 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 566 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
567 | #endif //KAB_EMBEDDED | 567 | #endif //KAB_EMBEDDED |
568 | mExtensionManager->saveSettings(); | 568 | mExtensionManager->saveSettings(); |
569 | mViewManager->saveSettings(); | 569 | mViewManager->saveSettings(); |
570 | 570 | ||
571 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 571 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
572 | KABPrefs::instance()->writeConfig(); | 572 | KABPrefs::instance()->writeConfig(); |
573 | qDebug("KA: KABCore::saveSettings() "); | 573 | qDebug("KA: KABCore::saveSettings() "); |
574 | } | 574 | } |
575 | 575 | ||
576 | KABC::AddressBook *KABCore::addressBook() const | 576 | KABC::AddressBook *KABCore::addressBook() const |
577 | { | 577 | { |
578 | return mAddressBook; | 578 | return mAddressBook; |
579 | } | 579 | } |
580 | 580 | ||
581 | KConfig *KABCore::config() | 581 | KConfig *KABCore::config() |
582 | { | 582 | { |
583 | #ifndef KAB_EMBEDDED | 583 | #ifndef KAB_EMBEDDED |
584 | return KABPrefs::instance()->config(); | 584 | return KABPrefs::instance()->config(); |
585 | #else //KAB_EMBEDDED | 585 | #else //KAB_EMBEDDED |
586 | return KABPrefs::instance()->getConfig(); | 586 | return KABPrefs::instance()->getConfig(); |
587 | #endif //KAB_EMBEDDED | 587 | #endif //KAB_EMBEDDED |
588 | } | 588 | } |
589 | 589 | ||
590 | KActionCollection *KABCore::actionCollection() const | 590 | KActionCollection *KABCore::actionCollection() const |
591 | { | 591 | { |
592 | return mGUIClient->actionCollection(); | 592 | return mGUIClient->actionCollection(); |
593 | } | 593 | } |
594 | 594 | ||
595 | KABC::Field *KABCore::currentSearchField() const | 595 | KABC::Field *KABCore::currentSearchField() const |
596 | { | 596 | { |
597 | if (mIncSearchWidget) | 597 | if (mIncSearchWidget) |
598 | return mIncSearchWidget->currentField(); | 598 | return mIncSearchWidget->currentField(); |
599 | else | 599 | else |
600 | return 0; | 600 | return 0; |
601 | } | 601 | } |
602 | 602 | ||
603 | QStringList KABCore::selectedUIDs() const | 603 | QStringList KABCore::selectedUIDs() const |
604 | { | 604 | { |
605 | return mViewManager->selectedUids(); | 605 | return mViewManager->selectedUids(); |
606 | } | 606 | } |
607 | 607 | ||
608 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 608 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
609 | { | 609 | { |
610 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 610 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
611 | 611 | ||
612 | QPtrList<KRES::Resource> kresResources; | 612 | QPtrList<KRES::Resource> kresResources; |
613 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 613 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
614 | KABC::Resource *resource; | 614 | KABC::Resource *resource; |
615 | while ( ( resource = resIt.current() ) != 0 ) { | 615 | while ( ( resource = resIt.current() ) != 0 ) { |
616 | ++resIt; | 616 | ++resIt; |
617 | if ( !resource->readOnly() ) { | 617 | if ( !resource->readOnly() ) { |
618 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 618 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
619 | if ( res ) | 619 | if ( res ) |
620 | kresResources.append( res ); | 620 | kresResources.append( res ); |
621 | } | 621 | } |
622 | } | 622 | } |
623 | 623 | ||
624 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 624 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
625 | return static_cast<KABC::Resource*>( res ); | 625 | return static_cast<KABC::Resource*>( res ); |
626 | } | 626 | } |
627 | 627 | ||
628 | #ifndef KAB_EMBEDDED | 628 | #ifndef KAB_EMBEDDED |
629 | KAboutData *KABCore::createAboutData() | 629 | KAboutData *KABCore::createAboutData() |
630 | #else //KAB_EMBEDDED | 630 | #else //KAB_EMBEDDED |
631 | void KABCore::createAboutData() | 631 | void KABCore::createAboutData() |
632 | #endif //KAB_EMBEDDED | 632 | #endif //KAB_EMBEDDED |
633 | { | 633 | { |
634 | #ifndef KAB_EMBEDDED | 634 | |
635 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | ||
636 | "3.1", I18N_NOOP( "The KDE Address Book" ), | ||
637 | KAboutData::License_GPL_V2, | ||
638 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | ||
639 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | ||
640 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | ||
641 | about->addAuthor( "Cornelius Schumacher", | ||
642 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | ||
643 | "schumacher@kde.org" ); | ||
644 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | ||
645 | "mpilone@slac.com" ); | ||
646 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | ||
647 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | ||
648 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | ||
649 | "michel@klaralvdalens-datakonsult.se" ); | ||
650 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | ||
651 | "hansen@kde.org" ); | ||
652 | |||
653 | return about; | ||
654 | #endif //KAB_EMBEDDED | ||
655 | 635 | ||
656 | QString version; | 636 | QString version; |
657 | #include <../version> | 637 | #include <../version> |
658 | QMessageBox::about( this, "About KAddressbook/Pi", | 638 | QMessageBox::about( this, "About KAddressbook/Pi", |
659 | "KAddressbook/Platform-independent\n" | 639 | "KAddressbook/Platform-independent\n" |
660 | "(KA/Pi) " +version + " - " + | 640 | "(KA/Pi) " +version + " - " + |
661 | #ifdef DESKTOP_VERSION | 641 | #ifdef DESKTOP_VERSION |
662 | "Desktop Edition\n" | 642 | "Desktop Edition\n" |
663 | #else | 643 | #else |
664 | "PDA-Edition\n" | 644 | "PDA-Edition\n" |
665 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 645 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
666 | #endif | 646 | #endif |
667 | 647 | ||
668 | "(c) 2004 Ulf Schenk\n" | 648 | "(c) 2004 Ulf Schenk\n" |
669 | "(c) 2004 Lutz Rogowski\n" | 649 | "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" |
670 | "(c) 1997-2003, The KDE PIM Team\n" | 650 | "(c) 1997-2003, The KDE PIM Team\n" |
671 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 651 | "Tobias Koenig Maintainer\n" |
672 | "Don Sanders Original author\n" | 652 | "Don Sanders Original author\n" |
673 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 653 | "Cornelius Schumacher Co-maintainer\n" |
674 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 654 | "Mike Pilone GUI and framework redesign\n" |
675 | "Greg Stern DCOP interface\n" | 655 | "Greg Stern DCOP interface\n" |
676 | "Mark Westcot Contact pinning\n" | 656 | "Mark Westcot Contact pinning\n" |
677 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 657 | "Michel Boyer de la Giroday LDAP Lookup\n" |
678 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 658 | "Steffen Hansen LDAP Lookup" |
679 | #ifdef _WIN32_ | 659 | #ifdef _WIN32_ |
680 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 660 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
681 | #endif | 661 | #endif |
682 | ); | 662 | ); |
683 | } | 663 | } |
684 | 664 | ||
685 | void KABCore::setContactSelected( const QString &uid ) | 665 | void KABCore::setContactSelected( const QString &uid ) |
686 | { | 666 | { |
687 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 667 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
688 | if ( !mDetails->isHidden() ) | 668 | if ( !mDetails->isHidden() ) |
689 | mDetails->setAddressee( addr ); | 669 | mDetails->setAddressee( addr ); |
690 | 670 | ||
691 | if ( !addr.isEmpty() ) { | 671 | if ( !addr.isEmpty() ) { |
692 | emit contactSelected( addr.formattedName() ); | 672 | emit contactSelected( addr.formattedName() ); |
693 | KABC::Picture pic = addr.photo(); | 673 | KABC::Picture pic = addr.photo(); |
694 | if ( pic.isIntern() ) { | 674 | if ( pic.isIntern() ) { |
695 | //US emit contactSelected( pic.data() ); | 675 | //US emit contactSelected( pic.data() ); |
696 | //US instead use: | 676 | //US instead use: |
697 | QPixmap px; | 677 | QPixmap px; |
698 | if (pic.data().isNull() != true) | 678 | if (pic.data().isNull() != true) |
699 | { | 679 | { |
700 | px.convertFromImage(pic.data()); | 680 | px.convertFromImage(pic.data()); |
701 | } | 681 | } |
702 | 682 | ||
703 | emit contactSelected( px ); | 683 | emit contactSelected( px ); |
704 | } | 684 | } |
705 | } | 685 | } |
706 | 686 | ||
707 | 687 | ||
708 | mExtensionManager->setSelectionChanged(); | 688 | mExtensionManager->setSelectionChanged(); |
709 | 689 | ||
710 | // update the actions | 690 | // update the actions |
711 | bool selected = !uid.isEmpty(); | 691 | bool selected = !uid.isEmpty(); |
712 | 692 | ||
713 | if ( mReadWrite ) { | 693 | if ( mReadWrite ) { |
714 | mActionCut->setEnabled( selected ); | 694 | mActionCut->setEnabled( selected ); |
715 | mActionPaste->setEnabled( selected ); | 695 | mActionPaste->setEnabled( selected ); |
716 | } | 696 | } |
717 | 697 | ||
718 | mActionCopy->setEnabled( selected ); | 698 | mActionCopy->setEnabled( selected ); |
719 | mActionDelete->setEnabled( selected ); | 699 | mActionDelete->setEnabled( selected ); |
720 | mActionEditAddressee->setEnabled( selected ); | 700 | mActionEditAddressee->setEnabled( selected ); |
721 | mActionMail->setEnabled( selected ); | 701 | mActionMail->setEnabled( selected ); |
722 | mActionMailVCard->setEnabled( selected ); | 702 | mActionMailVCard->setEnabled( selected ); |
723 | //if (mActionBeam) | 703 | //if (mActionBeam) |
724 | //mActionBeam->setEnabled( selected ); | 704 | //mActionBeam->setEnabled( selected ); |
725 | mActionWhoAmI->setEnabled( selected ); | 705 | mActionWhoAmI->setEnabled( selected ); |
726 | } | 706 | } |
727 | 707 | ||
728 | void KABCore::sendMail() | 708 | void KABCore::sendMail() |
729 | { | 709 | { |
730 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 710 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
731 | } | 711 | } |
732 | 712 | ||
733 | void KABCore::sendMail( const QString& emaillist ) | 713 | void KABCore::sendMail( const QString& emaillist ) |
734 | { | 714 | { |
735 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 715 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
736 | if (emaillist.contains(",") > 0) | 716 | if (emaillist.contains(",") > 0) |
737 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 717 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
738 | else | 718 | else |
739 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 719 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
740 | } | 720 | } |
741 | 721 | ||
742 | 722 | ||
743 | 723 | ||
744 | void KABCore::mailVCard() | 724 | void KABCore::mailVCard() |
745 | { | 725 | { |
746 | QStringList uids = mViewManager->selectedUids(); | 726 | QStringList uids = mViewManager->selectedUids(); |
747 | if ( !uids.isEmpty() ) | 727 | if ( !uids.isEmpty() ) |
748 | mailVCard( uids ); | 728 | mailVCard( uids ); |
749 | } | 729 | } |
750 | 730 | ||
751 | void KABCore::mailVCard( const QStringList& uids ) | 731 | void KABCore::mailVCard( const QStringList& uids ) |
752 | { | 732 | { |
753 | QStringList urls; | 733 | QStringList urls; |
754 | 734 | ||
755 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 735 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
756 | 736 | ||
757 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 737 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
758 | 738 | ||
759 | 739 | ||
760 | 740 | ||
761 | QDir().mkdir( dirName, true ); | 741 | QDir().mkdir( dirName, true ); |
762 | 742 | ||
763 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 743 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
764 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 744 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
765 | 745 | ||
766 | if ( a.isEmpty() ) | 746 | if ( a.isEmpty() ) |
767 | continue; | 747 | continue; |
768 | 748 | ||
769 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 749 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
770 | 750 | ||
771 | QString fileName = dirName + "/" + name; | 751 | QString fileName = dirName + "/" + name; |
772 | 752 | ||
773 | QFile outFile(fileName); | 753 | QFile outFile(fileName); |
774 | 754 | ||
775 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 755 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
776 | KABC::VCardConverter converter; | 756 | KABC::VCardConverter converter; |
777 | QString vcard; | 757 | QString vcard; |
778 | 758 | ||
779 | converter.addresseeToVCard( a, vcard ); | 759 | converter.addresseeToVCard( a, vcard ); |
780 | 760 | ||
781 | QTextStream t( &outFile ); // use a text stream | 761 | QTextStream t( &outFile ); // use a text stream |
782 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 762 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
783 | t << vcard; | 763 | t << vcard; |
784 | 764 | ||
785 | outFile.close(); | 765 | outFile.close(); |
786 | 766 | ||
787 | urls.append( fileName ); | 767 | urls.append( fileName ); |
788 | } | 768 | } |
789 | } | 769 | } |
790 | 770 | ||
791 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 771 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
792 | 772 | ||
793 | 773 | ||
794 | /*US | 774 | /*US |
795 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 775 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
796 | QString::null, // subject | 776 | QString::null, // subject |
797 | QString::null, // body | 777 | QString::null, // body |
798 | QString::null, | 778 | QString::null, |
799 | urls ); // attachments | 779 | urls ); // attachments |
800 | */ | 780 | */ |
801 | 781 | ||
802 | } | 782 | } |
803 | 783 | ||
804 | /** | 784 | /** |
805 | Beams the "WhoAmI contact. | 785 | Beams the "WhoAmI contact. |
806 | */ | 786 | */ |
807 | void KABCore::beamMySelf() | 787 | void KABCore::beamMySelf() |
808 | { | 788 | { |
809 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 789 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
810 | if (!a.isEmpty()) | 790 | if (!a.isEmpty()) |
811 | { | 791 | { |
812 | QStringList uids; | 792 | QStringList uids; |
813 | uids << a.uid(); | 793 | uids << a.uid(); |
814 | 794 | ||
815 | beamVCard(uids); | 795 | beamVCard(uids); |
816 | } else { | 796 | } else { |
817 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 797 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
818 | 798 | ||
819 | 799 | ||
820 | } | 800 | } |
821 | } | 801 | } |
822 | void KABCore::updateMainWindow() | 802 | void KABCore::updateMainWindow() |
823 | { | 803 | { |
824 | mMainWindow->showMaximized(); | 804 | mMainWindow->showMaximized(); |
825 | mMainWindow->update(); | 805 | mMainWindow->update(); |
826 | } | 806 | } |
827 | void KABCore::resizeEvent(QResizeEvent* e ) | 807 | void KABCore::resizeEvent(QResizeEvent* e ) |
828 | { | 808 | { |
829 | if ( !mMiniSplitter ) | 809 | if ( !mMiniSplitter ) |
830 | return; | 810 | return; |
831 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | 811 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); |
832 | if ( QApplication::desktop()->width() >= 480 ) { | 812 | if ( QApplication::desktop()->width() >= 480 ) { |
833 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 813 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
834 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 814 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
835 | mMiniSplitter->setOrientation( Qt::Horizontal); | 815 | mMiniSplitter->setOrientation( Qt::Horizontal); |
836 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 816 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
837 | } | 817 | } |
838 | if ( QApplication::desktop()->width() <= 640 ) { | 818 | if ( QApplication::desktop()->width() <= 640 ) { |
839 | mMainWindow->showMinimized(); | 819 | mMainWindow->showMinimized(); |
840 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 820 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
841 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 821 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
842 | if ( mIncSearchWidget ) | 822 | if ( mIncSearchWidget ) |
843 | mIncSearchWidget->setSize(); | 823 | mIncSearchWidget->setSize(); |
844 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 824 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
845 | } | 825 | } |
846 | 826 | ||
847 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 827 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
848 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 828 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
849 | mMiniSplitter->setOrientation( Qt::Vertical ); | 829 | mMiniSplitter->setOrientation( Qt::Vertical ); |
850 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 830 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
851 | } | 831 | } |
852 | if ( QApplication::desktop()->width() <= 640 ) { | 832 | if ( QApplication::desktop()->width() <= 640 ) { |
853 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 833 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
854 | mMainWindow->showMinimized(); | 834 | mMainWindow->showMinimized(); |
855 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { | 835 | if ( KABPrefs::instance()->mHideSearchOnSwitch ) { |
856 | if ( mIncSearchWidget ) { | 836 | if ( mIncSearchWidget ) { |
857 | mIncSearchWidget->setSize(); | 837 | mIncSearchWidget->setSize(); |
858 | } | 838 | } |
859 | } else { | 839 | } else { |
860 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 840 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
861 | } | 841 | } |
862 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 842 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
863 | } | 843 | } |
864 | } | 844 | } |
865 | } | 845 | } |
866 | QWidget::resizeEvent( e ); | 846 | QWidget::resizeEvent( e ); |
867 | 847 | ||
868 | } | 848 | } |
869 | void KABCore::export2phone() | 849 | void KABCore::export2phone() |
870 | { | 850 | { |
871 | 851 | ||
872 | QStringList uids; | 852 | QStringList uids; |
873 | XXPortSelectDialog dlg( this, false, this ); | 853 | XXPortSelectDialog dlg( this, false, this ); |
874 | if ( dlg.exec() ) | 854 | if ( dlg.exec() ) |
875 | uids = dlg.uids(); | 855 | uids = dlg.uids(); |
876 | else | 856 | else |
877 | return; | 857 | return; |
878 | if ( uids.isEmpty() ) | 858 | if ( uids.isEmpty() ) |
879 | return; | 859 | return; |
880 | // qDebug("count %d ", uids.count()); | 860 | // qDebug("count %d ", uids.count()); |
881 | 861 | ||
882 | KAex2phonePrefs ex2phone; | 862 | KAex2phonePrefs ex2phone; |
883 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 863 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
884 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 864 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
885 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 865 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
886 | 866 | ||
887 | if ( !ex2phone.exec() ) { | 867 | if ( !ex2phone.exec() ) { |
888 | return; | 868 | return; |
889 | } | 869 | } |
890 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 870 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
891 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 871 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
892 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 872 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
893 | 873 | ||
894 | 874 | ||
895 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 875 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
896 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 876 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
897 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 877 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
898 | 878 | ||
899 | QString fileName = getPhoneFile(); | 879 | QString fileName = getPhoneFile(); |
900 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 880 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
901 | return; | 881 | return; |
902 | 882 | ||
903 | message(i18n("Exporting to phone...")); | 883 | message(i18n("Exporting to phone...")); |
904 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 884 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
905 | 885 | ||
906 | } | 886 | } |
907 | QString KABCore::getPhoneFile() | 887 | QString KABCore::getPhoneFile() |
908 | { | 888 | { |
909 | #ifdef DESKTOP_VERSION | 889 | #ifdef DESKTOP_VERSION |
910 | return locateLocal("tmp", "phonefile.vcf"); | 890 | return locateLocal("tmp", "phonefile.vcf"); |
911 | #else | 891 | #else |
912 | return "/tmp/phonefile.vcf"; | 892 | return "/tmp/phonefile.vcf"; |
913 | #endif | 893 | #endif |
914 | 894 | ||
915 | } | 895 | } |
916 | void KABCore::writeToPhone( ) | 896 | void KABCore::writeToPhone( ) |
917 | { | 897 | { |
918 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 898 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
919 | message(i18n("Export to phone finished!")); | 899 | message(i18n("Export to phone finished!")); |
920 | else | 900 | else |
921 | qDebug(i18n("KA: Error exporting to phone")); | 901 | qDebug(i18n("KA: Error exporting to phone")); |
922 | } | 902 | } |
923 | void KABCore::beamVCard() | 903 | void KABCore::beamVCard() |
924 | { | 904 | { |
925 | QStringList uids; | 905 | QStringList uids; |
926 | XXPortSelectDialog dlg( this, false, this ); | 906 | XXPortSelectDialog dlg( this, false, this ); |
927 | if ( dlg.exec() ) | 907 | if ( dlg.exec() ) |
928 | uids = dlg.uids(); | 908 | uids = dlg.uids(); |
929 | else | 909 | else |
930 | return; | 910 | return; |
931 | if ( uids.isEmpty() ) | 911 | if ( uids.isEmpty() ) |
932 | return; | 912 | return; |
933 | beamVCard( uids ); | 913 | beamVCard( uids ); |
934 | } | 914 | } |
935 | 915 | ||
936 | 916 | ||
937 | void KABCore::beamVCard(const QStringList& uids) | 917 | void KABCore::beamVCard(const QStringList& uids) |
938 | { | 918 | { |
939 | 919 | ||
940 | // LR: we should use the /tmp dir on the Zaurus, | 920 | // LR: we should use the /tmp dir on the Zaurus, |
941 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 921 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
942 | 922 | ||
943 | #ifdef DESKTOP_VERSION | 923 | #ifdef DESKTOP_VERSION |
944 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 924 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
945 | #else | 925 | #else |
946 | QString fileName = "/tmp/kapibeamfile.vcf"; | 926 | QString fileName = "/tmp/kapibeamfile.vcf"; |
947 | #endif | 927 | #endif |
948 | 928 | ||
949 | KABC::VCardConverter converter; | 929 | KABC::VCardConverter converter; |
950 | QString description; | 930 | QString description; |
951 | QString datastream; | 931 | QString datastream; |
952 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 932 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
953 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 933 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
954 | 934 | ||
955 | if ( a.isEmpty() ) | 935 | if ( a.isEmpty() ) |
956 | continue; | 936 | continue; |
957 | 937 | ||
958 | if (description.isEmpty()) | 938 | if (description.isEmpty()) |
959 | description = a.formattedName(); | 939 | description = a.formattedName(); |
960 | 940 | ||
961 | QString vcard; | 941 | QString vcard; |
962 | converter.addresseeToVCard( a, vcard ); | 942 | converter.addresseeToVCard( a, vcard ); |
963 | int start = 0; | 943 | int start = 0; |
964 | int next; | 944 | int next; |
965 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 945 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
966 | int semi = vcard.find(";", next); | 946 | int semi = vcard.find(";", next); |
967 | int dopp = vcard.find(":", next); | 947 | int dopp = vcard.find(":", next); |
968 | int sep; | 948 | int sep; |
969 | if ( semi < dopp && semi >= 0 ) | 949 | if ( semi < dopp && semi >= 0 ) |
970 | sep = semi ; | 950 | sep = semi ; |
971 | else | 951 | else |
972 | sep = dopp; | 952 | sep = dopp; |
973 | datastream +=vcard.mid( start, next - start); | 953 | datastream +=vcard.mid( start, next - start); |
974 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 954 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
975 | start = sep; | 955 | start = sep; |
976 | } | 956 | } |
977 | datastream += vcard.mid( start,vcard.length() ); | 957 | datastream += vcard.mid( start,vcard.length() ); |
978 | } | 958 | } |
979 | #ifndef DESKTOP_VERSION | 959 | #ifndef DESKTOP_VERSION |
980 | QFile outFile(fileName); | 960 | QFile outFile(fileName); |
981 | if ( outFile.open(IO_WriteOnly) ) { | 961 | if ( outFile.open(IO_WriteOnly) ) { |
982 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 962 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
983 | QTextStream t( &outFile ); // use a text stream | 963 | QTextStream t( &outFile ); // use a text stream |
984 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 964 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
985 | t.setEncoding( QTextStream::Latin1 ); | 965 | t.setEncoding( QTextStream::Latin1 ); |
986 | t <<datastream.latin1(); | 966 | t <<datastream.latin1(); |
987 | outFile.close(); | 967 | outFile.close(); |
988 | Ir *ir = new Ir( this ); | 968 | Ir *ir = new Ir( this ); |
989 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 969 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
990 | ir->send( fileName, description, "text/x-vCard" ); | 970 | ir->send( fileName, description, "text/x-vCard" ); |
991 | } else { | 971 | } else { |
992 | qDebug("KA: Error open temp beam file "); | 972 | qDebug("KA: Error open temp beam file "); |
993 | return; | 973 | return; |
994 | } | 974 | } |
995 | #endif | 975 | #endif |
996 | 976 | ||
997 | } | 977 | } |
998 | 978 | ||
999 | void KABCore::beamDone( Ir *ir ) | 979 | void KABCore::beamDone( Ir *ir ) |
1000 | { | 980 | { |
1001 | #ifndef DESKTOP_VERSION | 981 | #ifndef DESKTOP_VERSION |
1002 | delete ir; | 982 | delete ir; |
1003 | #endif | 983 | #endif |
1004 | topLevelWidget()->raise(); | 984 | topLevelWidget()->raise(); |
1005 | message( i18n("Beaming finished!") ); | 985 | message( i18n("Beaming finished!") ); |
1006 | } | 986 | } |
1007 | 987 | ||
1008 | 988 | ||
1009 | void KABCore::browse( const QString& url ) | 989 | void KABCore::browse( const QString& url ) |
1010 | { | 990 | { |
1011 | #ifndef KAB_EMBEDDED | 991 | #ifndef KAB_EMBEDDED |
1012 | kapp->invokeBrowser( url ); | 992 | kapp->invokeBrowser( url ); |
1013 | #else //KAB_EMBEDDED | 993 | #else //KAB_EMBEDDED |
1014 | qDebug("KABCore::browse must be fixed"); | 994 | qDebug("KABCore::browse must be fixed"); |
1015 | #endif //KAB_EMBEDDED | 995 | #endif //KAB_EMBEDDED |
1016 | } | 996 | } |
1017 | 997 | ||
1018 | void KABCore::selectAllContacts() | 998 | void KABCore::selectAllContacts() |
1019 | { | 999 | { |
1020 | mViewManager->setSelected( QString::null, true ); | 1000 | mViewManager->setSelected( QString::null, true ); |
1021 | } | 1001 | } |
1022 | 1002 | ||
1023 | void KABCore::deleteContacts() | 1003 | void KABCore::deleteContacts() |
1024 | { | 1004 | { |
1025 | QStringList uidList = mViewManager->selectedUids(); | 1005 | QStringList uidList = mViewManager->selectedUids(); |
1026 | deleteContacts( uidList ); | 1006 | deleteContacts( uidList ); |
1027 | } | 1007 | } |
1028 | 1008 | ||
1029 | void KABCore::deleteContacts( const QStringList &uids ) | 1009 | void KABCore::deleteContacts( const QStringList &uids ) |
1030 | { | 1010 | { |
1031 | if ( uids.count() > 0 ) { | 1011 | if ( uids.count() > 0 ) { |
1032 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 1012 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
1033 | UndoStack::instance()->push( command ); | 1013 | UndoStack::instance()->push( command ); |
1034 | RedoStack::instance()->clear(); | 1014 | RedoStack::instance()->clear(); |
1035 | 1015 | ||
1036 | // now if we deleted anything, refresh | 1016 | // now if we deleted anything, refresh |
1037 | setContactSelected( QString::null ); | 1017 | setContactSelected( QString::null ); |
1038 | setModified( true ); | 1018 | setModified( true ); |
1039 | } | 1019 | } |
1040 | } | 1020 | } |
1041 | 1021 | ||
1042 | void KABCore::copyContacts() | 1022 | void KABCore::copyContacts() |
1043 | { | 1023 | { |
1044 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1024 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1045 | 1025 | ||
1046 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 1026 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
1047 | 1027 | ||
1048 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 1028 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
1049 | 1029 | ||
1050 | QClipboard *cb = QApplication::clipboard(); | 1030 | QClipboard *cb = QApplication::clipboard(); |
1051 | cb->setText( clipText ); | 1031 | cb->setText( clipText ); |
1052 | } | 1032 | } |
1053 | 1033 | ||
1054 | void KABCore::cutContacts() | 1034 | void KABCore::cutContacts() |
1055 | { | 1035 | { |
1056 | QStringList uidList = mViewManager->selectedUids(); | 1036 | QStringList uidList = mViewManager->selectedUids(); |
1057 | 1037 | ||
1058 | //US if ( uidList.size() > 0 ) { | 1038 | //US if ( uidList.size() > 0 ) { |
1059 | if ( uidList.count() > 0 ) { | 1039 | if ( uidList.count() > 0 ) { |
1060 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 1040 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
1061 | UndoStack::instance()->push( command ); | 1041 | UndoStack::instance()->push( command ); |
1062 | RedoStack::instance()->clear(); | 1042 | RedoStack::instance()->clear(); |
1063 | 1043 | ||
1064 | setModified( true ); | 1044 | setModified( true ); |
1065 | } | 1045 | } |
1066 | } | 1046 | } |
1067 | 1047 | ||
1068 | void KABCore::pasteContacts() | 1048 | void KABCore::pasteContacts() |
1069 | { | 1049 | { |
1070 | QClipboard *cb = QApplication::clipboard(); | 1050 | QClipboard *cb = QApplication::clipboard(); |
1071 | 1051 | ||
1072 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 1052 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
1073 | 1053 | ||
1074 | pasteContacts( list ); | 1054 | pasteContacts( list ); |
1075 | } | 1055 | } |
1076 | 1056 | ||
1077 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1057 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1078 | { | 1058 | { |
1079 | KABC::Resource *resource = requestResource( this ); | 1059 | KABC::Resource *resource = requestResource( this ); |
1080 | KABC::Addressee::List::Iterator it; | 1060 | KABC::Addressee::List::Iterator it; |
1081 | for ( it = list.begin(); it != list.end(); ++it ) | 1061 | for ( it = list.begin(); it != list.end(); ++it ) |
1082 | (*it).setResource( resource ); | 1062 | (*it).setResource( resource ); |
1083 | 1063 | ||
1084 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1064 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1085 | UndoStack::instance()->push( command ); | 1065 | UndoStack::instance()->push( command ); |
1086 | RedoStack::instance()->clear(); | 1066 | RedoStack::instance()->clear(); |
1087 | 1067 | ||
1088 | setModified( true ); | 1068 | setModified( true ); |
1089 | } | 1069 | } |
1090 | 1070 | ||
1091 | void KABCore::setWhoAmI() | 1071 | void KABCore::setWhoAmI() |
1092 | { | 1072 | { |
1093 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1073 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1094 | 1074 | ||
1095 | if ( addrList.count() > 1 ) { | 1075 | if ( addrList.count() > 1 ) { |
1096 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1076 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1097 | return; | 1077 | return; |
1098 | } | 1078 | } |
1099 | 1079 | ||
1100 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1080 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1101 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 1081 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
1102 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1082 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1103 | } | 1083 | } |
1104 | void KABCore::editCategories() | 1084 | void KABCore::editCategories() |
1105 | { | 1085 | { |
1106 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1086 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1107 | dlg.exec(); | 1087 | dlg.exec(); |
1108 | } | 1088 | } |
1109 | void KABCore::setCategories() | 1089 | void KABCore::setCategories() |
1110 | { | 1090 | { |
1111 | 1091 | ||
1112 | QStringList uids; | 1092 | QStringList uids; |
1113 | XXPortSelectDialog dlgx( this, false, this ); | 1093 | XXPortSelectDialog dlgx( this, false, this ); |
1114 | if ( dlgx.exec() ) | 1094 | if ( dlgx.exec() ) |
1115 | uids = dlgx.uids(); | 1095 | uids = dlgx.uids(); |
1116 | else | 1096 | else |
1117 | return; | 1097 | return; |
1118 | if ( uids.isEmpty() ) | 1098 | if ( uids.isEmpty() ) |
1119 | return; | 1099 | return; |
1120 | // qDebug("count %d ", uids.count()); | 1100 | // qDebug("count %d ", uids.count()); |
1121 | 1101 | ||
1122 | 1102 | ||
1123 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1103 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1124 | if ( !dlg.exec() ) { | 1104 | if ( !dlg.exec() ) { |
1125 | message( i18n("Setting categories cancelled") ); | 1105 | message( i18n("Setting categories cancelled") ); |
1126 | return; | 1106 | return; |
1127 | } | 1107 | } |
1128 | bool merge = false; | 1108 | bool merge = false; |
1129 | QString msg = i18n( "Merge with existing categories?" ); | 1109 | QString msg = i18n( "Merge with existing categories?" ); |
1130 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1110 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1131 | merge = true; | 1111 | merge = true; |
1132 | 1112 | ||
1133 | message( i18n("Setting categories ... please wait!") ); | 1113 | message( i18n("Setting categories ... please wait!") ); |
1134 | QStringList categories = dlg.selectedCategories(); | 1114 | QStringList categories = dlg.selectedCategories(); |
1135 | 1115 | ||
1136 | //QStringList uids = mViewManager->selectedUids(); | 1116 | //QStringList uids = mViewManager->selectedUids(); |
1137 | QStringList::Iterator it; | 1117 | QStringList::Iterator it; |
1138 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1118 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1139 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1119 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1140 | if ( !addr.isEmpty() ) { | 1120 | if ( !addr.isEmpty() ) { |
1141 | if ( !merge ) | 1121 | if ( !merge ) |
1142 | addr.setCategories( categories ); | 1122 | addr.setCategories( categories ); |
1143 | else { | 1123 | else { |
1144 | QStringList addrCategories = addr.categories(); | 1124 | QStringList addrCategories = addr.categories(); |
1145 | QStringList::Iterator catIt; | 1125 | QStringList::Iterator catIt; |
1146 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1126 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1147 | if ( !addrCategories.contains( *catIt ) ) | 1127 | if ( !addrCategories.contains( *catIt ) ) |
1148 | addrCategories.append( *catIt ); | 1128 | addrCategories.append( *catIt ); |
1149 | } | 1129 | } |
1150 | addr.setCategories( addrCategories ); | 1130 | addr.setCategories( addrCategories ); |
1151 | } | 1131 | } |
1152 | mAddressBook->insertAddressee( addr ); | 1132 | mAddressBook->insertAddressee( addr ); |
1153 | } | 1133 | } |
1154 | } | 1134 | } |
1155 | 1135 | ||
1156 | if ( uids.count() > 0 ) | 1136 | if ( uids.count() > 0 ) |
1157 | setModified( true ); | 1137 | setModified( true ); |
1158 | message( i18n("Setting categories completed!") ); | 1138 | message( i18n("Setting categories completed!") ); |
1159 | } | 1139 | } |
1160 | 1140 | ||
1161 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1141 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1162 | { | 1142 | { |
1163 | mIncSearchWidget->setFields( fields ); | 1143 | mIncSearchWidget->setFields( fields ); |
1164 | } | 1144 | } |
1165 | 1145 | ||
1166 | void KABCore::incrementalSearch( const QString& text ) | 1146 | void KABCore::incrementalSearch( const QString& text ) |
1167 | { | 1147 | { |
1168 | QString stext; | 1148 | QString stext; |
1169 | if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { | 1149 | if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { |
1170 | stext = "*" + text; | 1150 | stext = "*" + text; |
1171 | } else { | 1151 | } else { |
1172 | stext = text; | 1152 | stext = text; |
1173 | } | 1153 | } |
1174 | mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); | 1154 | mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); |
1175 | } | 1155 | } |
1176 | void KABCore::incrementalSearchJump( const QString& text ) | 1156 | void KABCore::incrementalSearchJump( const QString& text ) |
1177 | { | 1157 | { |
1178 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1158 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1179 | } | 1159 | } |
1180 | 1160 | ||
1181 | void KABCore::setModified() | 1161 | void KABCore::setModified() |
1182 | { | 1162 | { |
1183 | setModified( true ); | 1163 | setModified( true ); |
1184 | } | 1164 | } |
1185 | 1165 | ||
1186 | void KABCore::setModifiedWOrefresh() | 1166 | void KABCore::setModifiedWOrefresh() |
1187 | { | 1167 | { |
1188 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1168 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1189 | mModified = true; | 1169 | mModified = true; |
1190 | mActionSave->setEnabled( mModified ); | 1170 | mActionSave->setEnabled( mModified ); |
1191 | 1171 | ||
1192 | 1172 | ||
1193 | } | 1173 | } |
1194 | void KABCore::setModified( bool modified ) | 1174 | void KABCore::setModified( bool modified ) |
1195 | { | 1175 | { |
1196 | mModified = modified; | 1176 | mModified = modified; |
1197 | mActionSave->setEnabled( mModified ); | 1177 | mActionSave->setEnabled( mModified ); |
1198 | 1178 | ||
1199 | if ( modified ) | 1179 | if ( modified ) |
1200 | mJumpButtonBar->recreateButtons(); | 1180 | mJumpButtonBar->recreateButtons(); |
1201 | 1181 | ||
1202 | mViewManager->refreshView(); | 1182 | mViewManager->refreshView(); |
1203 | 1183 | ||
1204 | } | 1184 | } |
1205 | 1185 | ||
1206 | bool KABCore::modified() const | 1186 | bool KABCore::modified() const |
1207 | { | 1187 | { |
1208 | return mModified; | 1188 | return mModified; |
1209 | } | 1189 | } |
1210 | 1190 | ||
1211 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1191 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1212 | { | 1192 | { |
1213 | addrModified( addr ); | 1193 | addrModified( addr ); |
1214 | #if 0 // debug only | 1194 | #if 0 // debug only |
1215 | KABC::Addressee ad = addr; | 1195 | KABC::Addressee ad = addr; |
1216 | ad.computeCsum( "123"); | 1196 | ad.computeCsum( "123"); |
1217 | #endif | 1197 | #endif |
1218 | } | 1198 | } |
1219 | 1199 | ||
1220 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1200 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1221 | { | 1201 | { |
1222 | 1202 | ||
1223 | Command *command = 0; | 1203 | Command *command = 0; |
1224 | QString uid; | 1204 | QString uid; |
1225 | 1205 | ||
1226 | // check if it exists already | 1206 | // check if it exists already |
1227 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1207 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1228 | if ( origAddr.isEmpty() ) | 1208 | if ( origAddr.isEmpty() ) |
1229 | command = new PwNewCommand( mAddressBook, addr ); | 1209 | command = new PwNewCommand( mAddressBook, addr ); |
1230 | else { | 1210 | else { |
1231 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1211 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1232 | uid = addr.uid(); | 1212 | uid = addr.uid(); |
1233 | } | 1213 | } |
1234 | 1214 | ||
1235 | UndoStack::instance()->push( command ); | 1215 | UndoStack::instance()->push( command ); |
1236 | RedoStack::instance()->clear(); | 1216 | RedoStack::instance()->clear(); |
1237 | if ( updateDetails ) | 1217 | if ( updateDetails ) |
1238 | mDetails->setAddressee( addr ); | 1218 | mDetails->setAddressee( addr ); |
1239 | setModified( true ); | 1219 | setModified( true ); |
1240 | } | 1220 | } |
1241 | 1221 | ||
1242 | void KABCore::newContact() | 1222 | void KABCore::newContact() |
1243 | { | 1223 | { |
1244 | 1224 | ||
1245 | 1225 | ||
1246 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1226 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1247 | 1227 | ||
1248 | QPtrList<KRES::Resource> kresResources; | 1228 | QPtrList<KRES::Resource> kresResources; |
1249 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1229 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1250 | KABC::Resource *resource; | 1230 | KABC::Resource *resource; |
1251 | while ( ( resource = it.current() ) != 0 ) { | 1231 | while ( ( resource = it.current() ) != 0 ) { |
1252 | ++it; | 1232 | ++it; |
1253 | if ( !resource->readOnly() ) { | 1233 | if ( !resource->readOnly() ) { |
1254 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1234 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1255 | if ( res ) | 1235 | if ( res ) |
1256 | kresResources.append( res ); | 1236 | kresResources.append( res ); |
1257 | } | 1237 | } |
1258 | } | 1238 | } |
1259 | 1239 | ||
1260 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1240 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1261 | resource = static_cast<KABC::Resource*>( res ); | 1241 | resource = static_cast<KABC::Resource*>( res ); |
1262 | 1242 | ||
1263 | if ( resource ) { | 1243 | if ( resource ) { |
1264 | KABC::Addressee addr; | 1244 | KABC::Addressee addr; |
1265 | addr.setResource( resource ); | 1245 | addr.setResource( resource ); |
1266 | mEditorDialog->setAddressee( addr ); | 1246 | mEditorDialog->setAddressee( addr ); |
1267 | mEditorDialog->setCaption( i18n("Edit new contact")); | 1247 | mEditorDialog->setCaption( i18n("Edit new contact")); |
1268 | KApplication::execDialog ( mEditorDialog ); | 1248 | KApplication::execDialog ( mEditorDialog ); |
1269 | 1249 | ||
1270 | } else | 1250 | } else |
1271 | return; | 1251 | return; |
1272 | 1252 | ||
1273 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1253 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1274 | 1254 | ||
1275 | 1255 | ||
1276 | } | 1256 | } |
1277 | 1257 | ||
1278 | void KABCore::addEmail( QString aStr ) | 1258 | void KABCore::addEmail( QString aStr ) |
1279 | { | 1259 | { |
1280 | #ifndef KAB_EMBEDDED | 1260 | #ifndef KAB_EMBEDDED |
1281 | QString fullName, email; | 1261 | QString fullName, email; |
1282 | 1262 | ||
1283 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1263 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1284 | 1264 | ||
1285 | // Try to lookup the addressee matching the email address | 1265 | // Try to lookup the addressee matching the email address |
1286 | bool found = false; | 1266 | bool found = false; |
1287 | QStringList emailList; | 1267 | QStringList emailList; |
1288 | KABC::AddressBook::Iterator it; | 1268 | KABC::AddressBook::Iterator it; |
1289 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1269 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1290 | emailList = (*it).emails(); | 1270 | emailList = (*it).emails(); |
1291 | if ( emailList.contains( email ) > 0 ) { | 1271 | if ( emailList.contains( email ) > 0 ) { |
1292 | found = true; | 1272 | found = true; |
1293 | (*it).setNameFromString( fullName ); | 1273 | (*it).setNameFromString( fullName ); |
1294 | editContact( (*it).uid() ); | 1274 | editContact( (*it).uid() ); |
1295 | } | 1275 | } |
1296 | } | 1276 | } |
1297 | 1277 | ||
1298 | if ( !found ) { | 1278 | if ( !found ) { |
1299 | KABC::Addressee addr; | 1279 | KABC::Addressee addr; |
1300 | addr.setNameFromString( fullName ); | 1280 | addr.setNameFromString( fullName ); |
1301 | addr.insertEmail( email, true ); | 1281 | addr.insertEmail( email, true ); |
1302 | 1282 | ||
1303 | mAddressBook->insertAddressee( addr ); | 1283 | mAddressBook->insertAddressee( addr ); |
1304 | mViewManager->refreshView( addr.uid() ); | 1284 | mViewManager->refreshView( addr.uid() ); |
1305 | editContact( addr.uid() ); | 1285 | editContact( addr.uid() ); |
1306 | } | 1286 | } |
1307 | #else //KAB_EMBEDDED | 1287 | #else //KAB_EMBEDDED |
1308 | qDebug("KABCore::addEmail finsih method"); | 1288 | qDebug("KABCore::addEmail finsih method"); |
1309 | #endif //KAB_EMBEDDED | 1289 | #endif //KAB_EMBEDDED |
1310 | } | 1290 | } |
1311 | 1291 | ||
1312 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1292 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1313 | { | 1293 | { |
1314 | mXXPortManager->importVCard( url, showPreview ); | 1294 | mXXPortManager->importVCard( url, showPreview ); |
1315 | } | 1295 | } |
1316 | void KABCore::importFromOL() | 1296 | void KABCore::importFromOL() |
1317 | { | 1297 | { |
1318 | #ifdef _OL_IMPORT_ | 1298 | #ifdef _OL_IMPORT_ |
1319 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1299 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1320 | idgl->exec(); | 1300 | idgl->exec(); |
1321 | KABC::Addressee::List list = idgl->getAddressList(); | 1301 | KABC::Addressee::List list = idgl->getAddressList(); |
1322 | if ( list.count() > 0 ) { | 1302 | if ( list.count() > 0 ) { |
1323 | KABC::Addressee::List listNew; | 1303 | KABC::Addressee::List listNew; |
1324 | KABC::Addressee::List listExisting; | 1304 | KABC::Addressee::List listExisting; |
1325 | KABC::Addressee::List::Iterator it; | 1305 | KABC::Addressee::List::Iterator it; |
1326 | KABC::AddressBook::Iterator iter; | 1306 | KABC::AddressBook::Iterator iter; |
1327 | for ( it = list.begin(); it != list.end(); ++it ) { | 1307 | for ( it = list.begin(); it != list.end(); ++it ) { |
1328 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1308 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1329 | listNew.append( (*it) ); | 1309 | listNew.append( (*it) ); |
1330 | else | 1310 | else |
1331 | listExisting.append( (*it) ); | 1311 | listExisting.append( (*it) ); |
1332 | } | 1312 | } |
1333 | if ( listExisting.count() > 0 ) | 1313 | if ( listExisting.count() > 0 ) |
1334 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1314 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1335 | if ( listNew.count() > 0 ) { | 1315 | if ( listNew.count() > 0 ) { |
1336 | pasteWithNewUid = false; | 1316 | pasteWithNewUid = false; |
1337 | pasteContacts( listNew ); | 1317 | pasteContacts( listNew ); |
1338 | pasteWithNewUid = true; | 1318 | pasteWithNewUid = true; |
1339 | } | 1319 | } |
1340 | } | 1320 | } |
1341 | delete idgl; | 1321 | delete idgl; |
1342 | #endif | 1322 | #endif |
1343 | } | 1323 | } |
1344 | 1324 | ||
1345 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1325 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1346 | { | 1326 | { |
1347 | mXXPortManager->importVCard( vCard, showPreview ); | 1327 | mXXPortManager->importVCard( vCard, showPreview ); |
1348 | } | 1328 | } |
1349 | 1329 | ||
1350 | //US added a second method without defaultparameter | 1330 | //US added a second method without defaultparameter |
1351 | void KABCore::editContact2() { | 1331 | void KABCore::editContact2() { |
1352 | editContact( QString::null ); | 1332 | editContact( QString::null ); |
1353 | } | 1333 | } |
1354 | 1334 | ||
1355 | void KABCore::editContact( const QString &uid ) | 1335 | void KABCore::editContact( const QString &uid ) |
1356 | { | 1336 | { |
1357 | 1337 | ||
1358 | if ( mExtensionManager->isQuickEditVisible() ) | 1338 | if ( mExtensionManager->isQuickEditVisible() ) |
1359 | return; | 1339 | return; |
1360 | 1340 | ||
1361 | // First, locate the contact entry | 1341 | // First, locate the contact entry |
1362 | QString localUID = uid; | 1342 | QString localUID = uid; |
1363 | if ( localUID.isNull() ) { | 1343 | if ( localUID.isNull() ) { |
1364 | QStringList uidList = mViewManager->selectedUids(); | 1344 | QStringList uidList = mViewManager->selectedUids(); |
1365 | if ( uidList.count() > 0 ) | 1345 | if ( uidList.count() > 0 ) |
1366 | localUID = *( uidList.at( 0 ) ); | 1346 | localUID = *( uidList.at( 0 ) ); |
1367 | } | 1347 | } |
1368 | 1348 | ||
1369 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1349 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1370 | if ( !addr.isEmpty() ) { | 1350 | if ( !addr.isEmpty() ) { |
1371 | mEditorDialog->setAddressee( addr ); | 1351 | mEditorDialog->setAddressee( addr ); |
1372 | KApplication::execDialog ( mEditorDialog ); | 1352 | KApplication::execDialog ( mEditorDialog ); |
1373 | } | 1353 | } |
1374 | } | 1354 | } |
1375 | 1355 | ||
1376 | /** | 1356 | /** |
1377 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1357 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1378 | the method will try to find a selected addressee in the view. | 1358 | the method will try to find a selected addressee in the view. |
1379 | */ | 1359 | */ |
1380 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1360 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1381 | { | 1361 | { |
1382 | if ( mMultipleViewsAtOnce ) | 1362 | if ( mMultipleViewsAtOnce ) |
1383 | { | 1363 | { |
1384 | editContact( uid ); | 1364 | editContact( uid ); |
1385 | } | 1365 | } |
1386 | else | 1366 | else |
1387 | { | 1367 | { |
1388 | setDetailsVisible( true ); | 1368 | setDetailsVisible( true ); |
1389 | mActionDetails->setChecked(true); | 1369 | mActionDetails->setChecked(true); |
1390 | } | 1370 | } |
1391 | 1371 | ||
1392 | } | 1372 | } |
1393 | 1373 | ||
1394 | void KABCore::save() | 1374 | void KABCore::save() |
1395 | { | 1375 | { |
1396 | if (syncManager->blockSave()) | 1376 | if (syncManager->blockSave()) |
1397 | return; | 1377 | return; |
1398 | if ( !mModified ) | 1378 | if ( !mModified ) |
1399 | return; | 1379 | return; |
1400 | 1380 | ||
1401 | syncManager->setBlockSave(true); | 1381 | syncManager->setBlockSave(true); |
1402 | QString text = i18n( "There was an error while attempting to save\n the " | 1382 | QString text = i18n( "There was an error while attempting to save\n the " |
1403 | "address book. Please check that some \nother application is " | 1383 | "address book. Please check that some \nother application is " |
1404 | "not using it. " ); | 1384 | "not using it. " ); |
1405 | message(i18n("Saving ... please wait! "), false); | 1385 | message(i18n("Saving ... please wait! "), false); |
1406 | //qApp->processEvents(); | 1386 | //qApp->processEvents(); |
1407 | #ifndef KAB_EMBEDDED | 1387 | #ifndef KAB_EMBEDDED |
1408 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1388 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1409 | if ( !b || !b->save() ) { | 1389 | if ( !b || !b->save() ) { |
1410 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1390 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1411 | } | 1391 | } |
1412 | #else //KAB_EMBEDDED | 1392 | #else //KAB_EMBEDDED |
1413 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1393 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1414 | if ( !b || !b->save() ) { | 1394 | if ( !b || !b->save() ) { |
1415 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1395 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1416 | } | 1396 | } |
1417 | #endif //KAB_EMBEDDED | 1397 | #endif //KAB_EMBEDDED |
1418 | 1398 | ||
1419 | message(i18n("Addressbook saved!")); | 1399 | message(i18n("Addressbook saved!")); |
1420 | setModified( false ); | 1400 | setModified( false ); |
1421 | syncManager->setBlockSave(false); | 1401 | syncManager->setBlockSave(false); |
1422 | } | 1402 | } |
1423 | 1403 | ||
1424 | 1404 | ||
1425 | void KABCore::undo() | 1405 | void KABCore::undo() |
1426 | { | 1406 | { |
1427 | UndoStack::instance()->undo(); | 1407 | UndoStack::instance()->undo(); |
1428 | 1408 | ||
1429 | // Refresh the view | 1409 | // Refresh the view |
1430 | mViewManager->refreshView(); | 1410 | mViewManager->refreshView(); |
1431 | } | 1411 | } |
1432 | 1412 | ||
1433 | void KABCore::redo() | 1413 | void KABCore::redo() |
1434 | { | 1414 | { |
1435 | RedoStack::instance()->redo(); | 1415 | RedoStack::instance()->redo(); |
1436 | 1416 | ||
1437 | // Refresh the view | 1417 | // Refresh the view |
1438 | mViewManager->refreshView(); | 1418 | mViewManager->refreshView(); |
1439 | } | 1419 | } |
1440 | void KABCore::setJumpButtonBar( bool visible ) | 1420 | void KABCore::setJumpButtonBar( bool visible ) |
1441 | { | 1421 | { |
1442 | setJumpButtonBarVisible(visible ); | 1422 | setJumpButtonBarVisible(visible ); |
1443 | saveSettings(); | 1423 | saveSettings(); |
1444 | } | 1424 | } |
1445 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1425 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1446 | { | 1426 | { |
1447 | if (mMultipleViewsAtOnce) | 1427 | if (mMultipleViewsAtOnce) |
1448 | { | 1428 | { |
1449 | if ( visible ) | 1429 | if ( visible ) |
1450 | mJumpButtonBar->show(); | 1430 | mJumpButtonBar->show(); |
1451 | else | 1431 | else |
1452 | mJumpButtonBar->hide(); | 1432 | mJumpButtonBar->hide(); |
1453 | } | 1433 | } |
1454 | else | 1434 | else |
1455 | { | 1435 | { |
1456 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1436 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1457 | if (mViewManager->isVisible()) | 1437 | if (mViewManager->isVisible()) |
1458 | { | 1438 | { |
1459 | if ( visible ) | 1439 | if ( visible ) |
1460 | mJumpButtonBar->show(); | 1440 | mJumpButtonBar->show(); |
1461 | else | 1441 | else |
1462 | mJumpButtonBar->hide(); | 1442 | mJumpButtonBar->hide(); |
1463 | } | 1443 | } |
1464 | else | 1444 | else |
1465 | { | 1445 | { |
1466 | mJumpButtonBar->hide(); | 1446 | mJumpButtonBar->hide(); |
1467 | } | 1447 | } |
1468 | } | 1448 | } |
1469 | if ( visible ) { | 1449 | if ( visible ) { |
1470 | if ( mIncSearchWidget->currentItem() == 0 ) { | 1450 | if ( mIncSearchWidget->currentItem() == 0 ) { |
1471 | message( i18n("Change search field enable jump bar") ); | 1451 | message( i18n("Change search field enable jump bar") ); |
1472 | } | 1452 | } |
1473 | } | 1453 | } |
1474 | } | 1454 | } |
1475 | 1455 | ||
1476 | 1456 | ||
1477 | void KABCore::setDetailsToState() | 1457 | void KABCore::setDetailsToState() |
1478 | { | 1458 | { |
1479 | setDetailsVisible( mActionDetails->isChecked() ); | 1459 | setDetailsVisible( mActionDetails->isChecked() ); |
1480 | } | 1460 | } |
1481 | void KABCore::setDetailsToggle() | 1461 | void KABCore::setDetailsToggle() |
1482 | { | 1462 | { |
1483 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1463 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1484 | setDetailsToState(); | 1464 | setDetailsToState(); |
1485 | } | 1465 | } |
1486 | 1466 | ||
1487 | 1467 | ||
1488 | 1468 | ||
1489 | void KABCore::setDetailsVisible( bool visible ) | 1469 | void KABCore::setDetailsVisible( bool visible ) |
1490 | { | 1470 | { |
1491 | if (visible && mDetails->isHidden()) | 1471 | if (visible && mDetails->isHidden()) |
1492 | { | 1472 | { |
1493 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1473 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1494 | if ( addrList.count() > 0 ) | 1474 | if ( addrList.count() > 0 ) |
1495 | mDetails->setAddressee( addrList[ 0 ] ); | 1475 | mDetails->setAddressee( addrList[ 0 ] ); |
1496 | } | 1476 | } |
1497 | 1477 | ||
1498 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1478 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1499 | // the listview and the detailview. We do that by changing the splitbar size. | 1479 | // the listview and the detailview. We do that by changing the splitbar size. |
1500 | if (mMultipleViewsAtOnce) | 1480 | if (mMultipleViewsAtOnce) |
1501 | { | 1481 | { |
1502 | if ( visible ) | 1482 | if ( visible ) |
1503 | mDetails->show(); | 1483 | mDetails->show(); |
1504 | else | 1484 | else |
1505 | mDetails->hide(); | 1485 | mDetails->hide(); |
1506 | } | 1486 | } |
1507 | else | 1487 | else |
1508 | { | 1488 | { |
1509 | if ( visible ) { | 1489 | if ( visible ) { |
1510 | mViewManager->hide(); | 1490 | mViewManager->hide(); |
1511 | mDetails->show(); | 1491 | mDetails->show(); |
1512 | mIncSearchWidget->setFocus(); | 1492 | mIncSearchWidget->setFocus(); |
1513 | } | 1493 | } |
1514 | else { | 1494 | else { |
1515 | mViewManager->show(); | 1495 | mViewManager->show(); |
1516 | mDetails->hide(); | 1496 | mDetails->hide(); |
1517 | mViewManager->setFocusAV(); | 1497 | mViewManager->setFocusAV(); |
1518 | } | 1498 | } |
1519 | setJumpButtonBarVisible( !visible ); | 1499 | setJumpButtonBarVisible( !visible ); |
1520 | } | 1500 | } |
1521 | 1501 | ||
1522 | } | 1502 | } |
1523 | 1503 | ||
1524 | void KABCore::extensionChanged( int id ) | 1504 | void KABCore::extensionChanged( int id ) |
1525 | { | 1505 | { |
1526 | //change the details view only for non desktop systems | 1506 | //change the details view only for non desktop systems |
1527 | #ifndef DESKTOP_VERSION | 1507 | #ifndef DESKTOP_VERSION |
1528 | 1508 | ||
1529 | if (id == 0) | 1509 | if (id == 0) |
1530 | { | 1510 | { |
1531 | //the user disabled the extension. | 1511 | //the user disabled the extension. |
1532 | 1512 | ||
1533 | if (mMultipleViewsAtOnce) | 1513 | if (mMultipleViewsAtOnce) |
1534 | { // enable detailsview again | 1514 | { // enable detailsview again |
1535 | setDetailsVisible( true ); | 1515 | setDetailsVisible( true ); |
1536 | mActionDetails->setChecked( true ); | 1516 | mActionDetails->setChecked( true ); |
1537 | } | 1517 | } |
1538 | else | 1518 | else |
1539 | { //go back to the listview | 1519 | { //go back to the listview |
1540 | setDetailsVisible( false ); | 1520 | setDetailsVisible( false ); |
1541 | mActionDetails->setChecked( false ); | 1521 | mActionDetails->setChecked( false ); |
1542 | mActionDetails->setEnabled(true); | 1522 | mActionDetails->setEnabled(true); |
1543 | } | 1523 | } |
1544 | 1524 | ||
1545 | } | 1525 | } |
1546 | else | 1526 | else |
1547 | { | 1527 | { |
1548 | //the user enabled the extension. | 1528 | //the user enabled the extension. |
1549 | setDetailsVisible( false ); | 1529 | setDetailsVisible( false ); |
1550 | mActionDetails->setChecked( false ); | 1530 | mActionDetails->setChecked( false ); |
1551 | 1531 | ||
1552 | if (!mMultipleViewsAtOnce) | 1532 | if (!mMultipleViewsAtOnce) |
1553 | { | 1533 | { |
1554 | mActionDetails->setEnabled(false); | 1534 | mActionDetails->setEnabled(false); |
1555 | } | 1535 | } |
1556 | 1536 | ||
1557 | mExtensionManager->setSelectionChanged(); | 1537 | mExtensionManager->setSelectionChanged(); |
1558 | 1538 | ||
1559 | } | 1539 | } |
1560 | 1540 | ||
1561 | #endif// DESKTOP_VERSION | 1541 | #endif// DESKTOP_VERSION |
1562 | 1542 | ||
1563 | } | 1543 | } |
1564 | 1544 | ||
1565 | 1545 | ||
1566 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1546 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1567 | { | 1547 | { |
1568 | 1548 | ||
1569 | if ( list.count() != 0 ) { | 1549 | if ( list.count() != 0 ) { |
1570 | KABC::Addressee::List::ConstIterator it; | 1550 | KABC::Addressee::List::ConstIterator it; |
1571 | for ( it = list.begin(); it != list.end(); ++it ) | 1551 | for ( it = list.begin(); it != list.end(); ++it ) |
1572 | mAddressBook->insertAddressee( *it ); | 1552 | mAddressBook->insertAddressee( *it ); |
1573 | if ( list.count() > 1 ) | 1553 | if ( list.count() > 1 ) |
1574 | setModified(); | 1554 | setModified(); |
1575 | else | 1555 | else |
1576 | setModifiedWOrefresh(); | 1556 | setModifiedWOrefresh(); |
1577 | } | 1557 | } |
1578 | if ( list.count() == 0 ) | 1558 | if ( list.count() == 0 ) |
1579 | mViewManager->refreshView(); | 1559 | mViewManager->refreshView(); |
1580 | else | 1560 | else |
1581 | mViewManager->refreshView( list[ 0 ].uid() ); | 1561 | mViewManager->refreshView( list[ 0 ].uid() ); |
1582 | 1562 | ||
1583 | 1563 | ||
1584 | 1564 | ||
1585 | } | 1565 | } |
1586 | 1566 | ||
1587 | QString KABCore::getNameByPhone( const QString &phone ) | 1567 | QString KABCore::getNameByPhone( const QString &phone ) |
1588 | { | 1568 | { |
1589 | #ifndef KAB_EMBEDDED | 1569 | #ifndef KAB_EMBEDDED |
1590 | QRegExp r( "[/*/-/ ]" ); | 1570 | QRegExp r( "[/*/-/ ]" ); |
1591 | QString localPhone( phone ); | 1571 | QString localPhone( phone ); |
1592 | 1572 | ||
1593 | bool found = false; | 1573 | bool found = false; |
1594 | QString ownerName = ""; | 1574 | QString ownerName = ""; |
1595 | KABC::AddressBook::Iterator iter; | 1575 | KABC::AddressBook::Iterator iter; |
1596 | KABC::PhoneNumber::List::Iterator phoneIter; | 1576 | KABC::PhoneNumber::List::Iterator phoneIter; |
1597 | KABC::PhoneNumber::List phoneList; | 1577 | KABC::PhoneNumber::List phoneList; |
1598 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1578 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1599 | phoneList = (*iter).phoneNumbers(); | 1579 | phoneList = (*iter).phoneNumbers(); |
1600 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1580 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1601 | ++phoneIter) { | 1581 | ++phoneIter) { |
1602 | // Get rid of separator chars so just the numbers are compared. | 1582 | // Get rid of separator chars so just the numbers are compared. |
1603 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1583 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1604 | ownerName = (*iter).formattedName(); | 1584 | ownerName = (*iter).formattedName(); |
1605 | found = true; | 1585 | found = true; |
1606 | } | 1586 | } |
1607 | } | 1587 | } |
1608 | } | 1588 | } |
1609 | 1589 | ||
1610 | return ownerName; | 1590 | return ownerName; |
1611 | #else //KAB_EMBEDDED | 1591 | #else //KAB_EMBEDDED |
1612 | qDebug("KABCore::getNameByPhone finsih method"); | 1592 | qDebug("KABCore::getNameByPhone finsih method"); |
1613 | return ""; | 1593 | return ""; |
1614 | #endif //KAB_EMBEDDED | 1594 | #endif //KAB_EMBEDDED |
1615 | 1595 | ||
1616 | } | 1596 | } |
1617 | 1597 | ||
1618 | void KABCore::openConfigDialog() | 1598 | void KABCore::openConfigDialog() |
1619 | { | 1599 | { |
1620 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1600 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1621 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1601 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1622 | ConfigureDialog->addModule(kabcfg ); | 1602 | ConfigureDialog->addModule(kabcfg ); |
1623 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1603 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1624 | ConfigureDialog->addModule(kdelibcfg ); | 1604 | ConfigureDialog->addModule(kdelibcfg ); |
1625 | 1605 | ||
1626 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1606 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1627 | this, SLOT( configurationChanged() ) ); | 1607 | this, SLOT( configurationChanged() ) ); |
1628 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1608 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1629 | this, SLOT( configurationChanged() ) ); | 1609 | this, SLOT( configurationChanged() ) ); |
1630 | saveSettings(); | 1610 | saveSettings(); |
1631 | #ifndef DESKTOP_VERSION | 1611 | #ifndef DESKTOP_VERSION |
1632 | ConfigureDialog->showMaximized(); | 1612 | ConfigureDialog->showMaximized(); |
1633 | #endif | 1613 | #endif |
1634 | if ( ConfigureDialog->exec() ) | 1614 | if ( ConfigureDialog->exec() ) |
1635 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1615 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1636 | delete ConfigureDialog; | 1616 | delete ConfigureDialog; |
1637 | } | 1617 | } |
1638 | 1618 | ||
1639 | void KABCore::openLDAPDialog() | 1619 | void KABCore::openLDAPDialog() |
1640 | { | 1620 | { |
1641 | #ifndef KAB_EMBEDDED | 1621 | #ifndef KAB_EMBEDDED |
1642 | if ( !mLdapSearchDialog ) { | 1622 | if ( !mLdapSearchDialog ) { |
1643 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1623 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1644 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1624 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1645 | SLOT( refreshView() ) ); | 1625 | SLOT( refreshView() ) ); |
1646 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1626 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1647 | SLOT( setModified() ) ); | 1627 | SLOT( setModified() ) ); |
1648 | } else | 1628 | } else |
1649 | mLdapSearchDialog->restoreSettings(); | 1629 | mLdapSearchDialog->restoreSettings(); |
1650 | 1630 | ||
1651 | if ( mLdapSearchDialog->isOK() ) | 1631 | if ( mLdapSearchDialog->isOK() ) |
1652 | mLdapSearchDialog->exec(); | 1632 | mLdapSearchDialog->exec(); |
1653 | #else //KAB_EMBEDDED | 1633 | #else //KAB_EMBEDDED |
1654 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1634 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1655 | #endif //KAB_EMBEDDED | 1635 | #endif //KAB_EMBEDDED |
1656 | } | 1636 | } |
1657 | 1637 | ||
1658 | void KABCore::print() | 1638 | void KABCore::print() |
1659 | { | 1639 | { |
1660 | #ifndef KAB_EMBEDDED | 1640 | #ifndef KAB_EMBEDDED |
1661 | KPrinter printer; | 1641 | KPrinter printer; |
1662 | if ( !printer.setup( this ) ) | 1642 | if ( !printer.setup( this ) ) |
1663 | return; | 1643 | return; |
1664 | 1644 | ||
1665 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1645 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1666 | mViewManager->selectedUids(), this ); | 1646 | mViewManager->selectedUids(), this ); |
1667 | 1647 | ||
1668 | wizard.exec(); | 1648 | wizard.exec(); |
1669 | #else //KAB_EMBEDDED | 1649 | #else //KAB_EMBEDDED |
1670 | qDebug("KABCore::print() finsih method"); | 1650 | qDebug("KABCore::print() finsih method"); |
1671 | #endif //KAB_EMBEDDED | 1651 | #endif //KAB_EMBEDDED |
1672 | 1652 | ||
1673 | } | 1653 | } |
1674 | 1654 | ||
1675 | 1655 | ||
1676 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1656 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1677 | { | 1657 | { |
1678 | if ( mGUIClient ) | 1658 | if ( mGUIClient ) |
1679 | mGUIClient->insertChildClient( client ); | 1659 | mGUIClient->insertChildClient( client ); |
1680 | else | 1660 | else |
1681 | KMessageBox::error( this, "no KXMLGUICLient"); | 1661 | KMessageBox::error( this, "no KXMLGUICLient"); |
1682 | } | 1662 | } |
1683 | 1663 | ||
1684 | 1664 | ||
1685 | void KABCore::configurationChanged() | 1665 | void KABCore::configurationChanged() |
1686 | { | 1666 | { |
1687 | mExtensionManager->reconfigure(); | 1667 | mExtensionManager->reconfigure(); |
1688 | } | 1668 | } |
1689 | 1669 | ||
1690 | void KABCore::addressBookChanged() | 1670 | void KABCore::addressBookChanged() |
1691 | { | 1671 | { |
1692 | /*US | 1672 | /*US |
1693 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1673 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1694 | while ( it.current() ) { | 1674 | while ( it.current() ) { |
1695 | if ( it.current()->dirty() ) { | 1675 | if ( it.current()->dirty() ) { |
1696 | QString text = i18n( "Data has been changed externally. Unsaved " | 1676 | QString text = i18n( "Data has been changed externally. Unsaved " |
1697 | "changes will be lost." ); | 1677 | "changes will be lost." ); |
1698 | KMessageBox::information( this, text ); | 1678 | KMessageBox::information( this, text ); |
1699 | } | 1679 | } |
1700 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1680 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1701 | ++it; | 1681 | ++it; |
1702 | } | 1682 | } |
1703 | */ | 1683 | */ |
1704 | if (mEditorDialog) | 1684 | if (mEditorDialog) |
1705 | { | 1685 | { |
1706 | if (mEditorDialog->dirty()) | 1686 | if (mEditorDialog->dirty()) |
1707 | { | 1687 | { |
1708 | QString text = i18n( "Data has been changed externally. Unsaved " | 1688 | QString text = i18n( "Data has been changed externally. Unsaved " |
1709 | "changes will be lost." ); | 1689 | "changes will be lost." ); |
1710 | KMessageBox::information( this, text ); | 1690 | KMessageBox::information( this, text ); |
1711 | } | 1691 | } |
1712 | QString currentuid = mEditorDialog->addressee().uid(); | 1692 | QString currentuid = mEditorDialog->addressee().uid(); |
1713 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1693 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1714 | } | 1694 | } |
1715 | mViewManager->refreshView(); | 1695 | mViewManager->refreshView(); |
1716 | 1696 | ||
1717 | 1697 | ||
1718 | } | 1698 | } |
1719 | 1699 | ||
1720 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1700 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1721 | const char *name ) | 1701 | const char *name ) |
1722 | { | 1702 | { |
1723 | 1703 | ||
1724 | if ( mEditorDialog == 0 ) { | 1704 | if ( mEditorDialog == 0 ) { |
1725 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1705 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1726 | name ? name : "editorDialog" ); | 1706 | name ? name : "editorDialog" ); |
1727 | 1707 | ||
1728 | 1708 | ||
1729 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1709 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1730 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1710 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1731 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1711 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1732 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1712 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1733 | } | 1713 | } |
1734 | 1714 | ||
1735 | return mEditorDialog; | 1715 | return mEditorDialog; |
1736 | } | 1716 | } |
1737 | 1717 | ||
1738 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1718 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1739 | { | 1719 | { |
1740 | //mEditorDict.remove( uid ); | 1720 | //mEditorDict.remove( uid ); |
1741 | } | 1721 | } |
1742 | 1722 | ||
1743 | void KABCore::initGUI() | 1723 | void KABCore::initGUI() |
1744 | { | 1724 | { |
1745 | #ifndef KAB_EMBEDDED | 1725 | #ifndef KAB_EMBEDDED |
1746 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1726 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1747 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1727 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1748 | 1728 | ||
1749 | mExtensionBarSplitter = new QSplitter( this ); | 1729 | mExtensionBarSplitter = new QSplitter( this ); |
1750 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1730 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1751 | 1731 | ||
1752 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1732 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1753 | 1733 | ||
1754 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1734 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1755 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1735 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1756 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1736 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1757 | SLOT( incrementalSearch( const QString& ) ) ); | 1737 | SLOT( incrementalSearch( const QString& ) ) ); |
1758 | 1738 | ||
1759 | mViewManager = new ViewManager( this, viewSpace ); | 1739 | mViewManager = new ViewManager( this, viewSpace ); |
1760 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1740 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1761 | 1741 | ||
1762 | mDetails = new ViewContainer( mDetailsSplitter ); | 1742 | mDetails = new ViewContainer( mDetailsSplitter ); |
1763 | 1743 | ||
1764 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1744 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1765 | 1745 | ||
1766 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1746 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1767 | 1747 | ||
1768 | topLayout->addWidget( mExtensionBarSplitter ); | 1748 | topLayout->addWidget( mExtensionBarSplitter ); |
1769 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1749 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1770 | topLayout->addWidget( mJumpButtonBar ); | 1750 | topLayout->addWidget( mJumpButtonBar ); |
1771 | //topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1751 | //topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1772 | 1752 | ||
1773 | mXXPortManager = new XXPortManager( this, this ); | 1753 | mXXPortManager = new XXPortManager( this, this ); |
1774 | 1754 | ||
1775 | #else //KAB_EMBEDDED | 1755 | #else //KAB_EMBEDDED |
1776 | //US initialize viewMenu before settingup viewmanager. | 1756 | //US initialize viewMenu before settingup viewmanager. |
1777 | // Viewmanager needs this menu to plugin submenues. | 1757 | // Viewmanager needs this menu to plugin submenues. |
1778 | viewMenu = new QPopupMenu( this ); | 1758 | viewMenu = new QPopupMenu( this ); |
1779 | settingsMenu = new QPopupMenu( this ); | 1759 | settingsMenu = new QPopupMenu( this ); |
1780 | //filterMenu = new QPopupMenu( this ); | 1760 | //filterMenu = new QPopupMenu( this ); |
1781 | ImportMenu = new QPopupMenu( this ); | 1761 | ImportMenu = new QPopupMenu( this ); |
1782 | ExportMenu = new QPopupMenu( this ); | 1762 | ExportMenu = new QPopupMenu( this ); |
1783 | syncMenu = new QPopupMenu( this ); | 1763 | syncMenu = new QPopupMenu( this ); |
1784 | changeMenu= new QPopupMenu( this ); | 1764 | changeMenu= new QPopupMenu( this ); |
1785 | beamMenu= new QPopupMenu( this ); | 1765 | beamMenu= new QPopupMenu( this ); |
1786 | 1766 | ||
1787 | //US since we have no splitter for the embedded system, setup | 1767 | //US since we have no splitter for the embedded system, setup |
1788 | // a layout with two frames. One left and one right. | 1768 | // a layout with two frames. One left and one right. |
1789 | 1769 | ||
1790 | QBoxLayout *topLayout; | 1770 | QBoxLayout *topLayout; |
1791 | 1771 | ||
1792 | // = new QHBoxLayout( this ); | 1772 | // = new QHBoxLayout( this ); |
1793 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1773 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1794 | 1774 | ||
1795 | // QWidget *mainBox = new QWidget( this ); | 1775 | // QWidget *mainBox = new QWidget( this ); |
1796 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1776 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1797 | 1777 | ||
1798 | #ifdef DESKTOP_VERSION | 1778 | #ifdef DESKTOP_VERSION |
1799 | topLayout = new QHBoxLayout( this ); | 1779 | topLayout = new QHBoxLayout( this ); |
1800 | 1780 | ||
1801 | 1781 | ||
1802 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1782 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1803 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1783 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1804 | 1784 | ||
1805 | topLayout->addWidget(mMiniSplitter ); | 1785 | topLayout->addWidget(mMiniSplitter ); |
1806 | 1786 | ||
1807 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1787 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1808 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1788 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1809 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1789 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1810 | mDetails = new ViewContainer( mMiniSplitter ); | 1790 | mDetails = new ViewContainer( mMiniSplitter ); |
1811 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1791 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1812 | #else | 1792 | #else |
1813 | if ( QApplication::desktop()->width() > 480 ) { | 1793 | if ( QApplication::desktop()->width() > 480 ) { |
1814 | topLayout = new QHBoxLayout( this ); | 1794 | topLayout = new QHBoxLayout( this ); |
1815 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1795 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1816 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1796 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1817 | } else { | 1797 | } else { |
1818 | 1798 | ||
1819 | topLayout = new QHBoxLayout( this ); | 1799 | topLayout = new QHBoxLayout( this ); |
1820 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1800 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1821 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1801 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1822 | } | 1802 | } |
1823 | 1803 | ||
1824 | topLayout->addWidget(mMiniSplitter ); | 1804 | topLayout->addWidget(mMiniSplitter ); |
1825 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1805 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1826 | mDetails = new ViewContainer( mMiniSplitter ); | 1806 | mDetails = new ViewContainer( mMiniSplitter ); |
1827 | 1807 | ||
1828 | 1808 | ||
1829 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1809 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1830 | #endif | 1810 | #endif |
1831 | //eh->hide(); | 1811 | //eh->hide(); |
1832 | // topLayout->addWidget(mExtensionManager ); | 1812 | // topLayout->addWidget(mExtensionManager ); |
1833 | 1813 | ||
1834 | 1814 | ||
1835 | /*US | 1815 | /*US |
1836 | #ifndef KAB_NOSPLITTER | 1816 | #ifndef KAB_NOSPLITTER |
1837 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1817 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1838 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1818 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1839 | topLayout->setSpacing( 10 ); | 1819 | topLayout->setSpacing( 10 ); |
1840 | 1820 | ||
1841 | mDetailsSplitter = new QSplitter( this ); | 1821 | mDetailsSplitter = new QSplitter( this ); |
1842 | 1822 | ||
1843 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1823 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1844 | 1824 | ||
1845 | mViewManager = new ViewManager( this, viewSpace ); | 1825 | mViewManager = new ViewManager( this, viewSpace ); |
1846 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1826 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1847 | 1827 | ||
1848 | mDetails = new ViewContainer( mDetailsSplitter ); | 1828 | mDetails = new ViewContainer( mDetailsSplitter ); |
1849 | 1829 | ||
1850 | topLayout->addWidget( mDetailsSplitter ); | 1830 | topLayout->addWidget( mDetailsSplitter ); |
1851 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1831 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1852 | #else //KAB_NOSPLITTER | 1832 | #else //KAB_NOSPLITTER |
1853 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1833 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1854 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1834 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1855 | topLayout->setSpacing( 10 ); | 1835 | topLayout->setSpacing( 10 ); |
1856 | 1836 | ||
1857 | // mDetailsSplitter = new QSplitter( this ); | 1837 | // mDetailsSplitter = new QSplitter( this ); |
1858 | 1838 | ||
1859 | QVBox *viewSpace = new QVBox( this ); | 1839 | QVBox *viewSpace = new QVBox( this ); |
1860 | 1840 | ||
1861 | mViewManager = new ViewManager( this, viewSpace ); | 1841 | mViewManager = new ViewManager( this, viewSpace ); |
1862 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1842 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1863 | 1843 | ||
1864 | mDetails = new ViewContainer( this ); | 1844 | mDetails = new ViewContainer( this ); |
1865 | 1845 | ||
1866 | topLayout->addWidget( viewSpace ); | 1846 | topLayout->addWidget( viewSpace ); |
1867 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1847 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1868 | topLayout->addWidget( mDetails ); | 1848 | topLayout->addWidget( mDetails ); |
1869 | #endif //KAB_NOSPLITTER | 1849 | #endif //KAB_NOSPLITTER |
1870 | */ | 1850 | */ |
1871 | 1851 | ||
1872 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1852 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1873 | syncManager->setBlockSave(false); | 1853 | syncManager->setBlockSave(false); |
1874 | 1854 | ||
1875 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1855 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1876 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1856 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1877 | QString sync_file = sentSyncFile(); | 1857 | QString sync_file = sentSyncFile(); |
1878 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | 1858 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); |
1879 | syncManager->setDefaultFileName( sync_file ); | 1859 | syncManager->setDefaultFileName( sync_file ); |
1880 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1860 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1881 | 1861 | ||
1882 | #endif //KAB_EMBEDDED | 1862 | #endif //KAB_EMBEDDED |
1883 | initActions(); | 1863 | initActions(); |
1884 | 1864 | ||
1885 | #ifdef KAB_EMBEDDED | 1865 | #ifdef KAB_EMBEDDED |
1886 | addActionsManually(); | 1866 | addActionsManually(); |
1887 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1867 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1888 | mXXPortManager = new XXPortManager( this, this ); | 1868 | mXXPortManager = new XXPortManager( this, this ); |
1889 | 1869 | ||
1890 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1870 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1891 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1871 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1892 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1872 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1893 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1873 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1894 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1874 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1895 | // mIncSearchWidget->hide(); | 1875 | // mIncSearchWidget->hide(); |
1896 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1876 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1897 | SLOT( incrementalSearch( const QString& ) ) ); | 1877 | SLOT( incrementalSearch( const QString& ) ) ); |
1898 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1878 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1899 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1879 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1900 | 1880 | ||
1901 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1881 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1902 | 1882 | ||
1903 | topLayout->addWidget( mJumpButtonBar ); | 1883 | topLayout->addWidget( mJumpButtonBar ); |
1904 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1884 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1905 | 1885 | ||
1906 | // mMainWindow->getIconToolBar()->raise(); | 1886 | // mMainWindow->getIconToolBar()->raise(); |
1907 | 1887 | ||
1908 | #endif //KAB_EMBEDDED | 1888 | #endif //KAB_EMBEDDED |
1909 | 1889 | ||
1910 | } | 1890 | } |
1911 | void KABCore::initActions() | 1891 | void KABCore::initActions() |
1912 | { | 1892 | { |
1913 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1893 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1914 | 1894 | ||
1915 | #ifndef KAB_EMBEDDED | 1895 | #ifndef KAB_EMBEDDED |
1916 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1896 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1917 | SLOT( clipboardDataChanged() ) ); | 1897 | SLOT( clipboardDataChanged() ) ); |
1918 | #endif //KAB_EMBEDDED | 1898 | #endif //KAB_EMBEDDED |
1919 | 1899 | ||
1920 | // file menu | 1900 | // file menu |
1921 | 1901 | ||
1922 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1902 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1923 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1903 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1924 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, | 1904 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, |
1925 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); | 1905 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); |
1926 | 1906 | ||
1927 | 1907 | ||
1928 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, | 1908 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, |
1929 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); | 1909 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); |
1930 | 1910 | ||
1931 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1911 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1932 | SLOT( save() ), actionCollection(), "file_sync" ); | 1912 | SLOT( save() ), actionCollection(), "file_sync" ); |
1933 | 1913 | ||
1934 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1914 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1935 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1915 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1936 | 1916 | ||
1937 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1917 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1938 | this, SLOT( mailVCard() ), | 1918 | this, SLOT( mailVCard() ), |
1939 | actionCollection(), "file_mail_vcard"); | 1919 | actionCollection(), "file_mail_vcard"); |
1940 | 1920 | ||
1941 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 1921 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
1942 | SLOT( export2phone() ), actionCollection(), | 1922 | SLOT( export2phone() ), actionCollection(), |
1943 | "kaddressbook_ex2phone" ); | 1923 | "kaddressbook_ex2phone" ); |
1944 | 1924 | ||
1945 | mActionBeamVCard = 0; | 1925 | mActionBeamVCard = 0; |
1946 | mActionBeam = 0; | 1926 | mActionBeam = 0; |
1947 | 1927 | ||
1948 | #ifndef DESKTOP_VERSION | 1928 | #ifndef DESKTOP_VERSION |
1949 | if ( Ir::supported() ) { | 1929 | if ( Ir::supported() ) { |
1950 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 1930 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
1951 | SLOT( beamVCard() ), actionCollection(), | 1931 | SLOT( beamVCard() ), actionCollection(), |
1952 | "kaddressbook_beam_vcard" ); | 1932 | "kaddressbook_beam_vcard" ); |
1953 | 1933 | ||
1954 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1934 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1955 | SLOT( beamMySelf() ), actionCollection(), | 1935 | SLOT( beamMySelf() ), actionCollection(), |
1956 | "kaddressbook_beam_myself" ); | 1936 | "kaddressbook_beam_myself" ); |
1957 | } | 1937 | } |
1958 | #endif | 1938 | #endif |
1959 | 1939 | ||
1960 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1940 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1961 | this, SLOT( editContact2() ), | 1941 | this, SLOT( editContact2() ), |
1962 | actionCollection(), "file_properties" ); | 1942 | actionCollection(), "file_properties" ); |
1963 | 1943 | ||
1964 | #ifdef KAB_EMBEDDED | 1944 | #ifdef KAB_EMBEDDED |
1965 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1945 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1966 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1946 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1967 | mMainWindow, SLOT( exit() ), | 1947 | mMainWindow, SLOT( exit() ), |
1968 | actionCollection(), "quit" ); | 1948 | actionCollection(), "quit" ); |
1969 | #endif //KAB_EMBEDDED | 1949 | #endif //KAB_EMBEDDED |
1970 | 1950 | ||
1971 | // edit menu | 1951 | // edit menu |
1972 | if ( mIsPart ) { | 1952 | if ( mIsPart ) { |
1973 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1953 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1974 | SLOT( copyContacts() ), actionCollection(), | 1954 | SLOT( copyContacts() ), actionCollection(), |
1975 | "kaddressbook_copy" ); | 1955 | "kaddressbook_copy" ); |
1976 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1956 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1977 | SLOT( cutContacts() ), actionCollection(), | 1957 | SLOT( cutContacts() ), actionCollection(), |
1978 | "kaddressbook_cut" ); | 1958 | "kaddressbook_cut" ); |
1979 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1959 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1980 | SLOT( pasteContacts() ), actionCollection(), | 1960 | SLOT( pasteContacts() ), actionCollection(), |
1981 | "kaddressbook_paste" ); | 1961 | "kaddressbook_paste" ); |
1982 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1962 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1983 | SLOT( selectAllContacts() ), actionCollection(), | 1963 | SLOT( selectAllContacts() ), actionCollection(), |
1984 | "kaddressbook_select_all" ); | 1964 | "kaddressbook_select_all" ); |
1985 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1965 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1986 | SLOT( undo() ), actionCollection(), | 1966 | SLOT( undo() ), actionCollection(), |
1987 | "kaddressbook_undo" ); | 1967 | "kaddressbook_undo" ); |
1988 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1968 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1989 | this, SLOT( redo() ), actionCollection(), | 1969 | this, SLOT( redo() ), actionCollection(), |
1990 | "kaddressbook_redo" ); | 1970 | "kaddressbook_redo" ); |
1991 | } else { | 1971 | } else { |
1992 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1972 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1993 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1973 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1994 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1974 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1995 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1975 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1996 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1976 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1997 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1977 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1998 | } | 1978 | } |
1999 | 1979 | ||
2000 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1980 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
2001 | Key_Delete, this, SLOT( deleteContacts() ), | 1981 | Key_Delete, this, SLOT( deleteContacts() ), |
2002 | actionCollection(), "edit_delete" ); | 1982 | actionCollection(), "edit_delete" ); |
2003 | 1983 | ||
2004 | mActionUndo->setEnabled( false ); | 1984 | mActionUndo->setEnabled( false ); |
2005 | mActionRedo->setEnabled( false ); | 1985 | mActionRedo->setEnabled( false ); |
2006 | 1986 | ||
2007 | // settings menu | 1987 | // settings menu |
2008 | #ifdef KAB_EMBEDDED | 1988 | #ifdef KAB_EMBEDDED |
2009 | //US special menuentry to configure the addressbook resources. On KDE | 1989 | //US special menuentry to configure the addressbook resources. On KDE |
2010 | // you do that through the control center !!! | 1990 | // you do that through the control center !!! |
2011 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1991 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
2012 | SLOT( configureResources() ), actionCollection(), | 1992 | SLOT( configureResources() ), actionCollection(), |
2013 | "kaddressbook_configure_resources" ); | 1993 | "kaddressbook_configure_resources" ); |
2014 | #endif //KAB_EMBEDDED | 1994 | #endif //KAB_EMBEDDED |
2015 | 1995 | ||
2016 | if ( mIsPart ) { | 1996 | if ( mIsPart ) { |
2017 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1997 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
2018 | SLOT( openConfigDialog() ), actionCollection(), | 1998 | SLOT( openConfigDialog() ), actionCollection(), |
2019 | "kaddressbook_configure" ); | 1999 | "kaddressbook_configure" ); |
2020 | 2000 | ||
2021 | //US not implemented yet | 2001 | //US not implemented yet |
2022 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 2002 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
2023 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 2003 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
2024 | // "kaddressbook_configure_shortcuts" ); | 2004 | // "kaddressbook_configure_shortcuts" ); |
2025 | #ifdef KAB_EMBEDDED | 2005 | #ifdef KAB_EMBEDDED |
2026 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 2006 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
2027 | mActionConfigureToolbars->setEnabled( false ); | 2007 | mActionConfigureToolbars->setEnabled( false ); |
2028 | #endif //KAB_EMBEDDED | 2008 | #endif //KAB_EMBEDDED |
2029 | 2009 | ||
2030 | } else { | 2010 | } else { |
2031 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 2011 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
2032 | 2012 | ||
2033 | //US not implemented yet | 2013 | //US not implemented yet |
2034 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 2014 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
2035 | } | 2015 | } |
2036 | 2016 | ||
2037 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 2017 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
2038 | actionCollection(), "options_show_jump_bar" ); | 2018 | actionCollection(), "options_show_jump_bar" ); |
2039 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); | 2019 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); |
2040 | 2020 | ||
2041 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 2021 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
2042 | actionCollection(), "options_show_details" ); | 2022 | actionCollection(), "options_show_details" ); |
2043 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 2023 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
2044 | 2024 | ||
2045 | 2025 | ||
2046 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 2026 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
2047 | SLOT( toggleBeamReceive() ), actionCollection(), | 2027 | SLOT( toggleBeamReceive() ), actionCollection(), |
2048 | "kaddressbook_beam_rec" ); | 2028 | "kaddressbook_beam_rec" ); |
2049 | 2029 | ||
2050 | 2030 | ||
2051 | // misc | 2031 | // misc |
2052 | // only enable LDAP lookup if we can handle the protocol | 2032 | // only enable LDAP lookup if we can handle the protocol |
2053 | #ifndef KAB_EMBEDDED | 2033 | #ifndef KAB_EMBEDDED |
2054 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 2034 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
2055 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 2035 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
2056 | this, SLOT( openLDAPDialog() ), actionCollection(), | 2036 | this, SLOT( openLDAPDialog() ), actionCollection(), |
2057 | "ldap_lookup" ); | 2037 | "ldap_lookup" ); |
2058 | } | 2038 | } |
2059 | #else //KAB_EMBEDDED | 2039 | #else //KAB_EMBEDDED |
2060 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 2040 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
2061 | #endif //KAB_EMBEDDED | 2041 | #endif //KAB_EMBEDDED |
2062 | 2042 | ||
2063 | 2043 | ||
2064 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 2044 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
2065 | SLOT( setWhoAmI() ), actionCollection(), | 2045 | SLOT( setWhoAmI() ), actionCollection(), |
2066 | "set_personal" ); | 2046 | "set_personal" ); |
2067 | 2047 | ||
2068 | 2048 | ||
2069 | mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, | 2049 | mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, |
2070 | SLOT( setCategories() ), actionCollection(), | 2050 | SLOT( setCategories() ), actionCollection(), |
2071 | "edit_set_categories" ); | 2051 | "edit_set_categories" ); |
2072 | mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, | 2052 | mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, |
2073 | SLOT( editCategories() ), actionCollection(), | 2053 | SLOT( editCategories() ), actionCollection(), |
2074 | "edit__categories" ); | 2054 | "edit__categories" ); |
2075 | 2055 | ||
2076 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 2056 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
2077 | SLOT( removeVoice() ), actionCollection(), | 2057 | SLOT( removeVoice() ), actionCollection(), |
2078 | "remove_voice" ); | 2058 | "remove_voice" ); |
2079 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, | 2059 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, |
2080 | SLOT( setFormattedName() ), actionCollection(), | 2060 | SLOT( setFormattedName() ), actionCollection(), |
2081 | "set_formatted" ); | 2061 | "set_formatted" ); |
2082 | 2062 | ||
2083 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2063 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2084 | SLOT( manageCategories() ), actionCollection(), | 2064 | SLOT( manageCategories() ), actionCollection(), |
2085 | "remove_voice" ); | 2065 | "remove_voice" ); |
2086 | 2066 | ||
2087 | 2067 | ||
2088 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2068 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2089 | SLOT( importFromOL() ), actionCollection(), | 2069 | SLOT( importFromOL() ), actionCollection(), |
2090 | "import_OL" ); | 2070 | "import_OL" ); |
2091 | #ifdef KAB_EMBEDDED | 2071 | #ifdef KAB_EMBEDDED |
2092 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2072 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2093 | this, SLOT( showLicence() ), actionCollection(), | 2073 | this, SLOT( showLicence() ), actionCollection(), |
2094 | "licence_about_data" ); | 2074 | "licence_about_data" ); |
2095 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2075 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2096 | this, SLOT( faq() ), actionCollection(), | 2076 | this, SLOT( faq() ), actionCollection(), |
2097 | "faq_about_data" ); | 2077 | "faq_about_data" ); |
2098 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2078 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2099 | this, SLOT( whatsnew() ), actionCollection(), | 2079 | this, SLOT( whatsnew() ), actionCollection(), |
2100 | "wn" ); | 2080 | "wn" ); |
2101 | 2081 | ||
2102 | 2082 | ||
2103 | 2083 | ||
2104 | mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, | 2084 | mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, |
2105 | this, SLOT( storagehowto() ), actionCollection(), | 2085 | this, SLOT( storagehowto() ), actionCollection(), |
2106 | "storage" ); | 2086 | "storage" ); |
2107 | 2087 | ||
2108 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2088 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2109 | this, SLOT( synchowto() ), actionCollection(), | 2089 | this, SLOT( synchowto() ), actionCollection(), |
2110 | "sync" ); | 2090 | "sync" ); |
2111 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2091 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2112 | this, SLOT( kdesynchowto() ), actionCollection(), | 2092 | this, SLOT( kdesynchowto() ), actionCollection(), |
2113 | "kdesync" ); | 2093 | "kdesync" ); |
2114 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2094 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2115 | this, SLOT( multisynchowto() ), actionCollection(), | 2095 | this, SLOT( multisynchowto() ), actionCollection(), |
2116 | "multisync" ); | 2096 | "multisync" ); |
2117 | 2097 | ||
2118 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2098 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2119 | this, SLOT( createAboutData() ), actionCollection(), | 2099 | this, SLOT( createAboutData() ), actionCollection(), |
2120 | "kaddressbook_about_data" ); | 2100 | "kaddressbook_about_data" ); |
2121 | #endif //KAB_EMBEDDED | 2101 | #endif //KAB_EMBEDDED |
2122 | 2102 | ||
2123 | clipboardDataChanged(); | 2103 | clipboardDataChanged(); |
2124 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2104 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2125 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2105 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2126 | } | 2106 | } |
2127 | 2107 | ||
2128 | //US we need this function, to plug all actions into the correct menues. | 2108 | //US we need this function, to plug all actions into the correct menues. |
2129 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2109 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2130 | void KABCore::addActionsManually() | 2110 | void KABCore::addActionsManually() |
2131 | { | 2111 | { |
2132 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2112 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2133 | 2113 | ||
2134 | #ifdef KAB_EMBEDDED | 2114 | #ifdef KAB_EMBEDDED |
2135 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2115 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2136 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2116 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2137 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2117 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2138 | 2118 | ||
2139 | KToolBar* tb = mMainWindow->toolBar(); | 2119 | KToolBar* tb = mMainWindow->toolBar(); |
2140 | mMainWindow->setToolBarsMovable (false ); | 2120 | mMainWindow->setToolBarsMovable (false ); |
2141 | #ifndef DESKTOP_VERSION | 2121 | #ifndef DESKTOP_VERSION |
2142 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2122 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2143 | #endif | 2123 | #endif |
2144 | QMenuBar* mb = mMainWindow->menuBar(); | 2124 | QMenuBar* mb = mMainWindow->menuBar(); |
2145 | 2125 | ||
2146 | //US setup menubar. | 2126 | //US setup menubar. |
2147 | //Disable the following block if you do not want to have a menubar. | 2127 | //Disable the following block if you do not want to have a menubar. |
2148 | mb->insertItem( i18n("&File"), fileMenu ); | 2128 | mb->insertItem( i18n("&File"), fileMenu ); |
2149 | mb->insertItem( i18n("&Edit"), editMenu ); | 2129 | mb->insertItem( i18n("&Edit"), editMenu ); |
2150 | mb->insertItem( i18n("&View"), viewMenu ); | 2130 | mb->insertItem( i18n("&View"), viewMenu ); |
2151 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2131 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2152 | #ifdef DESKTOP_VERSION | 2132 | #ifdef DESKTOP_VERSION |
2153 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2133 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2154 | #else | 2134 | #else |
2155 | mb->insertItem( i18n("Sync"), syncMenu ); | 2135 | mb->insertItem( i18n("Sync"), syncMenu ); |
2156 | #endif | 2136 | #endif |
2157 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2137 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2158 | mb->insertItem( i18n("&Help"), helpMenu ); | 2138 | mb->insertItem( i18n("&Help"), helpMenu ); |
2159 | mIncSearchWidget = new IncSearchWidget( tb ); | 2139 | mIncSearchWidget = new IncSearchWidget( tb ); |
2160 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2140 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2161 | #ifndef DESKTOP_VERSION | 2141 | #ifndef DESKTOP_VERSION |
2162 | } else { | 2142 | } else { |
2163 | //US setup toolbar | 2143 | //US setup toolbar |
2164 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2144 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2165 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2145 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2166 | menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); | 2146 | menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); |
2167 | tb->insertWidget(-1, 0, menuBarTB); | 2147 | tb->insertWidget(-1, 0, menuBarTB); |
2168 | mIncSearchWidget = new IncSearchWidget( tb ); | 2148 | mIncSearchWidget = new IncSearchWidget( tb ); |
2169 | tb->enableMoving(false); | 2149 | tb->enableMoving(false); |
2170 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2150 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2171 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2151 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2172 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2152 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2173 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2153 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2174 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2154 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2175 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2155 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2176 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2156 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2177 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2157 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2178 | if (QApplication::desktop()->width() > 320 ) { | 2158 | if (QApplication::desktop()->width() > 320 ) { |
2179 | // mViewManager->getFilterAction()->plug ( tb); | 2159 | // mViewManager->getFilterAction()->plug ( tb); |
2180 | } | 2160 | } |
2181 | } | 2161 | } |
2182 | #endif | 2162 | #endif |
2183 | mIncSearchWidget->setSize(); | 2163 | mIncSearchWidget->setSize(); |
2184 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2164 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2185 | 2165 | ||
2186 | 2166 | ||
2187 | 2167 | ||
2188 | //US Now connect the actions with the menue entries. | 2168 | //US Now connect the actions with the menue entries. |
2189 | #ifdef DESKTOP_VERSION | 2169 | #ifdef DESKTOP_VERSION |
2190 | mActionPrint->plug( fileMenu ); | 2170 | mActionPrint->plug( fileMenu ); |
2191 | mActionPrintDetails->plug( fileMenu ); | 2171 | mActionPrintDetails->plug( fileMenu ); |
2192 | fileMenu->insertSeparator(); | 2172 | fileMenu->insertSeparator(); |
2193 | #endif | 2173 | #endif |
2194 | mActionMail->plug( fileMenu ); | 2174 | mActionMail->plug( fileMenu ); |
2195 | fileMenu->insertSeparator(); | 2175 | fileMenu->insertSeparator(); |
2196 | 2176 | ||
2197 | mActionNewContact->plug( editMenu ); | 2177 | mActionNewContact->plug( editMenu ); |
2198 | mActionNewContact->plug( tb ); | 2178 | mActionNewContact->plug( tb ); |
2199 | 2179 | ||
2200 | mActionEditAddressee->plug( editMenu ); | 2180 | mActionEditAddressee->plug( editMenu ); |
2201 | editMenu->insertSeparator(); | 2181 | editMenu->insertSeparator(); |
2202 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2182 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2203 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2183 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2204 | mActionEditAddressee->plug( tb ); | 2184 | mActionEditAddressee->plug( tb ); |
2205 | 2185 | ||
2206 | // fileMenu->insertSeparator(); | 2186 | // fileMenu->insertSeparator(); |
2207 | mActionSave->plug( fileMenu ); | 2187 | mActionSave->plug( fileMenu ); |
2208 | fileMenu->insertItem( "&Import", ImportMenu ); | 2188 | fileMenu->insertItem( "&Import", ImportMenu ); |
2209 | fileMenu->insertItem( "&Export", ExportMenu ); | 2189 | fileMenu->insertItem( "&Export", ExportMenu ); |
2210 | editMenu->insertItem( i18n("&Change"), changeMenu ); | 2190 | editMenu->insertItem( i18n("&Change"), changeMenu ); |
2211 | editMenu->insertSeparator(); | 2191 | editMenu->insertSeparator(); |
2212 | #ifndef DESKTOP_VERSION | 2192 | #ifndef DESKTOP_VERSION |
2213 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2193 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2214 | #endif | 2194 | #endif |
2215 | #if 0 | 2195 | #if 0 |
2216 | // PENDING fix MailVCard | 2196 | // PENDING fix MailVCard |
2217 | fileMenu->insertSeparator(); | 2197 | fileMenu->insertSeparator(); |
2218 | mActionMailVCard->plug( fileMenu ); | 2198 | mActionMailVCard->plug( fileMenu ); |
2219 | #endif | 2199 | #endif |
2220 | #ifndef DESKTOP_VERSION | 2200 | #ifndef DESKTOP_VERSION |
2221 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2201 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2222 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2202 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2223 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2203 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2224 | #endif | 2204 | #endif |
2225 | fileMenu->insertSeparator(); | 2205 | fileMenu->insertSeparator(); |
2226 | mActionQuit->plug( fileMenu ); | 2206 | mActionQuit->plug( fileMenu ); |
2227 | #ifdef _OL_IMPORT_ | 2207 | #ifdef _OL_IMPORT_ |
2228 | mActionImportOL->plug( ImportMenu ); | 2208 | mActionImportOL->plug( ImportMenu ); |
2229 | #endif | 2209 | #endif |
2230 | // edit menu | 2210 | // edit menu |
2231 | mActionUndo->plug( editMenu ); | 2211 | mActionUndo->plug( editMenu ); |
2232 | mActionRedo->plug( editMenu ); | 2212 | mActionRedo->plug( editMenu ); |
2233 | editMenu->insertSeparator(); | 2213 | editMenu->insertSeparator(); |
2234 | mActionCut->plug( editMenu ); | 2214 | mActionCut->plug( editMenu ); |
2235 | mActionCopy->plug( editMenu ); | 2215 | mActionCopy->plug( editMenu ); |
2236 | mActionPaste->plug( editMenu ); | 2216 | mActionPaste->plug( editMenu ); |
2237 | mActionDelete->plug( editMenu ); | 2217 | mActionDelete->plug( editMenu ); |
2238 | editMenu->insertSeparator(); | 2218 | editMenu->insertSeparator(); |
2239 | mActionSelectAll->plug( editMenu ); | 2219 | mActionSelectAll->plug( editMenu ); |
2240 | 2220 | ||
2241 | mActionSetFormattedName->plug( changeMenu ); | 2221 | mActionSetFormattedName->plug( changeMenu ); |
2242 | mActionRemoveVoice->plug( changeMenu ); | 2222 | mActionRemoveVoice->plug( changeMenu ); |
2243 | // settingsmings menu | 2223 | // settingsmings menu |
2244 | //US special menuentry to configure the addressbook resources. On KDE | 2224 | //US special menuentry to configure the addressbook resources. On KDE |
2245 | // you do that through the control center !!! | 2225 | // you do that through the control center !!! |
2246 | // settingsMenu->insertSeparator(); | 2226 | // settingsMenu->insertSeparator(); |
2247 | 2227 | ||
2248 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); | 2228 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); |
2249 | mActionConfigResources->plug( settingsMenu,1 ); | 2229 | mActionConfigResources->plug( settingsMenu,1 ); |
2250 | settingsMenu->insertSeparator(2); | 2230 | settingsMenu->insertSeparator(2); |
2251 | 2231 | ||
2252 | if ( mIsPart ) { | 2232 | if ( mIsPart ) { |
2253 | //US not implemented yet | 2233 | //US not implemented yet |
2254 | //mActionConfigShortcuts->plug( settingsMenu ); | 2234 | //mActionConfigShortcuts->plug( settingsMenu ); |
2255 | //mActionConfigureToolbars->plug( settingsMenu ); | 2235 | //mActionConfigureToolbars->plug( settingsMenu ); |
2256 | 2236 | ||
2257 | } else { | 2237 | } else { |
2258 | //US not implemented yet | 2238 | //US not implemented yet |
2259 | //mActionKeyBindings->plug( settingsMenu ); | 2239 | //mActionKeyBindings->plug( settingsMenu ); |
2260 | } | 2240 | } |
2261 | 2241 | ||
2262 | mActionEditCategories->plug( settingsMenu ); | 2242 | mActionEditCategories->plug( settingsMenu ); |
2263 | mActionManageCategories->plug( settingsMenu ); | 2243 | mActionManageCategories->plug( settingsMenu ); |
2264 | mActionJumpBar->plug( viewMenu,0 ); | 2244 | mActionJumpBar->plug( viewMenu,0 ); |
2265 | mActionDetails->plug( viewMenu,0 ); | 2245 | mActionDetails->plug( viewMenu,0 ); |
2266 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2246 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2267 | mActionDetails->plug( tb ); | 2247 | mActionDetails->plug( tb ); |
2268 | settingsMenu->insertSeparator(); | 2248 | settingsMenu->insertSeparator(); |
2269 | #ifndef DESKTOP_VERSION | 2249 | #ifndef DESKTOP_VERSION |
2270 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2250 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2271 | settingsMenu->insertSeparator(); | 2251 | settingsMenu->insertSeparator(); |
2272 | #endif | 2252 | #endif |
2273 | 2253 | ||
2274 | mActionWhoAmI->plug( settingsMenu ); | 2254 | mActionWhoAmI->plug( settingsMenu ); |
2275 | //mActionEditCategories->plug( changeMenu ); | 2255 | //mActionEditCategories->plug( changeMenu ); |
2276 | mActionCategories->plug( changeMenu ); | 2256 | mActionCategories->plug( changeMenu ); |
2277 | //mActionManageCategories->plug( changeMenu ); | 2257 | //mActionManageCategories->plug( changeMenu ); |
2278 | 2258 | ||
2279 | //mActionCategories->plug( settingsMenu ); | 2259 | //mActionCategories->plug( settingsMenu ); |
2280 | 2260 | ||
2281 | 2261 | ||
2282 | mActionWN->plug( helpMenu ); | 2262 | mActionWN->plug( helpMenu ); |
2283 | mActionStorageHowto->plug( helpMenu ); | 2263 | mActionStorageHowto->plug( helpMenu ); |
2284 | mActionSyncHowto->plug( helpMenu ); | 2264 | mActionSyncHowto->plug( helpMenu ); |
2285 | mActionKdeSyncHowto->plug( helpMenu ); | 2265 | mActionKdeSyncHowto->plug( helpMenu ); |
2286 | mActionMultiSyncHowto->plug( helpMenu ); | 2266 | mActionMultiSyncHowto->plug( helpMenu ); |
2287 | mActionFaq->plug( helpMenu ); | 2267 | mActionFaq->plug( helpMenu ); |
2288 | mActionLicence->plug( helpMenu ); | 2268 | mActionLicence->plug( helpMenu ); |
2289 | mActionAboutKAddressbook->plug( helpMenu ); | 2269 | mActionAboutKAddressbook->plug( helpMenu ); |
2290 | 2270 | ||
2291 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2271 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2292 | 2272 | ||
2293 | mActionSave->plug( tb ); | 2273 | mActionSave->plug( tb ); |
2294 | mViewManager->getFilterAction()->plug ( tb); | 2274 | mViewManager->getFilterAction()->plug ( tb); |
2295 | //LR hide filteraction on started in 480x640 | 2275 | //LR hide filteraction on started in 480x640 |
2296 | if (QApplication::desktop()->width() == 480 ) { | 2276 | if (QApplication::desktop()->width() == 480 ) { |
2297 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2277 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2298 | } | 2278 | } |
2299 | mActionUndo->plug( tb ); | 2279 | mActionUndo->plug( tb ); |
2300 | mActionDelete->plug( tb ); | 2280 | mActionDelete->plug( tb ); |
2301 | mActionRedo->plug( tb ); | 2281 | mActionRedo->plug( tb ); |
2302 | } else { | 2282 | } else { |
2303 | mActionSave->plug( tb ); | 2283 | mActionSave->plug( tb ); |
2304 | tb->enableMoving(false); | 2284 | tb->enableMoving(false); |
2305 | } | 2285 | } |
2306 | //mActionQuit->plug ( tb ); | 2286 | //mActionQuit->plug ( tb ); |
2307 | //tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2287 | //tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2308 | 2288 | ||
2309 | //US link the searchwidget first to this. | 2289 | //US link the searchwidget first to this. |
2310 | // The real linkage to the toolbar happens later. | 2290 | // The real linkage to the toolbar happens later. |
2311 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2291 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2312 | //US tb->insertItem( mIncSearchWidget ); | 2292 | //US tb->insertItem( mIncSearchWidget ); |
2313 | /*US | 2293 | /*US |
2314 | mIncSearchWidget = new IncSearchWidget( tb ); | 2294 | mIncSearchWidget = new IncSearchWidget( tb ); |
2315 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2295 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2316 | SLOT( incrementalSearch( const QString& ) ) ); | 2296 | SLOT( incrementalSearch( const QString& ) ) ); |
2317 | 2297 | ||
2318 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2298 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2319 | 2299 | ||
2320 | //US topLayout->addWidget( mJumpButtonBar ); | 2300 | //US topLayout->addWidget( mJumpButtonBar ); |
2321 | this->layout()->add( mJumpButtonBar ); | 2301 | this->layout()->add( mJumpButtonBar ); |
2322 | */ | 2302 | */ |
2323 | 2303 | ||
2324 | #endif //KAB_EMBEDDED | 2304 | #endif //KAB_EMBEDDED |
2325 | 2305 | ||
2326 | mActionExport2phone->plug( ExportMenu ); | 2306 | mActionExport2phone->plug( ExportMenu ); |
2327 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2307 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2328 | syncManager->fillSyncMenu(); | 2308 | syncManager->fillSyncMenu(); |
2329 | 2309 | ||
2330 | } | 2310 | } |
2331 | void KABCore::showLicence() | 2311 | void KABCore::showLicence() |
2332 | { | 2312 | { |
2333 | KApplication::showLicence(); | 2313 | KApplication::showLicence(); |
2334 | } | 2314 | } |
2335 | 2315 | ||
2336 | void KABCore::manageCategories( ) | 2316 | void KABCore::manageCategories( ) |
2337 | { | 2317 | { |
2338 | KABCatPrefs* cp = new KABCatPrefs(); | 2318 | KABCatPrefs* cp = new KABCatPrefs(); |
2339 | cp->show(); | 2319 | cp->show(); |
2340 | int w =cp->sizeHint().width() ; | 2320 | int w =cp->sizeHint().width() ; |
2341 | int h = cp->sizeHint().height() ; | 2321 | int h = cp->sizeHint().height() ; |
2342 | int dw = QApplication::desktop()->width(); | 2322 | int dw = QApplication::desktop()->width(); |
2343 | int dh = QApplication::desktop()->height(); | 2323 | int dh = QApplication::desktop()->height(); |
2344 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2324 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2345 | if ( !cp->exec() ) { | 2325 | if ( !cp->exec() ) { |
2346 | delete cp; | 2326 | delete cp; |
2347 | return; | 2327 | return; |
2348 | } | 2328 | } |
2349 | int count = 0; | 2329 | int count = 0; |
2350 | int cc = 0; | 2330 | int cc = 0; |
2351 | message( i18n("Please wait, processing categories...")); | 2331 | message( i18n("Please wait, processing categories...")); |
2352 | if ( cp->addCat() ) { | 2332 | if ( cp->addCat() ) { |
2353 | KABC::AddressBook::Iterator it; | 2333 | KABC::AddressBook::Iterator it; |
2354 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2334 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2355 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2335 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2356 | ++cc; | 2336 | ++cc; |
2357 | if ( cc %10 == 0) | 2337 | if ( cc %10 == 0) |
2358 | message(i18n("Processing contact #%1").arg(cc)); | 2338 | message(i18n("Processing contact #%1").arg(cc)); |
2359 | QStringList catIncList = (*it).categories(); | 2339 | QStringList catIncList = (*it).categories(); |
2360 | int i; | 2340 | int i; |
2361 | for( i = 0; i< catIncList.count(); ++i ) { | 2341 | for( i = 0; i< catIncList.count(); ++i ) { |
2362 | if ( !catList.contains (catIncList[i])) { | 2342 | if ( !catList.contains (catIncList[i])) { |
2363 | catList.append( catIncList[i] ); | 2343 | catList.append( catIncList[i] ); |
2364 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2344 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2365 | ++count; | 2345 | ++count; |
2366 | } | 2346 | } |
2367 | } | 2347 | } |
2368 | } | 2348 | } |
2369 | catList.sort(); | 2349 | catList.sort(); |
2370 | KABPrefs::instance()->mCustomCategories = catList; | 2350 | KABPrefs::instance()->mCustomCategories = catList; |
2371 | KABPrefs::instance()->writeConfig(); | 2351 | KABPrefs::instance()->writeConfig(); |
2372 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2352 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2373 | } else { | 2353 | } else { |
2374 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2354 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2375 | QStringList catIncList; | 2355 | QStringList catIncList; |
2376 | QStringList newCatList; | 2356 | QStringList newCatList; |
2377 | KABC::AddressBook::Iterator it; | 2357 | KABC::AddressBook::Iterator it; |
2378 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2358 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2379 | ++cc; | 2359 | ++cc; |
2380 | if ( cc %10 == 0) | 2360 | if ( cc %10 == 0) |
2381 | message(i18n("Processing contact #%1").arg(cc)); | 2361 | message(i18n("Processing contact #%1").arg(cc)); |
2382 | QStringList catIncList = (*it).categories(); | 2362 | QStringList catIncList = (*it).categories(); |
2383 | int i; | 2363 | int i; |
2384 | if ( catIncList.count() ) { | 2364 | if ( catIncList.count() ) { |
2385 | newCatList.clear(); | 2365 | newCatList.clear(); |
2386 | for( i = 0; i< catIncList.count(); ++i ) { | 2366 | for( i = 0; i< catIncList.count(); ++i ) { |
2387 | if ( catList.contains (catIncList[i])) { | 2367 | if ( catList.contains (catIncList[i])) { |
2388 | newCatList.append( catIncList[i] ); | 2368 | newCatList.append( catIncList[i] ); |
2389 | } | 2369 | } |
2390 | } | 2370 | } |
2391 | newCatList.sort(); | 2371 | newCatList.sort(); |
2392 | (*it).setCategories( newCatList ); | 2372 | (*it).setCategories( newCatList ); |
2393 | mAddressBook->insertAddressee( (*it) ); | 2373 | mAddressBook->insertAddressee( (*it) ); |
2394 | } | 2374 | } |
2395 | } | 2375 | } |
2396 | setModified( true ); | 2376 | setModified( true ); |
2397 | mViewManager->refreshView(); | 2377 | mViewManager->refreshView(); |
2398 | message( i18n("Removing categories done!")); | 2378 | message( i18n("Removing categories done!")); |
2399 | } | 2379 | } |
2400 | delete cp; | 2380 | delete cp; |
2401 | } | 2381 | } |
2402 | void KABCore::removeVoice() | 2382 | void KABCore::removeVoice() |
2403 | { | 2383 | { |
2404 | 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 ) | 2384 | 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 ) |
2405 | return; | 2385 | return; |
2406 | XXPortSelectDialog dlg( this, false, this ); | 2386 | XXPortSelectDialog dlg( this, false, this ); |
2407 | if ( !dlg.exec() ) | 2387 | if ( !dlg.exec() ) |
2408 | return; | 2388 | return; |
2409 | mAddressBook->setUntagged(); | 2389 | mAddressBook->setUntagged(); |
2410 | dlg.tagSelected(); | 2390 | dlg.tagSelected(); |
2411 | message(i18n("Removing voice..."), false ); | 2391 | message(i18n("Removing voice..."), false ); |
2412 | KABC::AddressBook::Iterator it; | 2392 | KABC::AddressBook::Iterator it; |
2413 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2393 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2414 | if ( (*it).tagged() ) { | 2394 | if ( (*it).tagged() ) { |
2415 | (*it).removeVoice(); | 2395 | (*it).removeVoice(); |
2416 | } | 2396 | } |
2417 | } | 2397 | } |
2418 | message(i18n("Refreshing view...") ); | 2398 | message(i18n("Refreshing view...") ); |
2419 | qApp->processEvents(); | 2399 | qApp->processEvents(); |
2420 | mViewManager->refreshView( "" ); | 2400 | mViewManager->refreshView( "" ); |
2421 | Addressee add; | 2401 | Addressee add; |
2422 | mDetails->setAddressee( add ); | 2402 | mDetails->setAddressee( add ); |
2423 | message(i18n("Remove voice completed!") ); | 2403 | message(i18n("Remove voice completed!") ); |
2424 | 2404 | ||
2425 | 2405 | ||
2426 | 2406 | ||
2427 | } | 2407 | } |
2428 | 2408 | ||
2429 | void KABCore::setFormattedName() | 2409 | void KABCore::setFormattedName() |
2430 | { | 2410 | { |
2431 | KABFormatPrefs setpref; | 2411 | KABFormatPrefs setpref; |
2432 | if ( !setpref.exec() ) { | 2412 | if ( !setpref.exec() ) { |
2433 | return; | 2413 | return; |
2434 | } | 2414 | } |
2435 | XXPortSelectDialog dlg( this, false, this ); | 2415 | XXPortSelectDialog dlg( this, false, this ); |
2436 | if ( !dlg.exec() ) | 2416 | if ( !dlg.exec() ) |
2437 | return; | 2417 | return; |
2438 | mAddressBook->setUntagged(); | 2418 | mAddressBook->setUntagged(); |
2439 | dlg.tagSelected(); | 2419 | dlg.tagSelected(); |
2440 | int count = 0; | 2420 | int count = 0; |
2441 | KABC::AddressBook::Iterator it; | 2421 | KABC::AddressBook::Iterator it; |
2442 | bool modified = false; | 2422 | bool modified = false; |
2443 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2423 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2444 | if ( (*it).tagged() ) { | 2424 | if ( (*it).tagged() ) { |
2445 | if ( (*it).uid().left( 2 ) == "la" ) | 2425 | if ( (*it).uid().left( 2 ) == "la" ) |
2446 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) | 2426 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) |
2447 | continue; | 2427 | continue; |
2448 | ++count; | 2428 | ++count; |
2449 | if ( count %10 == 0 ) | 2429 | if ( count %10 == 0 ) |
2450 | message(i18n("Changing contact #%1").arg( count ) ); | 2430 | message(i18n("Changing contact #%1").arg( count ) ); |
2451 | qApp->processEvents(); | 2431 | qApp->processEvents(); |
2452 | QString fName; | 2432 | QString fName; |
2453 | if ( setpref.simple->isChecked() ) | 2433 | if ( setpref.simple->isChecked() ) |
2454 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2434 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2455 | else if ( setpref.full->isChecked() ) | 2435 | else if ( setpref.full->isChecked() ) |
2456 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2436 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2457 | else if ( setpref.reverse->isChecked() ) | 2437 | else if ( setpref.reverse->isChecked() ) |
2458 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2438 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2459 | else | 2439 | else |
2460 | fName = (*it).organization(); | 2440 | fName = (*it).organization(); |
2461 | if ( setpref.setCompany->isChecked() ) | 2441 | if ( setpref.setCompany->isChecked() ) |
2462 | if ( fName.isEmpty() || fName =="," ) | 2442 | if ( fName.isEmpty() || fName =="," ) |
2463 | fName = (*it).organization(); | 2443 | fName = (*it).organization(); |
2464 | (*it).setFormattedName( fName ); | 2444 | (*it).setFormattedName( fName ); |
2465 | (*it).setChanged( true ); | 2445 | (*it).setChanged( true ); |
2466 | modified = true; | 2446 | modified = true; |
2467 | (*it).setRevision( QDateTime::currentDateTime() ); | 2447 | (*it).setRevision( QDateTime::currentDateTime() ); |
2468 | } | 2448 | } |
2469 | } | 2449 | } |
2470 | message(i18n("Refreshing view...") ); | 2450 | message(i18n("Refreshing view...") ); |
2471 | qApp->processEvents(); | 2451 | qApp->processEvents(); |
2472 | if ( modified ) | 2452 | if ( modified ) |
2473 | setModified( true ); | 2453 | setModified( true ); |
2474 | Addressee add; | 2454 | Addressee add; |
2475 | mDetails->setAddressee( add ); | 2455 | mDetails->setAddressee( add ); |
2476 | if ( count == 0 ) | 2456 | if ( count == 0 ) |
2477 | message(i18n("No contact changed!") ); | 2457 | message(i18n("No contact changed!") ); |
2478 | else | 2458 | else |
2479 | message(i18n("%1 contacts changed!").arg( count ) ); | 2459 | message(i18n("%1 contacts changed!").arg( count ) ); |
2480 | } | 2460 | } |
2481 | 2461 | ||
2482 | void KABCore::clipboardDataChanged() | 2462 | void KABCore::clipboardDataChanged() |
2483 | { | 2463 | { |
2484 | 2464 | ||
2485 | if ( mReadWrite ) | 2465 | if ( mReadWrite ) |
2486 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2466 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2487 | 2467 | ||
2488 | } | 2468 | } |
2489 | 2469 | ||
2490 | void KABCore::updateActionMenu() | 2470 | void KABCore::updateActionMenu() |
2491 | { | 2471 | { |
2492 | UndoStack *undo = UndoStack::instance(); | 2472 | UndoStack *undo = UndoStack::instance(); |
2493 | RedoStack *redo = RedoStack::instance(); | 2473 | RedoStack *redo = RedoStack::instance(); |
2494 | 2474 | ||
2495 | if ( undo->isEmpty() ) | 2475 | if ( undo->isEmpty() ) |
2496 | mActionUndo->setText( i18n( "Undo" ) ); | 2476 | mActionUndo->setText( i18n( "Undo" ) ); |
2497 | else | 2477 | else |
2498 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2478 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2499 | 2479 | ||
2500 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2480 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2501 | 2481 | ||
2502 | if ( !redo->top() ) | 2482 | if ( !redo->top() ) |
2503 | mActionRedo->setText( i18n( "Redo" ) ); | 2483 | mActionRedo->setText( i18n( "Redo" ) ); |
2504 | else | 2484 | else |
2505 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2485 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2506 | 2486 | ||
2507 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2487 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2508 | } | 2488 | } |
2509 | 2489 | ||
2510 | void KABCore::configureKeyBindings() | 2490 | void KABCore::configureKeyBindings() |
2511 | { | 2491 | { |
2512 | #ifndef KAB_EMBEDDED | 2492 | #ifndef KAB_EMBEDDED |
2513 | KKeyDialog::configure( actionCollection(), true ); | 2493 | KKeyDialog::configure( actionCollection(), true ); |
2514 | #else //KAB_EMBEDDED | 2494 | #else //KAB_EMBEDDED |
2515 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2495 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2516 | #endif //KAB_EMBEDDED | 2496 | #endif //KAB_EMBEDDED |
2517 | } | 2497 | } |
2518 | 2498 | ||
2519 | #ifdef KAB_EMBEDDED | 2499 | #ifdef KAB_EMBEDDED |
2520 | void KABCore::configureResources() | 2500 | void KABCore::configureResources() |
2521 | { | 2501 | { |
2522 | KRES::KCMKResources dlg( this, "" , 0 ); | 2502 | KRES::KCMKResources dlg( this, "" , 0 ); |
2523 | 2503 | ||
2524 | if ( !dlg.exec() ) | 2504 | if ( !dlg.exec() ) |
2525 | return; | 2505 | return; |
2526 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2506 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2527 | } | 2507 | } |
2528 | #endif //KAB_EMBEDDED | 2508 | #endif //KAB_EMBEDDED |
2529 | 2509 | ||
2530 | 2510 | ||
2531 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2511 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2532 | * for the attendees list of an event. | 2512 | * for the attendees list of an event. |
2533 | */ | 2513 | */ |
2534 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2514 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2535 | { | 2515 | { |
2536 | 2516 | ||
2537 | bool ok = false; | 2517 | bool ok = false; |
2538 | mEmailSourceChannel = sourceChannel; | 2518 | mEmailSourceChannel = sourceChannel; |
2539 | mEmailSourceUID = uid; | 2519 | mEmailSourceUID = uid; |
2540 | callContactdialog(); | 2520 | callContactdialog(); |
2541 | #if 0 | 2521 | #if 0 |
2542 | int wid = uid.toInt( &ok ); | 2522 | int wid = uid.toInt( &ok ); |
2543 | qDebug("UID %s ", uid.latin1()); | 2523 | qDebug("UID %s ", uid.latin1()); |
2544 | if ( ok ) { | 2524 | if ( ok ) { |
2545 | if ( wid != QApplication::desktop()->width() ) { | 2525 | if ( wid != QApplication::desktop()->width() ) { |
2546 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); | 2526 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); |
2547 | message( i18n("Resizing, please wait...") ); | 2527 | message( i18n("Resizing, please wait...") ); |
2548 | mMainWindow->showMinimized(); | 2528 | mMainWindow->showMinimized(); |
2549 | /* | 2529 | /* |
2550 | { | 2530 | { |
2551 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2531 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2552 | } | 2532 | } |
2553 | */ | 2533 | */ |
2554 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); | 2534 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); |
2555 | return; | 2535 | return; |
2556 | } | 2536 | } |
2557 | 2537 | ||
2558 | } else { | 2538 | } else { |
2559 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); | 2539 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); |
2560 | } | 2540 | } |
2561 | callContactdialog(); | 2541 | callContactdialog(); |
2562 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2542 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2563 | #endif | 2543 | #endif |
2564 | } | 2544 | } |
2565 | void KABCore::resizeAndCallContactdialog() | 2545 | void KABCore::resizeAndCallContactdialog() |
2566 | { | 2546 | { |
2567 | updateMainWindow(); | 2547 | updateMainWindow(); |
2568 | QTimer::singleShot( 100,this, SLOT ( callContactdialog() ) ); | 2548 | QTimer::singleShot( 100,this, SLOT ( callContactdialog() ) ); |
2569 | } | 2549 | } |
2570 | 2550 | ||
2571 | void KABCore::callContactdialog() | 2551 | void KABCore::callContactdialog() |
2572 | { | 2552 | { |
2573 | QStringList nameList; | 2553 | QStringList nameList; |
2574 | QStringList emailList; | 2554 | QStringList emailList; |
2575 | QStringList uidList; | 2555 | QStringList uidList; |
2576 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); | 2556 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); |
2577 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2557 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2578 | uint i=0; | 2558 | uint i=0; |
2579 | for (i=0; i < list.count(); i++) | 2559 | for (i=0; i < list.count(); i++) |
2580 | { | 2560 | { |
2581 | nameList.append(list[i].realName()); | 2561 | nameList.append(list[i].realName()); |
2582 | emailList.append(list[i].preferredEmail()); | 2562 | emailList.append(list[i].preferredEmail()); |
2583 | uidList.append(list[i].uid()); | 2563 | uidList.append(list[i].uid()); |
2584 | } | 2564 | } |
2585 | QString uid = mEmailSourceUID; | 2565 | QString uid = mEmailSourceUID; |
2586 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); | 2566 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); |
2587 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); | 2567 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); |
2588 | 2568 | ||
2589 | } | 2569 | } |
2590 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2570 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2591 | * to put them into the calendar. | 2571 | * to put them into the calendar. |
2592 | */ | 2572 | */ |
2593 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2573 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2594 | { | 2574 | { |
2595 | // qDebug("KABCore::requestForBirthdayList"); | 2575 | // qDebug("KABCore::requestForBirthdayList"); |
2596 | QStringList birthdayList; | 2576 | QStringList birthdayList; |
2597 | QStringList anniversaryList; | 2577 | QStringList anniversaryList; |
2598 | QStringList realNameList; | 2578 | QStringList realNameList; |
2599 | QStringList preferredEmailList; | 2579 | QStringList preferredEmailList; |
2600 | QStringList assembledNameList; | 2580 | QStringList assembledNameList; |
2601 | QStringList uidList; | 2581 | QStringList uidList; |
2602 | 2582 | ||
2603 | KABC::AddressBook::Iterator it; | 2583 | KABC::AddressBook::Iterator it; |
2604 | 2584 | ||
2605 | int count = 0; | 2585 | int count = 0; |
2606 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2586 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2607 | ++count; | 2587 | ++count; |
2608 | } | 2588 | } |
2609 | QProgressBar bar(count,0 ); | 2589 | QProgressBar bar(count,0 ); |
2610 | int w = 300; | 2590 | int w = 300; |
2611 | if ( QApplication::desktop()->width() < 320 ) | 2591 | if ( QApplication::desktop()->width() < 320 ) |
2612 | w = 220; | 2592 | w = 220; |
2613 | int h = bar.sizeHint().height() ; | 2593 | int h = bar.sizeHint().height() ; |
2614 | int dw = QApplication::desktop()->width(); | 2594 | int dw = QApplication::desktop()->width(); |
2615 | int dh = QApplication::desktop()->height(); | 2595 | int dh = QApplication::desktop()->height(); |
2616 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2596 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2617 | bar.show(); | 2597 | bar.show(); |
2618 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2598 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2619 | qApp->processEvents(); | 2599 | qApp->processEvents(); |
2620 | 2600 | ||
2621 | QDate bday; | 2601 | QDate bday; |
2622 | QString anni; | 2602 | QString anni; |
2623 | QString formattedbday; | 2603 | QString formattedbday; |
2624 | 2604 | ||
2625 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2605 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2626 | { | 2606 | { |
2627 | if ( ! bar.isVisible() ) | 2607 | if ( ! bar.isVisible() ) |
2628 | return; | 2608 | return; |
2629 | bar.setProgress( count++ ); | 2609 | bar.setProgress( count++ ); |
2630 | qApp->processEvents(); | 2610 | qApp->processEvents(); |
2631 | bday = (*it).birthday().date(); | 2611 | bday = (*it).birthday().date(); |
2632 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2612 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2633 | 2613 | ||
2634 | if ( bday.isValid() || !anni.isEmpty()) | 2614 | if ( bday.isValid() || !anni.isEmpty()) |
2635 | { | 2615 | { |
2636 | if (bday.isValid()) | 2616 | if (bday.isValid()) |
2637 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2617 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2638 | else | 2618 | else |
2639 | formattedbday = "NOTVALID"; | 2619 | formattedbday = "NOTVALID"; |
2640 | if (anni.isEmpty()) | 2620 | if (anni.isEmpty()) |
2641 | anni = "INVALID"; | 2621 | anni = "INVALID"; |
2642 | 2622 | ||
2643 | birthdayList.append(formattedbday); | 2623 | birthdayList.append(formattedbday); |
2644 | anniversaryList.append(anni); //should be ISODate | 2624 | anniversaryList.append(anni); //should be ISODate |
2645 | realNameList.append((*it).realName()); | 2625 | realNameList.append((*it).realName()); |
2646 | preferredEmailList.append((*it).preferredEmail()); | 2626 | preferredEmailList.append((*it).preferredEmail()); |
2647 | assembledNameList.append((*it).assembledName()); | 2627 | assembledNameList.append((*it).assembledName()); |
2648 | uidList.append((*it).uid()); | 2628 | uidList.append((*it).uid()); |
2649 | 2629 | ||
2650 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2630 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2651 | } | 2631 | } |
2652 | } | 2632 | } |
2653 | 2633 | ||
2654 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2634 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2655 | 2635 | ||
2656 | } | 2636 | } |
2657 | 2637 | ||
2658 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2638 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2659 | */ | 2639 | */ |
2660 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2640 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2661 | { | 2641 | { |
2662 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2642 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2663 | 2643 | ||
2664 | QString foundUid = QString::null; | 2644 | QString foundUid = QString::null; |
2665 | if ( ! uid.isEmpty() ) { | 2645 | if ( ! uid.isEmpty() ) { |
2666 | Addressee adrr = mAddressBook->findByUid( uid ); | 2646 | Addressee adrr = mAddressBook->findByUid( uid ); |
2667 | if ( !adrr.isEmpty() ) { | 2647 | if ( !adrr.isEmpty() ) { |
2668 | foundUid = uid; | 2648 | foundUid = uid; |
2669 | } | 2649 | } |
2670 | if ( email == "sendbacklist" ) { | 2650 | if ( email == "sendbacklist" ) { |
2671 | //qDebug("ssssssssssssssssssssssend "); | 2651 | //qDebug("ssssssssssssssssssssssend "); |
2672 | QStringList nameList; | 2652 | QStringList nameList; |
2673 | QStringList emailList; | 2653 | QStringList emailList; |
2674 | QStringList uidList; | 2654 | QStringList uidList; |
2675 | nameList.append(adrr.realName()); | 2655 | nameList.append(adrr.realName()); |
2676 | emailList = adrr.emails(); | 2656 | emailList = adrr.emails(); |
2677 | uidList.append( adrr.preferredEmail()); | 2657 | uidList.append( adrr.preferredEmail()); |
2678 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2658 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2679 | return; | 2659 | return; |
2680 | } | 2660 | } |
2681 | 2661 | ||
2682 | } | 2662 | } |
2683 | 2663 | ||
2684 | if ( email == "sendbacklist" ) | 2664 | if ( email == "sendbacklist" ) |
2685 | return; | 2665 | return; |
2686 | if (foundUid.isEmpty()) | 2666 | if (foundUid.isEmpty()) |
2687 | { | 2667 | { |
2688 | //find the uid of the person first | 2668 | //find the uid of the person first |
2689 | Addressee::List namelist; | 2669 | Addressee::List namelist; |
2690 | Addressee::List emaillist; | 2670 | Addressee::List emaillist; |
2691 | 2671 | ||
2692 | if (!name.isEmpty()) | 2672 | if (!name.isEmpty()) |
2693 | namelist = mAddressBook->findByName( name ); | 2673 | namelist = mAddressBook->findByName( name ); |
2694 | 2674 | ||
2695 | if (!email.isEmpty()) | 2675 | if (!email.isEmpty()) |
2696 | emaillist = mAddressBook->findByEmail( email ); | 2676 | emaillist = mAddressBook->findByEmail( email ); |
2697 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2677 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2698 | //check if we have a match in Namelist and Emaillist | 2678 | //check if we have a match in Namelist and Emaillist |
2699 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2679 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2700 | foundUid = emaillist[0].uid(); | 2680 | foundUid = emaillist[0].uid(); |
2701 | } | 2681 | } |
2702 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2682 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2703 | foundUid = namelist[0].uid(); | 2683 | foundUid = namelist[0].uid(); |
2704 | else | 2684 | else |
2705 | { | 2685 | { |
2706 | for (int i = 0; i < namelist.count(); i++) | 2686 | for (int i = 0; i < namelist.count(); i++) |
2707 | { | 2687 | { |
2708 | for (int j = 0; j < emaillist.count(); j++) | 2688 | for (int j = 0; j < emaillist.count(); j++) |
2709 | { | 2689 | { |
2710 | if (namelist[i] == emaillist[j]) | 2690 | if (namelist[i] == emaillist[j]) |
2711 | { | 2691 | { |
2712 | foundUid = namelist[i].uid(); | 2692 | foundUid = namelist[i].uid(); |
2713 | } | 2693 | } |
2714 | } | 2694 | } |
2715 | } | 2695 | } |
2716 | } | 2696 | } |
2717 | } | 2697 | } |
2718 | else | 2698 | else |
2719 | { | 2699 | { |
2720 | foundUid = uid; | 2700 | foundUid = uid; |
2721 | } | 2701 | } |
2722 | 2702 | ||
2723 | if (!foundUid.isEmpty()) | 2703 | if (!foundUid.isEmpty()) |
2724 | { | 2704 | { |
2725 | 2705 | ||
2726 | // raise Ka/Pi if it is in the background | 2706 | // raise Ka/Pi if it is in the background |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 20a5b74..76d5c4b 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,1624 +1,1631 @@ | |||
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 <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef KORG_NOSPLITTER | 29 | #ifndef KORG_NOSPLITTER |
30 | #include <qsplitter.h> | 30 | #include <qsplitter.h> |
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kconfig.h> | 46 | #include <kconfig.h> |
47 | #include <kglobal.h> | 47 | #include <kglobal.h> |
48 | #include "calendarview.h" | 48 | #include "calendarview.h" |
49 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
50 | 50 | ||
51 | #include <libkcal/calendar.h> | 51 | #include <libkcal/calendar.h> |
52 | #include <libkcal/icaldrag.h> | 52 | #include <libkcal/icaldrag.h> |
53 | #include <libkcal/dndfactory.h> | 53 | #include <libkcal/dndfactory.h> |
54 | 54 | ||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | myPix.resize( 1, 1 ); | 84 | myPix.resize( 1, 1 ); |
85 | mRows = rows; | 85 | mRows = rows; |
86 | 86 | ||
87 | mRedrawNeeded = true; | 87 | mRedrawNeeded = true; |
88 | setMinimumHeight( 20 ); | 88 | setMinimumHeight( 20 ); |
89 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 89 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
90 | 90 | ||
91 | enableClipper(true); | 91 | enableClipper(true); |
92 | 92 | ||
93 | setHScrollBarMode(AlwaysOff); | 93 | setHScrollBarMode(AlwaysOff); |
94 | setVScrollBarMode(AlwaysOff); | 94 | setVScrollBarMode(AlwaysOff); |
95 | 95 | ||
96 | resizeContents(50,mRows * mCellHeight); | 96 | resizeContents(50,mRows * mCellHeight); |
97 | 97 | ||
98 | viewport()->setBackgroundMode( PaletteBackground ); | 98 | viewport()->setBackgroundMode( PaletteBackground ); |
99 | } | 99 | } |
100 | 100 | ||
101 | void TimeLabels::setCellHeight(int height) | 101 | void TimeLabels::setCellHeight(int height) |
102 | { | 102 | { |
103 | mCellHeight = height; | 103 | mCellHeight = height; |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | 106 | /* |
107 | Optimization so that only the "dirty" portion of the scroll view | 107 | Optimization so that only the "dirty" portion of the scroll view |
108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
109 | */ | 109 | */ |
110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
111 | { | 111 | { |
112 | 112 | ||
113 | cx = contentsX() + frameWidth()*2; | 113 | cx = contentsX() + frameWidth()*2; |
114 | cw = contentsWidth() ; | 114 | cw = contentsWidth() ; |
115 | // end of workaround | 115 | // end of workaround |
116 | 116 | ||
117 | int cell = ((int)(cy/mCellHeight)); | 117 | int cell = ((int)(cy/mCellHeight)); |
118 | int y = cell * mCellHeight; | 118 | int y = cell * mCellHeight; |
119 | QFontMetrics fm = fontMetrics(); | 119 | QFontMetrics fm = fontMetrics(); |
120 | QString hour; | 120 | QString hour; |
121 | QString suffix = "am"; | 121 | QString suffix = "am"; |
122 | int timeHeight = fm.ascent(); | 122 | int timeHeight = fm.ascent(); |
123 | QFont nFont = font(); | 123 | QFont nFont = font(); |
124 | p->setFont( font()); | 124 | p->setFont( font()); |
125 | 125 | ||
126 | if (!KGlobal::locale()->use12Clock()) { | 126 | if (!KGlobal::locale()->use12Clock()) { |
127 | suffix = "00"; | 127 | suffix = "00"; |
128 | } else | 128 | } else |
129 | if (cell > 11) suffix = "pm"; | 129 | if (cell > 11) suffix = "pm"; |
130 | 130 | ||
131 | if ( timeHeight > mCellHeight ) { | 131 | if ( timeHeight > mCellHeight ) { |
132 | timeHeight = mCellHeight-1; | 132 | timeHeight = mCellHeight-1; |
133 | int pointS = nFont.pointSize(); | 133 | int pointS = nFont.pointSize(); |
134 | while ( pointS > 4 ) { | 134 | while ( pointS > 4 ) { |
135 | nFont.setPointSize( pointS ); | 135 | nFont.setPointSize( pointS ); |
136 | fm = QFontMetrics( nFont ); | 136 | fm = QFontMetrics( nFont ); |
137 | if ( fm.ascent() < mCellHeight ) | 137 | if ( fm.ascent() < mCellHeight ) |
138 | break; | 138 | break; |
139 | -- pointS; | 139 | -- pointS; |
140 | } | 140 | } |
141 | fm = QFontMetrics( nFont ); | 141 | fm = QFontMetrics( nFont ); |
142 | timeHeight = fm.ascent(); | 142 | timeHeight = fm.ascent(); |
143 | } | 143 | } |
144 | //timeHeight -= (timeHeight/4-2); | 144 | //timeHeight -= (timeHeight/4-2); |
145 | QFont sFont = nFont; | 145 | QFont sFont = nFont; |
146 | sFont.setPointSize( sFont.pointSize()/2 ); | 146 | sFont.setPointSize( sFont.pointSize()/2 ); |
147 | QFontMetrics fmS( sFont ); | 147 | QFontMetrics fmS( sFont ); |
148 | int sHei = fmS.ascent() ; | 148 | int sHei = fmS.ascent() ; |
149 | //sHei -= (sHei/4-2); | 149 | //sHei -= (sHei/4-2); |
150 | int startW = mMiniWidth - frameWidth()-2 ; | 150 | int startW = mMiniWidth - frameWidth()-2 ; |
151 | int tw2 = fmS.width(suffix); | 151 | int tw2 = fmS.width(suffix); |
152 | timeHeight = (timeHeight-1) /2 -1; | 152 | timeHeight = (timeHeight-1) /2 -1; |
153 | //testline | 153 | //testline |
154 | //p->drawLine(0,0,0,contentsHeight()); | 154 | //p->drawLine(0,0,0,contentsHeight()); |
155 | while (y < cy + ch+mCellHeight) { | 155 | while (y < cy + ch+mCellHeight) { |
156 | p->drawLine(startW-tw2+1 ,y,cw+2,y); | 156 | p->drawLine(startW-tw2+1 ,y,cw+2,y); |
157 | hour.setNum(cell); | 157 | hour.setNum(cell); |
158 | // handle 24h and am/pm time formats | 158 | // handle 24h and am/pm time formats |
159 | if (KGlobal::locale()->use12Clock()) { | 159 | if (KGlobal::locale()->use12Clock()) { |
160 | if (cell == 12) suffix = "pm"; | 160 | if (cell == 12) suffix = "pm"; |
161 | if (cell == 0) hour.setNum(12); | 161 | if (cell == 0) hour.setNum(12); |
162 | if (cell > 12) hour.setNum(cell - 12); | 162 | if (cell > 12) hour.setNum(cell - 12); |
163 | } | 163 | } |
164 | 164 | ||
165 | // center and draw the time label | 165 | // center and draw the time label |
166 | int timeWidth = fm.width(hour); | 166 | int timeWidth = fm.width(hour); |
167 | int offset = startW - timeWidth - tw2 -1 ; | 167 | int offset = startW - timeWidth - tw2 -1 ; |
168 | p->setFont( nFont ); | 168 | p->setFont( nFont ); |
169 | p->drawText( offset, y+ timeHeight, hour); | 169 | p->drawText( offset, y+ timeHeight, hour); |
170 | p->setFont( sFont ); | 170 | p->setFont( sFont ); |
171 | offset = startW - tw2; | 171 | offset = startW - tw2; |
172 | p->drawText( offset, y -1, suffix); | 172 | p->drawText( offset, y -1, suffix); |
173 | 173 | ||
174 | // increment indices | 174 | // increment indices |
175 | y += mCellHeight; | 175 | y += mCellHeight; |
176 | cell++; | 176 | cell++; |
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | 180 | ||
181 | 181 | ||
182 | } | 182 | } |
183 | 183 | ||
184 | /** | 184 | /** |
185 | Calculates the minimum width. | 185 | Calculates the minimum width. |
186 | */ | 186 | */ |
187 | int TimeLabels::minimumWidth() const | 187 | int TimeLabels::minimumWidth() const |
188 | { | 188 | { |
189 | return mMiniWidth; | 189 | return mMiniWidth; |
190 | } | 190 | } |
191 | 191 | ||
192 | /** updates widget's internal state */ | 192 | /** updates widget's internal state */ |
193 | void TimeLabels::updateConfig() | 193 | void TimeLabels::updateConfig() |
194 | { | 194 | { |
195 | mRedrawNeeded = true; | 195 | mRedrawNeeded = true; |
196 | // set the font | 196 | // set the font |
197 | // config->setGroup("Fonts"); | 197 | // config->setGroup("Fonts"); |
198 | // QFont font = config->readFontEntry("TimeBar Font"); | 198 | // QFont font = config->readFontEntry("TimeBar Font"); |
199 | setFont(KOPrefs::instance()->mTimeBarFont); | 199 | setFont(KOPrefs::instance()->mTimeBarFont); |
200 | QString test = "20"; | 200 | QString test = "20"; |
201 | if (KGlobal::locale()->use12Clock()) | 201 | if (KGlobal::locale()->use12Clock()) |
202 | test = "12"; | 202 | test = "12"; |
203 | mMiniWidth = fontMetrics().width(test); | 203 | mMiniWidth = fontMetrics().width(test); |
204 | if (KGlobal::locale()->use12Clock()) | 204 | if (KGlobal::locale()->use12Clock()) |
205 | test = "pm"; | 205 | test = "pm"; |
206 | else { | 206 | else { |
207 | test = "00"; | 207 | test = "00"; |
208 | } | 208 | } |
209 | QFont sFont = font(); | 209 | QFont sFont = font(); |
210 | sFont.setPointSize( sFont.pointSize()/2 ); | 210 | sFont.setPointSize( sFont.pointSize()/2 ); |
211 | QFontMetrics fmS( sFont ); | 211 | QFontMetrics fmS( sFont ); |
212 | mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; | 212 | mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; |
213 | // update geometry restrictions based on new settings | 213 | // update geometry restrictions based on new settings |
214 | setFixedWidth( mMiniWidth ); | 214 | setFixedWidth( mMiniWidth ); |
215 | 215 | ||
216 | // update HourSize | 216 | // update HourSize |
217 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 217 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
218 | resizeContents(mMiniWidth,mRows * mCellHeight+1); | 218 | resizeContents(mMiniWidth,mRows * mCellHeight+1); |
219 | } | 219 | } |
220 | 220 | ||
221 | /** update time label positions */ | 221 | /** update time label positions */ |
222 | void TimeLabels::positionChanged() | 222 | void TimeLabels::positionChanged() |
223 | { | 223 | { |
224 | int adjustment = mAgenda->contentsY(); | 224 | int adjustment = mAgenda->contentsY(); |
225 | setContentsPos(0, adjustment); | 225 | setContentsPos(0, adjustment); |
226 | } | 226 | } |
227 | 227 | ||
228 | /** */ | 228 | /** */ |
229 | void TimeLabels::setAgenda(KOAgenda* agenda) | 229 | void TimeLabels::setAgenda(KOAgenda* agenda) |
230 | { | 230 | { |
231 | mAgenda = agenda; | 231 | mAgenda = agenda; |
232 | } | 232 | } |
233 | 233 | ||
234 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 234 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
235 | { | 235 | { |
236 | mMouseDownY = e->pos().y(); | 236 | mMouseDownY = e->pos().y(); |
237 | mOrgCap = topLevelWidget()->caption(); | 237 | mOrgCap = topLevelWidget()->caption(); |
238 | } | 238 | } |
239 | 239 | ||
240 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 240 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
241 | { | 241 | { |
242 | int diff = mMouseDownY - e->pos().y(); | 242 | int diff = mMouseDownY - e->pos().y(); |
243 | if ( diff < 10 && diff > -10 ) | 243 | if ( diff < 10 && diff > -10 ) |
244 | return; | 244 | return; |
245 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 245 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
246 | if ( tSize < 4 ) | 246 | if ( tSize < 4 ) |
247 | tSize = 4; | 247 | tSize = 4; |
248 | if ( tSize > 22 ) | 248 | if ( tSize > 22 ) |
249 | tSize = 22; | 249 | tSize = 22; |
250 | tSize = (tSize-2)/2; | 250 | tSize = (tSize-2)/2; |
251 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 251 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
252 | 252 | ||
253 | } | 253 | } |
254 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 254 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
255 | { | 255 | { |
256 | topLevelWidget()->setCaption( mOrgCap ); | 256 | topLevelWidget()->setCaption( mOrgCap ); |
257 | int diff = mMouseDownY - e->pos().y(); | 257 | int diff = mMouseDownY - e->pos().y(); |
258 | if ( diff < 10 && diff > -10 ) | 258 | if ( diff < 10 && diff > -10 ) |
259 | return; | 259 | return; |
260 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 260 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
261 | if ( tSize < 4 ) | 261 | if ( tSize < 4 ) |
262 | tSize = 4; | 262 | tSize = 4; |
263 | if ( tSize > 22 ) | 263 | if ( tSize > 22 ) |
264 | tSize = 22; | 264 | tSize = 22; |
265 | tSize = (tSize/2)*2; | 265 | tSize = (tSize/2)*2; |
266 | if ( tSize == KOPrefs::instance()->mHourSize ) | 266 | if ( tSize == KOPrefs::instance()->mHourSize ) |
267 | return; | 267 | return; |
268 | KOPrefs::instance()->mHourSize = tSize; | 268 | KOPrefs::instance()->mHourSize = tSize; |
269 | emit scaleChanged(); | 269 | emit scaleChanged(); |
270 | } | 270 | } |
271 | 271 | ||
272 | /** This is called in response to repaint() */ | 272 | /** This is called in response to repaint() */ |
273 | void TimeLabels::paintEvent(QPaintEvent*) | 273 | void TimeLabels::paintEvent(QPaintEvent*) |
274 | { | 274 | { |
275 | 275 | ||
276 | // kdDebug() << "paintevent..." << endl; | 276 | // kdDebug() << "paintevent..." << endl; |
277 | // this is another hack! | 277 | // this is another hack! |
278 | // QPainter painter(this); | 278 | // QPainter painter(this); |
279 | //QString c | 279 | //QString c |
280 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 280 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
281 | } | 281 | } |
282 | 282 | ||
283 | //////////////////////////////////////////////////////////////////////////// | 283 | //////////////////////////////////////////////////////////////////////////// |
284 | 284 | ||
285 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 285 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
286 | : QFrame(parent,name) | 286 | : QFrame(parent,name) |
287 | { | 287 | { |
288 | mColumns = 1; | 288 | mColumns = 1; |
289 | mTopBox = 0; | 289 | mTopBox = 0; |
290 | mLocation = loc; | 290 | mLocation = loc; |
291 | mTopLayout = 0; | 291 | mTopLayout = 0; |
292 | mPaintWidget = 0; | 292 | mPaintWidget = 0; |
293 | mXOffset = 0; | 293 | mXOffset = 0; |
294 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 294 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
295 | else mPixmap = SmallIcon("1downarrow"); | 295 | else mPixmap = SmallIcon("1downarrow"); |
296 | mEnabled.resize(mColumns); | 296 | mEnabled.resize(mColumns); |
297 | mEnabled.fill( false ); | 297 | mEnabled.fill( false ); |
298 | setMinimumHeight(mPixmap.height()); | 298 | setMinimumHeight(mPixmap.height()); |
299 | } | 299 | } |
300 | 300 | ||
301 | EventIndicator::~EventIndicator() | 301 | EventIndicator::~EventIndicator() |
302 | { | 302 | { |
303 | } | 303 | } |
304 | 304 | ||
305 | void EventIndicator::drawContents(QPainter *p) | 305 | void EventIndicator::drawContents(QPainter *p) |
306 | { | 306 | { |
307 | 307 | ||
308 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 308 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
309 | KDGanttSplitterHandle* han = 0; | 309 | KDGanttSplitterHandle* han = 0; |
310 | if ( mPaintWidget ) | 310 | if ( mPaintWidget ) |
311 | han = mPaintWidget->firstHandle(); | 311 | han = mPaintWidget->firstHandle(); |
312 | if ( ! han ) { | 312 | if ( ! han ) { |
313 | int i; | 313 | int i; |
314 | for(i=0;i<mColumns;++i) { | 314 | for(i=0;i<mColumns;++i) { |
315 | if (mEnabled[i]) { | 315 | if (mEnabled[i]) { |
316 | int cellWidth = contentsRect().right()/mColumns; | 316 | int cellWidth = contentsRect().right()/mColumns; |
317 | int xOffset = KOGlobals::self()->reverseLayout() ? | 317 | int xOffset = KOGlobals::self()->reverseLayout() ? |
318 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : | 318 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : |
319 | i*cellWidth + (cellWidth -mPixmap.width()) /2; | 319 | i*cellWidth + (cellWidth -mPixmap.width()) /2; |
320 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); | 320 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | } else { | 323 | } else { |
324 | han->repaint(); | 324 | han->repaint(); |
325 | //mPaintWidget->setBackgroundColor( red ); | 325 | //mPaintWidget->setBackgroundColor( red ); |
326 | 326 | ||
327 | QPainter pa( han ); | 327 | QPainter pa( han ); |
328 | int i; | 328 | int i; |
329 | bool setColor = false; | 329 | bool setColor = false; |
330 | for(i=0;i<mColumns;++i) { | 330 | for(i=0;i<mColumns;++i) { |
331 | if (mEnabled[i]) { | 331 | if (mEnabled[i]) { |
332 | setColor = true; | 332 | setColor = true; |
333 | 333 | ||
334 | int cellWidth = contentsRect().right()/mColumns; | 334 | int cellWidth = contentsRect().right()/mColumns; |
335 | int xOffset = KOGlobals::self()->reverseLayout() ? | 335 | int xOffset = KOGlobals::self()->reverseLayout() ? |
336 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 336 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
337 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 337 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
338 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 338 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
339 | //qDebug("222draw pix %d ",xOffset ); | 339 | //qDebug("222draw pix %d ",xOffset ); |
340 | 340 | ||
341 | } | 341 | } |
342 | 342 | ||
343 | } | 343 | } |
344 | pa.end(); | 344 | pa.end(); |
345 | 345 | ||
346 | } | 346 | } |
347 | } | 347 | } |
348 | 348 | ||
349 | void EventIndicator::setXOffset( int x ) | 349 | void EventIndicator::setXOffset( int x ) |
350 | { | 350 | { |
351 | mXOffset = x; | 351 | mXOffset = x; |
352 | } | 352 | } |
353 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 353 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
354 | { | 354 | { |
355 | mPaintWidget = w; | 355 | mPaintWidget = w; |
356 | setMaximumHeight(0); | 356 | setMaximumHeight(0); |
357 | setMinimumHeight(0); | 357 | setMinimumHeight(0); |
358 | } | 358 | } |
359 | void EventIndicator::changeColumns(int columns) | 359 | void EventIndicator::changeColumns(int columns) |
360 | { | 360 | { |
361 | mColumns = columns; | 361 | mColumns = columns; |
362 | mEnabled.resize(mColumns); | 362 | mEnabled.resize(mColumns); |
363 | 363 | ||
364 | update(); | 364 | update(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void EventIndicator::enableColumn(int column, bool enable) | 367 | void EventIndicator::enableColumn(int column, bool enable) |
368 | { | 368 | { |
369 | mEnabled[column] = enable; | 369 | mEnabled[column] = enable; |
370 | } | 370 | } |
371 | 371 | ||
372 | 372 | ||
373 | //////////////////////////////////////////////////////////////////////////// | 373 | //////////////////////////////////////////////////////////////////////////// |
374 | //////////////////////////////////////////////////////////////////////////// | 374 | //////////////////////////////////////////////////////////////////////////// |
375 | //////////////////////////////////////////////////////////////////////////// | 375 | //////////////////////////////////////////////////////////////////////////// |
376 | 376 | ||
377 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 377 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
378 | KOEventView (cal,parent,name) | 378 | KOEventView (cal,parent,name) |
379 | { | 379 | { |
380 | mBlockUpdating = true; | 380 | mBlockUpdating = true; |
381 | mStartHour = 8; | 381 | mStartHour = 8; |
382 | mSelectedDates.append(QDate::currentDate()); | 382 | mSelectedDates.append(QDate::currentDate()); |
383 | 383 | ||
384 | mLayoutDayLabels = 0; | 384 | mLayoutDayLabels = 0; |
385 | mDayLabelsFrame = 0; | 385 | mDayLabelsFrame = 0; |
386 | mDayLabels = 0; | 386 | mDayLabels = 0; |
387 | bool isRTL = KOGlobals::self()->reverseLayout(); | 387 | bool isRTL = KOGlobals::self()->reverseLayout(); |
388 | QPixmap expandPix; | 388 | QPixmap expandPix; |
389 | if ( KOPrefs::instance()->mVerticalScreen ) { | 389 | if ( KOPrefs::instance()->mVerticalScreen ) { |
390 | expandPix = SmallIcon( "1updownarrow" ); | 390 | expandPix = SmallIcon( "1updownarrow" ); |
391 | } else { | 391 | } else { |
392 | expandPix = SmallIcon("1leftrightarrow" ); | 392 | expandPix = SmallIcon("1leftrightarrow" ); |
393 | } | 393 | } |
394 | 394 | ||
395 | QBoxLayout *topLayout = new QVBoxLayout(this); | 395 | QBoxLayout *topLayout = new QVBoxLayout(this); |
396 | 396 | ||
397 | // Create day name labels for agenda columns | 397 | // Create day name labels for agenda columns |
398 | // Create agenda splitter | 398 | // Create agenda splitter |
399 | 399 | ||
400 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 400 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
401 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 401 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
402 | topLayout->addWidget( mSplitterAgenda ); | 402 | topLayout->addWidget( mSplitterAgenda ); |
403 | mAllDayFrame = new QHBox(mSplitterAgenda); | 403 | mAllDayFrame = new QHBox(mSplitterAgenda); |
404 | mAllDayFrame->setFocusPolicy(NoFocus); | 404 | mAllDayFrame->setFocusPolicy(NoFocus); |
405 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 405 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
406 | agendaFrame->setFocusPolicy(NoFocus); | 406 | agendaFrame->setFocusPolicy(NoFocus); |
407 | 407 | ||
408 | // Create all-day agenda widget | 408 | // Create all-day agenda widget |
409 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 409 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
410 | 410 | ||
411 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 411 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
412 | mExpandButton->setPixmap( expandPix ); | 412 | mExpandButton->setPixmap( expandPix ); |
413 | int widebut = mExpandButton->sizeHint().width()+4; | 413 | int widebut = mExpandButton->sizeHint().width()+4; |
414 | int heibut = mExpandButton->sizeHint().height()+4; | 414 | int heibut = mExpandButton->sizeHint().height()+4; |
415 | if ( heibut > widebut ) | 415 | if ( heibut > widebut ) |
416 | widebut = heibut ; | 416 | widebut = heibut ; |
417 | 417 | ||
418 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 418 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
419 | // QSizePolicy::Fixed ) ); | 419 | // QSizePolicy::Fixed ) ); |
420 | mExpandButton->setFixedSize( widebut, widebut); | 420 | mExpandButton->setFixedSize( widebut, widebut); |
421 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 421 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
422 | mExpandButton->setFocusPolicy(NoFocus); | 422 | mExpandButton->setFocusPolicy(NoFocus); |
423 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 423 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
424 | mAllDayAgenda->setFocusPolicy(NoFocus); | 424 | mAllDayAgenda->setFocusPolicy(NoFocus); |
425 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 425 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
426 | 426 | ||
427 | // Create event context menu for all day agenda | 427 | // Create event context menu for all day agenda |
428 | //mAllDayAgendaPopup = eventPopup(); | 428 | //mAllDayAgendaPopup = eventPopup(); |
429 | 429 | ||
430 | // Create agenda frame | 430 | // Create agenda frame |
431 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); | 431 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); |
432 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 432 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
433 | 433 | ||
434 | // create event indicator bars | 434 | // create event indicator bars |
435 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 435 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
436 | #ifndef DESKTOP_VERSION | 436 | #ifndef DESKTOP_VERSION |
437 | // FIX | 437 | // FIX |
438 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 438 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
439 | #endif | 439 | #endif |
440 | mDayLabelsFrame = new QHBox(agendaFrame); | 440 | mDayLabelsFrame = new QHBox(agendaFrame); |
441 | //topLayout->addWidget(mDayLabelsFrame); | 441 | //topLayout->addWidget(mDayLabelsFrame); |
442 | mDayLabels = new QFrame (mDayLabelsFrame); | 442 | mDayLabels = new QFrame (mDayLabelsFrame); |
443 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 443 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
444 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 444 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
445 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 445 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
446 | 446 | ||
447 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 447 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
448 | agendaFrame); | 448 | agendaFrame); |
449 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 449 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
450 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 450 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
451 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 451 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
452 | 452 | ||
453 | // Create time labels | 453 | // Create time labels |
454 | mTimeLabels = new TimeLabels(24,agendaFrame); | 454 | mTimeLabels = new TimeLabels(24,agendaFrame); |
455 | agendaLayout->addWidget(mTimeLabels,2,0); | 455 | agendaLayout->addWidget(mTimeLabels,2,0); |
456 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 456 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
457 | this,SLOT(updateConfig())); | 457 | this,SLOT(updateConfig())); |
458 | 458 | ||
459 | // Create agenda | 459 | // Create agenda |
460 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 460 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
461 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 461 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
462 | agendaLayout->setColStretch(1,1); | 462 | agendaLayout->setColStretch(1,1); |
463 | mAgenda->setFocusPolicy(NoFocus); | 463 | mAgenda->setFocusPolicy(NoFocus); |
464 | // Create event context menu for agenda | 464 | // Create event context menu for agenda |
465 | mAllAgendaPopup = eventPopup(); | 465 | mAllAgendaPopup = eventPopup(); |
466 | 466 | ||
467 | #if 0 | 467 | #if 0 |
468 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 468 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
469 | i18n("Toggle Alarm"),mAgenda, | 469 | i18n("Toggle Alarm"),mAgenda, |
470 | SLOT(popupAlarm()),true); | 470 | SLOT(popupAlarm()),true); |
471 | 471 | ||
472 | #endif | 472 | #endif |
473 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 473 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
474 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 474 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
475 | 475 | ||
476 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 476 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
477 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 477 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
478 | mAgenda->setPopup( mAllAgendaPopup ); | 478 | mAgenda->setPopup( mAllAgendaPopup ); |
479 | mAllDayAgenda->setPopup( mAllAgendaPopup ); | 479 | mAllDayAgenda->setPopup( mAllAgendaPopup ); |
480 | // make connections between dependent widgets | 480 | // make connections between dependent widgets |
481 | mTimeLabels->setAgenda(mAgenda); | 481 | mTimeLabels->setAgenda(mAgenda); |
482 | 482 | ||
483 | // Update widgets to reflect user preferences | 483 | // Update widgets to reflect user preferences |
484 | // updateConfig(); | 484 | // updateConfig(); |
485 | 485 | ||
486 | // createDayLabels(); | 486 | // createDayLabels(); |
487 | 487 | ||
488 | // these blank widgets make the All Day Event box line up with the agenda | 488 | // these blank widgets make the All Day Event box line up with the agenda |
489 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 489 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
490 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 490 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
491 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 491 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
492 | 492 | ||
493 | // Scrolling | 493 | // Scrolling |
494 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 494 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
495 | mTimeLabels, SLOT(positionChanged())); | 495 | mTimeLabels, SLOT(positionChanged())); |
496 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 496 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
497 | SLOT(setContentsPos(int))); | 497 | SLOT(setContentsPos(int))); |
498 | 498 | ||
499 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 499 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
500 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 500 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
501 | 501 | ||
502 | // Create/Show/Edit/Delete Event | 502 | // Create/Show/Edit/Delete Event |
503 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 503 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
504 | SLOT(newEvent(int,int))); | 504 | SLOT(newEvent(int,int))); |
505 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 505 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
506 | SLOT(newTodo(int,int))); | 506 | SLOT(newTodo(int,int))); |
507 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 507 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
508 | SLOT(newEvent(int,int,int,int))); | 508 | SLOT(newEvent(int,int,int,int))); |
509 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 509 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
510 | SLOT(newEventAllDay(int,int))); | 510 | SLOT(newEventAllDay(int,int))); |
511 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 511 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
512 | SLOT(newTodoAllDay(int,int))); | 512 | SLOT(newTodoAllDay(int,int))); |
513 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 513 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
514 | SLOT(newEventAllDay(int,int))); | 514 | SLOT(newEventAllDay(int,int))); |
515 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 515 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
516 | SLOT(newTimeSpanSelected(int,int,int,int))); | 516 | SLOT(newTimeSpanSelected(int,int,int,int))); |
517 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 517 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
518 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 518 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
519 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 519 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
520 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 520 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
521 | 521 | ||
522 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 522 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
523 | SIGNAL(editIncidenceSignal(Incidence *))); | 523 | SIGNAL(editIncidenceSignal(Incidence *))); |
524 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 524 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
525 | SIGNAL(editIncidenceSignal(Incidence *))); | 525 | SIGNAL(editIncidenceSignal(Incidence *))); |
526 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 526 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
527 | SIGNAL(showIncidenceSignal(Incidence *))); | 527 | SIGNAL(showIncidenceSignal(Incidence *))); |
528 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 528 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
529 | SIGNAL(showIncidenceSignal(Incidence *))); | 529 | SIGNAL(showIncidenceSignal(Incidence *))); |
530 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 530 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
531 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 531 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
532 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 532 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
533 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 533 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
534 | 534 | ||
535 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 535 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
536 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 536 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
537 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 537 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
538 | SLOT(updateEventDates(KOAgendaItem *, int))); | 538 | SLOT(updateEventDates(KOAgendaItem *, int))); |
539 | 539 | ||
540 | // event indicator update | 540 | // event indicator update |
541 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 541 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
542 | SLOT(updateEventIndicatorTop(int))); | 542 | SLOT(updateEventIndicatorTop(int))); |
543 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 543 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
544 | SLOT(updateEventIndicatorBottom(int))); | 544 | SLOT(updateEventIndicatorBottom(int))); |
545 | // drag signals | 545 | // drag signals |
546 | /* | 546 | /* |
547 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 547 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
548 | SLOT(startDrag(Event *))); | 548 | SLOT(startDrag(Event *))); |
549 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 549 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
550 | SLOT(startDrag(Event *))); | 550 | SLOT(startDrag(Event *))); |
551 | */ | 551 | */ |
552 | // synchronize selections | 552 | // synchronize selections |
553 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 553 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
554 | mAllDayAgenda, SLOT( deselectItem() ) ); | 554 | mAllDayAgenda, SLOT( deselectItem() ) ); |
555 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 555 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
556 | mAgenda, SLOT( deselectItem() ) ); | 556 | mAgenda, SLOT( deselectItem() ) ); |
557 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 557 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
558 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 558 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
559 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 559 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
560 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 560 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
561 | connect( mAgenda, SIGNAL( resizedSignal() ), | 561 | connect( mAgenda, SIGNAL( resizedSignal() ), |
562 | SLOT( updateConfig( ) ) ); | 562 | SLOT( updateConfig( ) ) ); |
563 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 563 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
564 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 564 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
565 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 565 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
566 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 566 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
567 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 567 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
568 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 568 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
569 | 569 | ||
570 | 570 | ||
571 | } | 571 | } |
572 | 572 | ||
573 | void KOAgendaView::toggleAllDay() | 573 | void KOAgendaView::toggleAllDay() |
574 | { | 574 | { |
575 | if ( mSplitterAgenda->firstHandle() ) | 575 | if ( mSplitterAgenda->firstHandle() ) |
576 | mSplitterAgenda->firstHandle()->toggle(); | 576 | mSplitterAgenda->firstHandle()->toggle(); |
577 | } | 577 | } |
578 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 578 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
579 | { | 579 | { |
580 | calendar()->addIncidence( inc ); | 580 | calendar()->addIncidence( inc ); |
581 | 581 | ||
582 | if ( incOld ) { | 582 | if ( incOld ) { |
583 | if ( incOld->type() == "Todo" ) | 583 | if ( incOld->type() == "Todo" ) |
584 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 584 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
585 | else | 585 | else |
586 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 586 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
587 | } | 587 | } |
588 | 588 | ||
589 | } | 589 | } |
590 | 590 | ||
591 | KOAgendaView::~KOAgendaView() | 591 | KOAgendaView::~KOAgendaView() |
592 | { | 592 | { |
593 | delete mAllAgendaPopup; | 593 | delete mAllAgendaPopup; |
594 | //delete mAllDayAgendaPopup; | 594 | //delete mAllDayAgendaPopup; |
595 | delete KOAgendaItem::paintPix(); | 595 | delete KOAgendaItem::paintPix(); |
596 | delete KOAgendaItem::paintPixSel(); | 596 | delete KOAgendaItem::paintPixSel(); |
597 | } | 597 | } |
598 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 598 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
599 | { | 599 | { |
600 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 600 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
601 | bool uc = false; | 601 | bool uc = false; |
602 | int ow = e->oldSize().width(); | 602 | int ow = e->oldSize().width(); |
603 | int oh = e->oldSize().height(); | 603 | int oh = e->oldSize().height(); |
604 | int w = e->size().width(); | 604 | int w = e->size().width(); |
605 | int h = e->size().height(); | 605 | int h = e->size().height(); |
606 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 606 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
607 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 607 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
608 | uc = true; | 608 | uc = true; |
609 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 609 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
610 | } | 610 | } |
611 | mUpcomingWidth = e->size().width() ; | 611 | mUpcomingWidth = e->size().width() ; |
612 | if ( mBlockUpdating || uc ) { | 612 | if ( mBlockUpdating || uc ) { |
613 | mBlockUpdating = false; | 613 | mBlockUpdating = false; |
614 | //mAgenda->setMinimumSize(800 , 600 ); | 614 | //mAgenda->setMinimumSize(800 , 600 ); |
615 | //qDebug("mAgenda->resize+++++++++++++++ "); | 615 | //qDebug("mAgenda->resize+++++++++++++++ "); |
616 | updateConfig(); | 616 | updateConfig(); |
617 | //qDebug("KOAgendaView::Updating now possible "); | 617 | //qDebug("KOAgendaView::Updating now possible "); |
618 | } else | 618 | } else |
619 | createDayLabels(); | 619 | createDayLabels(); |
620 | //qDebug("resizeEvent end "); | 620 | //qDebug("resizeEvent end "); |
621 | 621 | ||
622 | } | 622 | } |
623 | void KOAgendaView::slotDaylabelClicked( int num ) | 623 | void KOAgendaView::slotDaylabelClicked( int num ) |
624 | { | 624 | { |
625 | 625 | ||
626 | QDate firstDate = mSelectedDates.first(); | 626 | QDate firstDate = mSelectedDates.first(); |
627 | if ( num == -1 ) | 627 | if ( num == -1 ) |
628 | emit showDateView( 6, firstDate ); | 628 | emit showDateView( 6, firstDate ); |
629 | else if (num >= 0 ) { | 629 | else if (num >= 0 ) { |
630 | if ( mSelectedDates.count() == 1) | 630 | if ( mSelectedDates.count() == 1) |
631 | emit showDateView( 9, firstDate.addDays( num ) ); | 631 | emit showDateView( 9, firstDate.addDays( num ) ); |
632 | else | 632 | else |
633 | emit showDateView( 3, firstDate.addDays( num ) ); | 633 | emit showDateView( 3, firstDate.addDays( num ) ); |
634 | } | 634 | } |
635 | else | 635 | else |
636 | showDateView( 10, firstDate.addDays(1) ); | 636 | showDateView( 10, firstDate.addDays(1) ); |
637 | } | 637 | } |
638 | 638 | ||
639 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 639 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
640 | { | 640 | { |
641 | 641 | ||
642 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 642 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
643 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 643 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
644 | mDayLabelsList.append( dayLabel ); | 644 | mDayLabelsList.append( dayLabel ); |
645 | mLayoutDayLabels->addWidget(dayLabel); | 645 | mLayoutDayLabels->addWidget(dayLabel); |
646 | return dayLabel ; | 646 | return dayLabel ; |
647 | } | 647 | } |
648 | 648 | ||
649 | void KOAgendaView::createDayLabels() | 649 | void KOAgendaView::createDayLabels() |
650 | { | 650 | { |
651 | 651 | ||
652 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 652 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
653 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 653 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
654 | return; | 654 | return; |
655 | 655 | ||
656 | } | 656 | } |
657 | int newHight; | 657 | int newHight; |
658 | if ( !mSelectedDates.count()) | 658 | if ( !mSelectedDates.count()) |
659 | return; | 659 | return; |
660 | 660 | ||
661 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 661 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
662 | // It would remove some flickering and gain speed (since this is called by | 662 | // It would remove some flickering and gain speed (since this is called by |
663 | // each updateView() call) | 663 | // each updateView() call) |
664 | 664 | ||
665 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 665 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
666 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 666 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
667 | if ( maxWid < 20 ) | 667 | if ( maxWid < 20 ) |
668 | maxWid = 20; | 668 | maxWid = 20; |
669 | 669 | ||
670 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 670 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
671 | QFontMetrics fm ( dlf ); | 671 | QFontMetrics fm ( dlf ); |
672 | int selCount = mSelectedDates.count(); | 672 | int selCount = mSelectedDates.count(); |
673 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; | 673 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; |
674 | QString dayTest = "Mon 20"; | 674 | QString dayTest = "Mon 20"; |
675 | //QString dayTest = "Mon 20"; | 675 | //QString dayTest = "Mon 20"; |
676 | int wid = fm.width( dayTest ); | 676 | int wid = fm.width( dayTest ); |
677 | //maxWid -= ( selCount * 3 ); //working for QLabels | 677 | //maxWid -= ( selCount * 3 ); //working for QLabels |
678 | if ( QApplication::desktop()->width() <= 320 ) | 678 | if ( QApplication::desktop()->width() <= 320 ) |
679 | maxWid -= ( selCount * 3 ); //working for QPushButton | 679 | maxWid -= ( selCount * 3 ); //working for QPushButton |
680 | else | 680 | else |
681 | maxWid -= ( selCount * 3 ); //working for QPushButton | 681 | maxWid -= ( selCount * 3 ); //working for QPushButton |
682 | if ( maxWid < 0 ) | 682 | if ( maxWid < 0 ) |
683 | maxWid = 20; | 683 | maxWid = 20; |
684 | int needWid = wid * selCount; | 684 | int needWid = wid * selCount; |
685 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 685 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
686 | //if ( needWid > maxWid ) | 686 | //if ( needWid > maxWid ) |
687 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 687 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
688 | while ( needWid > maxWid ) { | 688 | while ( needWid > maxWid ) { |
689 | dayTest = dayTest.left( dayTest.length() - 1 ); | 689 | dayTest = dayTest.left( dayTest.length() - 1 ); |
690 | wid = fm.width( dayTest ); | 690 | wid = fm.width( dayTest ); |
691 | needWid = wid * selCount; | 691 | needWid = wid * selCount; |
692 | } | 692 | } |
693 | int maxLen = dayTest.length(); | 693 | int maxLen = dayTest.length(); |
694 | int fontPoint = dlf.pointSize(); | 694 | int fontPoint = dlf.pointSize(); |
695 | if ( maxLen < 2 ) { | 695 | if ( maxLen < 2 ) { |
696 | int fontPoint = dlf.pointSize(); | 696 | int fontPoint = dlf.pointSize(); |
697 | while ( fontPoint > 4 ) { | 697 | while ( fontPoint > 4 ) { |
698 | --fontPoint; | 698 | --fontPoint; |
699 | dlf.setPointSize( fontPoint ); | 699 | dlf.setPointSize( fontPoint ); |
700 | QFontMetrics f( dlf ); | 700 | QFontMetrics f( dlf ); |
701 | wid = f.width( "30" ); | 701 | wid = f.width( "30" ); |
702 | needWid = wid * selCount; | 702 | needWid = wid * selCount; |
703 | if ( needWid < maxWid ) | 703 | if ( needWid < maxWid ) |
704 | break; | 704 | break; |
705 | } | 705 | } |
706 | maxLen = 2; | 706 | maxLen = 2; |
707 | } | 707 | } |
708 | //qDebug("Max len %d ", dayTest.length() ); | 708 | //qDebug("Max len %d ", dayTest.length() ); |
709 | 709 | ||
710 | QFontMetrics tempF( dlf ); | 710 | QFontMetrics tempF( dlf ); |
711 | newHight = tempF.height(); | 711 | newHight = tempF.height(); |
712 | mDayLabels->setFont( dlf ); | 712 | mDayLabels->setFont( dlf ); |
713 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 713 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
714 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 714 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
715 | //mLayoutDayLabels->addSpacing( 2 ); | 715 | //mLayoutDayLabels->addSpacing( 2 ); |
716 | // QFont lFont = dlf; | 716 | // QFont lFont = dlf; |
717 | bool appendLabels = false; | 717 | bool appendLabels = false; |
718 | KOAgendaButton *dayLabel; | 718 | KOAgendaButton *dayLabel; |
719 | dayLabel = mDayLabelsList.first(); | 719 | dayLabel = mDayLabelsList.first(); |
720 | if ( !dayLabel ) { | 720 | if ( !dayLabel ) { |
721 | appendLabels = true; | 721 | appendLabels = true; |
722 | dayLabel = getNewDaylabel(); | 722 | dayLabel = getNewDaylabel(); |
723 | } | 723 | } |
724 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 724 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
725 | dayLabel->setFont( dlf ); | 725 | dayLabel->setFont( dlf ); |
726 | dayLabel->setNum( -1 ); | 726 | dayLabel->setNum( -1 ); |
727 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 727 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
728 | #if 0 | 728 | #if 0 |
729 | if ( QApplication::desktop()->width() <= 320 ) | 729 | if ( QApplication::desktop()->width() <= 320 ) |
730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); | 730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); |
731 | else | 731 | else |
732 | #endif | 732 | #endif |
733 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 733 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
734 | dayLabel->show(); | 734 | dayLabel->show(); |
735 | DateList::ConstIterator dit; | 735 | DateList::ConstIterator dit; |
736 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 736 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
737 | int counter = -1; | 737 | int counter = -1; |
738 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 738 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
739 | ++counter; | 739 | ++counter; |
740 | QDate date = *dit; | 740 | QDate date = *dit; |
741 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 741 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
742 | if ( ! appendLabels ) { | 742 | if ( ! appendLabels ) { |
743 | dayLabel = mDayLabelsList.next(); | 743 | dayLabel = mDayLabelsList.next(); |
744 | if ( !dayLabel ) | 744 | if ( !dayLabel ) |
745 | appendLabels = true; | 745 | appendLabels = true; |
746 | } | 746 | } |
747 | if ( appendLabels ) { | 747 | if ( appendLabels ) { |
748 | dayLabel = getNewDaylabel(); | 748 | dayLabel = getNewDaylabel(); |
749 | } | 749 | } |
750 | dayLabel->setMinimumWidth( 1 ); | 750 | dayLabel->setMinimumWidth( 1 ); |
751 | dayLabel->setMaximumWidth( 10240 ); | 751 | dayLabel->setMaximumWidth( 10240 ); |
752 | dayLabel->setFont( dlf ); | 752 | dayLabel->setFont( dlf ); |
753 | dayLabel->show(); | 753 | dayLabel->show(); |
754 | dayLabel->setAutoRepeat( false ); | 754 | dayLabel->setAutoRepeat( false ); |
755 | dayLabel->setNum( counter ); | 755 | dayLabel->setNum( counter ); |
756 | QString str; | 756 | QString str; |
757 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 757 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
758 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 758 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
759 | switch ( maxLen ) { | 759 | switch ( maxLen ) { |
760 | case 2: | 760 | case 2: |
761 | str = QString::number( date.day() ); | 761 | str = QString::number( date.day() ); |
762 | break; | 762 | break; |
763 | 763 | ||
764 | case 3: | 764 | case 3: |
765 | str = dayName.left( 1 ) +QString::number( date.day()); | 765 | str = dayName.left( 1 ) +QString::number( date.day()); |
766 | 766 | ||
767 | break; | 767 | break; |
768 | case 4: | 768 | case 4: |
769 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 769 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
770 | 770 | ||
771 | break; | 771 | break; |
772 | case 5: | 772 | case 5: |
773 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 773 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
774 | 774 | ||
775 | break; | 775 | break; |
776 | case 6: | 776 | case 6: |
777 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 777 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
778 | break; | 778 | break; |
779 | 779 | ||
780 | default: | 780 | default: |
781 | break; | 781 | break; |
782 | } | 782 | } |
783 | if ( oneday ) { | 783 | if ( oneday ) { |
784 | QString addString; | 784 | QString addString; |
785 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 785 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
786 | addString = i18n("Today"); | 786 | addString = i18n("Today"); |
787 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 787 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
788 | addString = i18n("Tomorrow"); | 788 | addString = i18n("Tomorrow"); |
789 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 789 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
790 | addString = i18n("Yesterday"); | 790 | addString = i18n("Yesterday"); |
791 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 791 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
792 | addString = i18n("Day before yesterday"); | 792 | addString = i18n("Day before yesterday"); |
793 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 793 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
794 | addString = i18n("Day after tomorrow"); | 794 | addString = i18n("Day after tomorrow"); |
795 | if ( !addString.isEmpty() ) { | 795 | if ( !addString.isEmpty() ) { |
796 | str = addString+", " + str; | 796 | str = addString+", " + str; |
797 | } else { | 797 | } else { |
798 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 798 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
799 | } | 799 | } |
800 | } | 800 | } |
801 | dayLabel->setText(str); | 801 | dayLabel->setText(str); |
802 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 802 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
803 | if (date == QDate::currentDate()) { | 803 | if (date == QDate::currentDate()) { |
804 | QFont bFont = dlf; | 804 | QFont bFont = dlf; |
805 | bFont.setBold( true ); | 805 | bFont.setBold( true ); |
806 | dayLabel->setFont(bFont); | 806 | dayLabel->setFont(bFont); |
807 | } | 807 | } |
808 | //dayLayout->addWidget(dayLabel); | 808 | //dayLayout->addWidget(dayLabel); |
809 | 809 | ||
810 | #ifndef KORG_NOPLUGINS | 810 | #ifndef KORG_NOPLUGINS |
811 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 811 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
812 | CalendarDecoration *it; | 812 | CalendarDecoration *it; |
813 | for(it = cds.first(); it; it = cds.next()) { | 813 | for(it = cds.first(); it; it = cds.next()) { |
814 | QString text = it->shortText( date ); | 814 | QString text = it->shortText( date ); |
815 | if ( !text.isEmpty() ) { | 815 | if ( !text.isEmpty() ) { |
816 | QLabel *label = new QLabel(text,mDayLabels); | 816 | QLabel *label = new QLabel(text,mDayLabels); |
817 | label->setAlignment(AlignCenter); | 817 | label->setAlignment(AlignCenter); |
818 | dayLayout->addWidget(label); | 818 | dayLayout->addWidget(label); |
819 | } | 819 | } |
820 | } | 820 | } |
821 | 821 | ||
822 | for(it = cds.first(); it; it = cds.next()) { | 822 | for(it = cds.first(); it; it = cds.next()) { |
823 | QWidget *wid = it->smallWidget(mDayLabels,date); | 823 | QWidget *wid = it->smallWidget(mDayLabels,date); |
824 | if ( wid ) { | 824 | if ( wid ) { |
825 | // wid->setHeight(20); | 825 | // wid->setHeight(20); |
826 | dayLayout->addWidget(wid); | 826 | dayLayout->addWidget(wid); |
827 | } | 827 | } |
828 | } | 828 | } |
829 | #endif | 829 | #endif |
830 | } | 830 | } |
831 | if ( ! appendLabels ) { | 831 | if ( ! appendLabels ) { |
832 | dayLabel = mDayLabelsList.next(); | 832 | dayLabel = mDayLabelsList.next(); |
833 | if ( !dayLabel ) | 833 | if ( !dayLabel ) |
834 | appendLabels = true; | 834 | appendLabels = true; |
835 | } | 835 | } |
836 | if ( appendLabels ) { | 836 | if ( appendLabels ) { |
837 | dayLabel = getNewDaylabel(); | 837 | dayLabel = getNewDaylabel(); |
838 | } | 838 | } |
839 | //dayLabel->hide();//test only | 839 | //dayLabel->hide();//test only |
840 | 840 | ||
841 | dayLabel->setText(">"); | 841 | dayLabel->setText(">"); |
842 | dayLabel->setFont( dlf ); | 842 | dayLabel->setFont( dlf ); |
843 | dayLabel->setAutoRepeat( true ); | 843 | dayLabel->setAutoRepeat( true ); |
844 | dayLabel->show(); | 844 | dayLabel->show(); |
845 | dayLabel->setNum( -2 ); | 845 | dayLabel->setNum( -2 ); |
846 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 846 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
847 | 847 | ||
848 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 848 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
849 | if ( !appendLabels ) { | 849 | if ( !appendLabels ) { |
850 | dayLabel = mDayLabelsList.next(); | 850 | dayLabel = mDayLabelsList.next(); |
851 | while ( dayLabel ) { | 851 | while ( dayLabel ) { |
852 | //qDebug("!dayLabel %d",dayLabel ); | 852 | //qDebug("!dayLabel %d",dayLabel ); |
853 | dayLabel->hide(); | 853 | dayLabel->hide(); |
854 | dayLabel = mDayLabelsList.next(); | 854 | dayLabel = mDayLabelsList.next(); |
855 | } | 855 | } |
856 | } | 856 | } |
857 | 857 | ||
858 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 858 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
859 | } | 859 | } |
860 | 860 | ||
861 | int KOAgendaView::maxDatesHint() | 861 | int KOAgendaView::maxDatesHint() |
862 | { | 862 | { |
863 | // Not sure about the max number of events, so return 0 for now. | 863 | // Not sure about the max number of events, so return 0 for now. |
864 | return 0; | 864 | return 0; |
865 | } | 865 | } |
866 | 866 | ||
867 | int KOAgendaView::currentDateCount() | 867 | int KOAgendaView::currentDateCount() |
868 | { | 868 | { |
869 | return mSelectedDates.count(); | 869 | return mSelectedDates.count(); |
870 | } | 870 | } |
871 | 871 | ||
872 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 872 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
873 | { | 873 | { |
874 | QPtrList<Incidence> selected; | 874 | QPtrList<Incidence> selected; |
875 | Incidence *incidence; | 875 | Incidence *incidence; |
876 | 876 | ||
877 | incidence = mAgenda->selectedIncidence(); | 877 | incidence = mAgenda->selectedIncidence(); |
878 | if (incidence) selected.append(incidence); | 878 | if (incidence) selected.append(incidence); |
879 | 879 | ||
880 | incidence = mAllDayAgenda->selectedIncidence(); | 880 | incidence = mAllDayAgenda->selectedIncidence(); |
881 | if (incidence) selected.append(incidence); | 881 | if (incidence) selected.append(incidence); |
882 | 882 | ||
883 | return selected; | 883 | return selected; |
884 | } | 884 | } |
885 | 885 | ||
886 | DateList KOAgendaView::selectedDates() | 886 | DateList KOAgendaView::selectedDates() |
887 | { | 887 | { |
888 | DateList selected; | 888 | DateList selected; |
889 | QDate qd; | 889 | QDate qd; |
890 | 890 | ||
891 | qd = mAgenda->selectedIncidenceDate(); | 891 | qd = mAgenda->selectedIncidenceDate(); |
892 | if (qd.isValid()) selected.append(qd); | 892 | if (qd.isValid()) selected.append(qd); |
893 | 893 | ||
894 | qd = mAllDayAgenda->selectedIncidenceDate(); | 894 | qd = mAllDayAgenda->selectedIncidenceDate(); |
895 | if (qd.isValid()) selected.append(qd); | 895 | if (qd.isValid()) selected.append(qd); |
896 | 896 | ||
897 | return selected; | 897 | return selected; |
898 | } | 898 | } |
899 | 899 | ||
900 | 900 | ||
901 | void KOAgendaView::updateView() | 901 | void KOAgendaView::updateView() |
902 | { | 902 | { |
903 | if ( mBlockUpdating ) | 903 | if ( mBlockUpdating ) |
904 | return; | 904 | return; |
905 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 905 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
906 | fillAgenda(); | 906 | fillAgenda(); |
907 | 907 | ||
908 | } | 908 | } |
909 | 909 | ||
910 | 910 | ||
911 | /* | 911 | /* |
912 | Update configuration settings for the agenda view. This method is not | 912 | Update configuration settings for the agenda view. This method is not |
913 | complete. | 913 | complete. |
914 | */ | 914 | */ |
915 | void KOAgendaView::updateConfig() | 915 | void KOAgendaView::updateConfig() |
916 | { | 916 | { |
917 | if ( mBlockUpdating ) | 917 | if ( mBlockUpdating ) |
918 | return; | 918 | return; |
919 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 919 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
920 | int old = KOPrefs::instance()->mHourSize; | 920 | int old = KOPrefs::instance()->mHourSize; |
921 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 921 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
922 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 922 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
923 | } | 923 | } |
924 | 924 | ||
925 | 925 | ||
926 | // update config for children | 926 | // update config for children |
927 | mTimeLabels->updateConfig(); | 927 | mTimeLabels->updateConfig(); |
928 | mAgenda->storePosition(); | 928 | mAgenda->storePosition(); |
929 | mAgenda->updateConfig(); | 929 | mAgenda->updateConfig(); |
930 | mAllDayAgenda->updateConfig(); | 930 | mAllDayAgenda->updateConfig(); |
931 | // widget synchronization | 931 | // widget synchronization |
932 | //TODO: find a better way, maybe signal/slot | 932 | //TODO: find a better way, maybe signal/slot |
933 | mTimeLabels->positionChanged(); | 933 | mTimeLabels->positionChanged(); |
934 | 934 | ||
935 | // for some reason, this needs to be called explicitly | 935 | // for some reason, this needs to be called explicitly |
936 | mTimeLabels->repaint(); | 936 | mTimeLabels->repaint(); |
937 | 937 | ||
938 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 938 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
939 | 939 | ||
940 | // ToolTips displaying summary of events | 940 | // ToolTips displaying summary of events |
941 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 941 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
942 | ->mEnableToolTips); | 942 | ->mEnableToolTips); |
943 | 943 | ||
944 | //setHolidayMasks(); | 944 | //setHolidayMasks(); |
945 | 945 | ||
946 | //createDayLabels(); called by via updateView(); | 946 | //createDayLabels(); called by via updateView(); |
947 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 947 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
948 | updateView(); | 948 | updateView(); |
949 | mAgenda->restorePosition(); | 949 | mAgenda->restorePosition(); |
950 | } | 950 | } |
951 | 951 | ||
952 | 952 | ||
953 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 953 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
954 | { | 954 | { |
955 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 955 | |
956 | //qDebug("KOAgendaView::updateEventDates "); | 956 | |
957 | int xxx = item->cellX(); | ||
958 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); | ||
959 | if ( mMinY.at(xxx) > item->cellYTop() ) | ||
960 | mMinY.at(xxx) = item->cellYTop(); | ||
961 | if ( mMaxY.at(xxx) < item->cellYBottom() ) | ||
962 | mMaxY.at(xxx) = item->cellYBottom(); | ||
963 | |||
957 | QDateTime startDt,endDt; | 964 | QDateTime startDt,endDt; |
958 | QDate startDate; | 965 | QDate startDate; |
959 | int lenInSecs; | 966 | int lenInSecs; |
960 | // if ( type == KOAgenda::RESIZETOP ) | 967 | // if ( type == KOAgenda::RESIZETOP ) |
961 | // qDebug("RESIZETOP "); | 968 | // qDebug("RESIZETOP "); |
962 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 969 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
963 | // qDebug("RESIZEBOTTOM "); | 970 | // qDebug("RESIZEBOTTOM "); |
964 | // if ( type == KOAgenda::MOVE ) | 971 | // if ( type == KOAgenda::MOVE ) |
965 | // qDebug("MOVE "); | 972 | // qDebug("MOVE "); |
966 | if ( item->incidence()->type() == "Event" ) { | 973 | if ( item->incidence()->type() == "Event" ) { |
967 | startDt =item->incidence()->dtStart(); | 974 | startDt =item->incidence()->dtStart(); |
968 | endDt = item->incidence()->dtEnd(); | 975 | endDt = item->incidence()->dtEnd(); |
969 | lenInSecs = startDt.secsTo( endDt ); | 976 | lenInSecs = startDt.secsTo( endDt ); |
970 | } | 977 | } |
971 | 978 | ||
972 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 979 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
973 | 980 | ||
974 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 981 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
975 | startDate = mSelectedDates[item->mLastMoveXPos]; | 982 | startDate = mSelectedDates[item->mLastMoveXPos]; |
976 | } else { | 983 | } else { |
977 | if (item->cellX() < 0) { | 984 | if (item->cellX() < 0) { |
978 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 985 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
979 | } else { | 986 | } else { |
980 | startDate = mSelectedDates[item->cellX()]; | 987 | startDate = mSelectedDates[item->cellX()]; |
981 | } | 988 | } |
982 | } | 989 | } |
983 | startDt.setDate(startDate); | 990 | startDt.setDate(startDate); |
984 | 991 | ||
985 | if (item->incidence()->doesFloat()) { | 992 | if (item->incidence()->doesFloat()) { |
986 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 993 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
987 | } else { | 994 | } else { |
988 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 995 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
989 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 996 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
990 | if ( item->incidence()->type() == "Event" ) { | 997 | if ( item->incidence()->type() == "Event" ) { |
991 | if ( type == KOAgenda::MOVE ) { | 998 | if ( type == KOAgenda::MOVE ) { |
992 | endDt = startDt.addSecs(lenInSecs); | 999 | endDt = startDt.addSecs(lenInSecs); |
993 | 1000 | ||
994 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 1001 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
995 | if (item->lastMultiItem()) { | 1002 | if (item->lastMultiItem()) { |
996 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1003 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
997 | endDt.setDate(startDate. | 1004 | endDt.setDate(startDate. |
998 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1005 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
999 | } else { | 1006 | } else { |
1000 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1007 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1001 | endDt.setDate(startDate); | 1008 | endDt.setDate(startDate); |
1002 | } | 1009 | } |
1003 | } | 1010 | } |
1004 | } else { | 1011 | } else { |
1005 | // todo | 1012 | // todo |
1006 | if (item->lastMultiItem()) { | 1013 | if (item->lastMultiItem()) { |
1007 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1014 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1008 | endDt.setDate(startDate. | 1015 | endDt.setDate(startDate. |
1009 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1016 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1010 | } else { | 1017 | } else { |
1011 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1018 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1012 | if ( item->cellYBottom() > 0 ) | 1019 | if ( item->cellYBottom() > 0 ) |
1013 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1020 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1014 | else | 1021 | else |
1015 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1022 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1016 | endDt.setDate(startDate); | 1023 | endDt.setDate(startDate); |
1017 | } | 1024 | } |
1018 | } | 1025 | } |
1019 | } | 1026 | } |
1020 | if ( item->incidence()->type() == "Event" ) { | 1027 | if ( item->incidence()->type() == "Event" ) { |
1021 | item->incidence()->setDtStart(startDt); | 1028 | item->incidence()->setDtStart(startDt); |
1022 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1029 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1023 | } else if ( item->incidence()->type() == "Todo" ) { | 1030 | } else if ( item->incidence()->type() == "Todo" ) { |
1024 | Todo* to = static_cast<Todo*>(item->incidence()); | 1031 | Todo* to = static_cast<Todo*>(item->incidence()); |
1025 | 1032 | ||
1026 | to->setDtDue(endDt); | 1033 | to->setDtDue(endDt); |
1027 | if ( to->hasStartDate() ) { | 1034 | if ( to->hasStartDate() ) { |
1028 | if (to->dtStart() >= to->dtDue() ) | 1035 | if (to->dtStart() >= to->dtDue() ) |
1029 | to->setDtStart(to->dtDue().addDays( -2 )); | 1036 | to->setDtStart(to->dtDue().addDays( -2 )); |
1030 | } | 1037 | } |
1031 | 1038 | ||
1032 | } | 1039 | } |
1033 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1040 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1034 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1041 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1035 | item->setItemDate(startDt.date()); | 1042 | item->setItemDate(startDt.date()); |
1036 | //item->updateItem(); | 1043 | //item->updateItem(); |
1037 | if ( item->incidence()->type() == "Todo" ) { | 1044 | if ( item->incidence()->type() == "Todo" ) { |
1038 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1045 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1039 | 1046 | ||
1040 | } | 1047 | } |
1041 | else | 1048 | else |
1042 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1049 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1043 | item->updateItem(); | 1050 | item->updateItem(); |
1044 | } | 1051 | } |
1045 | 1052 | ||
1046 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1053 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1047 | { | 1054 | { |
1048 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1055 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1049 | 1056 | ||
1050 | mSelectedDates.clear(); | 1057 | mSelectedDates.clear(); |
1051 | // qDebug("KOAgendaView::showDates "); | 1058 | // qDebug("KOAgendaView::showDates "); |
1052 | QDate d = start; | 1059 | QDate d = start; |
1053 | while (d <= end) { | 1060 | while (d <= end) { |
1054 | mSelectedDates.append(d); | 1061 | mSelectedDates.append(d); |
1055 | d = d.addDays( 1 ); | 1062 | d = d.addDays( 1 ); |
1056 | } | 1063 | } |
1057 | 1064 | ||
1058 | // and update the view | 1065 | // and update the view |
1059 | fillAgenda(); | 1066 | fillAgenda(); |
1060 | } | 1067 | } |
1061 | 1068 | ||
1062 | 1069 | ||
1063 | void KOAgendaView::showEvents(QPtrList<Event>) | 1070 | void KOAgendaView::showEvents(QPtrList<Event>) |
1064 | { | 1071 | { |
1065 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1072 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1066 | } | 1073 | } |
1067 | 1074 | ||
1068 | void KOAgendaView::changeEventDisplay(Event *, int) | 1075 | void KOAgendaView::changeEventDisplay(Event *, int) |
1069 | { | 1076 | { |
1070 | // qDebug("KOAgendaView::changeEventDisplay "); | 1077 | // qDebug("KOAgendaView::changeEventDisplay "); |
1071 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1078 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1072 | // this should be re-written to be MUCH smarter. Right now we | 1079 | // this should be re-written to be MUCH smarter. Right now we |
1073 | // are just playing dumb. | 1080 | // are just playing dumb. |
1074 | fillAgenda(); | 1081 | fillAgenda(); |
1075 | } | 1082 | } |
1076 | 1083 | ||
1077 | void KOAgendaView::fillAgenda(const QDate &) | 1084 | void KOAgendaView::fillAgenda(const QDate &) |
1078 | { | 1085 | { |
1079 | // qDebug("KOAgendaView::fillAgenda "); | 1086 | // qDebug("KOAgendaView::fillAgenda "); |
1080 | fillAgenda(); | 1087 | fillAgenda(); |
1081 | } | 1088 | } |
1082 | 1089 | ||
1083 | void KOAgendaView::fillAgenda() | 1090 | void KOAgendaView::fillAgenda() |
1084 | { | 1091 | { |
1085 | if ( globalFlagBlockStartup ) | 1092 | if ( globalFlagBlockStartup ) |
1086 | return; | 1093 | return; |
1087 | if ( globalFlagBlockAgenda == 1 ) | 1094 | if ( globalFlagBlockAgenda == 1 ) |
1088 | return; | 1095 | return; |
1089 | static bool onlyOne = false; | 1096 | static bool onlyOne = false; |
1090 | if ( onlyOne ) | 1097 | if ( onlyOne ) |
1091 | return; | 1098 | return; |
1092 | onlyOne = true; | 1099 | onlyOne = true; |
1093 | //if ( globalFlagBlockAgenda == 2 ) | 1100 | //if ( globalFlagBlockAgenda == 2 ) |
1094 | //globalFlagBlockAgenda = 0; | 1101 | //globalFlagBlockAgenda = 0; |
1095 | // globalFlagBlockPainting = false; | 1102 | // globalFlagBlockPainting = false; |
1096 | if ( globalFlagBlockAgenda == 0 ) | 1103 | if ( globalFlagBlockAgenda == 0 ) |
1097 | globalFlagBlockAgenda = 1; | 1104 | globalFlagBlockAgenda = 1; |
1098 | // clearView(); | 1105 | // clearView(); |
1099 | //qDebug("fillAgenda()++++ "); | 1106 | //qDebug("fillAgenda()++++ "); |
1100 | globalFlagBlockAgendaItemPaint = 1; | 1107 | globalFlagBlockAgendaItemPaint = 1; |
1101 | 1108 | ||
1102 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1109 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1103 | mAgenda->changeColumns(mSelectedDates.count()); | 1110 | mAgenda->changeColumns(mSelectedDates.count()); |
1104 | qApp->processEvents(); | 1111 | qApp->processEvents(); |
1105 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1112 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1106 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1113 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1107 | setHolidayMasks(); | 1114 | setHolidayMasks(); |
1108 | 1115 | ||
1109 | //mAgenda->hideUnused(); | 1116 | //mAgenda->hideUnused(); |
1110 | //mAllDayAgenda->hideUnused(); | 1117 | //mAllDayAgenda->hideUnused(); |
1111 | 1118 | ||
1112 | // mAgenda->blockNextRepaint( false ); | 1119 | // mAgenda->blockNextRepaint( false ); |
1113 | // mAgenda->viewport()->repaint(); | 1120 | // mAgenda->viewport()->repaint(); |
1114 | // mAgenda->blockNextRepaint( true ); | 1121 | // mAgenda->blockNextRepaint( true ); |
1115 | mMinY.resize(mSelectedDates.count()); | 1122 | mMinY.resize(mSelectedDates.count()); |
1116 | mMaxY.resize(mSelectedDates.count()); | 1123 | mMaxY.resize(mSelectedDates.count()); |
1117 | 1124 | ||
1118 | QPtrList<Event> dayEvents; | 1125 | QPtrList<Event> dayEvents; |
1119 | 1126 | ||
1120 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1127 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1121 | // Therefore, gtodoset all of them. | 1128 | // Therefore, gtodoset all of them. |
1122 | QPtrList<Todo> todos = calendar()->todos(); | 1129 | QPtrList<Todo> todos = calendar()->todos(); |
1123 | 1130 | ||
1124 | mAgenda->setDateList(mSelectedDates); | 1131 | mAgenda->setDateList(mSelectedDates); |
1125 | 1132 | ||
1126 | QDate today = QDate::currentDate(); | 1133 | QDate today = QDate::currentDate(); |
1127 | 1134 | ||
1128 | DateList::ConstIterator dit; | 1135 | DateList::ConstIterator dit; |
1129 | int curCol = 0; | 1136 | int curCol = 0; |
1130 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1137 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1131 | QDate currentDate = *dit; | 1138 | QDate currentDate = *dit; |
1132 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1139 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1133 | // << endl; | 1140 | // << endl; |
1134 | 1141 | ||
1135 | dayEvents = calendar()->events(currentDate,true); | 1142 | dayEvents = calendar()->events(currentDate,true); |
1136 | 1143 | ||
1137 | // Default values, which can never be reached | 1144 | // Default values, which can never be reached |
1138 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1145 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1139 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1146 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1140 | 1147 | ||
1141 | unsigned int numEvent; | 1148 | unsigned int numEvent; |
1142 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1149 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1143 | Event *event = dayEvents.at(numEvent); | 1150 | Event *event = dayEvents.at(numEvent); |
1144 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1151 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1145 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1152 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1146 | continue; | 1153 | continue; |
1147 | // kdDebug() << " Event: " << event->summary() << endl; | 1154 | // kdDebug() << " Event: " << event->summary() << endl; |
1148 | 1155 | ||
1149 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1156 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1150 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1157 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1151 | 1158 | ||
1152 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1159 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1153 | 1160 | ||
1154 | if (event->doesFloat()) { | 1161 | if (event->doesFloat()) { |
1155 | if (event->recurrence()->doesRecur()) { | 1162 | if (event->recurrence()->doesRecur()) { |
1156 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1163 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1157 | } else { | 1164 | } else { |
1158 | if (beginX <= 0 && curCol == 0) { | 1165 | if (beginX <= 0 && curCol == 0) { |
1159 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1166 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1160 | } else if (beginX == curCol) { | 1167 | } else if (beginX == curCol) { |
1161 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1168 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1162 | } | 1169 | } |
1163 | } | 1170 | } |
1164 | } else if (event->isMultiDay()) { | 1171 | } else if (event->isMultiDay()) { |
1165 | if ( event->doesRecur () ) { | 1172 | if ( event->doesRecur () ) { |
1166 | QDate dateit = currentDate; | 1173 | QDate dateit = currentDate; |
1167 | int count = 0; | 1174 | int count = 0; |
1168 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1175 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1169 | while (! event->recursOn( dateit ) && count <= max ) { | 1176 | while (! event->recursOn( dateit ) && count <= max ) { |
1170 | ++count; | 1177 | ++count; |
1171 | dateit = dateit.addDays( -1 ); | 1178 | dateit = dateit.addDays( -1 ); |
1172 | } | 1179 | } |
1173 | bool ok; | 1180 | bool ok; |
1174 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1181 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1175 | if ( ok ) | 1182 | if ( ok ) |
1176 | { | 1183 | { |
1177 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1184 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1178 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1185 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1179 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1186 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1180 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1187 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1181 | 1188 | ||
1182 | } | 1189 | } |
1183 | } | 1190 | } |
1184 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1191 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1185 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1192 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1186 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1193 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1187 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1194 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1188 | //qDebug("insert!!! "); | 1195 | //qDebug("insert!!! "); |
1189 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1196 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1190 | } | 1197 | } |
1191 | if (beginX == curCol) { | 1198 | if (beginX == curCol) { |
1192 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1199 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1193 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1200 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1194 | } else if (endX == curCol) { | 1201 | } else if (endX == curCol) { |
1195 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1202 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1196 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1203 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1197 | } else { | 1204 | } else { |
1198 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1205 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1199 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1206 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1200 | } | 1207 | } |
1201 | } else { | 1208 | } else { |
1202 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1209 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1203 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1210 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1204 | if (endY < startY) endY = startY; | 1211 | if (endY < startY) endY = startY; |
1205 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1212 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1206 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1213 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1207 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1214 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1208 | } | 1215 | } |
1209 | } | 1216 | } |
1210 | // ---------- [display Todos -------------- | 1217 | // ---------- [display Todos -------------- |
1211 | unsigned int numTodo; | 1218 | unsigned int numTodo; |
1212 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1219 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1213 | Todo *todo = todos.at(numTodo); | 1220 | Todo *todo = todos.at(numTodo); |
1214 | 1221 | ||
1215 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1222 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1216 | 1223 | ||
1217 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1224 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1218 | // Already completed items can be displayed on their original due date | 1225 | // Already completed items can be displayed on their original due date |
1219 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1226 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1220 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1227 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1221 | bool fillIn = false; | 1228 | bool fillIn = false; |
1222 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1229 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1223 | fillIn = true; | 1230 | fillIn = true; |
1224 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1231 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1225 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1232 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1226 | if ( fillIn ) { | 1233 | if ( fillIn ) { |
1227 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1234 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1228 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1235 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1229 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1236 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1230 | } | 1237 | } |
1231 | else { | 1238 | else { |
1232 | QDateTime dt; | 1239 | QDateTime dt; |
1233 | if ( todo->hasCompletedDate() ) | 1240 | if ( todo->hasCompletedDate() ) |
1234 | dt = todo->completed(); | 1241 | dt = todo->completed(); |
1235 | else | 1242 | else |
1236 | dt = todo->dtDue();; | 1243 | dt = todo->dtDue();; |
1237 | 1244 | ||
1238 | 1245 | ||
1239 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1246 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1240 | int hi = (18/KOPrefs::instance()->mHourSize); | 1247 | int hi = (18/KOPrefs::instance()->mHourSize); |
1241 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1248 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1242 | int startY = endY -hi; | 1249 | int startY = endY -hi; |
1243 | 1250 | ||
1244 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1251 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1245 | 1252 | ||
1246 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1253 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1247 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1254 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1248 | } | 1255 | } |
1249 | } | 1256 | } |
1250 | } | 1257 | } |
1251 | // ---------- display Todos] -------------- | 1258 | // ---------- display Todos] -------------- |
1252 | 1259 | ||
1253 | ++curCol; | 1260 | ++curCol; |
1254 | } | 1261 | } |
1255 | mAgenda->hideUnused(); | 1262 | mAgenda->hideUnused(); |
1256 | mAllDayAgenda->hideUnused(); | 1263 | mAllDayAgenda->hideUnused(); |
1257 | mAgenda->checkScrollBoundaries(); | 1264 | mAgenda->checkScrollBoundaries(); |
1258 | 1265 | ||
1259 | deleteSelectedDateTime(); | 1266 | deleteSelectedDateTime(); |
1260 | 1267 | ||
1261 | createDayLabels(); | 1268 | createDayLabels(); |
1262 | emit incidenceSelected( 0 ); | 1269 | emit incidenceSelected( 0 ); |
1263 | 1270 | ||
1264 | if ( globalFlagBlockAgenda == 2 ) { | 1271 | if ( globalFlagBlockAgenda == 2 ) { |
1265 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1272 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1266 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1273 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1267 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1274 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1268 | setStartHour( QTime::currentTime ().hour() ); | 1275 | setStartHour( QTime::currentTime ().hour() ); |
1269 | // qApp->processEvents(); | 1276 | // qApp->processEvents(); |
1270 | } | 1277 | } |
1271 | qApp->processEvents(); | 1278 | qApp->processEvents(); |
1272 | //qDebug("qApp->processEvents(); END "); | 1279 | //qDebug("qApp->processEvents(); END "); |
1273 | globalFlagBlockAgenda = 0; | 1280 | globalFlagBlockAgenda = 0; |
1274 | 1281 | ||
1275 | // mAgenda->hideUnused(); | 1282 | // mAgenda->hideUnused(); |
1276 | //mAllDayAgenda->hideUnused(); | 1283 | //mAllDayAgenda->hideUnused(); |
1277 | mAllDayAgenda->drawContentsToPainter(); | 1284 | mAllDayAgenda->drawContentsToPainter(); |
1278 | mAgenda->drawContentsToPainter(); | 1285 | mAgenda->drawContentsToPainter(); |
1279 | repaintAgenda(); | 1286 | repaintAgenda(); |
1280 | onlyOne = false; | 1287 | onlyOne = false; |
1281 | // mAgenda->finishUpdate(); | 1288 | // mAgenda->finishUpdate(); |
1282 | //mAllDayAgenda->finishUpdate(); | 1289 | //mAllDayAgenda->finishUpdate(); |
1283 | 1290 | ||
1284 | // repaintAgenda(); | 1291 | // repaintAgenda(); |
1285 | //qApp->processEvents(); | 1292 | //qApp->processEvents(); |
1286 | // globalFlagBlockAgenda = 0; | 1293 | // globalFlagBlockAgenda = 0; |
1287 | } | 1294 | } |
1288 | void KOAgendaView::repaintAgenda() | 1295 | void KOAgendaView::repaintAgenda() |
1289 | { | 1296 | { |
1290 | // mAllDayAgenda->drawContentsToPainter(); | 1297 | // mAllDayAgenda->drawContentsToPainter(); |
1291 | // mAllDayAgenda->viewport()->repaint( false ); | 1298 | // mAllDayAgenda->viewport()->repaint( false ); |
1292 | // mAgenda->drawContentsToPainter(); | 1299 | // mAgenda->drawContentsToPainter(); |
1293 | // mAgenda->viewport()->repaint( false ); | 1300 | // mAgenda->viewport()->repaint( false ); |
1294 | // qApp->processEvents(); | 1301 | // qApp->processEvents(); |
1295 | 1302 | ||
1296 | //qDebug("KOAgendaView::repaintAgenda() "); | 1303 | //qDebug("KOAgendaView::repaintAgenda() "); |
1297 | //qApp->processEvents(); | 1304 | //qApp->processEvents(); |
1298 | mAgenda->viewport()->repaint( false ); | 1305 | mAgenda->viewport()->repaint( false ); |
1299 | mAllDayAgenda->viewport()->repaint( false ); | 1306 | mAllDayAgenda->viewport()->repaint( false ); |
1300 | mAgenda->finishUpdate(); | 1307 | mAgenda->finishUpdate(); |
1301 | mAllDayAgenda->finishUpdate(); | 1308 | mAllDayAgenda->finishUpdate(); |
1302 | } | 1309 | } |
1303 | 1310 | ||
1304 | 1311 | ||
1305 | void KOAgendaView::clearView() | 1312 | void KOAgendaView::clearView() |
1306 | { | 1313 | { |
1307 | // kdDebug() << "ClearView" << endl; | 1314 | // kdDebug() << "ClearView" << endl; |
1308 | mAllDayAgenda->clear(); | 1315 | mAllDayAgenda->clear(); |
1309 | mAgenda->clear(); | 1316 | mAgenda->clear(); |
1310 | } | 1317 | } |
1311 | 1318 | ||
1312 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1319 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1313 | const QDate &td) | 1320 | const QDate &td) |
1314 | { | 1321 | { |
1315 | #ifndef KORG_NOPRINTER | 1322 | #ifndef KORG_NOPRINTER |
1316 | if (fd == td) | 1323 | if (fd == td) |
1317 | calPrinter->preview(CalPrinter::Day, fd, td); | 1324 | calPrinter->preview(CalPrinter::Day, fd, td); |
1318 | else | 1325 | else |
1319 | calPrinter->preview(CalPrinter::Week, fd, td); | 1326 | calPrinter->preview(CalPrinter::Week, fd, td); |
1320 | #endif | 1327 | #endif |
1321 | } | 1328 | } |
1322 | 1329 | ||
1323 | // void KOAgendaView::updateMovedTodo() | 1330 | // void KOAgendaView::updateMovedTodo() |
1324 | // { | 1331 | // { |
1325 | // // updateConfig(); | 1332 | // // updateConfig(); |
1326 | // // emit updateTodoViews(); | 1333 | // // emit updateTodoViews(); |
1327 | // } | 1334 | // } |
1328 | 1335 | ||
1329 | void KOAgendaView::slotShowDateView( int mode , int d ) | 1336 | void KOAgendaView::slotShowDateView( int mode , int d ) |
1330 | { | 1337 | { |
1331 | if ( d >= mSelectedDates.count() ) { | 1338 | if ( d >= mSelectedDates.count() ) { |
1332 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); | 1339 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); |
1333 | 1340 | ||
1334 | } else { | 1341 | } else { |
1335 | QDate day = mSelectedDates[d]; | 1342 | QDate day = mSelectedDates[d]; |
1336 | emit showDateView(mode , day ); | 1343 | emit showDateView(mode , day ); |
1337 | } | 1344 | } |
1338 | 1345 | ||
1339 | } | 1346 | } |
1340 | void KOAgendaView::newEvent(int gx, int gy) | 1347 | void KOAgendaView::newEvent(int gx, int gy) |
1341 | { | 1348 | { |
1342 | if (!mSelectedDates.count()) return; | 1349 | if (!mSelectedDates.count()) return; |
1343 | 1350 | ||
1344 | QDate day = mSelectedDates[gx]; | 1351 | QDate day = mSelectedDates[gx]; |
1345 | 1352 | ||
1346 | QTime time = mAgenda->gyToTime(gy); | 1353 | QTime time = mAgenda->gyToTime(gy); |
1347 | QDateTime dt(day,time); | 1354 | QDateTime dt(day,time); |
1348 | // if ( dt < QDateTime::currentDateTime () ) | 1355 | // if ( dt < QDateTime::currentDateTime () ) |
1349 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1356 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1350 | emit newEventSignal(dt); | 1357 | emit newEventSignal(dt); |
1351 | } | 1358 | } |
1352 | 1359 | ||
1353 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1360 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1354 | { | 1361 | { |
1355 | if (!mSelectedDates.count()) return; | 1362 | if (!mSelectedDates.count()) return; |
1356 | 1363 | ||
1357 | QDate dayStart = mSelectedDates[gxStart]; | 1364 | QDate dayStart = mSelectedDates[gxStart]; |
1358 | QDate dayEnd = mSelectedDates[gxEnd]; | 1365 | QDate dayEnd = mSelectedDates[gxEnd]; |
1359 | 1366 | ||
1360 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1367 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1361 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1368 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1362 | 1369 | ||
1363 | QDateTime dtStart(dayStart,timeStart); | 1370 | QDateTime dtStart(dayStart,timeStart); |
1364 | QDateTime dtEnd(dayEnd,timeEnd); | 1371 | QDateTime dtEnd(dayEnd,timeEnd); |
1365 | 1372 | ||
1366 | emit newEventSignal(dtStart,dtEnd); | 1373 | emit newEventSignal(dtStart,dtEnd); |
1367 | } | 1374 | } |
1368 | 1375 | ||
1369 | void KOAgendaView::newEventAllDay(int gx, int ) | 1376 | void KOAgendaView::newEventAllDay(int gx, int ) |
1370 | { | 1377 | { |
1371 | if (!mSelectedDates.count()) return; | 1378 | if (!mSelectedDates.count()) return; |
1372 | 1379 | ||
1373 | QDate day = mSelectedDates[gx]; | 1380 | QDate day = mSelectedDates[gx]; |
1374 | 1381 | ||
1375 | emit newEventSignal(day); | 1382 | emit newEventSignal(day); |
1376 | } | 1383 | } |
1377 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1384 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1378 | { | 1385 | { |
1379 | if (!mSelectedDates.count()) return; | 1386 | if (!mSelectedDates.count()) return; |
1380 | 1387 | ||
1381 | QDateTime day (mSelectedDates[gx] ); | 1388 | QDateTime day (mSelectedDates[gx] ); |
1382 | emit newTodoSignal(day, true); | 1389 | emit newTodoSignal(day, true); |
1383 | } | 1390 | } |
1384 | void KOAgendaView::newTodo(int gx, int gy ) | 1391 | void KOAgendaView::newTodo(int gx, int gy ) |
1385 | { | 1392 | { |
1386 | if (!mSelectedDates.count()) return; | 1393 | if (!mSelectedDates.count()) return; |
1387 | QDate dayStart = mSelectedDates[gx]; | 1394 | QDate dayStart = mSelectedDates[gx]; |
1388 | QTime timeStart = mAgenda->gyToTime(gy); | 1395 | QTime timeStart = mAgenda->gyToTime(gy); |
1389 | QDateTime dt (dayStart,timeStart); | 1396 | QDateTime dt (dayStart,timeStart); |
1390 | emit newTodoSignal( dt, false ); | 1397 | emit newTodoSignal( dt, false ); |
1391 | } | 1398 | } |
1392 | 1399 | ||
1393 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1400 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1394 | { | 1401 | { |
1395 | uint i; | 1402 | uint i; |
1396 | for(i=0;i<mMinY.size();++i) { | 1403 | for(i=0;i<mMinY.size();++i) { |
1397 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1404 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1398 | else mEventIndicatorTop->enableColumn(i,false); | 1405 | else mEventIndicatorTop->enableColumn(i,false); |
1399 | } | 1406 | } |
1400 | 1407 | ||
1401 | mEventIndicatorTop->update(); | 1408 | mEventIndicatorTop->update(); |
1402 | } | 1409 | } |
1403 | 1410 | ||
1404 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1411 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1405 | { | 1412 | { |
1406 | uint i; | 1413 | uint i; |
1407 | for(i=0;i<mMaxY.size();++i) { | 1414 | for(i=0;i<mMaxY.size();++i) { |
1408 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1415 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1409 | else mEventIndicatorBottom->enableColumn(i,false); | 1416 | else mEventIndicatorBottom->enableColumn(i,false); |
1410 | } | 1417 | } |
1411 | 1418 | ||
1412 | mEventIndicatorBottom->update(); | 1419 | mEventIndicatorBottom->update(); |
1413 | } | 1420 | } |
1414 | 1421 | ||
1415 | void KOAgendaView::startDrag(Event *event) | 1422 | void KOAgendaView::startDrag(Event *event) |
1416 | { | 1423 | { |
1417 | #ifndef KORG_NODND | 1424 | #ifndef KORG_NODND |
1418 | DndFactory factory( calendar() ); | 1425 | DndFactory factory( calendar() ); |
1419 | ICalDrag *vd = factory.createDrag(event,this); | 1426 | ICalDrag *vd = factory.createDrag(event,this); |
1420 | if (vd->drag()) { | 1427 | if (vd->drag()) { |
1421 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1428 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1422 | } | 1429 | } |
1423 | #endif | 1430 | #endif |
1424 | } | 1431 | } |
1425 | 1432 | ||
1426 | void KOAgendaView::readSettings() | 1433 | void KOAgendaView::readSettings() |
1427 | { | 1434 | { |
1428 | readSettings(KOGlobals::config()); | 1435 | readSettings(KOGlobals::config()); |
1429 | } | 1436 | } |
1430 | 1437 | ||
1431 | void KOAgendaView::readSettings(KConfig *config) | 1438 | void KOAgendaView::readSettings(KConfig *config) |
1432 | { | 1439 | { |
1433 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1440 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1434 | 1441 | ||
1435 | config->setGroup("Views"); | 1442 | config->setGroup("Views"); |
1436 | 1443 | ||
1437 | //#ifndef KORG_NOSPLITTER | 1444 | //#ifndef KORG_NOSPLITTER |
1438 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1445 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1439 | if (sizes.count() == 2) { | 1446 | if (sizes.count() == 2) { |
1440 | if ( sizes[0] < 20 ) { | 1447 | if ( sizes[0] < 20 ) { |
1441 | sizes[1] = sizes[1] +20 - sizes[0]; | 1448 | sizes[1] = sizes[1] +20 - sizes[0]; |
1442 | sizes[0] = 20; | 1449 | sizes[0] = 20; |
1443 | } | 1450 | } |
1444 | mSplitterAgenda->setSizes(sizes); | 1451 | mSplitterAgenda->setSizes(sizes); |
1445 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1452 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1446 | } | 1453 | } |
1447 | //#endif | 1454 | //#endif |
1448 | 1455 | ||
1449 | // updateConfig(); | 1456 | // updateConfig(); |
1450 | } | 1457 | } |
1451 | 1458 | ||
1452 | void KOAgendaView::writeSettings(KConfig *config) | 1459 | void KOAgendaView::writeSettings(KConfig *config) |
1453 | { | 1460 | { |
1454 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1461 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1455 | 1462 | ||
1456 | config->setGroup("Views"); | 1463 | config->setGroup("Views"); |
1457 | 1464 | ||
1458 | //#ifndef KORG_NOSPLITTER | 1465 | //#ifndef KORG_NOSPLITTER |
1459 | QValueList<int> list = mSplitterAgenda->sizes(); | 1466 | QValueList<int> list = mSplitterAgenda->sizes(); |
1460 | config->writeEntry("Separator AgendaView",list); | 1467 | config->writeEntry("Separator AgendaView",list); |
1461 | //qDebug("write %d %d ", list[0],list[1] ); | 1468 | //qDebug("write %d %d ", list[0],list[1] ); |
1462 | //#endif | 1469 | //#endif |
1463 | } | 1470 | } |
1464 | 1471 | ||
1465 | void KOAgendaView::setHolidayMasks() | 1472 | void KOAgendaView::setHolidayMasks() |
1466 | { | 1473 | { |
1467 | mHolidayMask.resize(mSelectedDates.count()); | 1474 | mHolidayMask.resize(mSelectedDates.count()); |
1468 | 1475 | ||
1469 | uint i; | 1476 | uint i; |
1470 | for(i=0;i<mSelectedDates.count();++i) { | 1477 | for(i=0;i<mSelectedDates.count();++i) { |
1471 | QDate date = mSelectedDates[i]; | 1478 | QDate date = mSelectedDates[i]; |
1472 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1479 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1473 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1480 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1474 | bool showHoliday = false; | 1481 | bool showHoliday = false; |
1475 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1482 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1476 | QPtrList<Event> events = calendar()->events( date, true ); | 1483 | QPtrList<Event> events = calendar()->events( date, true ); |
1477 | Event *event; | 1484 | Event *event; |
1478 | for( event = events.first(); event; event = events.next() ) { | 1485 | for( event = events.first(); event; event = events.next() ) { |
1479 | if ( event->isHoliday()) { | 1486 | if ( event->isHoliday()) { |
1480 | showHoliday = true; | 1487 | showHoliday = true; |
1481 | break; | 1488 | break; |
1482 | } | 1489 | } |
1483 | } | 1490 | } |
1484 | 1491 | ||
1485 | } | 1492 | } |
1486 | 1493 | ||
1487 | #ifndef KORG_NOPLUGINS | 1494 | #ifndef KORG_NOPLUGINS |
1488 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1495 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1489 | !KOCore::self()->holiday(date).isEmpty(); | 1496 | !KOCore::self()->holiday(date).isEmpty(); |
1490 | #endif | 1497 | #endif |
1491 | bool showDay = showSaturday || showSunday || showHoliday; | 1498 | bool showDay = showSaturday || showSunday || showHoliday; |
1492 | 1499 | ||
1493 | if (showDay) { | 1500 | if (showDay) { |
1494 | mHolidayMask.at(i) = true; | 1501 | mHolidayMask.at(i) = true; |
1495 | } else { | 1502 | } else { |
1496 | mHolidayMask.at(i) = false; | 1503 | mHolidayMask.at(i) = false; |
1497 | } | 1504 | } |
1498 | } | 1505 | } |
1499 | 1506 | ||
1500 | mAgenda->setHolidayMask(&mHolidayMask); | 1507 | mAgenda->setHolidayMask(&mHolidayMask); |
1501 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1508 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1502 | } | 1509 | } |
1503 | 1510 | ||
1504 | void KOAgendaView::setContentsPos(int y) | 1511 | void KOAgendaView::setContentsPos(int y) |
1505 | { | 1512 | { |
1506 | mAgenda->setContentsPos(0,y); | 1513 | mAgenda->setContentsPos(0,y); |
1507 | } | 1514 | } |
1508 | 1515 | ||
1509 | void KOAgendaView::clearSelection() | 1516 | void KOAgendaView::clearSelection() |
1510 | { | 1517 | { |
1511 | mAgenda->deselectItem(); | 1518 | mAgenda->deselectItem(); |
1512 | mAllDayAgenda->deselectItem(); | 1519 | mAllDayAgenda->deselectItem(); |
1513 | } | 1520 | } |
1514 | 1521 | ||
1515 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1522 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1516 | int gxEnd, int gyEnd) | 1523 | int gxEnd, int gyEnd) |
1517 | { | 1524 | { |
1518 | mTimeSpanInAllDay = true; | 1525 | mTimeSpanInAllDay = true; |
1519 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1526 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1520 | } | 1527 | } |
1521 | 1528 | ||
1522 | 1529 | ||
1523 | 1530 | ||
1524 | 1531 | ||
1525 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1532 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1526 | int gxEnd, int gyEnd) | 1533 | int gxEnd, int gyEnd) |
1527 | { | 1534 | { |
1528 | if (!mSelectedDates.count()) return; | 1535 | if (!mSelectedDates.count()) return; |
1529 | 1536 | ||
1530 | QDate dayStart = mSelectedDates[gxStart]; | 1537 | QDate dayStart = mSelectedDates[gxStart]; |
1531 | QDate dayEnd = mSelectedDates[gxEnd]; | 1538 | QDate dayEnd = mSelectedDates[gxEnd]; |
1532 | 1539 | ||
1533 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1540 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1534 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1541 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1535 | 1542 | ||
1536 | QDateTime dtStart(dayStart,timeStart); | 1543 | QDateTime dtStart(dayStart,timeStart); |
1537 | QDateTime dtEnd(dayEnd,timeEnd); | 1544 | QDateTime dtEnd(dayEnd,timeEnd); |
1538 | 1545 | ||
1539 | mTimeSpanBegin = dtStart; | 1546 | mTimeSpanBegin = dtStart; |
1540 | mTimeSpanEnd = dtEnd; | 1547 | mTimeSpanEnd = dtEnd; |
1541 | 1548 | ||
1542 | } | 1549 | } |
1543 | 1550 | ||
1544 | void KOAgendaView::deleteSelectedDateTime() | 1551 | void KOAgendaView::deleteSelectedDateTime() |
1545 | { | 1552 | { |
1546 | mTimeSpanBegin.setDate(QDate()); | 1553 | mTimeSpanBegin.setDate(QDate()); |
1547 | mTimeSpanEnd.setDate(QDate()); | 1554 | mTimeSpanEnd.setDate(QDate()); |
1548 | mTimeSpanInAllDay = false; | 1555 | mTimeSpanInAllDay = false; |
1549 | } | 1556 | } |
1550 | 1557 | ||
1551 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1558 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1552 | { | 1559 | { |
1553 | e->ignore(); | 1560 | e->ignore(); |
1554 | } | 1561 | } |
1555 | 1562 | ||
1556 | void KOAgendaView::scrollOneHourUp() | 1563 | void KOAgendaView::scrollOneHourUp() |
1557 | { | 1564 | { |
1558 | 1565 | ||
1559 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1566 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1560 | } | 1567 | } |
1561 | void KOAgendaView::scrollOneHourDown() | 1568 | void KOAgendaView::scrollOneHourDown() |
1562 | { | 1569 | { |
1563 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1570 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1564 | } | 1571 | } |
1565 | 1572 | ||
1566 | void KOAgendaView::setStartHour( int h ) | 1573 | void KOAgendaView::setStartHour( int h ) |
1567 | { | 1574 | { |
1568 | mAgenda->setStartHour( h ); | 1575 | mAgenda->setStartHour( h ); |
1569 | 1576 | ||
1570 | } | 1577 | } |
1571 | void KOAgendaView::setInitStartHour() | 1578 | void KOAgendaView::setInitStartHour() |
1572 | { | 1579 | { |
1573 | 1580 | ||
1574 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1581 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1575 | setStartHour( QTime::currentTime ().hour() ); | 1582 | setStartHour( QTime::currentTime ().hour() ); |
1576 | else | 1583 | else |
1577 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1584 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1578 | 1585 | ||
1579 | } | 1586 | } |
1580 | 1587 | ||
1581 | 1588 | ||
1582 | void KOAgendaView::updateTodo( Todo * t, int ) | 1589 | void KOAgendaView::updateTodo( Todo * t, int ) |
1583 | { | 1590 | { |
1584 | if ( !isVisible() ) | 1591 | if ( !isVisible() ) |
1585 | return; | 1592 | return; |
1586 | bool remove = false; | 1593 | bool remove = false; |
1587 | bool removeAD = false; | 1594 | bool removeAD = false; |
1588 | QDate da; | 1595 | QDate da; |
1589 | if ( t->hasCompletedDate() ) | 1596 | if ( t->hasCompletedDate() ) |
1590 | da = t->completed().date(); | 1597 | da = t->completed().date(); |
1591 | else | 1598 | else |
1592 | da = t->dtDue().date(); | 1599 | da = t->dtDue().date(); |
1593 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1600 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1594 | remove = true; | 1601 | remove = true; |
1595 | removeAD = true; | 1602 | removeAD = true; |
1596 | } | 1603 | } |
1597 | else { | 1604 | else { |
1598 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1605 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1599 | if ( overdue && | 1606 | if ( overdue && |
1600 | QDate::currentDate() >= mSelectedDates.first() && | 1607 | QDate::currentDate() >= mSelectedDates.first() && |
1601 | QDate::currentDate() <= mSelectedDates.last()) { | 1608 | QDate::currentDate() <= mSelectedDates.last()) { |
1602 | removeAD = false; | 1609 | removeAD = false; |
1603 | remove = true; | 1610 | remove = true; |
1604 | } | 1611 | } |
1605 | else { | 1612 | else { |
1606 | 1613 | ||
1607 | if ( da < mSelectedDates.first() || | 1614 | if ( da < mSelectedDates.first() || |
1608 | da > mSelectedDates.last() ) { | 1615 | da > mSelectedDates.last() ) { |
1609 | remove = true; | 1616 | remove = true; |
1610 | removeAD = true; | 1617 | removeAD = true; |
1611 | } else { | 1618 | } else { |
1612 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1619 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1613 | removeAD = !remove; | 1620 | removeAD = !remove; |
1614 | } | 1621 | } |
1615 | } | 1622 | } |
1616 | } | 1623 | } |
1617 | int days = mSelectedDates.first().daysTo( da ); | 1624 | int days = mSelectedDates.first().daysTo( da ); |
1618 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1625 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1619 | mAgenda->updateTodo( t , days, remove); | 1626 | mAgenda->updateTodo( t , days, remove); |
1620 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1627 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1621 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1628 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1622 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1629 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1623 | 1630 | ||
1624 | } | 1631 | } |