-rw-r--r-- | kaddressbook/kabcore.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/views/cardview.cpp | 10 | ||||
-rw-r--r-- | kmicromail/koprefsdialog.cpp | 7 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/generatemail.cpp | 16 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/generatemail.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 3 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 4 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailwrapper.h | 2 | ||||
-rw-r--r-- | kmicromail/mainwindow.cpp | 3 | ||||
-rw-r--r-- | microkde/kdecore/klocale.cpp | 27 | ||||
-rw-r--r-- | microkde/kidmanager.cpp | 2 | ||||
-rw-r--r-- | microkde/kresources/managerimpl.cpp | 4 |
12 files changed, 46 insertions, 35 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d651224..c339244 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,3096 +1,3096 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /*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 | 118 | ||
119 | 119 | ||
120 | #include <kresources/selectdialog.h> | 120 | #include <kresources/selectdialog.h> |
121 | #include <kmessagebox.h> | 121 | #include <kmessagebox.h> |
122 | 122 | ||
123 | #include <picture.h> | 123 | #include <picture.h> |
124 | #include <resource.h> | 124 | #include <resource.h> |
125 | 125 | ||
126 | //US#include <qsplitter.h> | 126 | //US#include <qsplitter.h> |
127 | #include <qmap.h> | 127 | #include <qmap.h> |
128 | #include <qdir.h> | 128 | #include <qdir.h> |
129 | #include <qfile.h> | 129 | #include <qfile.h> |
130 | #include <qvbox.h> | 130 | #include <qvbox.h> |
131 | #include <qlayout.h> | 131 | #include <qlayout.h> |
132 | #include <qclipboard.h> | 132 | #include <qclipboard.h> |
133 | #include <qtextstream.h> | 133 | #include <qtextstream.h> |
134 | #include <qradiobutton.h> | 134 | #include <qradiobutton.h> |
135 | #include <qbuttongroup.h> | 135 | #include <qbuttongroup.h> |
136 | 136 | ||
137 | #include <libkdepim/categoryselectdialog.h> | 137 | #include <libkdepim/categoryselectdialog.h> |
138 | #include <libkdepim/categoryeditdialog.h> | 138 | #include <libkdepim/categoryeditdialog.h> |
139 | #include <kabc/vcardconverter.h> | 139 | #include <kabc/vcardconverter.h> |
140 | 140 | ||
141 | 141 | ||
142 | #include "addresseeutil.h" | 142 | #include "addresseeutil.h" |
143 | #include "undocmds.h" | 143 | #include "undocmds.h" |
144 | #include "addresseeeditordialog.h" | 144 | #include "addresseeeditordialog.h" |
145 | #include "viewmanager.h" | 145 | #include "viewmanager.h" |
146 | #include "details/detailsviewcontainer.h" | 146 | #include "details/detailsviewcontainer.h" |
147 | #include "kabprefs.h" | 147 | #include "kabprefs.h" |
148 | #include "xxportmanager.h" | 148 | #include "xxportmanager.h" |
149 | #include "incsearchwidget.h" | 149 | #include "incsearchwidget.h" |
150 | #include "jumpbuttonbar.h" | 150 | #include "jumpbuttonbar.h" |
151 | #include "extensionmanager.h" | 151 | #include "extensionmanager.h" |
152 | #include "addresseeconfig.h" | 152 | #include "addresseeconfig.h" |
153 | #include <kcmultidialog.h> | 153 | #include <kcmultidialog.h> |
154 | 154 | ||
155 | #ifdef _WIN32_ | 155 | #ifdef _WIN32_ |
156 | 156 | ||
157 | #include "kaimportoldialog.h" | 157 | #include "kaimportoldialog.h" |
158 | #else | 158 | #else |
159 | #include <unistd.h> | 159 | #include <unistd.h> |
160 | #endif | 160 | #endif |
161 | // sync includes | 161 | // sync includes |
162 | #include <libkdepim/ksyncprofile.h> | 162 | #include <libkdepim/ksyncprofile.h> |
163 | #include <libkdepim/ksyncprefsdialog.h> | 163 | #include <libkdepim/ksyncprefsdialog.h> |
164 | 164 | ||
165 | 165 | ||
166 | class KABCatPrefs : public QDialog | 166 | class KABCatPrefs : public QDialog |
167 | { | 167 | { |
168 | public: | 168 | public: |
169 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : | 169 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : |
170 | QDialog( parent, name, true ) | 170 | QDialog( parent, name, true ) |
171 | { | 171 | { |
172 | setCaption( i18n("Manage new Categories") ); | 172 | setCaption( i18n("Manage new Categories") ); |
173 | QVBoxLayout* lay = new QVBoxLayout( this ); | 173 | QVBoxLayout* lay = new QVBoxLayout( this ); |
174 | lay->setSpacing( 3 ); | 174 | lay->setSpacing( 3 ); |
175 | lay->setMargin( 3 ); | 175 | lay->setMargin( 3 ); |
176 | 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 ); | 176 | 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 ); |
177 | lay->addWidget( lab ); | 177 | lay->addWidget( lab ); |
178 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 178 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
179 | lay->addWidget( format ); | 179 | lay->addWidget( format ); |
180 | format->setExclusive ( true ) ; | 180 | format->setExclusive ( true ) ; |
181 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 181 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
182 | new QRadioButton(i18n("Remove from addressees"), format ); | 182 | new QRadioButton(i18n("Remove from addressees"), format ); |
183 | addCatBut->setChecked( true ); | 183 | addCatBut->setChecked( true ); |
184 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 184 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
185 | lay->addWidget( ok ); | 185 | lay->addWidget( ok ); |
186 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 186 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
187 | lay->addWidget( cancel ); | 187 | lay->addWidget( cancel ); |
188 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 188 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
189 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 189 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
190 | resize( 200, 200 ); | 190 | resize( 200, 200 ); |
191 | } | 191 | } |
192 | 192 | ||
193 | bool addCat() { return addCatBut->isChecked(); } | 193 | bool addCat() { return addCatBut->isChecked(); } |
194 | private: | 194 | private: |
195 | QRadioButton* addCatBut; | 195 | QRadioButton* addCatBut; |
196 | }; | 196 | }; |
197 | 197 | ||
198 | 198 | ||
199 | 199 | ||
200 | class KAex2phonePrefs : public QDialog | 200 | class KAex2phonePrefs : public QDialog |
201 | { | 201 | { |
202 | public: | 202 | public: |
203 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 203 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
204 | QDialog( parent, name, true ) | 204 | QDialog( parent, name, true ) |
205 | { | 205 | { |
206 | setCaption( i18n("Export to phone options") ); | 206 | setCaption( i18n("Export to phone options") ); |
207 | QVBoxLayout* lay = new QVBoxLayout( this ); | 207 | QVBoxLayout* lay = new QVBoxLayout( this ); |
208 | lay->setSpacing( 3 ); | 208 | lay->setSpacing( 3 ); |
209 | lay->setMargin( 3 ); | 209 | lay->setMargin( 3 ); |
210 | QLabel *lab; | 210 | QLabel *lab; |
211 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 211 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
212 | lab->setAlignment (AlignHCenter ); | 212 | lab->setAlignment (AlignHCenter ); |
213 | QHBox* temphb; | 213 | QHBox* temphb; |
214 | temphb = new QHBox( this ); | 214 | temphb = new QHBox( this ); |
215 | new QLabel( i18n("I/O device: "), temphb ); | 215 | new QLabel( i18n("I/O device: "), temphb ); |
216 | mPhoneDevice = new QLineEdit( temphb); | 216 | mPhoneDevice = new QLineEdit( temphb); |
217 | lay->addWidget( temphb ); | 217 | lay->addWidget( temphb ); |
218 | temphb = new QHBox( this ); | 218 | temphb = new QHBox( this ); |
219 | new QLabel( i18n("Connection: "), temphb ); | 219 | new QLabel( i18n("Connection: "), temphb ); |
220 | mPhoneConnection = new QLineEdit( temphb); | 220 | mPhoneConnection = new QLineEdit( temphb); |
221 | lay->addWidget( temphb ); | 221 | lay->addWidget( temphb ); |
222 | temphb = new QHBox( this ); | 222 | temphb = new QHBox( this ); |
223 | new QLabel( i18n("Model(opt.): "), temphb ); | 223 | new QLabel( i18n("Model(opt.): "), temphb ); |
224 | mPhoneModel = new QLineEdit( temphb); | 224 | mPhoneModel = new QLineEdit( temphb); |
225 | lay->addWidget( temphb ); | 225 | lay->addWidget( temphb ); |
226 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 226 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
227 | // lay->addWidget( mWriteToSim ); | 227 | // lay->addWidget( mWriteToSim ); |
228 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 228 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
229 | lab->setAlignment (AlignHCenter ); | 229 | lab->setAlignment (AlignHCenter ); |
230 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 230 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
231 | lay->addWidget( ok ); | 231 | lay->addWidget( ok ); |
232 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 232 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
233 | lay->addWidget( cancel ); | 233 | lay->addWidget( cancel ); |
234 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 234 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
235 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 235 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
236 | resize( 220, 240 ); | 236 | resize( 220, 240 ); |
237 | 237 | ||
238 | } | 238 | } |
239 | 239 | ||
240 | public: | 240 | public: |
241 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 241 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
242 | QCheckBox* mWriteToSim; | 242 | QCheckBox* mWriteToSim; |
243 | }; | 243 | }; |
244 | 244 | ||
245 | 245 | ||
246 | bool pasteWithNewUid = true; | 246 | bool pasteWithNewUid = true; |
247 | 247 | ||
248 | #ifdef KAB_EMBEDDED | 248 | #ifdef KAB_EMBEDDED |
249 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 249 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
250 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 250 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
251 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 251 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
252 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 252 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
253 | #else //KAB_EMBEDDED | 253 | #else //KAB_EMBEDDED |
254 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 254 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
255 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 255 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
256 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 256 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
257 | mReadWrite( readWrite ), mModified( false ) | 257 | mReadWrite( readWrite ), mModified( false ) |
258 | #endif //KAB_EMBEDDED | 258 | #endif //KAB_EMBEDDED |
259 | { | 259 | { |
260 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 260 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
261 | // syncManager->setBlockSave(false); | 261 | // syncManager->setBlockSave(false); |
262 | mExtensionBarSplitter = 0; | 262 | mExtensionBarSplitter = 0; |
263 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 263 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
264 | mAddressBook = KABC::StdAddressBook::self(); | 264 | mAddressBook = KABC::StdAddressBook::self(); |
265 | KABC::StdAddressBook::setAutomaticSave( false ); | 265 | KABC::StdAddressBook::setAutomaticSave( false ); |
266 | 266 | ||
267 | #ifndef KAB_EMBEDDED | 267 | #ifndef KAB_EMBEDDED |
268 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 268 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
269 | #endif //KAB_EMBEDDED | 269 | #endif //KAB_EMBEDDED |
270 | 270 | ||
271 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 271 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
272 | SLOT( addressBookChanged() ) ); | 272 | SLOT( addressBookChanged() ) ); |
273 | 273 | ||
274 | #if 0 | 274 | #if 0 |
275 | // LP moved to addressbook init method | 275 | // LP moved to addressbook init method |
276 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 276 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
277 | "X-Department", "KADDRESSBOOK" ); | 277 | "X-Department", "KADDRESSBOOK" ); |
278 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 278 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
279 | "X-Profession", "KADDRESSBOOK" ); | 279 | "X-Profession", "KADDRESSBOOK" ); |
280 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 280 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
281 | "X-AssistantsName", "KADDRESSBOOK" ); | 281 | "X-AssistantsName", "KADDRESSBOOK" ); |
282 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 282 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
283 | "X-ManagersName", "KADDRESSBOOK" ); | 283 | "X-ManagersName", "KADDRESSBOOK" ); |
284 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 284 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
285 | "X-SpousesName", "KADDRESSBOOK" ); | 285 | "X-SpousesName", "KADDRESSBOOK" ); |
286 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 286 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
287 | "X-Office", "KADDRESSBOOK" ); | 287 | "X-Office", "KADDRESSBOOK" ); |
288 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 288 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
289 | "X-IMAddress", "KADDRESSBOOK" ); | 289 | "X-IMAddress", "KADDRESSBOOK" ); |
290 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 290 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
291 | "X-Anniversary", "KADDRESSBOOK" ); | 291 | "X-Anniversary", "KADDRESSBOOK" ); |
292 | 292 | ||
293 | //US added this field to become compatible with Opie/qtopia addressbook | 293 | //US added this field to become compatible with Opie/qtopia addressbook |
294 | // values can be "female" or "male" or "". An empty field represents undefined. | 294 | // values can be "female" or "male" or "". An empty field represents undefined. |
295 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 295 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
296 | "X-Gender", "KADDRESSBOOK" ); | 296 | "X-Gender", "KADDRESSBOOK" ); |
297 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 297 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
298 | "X-Children", "KADDRESSBOOK" ); | 298 | "X-Children", "KADDRESSBOOK" ); |
299 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 299 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
300 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 300 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
301 | #endif | 301 | #endif |
302 | initGUI(); | 302 | initGUI(); |
303 | 303 | ||
304 | mIncSearchWidget->setFocus(); | 304 | mIncSearchWidget->setFocus(); |
305 | 305 | ||
306 | 306 | ||
307 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 307 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
308 | SLOT( setContactSelected( const QString& ) ) ); | 308 | SLOT( setContactSelected( const QString& ) ) ); |
309 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 309 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
310 | SLOT( executeContact( const QString& ) ) ); | 310 | SLOT( executeContact( const QString& ) ) ); |
311 | 311 | ||
312 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 312 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
313 | SLOT( deleteContacts( ) ) ); | 313 | SLOT( deleteContacts( ) ) ); |
314 | connect( mViewManager, SIGNAL( modified() ), | 314 | connect( mViewManager, SIGNAL( modified() ), |
315 | SLOT( setModified() ) ); | 315 | SLOT( setModified() ) ); |
316 | 316 | ||
317 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 317 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
318 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 318 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
319 | 319 | ||
320 | connect( mXXPortManager, SIGNAL( modified() ), | 320 | connect( mXXPortManager, SIGNAL( modified() ), |
321 | SLOT( setModified() ) ); | 321 | SLOT( setModified() ) ); |
322 | 322 | ||
323 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 323 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
324 | SLOT( incrementalSearch( const QString& ) ) ); | 324 | SLOT( incrementalSearch( const QString& ) ) ); |
325 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 325 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
326 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 326 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
327 | 327 | ||
328 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 328 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
329 | SLOT( sendMail( const QString& ) ) ); | 329 | SLOT( sendMail( const QString& ) ) ); |
330 | 330 | ||
331 | 331 | ||
332 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 332 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
333 | 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&))); | 333 | 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&))); |
334 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 334 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
335 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | 335 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); |
336 | 336 | ||
337 | 337 | ||
338 | #ifndef KAB_EMBEDDED | 338 | #ifndef KAB_EMBEDDED |
339 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 339 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
340 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 340 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
341 | 341 | ||
342 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 342 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
343 | SLOT( browse( const QString& ) ) ); | 343 | SLOT( browse( const QString& ) ) ); |
344 | 344 | ||
345 | 345 | ||
346 | mAddressBookService = new KAddressBookService( this ); | 346 | mAddressBookService = new KAddressBookService( this ); |
347 | 347 | ||
348 | #endif //KAB_EMBEDDED | 348 | #endif //KAB_EMBEDDED |
349 | 349 | ||
350 | mMessageTimer = new QTimer( this ); | 350 | mMessageTimer = new QTimer( this ); |
351 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 351 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
352 | mEditorDialog = 0; | 352 | mEditorDialog = 0; |
353 | createAddresseeEditorDialog( this ); | 353 | createAddresseeEditorDialog( this ); |
354 | setModified( false ); | 354 | setModified( false ); |
355 | mBRdisabled = false; | 355 | mBRdisabled = false; |
356 | #ifndef DESKTOP_VERSION | 356 | #ifndef DESKTOP_VERSION |
357 | infrared = 0; | 357 | infrared = 0; |
358 | #endif | 358 | #endif |
359 | //toggleBeamReceive( ); | 359 | //toggleBeamReceive( ); |
360 | 360 | ||
361 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 361 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
362 | QTimer::singleShot( 1, this , SLOT ( updateToolBar())); | 362 | QTimer::singleShot( 1, this , SLOT ( updateToolBar())); |
363 | } | 363 | } |
364 | 364 | ||
365 | void KABCore::updateToolBar() | 365 | void KABCore::updateToolBar() |
366 | { | 366 | { |
367 | mMainWindow->toolBar()->repaint(); | 367 | mMainWindow->toolBar()->repaint(); |
368 | } | 368 | } |
369 | KABCore::~KABCore() | 369 | KABCore::~KABCore() |
370 | { | 370 | { |
371 | // save(); | 371 | // save(); |
372 | //saveSettings(); | 372 | //saveSettings(); |
373 | //KABPrefs::instance()->writeConfig(); | 373 | //KABPrefs::instance()->writeConfig(); |
374 | delete AddresseeConfig::instance(); | 374 | delete AddresseeConfig::instance(); |
375 | mAddressBook = 0; | 375 | mAddressBook = 0; |
376 | KABC::StdAddressBook::close(); | 376 | KABC::StdAddressBook::close(); |
377 | 377 | ||
378 | delete syncManager; | 378 | delete syncManager; |
379 | #ifndef DESKTOP_VERSION | 379 | #ifndef DESKTOP_VERSION |
380 | if ( infrared ) | 380 | if ( infrared ) |
381 | delete infrared; | 381 | delete infrared; |
382 | #endif | 382 | #endif |
383 | } | 383 | } |
384 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 384 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
385 | { | 385 | { |
386 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 386 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
387 | if ( cmsg == "setDocument(QString)" ) { | 387 | if ( cmsg == "setDocument(QString)" ) { |
388 | QDataStream stream( data, IO_ReadOnly ); | 388 | QDataStream stream( data, IO_ReadOnly ); |
389 | QString fileName; | 389 | QString fileName; |
390 | stream >> fileName; | 390 | stream >> fileName; |
391 | recieve( fileName ); | 391 | recieve( fileName ); |
392 | return; | 392 | return; |
393 | } | 393 | } |
394 | } | 394 | } |
395 | void KABCore::toggleBeamReceive( ) | 395 | void KABCore::toggleBeamReceive( ) |
396 | { | 396 | { |
397 | if ( mBRdisabled ) | 397 | if ( mBRdisabled ) |
398 | return; | 398 | return; |
399 | #ifndef DESKTOP_VERSION | 399 | #ifndef DESKTOP_VERSION |
400 | if ( infrared ) { | 400 | if ( infrared ) { |
401 | qDebug("AB disable BeamReceive "); | 401 | qDebug("AB disable BeamReceive "); |
402 | delete infrared; | 402 | delete infrared; |
403 | infrared = 0; | 403 | infrared = 0; |
404 | mActionBR->setChecked(false); | 404 | mActionBR->setChecked(false); |
405 | return; | 405 | return; |
406 | } | 406 | } |
407 | qDebug("AB enable BeamReceive "); | 407 | qDebug("AB enable BeamReceive "); |
408 | mActionBR->setChecked(true); | 408 | mActionBR->setChecked(true); |
409 | 409 | ||
410 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 410 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
411 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 411 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
412 | #endif | 412 | #endif |
413 | } | 413 | } |
414 | 414 | ||
415 | 415 | ||
416 | void KABCore::disableBR(bool b) | 416 | void KABCore::disableBR(bool b) |
417 | { | 417 | { |
418 | #ifndef DESKTOP_VERSION | 418 | #ifndef DESKTOP_VERSION |
419 | if ( b ) { | 419 | if ( b ) { |
420 | if ( infrared ) { | 420 | if ( infrared ) { |
421 | toggleBeamReceive( ); | 421 | toggleBeamReceive( ); |
422 | } | 422 | } |
423 | mBRdisabled = true; | 423 | mBRdisabled = true; |
424 | } else { | 424 | } else { |
425 | if ( mBRdisabled ) { | 425 | if ( mBRdisabled ) { |
426 | mBRdisabled = false; | 426 | mBRdisabled = false; |
427 | //toggleBeamReceive( ); | 427 | //toggleBeamReceive( ); |
428 | } | 428 | } |
429 | } | 429 | } |
430 | #endif | 430 | #endif |
431 | 431 | ||
432 | } | 432 | } |
433 | void KABCore::recieve( QString fn ) | 433 | void KABCore::recieve( QString fn ) |
434 | { | 434 | { |
435 | //qDebug("KABCore::recieve "); | 435 | //qDebug("KABCore::recieve "); |
436 | int count = mAddressBook->importFromFile( fn, true ); | 436 | int count = mAddressBook->importFromFile( fn, true ); |
437 | if ( count ) | 437 | if ( count ) |
438 | setModified( true ); | 438 | setModified( true ); |
439 | mViewManager->refreshView(); | 439 | mViewManager->refreshView(); |
440 | message(i18n("%1 contact(s) received!").arg( count )); | 440 | message(i18n("%1 contact(s) received!").arg( count )); |
441 | topLevelWidget()->showMaximized(); | 441 | topLevelWidget()->showMaximized(); |
442 | topLevelWidget()->raise(); | 442 | topLevelWidget()->raise(); |
443 | } | 443 | } |
444 | void KABCore::restoreSettings() | 444 | void KABCore::restoreSettings() |
445 | { | 445 | { |
446 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 446 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
447 | 447 | ||
448 | bool state; | 448 | bool state; |
449 | 449 | ||
450 | if (mMultipleViewsAtOnce) | 450 | if (mMultipleViewsAtOnce) |
451 | state = KABPrefs::instance()->mDetailsPageVisible; | 451 | state = KABPrefs::instance()->mDetailsPageVisible; |
452 | else | 452 | else |
453 | state = false; | 453 | state = false; |
454 | 454 | ||
455 | mActionDetails->setChecked( state ); | 455 | mActionDetails->setChecked( state ); |
456 | setDetailsVisible( state ); | 456 | setDetailsVisible( state ); |
457 | 457 | ||
458 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 458 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
459 | 459 | ||
460 | mActionJumpBar->setChecked( state ); | 460 | mActionJumpBar->setChecked( state ); |
461 | setJumpButtonBarVisible( state ); | 461 | setJumpButtonBarVisible( state ); |
462 | /*US | 462 | /*US |
463 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 463 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
464 | if ( splitterSize.count() == 0 ) { | 464 | if ( splitterSize.count() == 0 ) { |
465 | splitterSize.append( width() / 2 ); | 465 | splitterSize.append( width() / 2 ); |
466 | splitterSize.append( width() / 2 ); | 466 | splitterSize.append( width() / 2 ); |
467 | } | 467 | } |
468 | mMiniSplitter->setSizes( splitterSize ); | 468 | mMiniSplitter->setSizes( splitterSize ); |
469 | if ( mExtensionBarSplitter ) { | 469 | if ( mExtensionBarSplitter ) { |
470 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 470 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
471 | if ( splitterSize.count() == 0 ) { | 471 | if ( splitterSize.count() == 0 ) { |
472 | splitterSize.append( width() / 2 ); | 472 | splitterSize.append( width() / 2 ); |
473 | splitterSize.append( width() / 2 ); | 473 | splitterSize.append( width() / 2 ); |
474 | } | 474 | } |
475 | mExtensionBarSplitter->setSizes( splitterSize ); | 475 | mExtensionBarSplitter->setSizes( splitterSize ); |
476 | 476 | ||
477 | } | 477 | } |
478 | */ | 478 | */ |
479 | mViewManager->restoreSettings(); | 479 | mViewManager->restoreSettings(); |
480 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 480 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
481 | mExtensionManager->restoreSettings(); | 481 | mExtensionManager->restoreSettings(); |
482 | #ifdef DESKTOP_VERSION | 482 | #ifdef DESKTOP_VERSION |
483 | int wid = width(); | 483 | int wid = width(); |
484 | if ( wid < 10 ) | 484 | if ( wid < 10 ) |
485 | wid = 400; | 485 | wid = 400; |
486 | #else | 486 | #else |
487 | int wid = QApplication::desktop()->width(); | 487 | int wid = QApplication::desktop()->width(); |
488 | if ( wid < 640 ) | 488 | if ( wid < 640 ) |
489 | wid = QApplication::desktop()->height(); | 489 | wid = QApplication::desktop()->height(); |
490 | #endif | 490 | #endif |
491 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 491 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
492 | if ( true /*splitterSize.count() == 0*/ ) { | 492 | if ( true /*splitterSize.count() == 0*/ ) { |
493 | splitterSize.append( wid / 2 ); | 493 | splitterSize.append( wid / 2 ); |
494 | splitterSize.append( wid / 2 ); | 494 | splitterSize.append( wid / 2 ); |
495 | } | 495 | } |
496 | mMiniSplitter->setSizes( splitterSize ); | 496 | mMiniSplitter->setSizes( splitterSize ); |
497 | if ( mExtensionBarSplitter ) { | 497 | if ( mExtensionBarSplitter ) { |
498 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 498 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
499 | if ( true /*splitterSize.count() == 0*/ ) { | 499 | if ( true /*splitterSize.count() == 0*/ ) { |
500 | splitterSize.append( wid / 2 ); | 500 | splitterSize.append( wid / 2 ); |
501 | splitterSize.append( wid / 2 ); | 501 | splitterSize.append( wid / 2 ); |
502 | } | 502 | } |
503 | mExtensionBarSplitter->setSizes( splitterSize ); | 503 | mExtensionBarSplitter->setSizes( splitterSize ); |
504 | 504 | ||
505 | } | 505 | } |
506 | 506 | ||
507 | 507 | ||
508 | } | 508 | } |
509 | 509 | ||
510 | void KABCore::saveSettings() | 510 | void KABCore::saveSettings() |
511 | { | 511 | { |
512 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 512 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
513 | if ( mExtensionBarSplitter ) | 513 | if ( mExtensionBarSplitter ) |
514 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 514 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
515 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 515 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
516 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 516 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
517 | #ifndef KAB_EMBEDDED | 517 | #ifndef KAB_EMBEDDED |
518 | 518 | ||
519 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 519 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
520 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 520 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
521 | #endif //KAB_EMBEDDED | 521 | #endif //KAB_EMBEDDED |
522 | mExtensionManager->saveSettings(); | 522 | mExtensionManager->saveSettings(); |
523 | mViewManager->saveSettings(); | 523 | mViewManager->saveSettings(); |
524 | 524 | ||
525 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 525 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
526 | } | 526 | } |
527 | 527 | ||
528 | KABC::AddressBook *KABCore::addressBook() const | 528 | KABC::AddressBook *KABCore::addressBook() const |
529 | { | 529 | { |
530 | return mAddressBook; | 530 | return mAddressBook; |
531 | } | 531 | } |
532 | 532 | ||
533 | KConfig *KABCore::config() | 533 | KConfig *KABCore::config() |
534 | { | 534 | { |
535 | #ifndef KAB_EMBEDDED | 535 | #ifndef KAB_EMBEDDED |
536 | return KABPrefs::instance()->config(); | 536 | return KABPrefs::instance()->config(); |
537 | #else //KAB_EMBEDDED | 537 | #else //KAB_EMBEDDED |
538 | return KABPrefs::instance()->getConfig(); | 538 | return KABPrefs::instance()->getConfig(); |
539 | #endif //KAB_EMBEDDED | 539 | #endif //KAB_EMBEDDED |
540 | } | 540 | } |
541 | 541 | ||
542 | KActionCollection *KABCore::actionCollection() const | 542 | KActionCollection *KABCore::actionCollection() const |
543 | { | 543 | { |
544 | return mGUIClient->actionCollection(); | 544 | return mGUIClient->actionCollection(); |
545 | } | 545 | } |
546 | 546 | ||
547 | KABC::Field *KABCore::currentSearchField() const | 547 | KABC::Field *KABCore::currentSearchField() const |
548 | { | 548 | { |
549 | if (mIncSearchWidget) | 549 | if (mIncSearchWidget) |
550 | return mIncSearchWidget->currentField(); | 550 | return mIncSearchWidget->currentField(); |
551 | else | 551 | else |
552 | return 0; | 552 | return 0; |
553 | } | 553 | } |
554 | 554 | ||
555 | QStringList KABCore::selectedUIDs() const | 555 | QStringList KABCore::selectedUIDs() const |
556 | { | 556 | { |
557 | return mViewManager->selectedUids(); | 557 | return mViewManager->selectedUids(); |
558 | } | 558 | } |
559 | 559 | ||
560 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 560 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
561 | { | 561 | { |
562 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 562 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
563 | 563 | ||
564 | QPtrList<KRES::Resource> kresResources; | 564 | QPtrList<KRES::Resource> kresResources; |
565 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 565 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
566 | KABC::Resource *resource; | 566 | KABC::Resource *resource; |
567 | while ( ( resource = resIt.current() ) != 0 ) { | 567 | while ( ( resource = resIt.current() ) != 0 ) { |
568 | ++resIt; | 568 | ++resIt; |
569 | if ( !resource->readOnly() ) { | 569 | if ( !resource->readOnly() ) { |
570 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 570 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
571 | if ( res ) | 571 | if ( res ) |
572 | kresResources.append( res ); | 572 | kresResources.append( res ); |
573 | } | 573 | } |
574 | } | 574 | } |
575 | 575 | ||
576 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 576 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
577 | return static_cast<KABC::Resource*>( res ); | 577 | return static_cast<KABC::Resource*>( res ); |
578 | } | 578 | } |
579 | 579 | ||
580 | #ifndef KAB_EMBEDDED | 580 | #ifndef KAB_EMBEDDED |
581 | KAboutData *KABCore::createAboutData() | 581 | KAboutData *KABCore::createAboutData() |
582 | #else //KAB_EMBEDDED | 582 | #else //KAB_EMBEDDED |
583 | void KABCore::createAboutData() | 583 | void KABCore::createAboutData() |
584 | #endif //KAB_EMBEDDED | 584 | #endif //KAB_EMBEDDED |
585 | { | 585 | { |
586 | #ifndef KAB_EMBEDDED | 586 | #ifndef KAB_EMBEDDED |
587 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 587 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
588 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 588 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
589 | KAboutData::License_GPL_V2, | 589 | KAboutData::License_GPL_V2, |
590 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 590 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
591 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 591 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
592 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 592 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
593 | about->addAuthor( "Cornelius Schumacher", | 593 | about->addAuthor( "Cornelius Schumacher", |
594 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 594 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
595 | "schumacher@kde.org" ); | 595 | "schumacher@kde.org" ); |
596 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 596 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
597 | "mpilone@slac.com" ); | 597 | "mpilone@slac.com" ); |
598 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 598 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
599 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 599 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
600 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 600 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
601 | "michel@klaralvdalens-datakonsult.se" ); | 601 | "michel@klaralvdalens-datakonsult.se" ); |
602 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 602 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
603 | "hansen@kde.org" ); | 603 | "hansen@kde.org" ); |
604 | 604 | ||
605 | return about; | 605 | return about; |
606 | #endif //KAB_EMBEDDED | 606 | #endif //KAB_EMBEDDED |
607 | 607 | ||
608 | QString version; | 608 | QString version; |
609 | #include <../version> | 609 | #include <../version> |
610 | QMessageBox::about( this, "About KAddressbook/Pi", | 610 | QMessageBox::about( this, "About KAddressbook/Pi", |
611 | "KAddressbook/Platform-independent\n" | 611 | "KAddressbook/Platform-independent\n" |
612 | "(KA/Pi) " +version + " - " + | 612 | "(KA/Pi) " +version + " - " + |
613 | #ifdef DESKTOP_VERSION | 613 | #ifdef DESKTOP_VERSION |
614 | "Desktop Edition\n" | 614 | "Desktop Edition\n" |
615 | #else | 615 | #else |
616 | "PDA-Edition\n" | 616 | "PDA-Edition\n" |
617 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 617 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
618 | #endif | 618 | #endif |
619 | 619 | ||
620 | "(c) 2004 Ulf Schenk\n" | 620 | "(c) 2004 Ulf Schenk\n" |
621 | "(c) 2004 Lutz Rogowski\n" | 621 | "(c) 2004 Lutz Rogowski\n" |
622 | "(c) 1997-2003, The KDE PIM Team\n" | 622 | "(c) 1997-2003, The KDE PIM Team\n" |
623 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 623 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
624 | "Don Sanders Original author\n" | 624 | "Don Sanders Original author\n" |
625 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 625 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
626 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 626 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
627 | "Greg Stern DCOP interface\n" | 627 | "Greg Stern DCOP interface\n" |
628 | "Mark Westcot Contact pinning\n" | 628 | "Mark Westcot Contact pinning\n" |
629 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 629 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
630 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 630 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
631 | #ifdef _WIN32_ | 631 | #ifdef _WIN32_ |
632 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 632 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
633 | #endif | 633 | #endif |
634 | ); | 634 | ); |
635 | } | 635 | } |
636 | 636 | ||
637 | void KABCore::setContactSelected( const QString &uid ) | 637 | void KABCore::setContactSelected( const QString &uid ) |
638 | { | 638 | { |
639 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 639 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
640 | if ( !mDetails->isHidden() ) | 640 | if ( !mDetails->isHidden() ) |
641 | mDetails->setAddressee( addr ); | 641 | mDetails->setAddressee( addr ); |
642 | 642 | ||
643 | if ( !addr.isEmpty() ) { | 643 | if ( !addr.isEmpty() ) { |
644 | emit contactSelected( addr.formattedName() ); | 644 | emit contactSelected( addr.formattedName() ); |
645 | KABC::Picture pic = addr.photo(); | 645 | KABC::Picture pic = addr.photo(); |
646 | if ( pic.isIntern() ) { | 646 | if ( pic.isIntern() ) { |
647 | //US emit contactSelected( pic.data() ); | 647 | //US emit contactSelected( pic.data() ); |
648 | //US instead use: | 648 | //US instead use: |
649 | QPixmap px; | 649 | QPixmap px; |
650 | if (pic.data().isNull() != true) | 650 | if (pic.data().isNull() != true) |
651 | { | 651 | { |
652 | px.convertFromImage(pic.data()); | 652 | px.convertFromImage(pic.data()); |
653 | } | 653 | } |
654 | 654 | ||
655 | emit contactSelected( px ); | 655 | emit contactSelected( px ); |
656 | } | 656 | } |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | mExtensionManager->setSelectionChanged(); | 660 | mExtensionManager->setSelectionChanged(); |
661 | 661 | ||
662 | // update the actions | 662 | // update the actions |
663 | bool selected = !uid.isEmpty(); | 663 | bool selected = !uid.isEmpty(); |
664 | 664 | ||
665 | if ( mReadWrite ) { | 665 | if ( mReadWrite ) { |
666 | mActionCut->setEnabled( selected ); | 666 | mActionCut->setEnabled( selected ); |
667 | mActionPaste->setEnabled( selected ); | 667 | mActionPaste->setEnabled( selected ); |
668 | } | 668 | } |
669 | 669 | ||
670 | mActionCopy->setEnabled( selected ); | 670 | mActionCopy->setEnabled( selected ); |
671 | mActionDelete->setEnabled( selected ); | 671 | mActionDelete->setEnabled( selected ); |
672 | mActionEditAddressee->setEnabled( selected ); | 672 | mActionEditAddressee->setEnabled( selected ); |
673 | mActionMail->setEnabled( selected ); | 673 | mActionMail->setEnabled( selected ); |
674 | mActionMailVCard->setEnabled( selected ); | 674 | mActionMailVCard->setEnabled( selected ); |
675 | //if (mActionBeam) | 675 | //if (mActionBeam) |
676 | //mActionBeam->setEnabled( selected ); | 676 | //mActionBeam->setEnabled( selected ); |
677 | 677 | ||
678 | if (mActionBeamVCard) | 678 | if (mActionBeamVCard) |
679 | mActionBeamVCard->setEnabled( selected ); | 679 | mActionBeamVCard->setEnabled( selected ); |
680 | 680 | ||
681 | mActionExport2phone->setEnabled( selected ); | 681 | mActionExport2phone->setEnabled( selected ); |
682 | mActionWhoAmI->setEnabled( selected ); | 682 | mActionWhoAmI->setEnabled( selected ); |
683 | mActionCategories->setEnabled( selected ); | 683 | mActionCategories->setEnabled( selected ); |
684 | } | 684 | } |
685 | 685 | ||
686 | void KABCore::sendMail() | 686 | void KABCore::sendMail() |
687 | { | 687 | { |
688 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 688 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
689 | } | 689 | } |
690 | 690 | ||
691 | void KABCore::sendMail( const QString& emaillist ) | 691 | void KABCore::sendMail( const QString& emaillist ) |
692 | { | 692 | { |
693 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 693 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
694 | if (emaillist.contains(",") > 0) | 694 | if (emaillist.contains(",") > 0) |
695 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 695 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
696 | else | 696 | else |
697 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 697 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
698 | } | 698 | } |
699 | 699 | ||
700 | 700 | ||
701 | 701 | ||
702 | void KABCore::mailVCard() | 702 | void KABCore::mailVCard() |
703 | { | 703 | { |
704 | QStringList uids = mViewManager->selectedUids(); | 704 | QStringList uids = mViewManager->selectedUids(); |
705 | if ( !uids.isEmpty() ) | 705 | if ( !uids.isEmpty() ) |
706 | mailVCard( uids ); | 706 | mailVCard( uids ); |
707 | } | 707 | } |
708 | 708 | ||
709 | void KABCore::mailVCard( const QStringList& uids ) | 709 | void KABCore::mailVCard( const QStringList& uids ) |
710 | { | 710 | { |
711 | QStringList urls; | 711 | QStringList urls; |
712 | 712 | ||
713 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 713 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
714 | 714 | ||
715 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 715 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
716 | 716 | ||
717 | 717 | ||
718 | 718 | ||
719 | QDir().mkdir( dirName, true ); | 719 | QDir().mkdir( dirName, true ); |
720 | 720 | ||
721 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 721 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
722 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 722 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
723 | 723 | ||
724 | if ( a.isEmpty() ) | 724 | if ( a.isEmpty() ) |
725 | continue; | 725 | continue; |
726 | 726 | ||
727 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 727 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
728 | 728 | ||
729 | QString fileName = dirName + "/" + name; | 729 | QString fileName = dirName + "/" + name; |
730 | 730 | ||
731 | QFile outFile(fileName); | 731 | QFile outFile(fileName); |
732 | 732 | ||
733 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 733 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
734 | KABC::VCardConverter converter; | 734 | KABC::VCardConverter converter; |
735 | QString vcard; | 735 | QString vcard; |
736 | 736 | ||
737 | converter.addresseeToVCard( a, vcard ); | 737 | converter.addresseeToVCard( a, vcard ); |
738 | 738 | ||
739 | QTextStream t( &outFile ); // use a text stream | 739 | QTextStream t( &outFile ); // use a text stream |
740 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 740 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
741 | t << vcard; | 741 | t << vcard; |
742 | 742 | ||
743 | outFile.close(); | 743 | outFile.close(); |
744 | 744 | ||
745 | urls.append( fileName ); | 745 | urls.append( fileName ); |
746 | } | 746 | } |
747 | } | 747 | } |
748 | 748 | ||
749 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 749 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
750 | 750 | ||
751 | 751 | ||
752 | /*US | 752 | /*US |
753 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 753 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
754 | QString::null, // subject | 754 | QString::null, // subject |
755 | QString::null, // body | 755 | QString::null, // body |
756 | QString::null, | 756 | QString::null, |
757 | urls ); // attachments | 757 | urls ); // attachments |
758 | */ | 758 | */ |
759 | 759 | ||
760 | } | 760 | } |
761 | 761 | ||
762 | /** | 762 | /** |
763 | Beams the "WhoAmI contact. | 763 | Beams the "WhoAmI contact. |
764 | */ | 764 | */ |
765 | void KABCore::beamMySelf() | 765 | void KABCore::beamMySelf() |
766 | { | 766 | { |
767 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 767 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
768 | if (!a.isEmpty()) | 768 | if (!a.isEmpty()) |
769 | { | 769 | { |
770 | QStringList uids; | 770 | QStringList uids; |
771 | uids << a.uid(); | 771 | uids << a.uid(); |
772 | 772 | ||
773 | beamVCard(uids); | 773 | beamVCard(uids); |
774 | } else { | 774 | } else { |
775 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 775 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
776 | 776 | ||
777 | 777 | ||
778 | } | 778 | } |
779 | } | 779 | } |
780 | 780 | ||
781 | void KABCore::export2phone() | 781 | void KABCore::export2phone() |
782 | { | 782 | { |
783 | 783 | ||
784 | KAex2phonePrefs ex2phone; | 784 | KAex2phonePrefs ex2phone; |
785 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 785 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
786 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 786 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
787 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 787 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
788 | 788 | ||
789 | if ( !ex2phone.exec() ) { | 789 | if ( !ex2phone.exec() ) { |
790 | return; | 790 | return; |
791 | } | 791 | } |
792 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 792 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
793 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 793 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
794 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 794 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
795 | 795 | ||
796 | 796 | ||
797 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 797 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
798 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 798 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
799 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 799 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
800 | 800 | ||
801 | QStringList uids = mViewManager->selectedUids(); | 801 | QStringList uids = mViewManager->selectedUids(); |
802 | if ( uids.isEmpty() ) | 802 | if ( uids.isEmpty() ) |
803 | return; | 803 | return; |
804 | 804 | ||
805 | QString fileName = getPhoneFile(); | 805 | QString fileName = getPhoneFile(); |
806 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 806 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
807 | return; | 807 | return; |
808 | 808 | ||
809 | message(i18n("Exporting to phone...")); | 809 | message(i18n("Exporting to phone...")); |
810 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 810 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
811 | 811 | ||
812 | } | 812 | } |
813 | QString KABCore::getPhoneFile() | 813 | QString KABCore::getPhoneFile() |
814 | { | 814 | { |
815 | #ifdef DESKTOP_VERSION | 815 | #ifdef DESKTOP_VERSION |
816 | return locateLocal("tmp", "phonefile.vcf"); | 816 | return locateLocal("tmp", "phonefile.vcf"); |
817 | #else | 817 | #else |
818 | return "/tmp/phonefile.vcf"; | 818 | return "/tmp/phonefile.vcf"; |
819 | #endif | 819 | #endif |
820 | 820 | ||
821 | } | 821 | } |
822 | void KABCore::writeToPhone( ) | 822 | void KABCore::writeToPhone( ) |
823 | { | 823 | { |
824 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 824 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
825 | message(i18n("Export to phone finished!")); | 825 | message(i18n("Export to phone finished!")); |
826 | else | 826 | else |
827 | qDebug(i18n("Error exporting to phone")); | 827 | qDebug(i18n("Error exporting to phone")); |
828 | } | 828 | } |
829 | void KABCore::beamVCard() | 829 | void KABCore::beamVCard() |
830 | { | 830 | { |
831 | QStringList uids = mViewManager->selectedUids(); | 831 | QStringList uids = mViewManager->selectedUids(); |
832 | if ( !uids.isEmpty() ) | 832 | if ( !uids.isEmpty() ) |
833 | beamVCard( uids ); | 833 | beamVCard( uids ); |
834 | } | 834 | } |
835 | 835 | ||
836 | 836 | ||
837 | void KABCore::beamVCard(const QStringList& uids) | 837 | void KABCore::beamVCard(const QStringList& uids) |
838 | { | 838 | { |
839 | 839 | ||
840 | // LR: we should use the /tmp dir on the Zaurus, | 840 | // LR: we should use the /tmp dir on the Zaurus, |
841 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 841 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
842 | 842 | ||
843 | #ifdef DESKTOP_VERSION | 843 | #ifdef DESKTOP_VERSION |
844 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 844 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
845 | #else | 845 | #else |
846 | QString fileName = "/tmp/kapibeamfile.vcf"; | 846 | QString fileName = "/tmp/kapibeamfile.vcf"; |
847 | #endif | 847 | #endif |
848 | 848 | ||
849 | KABC::VCardConverter converter; | 849 | KABC::VCardConverter converter; |
850 | QString description; | 850 | QString description; |
851 | QString datastream; | 851 | QString datastream; |
852 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 852 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
853 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 853 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
854 | 854 | ||
855 | if ( a.isEmpty() ) | 855 | if ( a.isEmpty() ) |
856 | continue; | 856 | continue; |
857 | 857 | ||
858 | if (description.isEmpty()) | 858 | if (description.isEmpty()) |
859 | description = a.formattedName(); | 859 | description = a.formattedName(); |
860 | 860 | ||
861 | QString vcard; | 861 | QString vcard; |
862 | converter.addresseeToVCard( a, vcard ); | 862 | converter.addresseeToVCard( a, vcard ); |
863 | int start = 0; | 863 | int start = 0; |
864 | int next; | 864 | int next; |
865 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 865 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
866 | int semi = vcard.find(";", next); | 866 | int semi = vcard.find(";", next); |
867 | int dopp = vcard.find(":", next); | 867 | int dopp = vcard.find(":", next); |
868 | int sep; | 868 | int sep; |
869 | if ( semi < dopp && semi >= 0 ) | 869 | if ( semi < dopp && semi >= 0 ) |
870 | sep = semi ; | 870 | sep = semi ; |
871 | else | 871 | else |
872 | sep = dopp; | 872 | sep = dopp; |
873 | datastream +=vcard.mid( start, next - start); | 873 | datastream +=vcard.mid( start, next - start); |
874 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 874 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
875 | start = sep; | 875 | start = sep; |
876 | } | 876 | } |
877 | datastream += vcard.mid( start,vcard.length() ); | 877 | datastream += vcard.mid( start,vcard.length() ); |
878 | } | 878 | } |
879 | #ifndef DESKTOP_VERSION | 879 | #ifndef DESKTOP_VERSION |
880 | QFile outFile(fileName); | 880 | QFile outFile(fileName); |
881 | if ( outFile.open(IO_WriteOnly) ) { | 881 | if ( outFile.open(IO_WriteOnly) ) { |
882 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 882 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
883 | QTextStream t( &outFile ); // use a text stream | 883 | QTextStream t( &outFile ); // use a text stream |
884 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 884 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
885 | t.setEncoding( QTextStream::Latin1 ); | 885 | t.setEncoding( QTextStream::Latin1 ); |
886 | t <<datastream.latin1(); | 886 | t <<datastream.latin1(); |
887 | outFile.close(); | 887 | outFile.close(); |
888 | Ir *ir = new Ir( this ); | 888 | Ir *ir = new Ir( this ); |
889 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 889 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
890 | ir->send( fileName, description, "text/x-vCard" ); | 890 | ir->send( fileName, description, "text/x-vCard" ); |
891 | } else { | 891 | } else { |
892 | qDebug("Error open temp beam file "); | 892 | qDebug("Error open temp beam file "); |
893 | return; | 893 | return; |
894 | } | 894 | } |
895 | #endif | 895 | #endif |
896 | 896 | ||
897 | } | 897 | } |
898 | 898 | ||
899 | void KABCore::beamDone( Ir *ir ) | 899 | void KABCore::beamDone( Ir *ir ) |
900 | { | 900 | { |
901 | #ifndef DESKTOP_VERSION | 901 | #ifndef DESKTOP_VERSION |
902 | delete ir; | 902 | delete ir; |
903 | #endif | 903 | #endif |
904 | topLevelWidget()->raise(); | 904 | topLevelWidget()->raise(); |
905 | message( i18n("Beaming finished!") ); | 905 | message( i18n("Beaming finished!") ); |
906 | } | 906 | } |
907 | 907 | ||
908 | 908 | ||
909 | void KABCore::browse( const QString& url ) | 909 | void KABCore::browse( const QString& url ) |
910 | { | 910 | { |
911 | #ifndef KAB_EMBEDDED | 911 | #ifndef KAB_EMBEDDED |
912 | kapp->invokeBrowser( url ); | 912 | kapp->invokeBrowser( url ); |
913 | #else //KAB_EMBEDDED | 913 | #else //KAB_EMBEDDED |
914 | qDebug("KABCore::browse must be fixed"); | 914 | qDebug("KABCore::browse must be fixed"); |
915 | #endif //KAB_EMBEDDED | 915 | #endif //KAB_EMBEDDED |
916 | } | 916 | } |
917 | 917 | ||
918 | void KABCore::selectAllContacts() | 918 | void KABCore::selectAllContacts() |
919 | { | 919 | { |
920 | mViewManager->setSelected( QString::null, true ); | 920 | mViewManager->setSelected( QString::null, true ); |
921 | } | 921 | } |
922 | 922 | ||
923 | void KABCore::deleteContacts() | 923 | void KABCore::deleteContacts() |
924 | { | 924 | { |
925 | QStringList uidList = mViewManager->selectedUids(); | 925 | QStringList uidList = mViewManager->selectedUids(); |
926 | deleteContacts( uidList ); | 926 | deleteContacts( uidList ); |
927 | } | 927 | } |
928 | 928 | ||
929 | void KABCore::deleteContacts( const QStringList &uids ) | 929 | void KABCore::deleteContacts( const QStringList &uids ) |
930 | { | 930 | { |
931 | if ( uids.count() > 0 ) { | 931 | if ( uids.count() > 0 ) { |
932 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 932 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
933 | UndoStack::instance()->push( command ); | 933 | UndoStack::instance()->push( command ); |
934 | RedoStack::instance()->clear(); | 934 | RedoStack::instance()->clear(); |
935 | 935 | ||
936 | // now if we deleted anything, refresh | 936 | // now if we deleted anything, refresh |
937 | setContactSelected( QString::null ); | 937 | setContactSelected( QString::null ); |
938 | setModified( true ); | 938 | setModified( true ); |
939 | } | 939 | } |
940 | } | 940 | } |
941 | 941 | ||
942 | void KABCore::copyContacts() | 942 | void KABCore::copyContacts() |
943 | { | 943 | { |
944 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 944 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
945 | 945 | ||
946 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 946 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
947 | 947 | ||
948 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 948 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
949 | 949 | ||
950 | QClipboard *cb = QApplication::clipboard(); | 950 | QClipboard *cb = QApplication::clipboard(); |
951 | cb->setText( clipText ); | 951 | cb->setText( clipText ); |
952 | } | 952 | } |
953 | 953 | ||
954 | void KABCore::cutContacts() | 954 | void KABCore::cutContacts() |
955 | { | 955 | { |
956 | QStringList uidList = mViewManager->selectedUids(); | 956 | QStringList uidList = mViewManager->selectedUids(); |
957 | 957 | ||
958 | //US if ( uidList.size() > 0 ) { | 958 | //US if ( uidList.size() > 0 ) { |
959 | if ( uidList.count() > 0 ) { | 959 | if ( uidList.count() > 0 ) { |
960 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 960 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
961 | UndoStack::instance()->push( command ); | 961 | UndoStack::instance()->push( command ); |
962 | RedoStack::instance()->clear(); | 962 | RedoStack::instance()->clear(); |
963 | 963 | ||
964 | setModified( true ); | 964 | setModified( true ); |
965 | } | 965 | } |
966 | } | 966 | } |
967 | 967 | ||
968 | void KABCore::pasteContacts() | 968 | void KABCore::pasteContacts() |
969 | { | 969 | { |
970 | QClipboard *cb = QApplication::clipboard(); | 970 | QClipboard *cb = QApplication::clipboard(); |
971 | 971 | ||
972 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 972 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
973 | 973 | ||
974 | pasteContacts( list ); | 974 | pasteContacts( list ); |
975 | } | 975 | } |
976 | 976 | ||
977 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 977 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
978 | { | 978 | { |
979 | KABC::Resource *resource = requestResource( this ); | 979 | KABC::Resource *resource = requestResource( this ); |
980 | KABC::Addressee::List::Iterator it; | 980 | KABC::Addressee::List::Iterator it; |
981 | for ( it = list.begin(); it != list.end(); ++it ) | 981 | for ( it = list.begin(); it != list.end(); ++it ) |
982 | (*it).setResource( resource ); | 982 | (*it).setResource( resource ); |
983 | 983 | ||
984 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 984 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
985 | UndoStack::instance()->push( command ); | 985 | UndoStack::instance()->push( command ); |
986 | RedoStack::instance()->clear(); | 986 | RedoStack::instance()->clear(); |
987 | 987 | ||
988 | setModified( true ); | 988 | setModified( true ); |
989 | } | 989 | } |
990 | 990 | ||
991 | void KABCore::setWhoAmI() | 991 | void KABCore::setWhoAmI() |
992 | { | 992 | { |
993 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 993 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
994 | 994 | ||
995 | if ( addrList.count() > 1 ) { | 995 | if ( addrList.count() > 1 ) { |
996 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 996 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
997 | return; | 997 | return; |
998 | } | 998 | } |
999 | 999 | ||
1000 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1000 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1001 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 1001 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
1002 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1002 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1003 | } | 1003 | } |
1004 | void KABCore::editCategories() | 1004 | void KABCore::editCategories() |
1005 | { | 1005 | { |
1006 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1006 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1007 | dlg.exec(); | 1007 | dlg.exec(); |
1008 | } | 1008 | } |
1009 | void KABCore::setCategories() | 1009 | void KABCore::setCategories() |
1010 | { | 1010 | { |
1011 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1011 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1012 | if ( !dlg.exec() ) { | 1012 | if ( !dlg.exec() ) { |
1013 | message( i18n("Setting categories cancelled") ); | 1013 | message( i18n("Setting categories cancelled") ); |
1014 | return; | 1014 | return; |
1015 | } | 1015 | } |
1016 | bool merge = false; | 1016 | bool merge = false; |
1017 | QString msg = i18n( "Merge with existing categories?" ); | 1017 | QString msg = i18n( "Merge with existing categories?" ); |
1018 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1018 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1019 | merge = true; | 1019 | merge = true; |
1020 | 1020 | ||
1021 | message( i18n("Setting categories ... please wait!") ); | 1021 | message( i18n("Setting categories ... please wait!") ); |
1022 | QStringList categories = dlg.selectedCategories(); | 1022 | QStringList categories = dlg.selectedCategories(); |
1023 | 1023 | ||
1024 | QStringList uids = mViewManager->selectedUids(); | 1024 | QStringList uids = mViewManager->selectedUids(); |
1025 | QStringList::Iterator it; | 1025 | QStringList::Iterator it; |
1026 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1026 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1027 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1027 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1028 | if ( !addr.isEmpty() ) { | 1028 | if ( !addr.isEmpty() ) { |
1029 | if ( !merge ) | 1029 | if ( !merge ) |
1030 | addr.setCategories( categories ); | 1030 | addr.setCategories( categories ); |
1031 | else { | 1031 | else { |
1032 | QStringList addrCategories = addr.categories(); | 1032 | QStringList addrCategories = addr.categories(); |
1033 | QStringList::Iterator catIt; | 1033 | QStringList::Iterator catIt; |
1034 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1034 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1035 | if ( !addrCategories.contains( *catIt ) ) | 1035 | if ( !addrCategories.contains( *catIt ) ) |
1036 | addrCategories.append( *catIt ); | 1036 | addrCategories.append( *catIt ); |
1037 | } | 1037 | } |
1038 | addr.setCategories( addrCategories ); | 1038 | addr.setCategories( addrCategories ); |
1039 | } | 1039 | } |
1040 | mAddressBook->insertAddressee( addr ); | 1040 | mAddressBook->insertAddressee( addr ); |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | if ( uids.count() > 0 ) | 1044 | if ( uids.count() > 0 ) |
1045 | setModified( true ); | 1045 | setModified( true ); |
1046 | message( i18n("Setting categories completed!") ); | 1046 | message( i18n("Setting categories completed!") ); |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1049 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1050 | { | 1050 | { |
1051 | mIncSearchWidget->setFields( fields ); | 1051 | mIncSearchWidget->setFields( fields ); |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | void KABCore::incrementalSearch( const QString& text ) | 1054 | void KABCore::incrementalSearch( const QString& text ) |
1055 | { | 1055 | { |
1056 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1056 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | void KABCore::setModified() | 1059 | void KABCore::setModified() |
1060 | { | 1060 | { |
1061 | setModified( true ); | 1061 | setModified( true ); |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | void KABCore::setModifiedWOrefresh() | 1064 | void KABCore::setModifiedWOrefresh() |
1065 | { | 1065 | { |
1066 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1066 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1067 | mModified = true; | 1067 | mModified = true; |
1068 | mActionSave->setEnabled( mModified ); | 1068 | mActionSave->setEnabled( mModified ); |
1069 | #ifdef DESKTOP_VERSION | 1069 | #ifdef DESKTOP_VERSION |
1070 | mDetails->refreshView(); | 1070 | mDetails->refreshView(); |
1071 | #endif | 1071 | #endif |
1072 | 1072 | ||
1073 | } | 1073 | } |
1074 | void KABCore::setModified( bool modified ) | 1074 | void KABCore::setModified( bool modified ) |
1075 | { | 1075 | { |
1076 | mModified = modified; | 1076 | mModified = modified; |
1077 | mActionSave->setEnabled( mModified ); | 1077 | mActionSave->setEnabled( mModified ); |
1078 | 1078 | ||
1079 | if ( modified ) | 1079 | if ( modified ) |
1080 | mJumpButtonBar->recreateButtons(); | 1080 | mJumpButtonBar->recreateButtons(); |
1081 | 1081 | ||
1082 | mViewManager->refreshView(); | 1082 | mViewManager->refreshView(); |
1083 | mDetails->refreshView(); | 1083 | mDetails->refreshView(); |
1084 | 1084 | ||
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | bool KABCore::modified() const | 1087 | bool KABCore::modified() const |
1088 | { | 1088 | { |
1089 | return mModified; | 1089 | return mModified; |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1092 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1093 | { | 1093 | { |
1094 | 1094 | ||
1095 | Command *command = 0; | 1095 | Command *command = 0; |
1096 | QString uid; | 1096 | QString uid; |
1097 | 1097 | ||
1098 | // check if it exists already | 1098 | // check if it exists already |
1099 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1099 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1100 | if ( origAddr.isEmpty() ) | 1100 | if ( origAddr.isEmpty() ) |
1101 | command = new PwNewCommand( mAddressBook, addr ); | 1101 | command = new PwNewCommand( mAddressBook, addr ); |
1102 | else { | 1102 | else { |
1103 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1103 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1104 | uid = addr.uid(); | 1104 | uid = addr.uid(); |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | UndoStack::instance()->push( command ); | 1107 | UndoStack::instance()->push( command ); |
1108 | RedoStack::instance()->clear(); | 1108 | RedoStack::instance()->clear(); |
1109 | 1109 | ||
1110 | setModified( true ); | 1110 | setModified( true ); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | void KABCore::newContact() | 1113 | void KABCore::newContact() |
1114 | { | 1114 | { |
1115 | 1115 | ||
1116 | 1116 | ||
1117 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1117 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1118 | 1118 | ||
1119 | QPtrList<KRES::Resource> kresResources; | 1119 | QPtrList<KRES::Resource> kresResources; |
1120 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1120 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1121 | KABC::Resource *resource; | 1121 | KABC::Resource *resource; |
1122 | while ( ( resource = it.current() ) != 0 ) { | 1122 | while ( ( resource = it.current() ) != 0 ) { |
1123 | ++it; | 1123 | ++it; |
1124 | if ( !resource->readOnly() ) { | 1124 | if ( !resource->readOnly() ) { |
1125 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1125 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1126 | if ( res ) | 1126 | if ( res ) |
1127 | kresResources.append( res ); | 1127 | kresResources.append( res ); |
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1131 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1132 | resource = static_cast<KABC::Resource*>( res ); | 1132 | resource = static_cast<KABC::Resource*>( res ); |
1133 | 1133 | ||
1134 | if ( resource ) { | 1134 | if ( resource ) { |
1135 | KABC::Addressee addr; | 1135 | KABC::Addressee addr; |
1136 | addr.setResource( resource ); | 1136 | addr.setResource( resource ); |
1137 | mEditorDialog->setAddressee( addr ); | 1137 | mEditorDialog->setAddressee( addr ); |
1138 | KApplication::execDialog ( mEditorDialog ); | 1138 | KApplication::execDialog ( mEditorDialog ); |
1139 | 1139 | ||
1140 | } else | 1140 | } else |
1141 | return; | 1141 | return; |
1142 | 1142 | ||
1143 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1143 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1144 | 1144 | ||
1145 | 1145 | ||
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | void KABCore::addEmail( QString aStr ) | 1148 | void KABCore::addEmail( QString aStr ) |
1149 | { | 1149 | { |
1150 | #ifndef KAB_EMBEDDED | 1150 | #ifndef KAB_EMBEDDED |
1151 | QString fullName, email; | 1151 | QString fullName, email; |
1152 | 1152 | ||
1153 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1153 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1154 | 1154 | ||
1155 | // Try to lookup the addressee matching the email address | 1155 | // Try to lookup the addressee matching the email address |
1156 | bool found = false; | 1156 | bool found = false; |
1157 | QStringList emailList; | 1157 | QStringList emailList; |
1158 | KABC::AddressBook::Iterator it; | 1158 | KABC::AddressBook::Iterator it; |
1159 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1159 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1160 | emailList = (*it).emails(); | 1160 | emailList = (*it).emails(); |
1161 | if ( emailList.contains( email ) > 0 ) { | 1161 | if ( emailList.contains( email ) > 0 ) { |
1162 | found = true; | 1162 | found = true; |
1163 | (*it).setNameFromString( fullName ); | 1163 | (*it).setNameFromString( fullName ); |
1164 | editContact( (*it).uid() ); | 1164 | editContact( (*it).uid() ); |
1165 | } | 1165 | } |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | if ( !found ) { | 1168 | if ( !found ) { |
1169 | KABC::Addressee addr; | 1169 | KABC::Addressee addr; |
1170 | addr.setNameFromString( fullName ); | 1170 | addr.setNameFromString( fullName ); |
1171 | addr.insertEmail( email, true ); | 1171 | addr.insertEmail( email, true ); |
1172 | 1172 | ||
1173 | mAddressBook->insertAddressee( addr ); | 1173 | mAddressBook->insertAddressee( addr ); |
1174 | mViewManager->refreshView( addr.uid() ); | 1174 | mViewManager->refreshView( addr.uid() ); |
1175 | editContact( addr.uid() ); | 1175 | editContact( addr.uid() ); |
1176 | } | 1176 | } |
1177 | #else //KAB_EMBEDDED | 1177 | #else //KAB_EMBEDDED |
1178 | qDebug("KABCore::addEmail finsih method"); | 1178 | qDebug("KABCore::addEmail finsih method"); |
1179 | #endif //KAB_EMBEDDED | 1179 | #endif //KAB_EMBEDDED |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1182 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1183 | { | 1183 | { |
1184 | mXXPortManager->importVCard( url, showPreview ); | 1184 | mXXPortManager->importVCard( url, showPreview ); |
1185 | } | 1185 | } |
1186 | void KABCore::importFromOL() | 1186 | void KABCore::importFromOL() |
1187 | { | 1187 | { |
1188 | #ifdef _WIN32_ | 1188 | #ifdef _WIN32_ |
1189 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1189 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1190 | idgl->exec(); | 1190 | idgl->exec(); |
1191 | KABC::Addressee::List list = idgl->getAddressList(); | 1191 | KABC::Addressee::List list = idgl->getAddressList(); |
1192 | if ( list.count() > 0 ) { | 1192 | if ( list.count() > 0 ) { |
1193 | KABC::Addressee::List listNew; | 1193 | KABC::Addressee::List listNew; |
1194 | KABC::Addressee::List listExisting; | 1194 | KABC::Addressee::List listExisting; |
1195 | KABC::Addressee::List::Iterator it; | 1195 | KABC::Addressee::List::Iterator it; |
1196 | KABC::AddressBook::Iterator iter; | 1196 | KABC::AddressBook::Iterator iter; |
1197 | for ( it = list.begin(); it != list.end(); ++it ) { | 1197 | for ( it = list.begin(); it != list.end(); ++it ) { |
1198 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1198 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1199 | listNew.append( (*it) ); | 1199 | listNew.append( (*it) ); |
1200 | else | 1200 | else |
1201 | listExisting.append( (*it) ); | 1201 | listExisting.append( (*it) ); |
1202 | } | 1202 | } |
1203 | if ( listExisting.count() > 0 ) | 1203 | if ( listExisting.count() > 0 ) |
1204 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1204 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1205 | if ( listNew.count() > 0 ) { | 1205 | if ( listNew.count() > 0 ) { |
1206 | pasteWithNewUid = false; | 1206 | pasteWithNewUid = false; |
1207 | pasteContacts( listNew ); | 1207 | pasteContacts( listNew ); |
1208 | pasteWithNewUid = true; | 1208 | pasteWithNewUid = true; |
1209 | } | 1209 | } |
1210 | } | 1210 | } |
1211 | delete idgl; | 1211 | delete idgl; |
1212 | #endif | 1212 | #endif |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1215 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1216 | { | 1216 | { |
1217 | mXXPortManager->importVCard( vCard, showPreview ); | 1217 | mXXPortManager->importVCard( vCard, showPreview ); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | //US added a second method without defaultparameter | 1220 | //US added a second method without defaultparameter |
1221 | void KABCore::editContact2() { | 1221 | void KABCore::editContact2() { |
1222 | editContact( QString::null ); | 1222 | editContact( QString::null ); |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | void KABCore::editContact( const QString &uid ) | 1225 | void KABCore::editContact( const QString &uid ) |
1226 | { | 1226 | { |
1227 | 1227 | ||
1228 | if ( mExtensionManager->isQuickEditVisible() ) | 1228 | if ( mExtensionManager->isQuickEditVisible() ) |
1229 | return; | 1229 | return; |
1230 | 1230 | ||
1231 | // First, locate the contact entry | 1231 | // First, locate the contact entry |
1232 | QString localUID = uid; | 1232 | QString localUID = uid; |
1233 | if ( localUID.isNull() ) { | 1233 | if ( localUID.isNull() ) { |
1234 | QStringList uidList = mViewManager->selectedUids(); | 1234 | QStringList uidList = mViewManager->selectedUids(); |
1235 | if ( uidList.count() > 0 ) | 1235 | if ( uidList.count() > 0 ) |
1236 | localUID = *( uidList.at( 0 ) ); | 1236 | localUID = *( uidList.at( 0 ) ); |
1237 | } | 1237 | } |
1238 | 1238 | ||
1239 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1239 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1240 | if ( !addr.isEmpty() ) { | 1240 | if ( !addr.isEmpty() ) { |
1241 | mEditorDialog->setAddressee( addr ); | 1241 | mEditorDialog->setAddressee( addr ); |
1242 | KApplication::execDialog ( mEditorDialog ); | 1242 | KApplication::execDialog ( mEditorDialog ); |
1243 | } | 1243 | } |
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | /** | 1246 | /** |
1247 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1247 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1248 | the method will try to find a selected addressee in the view. | 1248 | the method will try to find a selected addressee in the view. |
1249 | */ | 1249 | */ |
1250 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1250 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1251 | { | 1251 | { |
1252 | if ( mMultipleViewsAtOnce ) | 1252 | if ( mMultipleViewsAtOnce ) |
1253 | { | 1253 | { |
1254 | editContact( uid ); | 1254 | editContact( uid ); |
1255 | } | 1255 | } |
1256 | else | 1256 | else |
1257 | { | 1257 | { |
1258 | setDetailsVisible( true ); | 1258 | setDetailsVisible( true ); |
1259 | mActionDetails->setChecked(true); | 1259 | mActionDetails->setChecked(true); |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | void KABCore::save() | 1264 | void KABCore::save() |
1265 | { | 1265 | { |
1266 | if (syncManager->blockSave()) | 1266 | if (syncManager->blockSave()) |
1267 | return; | 1267 | return; |
1268 | if ( !mModified ) | 1268 | if ( !mModified ) |
1269 | return; | 1269 | return; |
1270 | 1270 | ||
1271 | syncManager->setBlockSave(true); | 1271 | syncManager->setBlockSave(true); |
1272 | QString text = i18n( "There was an error while attempting to save\n the " | 1272 | QString text = i18n( "There was an error while attempting to save\n the " |
1273 | "address book. Please check that some \nother application is " | 1273 | "address book. Please check that some \nother application is " |
1274 | "not using it. " ); | 1274 | "not using it. " ); |
1275 | message(i18n("Saving addressbook ... ")); | 1275 | message(i18n("Saving addressbook ... ")); |
1276 | #ifndef KAB_EMBEDDED | 1276 | #ifndef KAB_EMBEDDED |
1277 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1277 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1278 | if ( !b || !b->save() ) { | 1278 | if ( !b || !b->save() ) { |
1279 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1279 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1280 | } | 1280 | } |
1281 | #else //KAB_EMBEDDED | 1281 | #else //KAB_EMBEDDED |
1282 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1282 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1283 | if ( !b || !b->save() ) { | 1283 | if ( !b || !b->save() ) { |
1284 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1284 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1285 | } | 1285 | } |
1286 | #endif //KAB_EMBEDDED | 1286 | #endif //KAB_EMBEDDED |
1287 | 1287 | ||
1288 | message(i18n("Addressbook saved!")); | 1288 | message(i18n("Addressbook saved!")); |
1289 | setModified( false ); | 1289 | setModified( false ); |
1290 | syncManager->setBlockSave(false); | 1290 | syncManager->setBlockSave(false); |
1291 | } | 1291 | } |
1292 | 1292 | ||
1293 | 1293 | ||
1294 | void KABCore::undo() | 1294 | void KABCore::undo() |
1295 | { | 1295 | { |
1296 | UndoStack::instance()->undo(); | 1296 | UndoStack::instance()->undo(); |
1297 | 1297 | ||
1298 | // Refresh the view | 1298 | // Refresh the view |
1299 | mViewManager->refreshView(); | 1299 | mViewManager->refreshView(); |
1300 | } | 1300 | } |
1301 | 1301 | ||
1302 | void KABCore::redo() | 1302 | void KABCore::redo() |
1303 | { | 1303 | { |
1304 | RedoStack::instance()->redo(); | 1304 | RedoStack::instance()->redo(); |
1305 | 1305 | ||
1306 | // Refresh the view | 1306 | // Refresh the view |
1307 | mViewManager->refreshView(); | 1307 | mViewManager->refreshView(); |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1310 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1311 | { | 1311 | { |
1312 | if (mMultipleViewsAtOnce) | 1312 | if (mMultipleViewsAtOnce) |
1313 | { | 1313 | { |
1314 | if ( visible ) | 1314 | if ( visible ) |
1315 | mJumpButtonBar->show(); | 1315 | mJumpButtonBar->show(); |
1316 | else | 1316 | else |
1317 | mJumpButtonBar->hide(); | 1317 | mJumpButtonBar->hide(); |
1318 | } | 1318 | } |
1319 | else | 1319 | else |
1320 | { | 1320 | { |
1321 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1321 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1322 | if (mViewManager->isVisible()) | 1322 | if (mViewManager->isVisible()) |
1323 | { | 1323 | { |
1324 | if ( visible ) | 1324 | if ( visible ) |
1325 | mJumpButtonBar->show(); | 1325 | mJumpButtonBar->show(); |
1326 | else | 1326 | else |
1327 | mJumpButtonBar->hide(); | 1327 | mJumpButtonBar->hide(); |
1328 | } | 1328 | } |
1329 | else | 1329 | else |
1330 | { | 1330 | { |
1331 | mJumpButtonBar->hide(); | 1331 | mJumpButtonBar->hide(); |
1332 | } | 1332 | } |
1333 | } | 1333 | } |
1334 | } | 1334 | } |
1335 | 1335 | ||
1336 | 1336 | ||
1337 | void KABCore::setDetailsToState() | 1337 | void KABCore::setDetailsToState() |
1338 | { | 1338 | { |
1339 | setDetailsVisible( mActionDetails->isChecked() ); | 1339 | setDetailsVisible( mActionDetails->isChecked() ); |
1340 | } | 1340 | } |
1341 | void KABCore::setDetailsToggle() | 1341 | void KABCore::setDetailsToggle() |
1342 | { | 1342 | { |
1343 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1343 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1344 | setDetailsToState(); | 1344 | setDetailsToState(); |
1345 | } | 1345 | } |
1346 | 1346 | ||
1347 | 1347 | ||
1348 | 1348 | ||
1349 | void KABCore::setDetailsVisible( bool visible ) | 1349 | void KABCore::setDetailsVisible( bool visible ) |
1350 | { | 1350 | { |
1351 | if (visible && mDetails->isHidden()) | 1351 | if (visible && mDetails->isHidden()) |
1352 | { | 1352 | { |
1353 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1353 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1354 | if ( addrList.count() > 0 ) | 1354 | if ( addrList.count() > 0 ) |
1355 | mDetails->setAddressee( addrList[ 0 ] ); | 1355 | mDetails->setAddressee( addrList[ 0 ] ); |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1358 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1359 | // the listview and the detailview. We do that by changing the splitbar size. | 1359 | // the listview and the detailview. We do that by changing the splitbar size. |
1360 | if (mMultipleViewsAtOnce) | 1360 | if (mMultipleViewsAtOnce) |
1361 | { | 1361 | { |
1362 | if ( visible ) | 1362 | if ( visible ) |
1363 | mDetails->show(); | 1363 | mDetails->show(); |
1364 | else | 1364 | else |
1365 | mDetails->hide(); | 1365 | mDetails->hide(); |
1366 | } | 1366 | } |
1367 | else | 1367 | else |
1368 | { | 1368 | { |
1369 | if ( visible ) { | 1369 | if ( visible ) { |
1370 | mViewManager->hide(); | 1370 | mViewManager->hide(); |
1371 | mDetails->show(); | 1371 | mDetails->show(); |
1372 | mIncSearchWidget->setFocus(); | 1372 | mIncSearchWidget->setFocus(); |
1373 | } | 1373 | } |
1374 | else { | 1374 | else { |
1375 | mViewManager->show(); | 1375 | mViewManager->show(); |
1376 | mDetails->hide(); | 1376 | mDetails->hide(); |
1377 | mViewManager->setFocusAV(); | 1377 | mViewManager->setFocusAV(); |
1378 | } | 1378 | } |
1379 | setJumpButtonBarVisible( !visible ); | 1379 | setJumpButtonBarVisible( !visible ); |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | } | 1382 | } |
1383 | 1383 | ||
1384 | void KABCore::extensionChanged( int id ) | 1384 | void KABCore::extensionChanged( int id ) |
1385 | { | 1385 | { |
1386 | //change the details view only for non desktop systems | 1386 | //change the details view only for non desktop systems |
1387 | #ifndef DESKTOP_VERSION | 1387 | #ifndef DESKTOP_VERSION |
1388 | 1388 | ||
1389 | if (id == 0) | 1389 | if (id == 0) |
1390 | { | 1390 | { |
1391 | //the user disabled the extension. | 1391 | //the user disabled the extension. |
1392 | 1392 | ||
1393 | if (mMultipleViewsAtOnce) | 1393 | if (mMultipleViewsAtOnce) |
1394 | { // enable detailsview again | 1394 | { // enable detailsview again |
1395 | setDetailsVisible( true ); | 1395 | setDetailsVisible( true ); |
1396 | mActionDetails->setChecked( true ); | 1396 | mActionDetails->setChecked( true ); |
1397 | } | 1397 | } |
1398 | else | 1398 | else |
1399 | { //go back to the listview | 1399 | { //go back to the listview |
1400 | setDetailsVisible( false ); | 1400 | setDetailsVisible( false ); |
1401 | mActionDetails->setChecked( false ); | 1401 | mActionDetails->setChecked( false ); |
1402 | mActionDetails->setEnabled(true); | 1402 | mActionDetails->setEnabled(true); |
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | } | 1405 | } |
1406 | else | 1406 | else |
1407 | { | 1407 | { |
1408 | //the user enabled the extension. | 1408 | //the user enabled the extension. |
1409 | setDetailsVisible( false ); | 1409 | setDetailsVisible( false ); |
1410 | mActionDetails->setChecked( false ); | 1410 | mActionDetails->setChecked( false ); |
1411 | 1411 | ||
1412 | if (!mMultipleViewsAtOnce) | 1412 | if (!mMultipleViewsAtOnce) |
1413 | { | 1413 | { |
1414 | mActionDetails->setEnabled(false); | 1414 | mActionDetails->setEnabled(false); |
1415 | } | 1415 | } |
1416 | 1416 | ||
1417 | mExtensionManager->setSelectionChanged(); | 1417 | mExtensionManager->setSelectionChanged(); |
1418 | 1418 | ||
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | #endif// DESKTOP_VERSION | 1421 | #endif// DESKTOP_VERSION |
1422 | 1422 | ||
1423 | } | 1423 | } |
1424 | 1424 | ||
1425 | 1425 | ||
1426 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1426 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1427 | { | 1427 | { |
1428 | 1428 | ||
1429 | if ( list.count() != 0 ) { | 1429 | if ( list.count() != 0 ) { |
1430 | KABC::Addressee::List::ConstIterator it; | 1430 | KABC::Addressee::List::ConstIterator it; |
1431 | for ( it = list.begin(); it != list.end(); ++it ) | 1431 | for ( it = list.begin(); it != list.end(); ++it ) |
1432 | mAddressBook->insertAddressee( *it ); | 1432 | mAddressBook->insertAddressee( *it ); |
1433 | if ( list.count() > 1 ) | 1433 | if ( list.count() > 1 ) |
1434 | setModified(); | 1434 | setModified(); |
1435 | else | 1435 | else |
1436 | setModifiedWOrefresh(); | 1436 | setModifiedWOrefresh(); |
1437 | } | 1437 | } |
1438 | if ( list.count() == 0 ) | 1438 | if ( list.count() == 0 ) |
1439 | mViewManager->refreshView(); | 1439 | mViewManager->refreshView(); |
1440 | else | 1440 | else |
1441 | mViewManager->refreshView( list[ 0 ].uid() ); | 1441 | mViewManager->refreshView( list[ 0 ].uid() ); |
1442 | 1442 | ||
1443 | 1443 | ||
1444 | 1444 | ||
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | QString KABCore::getNameByPhone( const QString &phone ) | 1447 | QString KABCore::getNameByPhone( const QString &phone ) |
1448 | { | 1448 | { |
1449 | #ifndef KAB_EMBEDDED | 1449 | #ifndef KAB_EMBEDDED |
1450 | QRegExp r( "[/*/-/ ]" ); | 1450 | QRegExp r( "[/*/-/ ]" ); |
1451 | QString localPhone( phone ); | 1451 | QString localPhone( phone ); |
1452 | 1452 | ||
1453 | bool found = false; | 1453 | bool found = false; |
1454 | QString ownerName = ""; | 1454 | QString ownerName = ""; |
1455 | KABC::AddressBook::Iterator iter; | 1455 | KABC::AddressBook::Iterator iter; |
1456 | KABC::PhoneNumber::List::Iterator phoneIter; | 1456 | KABC::PhoneNumber::List::Iterator phoneIter; |
1457 | KABC::PhoneNumber::List phoneList; | 1457 | KABC::PhoneNumber::List phoneList; |
1458 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1458 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1459 | phoneList = (*iter).phoneNumbers(); | 1459 | phoneList = (*iter).phoneNumbers(); |
1460 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1460 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1461 | ++phoneIter) { | 1461 | ++phoneIter) { |
1462 | // Get rid of separator chars so just the numbers are compared. | 1462 | // Get rid of separator chars so just the numbers are compared. |
1463 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1463 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1464 | ownerName = (*iter).formattedName(); | 1464 | ownerName = (*iter).formattedName(); |
1465 | found = true; | 1465 | found = true; |
1466 | } | 1466 | } |
1467 | } | 1467 | } |
1468 | } | 1468 | } |
1469 | 1469 | ||
1470 | return ownerName; | 1470 | return ownerName; |
1471 | #else //KAB_EMBEDDED | 1471 | #else //KAB_EMBEDDED |
1472 | qDebug("KABCore::getNameByPhone finsih method"); | 1472 | qDebug("KABCore::getNameByPhone finsih method"); |
1473 | return ""; | 1473 | return ""; |
1474 | #endif //KAB_EMBEDDED | 1474 | #endif //KAB_EMBEDDED |
1475 | 1475 | ||
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | void KABCore::openConfigDialog() | 1478 | void KABCore::openConfigDialog() |
1479 | { | 1479 | { |
1480 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1480 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1481 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1481 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1482 | ConfigureDialog->addModule(kabcfg ); | 1482 | ConfigureDialog->addModule(kabcfg ); |
1483 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1483 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1484 | ConfigureDialog->addModule(kdelibcfg ); | 1484 | ConfigureDialog->addModule(kdelibcfg ); |
1485 | 1485 | ||
1486 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1486 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1487 | this, SLOT( configurationChanged() ) ); | 1487 | this, SLOT( configurationChanged() ) ); |
1488 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1488 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1489 | this, SLOT( configurationChanged() ) ); | 1489 | this, SLOT( configurationChanged() ) ); |
1490 | saveSettings(); | 1490 | saveSettings(); |
1491 | #ifndef DESKTOP_VERSION | 1491 | #ifndef DESKTOP_VERSION |
1492 | ConfigureDialog->showMaximized(); | 1492 | ConfigureDialog->showMaximized(); |
1493 | #endif | 1493 | #endif |
1494 | if ( ConfigureDialog->exec() ) | 1494 | if ( ConfigureDialog->exec() ) |
1495 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1495 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1496 | delete ConfigureDialog; | 1496 | delete ConfigureDialog; |
1497 | } | 1497 | } |
1498 | 1498 | ||
1499 | void KABCore::openLDAPDialog() | 1499 | void KABCore::openLDAPDialog() |
1500 | { | 1500 | { |
1501 | #ifndef KAB_EMBEDDED | 1501 | #ifndef KAB_EMBEDDED |
1502 | if ( !mLdapSearchDialog ) { | 1502 | if ( !mLdapSearchDialog ) { |
1503 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1503 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1504 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1504 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1505 | SLOT( refreshView() ) ); | 1505 | SLOT( refreshView() ) ); |
1506 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1506 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1507 | SLOT( setModified() ) ); | 1507 | SLOT( setModified() ) ); |
1508 | } else | 1508 | } else |
1509 | mLdapSearchDialog->restoreSettings(); | 1509 | mLdapSearchDialog->restoreSettings(); |
1510 | 1510 | ||
1511 | if ( mLdapSearchDialog->isOK() ) | 1511 | if ( mLdapSearchDialog->isOK() ) |
1512 | mLdapSearchDialog->exec(); | 1512 | mLdapSearchDialog->exec(); |
1513 | #else //KAB_EMBEDDED | 1513 | #else //KAB_EMBEDDED |
1514 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1514 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1515 | #endif //KAB_EMBEDDED | 1515 | #endif //KAB_EMBEDDED |
1516 | } | 1516 | } |
1517 | 1517 | ||
1518 | void KABCore::print() | 1518 | void KABCore::print() |
1519 | { | 1519 | { |
1520 | #ifndef KAB_EMBEDDED | 1520 | #ifndef KAB_EMBEDDED |
1521 | KPrinter printer; | 1521 | KPrinter printer; |
1522 | if ( !printer.setup( this ) ) | 1522 | if ( !printer.setup( this ) ) |
1523 | return; | 1523 | return; |
1524 | 1524 | ||
1525 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1525 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1526 | mViewManager->selectedUids(), this ); | 1526 | mViewManager->selectedUids(), this ); |
1527 | 1527 | ||
1528 | wizard.exec(); | 1528 | wizard.exec(); |
1529 | #else //KAB_EMBEDDED | 1529 | #else //KAB_EMBEDDED |
1530 | qDebug("KABCore::print() finsih method"); | 1530 | qDebug("KABCore::print() finsih method"); |
1531 | #endif //KAB_EMBEDDED | 1531 | #endif //KAB_EMBEDDED |
1532 | 1532 | ||
1533 | } | 1533 | } |
1534 | 1534 | ||
1535 | 1535 | ||
1536 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1536 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1537 | { | 1537 | { |
1538 | if ( mGUIClient ) | 1538 | if ( mGUIClient ) |
1539 | mGUIClient->insertChildClient( client ); | 1539 | mGUIClient->insertChildClient( client ); |
1540 | else | 1540 | else |
1541 | KMessageBox::error( this, "no KXMLGUICLient"); | 1541 | KMessageBox::error( this, "no KXMLGUICLient"); |
1542 | } | 1542 | } |
1543 | 1543 | ||
1544 | 1544 | ||
1545 | void KABCore::configurationChanged() | 1545 | void KABCore::configurationChanged() |
1546 | { | 1546 | { |
1547 | mExtensionManager->reconfigure(); | 1547 | mExtensionManager->reconfigure(); |
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | void KABCore::addressBookChanged() | 1550 | void KABCore::addressBookChanged() |
1551 | { | 1551 | { |
1552 | /*US | 1552 | /*US |
1553 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1553 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1554 | while ( it.current() ) { | 1554 | while ( it.current() ) { |
1555 | if ( it.current()->dirty() ) { | 1555 | if ( it.current()->dirty() ) { |
1556 | QString text = i18n( "Data has been changed externally. Unsaved " | 1556 | QString text = i18n( "Data has been changed externally. Unsaved " |
1557 | "changes will be lost." ); | 1557 | "changes will be lost." ); |
1558 | KMessageBox::information( this, text ); | 1558 | KMessageBox::information( this, text ); |
1559 | } | 1559 | } |
1560 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1560 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1561 | ++it; | 1561 | ++it; |
1562 | } | 1562 | } |
1563 | */ | 1563 | */ |
1564 | if (mEditorDialog) | 1564 | if (mEditorDialog) |
1565 | { | 1565 | { |
1566 | if (mEditorDialog->dirty()) | 1566 | if (mEditorDialog->dirty()) |
1567 | { | 1567 | { |
1568 | QString text = i18n( "Data has been changed externally. Unsaved " | 1568 | QString text = i18n( "Data has been changed externally. Unsaved " |
1569 | "changes will be lost." ); | 1569 | "changes will be lost." ); |
1570 | KMessageBox::information( this, text ); | 1570 | KMessageBox::information( this, text ); |
1571 | } | 1571 | } |
1572 | QString currentuid = mEditorDialog->addressee().uid(); | 1572 | QString currentuid = mEditorDialog->addressee().uid(); |
1573 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1573 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1574 | } | 1574 | } |
1575 | mViewManager->refreshView(); | 1575 | mViewManager->refreshView(); |
1576 | // mDetails->refreshView(); | 1576 | // mDetails->refreshView(); |
1577 | 1577 | ||
1578 | 1578 | ||
1579 | } | 1579 | } |
1580 | 1580 | ||
1581 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1581 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1582 | const char *name ) | 1582 | const char *name ) |
1583 | { | 1583 | { |
1584 | 1584 | ||
1585 | if ( mEditorDialog == 0 ) { | 1585 | if ( mEditorDialog == 0 ) { |
1586 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1586 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1587 | name ? name : "editorDialog" ); | 1587 | name ? name : "editorDialog" ); |
1588 | 1588 | ||
1589 | 1589 | ||
1590 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1590 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1591 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1591 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1592 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1592 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1593 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1593 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1594 | } | 1594 | } |
1595 | 1595 | ||
1596 | return mEditorDialog; | 1596 | return mEditorDialog; |
1597 | } | 1597 | } |
1598 | 1598 | ||
1599 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1599 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1600 | { | 1600 | { |
1601 | //mEditorDict.remove( uid ); | 1601 | //mEditorDict.remove( uid ); |
1602 | } | 1602 | } |
1603 | 1603 | ||
1604 | void KABCore::initGUI() | 1604 | void KABCore::initGUI() |
1605 | { | 1605 | { |
1606 | #ifndef KAB_EMBEDDED | 1606 | #ifndef KAB_EMBEDDED |
1607 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1607 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1608 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1608 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1609 | 1609 | ||
1610 | mExtensionBarSplitter = new QSplitter( this ); | 1610 | mExtensionBarSplitter = new QSplitter( this ); |
1611 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1611 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1612 | 1612 | ||
1613 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1613 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1614 | 1614 | ||
1615 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1615 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1616 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1616 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1617 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1617 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1618 | SLOT( incrementalSearch( const QString& ) ) ); | 1618 | SLOT( incrementalSearch( const QString& ) ) ); |
1619 | 1619 | ||
1620 | mViewManager = new ViewManager( this, viewSpace ); | 1620 | mViewManager = new ViewManager( this, viewSpace ); |
1621 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1621 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1622 | 1622 | ||
1623 | mDetails = new ViewContainer( mDetailsSplitter ); | 1623 | mDetails = new ViewContainer( mDetailsSplitter ); |
1624 | 1624 | ||
1625 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1625 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1626 | 1626 | ||
1627 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1627 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1628 | 1628 | ||
1629 | topLayout->addWidget( mExtensionBarSplitter ); | 1629 | topLayout->addWidget( mExtensionBarSplitter ); |
1630 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1630 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1631 | topLayout->addWidget( mJumpButtonBar ); | 1631 | topLayout->addWidget( mJumpButtonBar ); |
1632 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1632 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1633 | 1633 | ||
1634 | mXXPortManager = new XXPortManager( this, this ); | 1634 | mXXPortManager = new XXPortManager( this, this ); |
1635 | 1635 | ||
1636 | #else //KAB_EMBEDDED | 1636 | #else //KAB_EMBEDDED |
1637 | //US initialize viewMenu before settingup viewmanager. | 1637 | //US initialize viewMenu before settingup viewmanager. |
1638 | // Viewmanager needs this menu to plugin submenues. | 1638 | // Viewmanager needs this menu to plugin submenues. |
1639 | viewMenu = new QPopupMenu( this ); | 1639 | viewMenu = new QPopupMenu( this ); |
1640 | settingsMenu = new QPopupMenu( this ); | 1640 | settingsMenu = new QPopupMenu( this ); |
1641 | //filterMenu = new QPopupMenu( this ); | 1641 | //filterMenu = new QPopupMenu( this ); |
1642 | ImportMenu = new QPopupMenu( this ); | 1642 | ImportMenu = new QPopupMenu( this ); |
1643 | ExportMenu = new QPopupMenu( this ); | 1643 | ExportMenu = new QPopupMenu( this ); |
1644 | syncMenu = new QPopupMenu( this ); | 1644 | syncMenu = new QPopupMenu( this ); |
1645 | changeMenu= new QPopupMenu( this ); | 1645 | changeMenu= new QPopupMenu( this ); |
1646 | 1646 | ||
1647 | //US since we have no splitter for the embedded system, setup | 1647 | //US since we have no splitter for the embedded system, setup |
1648 | // a layout with two frames. One left and one right. | 1648 | // a layout with two frames. One left and one right. |
1649 | 1649 | ||
1650 | QBoxLayout *topLayout; | 1650 | QBoxLayout *topLayout; |
1651 | 1651 | ||
1652 | // = new QHBoxLayout( this ); | 1652 | // = new QHBoxLayout( this ); |
1653 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1653 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1654 | 1654 | ||
1655 | // QWidget *mainBox = new QWidget( this ); | 1655 | // QWidget *mainBox = new QWidget( this ); |
1656 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1656 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1657 | 1657 | ||
1658 | #ifdef DESKTOP_VERSION | 1658 | #ifdef DESKTOP_VERSION |
1659 | topLayout = new QHBoxLayout( this ); | 1659 | topLayout = new QHBoxLayout( this ); |
1660 | 1660 | ||
1661 | 1661 | ||
1662 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1662 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1663 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1663 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1664 | 1664 | ||
1665 | topLayout->addWidget(mMiniSplitter ); | 1665 | topLayout->addWidget(mMiniSplitter ); |
1666 | 1666 | ||
1667 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1667 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1668 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1668 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1669 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1669 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1670 | mDetails = new ViewContainer( mMiniSplitter ); | 1670 | mDetails = new ViewContainer( mMiniSplitter ); |
1671 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1671 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1672 | #else | 1672 | #else |
1673 | if ( QApplication::desktop()->width() > 480 ) { | 1673 | if ( QApplication::desktop()->width() > 480 ) { |
1674 | topLayout = new QHBoxLayout( this ); | 1674 | topLayout = new QHBoxLayout( this ); |
1675 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1675 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1676 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1676 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1677 | } else { | 1677 | } else { |
1678 | 1678 | ||
1679 | topLayout = new QHBoxLayout( this ); | 1679 | topLayout = new QHBoxLayout( this ); |
1680 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1680 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1681 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1681 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1682 | } | 1682 | } |
1683 | 1683 | ||
1684 | topLayout->addWidget(mMiniSplitter ); | 1684 | topLayout->addWidget(mMiniSplitter ); |
1685 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1685 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1686 | mDetails = new ViewContainer( mMiniSplitter ); | 1686 | mDetails = new ViewContainer( mMiniSplitter ); |
1687 | 1687 | ||
1688 | 1688 | ||
1689 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1689 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1690 | #endif | 1690 | #endif |
1691 | //eh->hide(); | 1691 | //eh->hide(); |
1692 | // topLayout->addWidget(mExtensionManager ); | 1692 | // topLayout->addWidget(mExtensionManager ); |
1693 | 1693 | ||
1694 | 1694 | ||
1695 | /*US | 1695 | /*US |
1696 | #ifndef KAB_NOSPLITTER | 1696 | #ifndef KAB_NOSPLITTER |
1697 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1697 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1698 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1698 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1699 | topLayout->setSpacing( 10 ); | 1699 | topLayout->setSpacing( 10 ); |
1700 | 1700 | ||
1701 | mDetailsSplitter = new QSplitter( this ); | 1701 | mDetailsSplitter = new QSplitter( this ); |
1702 | 1702 | ||
1703 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1703 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1704 | 1704 | ||
1705 | mViewManager = new ViewManager( this, viewSpace ); | 1705 | mViewManager = new ViewManager( this, viewSpace ); |
1706 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1706 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1707 | 1707 | ||
1708 | mDetails = new ViewContainer( mDetailsSplitter ); | 1708 | mDetails = new ViewContainer( mDetailsSplitter ); |
1709 | 1709 | ||
1710 | topLayout->addWidget( mDetailsSplitter ); | 1710 | topLayout->addWidget( mDetailsSplitter ); |
1711 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1711 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1712 | #else //KAB_NOSPLITTER | 1712 | #else //KAB_NOSPLITTER |
1713 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1713 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1714 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1714 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1715 | topLayout->setSpacing( 10 ); | 1715 | topLayout->setSpacing( 10 ); |
1716 | 1716 | ||
1717 | // mDetailsSplitter = new QSplitter( this ); | 1717 | // mDetailsSplitter = new QSplitter( this ); |
1718 | 1718 | ||
1719 | QVBox *viewSpace = new QVBox( this ); | 1719 | QVBox *viewSpace = new QVBox( this ); |
1720 | 1720 | ||
1721 | mViewManager = new ViewManager( this, viewSpace ); | 1721 | mViewManager = new ViewManager( this, viewSpace ); |
1722 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1722 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1723 | 1723 | ||
1724 | mDetails = new ViewContainer( this ); | 1724 | mDetails = new ViewContainer( this ); |
1725 | 1725 | ||
1726 | topLayout->addWidget( viewSpace ); | 1726 | topLayout->addWidget( viewSpace ); |
1727 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1727 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1728 | topLayout->addWidget( mDetails ); | 1728 | topLayout->addWidget( mDetails ); |
1729 | #endif //KAB_NOSPLITTER | 1729 | #endif //KAB_NOSPLITTER |
1730 | */ | 1730 | */ |
1731 | 1731 | ||
1732 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1732 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1733 | syncManager->setBlockSave(false); | 1733 | syncManager->setBlockSave(false); |
1734 | 1734 | ||
1735 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1735 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1736 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1736 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1737 | syncManager->setDefaultFileName( sentSyncFile()); | 1737 | syncManager->setDefaultFileName( sentSyncFile()); |
1738 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1738 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1739 | 1739 | ||
1740 | #endif //KAB_EMBEDDED | 1740 | #endif //KAB_EMBEDDED |
1741 | initActions(); | 1741 | initActions(); |
1742 | 1742 | ||
1743 | #ifdef KAB_EMBEDDED | 1743 | #ifdef KAB_EMBEDDED |
1744 | addActionsManually(); | 1744 | addActionsManually(); |
1745 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1745 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1746 | mXXPortManager = new XXPortManager( this, this ); | 1746 | mXXPortManager = new XXPortManager( this, this ); |
1747 | 1747 | ||
1748 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1748 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1749 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1749 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1750 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1750 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1751 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1751 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1752 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1752 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1753 | // mIncSearchWidget->hide(); | 1753 | // mIncSearchWidget->hide(); |
1754 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1754 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1755 | SLOT( incrementalSearch( const QString& ) ) ); | 1755 | SLOT( incrementalSearch( const QString& ) ) ); |
1756 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1756 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1757 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1757 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1758 | 1758 | ||
1759 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1759 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1760 | 1760 | ||
1761 | topLayout->addWidget( mJumpButtonBar ); | 1761 | topLayout->addWidget( mJumpButtonBar ); |
1762 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1762 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1763 | 1763 | ||
1764 | // mMainWindow->getIconToolBar()->raise(); | 1764 | // mMainWindow->getIconToolBar()->raise(); |
1765 | 1765 | ||
1766 | #endif //KAB_EMBEDDED | 1766 | #endif //KAB_EMBEDDED |
1767 | 1767 | ||
1768 | } | 1768 | } |
1769 | void KABCore::initActions() | 1769 | void KABCore::initActions() |
1770 | { | 1770 | { |
1771 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1771 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1772 | 1772 | ||
1773 | #ifndef KAB_EMBEDDED | 1773 | #ifndef KAB_EMBEDDED |
1774 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1774 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1775 | SLOT( clipboardDataChanged() ) ); | 1775 | SLOT( clipboardDataChanged() ) ); |
1776 | #endif //KAB_EMBEDDED | 1776 | #endif //KAB_EMBEDDED |
1777 | 1777 | ||
1778 | // file menu | 1778 | // file menu |
1779 | if ( mIsPart ) { | 1779 | if ( mIsPart ) { |
1780 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1780 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1781 | SLOT( sendMail() ), actionCollection(), | 1781 | SLOT( sendMail() ), actionCollection(), |
1782 | "kaddressbook_mail" ); | 1782 | "kaddressbook_mail" ); |
1783 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1783 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1784 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1784 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1785 | 1785 | ||
1786 | } else { | 1786 | } else { |
1787 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1787 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1788 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1788 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1789 | } | 1789 | } |
1790 | 1790 | ||
1791 | 1791 | ||
1792 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1792 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1793 | SLOT( save() ), actionCollection(), "file_sync" ); | 1793 | SLOT( save() ), actionCollection(), "file_sync" ); |
1794 | 1794 | ||
1795 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1795 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1796 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1796 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1797 | 1797 | ||
1798 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1798 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1799 | this, SLOT( mailVCard() ), | 1799 | this, SLOT( mailVCard() ), |
1800 | actionCollection(), "file_mail_vcard"); | 1800 | actionCollection(), "file_mail_vcard"); |
1801 | 1801 | ||
1802 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1802 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1803 | SLOT( export2phone() ), actionCollection(), | 1803 | SLOT( export2phone() ), actionCollection(), |
1804 | "kaddressbook_ex2phone" ); | 1804 | "kaddressbook_ex2phone" ); |
1805 | 1805 | ||
1806 | mActionBeamVCard = 0; | 1806 | mActionBeamVCard = 0; |
1807 | mActionBeam = 0; | 1807 | mActionBeam = 0; |
1808 | 1808 | ||
1809 | #ifndef DESKTOP_VERSION | 1809 | #ifndef DESKTOP_VERSION |
1810 | if ( Ir::supported() ) { | 1810 | if ( Ir::supported() ) { |
1811 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1811 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1812 | SLOT( beamVCard() ), actionCollection(), | 1812 | SLOT( beamVCard() ), actionCollection(), |
1813 | "kaddressbook_beam_vcard" ); | 1813 | "kaddressbook_beam_vcard" ); |
1814 | 1814 | ||
1815 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1815 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1816 | SLOT( beamMySelf() ), actionCollection(), | 1816 | SLOT( beamMySelf() ), actionCollection(), |
1817 | "kaddressbook_beam_myself" ); | 1817 | "kaddressbook_beam_myself" ); |
1818 | } | 1818 | } |
1819 | #endif | 1819 | #endif |
1820 | 1820 | ||
1821 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1821 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1822 | this, SLOT( editContact2() ), | 1822 | this, SLOT( editContact2() ), |
1823 | actionCollection(), "file_properties" ); | 1823 | actionCollection(), "file_properties" ); |
1824 | 1824 | ||
1825 | #ifdef KAB_EMBEDDED | 1825 | #ifdef KAB_EMBEDDED |
1826 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1826 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1827 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1827 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1828 | mMainWindow, SLOT( exit() ), | 1828 | mMainWindow, SLOT( exit() ), |
1829 | actionCollection(), "quit" ); | 1829 | actionCollection(), "quit" ); |
1830 | #endif //KAB_EMBEDDED | 1830 | #endif //KAB_EMBEDDED |
1831 | 1831 | ||
1832 | // edit menu | 1832 | // edit menu |
1833 | if ( mIsPart ) { | 1833 | if ( mIsPart ) { |
1834 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1834 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1835 | SLOT( copyContacts() ), actionCollection(), | 1835 | SLOT( copyContacts() ), actionCollection(), |
1836 | "kaddressbook_copy" ); | 1836 | "kaddressbook_copy" ); |
1837 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1837 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1838 | SLOT( cutContacts() ), actionCollection(), | 1838 | SLOT( cutContacts() ), actionCollection(), |
1839 | "kaddressbook_cut" ); | 1839 | "kaddressbook_cut" ); |
1840 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1840 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1841 | SLOT( pasteContacts() ), actionCollection(), | 1841 | SLOT( pasteContacts() ), actionCollection(), |
1842 | "kaddressbook_paste" ); | 1842 | "kaddressbook_paste" ); |
1843 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1843 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1844 | SLOT( selectAllContacts() ), actionCollection(), | 1844 | SLOT( selectAllContacts() ), actionCollection(), |
1845 | "kaddressbook_select_all" ); | 1845 | "kaddressbook_select_all" ); |
1846 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1846 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1847 | SLOT( undo() ), actionCollection(), | 1847 | SLOT( undo() ), actionCollection(), |
1848 | "kaddressbook_undo" ); | 1848 | "kaddressbook_undo" ); |
1849 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1849 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1850 | this, SLOT( redo() ), actionCollection(), | 1850 | this, SLOT( redo() ), actionCollection(), |
1851 | "kaddressbook_redo" ); | 1851 | "kaddressbook_redo" ); |
1852 | } else { | 1852 | } else { |
1853 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1853 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1854 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1854 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1855 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1855 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1856 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1856 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1857 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1857 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1858 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1858 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1859 | } | 1859 | } |
1860 | 1860 | ||
1861 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1861 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1862 | Key_Delete, this, SLOT( deleteContacts() ), | 1862 | Key_Delete, this, SLOT( deleteContacts() ), |
1863 | actionCollection(), "edit_delete" ); | 1863 | actionCollection(), "edit_delete" ); |
1864 | 1864 | ||
1865 | mActionUndo->setEnabled( false ); | 1865 | mActionUndo->setEnabled( false ); |
1866 | mActionRedo->setEnabled( false ); | 1866 | mActionRedo->setEnabled( false ); |
1867 | 1867 | ||
1868 | // settings menu | 1868 | // settings menu |
1869 | #ifdef KAB_EMBEDDED | 1869 | #ifdef KAB_EMBEDDED |
1870 | //US special menuentry to configure the addressbook resources. On KDE | 1870 | //US special menuentry to configure the addressbook resources. On KDE |
1871 | // you do that through the control center !!! | 1871 | // you do that through the control center !!! |
1872 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1872 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1873 | SLOT( configureResources() ), actionCollection(), | 1873 | SLOT( configureResources() ), actionCollection(), |
1874 | "kaddressbook_configure_resources" ); | 1874 | "kaddressbook_configure_resources" ); |
1875 | #endif //KAB_EMBEDDED | 1875 | #endif //KAB_EMBEDDED |
1876 | 1876 | ||
1877 | if ( mIsPart ) { | 1877 | if ( mIsPart ) { |
1878 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1878 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1879 | SLOT( openConfigDialog() ), actionCollection(), | 1879 | SLOT( openConfigDialog() ), actionCollection(), |
1880 | "kaddressbook_configure" ); | 1880 | "kaddressbook_configure" ); |
1881 | 1881 | ||
1882 | //US not implemented yet | 1882 | //US not implemented yet |
1883 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1883 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1884 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1884 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1885 | // "kaddressbook_configure_shortcuts" ); | 1885 | // "kaddressbook_configure_shortcuts" ); |
1886 | #ifdef KAB_EMBEDDED | 1886 | #ifdef KAB_EMBEDDED |
1887 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1887 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1888 | mActionConfigureToolbars->setEnabled( false ); | 1888 | mActionConfigureToolbars->setEnabled( false ); |
1889 | #endif //KAB_EMBEDDED | 1889 | #endif //KAB_EMBEDDED |
1890 | 1890 | ||
1891 | } else { | 1891 | } else { |
1892 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1892 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1893 | 1893 | ||
1894 | //US not implemented yet | 1894 | //US not implemented yet |
1895 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1895 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1896 | } | 1896 | } |
1897 | 1897 | ||
1898 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1898 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1899 | actionCollection(), "options_show_jump_bar" ); | 1899 | actionCollection(), "options_show_jump_bar" ); |
1900 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1900 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1901 | 1901 | ||
1902 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1902 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1903 | actionCollection(), "options_show_details" ); | 1903 | actionCollection(), "options_show_details" ); |
1904 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1904 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1905 | 1905 | ||
1906 | 1906 | ||
1907 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 1907 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
1908 | SLOT( toggleBeamReceive() ), actionCollection(), | 1908 | SLOT( toggleBeamReceive() ), actionCollection(), |
1909 | "kaddressbook_beam_rec" ); | 1909 | "kaddressbook_beam_rec" ); |
1910 | 1910 | ||
1911 | 1911 | ||
1912 | // misc | 1912 | // misc |
1913 | // only enable LDAP lookup if we can handle the protocol | 1913 | // only enable LDAP lookup if we can handle the protocol |
1914 | #ifndef KAB_EMBEDDED | 1914 | #ifndef KAB_EMBEDDED |
1915 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1915 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1916 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1916 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1917 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1917 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1918 | "ldap_lookup" ); | 1918 | "ldap_lookup" ); |
1919 | } | 1919 | } |
1920 | #else //KAB_EMBEDDED | 1920 | #else //KAB_EMBEDDED |
1921 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1921 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1922 | #endif //KAB_EMBEDDED | 1922 | #endif //KAB_EMBEDDED |
1923 | 1923 | ||
1924 | 1924 | ||
1925 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1925 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1926 | SLOT( setWhoAmI() ), actionCollection(), | 1926 | SLOT( setWhoAmI() ), actionCollection(), |
1927 | "set_personal" ); | 1927 | "set_personal" ); |
1928 | 1928 | ||
1929 | 1929 | ||
1930 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1930 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1931 | SLOT( setCategories() ), actionCollection(), | 1931 | SLOT( setCategories() ), actionCollection(), |
1932 | "edit_set_categories" ); | 1932 | "edit_set_categories" ); |
1933 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, | 1933 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, |
1934 | SLOT( editCategories() ), actionCollection(), | 1934 | SLOT( editCategories() ), actionCollection(), |
1935 | "edit__categories" ); | 1935 | "edit__categories" ); |
1936 | 1936 | ||
1937 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1937 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1938 | SLOT( removeVoice() ), actionCollection(), | 1938 | SLOT( removeVoice() ), actionCollection(), |
1939 | "remove_voice" ); | 1939 | "remove_voice" ); |
1940 | 1940 | ||
1941 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 1941 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
1942 | SLOT( manageCategories() ), actionCollection(), | 1942 | SLOT( manageCategories() ), actionCollection(), |
1943 | "remove_voice" ); | 1943 | "remove_voice" ); |
1944 | 1944 | ||
1945 | 1945 | ||
1946 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1946 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1947 | SLOT( importFromOL() ), actionCollection(), | 1947 | SLOT( importFromOL() ), actionCollection(), |
1948 | "import_OL" ); | 1948 | "import_OL" ); |
1949 | #ifdef KAB_EMBEDDED | 1949 | #ifdef KAB_EMBEDDED |
1950 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1950 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1951 | this, SLOT( showLicence() ), actionCollection(), | 1951 | this, SLOT( showLicence() ), actionCollection(), |
1952 | "licence_about_data" ); | 1952 | "licence_about_data" ); |
1953 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1953 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1954 | this, SLOT( faq() ), actionCollection(), | 1954 | this, SLOT( faq() ), actionCollection(), |
1955 | "faq_about_data" ); | 1955 | "faq_about_data" ); |
1956 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 1956 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
1957 | this, SLOT( whatsnew() ), actionCollection(), | 1957 | this, SLOT( whatsnew() ), actionCollection(), |
1958 | "wn" ); | 1958 | "wn" ); |
1959 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 1959 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
1960 | this, SLOT( synchowto() ), actionCollection(), | 1960 | this, SLOT( synchowto() ), actionCollection(), |
1961 | "sync" ); | 1961 | "sync" ); |
1962 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 1962 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
1963 | this, SLOT( kdesynchowto() ), actionCollection(), | 1963 | this, SLOT( kdesynchowto() ), actionCollection(), |
1964 | "kdesync" ); | 1964 | "kdesync" ); |
1965 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 1965 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
1966 | this, SLOT( multisynchowto() ), actionCollection(), | 1966 | this, SLOT( multisynchowto() ), actionCollection(), |
1967 | "multisync" ); | 1967 | "multisync" ); |
1968 | 1968 | ||
1969 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1969 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1970 | this, SLOT( createAboutData() ), actionCollection(), | 1970 | this, SLOT( createAboutData() ), actionCollection(), |
1971 | "kaddressbook_about_data" ); | 1971 | "kaddressbook_about_data" ); |
1972 | #endif //KAB_EMBEDDED | 1972 | #endif //KAB_EMBEDDED |
1973 | 1973 | ||
1974 | clipboardDataChanged(); | 1974 | clipboardDataChanged(); |
1975 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1975 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1976 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1976 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1977 | } | 1977 | } |
1978 | 1978 | ||
1979 | //US we need this function, to plug all actions into the correct menues. | 1979 | //US we need this function, to plug all actions into the correct menues. |
1980 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1980 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1981 | void KABCore::addActionsManually() | 1981 | void KABCore::addActionsManually() |
1982 | { | 1982 | { |
1983 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1983 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1984 | 1984 | ||
1985 | #ifdef KAB_EMBEDDED | 1985 | #ifdef KAB_EMBEDDED |
1986 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1986 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1987 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1987 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1988 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1988 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1989 | 1989 | ||
1990 | KToolBar* tb = mMainWindow->toolBar(); | 1990 | KToolBar* tb = mMainWindow->toolBar(); |
1991 | 1991 | ||
1992 | #ifndef DESKTOP_VERSION | 1992 | #ifndef DESKTOP_VERSION |
1993 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 1993 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
1994 | #endif | 1994 | #endif |
1995 | QMenuBar* mb = mMainWindow->menuBar(); | 1995 | QMenuBar* mb = mMainWindow->menuBar(); |
1996 | 1996 | ||
1997 | //US setup menubar. | 1997 | //US setup menubar. |
1998 | //Disable the following block if you do not want to have a menubar. | 1998 | //Disable the following block if you do not want to have a menubar. |
1999 | mb->insertItem( i18n("&File"), fileMenu ); | 1999 | mb->insertItem( i18n("&File"), fileMenu ); |
2000 | mb->insertItem( i18n("&Edit"), editMenu ); | 2000 | mb->insertItem( i18n("&Edit"), editMenu ); |
2001 | mb->insertItem( i18n("&View"), viewMenu ); | 2001 | mb->insertItem( i18n("&View"), viewMenu ); |
2002 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2002 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2003 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2003 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2004 | mb->insertItem( i18n("&Change selected"), changeMenu ); | 2004 | mb->insertItem( i18n("&Change selected"), changeMenu ); |
2005 | mb->insertItem( i18n("&Help"), helpMenu ); | 2005 | mb->insertItem( i18n("&Help"), helpMenu ); |
2006 | mIncSearchWidget = new IncSearchWidget( tb ); | 2006 | mIncSearchWidget = new IncSearchWidget( tb ); |
2007 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2007 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2008 | #ifndef DESKTOP_VERSION | 2008 | #ifndef DESKTOP_VERSION |
2009 | } else { | 2009 | } else { |
2010 | //US setup toolbar | 2010 | //US setup toolbar |
2011 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2011 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2012 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2012 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2013 | menuBarTB->insertItem( "ME", popupBarTB); | 2013 | menuBarTB->insertItem( "ME", popupBarTB); |
2014 | tb->insertWidget(-1, 0, menuBarTB); | 2014 | tb->insertWidget(-1, 0, menuBarTB); |
2015 | mIncSearchWidget = new IncSearchWidget( tb ); | 2015 | mIncSearchWidget = new IncSearchWidget( tb ); |
2016 | 2016 | ||
2017 | tb->enableMoving(false); | 2017 | tb->enableMoving(false); |
2018 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2018 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2019 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2019 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2020 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2020 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2021 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2021 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2022 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2022 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2023 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2023 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2024 | popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2024 | popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2025 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2025 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2026 | if (QApplication::desktop()->width() > 320 ) { | 2026 | if (QApplication::desktop()->width() > 320 ) { |
2027 | // mViewManager->getFilterAction()->plug ( tb); | 2027 | // mViewManager->getFilterAction()->plug ( tb); |
2028 | } | 2028 | } |
2029 | } | 2029 | } |
2030 | #endif | 2030 | #endif |
2031 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2031 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2032 | 2032 | ||
2033 | 2033 | ||
2034 | 2034 | ||
2035 | //US Now connect the actions with the menue entries. | 2035 | //US Now connect the actions with the menue entries. |
2036 | mActionPrint->plug( fileMenu ); | 2036 | mActionPrint->plug( fileMenu ); |
2037 | mActionMail->plug( fileMenu ); | 2037 | mActionMail->plug( fileMenu ); |
2038 | fileMenu->insertSeparator(); | 2038 | fileMenu->insertSeparator(); |
2039 | 2039 | ||
2040 | mActionNewContact->plug( fileMenu ); | 2040 | mActionNewContact->plug( fileMenu ); |
2041 | mActionNewContact->plug( tb ); | 2041 | mActionNewContact->plug( tb ); |
2042 | 2042 | ||
2043 | mActionEditAddressee->plug( fileMenu ); | 2043 | mActionEditAddressee->plug( fileMenu ); |
2044 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2044 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2045 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2045 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2046 | mActionEditAddressee->plug( tb ); | 2046 | mActionEditAddressee->plug( tb ); |
2047 | 2047 | ||
2048 | fileMenu->insertSeparator(); | 2048 | fileMenu->insertSeparator(); |
2049 | mActionSave->plug( fileMenu ); | 2049 | mActionSave->plug( fileMenu ); |
2050 | fileMenu->insertItem( "&Import", ImportMenu ); | 2050 | fileMenu->insertItem( "&Import", ImportMenu ); |
2051 | fileMenu->insertItem( "&Export", ExportMenu ); | 2051 | fileMenu->insertItem( "&Export", ExportMenu ); |
2052 | fileMenu->insertSeparator(); | 2052 | fileMenu->insertSeparator(); |
2053 | mActionMailVCard->plug( fileMenu ); | 2053 | mActionMailVCard->plug( fileMenu ); |
2054 | #ifndef DESKTOP_VERSION | 2054 | #ifndef DESKTOP_VERSION |
2055 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 2055 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
2056 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 2056 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
2057 | #endif | 2057 | #endif |
2058 | fileMenu->insertSeparator(); | 2058 | fileMenu->insertSeparator(); |
2059 | mActionQuit->plug( fileMenu ); | 2059 | mActionQuit->plug( fileMenu ); |
2060 | #ifdef _WIN32_ | 2060 | #ifdef _WIN32_ |
2061 | mActionImportOL->plug( ImportMenu ); | 2061 | mActionImportOL->plug( ImportMenu ); |
2062 | #endif | 2062 | #endif |
2063 | // edit menu | 2063 | // edit menu |
2064 | mActionUndo->plug( editMenu ); | 2064 | mActionUndo->plug( editMenu ); |
2065 | mActionRedo->plug( editMenu ); | 2065 | mActionRedo->plug( editMenu ); |
2066 | editMenu->insertSeparator(); | 2066 | editMenu->insertSeparator(); |
2067 | mActionCut->plug( editMenu ); | 2067 | mActionCut->plug( editMenu ); |
2068 | mActionCopy->plug( editMenu ); | 2068 | mActionCopy->plug( editMenu ); |
2069 | mActionPaste->plug( editMenu ); | 2069 | mActionPaste->plug( editMenu ); |
2070 | mActionDelete->plug( editMenu ); | 2070 | mActionDelete->plug( editMenu ); |
2071 | editMenu->insertSeparator(); | 2071 | editMenu->insertSeparator(); |
2072 | mActionSelectAll->plug( editMenu ); | 2072 | mActionSelectAll->plug( editMenu ); |
2073 | 2073 | ||
2074 | mActionRemoveVoice->plug( changeMenu ); | 2074 | mActionRemoveVoice->plug( changeMenu ); |
2075 | // settings menu | 2075 | // settings menu |
2076 | //US special menuentry to configure the addressbook resources. On KDE | 2076 | //US special menuentry to configure the addressbook resources. On KDE |
2077 | // you do that through the control center !!! | 2077 | // you do that through the control center !!! |
2078 | mActionConfigResources->plug( settingsMenu ); | 2078 | mActionConfigResources->plug( settingsMenu ); |
2079 | settingsMenu->insertSeparator(); | 2079 | settingsMenu->insertSeparator(); |
2080 | 2080 | ||
2081 | mActionConfigKAddressbook->plug( settingsMenu ); | 2081 | mActionConfigKAddressbook->plug( settingsMenu ); |
2082 | 2082 | ||
2083 | if ( mIsPart ) { | 2083 | if ( mIsPart ) { |
2084 | //US not implemented yet | 2084 | //US not implemented yet |
2085 | //mActionConfigShortcuts->plug( settingsMenu ); | 2085 | //mActionConfigShortcuts->plug( settingsMenu ); |
2086 | //mActionConfigureToolbars->plug( settingsMenu ); | 2086 | //mActionConfigureToolbars->plug( settingsMenu ); |
2087 | 2087 | ||
2088 | } else { | 2088 | } else { |
2089 | //US not implemented yet | 2089 | //US not implemented yet |
2090 | //mActionKeyBindings->plug( settingsMenu ); | 2090 | //mActionKeyBindings->plug( settingsMenu ); |
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | settingsMenu->insertSeparator(); | 2093 | settingsMenu->insertSeparator(); |
2094 | 2094 | ||
2095 | mActionJumpBar->plug( settingsMenu ); | 2095 | mActionJumpBar->plug( settingsMenu ); |
2096 | mActionDetails->plug( settingsMenu ); | 2096 | mActionDetails->plug( settingsMenu ); |
2097 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2097 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2098 | mActionDetails->plug( tb ); | 2098 | mActionDetails->plug( tb ); |
2099 | settingsMenu->insertSeparator(); | 2099 | settingsMenu->insertSeparator(); |
2100 | mActionBR->plug(settingsMenu ); | 2100 | mActionBR->plug(settingsMenu ); |
2101 | settingsMenu->insertSeparator(); | 2101 | settingsMenu->insertSeparator(); |
2102 | 2102 | ||
2103 | mActionWhoAmI->plug( settingsMenu ); | 2103 | mActionWhoAmI->plug( settingsMenu ); |
2104 | mActionEditCategories->plug( settingsMenu ); | 2104 | mActionEditCategories->plug( settingsMenu ); |
2105 | mActionCategories->plug( settingsMenu ); | 2105 | mActionCategories->plug( settingsMenu ); |
2106 | mActionManageCategories->plug( settingsMenu ); | 2106 | mActionManageCategories->plug( settingsMenu ); |
2107 | 2107 | ||
2108 | 2108 | ||
2109 | mActionWN->plug( helpMenu ); | 2109 | mActionWN->plug( helpMenu ); |
2110 | mActionSyncHowto->plug( helpMenu ); | 2110 | mActionSyncHowto->plug( helpMenu ); |
2111 | mActionKdeSyncHowto->plug( helpMenu ); | 2111 | mActionKdeSyncHowto->plug( helpMenu ); |
2112 | mActionMultiSyncHowto->plug( helpMenu ); | 2112 | mActionMultiSyncHowto->plug( helpMenu ); |
2113 | mActionFaq->plug( helpMenu ); | 2113 | mActionFaq->plug( helpMenu ); |
2114 | mActionLicence->plug( helpMenu ); | 2114 | mActionLicence->plug( helpMenu ); |
2115 | mActionAboutKAddressbook->plug( helpMenu ); | 2115 | mActionAboutKAddressbook->plug( helpMenu ); |
2116 | 2116 | ||
2117 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2117 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2118 | 2118 | ||
2119 | mActionSave->plug( tb ); | 2119 | mActionSave->plug( tb ); |
2120 | mViewManager->getFilterAction()->plug ( tb); | 2120 | mViewManager->getFilterAction()->plug ( tb); |
2121 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2121 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2122 | mActionUndo->plug( tb ); | 2122 | mActionUndo->plug( tb ); |
2123 | mActionDelete->plug( tb ); | 2123 | mActionDelete->plug( tb ); |
2124 | mActionRedo->plug( tb ); | 2124 | mActionRedo->plug( tb ); |
2125 | } | 2125 | } |
2126 | } else { | 2126 | } else { |
2127 | mActionSave->plug( tb ); | 2127 | mActionSave->plug( tb ); |
2128 | tb->enableMoving(false); | 2128 | tb->enableMoving(false); |
2129 | } | 2129 | } |
2130 | //mActionQuit->plug ( tb ); | 2130 | //mActionQuit->plug ( tb ); |
2131 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2131 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2132 | 2132 | ||
2133 | //US link the searchwidget first to this. | 2133 | //US link the searchwidget first to this. |
2134 | // The real linkage to the toolbar happens later. | 2134 | // The real linkage to the toolbar happens later. |
2135 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2135 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2136 | //US tb->insertItem( mIncSearchWidget ); | 2136 | //US tb->insertItem( mIncSearchWidget ); |
2137 | /*US | 2137 | /*US |
2138 | mIncSearchWidget = new IncSearchWidget( tb ); | 2138 | mIncSearchWidget = new IncSearchWidget( tb ); |
2139 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2139 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2140 | SLOT( incrementalSearch( const QString& ) ) ); | 2140 | SLOT( incrementalSearch( const QString& ) ) ); |
2141 | 2141 | ||
2142 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2142 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2143 | 2143 | ||
2144 | //US topLayout->addWidget( mJumpButtonBar ); | 2144 | //US topLayout->addWidget( mJumpButtonBar ); |
2145 | this->layout()->add( mJumpButtonBar ); | 2145 | this->layout()->add( mJumpButtonBar ); |
2146 | */ | 2146 | */ |
2147 | 2147 | ||
2148 | #endif //KAB_EMBEDDED | 2148 | #endif //KAB_EMBEDDED |
2149 | 2149 | ||
2150 | mActionExport2phone->plug( ExportMenu ); | 2150 | mActionExport2phone->plug( ExportMenu ); |
2151 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2151 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2152 | syncManager->fillSyncMenu(); | 2152 | syncManager->fillSyncMenu(); |
2153 | 2153 | ||
2154 | } | 2154 | } |
2155 | void KABCore::showLicence() | 2155 | void KABCore::showLicence() |
2156 | { | 2156 | { |
2157 | KApplication::showLicence(); | 2157 | KApplication::showLicence(); |
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | void KABCore::manageCategories( ) | 2160 | void KABCore::manageCategories( ) |
2161 | { | 2161 | { |
2162 | KABCatPrefs* cp = new KABCatPrefs(); | 2162 | KABCatPrefs* cp = new KABCatPrefs(); |
2163 | cp->show(); | 2163 | cp->show(); |
2164 | int w =cp->sizeHint().width() ; | 2164 | int w =cp->sizeHint().width() ; |
2165 | int h = cp->sizeHint().height() ; | 2165 | int h = cp->sizeHint().height() ; |
2166 | int dw = QApplication::desktop()->width(); | 2166 | int dw = QApplication::desktop()->width(); |
2167 | int dh = QApplication::desktop()->height(); | 2167 | int dh = QApplication::desktop()->height(); |
2168 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2168 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2169 | if ( !cp->exec() ) { | 2169 | if ( !cp->exec() ) { |
2170 | delete cp; | 2170 | delete cp; |
2171 | return; | 2171 | return; |
2172 | } | 2172 | } |
2173 | int count = 0; | 2173 | int count = 0; |
2174 | message( i18n("Please wait, processing categories...")); | 2174 | message( i18n("Please wait, processing categories...")); |
2175 | if ( cp->addCat() ) { | 2175 | if ( cp->addCat() ) { |
2176 | KABC::AddressBook::Iterator it; | 2176 | KABC::AddressBook::Iterator it; |
2177 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2177 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2178 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2178 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2179 | QStringList catIncList = (*it).categories(); | 2179 | QStringList catIncList = (*it).categories(); |
2180 | int i; | 2180 | int i; |
2181 | for( i = 0; i< catIncList.count(); ++i ) { | 2181 | for( i = 0; i< catIncList.count(); ++i ) { |
2182 | if ( !catList.contains (catIncList[i])) { | 2182 | if ( !catList.contains (catIncList[i])) { |
2183 | catList.append( catIncList[i] ); | 2183 | catList.append( catIncList[i] ); |
2184 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2184 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2185 | ++count; | 2185 | ++count; |
2186 | } | 2186 | } |
2187 | } | 2187 | } |
2188 | } | 2188 | } |
2189 | catList.sort(); | 2189 | catList.sort(); |
2190 | KABPrefs::instance()->mCustomCategories = catList; | 2190 | KABPrefs::instance()->mCustomCategories = catList; |
2191 | KABPrefs::instance()->writeConfig(); | 2191 | KABPrefs::instance()->writeConfig(); |
2192 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2192 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2193 | } else { | 2193 | } else { |
2194 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2194 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2195 | QStringList catIncList; | 2195 | QStringList catIncList; |
2196 | QStringList newCatList; | 2196 | QStringList newCatList; |
2197 | KABC::AddressBook::Iterator it; | 2197 | KABC::AddressBook::Iterator it; |
2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2199 | QStringList catIncList = (*it).categories(); | 2199 | QStringList catIncList = (*it).categories(); |
2200 | int i; | 2200 | int i; |
2201 | if ( catIncList.count() ) { | 2201 | if ( catIncList.count() ) { |
2202 | newCatList.clear(); | 2202 | newCatList.clear(); |
2203 | for( i = 0; i< catIncList.count(); ++i ) { | 2203 | for( i = 0; i< catIncList.count(); ++i ) { |
2204 | if ( catList.contains (catIncList[i])) { | 2204 | if ( catList.contains (catIncList[i])) { |
2205 | newCatList.append( catIncList[i] ); | 2205 | newCatList.append( catIncList[i] ); |
2206 | } | 2206 | } |
2207 | } | 2207 | } |
2208 | newCatList.sort(); | 2208 | newCatList.sort(); |
2209 | (*it).setCategories( newCatList ); | 2209 | (*it).setCategories( newCatList ); |
2210 | mAddressBook->insertAddressee( (*it) ); | 2210 | mAddressBook->insertAddressee( (*it) ); |
2211 | } | 2211 | } |
2212 | } | 2212 | } |
2213 | setModified( true ); | 2213 | setModified( true ); |
2214 | mViewManager->refreshView(); | 2214 | mViewManager->refreshView(); |
2215 | mDetails->refreshView(); | 2215 | mDetails->refreshView(); |
2216 | message( i18n("Removing categories done!")); | 2216 | message( i18n("Removing categories done!")); |
2217 | } | 2217 | } |
2218 | delete cp; | 2218 | delete cp; |
2219 | } | 2219 | } |
2220 | void KABCore::removeVoice() | 2220 | void KABCore::removeVoice() |
2221 | { | 2221 | { |
2222 | 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 ) | 2222 | 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 ) |
2223 | return; | 2223 | return; |
2224 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2224 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2225 | KABC::Addressee::List::Iterator it; | 2225 | KABC::Addressee::List::Iterator it; |
2226 | for ( it = list.begin(); it != list.end(); ++it ) { | 2226 | for ( it = list.begin(); it != list.end(); ++it ) { |
2227 | 2227 | ||
2228 | if ( (*it).removeVoice() ) | 2228 | if ( (*it).removeVoice() ) |
2229 | contactModified((*it) ); | 2229 | contactModified((*it) ); |
2230 | } | 2230 | } |
2231 | } | 2231 | } |
2232 | 2232 | ||
2233 | 2233 | ||
2234 | 2234 | ||
2235 | void KABCore::clipboardDataChanged() | 2235 | void KABCore::clipboardDataChanged() |
2236 | { | 2236 | { |
2237 | 2237 | ||
2238 | if ( mReadWrite ) | 2238 | if ( mReadWrite ) |
2239 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2239 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2240 | 2240 | ||
2241 | } | 2241 | } |
2242 | 2242 | ||
2243 | void KABCore::updateActionMenu() | 2243 | void KABCore::updateActionMenu() |
2244 | { | 2244 | { |
2245 | UndoStack *undo = UndoStack::instance(); | 2245 | UndoStack *undo = UndoStack::instance(); |
2246 | RedoStack *redo = RedoStack::instance(); | 2246 | RedoStack *redo = RedoStack::instance(); |
2247 | 2247 | ||
2248 | if ( undo->isEmpty() ) | 2248 | if ( undo->isEmpty() ) |
2249 | mActionUndo->setText( i18n( "Undo" ) ); | 2249 | mActionUndo->setText( i18n( "Undo" ) ); |
2250 | else | 2250 | else |
2251 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2251 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2252 | 2252 | ||
2253 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2253 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2254 | 2254 | ||
2255 | if ( !redo->top() ) | 2255 | if ( !redo->top() ) |
2256 | mActionRedo->setText( i18n( "Redo" ) ); | 2256 | mActionRedo->setText( i18n( "Redo" ) ); |
2257 | else | 2257 | else |
2258 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2258 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2259 | 2259 | ||
2260 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2260 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | void KABCore::configureKeyBindings() | 2263 | void KABCore::configureKeyBindings() |
2264 | { | 2264 | { |
2265 | #ifndef KAB_EMBEDDED | 2265 | #ifndef KAB_EMBEDDED |
2266 | KKeyDialog::configure( actionCollection(), true ); | 2266 | KKeyDialog::configure( actionCollection(), true ); |
2267 | #else //KAB_EMBEDDED | 2267 | #else //KAB_EMBEDDED |
2268 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2268 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2269 | #endif //KAB_EMBEDDED | 2269 | #endif //KAB_EMBEDDED |
2270 | } | 2270 | } |
2271 | 2271 | ||
2272 | #ifdef KAB_EMBEDDED | 2272 | #ifdef KAB_EMBEDDED |
2273 | void KABCore::configureResources() | 2273 | void KABCore::configureResources() |
2274 | { | 2274 | { |
2275 | KRES::KCMKResources dlg( this, "" , 0 ); | 2275 | KRES::KCMKResources dlg( this, "" , 0 ); |
2276 | 2276 | ||
2277 | if ( !dlg.exec() ) | 2277 | if ( !dlg.exec() ) |
2278 | return; | 2278 | return; |
2279 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2279 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2280 | } | 2280 | } |
2281 | #endif //KAB_EMBEDDED | 2281 | #endif //KAB_EMBEDDED |
2282 | 2282 | ||
2283 | 2283 | ||
2284 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2284 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2285 | * for the attendees list of an event. | 2285 | * for the attendees list of an event. |
2286 | */ | 2286 | */ |
2287 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2287 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2288 | { | 2288 | { |
2289 | QStringList nameList; | 2289 | QStringList nameList; |
2290 | QStringList emailList; | 2290 | QStringList emailList; |
2291 | QStringList uidList; | 2291 | QStringList uidList; |
2292 | 2292 | ||
2293 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2293 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2294 | uint i=0; | 2294 | uint i=0; |
2295 | for (i=0; i < list.count(); i++) | 2295 | for (i=0; i < list.count(); i++) |
2296 | { | 2296 | { |
2297 | nameList.append(list[i].realName()); | 2297 | nameList.append(list[i].realName()); |
2298 | emailList.append(list[i].preferredEmail()); | 2298 | emailList.append(list[i].preferredEmail()); |
2299 | uidList.append(list[i].uid()); | 2299 | uidList.append(list[i].uid()); |
2300 | } | 2300 | } |
2301 | 2301 | ||
2302 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2302 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2303 | 2303 | ||
2304 | } | 2304 | } |
2305 | 2305 | ||
2306 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2306 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2307 | * to put them into the calendar. | 2307 | * to put them into the calendar. |
2308 | */ | 2308 | */ |
2309 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2309 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2310 | { | 2310 | { |
2311 | // qDebug("KABCore::requestForBirthdayList"); | 2311 | // qDebug("KABCore::requestForBirthdayList"); |
2312 | QStringList birthdayList; | 2312 | QStringList birthdayList; |
2313 | QStringList anniversaryList; | 2313 | QStringList anniversaryList; |
2314 | QStringList realNameList; | 2314 | QStringList realNameList; |
2315 | QStringList preferredEmailList; | 2315 | QStringList preferredEmailList; |
2316 | QStringList assembledNameList; | 2316 | QStringList assembledNameList; |
2317 | QStringList uidList; | 2317 | QStringList uidList; |
2318 | 2318 | ||
2319 | KABC::AddressBook::Iterator it; | 2319 | KABC::AddressBook::Iterator it; |
2320 | 2320 | ||
2321 | int count = 0; | 2321 | int count = 0; |
2322 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2322 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2323 | ++count; | 2323 | ++count; |
2324 | } | 2324 | } |
2325 | QProgressBar bar(count,0 ); | 2325 | QProgressBar bar(count,0 ); |
2326 | int w = 300; | 2326 | int w = 300; |
2327 | if ( QApplication::desktop()->width() < 320 ) | 2327 | if ( QApplication::desktop()->width() < 320 ) |
2328 | w = 220; | 2328 | w = 220; |
2329 | int h = bar.sizeHint().height() ; | 2329 | int h = bar.sizeHint().height() ; |
2330 | int dw = QApplication::desktop()->width(); | 2330 | int dw = QApplication::desktop()->width(); |
2331 | int dh = QApplication::desktop()->height(); | 2331 | int dh = QApplication::desktop()->height(); |
2332 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2332 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2333 | bar.show(); | 2333 | bar.show(); |
2334 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2334 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2335 | qApp->processEvents(); | 2335 | qApp->processEvents(); |
2336 | 2336 | ||
2337 | QDate bday; | 2337 | QDate bday; |
2338 | QString anni; | 2338 | QString anni; |
2339 | QString formattedbday; | 2339 | QString formattedbday; |
2340 | 2340 | ||
2341 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2341 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2342 | { | 2342 | { |
2343 | if ( ! bar.isVisible() ) | 2343 | if ( ! bar.isVisible() ) |
2344 | return; | 2344 | return; |
2345 | bar.setProgress( count++ ); | 2345 | bar.setProgress( count++ ); |
2346 | qApp->processEvents(); | 2346 | qApp->processEvents(); |
2347 | bday = (*it).birthday().date(); | 2347 | bday = (*it).birthday().date(); |
2348 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2348 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2349 | 2349 | ||
2350 | if ( bday.isValid() || !anni.isEmpty()) | 2350 | if ( bday.isValid() || !anni.isEmpty()) |
2351 | { | 2351 | { |
2352 | if (bday.isValid()) | 2352 | if (bday.isValid()) |
2353 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2353 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2354 | else | 2354 | else |
2355 | formattedbday = "NOTVALID"; | 2355 | formattedbday = "NOTVALID"; |
2356 | if (anni.isEmpty()) | 2356 | if (anni.isEmpty()) |
2357 | anni = "INVALID"; | 2357 | anni = "INVALID"; |
2358 | 2358 | ||
2359 | birthdayList.append(formattedbday); | 2359 | birthdayList.append(formattedbday); |
2360 | anniversaryList.append(anni); //should be ISODate | 2360 | anniversaryList.append(anni); //should be ISODate |
2361 | realNameList.append((*it).realName()); | 2361 | realNameList.append((*it).realName()); |
2362 | preferredEmailList.append((*it).preferredEmail()); | 2362 | preferredEmailList.append((*it).preferredEmail()); |
2363 | assembledNameList.append((*it).assembledName()); | 2363 | assembledNameList.append((*it).assembledName()); |
2364 | uidList.append((*it).uid()); | 2364 | uidList.append((*it).uid()); |
2365 | 2365 | ||
2366 | //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() ); | 2366 | //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() ); |
2367 | } | 2367 | } |
2368 | } | 2368 | } |
2369 | 2369 | ||
2370 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2370 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2371 | 2371 | ||
2372 | } | 2372 | } |
2373 | 2373 | ||
2374 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2374 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2375 | */ | 2375 | */ |
2376 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2376 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2377 | { | 2377 | { |
2378 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2378 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2379 | 2379 | ||
2380 | QString foundUid = QString::null; | 2380 | QString foundUid = QString::null; |
2381 | if ( ! uid.isEmpty() ) { | 2381 | if ( ! uid.isEmpty() ) { |
2382 | Addressee adrr = mAddressBook->findByUid( uid ); | 2382 | Addressee adrr = mAddressBook->findByUid( uid ); |
2383 | if ( !adrr.isEmpty() ) { | 2383 | if ( !adrr.isEmpty() ) { |
2384 | foundUid = uid; | 2384 | foundUid = uid; |
2385 | } | 2385 | } |
2386 | if ( email == "sendbacklist" ) { | 2386 | if ( email == "sendbacklist" ) { |
2387 | //qDebug("ssssssssssssssssssssssend "); | 2387 | //qDebug("ssssssssssssssssssssssend "); |
2388 | QStringList nameList; | 2388 | QStringList nameList; |
2389 | QStringList emailList; | 2389 | QStringList emailList; |
2390 | QStringList uidList; | 2390 | QStringList uidList; |
2391 | nameList.append(adrr.realName()); | 2391 | nameList.append(adrr.realName()); |
2392 | emailList = adrr.emails(); | 2392 | emailList = adrr.emails(); |
2393 | uidList.append( adrr.preferredEmail()); | 2393 | uidList.append( adrr.preferredEmail()); |
2394 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2394 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2395 | return; | 2395 | return; |
2396 | } | 2396 | } |
2397 | 2397 | ||
2398 | } | 2398 | } |
2399 | 2399 | ||
2400 | if ( email == "sendbacklist" ) | 2400 | if ( email == "sendbacklist" ) |
2401 | return; | 2401 | return; |
2402 | if (foundUid.isEmpty()) | 2402 | if (foundUid.isEmpty()) |
2403 | { | 2403 | { |
2404 | //find the uid of the person first | 2404 | //find the uid of the person first |
2405 | Addressee::List namelist; | 2405 | Addressee::List namelist; |
2406 | Addressee::List emaillist; | 2406 | Addressee::List emaillist; |
2407 | 2407 | ||
2408 | if (!name.isEmpty()) | 2408 | if (!name.isEmpty()) |
2409 | namelist = mAddressBook->findByName( name ); | 2409 | namelist = mAddressBook->findByName( name ); |
2410 | 2410 | ||
2411 | if (!email.isEmpty()) | 2411 | if (!email.isEmpty()) |
2412 | emaillist = mAddressBook->findByEmail( email ); | 2412 | emaillist = mAddressBook->findByEmail( email ); |
2413 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2413 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2414 | //check if we have a match in Namelist and Emaillist | 2414 | //check if we have a match in Namelist and Emaillist |
2415 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2415 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2416 | foundUid = emaillist[0].uid(); | 2416 | foundUid = emaillist[0].uid(); |
2417 | } | 2417 | } |
2418 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2418 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2419 | foundUid = namelist[0].uid(); | 2419 | foundUid = namelist[0].uid(); |
2420 | else | 2420 | else |
2421 | { | 2421 | { |
2422 | for (int i = 0; i < namelist.count(); i++) | 2422 | for (int i = 0; i < namelist.count(); i++) |
2423 | { | 2423 | { |
2424 | for (int j = 0; j < emaillist.count(); j++) | 2424 | for (int j = 0; j < emaillist.count(); j++) |
2425 | { | 2425 | { |
2426 | if (namelist[i] == emaillist[j]) | 2426 | if (namelist[i] == emaillist[j]) |
2427 | { | 2427 | { |
2428 | foundUid = namelist[i].uid(); | 2428 | foundUid = namelist[i].uid(); |
2429 | } | 2429 | } |
2430 | } | 2430 | } |
2431 | } | 2431 | } |
2432 | } | 2432 | } |
2433 | } | 2433 | } |
2434 | else | 2434 | else |
2435 | { | 2435 | { |
2436 | foundUid = uid; | 2436 | foundUid = uid; |
2437 | } | 2437 | } |
2438 | 2438 | ||
2439 | if (!foundUid.isEmpty()) | 2439 | if (!foundUid.isEmpty()) |
2440 | { | 2440 | { |
2441 | 2441 | ||
2442 | // raise Ka/Pi if it is in the background | 2442 | // raise Ka/Pi if it is in the background |
2443 | #ifndef DESKTOP_VERSION | 2443 | #ifndef DESKTOP_VERSION |
2444 | #ifndef KORG_NODCOP | 2444 | #ifndef KORG_NODCOP |
2445 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2445 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2446 | #endif | 2446 | #endif |
2447 | #endif | 2447 | #endif |
2448 | 2448 | ||
2449 | mMainWindow->showMaximized(); | 2449 | mMainWindow->showMaximized(); |
2450 | mMainWindow-> raise(); | 2450 | mMainWindow-> raise(); |
2451 | 2451 | ||
2452 | mViewManager->setSelected( "", false); | 2452 | mViewManager->setSelected( "", false); |
2453 | mViewManager->refreshView( "" ); | 2453 | mViewManager->refreshView( "" ); |
2454 | mViewManager->setSelected( foundUid, true ); | 2454 | mViewManager->setSelected( foundUid, true ); |
2455 | mViewManager->refreshView( foundUid ); | 2455 | mViewManager->refreshView( foundUid ); |
2456 | 2456 | ||
2457 | if ( !mMultipleViewsAtOnce ) | 2457 | if ( !mMultipleViewsAtOnce ) |
2458 | { | 2458 | { |
2459 | setDetailsVisible( true ); | 2459 | setDetailsVisible( true ); |
2460 | mActionDetails->setChecked(true); | 2460 | mActionDetails->setChecked(true); |
2461 | } | 2461 | } |
2462 | } | 2462 | } |
2463 | } | 2463 | } |
2464 | 2464 | ||
2465 | void KABCore::whatsnew() | 2465 | void KABCore::whatsnew() |
2466 | { | 2466 | { |
2467 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2467 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2468 | } | 2468 | } |
2469 | void KABCore::synchowto() | 2469 | void KABCore::synchowto() |
2470 | { | 2470 | { |
2471 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2471 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2472 | } | 2472 | } |
2473 | void KABCore::kdesynchowto() | 2473 | void KABCore::kdesynchowto() |
2474 | { | 2474 | { |
2475 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2475 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2476 | } | 2476 | } |
2477 | void KABCore::multisynchowto() | 2477 | void KABCore::multisynchowto() |
2478 | { | 2478 | { |
2479 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2479 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2480 | } | 2480 | } |
2481 | void KABCore::faq() | 2481 | void KABCore::faq() |
2482 | { | 2482 | { |
2483 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2483 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2484 | } | 2484 | } |
2485 | 2485 | ||
2486 | #include <libkcal/syncdefines.h> | 2486 | #include <libkcal/syncdefines.h> |
2487 | 2487 | ||
2488 | KABC::Addressee KABCore::getLastSyncAddressee() | 2488 | KABC::Addressee KABCore::getLastSyncAddressee() |
2489 | { | 2489 | { |
2490 | Addressee lse; | 2490 | Addressee lse; |
2491 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2491 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2492 | 2492 | ||
2493 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2493 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2494 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2494 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2495 | if (lse.isEmpty()) { | 2495 | if (lse.isEmpty()) { |
2496 | qDebug("Creating new last-syncAddressee "); | 2496 | qDebug("Creating new last-syncAddressee "); |
2497 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2497 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2498 | QString sum = ""; | 2498 | QString sum = ""; |
2499 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2499 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2500 | sum = "E: "; | 2500 | sum = "E: "; |
2501 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2501 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2502 | lse.setRevision( mLastAddressbookSync ); | 2502 | lse.setRevision( mLastAddressbookSync ); |
2503 | lse.setCategories( i18n("SyncEvent") ); | 2503 | lse.setCategories( i18n("SyncEvent") ); |
2504 | mAddressBook->insertAddressee( lse ); | 2504 | mAddressBook->insertAddressee( lse ); |
2505 | } | 2505 | } |
2506 | return lse; | 2506 | return lse; |
2507 | } | 2507 | } |
2508 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2508 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2509 | { | 2509 | { |
2510 | 2510 | ||
2511 | //void setZaurusId(int id); | 2511 | //void setZaurusId(int id); |
2512 | // int zaurusId() const; | 2512 | // int zaurusId() const; |
2513 | // void setZaurusUid(int id); | 2513 | // void setZaurusUid(int id); |
2514 | // int zaurusUid() const; | 2514 | // int zaurusUid() const; |
2515 | // void setZaurusStat(int id); | 2515 | // void setZaurusStat(int id); |
2516 | // int zaurusStat() const; | 2516 | // int zaurusStat() const; |
2517 | // 0 equal | 2517 | // 0 equal |
2518 | // 1 take local | 2518 | // 1 take local |
2519 | // 2 take remote | 2519 | // 2 take remote |
2520 | // 3 cancel | 2520 | // 3 cancel |
2521 | QDateTime lastSync = mLastAddressbookSync; | 2521 | QDateTime lastSync = mLastAddressbookSync; |
2522 | QDateTime localMod = local->revision(); | 2522 | QDateTime localMod = local->revision(); |
2523 | QDateTime remoteMod = remote->revision(); | 2523 | QDateTime remoteMod = remote->revision(); |
2524 | 2524 | ||
2525 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2525 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2526 | 2526 | ||
2527 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2527 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2528 | bool remCh, locCh; | 2528 | bool remCh, locCh; |
2529 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2529 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2530 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2530 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2531 | locCh = ( localMod > mLastAddressbookSync ); | 2531 | locCh = ( localMod > mLastAddressbookSync ); |
2532 | if ( !remCh && ! locCh ) { | 2532 | if ( !remCh && ! locCh ) { |
2533 | //qDebug("both not changed "); | 2533 | //qDebug("both not changed "); |
2534 | lastSync = localMod.addDays(1); | 2534 | lastSync = localMod.addDays(1); |
2535 | if ( mode <= SYNC_PREF_ASK ) | 2535 | if ( mode <= SYNC_PREF_ASK ) |
2536 | return 0; | 2536 | return 0; |
2537 | } else { | 2537 | } else { |
2538 | if ( locCh ) { | 2538 | if ( locCh ) { |
2539 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2539 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2540 | lastSync = localMod.addDays( -1 ); | 2540 | lastSync = localMod.addDays( -1 ); |
2541 | if ( !remCh ) | 2541 | if ( !remCh ) |
2542 | remoteMod =( lastSync.addDays( -1 ) ); | 2542 | remoteMod =( lastSync.addDays( -1 ) ); |
2543 | } else { | 2543 | } else { |
2544 | //qDebug(" not loc changed "); | 2544 | //qDebug(" not loc changed "); |
2545 | lastSync = localMod.addDays( 1 ); | 2545 | lastSync = localMod.addDays( 1 ); |
2546 | if ( remCh ) { | 2546 | if ( remCh ) { |
2547 | //qDebug("rem changed "); | 2547 | //qDebug("rem changed "); |
2548 | remoteMod =( lastSync.addDays( 1 ) ); | 2548 | remoteMod =( lastSync.addDays( 1 ) ); |
2549 | } | 2549 | } |
2550 | 2550 | ||
2551 | } | 2551 | } |
2552 | } | 2552 | } |
2553 | full = true; | 2553 | full = true; |
2554 | if ( mode < SYNC_PREF_ASK ) | 2554 | if ( mode < SYNC_PREF_ASK ) |
2555 | mode = SYNC_PREF_ASK; | 2555 | mode = SYNC_PREF_ASK; |
2556 | } else { | 2556 | } else { |
2557 | if ( localMod == remoteMod ) | 2557 | if ( localMod == remoteMod ) |
2558 | return 0; | 2558 | return 0; |
2559 | 2559 | ||
2560 | } | 2560 | } |
2561 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2561 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2562 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2562 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2563 | //full = true; //debug only | 2563 | //full = true; //debug only |
2564 | if ( full ) { | 2564 | if ( full ) { |
2565 | bool equ = ( (*local) == (*remote) ); | 2565 | bool equ = ( (*local) == (*remote) ); |
2566 | if ( equ ) { | 2566 | if ( equ ) { |
2567 | //qDebug("equal "); | 2567 | //qDebug("equal "); |
2568 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2568 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2569 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2569 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2570 | } | 2570 | } |
2571 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2571 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2572 | return 0; | 2572 | return 0; |
2573 | 2573 | ||
2574 | }//else //debug only | 2574 | }//else //debug only |
2575 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2575 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2576 | } | 2576 | } |
2577 | int result; | 2577 | int result; |
2578 | bool localIsNew; | 2578 | bool localIsNew; |
2579 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2579 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2580 | 2580 | ||
2581 | if ( full && mode < SYNC_PREF_NEWEST ) | 2581 | if ( full && mode < SYNC_PREF_NEWEST ) |
2582 | mode = SYNC_PREF_ASK; | 2582 | mode = SYNC_PREF_ASK; |
2583 | 2583 | ||
2584 | switch( mode ) { | 2584 | switch( mode ) { |
2585 | case SYNC_PREF_LOCAL: | 2585 | case SYNC_PREF_LOCAL: |
2586 | if ( lastSync > remoteMod ) | 2586 | if ( lastSync > remoteMod ) |
2587 | return 1; | 2587 | return 1; |
2588 | if ( lastSync > localMod ) | 2588 | if ( lastSync > localMod ) |
2589 | return 2; | 2589 | return 2; |
2590 | return 1; | 2590 | return 1; |
2591 | break; | 2591 | break; |
2592 | case SYNC_PREF_REMOTE: | 2592 | case SYNC_PREF_REMOTE: |
2593 | if ( lastSync > remoteMod ) | 2593 | if ( lastSync > remoteMod ) |
2594 | return 1; | 2594 | return 1; |
2595 | if ( lastSync > localMod ) | 2595 | if ( lastSync > localMod ) |
2596 | return 2; | 2596 | return 2; |
2597 | return 2; | 2597 | return 2; |
2598 | break; | 2598 | break; |
2599 | case SYNC_PREF_NEWEST: | 2599 | case SYNC_PREF_NEWEST: |
2600 | if ( localMod > remoteMod ) | 2600 | if ( localMod > remoteMod ) |
2601 | return 1; | 2601 | return 1; |
2602 | else | 2602 | else |
2603 | return 2; | 2603 | return 2; |
2604 | break; | 2604 | break; |
2605 | case SYNC_PREF_ASK: | 2605 | case SYNC_PREF_ASK: |
2606 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2606 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2607 | if ( lastSync > remoteMod ) | 2607 | if ( lastSync > remoteMod ) |
2608 | return 1; | 2608 | return 1; |
2609 | if ( lastSync > localMod ) | 2609 | if ( lastSync > localMod ) |
2610 | return 2; | 2610 | return 2; |
2611 | localIsNew = localMod >= remoteMod; | 2611 | localIsNew = localMod >= remoteMod; |
2612 | //qDebug("conflict! ************************************** "); | 2612 | //qDebug("conflict! ************************************** "); |
2613 | { | 2613 | { |
2614 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2614 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2615 | result = acd.executeD(localIsNew); | 2615 | result = acd.executeD(localIsNew); |
2616 | return result; | 2616 | return result; |
2617 | } | 2617 | } |
2618 | break; | 2618 | break; |
2619 | case SYNC_PREF_FORCE_LOCAL: | 2619 | case SYNC_PREF_FORCE_LOCAL: |
2620 | return 1; | 2620 | return 1; |
2621 | break; | 2621 | break; |
2622 | case SYNC_PREF_FORCE_REMOTE: | 2622 | case SYNC_PREF_FORCE_REMOTE: |
2623 | return 2; | 2623 | return 2; |
2624 | break; | 2624 | break; |
2625 | 2625 | ||
2626 | default: | 2626 | default: |
2627 | // SYNC_PREF_TAKE_BOTH not implemented | 2627 | // SYNC_PREF_TAKE_BOTH not implemented |
2628 | break; | 2628 | break; |
2629 | } | 2629 | } |
2630 | return 0; | 2630 | return 0; |
2631 | } | 2631 | } |
2632 | 2632 | ||
2633 | 2633 | ||
2634 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2634 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2635 | { | 2635 | { |
2636 | bool syncOK = true; | 2636 | bool syncOK = true; |
2637 | int addedAddressee = 0; | 2637 | int addedAddressee = 0; |
2638 | int addedAddresseeR = 0; | 2638 | int addedAddresseeR = 0; |
2639 | int deletedAddresseeR = 0; | 2639 | int deletedAddresseeR = 0; |
2640 | int deletedAddresseeL = 0; | 2640 | int deletedAddresseeL = 0; |
2641 | int changedLocal = 0; | 2641 | int changedLocal = 0; |
2642 | int changedRemote = 0; | 2642 | int changedRemote = 0; |
2643 | 2643 | ||
2644 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2644 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2645 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2645 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2646 | 2646 | ||
2647 | //QPtrList<Addressee> el = local->rawAddressees(); | 2647 | //QPtrList<Addressee> el = local->rawAddressees(); |
2648 | Addressee addresseeR; | 2648 | Addressee addresseeR; |
2649 | QString uid; | 2649 | QString uid; |
2650 | int take; | 2650 | int take; |
2651 | Addressee addresseeL; | 2651 | Addressee addresseeL; |
2652 | Addressee addresseeRSync; | 2652 | Addressee addresseeRSync; |
2653 | Addressee addresseeLSync; | 2653 | Addressee addresseeLSync; |
2654 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2654 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2655 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2655 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2656 | bool fullDateRange = false; | 2656 | bool fullDateRange = false; |
2657 | local->resetTempSyncStat(); | 2657 | local->resetTempSyncStat(); |
2658 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2658 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2659 | if ( syncManager->syncWithDesktop() ) { | 2659 | if ( syncManager->syncWithDesktop() ) { |
2660 | // remote->removeSyncInfo( QString());//remove all info | 2660 | // remote->removeSyncInfo( QString());//remove all info |
2661 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2661 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2662 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2662 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2663 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2663 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2664 | } else { | 2664 | } else { |
2665 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2665 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2666 | } | 2666 | } |
2667 | } | 2667 | } |
2668 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2668 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2669 | addresseeLSync = getLastSyncAddressee(); | 2669 | addresseeLSync = getLastSyncAddressee(); |
2670 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2670 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2671 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2671 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2672 | if ( !addresseeR.isEmpty() ) { | 2672 | if ( !addresseeR.isEmpty() ) { |
2673 | addresseeRSync = addresseeR; | 2673 | addresseeRSync = addresseeR; |
2674 | remote->removeAddressee(addresseeR ); | 2674 | remote->removeAddressee(addresseeR ); |
2675 | 2675 | ||
2676 | } else { | 2676 | } else { |
2677 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2677 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2678 | addresseeRSync = addresseeLSync ; | 2678 | addresseeRSync = addresseeLSync ; |
2679 | } else { | 2679 | } else { |
2680 | //qDebug("FULLDATE 1"); | 2680 | //qDebug("FULLDATE 1"); |
2681 | fullDateRange = true; | 2681 | fullDateRange = true; |
2682 | Addressee newAdd; | 2682 | Addressee newAdd; |
2683 | addresseeRSync = newAdd; | 2683 | addresseeRSync = newAdd; |
2684 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2684 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2685 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2685 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2686 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2686 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2687 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2687 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2688 | } | 2688 | } |
2689 | } | 2689 | } |
2690 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2690 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2691 | // qDebug("FULLDATE 2"); | 2691 | // qDebug("FULLDATE 2"); |
2692 | fullDateRange = true; | 2692 | fullDateRange = true; |
2693 | } | 2693 | } |
2694 | if ( ! fullDateRange ) { | 2694 | if ( ! fullDateRange ) { |
2695 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2695 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2696 | 2696 | ||
2697 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2697 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2698 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2698 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2699 | fullDateRange = true; | 2699 | fullDateRange = true; |
2700 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2700 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2701 | } | 2701 | } |
2702 | } | 2702 | } |
2703 | // fullDateRange = true; // debug only! | 2703 | // fullDateRange = true; // debug only! |
2704 | if ( fullDateRange ) | 2704 | if ( fullDateRange ) |
2705 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2705 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2706 | else | 2706 | else |
2707 | mLastAddressbookSync = addresseeLSync.revision(); | 2707 | mLastAddressbookSync = addresseeLSync.revision(); |
2708 | // for resyncing if own file has changed | 2708 | // for resyncing if own file has changed |
2709 | // PENDING fixme later when implemented | 2709 | // PENDING fixme later when implemented |
2710 | #if 0 | 2710 | #if 0 |
2711 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2711 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2712 | mLastAddressbookSync = loadedFileVersion; | 2712 | mLastAddressbookSync = loadedFileVersion; |
2713 | qDebug("setting mLastAddressbookSync "); | 2713 | qDebug("setting mLastAddressbookSync "); |
2714 | } | 2714 | } |
2715 | #endif | 2715 | #endif |
2716 | 2716 | ||
2717 | //qDebug("*************************** "); | 2717 | //qDebug("*************************** "); |
2718 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2718 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2719 | QStringList er = remote->uidList(); | 2719 | QStringList er = remote->uidList(); |
2720 | Addressee inR ;//= er.first(); | 2720 | Addressee inR ;//= er.first(); |
2721 | Addressee inL; | 2721 | Addressee inL; |
2722 | 2722 | ||
2723 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2723 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2724 | 2724 | ||
2725 | int modulo = (er.count()/10)+1; | 2725 | int modulo = (er.count()/10)+1; |
2726 | int incCounter = 0; | 2726 | int incCounter = 0; |
2727 | while ( incCounter < er.count()) { | 2727 | while ( incCounter < er.count()) { |
2728 | if (syncManager->isProgressBarCanceled()) | 2728 | if (syncManager->isProgressBarCanceled()) |
2729 | return false; | 2729 | return false; |
2730 | if ( incCounter % modulo == 0 ) | 2730 | if ( incCounter % modulo == 0 ) |
2731 | syncManager->showProgressBar(incCounter); | 2731 | syncManager->showProgressBar(incCounter); |
2732 | 2732 | ||
2733 | uid = er[ incCounter ]; | 2733 | uid = er[ incCounter ]; |
2734 | bool skipIncidence = false; | 2734 | bool skipIncidence = false; |
2735 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2735 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2736 | skipIncidence = true; | 2736 | skipIncidence = true; |
2737 | QString idS,OidS; | 2737 | QString idS,OidS; |
2738 | qApp->processEvents(); | 2738 | qApp->processEvents(); |
2739 | if ( !skipIncidence ) { | 2739 | if ( !skipIncidence ) { |
2740 | inL = local->findByUid( uid ); | 2740 | inL = local->findByUid( uid ); |
2741 | inR = remote->findByUid( uid ); | 2741 | inR = remote->findByUid( uid ); |
2742 | //inL.setResource( 0 ); | 2742 | //inL.setResource( 0 ); |
2743 | //inR.setResource( 0 ); | 2743 | //inR.setResource( 0 ); |
2744 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2744 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2745 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2745 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2746 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2746 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
2747 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2747 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2748 | if ( take == 3 ) | 2748 | if ( take == 3 ) |
2749 | return false; | 2749 | return false; |
2750 | if ( take == 1 ) {// take local ********************** | 2750 | if ( take == 1 ) {// take local ********************** |
2751 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2751 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2752 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2752 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2753 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2753 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2754 | local->insertAddressee( inL, false ); | 2754 | local->insertAddressee( inL, false ); |
2755 | idS = inR.externalUID(); | 2755 | idS = inR.externalUID(); |
2756 | OidS = inR.originalExternalUID(); | 2756 | OidS = inR.originalExternalUID(); |
2757 | } | 2757 | } |
2758 | else | 2758 | else |
2759 | idS = inR.IDStr(); | 2759 | idS = inR.IDStr(); |
2760 | remote->removeAddressee( inR ); | 2760 | remote->removeAddressee( inR ); |
2761 | inR = inL; | 2761 | inR = inL; |
2762 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2762 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2763 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2763 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2764 | inR.setOriginalExternalUID( OidS ); | 2764 | inR.setOriginalExternalUID( OidS ); |
2765 | inR.setExternalUID( idS ); | 2765 | inR.setExternalUID( idS ); |
2766 | if ( syncManager->syncWithDesktop() ) { | 2766 | if ( syncManager->syncWithDesktop() ) { |
2767 | inR.setIDStr("changed" ); | 2767 | inR.setIDStr("changed" ); |
2768 | } | 2768 | } |
2769 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2769 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2770 | } else { | 2770 | } else { |
2771 | inR.setIDStr( idS ); | 2771 | inR.setIDStr( idS ); |
2772 | } | 2772 | } |
2773 | inR.setResource( 0 ); | 2773 | inR.setResource( 0 ); |
2774 | remote->insertAddressee( inR , false); | 2774 | remote->insertAddressee( inR , false); |
2775 | ++changedRemote; | 2775 | ++changedRemote; |
2776 | } else { // take == 2 take remote ********************** | 2776 | } else { // take == 2 take remote ********************** |
2777 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2777 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2778 | if ( inR.revision().date().year() < 2004 ) | 2778 | if ( inR.revision().date().year() < 2004 ) |
2779 | inR.setRevision( modifiedCalendar ); | 2779 | inR.setRevision( modifiedCalendar ); |
2780 | } | 2780 | } |
2781 | idS = inL.IDStr(); | 2781 | idS = inL.IDStr(); |
2782 | local->removeAddressee( inL ); | 2782 | local->removeAddressee( inL ); |
2783 | inL = inR; | 2783 | inL = inR; |
2784 | inL.setIDStr( idS ); | 2784 | inL.setIDStr( idS ); |
2785 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2785 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2786 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2786 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2787 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2787 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2788 | } | 2788 | } |
2789 | inL.setResource( 0 ); | 2789 | inL.setResource( 0 ); |
2790 | local->insertAddressee( inL , false ); | 2790 | local->insertAddressee( inL , false ); |
2791 | ++changedLocal; | 2791 | ++changedLocal; |
2792 | } | 2792 | } |
2793 | } | 2793 | } |
2794 | } | 2794 | } |
2795 | } else { // no conflict ********** add or delete remote | 2795 | } else { // no conflict ********** add or delete remote |
2796 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2796 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2797 | QString des = addresseeLSync.note(); | 2797 | QString des = addresseeLSync.note(); |
2798 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2798 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2799 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2799 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2800 | remote->insertAddressee( inR, false ); | 2800 | remote->insertAddressee( inR, false ); |
2801 | ++deletedAddresseeR; | 2801 | ++deletedAddresseeR; |
2802 | } else { | 2802 | } else { |
2803 | inR.setRevision( modifiedCalendar ); | 2803 | inR.setRevision( modifiedCalendar ); |
2804 | remote->insertAddressee( inR, false ); | 2804 | remote->insertAddressee( inR, false ); |
2805 | inL = inR; | 2805 | inL = inR; |
2806 | inL.setIDStr( ":" ); | 2806 | inL.setIDStr( ":" ); |
2807 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2807 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2808 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2808 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2809 | inL.setResource( 0 ); | 2809 | inL.setResource( 0 ); |
2810 | local->insertAddressee( inL , false); | 2810 | local->insertAddressee( inL , false); |
2811 | ++addedAddressee; | 2811 | ++addedAddressee; |
2812 | } | 2812 | } |
2813 | } else { | 2813 | } else { |
2814 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2814 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2815 | inR.setRevision( modifiedCalendar ); | 2815 | inR.setRevision( modifiedCalendar ); |
2816 | remote->insertAddressee( inR, false ); | 2816 | remote->insertAddressee( inR, false ); |
2817 | inR.setResource( 0 ); | 2817 | inR.setResource( 0 ); |
2818 | local->insertAddressee( inR, false ); | 2818 | local->insertAddressee( inR, false ); |
2819 | ++addedAddressee; | 2819 | ++addedAddressee; |
2820 | } else { | 2820 | } else { |
2821 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2821 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2822 | remote->removeAddressee( inR ); | 2822 | remote->removeAddressee( inR ); |
2823 | ++deletedAddresseeR; | 2823 | ++deletedAddresseeR; |
2824 | } | 2824 | } |
2825 | } | 2825 | } |
2826 | } | 2826 | } |
2827 | } | 2827 | } |
2828 | ++incCounter; | 2828 | ++incCounter; |
2829 | } | 2829 | } |
2830 | er.clear(); | 2830 | er.clear(); |
2831 | QStringList el = local->uidList(); | 2831 | QStringList el = local->uidList(); |
2832 | modulo = (el.count()/10)+1; | 2832 | modulo = (el.count()/10)+1; |
2833 | 2833 | ||
2834 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2834 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2835 | incCounter = 0; | 2835 | incCounter = 0; |
2836 | while ( incCounter < el.count()) { | 2836 | while ( incCounter < el.count()) { |
2837 | qApp->processEvents(); | 2837 | qApp->processEvents(); |
2838 | if (syncManager->isProgressBarCanceled()) | 2838 | if (syncManager->isProgressBarCanceled()) |
2839 | return false; | 2839 | return false; |
2840 | if ( incCounter % modulo == 0 ) | 2840 | if ( incCounter % modulo == 0 ) |
2841 | syncManager->showProgressBar(incCounter); | 2841 | syncManager->showProgressBar(incCounter); |
2842 | uid = el[ incCounter ]; | 2842 | uid = el[ incCounter ]; |
2843 | bool skipIncidence = false; | 2843 | bool skipIncidence = false; |
2844 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2844 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2845 | skipIncidence = true; | 2845 | skipIncidence = true; |
2846 | if ( !skipIncidence ) { | 2846 | if ( !skipIncidence ) { |
2847 | inL = local->findByUid( uid ); | 2847 | inL = local->findByUid( uid ); |
2848 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2848 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2849 | inR = remote->findByUid( uid ); | 2849 | inR = remote->findByUid( uid ); |
2850 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local | 2850 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local |
2851 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2851 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2852 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2852 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2853 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2853 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2854 | local->removeAddressee( inL ); | 2854 | local->removeAddressee( inL ); |
2855 | ++deletedAddresseeL; | 2855 | ++deletedAddresseeL; |
2856 | } else { | 2856 | } else { |
2857 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2857 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2858 | inL.removeID(mCurrentSyncDevice ); | 2858 | inL.removeID(mCurrentSyncDevice ); |
2859 | ++addedAddresseeR; | 2859 | ++addedAddresseeR; |
2860 | inL.setRevision( modifiedCalendar ); | 2860 | inL.setRevision( modifiedCalendar ); |
2861 | local->insertAddressee( inL, false ); | 2861 | local->insertAddressee( inL, false ); |
2862 | inR = inL; | 2862 | inR = inL; |
2863 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2863 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2864 | inR.setResource( 0 ); | 2864 | inR.setResource( 0 ); |
2865 | remote->insertAddressee( inR, false ); | 2865 | remote->insertAddressee( inR, false ); |
2866 | } | 2866 | } |
2867 | } | 2867 | } |
2868 | } else { | 2868 | } else { |
2869 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2869 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2870 | //qDebug("data %s ", inL.revision().toString().latin1()); | 2870 | //qDebug("data %s ", inL.revision().toString().latin1()); |
2871 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2871 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2872 | local->removeAddressee( inL ); | 2872 | local->removeAddressee( inL ); |
2873 | ++deletedAddresseeL; | 2873 | ++deletedAddresseeL; |
2874 | } else { | 2874 | } else { |
2875 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2875 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2876 | ++addedAddresseeR; | 2876 | ++addedAddresseeR; |
2877 | inL.setRevision( modifiedCalendar ); | 2877 | inL.setRevision( modifiedCalendar ); |
2878 | local->insertAddressee( inL, false ); | 2878 | local->insertAddressee( inL, false ); |
2879 | inR = inL; | 2879 | inR = inL; |
2880 | inR.setIDStr( ":" ); | 2880 | inR.setIDStr( ":" ); |
2881 | inR.setResource( 0 ); | 2881 | inR.setResource( 0 ); |
2882 | remote->insertAddressee( inR, false ); | 2882 | remote->insertAddressee( inR, false ); |
2883 | } | 2883 | } |
2884 | } | 2884 | } |
2885 | } | 2885 | } |
2886 | } | 2886 | } |
2887 | } | 2887 | } |
2888 | } | 2888 | } |
2889 | ++incCounter; | 2889 | ++incCounter; |
2890 | } | 2890 | } |
2891 | el.clear(); | 2891 | el.clear(); |
2892 | syncManager->hideProgressBar(); | 2892 | syncManager->hideProgressBar(); |
2893 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2893 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2894 | // get rid of micro seconds | 2894 | // get rid of micro seconds |
2895 | QTime t = mLastAddressbookSync.time(); | 2895 | QTime t = mLastAddressbookSync.time(); |
2896 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2896 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2897 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2897 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2898 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2898 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2899 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2899 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2900 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2900 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2901 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2901 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2902 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2902 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2903 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2903 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2904 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2904 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2905 | addresseeRSync.setNote( "" ) ; | 2905 | addresseeRSync.setNote( "" ) ; |
2906 | addresseeLSync.setNote( "" ); | 2906 | addresseeLSync.setNote( "" ); |
2907 | 2907 | ||
2908 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2908 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2909 | remote->insertAddressee( addresseeRSync, false ); | 2909 | remote->insertAddressee( addresseeRSync, false ); |
2910 | local->insertAddressee( addresseeLSync, false ); | 2910 | local->insertAddressee( addresseeLSync, false ); |
2911 | QString mes; | 2911 | QString mes; |
2912 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2912 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2913 | qDebug( mes ); | 2913 | qDebug( mes ); |
2914 | mes = i18n("Local addressbook changed!\n") +mes; | 2914 | mes = i18n("Local addressbook changed!\n") +mes; |
2915 | if ( syncManager->mShowSyncSummary ) { | 2915 | if ( syncManager->mShowSyncSummary ) { |
2916 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 2916 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
2917 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 2917 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
2918 | qDebug("cancelled "); | 2918 | qDebug("cancelled "); |
2919 | return false; | 2919 | return false; |
2920 | } | 2920 | } |
2921 | } | 2921 | } |
2922 | return syncOK; | 2922 | return syncOK; |
2923 | } | 2923 | } |
2924 | 2924 | ||
2925 | 2925 | ||
2926 | //this is a overwritten callbackmethods from the syncinterface | 2926 | //this is a overwritten callbackmethods from the syncinterface |
2927 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2927 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2928 | { | 2928 | { |
2929 | 2929 | ||
2930 | //pending prepare addresseeview for output | 2930 | //pending prepare addresseeview for output |
2931 | //pending detect, if remote file has REV field. if not switch to external sync | 2931 | //pending detect, if remote file has REV field. if not switch to external sync |
2932 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2932 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2933 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2933 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2934 | 2934 | ||
2935 | AddressBook abLocal(filename,"syncContact"); | 2935 | AddressBook abLocal(filename,"syncContact"); |
2936 | bool syncOK = false; | 2936 | bool syncOK = false; |
2937 | if ( abLocal.load() ) { | 2937 | if ( abLocal.load() ) { |
2938 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2938 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2939 | bool external = false; | 2939 | bool external = false; |
2940 | bool isXML = false; | 2940 | bool isXML = false; |
2941 | if ( filename.right(4) == ".xml") { | 2941 | if ( filename.right(4) == ".xml") { |
2942 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2942 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2943 | isXML = true; | 2943 | isXML = true; |
2944 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2944 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2945 | } else { | 2945 | } else { |
2946 | external = !manager->mIsKapiFile; | 2946 | external = !manager->mIsKapiFile; |
2947 | if ( external ) { | 2947 | if ( external ) { |
2948 | qDebug("Setting vcf mode to external "); | 2948 | qDebug("Setting vcf mode to external "); |
2949 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2949 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2950 | AddressBook::Iterator it; | 2950 | AddressBook::Iterator it; |
2951 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2951 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2952 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2952 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2953 | (*it).computeCsum( mCurrentSyncDevice ); | 2953 | (*it).computeCsum( mCurrentSyncDevice ); |
2954 | } | 2954 | } |
2955 | } | 2955 | } |
2956 | } | 2956 | } |
2957 | //AddressBook::Iterator it; | 2957 | //AddressBook::Iterator it; |
2958 | //QStringList vcards; | 2958 | //QStringList vcards; |
2959 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2959 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2960 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2960 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2961 | //} | 2961 | //} |
2962 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2962 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2963 | if ( syncOK ) { | 2963 | if ( syncOK ) { |
2964 | if ( syncManager->mWriteBackFile ) | 2964 | if ( syncManager->mWriteBackFile ) |
2965 | { | 2965 | { |
2966 | if ( external ) | 2966 | if ( external ) |
2967 | abLocal.removeSyncAddressees( !isXML); | 2967 | abLocal.removeSyncAddressees( !isXML); |
2968 | qDebug("Saving remote AB "); | 2968 | qDebug("Saving remote AB "); |
2969 | if ( ! abLocal.saveAB()) | 2969 | if ( ! abLocal.saveAB()) |
2970 | qDebug("Error writing back AB to file "); | 2970 | qDebug("Error writing back AB to file "); |
2971 | if ( external ) { | 2971 | if ( external ) { |
2972 | // afterwrite processing | 2972 | // afterwrite processing |
2973 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 2973 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
2974 | } | 2974 | } |
2975 | } | 2975 | } |
2976 | } | 2976 | } |
2977 | setModified(); | 2977 | setModified(); |
2978 | 2978 | ||
2979 | } | 2979 | } |
2980 | abLocal.removeResources(); | 2980 | abLocal.removeResources(); |
2981 | if ( syncOK ) | 2981 | if ( syncOK ) |
2982 | mViewManager->refreshView(); | 2982 | mViewManager->refreshView(); |
2983 | return syncOK; | 2983 | return syncOK; |
2984 | 2984 | ||
2985 | } | 2985 | } |
2986 | void KABCore::removeSyncInfo( QString syncProfile) | 2986 | void KABCore::removeSyncInfo( QString syncProfile) |
2987 | { | 2987 | { |
2988 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 2988 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2989 | mAddressBook->removeSyncInfo( syncProfile ); | 2989 | mAddressBook->removeSyncInfo( syncProfile ); |
2990 | setModified(); | 2990 | setModified(); |
2991 | } | 2991 | } |
2992 | 2992 | ||
2993 | 2993 | ||
2994 | //this is a overwritten callbackmethods from the syncinterface | 2994 | //this is a overwritten callbackmethods from the syncinterface |
2995 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2995 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2996 | { | 2996 | { |
2997 | if ( resource == "phone" ) | 2997 | if ( resource == "phone" ) |
2998 | return syncPhone(); | 2998 | return syncPhone(); |
2999 | disableBR( true ); | 2999 | disableBR( true ); |
3000 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3000 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3001 | 3001 | ||
3002 | AddressBook abLocal( resource,"syncContact"); | 3002 | AddressBook abLocal( resource,"syncContact"); |
3003 | bool syncOK = false; | 3003 | bool syncOK = false; |
3004 | if ( abLocal.load() ) { | 3004 | if ( abLocal.load() ) { |
3005 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3005 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3006 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3006 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3007 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3007 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3008 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3008 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3009 | if ( syncOK ) { | 3009 | if ( syncOK ) { |
3010 | if ( syncManager->mWriteBackFile ) { | 3010 | if ( syncManager->mWriteBackFile ) { |
3011 | abLocal.removeSyncAddressees( false ); | 3011 | abLocal.removeSyncAddressees( false ); |
3012 | abLocal.saveAB(); | 3012 | abLocal.saveAB(); |
3013 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3013 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3014 | } | 3014 | } |
3015 | } else | 3015 | } else |
3016 | message( i18n("Sync cancelled or failed.") ); | 3016 | message( i18n("Sync cancelled or failed.") ); |
3017 | setModified(); | 3017 | setModified(); |
3018 | } | 3018 | } |
3019 | abLocal.removeResources(); | 3019 | abLocal.removeResources(); |
3020 | if ( syncOK ) | 3020 | if ( syncOK ) |
3021 | mViewManager->refreshView(); | 3021 | mViewManager->refreshView(); |
3022 | disableBR( false ); | 3022 | disableBR( false ); |
3023 | return syncOK; | 3023 | return syncOK; |
3024 | 3024 | ||
3025 | } | 3025 | } |
3026 | void KABCore::message( QString m ) | 3026 | void KABCore::message( QString m ) |
3027 | { | 3027 | { |
3028 | topLevelWidget()->setCaption( m ); | 3028 | topLevelWidget()->setCaption( m ); |
3029 | mMessageTimer->start( 15000, true ); | 3029 | mMessageTimer->start( 15000, true ); |
3030 | } | 3030 | } |
3031 | bool KABCore::syncPhone() | 3031 | bool KABCore::syncPhone() |
3032 | { | 3032 | { |
3033 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3033 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3034 | QString fileName = getPhoneFile(); | 3034 | QString fileName = getPhoneFile(); |
3035 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3035 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3036 | message(i18n("Phone access failed!")); | 3036 | message(i18n("Phone access failed!")); |
3037 | return false; | 3037 | return false; |
3038 | } | 3038 | } |
3039 | AddressBook abLocal( fileName,"syncContact"); | 3039 | AddressBook abLocal( fileName,"syncContact"); |
3040 | bool syncOK = false; | 3040 | bool syncOK = false; |
3041 | { | 3041 | { |
3042 | abLocal.importFromFile( fileName ); | 3042 | abLocal.importFromFile( fileName ); |
3043 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3043 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3044 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3044 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3045 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3045 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3046 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3046 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3047 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3047 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3048 | if ( syncOK ) { | 3048 | if ( syncOK ) { |
3049 | if ( syncManager->mWriteBackFile ) { | 3049 | if ( syncManager->mWriteBackFile ) { |
3050 | abLocal.removeSyncAddressees( true ); | 3050 | abLocal.removeSyncAddressees( true ); |
3051 | abLocal.saveABphone( fileName ); | 3051 | abLocal.saveABphone( fileName ); |
3052 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3052 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3053 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3053 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3054 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3054 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3055 | } | 3055 | } |
3056 | } | 3056 | } |
3057 | setModified(); | 3057 | setModified(); |
3058 | } | 3058 | } |
3059 | abLocal.removeResources(); | 3059 | abLocal.removeResources(); |
3060 | if ( syncOK ) | 3060 | if ( syncOK ) |
3061 | mViewManager->refreshView(); | 3061 | mViewManager->refreshView(); |
3062 | return syncOK; | 3062 | return syncOK; |
3063 | } | 3063 | } |
3064 | void KABCore::getFile( bool success ) | 3064 | void KABCore::getFile( bool success ) |
3065 | { | 3065 | { |
3066 | if ( ! success ) { | 3066 | if ( ! success ) { |
3067 | message( i18n("Error receiving file. Nothing changed!") ); | 3067 | message( i18n("Error receiving file. Nothing changed!") ); |
3068 | return; | 3068 | return; |
3069 | } | 3069 | } |
3070 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3070 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3071 | if ( count ) | 3071 | if ( count ) |
3072 | setModified( true ); | 3072 | setModified( true ); |
3073 | message( i18n("Pi-Sync successful!") ); | 3073 | message( i18n("Pi-Sync successful!") ); |
3074 | mViewManager->refreshView(); | 3074 | mViewManager->refreshView(); |
3075 | } | 3075 | } |
3076 | void KABCore::syncFileRequest() | 3076 | void KABCore::syncFileRequest() |
3077 | { | 3077 | { |
3078 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3078 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3079 | syncManager->slotSyncMenu( 999 ); | 3079 | syncManager->slotSyncMenu( 999 ); |
3080 | } | 3080 | } |
3081 | mAddressBook->export2File( sentSyncFile() ); | 3081 | mAddressBook->export2File( sentSyncFile() ); |
3082 | } | 3082 | } |
3083 | QString KABCore::sentSyncFile() | 3083 | QString KABCore::sentSyncFile() |
3084 | { | 3084 | { |
3085 | #ifdef DESKTOP_VERSION | 3085 | #ifdef DESKTOP_VERSION |
3086 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3086 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3087 | #else | 3087 | #else |
3088 | return QString( "/tmp/copysyncab.vcf" ); | 3088 | return QString( "/tmp/copysyncab.vcf" ); |
3089 | #endif | 3089 | #endif |
3090 | } | 3090 | } |
3091 | 3091 | ||
3092 | void KABCore::setCaptionBack() | 3092 | void KABCore::setCaptionBack() |
3093 | { | 3093 | { |
3094 | mMessageTimer->stop(); | 3094 | mMessageTimer->stop(); |
3095 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3095 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3096 | } | 3096 | } |
diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp index da552c3..03df444 100644 --- a/kaddressbook/views/cardview.cpp +++ b/kaddressbook/views/cardview.cpp | |||
@@ -1,1722 +1,1722 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 | //BEGIN Includes | 24 | //BEGIN Includes |
25 | #include "cardview.h" | 25 | #include "cardview.h" |
26 | 26 | ||
27 | #include <limits.h> | 27 | #include <limits.h> |
28 | 28 | ||
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qstyle.h> | 33 | #include <qstyle.h> |
34 | #include <qcursor.h> | 34 | #include <qcursor.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | 36 | ||
37 | #include "kabprefs.h" | 37 | #include "kabprefs.h" |
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <kglobalsettings.h> | 39 | #include <kglobalsettings.h> |
40 | //END includes | 40 | //END includes |
41 | 41 | ||
42 | #define MIN_ITEM_WIDTH 80 | 42 | #define MIN_ITEM_WIDTH 80 |
43 | 43 | ||
44 | //BEGIN Helpers | 44 | //BEGIN Helpers |
45 | ////////////////////////////////////// | 45 | ////////////////////////////////////// |
46 | // CardViewTip | 46 | // CardViewTip |
47 | class CardViewTip : public QLabel { | 47 | class CardViewTip : public QLabel { |
48 | public: | 48 | public: |
49 | CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name ) | 49 | CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name ) |
50 | { | 50 | { |
51 | setPalette( QToolTip::palette() ); | 51 | setPalette( QToolTip::palette() ); |
52 | setFrameStyle( Panel|Plain ); | 52 | setFrameStyle( Panel|Plain ); |
53 | setMidLineWidth(0); | 53 | setMidLineWidth(0); |
54 | setIndent(1); | 54 | setIndent(1); |
55 | } | 55 | } |
56 | 56 | ||
57 | ~CardViewTip() {}; | 57 | ~CardViewTip() {}; |
58 | protected: | 58 | protected: |
59 | void leaveEvent( QEvent * ) | 59 | void leaveEvent( QEvent * ) |
60 | { | 60 | { |
61 | hide(); | 61 | hide(); |
62 | } | 62 | } |
63 | }; | 63 | }; |
64 | 64 | ||
65 | ////////////////////////////////////// | 65 | ////////////////////////////////////// |
66 | // CardViewItemList | 66 | // CardViewItemList |
67 | 67 | ||
68 | 68 | ||
69 | // | 69 | // |
70 | // Warning: make sure you use findRef() instead of find() to find an | 70 | // Warning: make sure you use findRef() instead of find() to find an |
71 | // item! Only the pointer value is unique in the list. | 71 | // item! Only the pointer value is unique in the list. |
72 | // | 72 | // |
73 | class CardViewItemList : public QPtrList<CardViewItem> | 73 | class CardViewItemList : public QPtrList<CardViewItem> |
74 | { | 74 | { |
75 | protected: | 75 | protected: |
76 | virtual int compareItems(QPtrCollection::Item item1, | 76 | virtual int compareItems(QPtrCollection::Item item1, |
77 | QPtrCollection::Item item2) | 77 | QPtrCollection::Item item2) |
78 | { | 78 | { |
79 | CardViewItem *cItem1 = (CardViewItem*)item1; | 79 | CardViewItem *cItem1 = (CardViewItem*)item1; |
80 | CardViewItem *cItem2 = (CardViewItem*)item2; | 80 | CardViewItem *cItem2 = (CardViewItem*)item2; |
81 | 81 | ||
82 | if ( cItem1 == cItem2 ) | 82 | if ( cItem1 == cItem2 ) |
83 | return 0; | 83 | return 0; |
84 | 84 | ||
85 | if ((cItem1 == 0) || (cItem2 == 0)) | 85 | if ((cItem1 == 0) || (cItem2 == 0)) |
86 | return cItem1 ? -1 : 1; | 86 | return cItem1 ? -1 : 1; |
87 | 87 | ||
88 | if (cItem1->caption() < cItem2->caption()) | 88 | if (cItem1->caption() < cItem2->caption()) |
89 | return -1; | 89 | return -1; |
90 | 90 | ||
91 | else if (cItem1->caption() > cItem2->caption()) | 91 | else if (cItem1->caption() > cItem2->caption()) |
92 | return 1; | 92 | return 1; |
93 | 93 | ||
94 | return 0; | 94 | return 0; |
95 | } | 95 | } |
96 | 96 | ||
97 | private: | 97 | private: |
98 | /*int find( const CardViewItem * ) | 98 | /*int find( const CardViewItem * ) |
99 | { | 99 | { |
100 | qDebug("DON'T USE CardViewItemList::find( item )! Use findRef( item )!"); | 100 | qDebug("DON'T USE CardViewItemList::find( item )! Use findRef( item )!"); |
101 | }*/ | 101 | }*/ |
102 | }; | 102 | }; |
103 | 103 | ||
104 | ////////////////////////////////////// | 104 | ////////////////////////////////////// |
105 | // CardViewSeparator | 105 | // CardViewSeparator |
106 | class CardViewSeparator | 106 | class CardViewSeparator |
107 | { | 107 | { |
108 | friend class CardView; | 108 | friend class CardView; |
109 | 109 | ||
110 | public: | 110 | public: |
111 | CardViewSeparator(CardView *view) | 111 | CardViewSeparator(CardView *view) |
112 | : mView(view) | 112 | : mView(view) |
113 | { | 113 | { |
114 | mRect = QRect(0, 0, view->separatorWidth(), 0); | 114 | mRect = QRect(0, 0, view->separatorWidth(), 0); |
115 | } | 115 | } |
116 | 116 | ||
117 | ~CardViewSeparator() {} | 117 | ~CardViewSeparator() {} |
118 | 118 | ||
119 | void paintSeparator(QPainter *p, QColorGroup &cg) | 119 | void paintSeparator(QPainter *p, QColorGroup &cg) |
120 | { | 120 | { |
121 | p->fillRect(0, 0, mRect.width(), mRect.height(), | 121 | p->fillRect(0, 0, mRect.width(), mRect.height(), |
122 | cg.brush(QColorGroup::Button)); | 122 | cg.brush(QColorGroup::Button)); |
123 | } | 123 | } |
124 | 124 | ||
125 | void repaintSeparator() | 125 | void repaintSeparator() |
126 | { | 126 | { |
127 | mView->repaintContents(mRect); | 127 | mView->repaintContents(mRect); |
128 | } | 128 | } |
129 | 129 | ||
130 | private: | 130 | private: |
131 | CardView *mView; | 131 | CardView *mView; |
132 | QRect mRect; | 132 | QRect mRect; |
133 | }; | 133 | }; |
134 | 134 | ||
135 | //END Helpers | 135 | //END Helpers |
136 | 136 | ||
137 | //BEGIN Private Data | 137 | //BEGIN Private Data |
138 | 138 | ||
139 | class CardViewPrivate | 139 | class CardViewPrivate |
140 | { | 140 | { |
141 | public: | 141 | public: |
142 | CardViewPrivate() | 142 | CardViewPrivate() |
143 | : mSelectionMode( CardView::Multi ), | 143 | : mSelectionMode( CardView::Multi ), |
144 | mDrawCardBorder( true ), | 144 | mDrawCardBorder( true ), |
145 | mDrawFieldLabels( true ), | 145 | mDrawFieldLabels( true ), |
146 | mDrawSeparators( true), | 146 | mDrawSeparators( true), |
147 | mSepWidth( 2 ), | 147 | mSepWidth( 2 ), |
148 | mShowEmptyFields( false ), | 148 | mShowEmptyFields( false ), |
149 | mLayoutDirty( true ), | 149 | mLayoutDirty( true ), |
150 | mLastClickOnItem( false ), | 150 | mLastClickOnItem( false ), |
151 | mItemMargin( 0 ), | 151 | mItemMargin( 0 ), |
152 | mItemSpacing( 10 ), | 152 | mItemSpacing( 10 ), |
153 | mItemWidth( 200 ), | 153 | mItemWidth( 200 ), |
154 | mMaxFieldLines( INT_MAX ), | 154 | mMaxFieldLines( INT_MAX ), |
155 | mCurrentItem( 0L ), | 155 | mCurrentItem( 0L ), |
156 | mLastClickPos( QPoint(0, 0) ), | 156 | mLastClickPos( QPoint(0, 0) ), |
157 | mResizeAnchor(0), | ||
157 | mRubberBandAnchor( 0 ), | 158 | mRubberBandAnchor( 0 ), |
158 | mCompText( QString::null ), | 159 | mCompText( QString::null ) |
159 | mResizeAnchor(0) | ||
160 | {}; | 160 | {}; |
161 | 161 | ||
162 | CardViewItemList mItemList; | 162 | CardViewItemList mItemList; |
163 | QPtrList<CardViewSeparator> mSeparatorList; | 163 | QPtrList<CardViewSeparator> mSeparatorList; |
164 | QFontMetrics *mFm; | 164 | QFontMetrics *mFm; |
165 | QFontMetrics *mBFm; // bold font | 165 | QFontMetrics *mBFm; // bold font |
166 | QFont mHeaderFont; // custom header font | 166 | QFont mHeaderFont; // custom header font |
167 | CardView::SelectionMode mSelectionMode; | 167 | CardView::SelectionMode mSelectionMode; |
168 | bool mDrawCardBorder; | 168 | bool mDrawCardBorder; |
169 | bool mDrawFieldLabels; | 169 | bool mDrawFieldLabels; |
170 | bool mDrawSeparators; | 170 | bool mDrawSeparators; |
171 | int mSepWidth; | 171 | int mSepWidth; |
172 | bool mShowEmptyFields; | 172 | bool mShowEmptyFields; |
173 | bool mLayoutDirty; | 173 | bool mLayoutDirty; |
174 | bool mLastClickOnItem; | 174 | bool mLastClickOnItem; |
175 | uint mItemMargin; // internal margin in items | 175 | uint mItemMargin; // internal margin in items |
176 | uint mItemSpacing; // spacing between items, column seperators and border | 176 | uint mItemSpacing; // spacing between items, column seperators and border |
177 | int mItemWidth; // width of all items | 177 | int mItemWidth; // width of all items |
178 | uint mMaxFieldLines; // Max lines to dispaly pr field | 178 | uint mMaxFieldLines; // Max lines to dispaly pr field |
179 | CardViewItem *mCurrentItem; | 179 | CardViewItem *mCurrentItem; |
180 | QPoint mLastClickPos; | 180 | QPoint mLastClickPos; |
181 | QTimer *mTimer; // times out if mouse rests for more than 500 msecs | 181 | QTimer *mTimer; // times out if mouse rests for more than 500 msecs |
182 | CardViewTip *mTip; // passed to the item under a resting cursor to display full text | 182 | CardViewTip *mTip; // passed to the item under a resting cursor to display full text |
183 | bool mOnSeparator; // set/reset on mouse movement | 183 | bool mOnSeparator; // set/reset on mouse movement |
184 | // for resizing by dragging the separators | 184 | // for resizing by dragging the separators |
185 | int mResizeAnchor; // uint, ulong? the mouse down separator left | 185 | int mResizeAnchor; // uint, ulong? the mouse down separator left |
186 | int mRubberBandAnchor; // for erasing rubber bands | 186 | int mRubberBandAnchor; // for erasing rubber bands |
187 | // data used for resizing. | 187 | // data used for resizing. |
188 | // as they are beeded by each mouse move while resizing, we store them here, | 188 | // as they are beeded by each mouse move while resizing, we store them here, |
189 | // saving 8 calculations in each mouse move. | 189 | // saving 8 calculations in each mouse move. |
190 | int colspace; // amount of space between items pr column | 190 | int colspace; // amount of space between items pr column |
191 | uint first; // the first col to anchor at for painting rubber bands | 191 | uint first; // the first col to anchor at for painting rubber bands |
192 | int firstX; // X position of first in pixel | 192 | int firstX; // X position of first in pixel |
193 | int pressed; // the colummn that was pressed on at resizing start | 193 | int pressed; // the colummn that was pressed on at resizing start |
194 | int span; // pressed - first | 194 | int span; // pressed - first |
195 | // key completion | 195 | // key completion |
196 | QString mCompText; // current completion string | 196 | QString mCompText; // current completion string |
197 | QDateTime mCompUpdated; // ...was updated at this time | 197 | QDateTime mCompUpdated; // ...was updated at this time |
198 | }; | 198 | }; |
199 | 199 | ||
200 | class CardViewItemPrivate | 200 | class CardViewItemPrivate |
201 | { | 201 | { |
202 | public: | 202 | public: |
203 | CardViewItemPrivate() : | 203 | CardViewItemPrivate() : |
204 | x( 0 ), | 204 | mSelected( false ), |
205 | y( 0 ), | 205 | x( 0 ), |
206 | mSelected( false ){}; | 206 | y( 0 ){}; |
207 | 207 | ||
208 | 208 | ||
209 | QString mCaption; | 209 | QString mCaption; |
210 | QPtrList< CardViewItem::Field > mFieldList; | 210 | QPtrList< CardViewItem::Field > mFieldList; |
211 | bool mSelected; | 211 | bool mSelected; |
212 | int x; // horizontal position, set by the view | 212 | int x; // horizontal position, set by the view |
213 | int y; // vertical position, set by the view | 213 | int y; // vertical position, set by the view |
214 | int maxLabelWidth; // the width of the widest label, according to the view font. | 214 | int maxLabelWidth; // the width of the widest label, according to the view font. |
215 | int hcache; // height cache | 215 | int hcache; // height cache |
216 | }; | 216 | }; |
217 | //END Private Data | 217 | //END Private Data |
218 | 218 | ||
219 | //BEGIN CardViewItem | 219 | //BEGIN CardViewItem |
220 | 220 | ||
221 | CardViewItem::CardViewItem(CardView *parent, QString caption) | 221 | CardViewItem::CardViewItem(CardView *parent, QString caption) |
222 | : d(new CardViewItemPrivate()), mView(parent) | 222 | : d(new CardViewItemPrivate()), mView(parent) |
223 | { | 223 | { |
224 | d->mCaption = caption; | 224 | d->mCaption = caption; |
225 | 225 | ||
226 | initialize(); | 226 | initialize(); |
227 | } | 227 | } |
228 | 228 | ||
229 | CardViewItem::~CardViewItem() | 229 | CardViewItem::~CardViewItem() |
230 | { | 230 | { |
231 | // Remove ourself from the view | 231 | // Remove ourself from the view |
232 | if (mView != 0) | 232 | if (mView != 0) |
233 | mView->takeItem(this); | 233 | mView->takeItem(this); |
234 | 234 | ||
235 | delete d; | 235 | delete d; |
236 | d = 0; | 236 | d = 0; |
237 | } | 237 | } |
238 | 238 | ||
239 | void CardViewItem::initialize() | 239 | void CardViewItem::initialize() |
240 | { | 240 | { |
241 | d->mSelected = false; | 241 | d->mSelected = false; |
242 | d->mFieldList.setAutoDelete(true); | 242 | d->mFieldList.setAutoDelete(true); |
243 | d->maxLabelWidth = 0; | 243 | d->maxLabelWidth = 0; |
244 | d->hcache=0; | 244 | d->hcache=0; |
245 | 245 | ||
246 | //calcRect(); | 246 | //calcRect(); |
247 | 247 | ||
248 | // Add ourself to the view | 248 | // Add ourself to the view |
249 | if (mView != 0) | 249 | if (mView != 0) |
250 | mView->insertItem(this); | 250 | mView->insertItem(this); |
251 | } | 251 | } |
252 | 252 | ||
253 | void CardViewItem::paintCard(QPainter *p, QColorGroup &cg) | 253 | void CardViewItem::paintCard(QPainter *p, QColorGroup &cg) |
254 | { | 254 | { |
255 | 255 | ||
256 | if (!mView) | 256 | if (!mView) |
257 | return; | 257 | return; |
258 | 258 | ||
259 | QPen pen; | 259 | QPen pen; |
260 | QBrush brush; | 260 | QBrush brush; |
261 | QFontMetrics fm = *(mView->d->mFm); | 261 | QFontMetrics fm = *(mView->d->mFm); |
262 | QFontMetrics bFm = *(mView->d->mBFm); | 262 | QFontMetrics bFm = *(mView->d->mBFm); |
263 | bool drawLabels = mView->d->mDrawFieldLabels; | 263 | bool drawLabels = mView->d->mDrawFieldLabels; |
264 | bool drawBorder = mView->d->mDrawCardBorder; | 264 | bool drawBorder = mView->d->mDrawCardBorder; |
265 | int mg = mView->itemMargin(); | 265 | int mg = mView->itemMargin(); |
266 | int w = mView->itemWidth() - (mg*2); | 266 | int w = mView->itemWidth() - (mg*2); |
267 | int h = height() - (mg*2); | 267 | int h = height() - (mg*2); |
268 | const int colonWidth( fm.width(":") ); | 268 | const int colonWidth( fm.width(":") ); |
269 | int labelXPos = 2 + mg; | 269 | int labelXPos = 2 + mg; |
270 | int labelWidth = QMIN( w/2 - 4 - mg, d->maxLabelWidth + colonWidth + 4 ); | 270 | int labelWidth = QMIN( w/2 - 4 - mg, d->maxLabelWidth + colonWidth + 4 ); |
271 | int valueXPos = labelWidth + 4 + mg; | 271 | int valueXPos = labelWidth + 4 + mg; |
272 | int valueWidth = w - labelWidth - 4 - mg; | 272 | int valueWidth = w - labelWidth - 4 - mg; |
273 | 273 | ||
274 | p->setFont( mView->font() ); | 274 | p->setFont( mView->font() ); |
275 | labelWidth -= colonWidth; // extra space for the colon | 275 | labelWidth -= colonWidth; // extra space for the colon |
276 | 276 | ||
277 | if (!drawLabels) | 277 | if (!drawLabels) |
278 | { | 278 | { |
279 | valueXPos = labelXPos; | 279 | valueXPos = labelXPos; |
280 | valueWidth = w - 4; | 280 | valueWidth = w - 4; |
281 | } | 281 | } |
282 | 282 | ||
283 | // Draw a simple box | 283 | // Draw a simple box |
284 | if (isSelected()) | 284 | if (isSelected()) |
285 | pen = QPen(cg.highlight(), 1); | 285 | pen = QPen(cg.highlight(), 1); |
286 | else | 286 | else |
287 | pen = QPen(cg.button(), 1); | 287 | pen = QPen(cg.button(), 1); |
288 | p->setPen(pen); | 288 | p->setPen(pen); |
289 | 289 | ||
290 | // Draw the border - this is only draw if the user asks for it. | 290 | // Draw the border - this is only draw if the user asks for it. |
291 | if (drawBorder) | 291 | if (drawBorder) |
292 | p->drawRect( mg, mg, w, h ); | 292 | p->drawRect( mg, mg, w, h ); |
293 | 293 | ||
294 | // set the proper pen color for the caption box | 294 | // set the proper pen color for the caption box |
295 | if (isSelected()) | 295 | if (isSelected()) |
296 | brush = cg.brush(QColorGroup::Highlight); | 296 | brush = cg.brush(QColorGroup::Highlight); |
297 | else | 297 | else |
298 | brush = cg.brush(QColorGroup::Button); | 298 | brush = cg.brush(QColorGroup::Button); |
299 | 299 | ||
300 | p->fillRect(mg, mg, w, 4 + bFm.height(), brush); | 300 | p->fillRect(mg, mg, w, 4 + bFm.height(), brush); |
301 | 301 | ||
302 | // Now paint the caption | 302 | // Now paint the caption |
303 | p->save(); | 303 | p->save(); |
304 | QFont bFont = mView->headerFont(); | 304 | QFont bFont = mView->headerFont(); |
305 | //bFont.setBold(true); | 305 | //bFont.setBold(true); |
306 | p->setFont(bFont); | 306 | p->setFont(bFont); |
307 | if (isSelected()) | 307 | if (isSelected()) |
308 | p->setPen(cg.highlightedText()); | 308 | p->setPen(cg.highlightedText()); |
309 | else | 309 | else |
310 | p->setPen(cg.buttonText()); | 310 | p->setPen(cg.buttonText()); |
311 | p->drawText(2+mg, 2+mg + bFm.ascent()/*bFm.height()*//*-bFm.descent()*//*-bFm.leading()*/, trimString(d->mCaption, w-4, bFm)); | 311 | p->drawText(2+mg, 2+mg + bFm.ascent()/*bFm.height()*//*-bFm.descent()*//*-bFm.leading()*/, trimString(d->mCaption, w-4, bFm)); |
312 | p->restore(); | 312 | p->restore(); |
313 | 313 | ||
314 | // Go through the fields and draw them | 314 | // Go through the fields and draw them |
315 | QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); | 315 | QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); |
316 | QString label, value; | 316 | QString label, value; |
317 | int yPos = mg + 4 + bFm.height()/* + 1*/ + fm.height(); // why the + 1 ??? (anders) | 317 | int yPos = mg + 4 + bFm.height()/* + 1*/ + fm.height(); // why the + 1 ??? (anders) |
318 | p->setPen(cg.text()); | 318 | p->setPen(cg.text()); |
319 | 319 | ||
320 | int fh = fm.height(); | 320 | int fh = fm.height(); |
321 | int cln( 0 ); | 321 | int cln( 0 ); |
322 | QString tmp; | 322 | QString tmp; |
323 | int maxLines = mView->maxFieldLines(); | 323 | int maxLines = mView->maxFieldLines(); |
324 | for (iter.toFirst(); iter.current(); ++iter) | 324 | for (iter.toFirst(); iter.current(); ++iter) |
325 | { | 325 | { |
326 | value = (*iter)->second; | 326 | value = (*iter)->second; |
327 | if ( value.isEmpty() && ! mView->d->mShowEmptyFields ) | 327 | if ( value.isEmpty() && ! mView->d->mShowEmptyFields ) |
328 | continue; | 328 | continue; |
329 | 329 | ||
330 | if (drawLabels) | 330 | if (drawLabels) |
331 | { | 331 | { |
332 | label = trimString((*iter)->first, labelWidth, fm); | 332 | label = trimString((*iter)->first, labelWidth, fm); |
333 | p->drawText(labelXPos, yPos, label + ":"); | 333 | p->drawText(labelXPos, yPos, label + ":"); |
334 | } | 334 | } |
335 | /* US original | 335 | /* US original |
336 | for (cln=0; cln <= maxLines; cln++) | 336 | for (cln=0; cln <= maxLines; cln++) |
337 | { | 337 | { |
338 | tmp = value.section('\n',cln,cln); | 338 | tmp = value.section('\n',cln,cln); |
339 | if ( !tmp.isEmpty() ) p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) ); | 339 | if ( !tmp.isEmpty() ) p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) ); |
340 | else break; | 340 | else break; |
341 | } | 341 | } |
342 | */ | 342 | */ |
343 | 343 | ||
344 | //US new implementation | 344 | //US new implementation |
345 | QStringList strlst = QStringList::split('\n', value, true); | 345 | QStringList strlst = QStringList::split('\n', value, true); |
346 | 346 | ||
347 | for (cln=0; cln <= maxLines && cln <= (int)strlst.count(); cln++) | 347 | for (cln=0; cln <= maxLines && cln <= (int)strlst.count(); cln++) |
348 | { | 348 | { |
349 | tmp = strlst[cln]; | 349 | tmp = strlst[cln]; |
350 | 350 | ||
351 | if ( !tmp.isEmpty() ) | 351 | if ( !tmp.isEmpty() ) |
352 | p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) ); | 352 | p->drawText( valueXPos, yPos + cln*fh, trimString( tmp, valueWidth, fm ) ); |
353 | else | 353 | else |
354 | break; | 354 | break; |
355 | 355 | ||
356 | } | 356 | } |
357 | 357 | ||
358 | if ( cln == 0 ) cln = 1; | 358 | if ( cln == 0 ) cln = 1; |
359 | yPos += cln * fh + 2; | 359 | yPos += cln * fh + 2; |
360 | } | 360 | } |
361 | 361 | ||
362 | // if we are the current item and the view has focus, draw focus rect | 362 | // if we are the current item and the view has focus, draw focus rect |
363 | if ( mView->currentItem() == this && mView->hasFocus() ) | 363 | if ( mView->currentItem() == this && mView->hasFocus() ) |
364 | { | 364 | { |
365 | /*US | 365 | /*US |
366 | mView->style().drawPrimitive( QStyle::PE_FocusRect, p, | 366 | mView->style().drawPrimitive( QStyle::PE_FocusRect, p, |
367 | QRect(0, 0, mView->itemWidth(), h+(2*mg)), cg, | 367 | QRect(0, 0, mView->itemWidth(), h+(2*mg)), cg, |
368 | QStyle::Style_FocusAtBorder, | 368 | QStyle::Style_FocusAtBorder, |
369 | QStyleOption( isSelected() ? cg.highlight() : cg.base() ) ); | 369 | QStyleOption( isSelected() ? cg.highlight() : cg.base() ) ); |
370 | */ | 370 | */ |
371 | 371 | ||
372 | const QColor pHighl = isSelected() ? cg.highlight() : cg.base(); | 372 | const QColor pHighl = isSelected() ? cg.highlight() : cg.base(); |
373 | const QRect r(0, 0, mView->itemWidth(), h+(2*mg)); | 373 | const QRect r(0, 0, mView->itemWidth(), h+(2*mg)); |
374 | #ifndef DESKTOP_VERSION | 374 | #ifndef DESKTOP_VERSION |
375 | mView->style().drawFocusRect(p, r, cg, &pHighl, true); | 375 | mView->style().drawFocusRect(p, r, cg, &pHighl, true); |
376 | #endif | 376 | #endif |
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | const QString &CardViewItem::caption() const | 380 | const QString &CardViewItem::caption() const |
381 | { | 381 | { |
382 | return d->mCaption; | 382 | return d->mCaption; |
383 | } | 383 | } |
384 | 384 | ||
385 | 385 | ||
386 | int CardViewItem::height( bool allowCache ) const | 386 | int CardViewItem::height( bool allowCache ) const |
387 | { | 387 | { |
388 | // use cache | 388 | // use cache |
389 | if ( allowCache && d->hcache ) | 389 | if ( allowCache && d->hcache ) |
390 | return d->hcache; | 390 | return d->hcache; |
391 | 391 | ||
392 | // Base height: | 392 | // Base height: |
393 | // 2 for line width | 393 | // 2 for line width |
394 | // 2 for top caption pad | 394 | // 2 for top caption pad |
395 | // 2 for bottom caption pad | 395 | // 2 for bottom caption pad |
396 | // 2 pad for the end | 396 | // 2 pad for the end |
397 | // + 2 times the advised margin | 397 | // + 2 times the advised margin |
398 | int baseHeight = 8 + ( 2 * mView->itemMargin() ); | 398 | int baseHeight = 8 + ( 2 * mView->itemMargin() ); |
399 | 399 | ||
400 | // size of font for each field | 400 | // size of font for each field |
401 | // 2 pad for each field | 401 | // 2 pad for each field |
402 | 402 | ||
403 | // anders: if the view does not show empty fields, check for value | 403 | // anders: if the view does not show empty fields, check for value |
404 | bool sef = mView->showEmptyFields(); | 404 | bool sef = mView->showEmptyFields(); |
405 | int fh = mView->d->mFm->height();//lineSpacing(); // font height | 405 | int fh = mView->d->mFm->height();//lineSpacing(); // font height |
406 | //int sp = QMAX( 0, 2- mView->d->mFm->leading() ); // field spacing NOTE make a property | 406 | //int sp = QMAX( 0, 2- mView->d->mFm->leading() ); // field spacing NOTE make a property |
407 | int fieldHeight = 0; | 407 | int fieldHeight = 0; |
408 | int lines; | 408 | int lines; |
409 | int maxLines( mView->maxFieldLines() ); | 409 | int maxLines( mView->maxFieldLines() ); |
410 | QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); | 410 | QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); |
411 | for (iter.toFirst(); iter.current(); ++iter) | 411 | for (iter.toFirst(); iter.current(); ++iter) |
412 | { | 412 | { |
413 | if ( !sef && (*iter)->second.isEmpty() ) | 413 | if ( !sef && (*iter)->second.isEmpty() ) |
414 | continue; | 414 | continue; |
415 | lines = QMIN( (*iter)->second.contains('\n') + 1, maxLines ); | 415 | lines = QMIN( (*iter)->second.contains('\n') + 1, maxLines ); |
416 | fieldHeight += ( lines * fh ) + 2;//sp; | 416 | fieldHeight += ( lines * fh ) + 2;//sp; |
417 | } | 417 | } |
418 | 418 | ||
419 | // height of caption font (bold) | 419 | // height of caption font (bold) |
420 | fieldHeight += mView->d->mBFm->height(); | 420 | fieldHeight += mView->d->mBFm->height(); |
421 | d->hcache = baseHeight + fieldHeight; | 421 | d->hcache = baseHeight + fieldHeight; |
422 | return d->hcache; | 422 | return d->hcache; |
423 | } | 423 | } |
424 | 424 | ||
425 | bool CardViewItem::isSelected() const | 425 | bool CardViewItem::isSelected() const |
426 | { | 426 | { |
427 | return d->mSelected; | 427 | return d->mSelected; |
428 | } | 428 | } |
429 | 429 | ||
430 | void CardViewItem::setSelected(bool selected) | 430 | void CardViewItem::setSelected(bool selected) |
431 | { | 431 | { |
432 | d->mSelected = selected; | 432 | d->mSelected = selected; |
433 | } | 433 | } |
434 | 434 | ||
435 | void CardViewItem::insertField(const QString &label, const QString &value) | 435 | void CardViewItem::insertField(const QString &label, const QString &value) |
436 | { | 436 | { |
437 | CardViewItem::Field *f = new CardViewItem::Field(label, value); | 437 | CardViewItem::Field *f = new CardViewItem::Field(label, value); |
438 | d->mFieldList.append(f); | 438 | d->mFieldList.append(f); |
439 | d->hcache=0; | 439 | d->hcache=0; |
440 | 440 | ||
441 | if (mView) | 441 | if (mView) |
442 | { | 442 | { |
443 | mView->setLayoutDirty(true); | 443 | mView->setLayoutDirty(true); |
444 | d->maxLabelWidth = QMAX( mView->d->mFm->width( label ), d->maxLabelWidth ); | 444 | d->maxLabelWidth = QMAX( mView->d->mFm->width( label ), d->maxLabelWidth ); |
445 | } | 445 | } |
446 | } | 446 | } |
447 | 447 | ||
448 | void CardViewItem::removeField(const QString &label) | 448 | void CardViewItem::removeField(const QString &label) |
449 | { | 449 | { |
450 | CardViewItem::Field *f; | 450 | CardViewItem::Field *f; |
451 | 451 | ||
452 | QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); | 452 | QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); |
453 | for (iter.toFirst(); iter.current(); ++iter) | 453 | for (iter.toFirst(); iter.current(); ++iter) |
454 | { | 454 | { |
455 | f = *iter; | 455 | f = *iter; |
456 | if (f->first == label) | 456 | if (f->first == label) |
457 | break; | 457 | break; |
458 | } | 458 | } |
459 | 459 | ||
460 | if (*iter) | 460 | if (*iter) |
461 | d->mFieldList.remove(*iter); | 461 | d->mFieldList.remove(*iter); |
462 | d->hcache = 0; | 462 | d->hcache = 0; |
463 | 463 | ||
464 | if (mView) | 464 | if (mView) |
465 | mView->setLayoutDirty(true); | 465 | mView->setLayoutDirty(true); |
466 | } | 466 | } |
467 | 467 | ||
468 | void CardViewItem::clearFields() | 468 | void CardViewItem::clearFields() |
469 | { | 469 | { |
470 | d->mFieldList.clear(); | 470 | d->mFieldList.clear(); |
471 | d->hcache = 0; | 471 | d->hcache = 0; |
472 | 472 | ||
473 | if (mView) | 473 | if (mView) |
474 | mView->setLayoutDirty(true); | 474 | mView->setLayoutDirty(true); |
475 | } | 475 | } |
476 | 476 | ||
477 | QString CardViewItem::trimString(const QString &text, int width, | 477 | QString CardViewItem::trimString(const QString &text, int width, |
478 | QFontMetrics &fm) | 478 | QFontMetrics &fm) |
479 | { | 479 | { |
480 | if (fm.width(text) <= width) | 480 | if (fm.width(text) <= width) |
481 | return text; | 481 | return text; |
482 | 482 | ||
483 | QString dots = "..."; | 483 | QString dots = "..."; |
484 | int dotWidth = fm.width(dots); | 484 | int dotWidth = fm.width(dots); |
485 | QString trimmed; | 485 | QString trimmed; |
486 | int charNum = 0; | 486 | int charNum = 0; |
487 | 487 | ||
488 | while (fm.width(trimmed) + dotWidth < width) | 488 | while (fm.width(trimmed) + dotWidth < width) |
489 | { | 489 | { |
490 | trimmed += text[charNum]; | 490 | trimmed += text[charNum]; |
491 | charNum++; | 491 | charNum++; |
492 | } | 492 | } |
493 | 493 | ||
494 | // Now trim the last char, since it put the width over the top | 494 | // Now trim the last char, since it put the width over the top |
495 | trimmed = trimmed.left(trimmed.length()-1); | 495 | trimmed = trimmed.left(trimmed.length()-1); |
496 | trimmed += dots; | 496 | trimmed += dots; |
497 | 497 | ||
498 | return trimmed; | 498 | return trimmed; |
499 | } | 499 | } |
500 | 500 | ||
501 | CardViewItem *CardViewItem::nextItem() | 501 | CardViewItem *CardViewItem::nextItem() |
502 | { | 502 | { |
503 | CardViewItem *item = 0; | 503 | CardViewItem *item = 0; |
504 | 504 | ||
505 | if (mView) | 505 | if (mView) |
506 | item = mView->itemAfter(this); | 506 | item = mView->itemAfter(this); |
507 | 507 | ||
508 | return item; | 508 | return item; |
509 | } | 509 | } |
510 | 510 | ||
511 | void CardViewItem::repaintCard() | 511 | void CardViewItem::repaintCard() |
512 | { | 512 | { |
513 | if (mView) | 513 | if (mView) |
514 | mView->repaintItem(this); | 514 | mView->repaintItem(this); |
515 | } | 515 | } |
516 | 516 | ||
517 | void CardViewItem::setCaption(const QString &caption) | 517 | void CardViewItem::setCaption(const QString &caption) |
518 | { | 518 | { |
519 | d->mCaption = caption; | 519 | d->mCaption = caption; |
520 | repaintCard(); | 520 | repaintCard(); |
521 | } | 521 | } |
522 | 522 | ||
523 | QString CardViewItem::fieldValue(const QString &label) | 523 | QString CardViewItem::fieldValue(const QString &label) |
524 | { | 524 | { |
525 | QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); | 525 | QPtrListIterator< CardViewItem::Field > iter(d->mFieldList); |
526 | for (iter.toFirst(); iter.current(); ++iter) | 526 | for (iter.toFirst(); iter.current(); ++iter) |
527 | if ((*iter)->first == label) | 527 | if ((*iter)->first == label) |
528 | return (*iter)->second; | 528 | return (*iter)->second; |
529 | 529 | ||
530 | return QString(); | 530 | return QString(); |
531 | } | 531 | } |
532 | 532 | ||
533 | 533 | ||
534 | void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip ) | 534 | void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip ) |
535 | { | 535 | { |
536 | bool trimmed( false ); | 536 | bool trimmed( false ); |
537 | QString s; | 537 | QString s; |
538 | int mrg = mView->itemMargin(); | 538 | int mrg = mView->itemMargin(); |
539 | int y = mView->d->mBFm->height() + 6 + mrg; | 539 | int y = mView->d->mBFm->height() + 6 + mrg; |
540 | int w = mView->itemWidth() - (2*mrg); | 540 | int w = mView->itemWidth() - (2*mrg); |
541 | int lw; | 541 | int lw; |
542 | bool drawLabels = mView->drawFieldLabels(); | 542 | bool drawLabels = mView->drawFieldLabels(); |
543 | bool isLabel = drawLabels && itempos.x() < w/2 ? true : false; | 543 | bool isLabel = drawLabels && itempos.x() < w/2 ? true : false; |
544 | 544 | ||
545 | if ( itempos.y() < y ) | 545 | if ( itempos.y() < y ) |
546 | { | 546 | { |
547 | if ( itempos.y() < 8 + mrg || itempos.y() > y - 4 ) | 547 | if ( itempos.y() < 8 + mrg || itempos.y() > y - 4 ) |
548 | return; | 548 | return; |
549 | // this is the caption | 549 | // this is the caption |
550 | s = caption(); | 550 | s = caption(); |
551 | trimmed = mView->d->mBFm->width( s ) > w - 4; | 551 | trimmed = mView->d->mBFm->width( s ) > w - 4; |
552 | y = 2 + mrg; | 552 | y = 2 + mrg; |
553 | lw = 0; | 553 | lw = 0; |
554 | isLabel=true; | 554 | isLabel=true; |
555 | } else { | 555 | } else { |
556 | // find the field | 556 | // find the field |
557 | Field *f = fieldAt( itempos ); | 557 | Field *f = fieldAt( itempos ); |
558 | if ( !f || ( !mView->showEmptyFields() && f->second.isEmpty() ) ) | 558 | if ( !f || ( !mView->showEmptyFields() && f->second.isEmpty() ) ) |
559 | return; | 559 | return; |
560 | 560 | ||
561 | // y position: | 561 | // y position: |
562 | // header font height + 4px hader margin + 2px leading + item margin | 562 | // header font height + 4px hader margin + 2px leading + item margin |
563 | // + actual field index * (fontheight + 2px leading) | 563 | // + actual field index * (fontheight + 2px leading) |
564 | int maxLines = mView->maxFieldLines(); | 564 | int maxLines = mView->maxFieldLines(); |
565 | bool se = mView->showEmptyFields(); | 565 | bool se = mView->showEmptyFields(); |
566 | int fh = mView->d->mFm->height(); | 566 | int fh = mView->d->mFm->height(); |
567 | // { | 567 | // { |
568 | Field *_f; | 568 | Field *_f; |
569 | for (_f = d->mFieldList.first(); _f != f; _f = d->mFieldList.next()) | 569 | for (_f = d->mFieldList.first(); _f != f; _f = d->mFieldList.next()) |
570 | if ( se || ! _f->second.isEmpty() ) | 570 | if ( se || ! _f->second.isEmpty() ) |
571 | y += ( QMIN(_f->second.contains('\n')+1, maxLines) * fh ) + 2; | 571 | y += ( QMIN(_f->second.contains('\n')+1, maxLines) * fh ) + 2; |
572 | // } | 572 | // } |
573 | if ( isLabel && itempos.y() > y + fh ) | 573 | if ( isLabel && itempos.y() > y + fh ) |
574 | return; | 574 | return; |
575 | // label or data? | 575 | // label or data? |
576 | s = isLabel ? f->first : f->second; | 576 | s = isLabel ? f->first : f->second; |
577 | // trimmed? | 577 | // trimmed? |
578 | int colonWidth = mView->d->mFm->width(":"); | 578 | int colonWidth = mView->d->mFm->width(":"); |
579 | lw = drawLabels ? // label width | 579 | lw = drawLabels ? // label width |
580 | QMIN( w/2 - 4 - mrg, d->maxLabelWidth + colonWidth + 4 ) : | 580 | QMIN( w/2 - 4 - mrg, d->maxLabelWidth + colonWidth + 4 ) : |
581 | 0; | 581 | 0; |
582 | int mw = isLabel ? lw - colonWidth : w - lw - (mrg*2); // max width for string | 582 | int mw = isLabel ? lw - colonWidth : w - lw - (mrg*2); // max width for string |
583 | if ( isLabel ) | 583 | if ( isLabel ) |
584 | { | 584 | { |
585 | trimmed = mView->d->mFm->width( s ) > mw - colonWidth; | 585 | trimmed = mView->d->mFm->width( s ) > mw - colonWidth; |
586 | } else { | 586 | } else { |
587 | QRect r( mView->d->mFm->boundingRect( 0, 0, INT_MAX, INT_MAX, Qt::AlignTop|Qt::AlignLeft, s ) ); | 587 | QRect r( mView->d->mFm->boundingRect( 0, 0, INT_MAX, INT_MAX, Qt::AlignTop|Qt::AlignLeft, s ) ); |
588 | trimmed = r.width() > mw || r.height()/fh > QMIN(s.contains('\n') + 1, maxLines); | 588 | trimmed = r.width() > mw || r.height()/fh > QMIN(s.contains('\n') + 1, maxLines); |
589 | } | 589 | } |
590 | } | 590 | } |
591 | if ( trimmed ) | 591 | if ( trimmed ) |
592 | { | 592 | { |
593 | tip->setFont( (isLabel && !lw) ? mView->headerFont() : mView->font() ); // if condition is true, a header | 593 | tip->setFont( (isLabel && !lw) ? mView->headerFont() : mView->font() ); // if condition is true, a header |
594 | tip->setText( s ); | 594 | tip->setText( s ); |
595 | tip->adjustSize(); | 595 | tip->adjustSize(); |
596 | // find a proper position | 596 | // find a proper position |
597 | int lx; | 597 | int lx; |
598 | lx = isLabel || !drawLabels ? mrg : lw + mrg + 2 /*-1*/; | 598 | lx = isLabel || !drawLabels ? mrg : lw + mrg + 2 /*-1*/; |
599 | QPoint pnt(mView->contentsToViewport( QPoint(d->x, d->y) )); | 599 | QPoint pnt(mView->contentsToViewport( QPoint(d->x, d->y) )); |
600 | pnt += QPoint(lx, y); | 600 | pnt += QPoint(lx, y); |
601 | if ( pnt.x() < 0 ) | 601 | if ( pnt.x() < 0 ) |
602 | pnt.setX( 0 ); | 602 | pnt.setX( 0 ); |
603 | if ( pnt.x() + tip->width() > mView->visibleWidth() ) | 603 | if ( pnt.x() + tip->width() > mView->visibleWidth() ) |
604 | pnt.setX( mView->visibleWidth() - tip->width() ); | 604 | pnt.setX( mView->visibleWidth() - tip->width() ); |
605 | if ( pnt.y() + tip->height() > mView->visibleHeight() ) | 605 | if ( pnt.y() + tip->height() > mView->visibleHeight() ) |
606 | pnt.setY( QMAX( 0, mView->visibleHeight() - tip->height() ) ); | 606 | pnt.setY( QMAX( 0, mView->visibleHeight() - tip->height() ) ); |
607 | // show | 607 | // show |
608 | tip->move( pnt ); | 608 | tip->move( pnt ); |
609 | tip->show(); | 609 | tip->show(); |
610 | } | 610 | } |
611 | } | 611 | } |
612 | 612 | ||
613 | CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const | 613 | CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const |
614 | { | 614 | { |
615 | int ypos = mView->d->mBFm->height() + 7 + mView->d->mItemMargin; | 615 | int ypos = mView->d->mBFm->height() + 7 + mView->d->mItemMargin; |
616 | int iy = itempos.y(); | 616 | int iy = itempos.y(); |
617 | // skip below caption | 617 | // skip below caption |
618 | if ( iy <= ypos ) | 618 | if ( iy <= ypos ) |
619 | return 0; | 619 | return 0; |
620 | // try find a field | 620 | // try find a field |
621 | bool showEmpty = mView->showEmptyFields(); | 621 | bool showEmpty = mView->showEmptyFields(); |
622 | int fh = mView->d->mFm->height(); | 622 | int fh = mView->d->mFm->height(); |
623 | int maxLines = mView->maxFieldLines(); | 623 | int maxLines = mView->maxFieldLines(); |
624 | Field *f; | 624 | Field *f; |
625 | for ( f = d->mFieldList.first(); f; f = d->mFieldList.next() ) | 625 | for ( f = d->mFieldList.first(); f; f = d->mFieldList.next() ) |
626 | { | 626 | { |
627 | if ( showEmpty || !f->second.isEmpty() ) | 627 | if ( showEmpty || !f->second.isEmpty() ) |
628 | ypos += ( QMIN( f->second.contains('\n')+1, maxLines ) *fh)+2; | 628 | ypos += ( QMIN( f->second.contains('\n')+1, maxLines ) *fh)+2; |
629 | if ( iy <= ypos ) | 629 | if ( iy <= ypos ) |
630 | break; | 630 | break; |
631 | } | 631 | } |
632 | return f ? f : 0; | 632 | return f ? f : 0; |
633 | } | 633 | } |
634 | //END CardViewItem | 634 | //END CardViewItem |
635 | 635 | ||
636 | //BEGIN CardView | 636 | //BEGIN CardView |
637 | 637 | ||
638 | CardView::CardView(QWidget *parent, const char *name) | 638 | CardView::CardView(QWidget *parent, const char *name) |
639 | : QScrollView(parent, name), | 639 | : QScrollView(parent, name), |
640 | d(new CardViewPrivate()) | 640 | d(new CardViewPrivate()) |
641 | { | 641 | { |
642 | d->mItemList.setAutoDelete(true); | 642 | d->mItemList.setAutoDelete(true); |
643 | d->mSeparatorList.setAutoDelete(true); | 643 | d->mSeparatorList.setAutoDelete(true); |
644 | 644 | ||
645 | QFont f = font(); | 645 | QFont f = font(); |
646 | d->mFm = new QFontMetrics(f); | 646 | d->mFm = new QFontMetrics(f); |
647 | f.setBold(true); | 647 | f.setBold(true); |
648 | d->mHeaderFont = f; | 648 | d->mHeaderFont = f; |
649 | d->mBFm = new QFontMetrics(f); | 649 | d->mBFm = new QFontMetrics(f); |
650 | d->mTip = ( new CardViewTip( viewport() ) ), | 650 | d->mTip = ( new CardViewTip( viewport() ) ), |
651 | d->mTip->hide(); | 651 | d->mTip->hide(); |
652 | d->mTimer = ( new QTimer(this, "mouseTimer") ), | 652 | d->mTimer = ( new QTimer(this, "mouseTimer") ), |
653 | 653 | ||
654 | viewport()->setMouseTracking( true ); | 654 | viewport()->setMouseTracking( true ); |
655 | viewport()->setFocusProxy(this); | 655 | viewport()->setFocusProxy(this); |
656 | viewport()->setFocusPolicy(WheelFocus); | 656 | viewport()->setFocusPolicy(WheelFocus); |
657 | viewport()->setBackgroundMode(PaletteBase); | 657 | viewport()->setBackgroundMode(PaletteBase); |
658 | 658 | ||
659 | connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) ); | 659 | connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) ); |
660 | 660 | ||
661 | //US setBackgroundMode(PaletteBackground, PaletteBase); | 661 | //US setBackgroundMode(PaletteBackground, PaletteBase); |
662 | setBackgroundMode(PaletteBackground); | 662 | setBackgroundMode(PaletteBackground); |
663 | 663 | ||
664 | // no reason for a vertical scrollbar | 664 | // no reason for a vertical scrollbar |
665 | setVScrollBarMode(AlwaysOff); | 665 | setVScrollBarMode(AlwaysOff); |
666 | } | 666 | } |
667 | 667 | ||
668 | CardView::~CardView() | 668 | CardView::~CardView() |
669 | { | 669 | { |
670 | delete d->mFm; | 670 | delete d->mFm; |
671 | delete d->mBFm; | 671 | delete d->mBFm; |
672 | delete d; | 672 | delete d; |
673 | d = 0; | 673 | d = 0; |
674 | } | 674 | } |
675 | 675 | ||
676 | void CardView::insertItem(CardViewItem *item) | 676 | void CardView::insertItem(CardViewItem *item) |
677 | { | 677 | { |
678 | d->mItemList.inSort(item); | 678 | d->mItemList.inSort(item); |
679 | setLayoutDirty(true); | 679 | setLayoutDirty(true); |
680 | } | 680 | } |
681 | 681 | ||
682 | void CardView::takeItem(CardViewItem *item) | 682 | void CardView::takeItem(CardViewItem *item) |
683 | { | 683 | { |
684 | if ( d->mCurrentItem == item ) | 684 | if ( d->mCurrentItem == item ) |
685 | d->mCurrentItem = item->nextItem(); | 685 | d->mCurrentItem = item->nextItem(); |
686 | d->mItemList.take(d->mItemList.findRef(item)); | 686 | d->mItemList.take(d->mItemList.findRef(item)); |
687 | 687 | ||
688 | setLayoutDirty(true); | 688 | setLayoutDirty(true); |
689 | } | 689 | } |
690 | 690 | ||
691 | void CardView::clear() | 691 | void CardView::clear() |
692 | { | 692 | { |
693 | d->mItemList.clear(); | 693 | d->mItemList.clear(); |
694 | 694 | ||
695 | setLayoutDirty(true); | 695 | setLayoutDirty(true); |
696 | } | 696 | } |
697 | 697 | ||
698 | CardViewItem *CardView::currentItem() | 698 | CardViewItem *CardView::currentItem() |
699 | { | 699 | { |
700 | if ( ! d->mCurrentItem && d->mItemList.count() ) | 700 | if ( ! d->mCurrentItem && d->mItemList.count() ) |
701 | d->mCurrentItem = d->mItemList.first(); | 701 | d->mCurrentItem = d->mItemList.first(); |
702 | return d->mCurrentItem; | 702 | return d->mCurrentItem; |
703 | } | 703 | } |
704 | 704 | ||
705 | void CardView::setCurrentItem( CardViewItem *item ) | 705 | void CardView::setCurrentItem( CardViewItem *item ) |
706 | { | 706 | { |
707 | if ( !item ) | 707 | if ( !item ) |
708 | return; | 708 | return; |
709 | else if ( item->cardView() != this ) | 709 | else if ( item->cardView() != this ) |
710 | { | 710 | { |
711 | kdDebug(5720)<<"CardView::setCurrentItem: Item ("<<item<<") not owned! Backing out.."<<endl; | 711 | kdDebug(5720)<<"CardView::setCurrentItem: Item ("<<item<<") not owned! Backing out.."<<endl; |
712 | return; | 712 | return; |
713 | } | 713 | } |
714 | else if ( item == currentItem() ) | 714 | else if ( item == currentItem() ) |
715 | { | 715 | { |
716 | return; | 716 | return; |
717 | } | 717 | } |
718 | 718 | ||
719 | if ( d->mSelectionMode == Single ) | 719 | if ( d->mSelectionMode == Single ) |
720 | { | 720 | { |
721 | setSelected( item, true ); | 721 | setSelected( item, true ); |
722 | } | 722 | } |
723 | else | 723 | else |
724 | { | 724 | { |
725 | CardViewItem *it = d->mCurrentItem; | 725 | CardViewItem *it = d->mCurrentItem; |
726 | d->mCurrentItem = item; | 726 | d->mCurrentItem = item; |
727 | if ( it ) | 727 | if ( it ) |
728 | it->repaintCard(); | 728 | it->repaintCard(); |
729 | item->repaintCard(); | 729 | item->repaintCard(); |
730 | } | 730 | } |
731 | if ( ! d->mOnSeparator ) | 731 | if ( ! d->mOnSeparator ) |
732 | ensureItemVisible( item ); | 732 | ensureItemVisible( item ); |
733 | emit currentChanged( item ); | 733 | emit currentChanged( item ); |
734 | } | 734 | } |
735 | 735 | ||
736 | CardViewItem *CardView::itemAt(const QPoint &viewPos) | 736 | CardViewItem *CardView::itemAt(const QPoint &viewPos) |
737 | { | 737 | { |
738 | CardViewItem *item = 0; | 738 | CardViewItem *item = 0; |
739 | QPtrListIterator<CardViewItem> iter(d->mItemList); | 739 | QPtrListIterator<CardViewItem> iter(d->mItemList); |
740 | bool found = false; | 740 | bool found = false; |
741 | for (iter.toFirst(); iter.current() && !found; ++iter) | 741 | for (iter.toFirst(); iter.current() && !found; ++iter) |
742 | { | 742 | { |
743 | item = *iter; | 743 | item = *iter; |
744 | //if (item->d->mRect.contains(viewPos)) | 744 | //if (item->d->mRect.contains(viewPos)) |
745 | if (QRect(item->d->x, item->d->y, d->mItemWidth, item->height()).contains(viewPos)) | 745 | if (QRect(item->d->x, item->d->y, d->mItemWidth, item->height()).contains(viewPos)) |
746 | found = true; | 746 | found = true; |
747 | } | 747 | } |
748 | 748 | ||
749 | if (found) | 749 | if (found) |
750 | return item; | 750 | return item; |
751 | 751 | ||
752 | return 0; | 752 | return 0; |
753 | } | 753 | } |
754 | 754 | ||
755 | QRect CardView::itemRect(const CardViewItem *item) | 755 | QRect CardView::itemRect(const CardViewItem *item) |
756 | { | 756 | { |
757 | //return item->d->mRect; | 757 | //return item->d->mRect; |
758 | return QRect(item->d->x, item->d->y, d->mItemWidth, item->height()); | 758 | return QRect(item->d->x, item->d->y, d->mItemWidth, item->height()); |
759 | } | 759 | } |
760 | 760 | ||
761 | void CardView::ensureItemVisible(const CardViewItem *item) | 761 | void CardView::ensureItemVisible(const CardViewItem *item) |
762 | { | 762 | { |
763 | ensureVisible(item->d->x , item->d->y, d->mItemSpacing, 0); | 763 | ensureVisible(item->d->x , item->d->y, d->mItemSpacing, 0); |
764 | ensureVisible(item->d->x + d->mItemWidth, item->d->y, d->mItemSpacing, 0); | 764 | ensureVisible(item->d->x + d->mItemWidth, item->d->y, d->mItemSpacing, 0); |
765 | } | 765 | } |
766 | 766 | ||
767 | void CardView::repaintItem(const CardViewItem *item) | 767 | void CardView::repaintItem(const CardViewItem *item) |
768 | { | 768 | { |
769 | //repaintContents(item->d->mRect); | 769 | //repaintContents(item->d->mRect); |
770 | repaintContents( QRect(item->d->x, item->d->y, d->mItemWidth, item->height()) ); | 770 | repaintContents( QRect(item->d->x, item->d->y, d->mItemWidth, item->height()) ); |
771 | } | 771 | } |
772 | 772 | ||
773 | void CardView::setSelectionMode(CardView::SelectionMode mode) | 773 | void CardView::setSelectionMode(CardView::SelectionMode mode) |
774 | { | 774 | { |
775 | selectAll(false); | 775 | selectAll(false); |
776 | 776 | ||
777 | d->mSelectionMode = mode; | 777 | d->mSelectionMode = mode; |
778 | } | 778 | } |
779 | 779 | ||
780 | CardView::SelectionMode CardView::selectionMode() const | 780 | CardView::SelectionMode CardView::selectionMode() const |
781 | { | 781 | { |
782 | return d->mSelectionMode; | 782 | return d->mSelectionMode; |
783 | } | 783 | } |
784 | 784 | ||
785 | void CardView::selectAll(bool state) | 785 | void CardView::selectAll(bool state) |
786 | { | 786 | { |
787 | QPtrListIterator<CardViewItem> iter(d->mItemList); | 787 | QPtrListIterator<CardViewItem> iter(d->mItemList); |
788 | if (!state) | 788 | if (!state) |
789 | { | 789 | { |
790 | for (iter.toFirst(); iter.current(); ++iter) | 790 | for (iter.toFirst(); iter.current(); ++iter) |
791 | { | 791 | { |
792 | if ((*iter)->isSelected()) | 792 | if ((*iter)->isSelected()) |
793 | { | 793 | { |
794 | (*iter)->setSelected(false); | 794 | (*iter)->setSelected(false); |
795 | (*iter)->repaintCard(); | 795 | (*iter)->repaintCard(); |
796 | } | 796 | } |
797 | } | 797 | } |
798 | //emit selectionChanged(); // WARNING FIXME | 798 | //emit selectionChanged(); // WARNING FIXME |
799 | emit selectionChanged(0); | 799 | emit selectionChanged(0); |
800 | } | 800 | } |
801 | else if (d->mSelectionMode != CardView::Single) | 801 | else if (d->mSelectionMode != CardView::Single) |
802 | { | 802 | { |
803 | for (iter.toFirst(); iter.current(); ++iter) | 803 | for (iter.toFirst(); iter.current(); ++iter) |
804 | { | 804 | { |
805 | (*iter)->setSelected(true); | 805 | (*iter)->setSelected(true); |
806 | } | 806 | } |
807 | 807 | ||
808 | if (d->mItemList.count() > 0) | 808 | if (d->mItemList.count() > 0) |
809 | { | 809 | { |
810 | // emit, since there must have been at least one selected | 810 | // emit, since there must have been at least one selected |
811 | emit selectionChanged(); | 811 | emit selectionChanged(); |
812 | //repaint();//??? | 812 | //repaint();//??? |
813 | viewport()->update(); | 813 | viewport()->update(); |
814 | } | 814 | } |
815 | } | 815 | } |
816 | } | 816 | } |
817 | 817 | ||
818 | void CardView::setSelected(CardViewItem *item, bool selected) | 818 | void CardView::setSelected(CardViewItem *item, bool selected) |
819 | { | 819 | { |
820 | if ((item == 0) || (item->isSelected() == selected)) | 820 | if ((item == 0) || (item->isSelected() == selected)) |
821 | return; | 821 | return; |
822 | 822 | ||
823 | if ( selected && d->mCurrentItem != item ) | 823 | if ( selected && d->mCurrentItem != item ) |
824 | { | 824 | { |
825 | CardViewItem *it = d->mCurrentItem; | 825 | CardViewItem *it = d->mCurrentItem; |
826 | d->mCurrentItem = item; | 826 | d->mCurrentItem = item; |
827 | if ( it ) | 827 | if ( it ) |
828 | it->repaintCard(); | 828 | it->repaintCard(); |
829 | } | 829 | } |
830 | 830 | ||
831 | if (d->mSelectionMode == CardView::Single) | 831 | if (d->mSelectionMode == CardView::Single) |
832 | { | 832 | { |
833 | bool b = signalsBlocked(); | 833 | bool b = signalsBlocked(); |
834 | blockSignals(true); | 834 | blockSignals(true); |
835 | selectAll(false); | 835 | selectAll(false); |
836 | blockSignals(b); | 836 | blockSignals(b); |
837 | 837 | ||
838 | if (selected) | 838 | if (selected) |
839 | { | 839 | { |
840 | item->setSelected(selected); | 840 | item->setSelected(selected); |
841 | item->repaintCard(); | 841 | item->repaintCard(); |
842 | emit selectionChanged(); | 842 | emit selectionChanged(); |
843 | emit selectionChanged(item); | 843 | emit selectionChanged(item); |
844 | } | 844 | } |
845 | else | 845 | else |
846 | { | 846 | { |
847 | emit selectionChanged(); | 847 | emit selectionChanged(); |
848 | emit selectionChanged(0); | 848 | emit selectionChanged(0); |
849 | } | 849 | } |
850 | } | 850 | } |
851 | else if (d->mSelectionMode == CardView::Multi) | 851 | else if (d->mSelectionMode == CardView::Multi) |
852 | { | 852 | { |
853 | item->setSelected(selected); | 853 | item->setSelected(selected); |
854 | item->repaintCard(); | 854 | item->repaintCard(); |
855 | emit selectionChanged(); | 855 | emit selectionChanged(); |
856 | } | 856 | } |
857 | else if (d->mSelectionMode == CardView::Extended) | 857 | else if (d->mSelectionMode == CardView::Extended) |
858 | { | 858 | { |
859 | bool b = signalsBlocked(); | 859 | bool b = signalsBlocked(); |
860 | blockSignals(true); | 860 | blockSignals(true); |
861 | selectAll(false); | 861 | selectAll(false); |
862 | blockSignals(b); | 862 | blockSignals(b); |
863 | 863 | ||
864 | item->setSelected(selected); | 864 | item->setSelected(selected); |
865 | item->repaintCard(); | 865 | item->repaintCard(); |
866 | emit selectionChanged(); | 866 | emit selectionChanged(); |
867 | } | 867 | } |
868 | } | 868 | } |
869 | 869 | ||
870 | bool CardView::isSelected(CardViewItem *item) const | 870 | bool CardView::isSelected(CardViewItem *item) const |
871 | { | 871 | { |
872 | return (item && item->isSelected()); | 872 | return (item && item->isSelected()); |
873 | } | 873 | } |
874 | 874 | ||
875 | CardViewItem *CardView::selectedItem() const | 875 | CardViewItem *CardView::selectedItem() const |
876 | { | 876 | { |
877 | // find the first selected item | 877 | // find the first selected item |
878 | QPtrListIterator<CardViewItem> iter(d->mItemList); | 878 | QPtrListIterator<CardViewItem> iter(d->mItemList); |
879 | for (iter.toFirst(); iter.current(); ++iter) | 879 | for (iter.toFirst(); iter.current(); ++iter) |
880 | { | 880 | { |
881 | if ((*iter)->isSelected()) | 881 | if ((*iter)->isSelected()) |
882 | return *iter; | 882 | return *iter; |
883 | } | 883 | } |
884 | 884 | ||
885 | return 0; | 885 | return 0; |
886 | } | 886 | } |
887 | 887 | ||
888 | CardViewItem *CardView::firstItem() const | 888 | CardViewItem *CardView::firstItem() const |
889 | { | 889 | { |
890 | return d->mItemList.first(); | 890 | return d->mItemList.first(); |
891 | } | 891 | } |
892 | 892 | ||
893 | int CardView::childCount() const | 893 | int CardView::childCount() const |
894 | { | 894 | { |
895 | return d->mItemList.count(); | 895 | return d->mItemList.count(); |
896 | } | 896 | } |
897 | /*US | 897 | /*US |
898 | CardViewItem *CardView::findItem(const QString &text, const QString &label, | 898 | CardViewItem *CardView::findItem(const QString &text, const QString &label, |
899 | Qt::StringComparisonMode compare) | 899 | Qt::StringComparisonMode compare) |
900 | { | 900 | { |
901 | // IF the text is empty, we will return null, since empty text will | 901 | // IF the text is empty, we will return null, since empty text will |
902 | // match anything! | 902 | // match anything! |
903 | if (text.isEmpty()) | 903 | if (text.isEmpty()) |
904 | return 0; | 904 | return 0; |
905 | 905 | ||
906 | QPtrListIterator<CardViewItem> iter(d->mItemList); | 906 | QPtrListIterator<CardViewItem> iter(d->mItemList); |
907 | if (compare & Qt::BeginsWith) | 907 | if (compare & Qt::BeginsWith) |
908 | { | 908 | { |
909 | QString value; | 909 | QString value; |
910 | for (iter.toFirst(); iter.current(); ++iter) | 910 | for (iter.toFirst(); iter.current(); ++iter) |
911 | { | 911 | { |
912 | value = (*iter)->fieldValue(label).upper(); | 912 | value = (*iter)->fieldValue(label).upper(); |
913 | if (value.startsWith(text.upper())) | 913 | if (value.startsWith(text.upper())) |
914 | return *iter; | 914 | return *iter; |
915 | } | 915 | } |
916 | } | 916 | } |
917 | else | 917 | else |
918 | { | 918 | { |
919 | kdDebug(5720) << "CardView::findItem: search method not implemented" << endl; | 919 | kdDebug(5720) << "CardView::findItem: search method not implemented" << endl; |
920 | } | 920 | } |
921 | 921 | ||
922 | return 0; | 922 | return 0; |
923 | } | 923 | } |
924 | */ | 924 | */ |
925 | 925 | ||
926 | uint CardView::columnWidth() | 926 | uint CardView::columnWidth() |
927 | { | 927 | { |
928 | return d->mDrawSeparators ? | 928 | return d->mDrawSeparators ? |
929 | d->mItemWidth + ( 2 * d->mItemSpacing ) + d->mSepWidth : | 929 | d->mItemWidth + ( 2 * d->mItemSpacing ) + d->mSepWidth : |
930 | d->mItemWidth + d->mItemSpacing; | 930 | d->mItemWidth + d->mItemSpacing; |
931 | } | 931 | } |
932 | 932 | ||
933 | void CardView::drawContents(QPainter *p, int clipx, int clipy, | 933 | void CardView::drawContents(QPainter *p, int clipx, int clipy, |
934 | int clipw, int cliph) | 934 | int clipw, int cliph) |
935 | { | 935 | { |
936 | QScrollView::drawContents(p, clipx, clipy, clipw, cliph); | 936 | QScrollView::drawContents(p, clipx, clipy, clipw, cliph); |
937 | 937 | ||
938 | if (d->mLayoutDirty) | 938 | if (d->mLayoutDirty) |
939 | calcLayout(); | 939 | calcLayout(); |
940 | 940 | ||
941 | //kdDebug() << "CardView::drawContents: " << clipx << ", " << clipy | 941 | //kdDebug() << "CardView::drawContents: " << clipx << ", " << clipy |
942 | // << ", " << clipw << ", " << cliph << endl; | 942 | // << ", " << clipw << ", " << cliph << endl; |
943 | 943 | ||
944 | QColorGroup cg = viewport()->palette().active(); // allow setting costum colors in the viewport pale | 944 | QColorGroup cg = viewport()->palette().active(); // allow setting costum colors in the viewport pale |
945 | 945 | ||
946 | QRect clipRect(clipx, clipy, clipw, cliph); | 946 | QRect clipRect(clipx, clipy, clipw, cliph); |
947 | QRect cardRect; | 947 | QRect cardRect; |
948 | QRect sepRect; | 948 | QRect sepRect; |
949 | CardViewItem *item; | 949 | CardViewItem *item; |
950 | CardViewSeparator *sep; | 950 | CardViewSeparator *sep; |
951 | 951 | ||
952 | // make sure the viewport is a pure background | 952 | // make sure the viewport is a pure background |
953 | viewport()->erase(clipRect); | 953 | viewport()->erase(clipRect); |
954 | 954 | ||
955 | // Now tell the cards to draw, if they are in the clip region | 955 | // Now tell the cards to draw, if they are in the clip region |
956 | QPtrListIterator<CardViewItem> iter(d->mItemList); | 956 | QPtrListIterator<CardViewItem> iter(d->mItemList); |
957 | for (iter.toFirst(); iter.current(); ++iter) | 957 | for (iter.toFirst(); iter.current(); ++iter) |
958 | { | 958 | { |
959 | item = *iter; | 959 | item = *iter; |
960 | cardRect.setRect( item->d->x, item->d->y, d->mItemWidth, item->height() ); | 960 | cardRect.setRect( item->d->x, item->d->y, d->mItemWidth, item->height() ); |
961 | 961 | ||
962 | if (clipRect.intersects(cardRect) || clipRect.contains(cardRect)) | 962 | if (clipRect.intersects(cardRect) || clipRect.contains(cardRect)) |
963 | { | 963 | { |
964 | //kdDebug() << "\trepainting card at: " << cardRect.x() << ", " | 964 | //kdDebug() << "\trepainting card at: " << cardRect.x() << ", " |
965 | // << cardRect.y() << endl; | 965 | // << cardRect.y() << endl; |
966 | 966 | ||
967 | // Tell the card to paint | 967 | // Tell the card to paint |
968 | p->save(); | 968 | p->save(); |
969 | p->translate(cardRect.x(), cardRect.y()); | 969 | p->translate(cardRect.x(), cardRect.y()); |
970 | item->paintCard(p, cg); | 970 | item->paintCard(p, cg); |
971 | p->restore(); | 971 | p->restore(); |
972 | } | 972 | } |
973 | } | 973 | } |
974 | 974 | ||
975 | // Followed by the separators if they are in the clip region | 975 | // Followed by the separators if they are in the clip region |
976 | QPtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList); | 976 | QPtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList); |
977 | for (sepIter.toFirst(); sepIter.current(); ++sepIter) | 977 | for (sepIter.toFirst(); sepIter.current(); ++sepIter) |
978 | { | 978 | { |
979 | sep = *sepIter; | 979 | sep = *sepIter; |
980 | sepRect = sep->mRect; | 980 | sepRect = sep->mRect; |
981 | 981 | ||
982 | if (clipRect.intersects(sepRect) || clipRect.contains(sepRect)) | 982 | if (clipRect.intersects(sepRect) || clipRect.contains(sepRect)) |
983 | { | 983 | { |
984 | p->save(); | 984 | p->save(); |
985 | p->translate(sepRect.x(), sepRect.y()); | 985 | p->translate(sepRect.x(), sepRect.y()); |
986 | sep->paintSeparator(p, cg); | 986 | sep->paintSeparator(p, cg); |
987 | p->restore(); | 987 | p->restore(); |
988 | } | 988 | } |
989 | } | 989 | } |
990 | } | 990 | } |
991 | 991 | ||
992 | void CardView::resizeEvent(QResizeEvent *e) | 992 | void CardView::resizeEvent(QResizeEvent *e) |
993 | { | 993 | { |
994 | QScrollView::resizeEvent(e); | 994 | QScrollView::resizeEvent(e); |
995 | 995 | ||
996 | setLayoutDirty(true); | 996 | setLayoutDirty(true); |
997 | } | 997 | } |
998 | 998 | ||
999 | void CardView::calcLayout() | 999 | void CardView::calcLayout() |
1000 | { | 1000 | { |
1001 | //kdDebug() << "CardView::calcLayout:" << endl; | 1001 | //kdDebug() << "CardView::calcLayout:" << endl; |
1002 | 1002 | ||
1003 | // Start in the upper left corner and layout all the | 1003 | // Start in the upper left corner and layout all the |
1004 | // cars using their height and width | 1004 | // cars using their height and width |
1005 | int maxWidth = 0; | 1005 | int maxWidth = 0; |
1006 | int maxHeight = 0; | 1006 | int maxHeight = 0; |
1007 | int xPos = 0; | 1007 | int xPos = 0; |
1008 | int yPos = 0; | 1008 | int yPos = 0; |
1009 | int cardSpacing = d->mItemSpacing; | 1009 | int cardSpacing = d->mItemSpacing; |
1010 | 1010 | ||
1011 | // delete the old separators | 1011 | // delete the old separators |
1012 | d->mSeparatorList.clear(); | 1012 | d->mSeparatorList.clear(); |
1013 | 1013 | ||
1014 | QPtrListIterator<CardViewItem> iter(d->mItemList); | 1014 | QPtrListIterator<CardViewItem> iter(d->mItemList); |
1015 | CardViewItem *item = 0; | 1015 | CardViewItem *item = 0; |
1016 | CardViewSeparator *sep = 0; | 1016 | CardViewSeparator *sep = 0; |
1017 | xPos += cardSpacing; | 1017 | xPos += cardSpacing; |
1018 | 1018 | ||
1019 | for (iter.toFirst(); iter.current(); ++iter) | 1019 | for (iter.toFirst(); iter.current(); ++iter) |
1020 | { | 1020 | { |
1021 | item = *iter; | 1021 | item = *iter; |
1022 | 1022 | ||
1023 | yPos += cardSpacing; | 1023 | yPos += cardSpacing; |
1024 | 1024 | ||
1025 | if (yPos + item->height() + cardSpacing >= height() - horizontalScrollBar()->height()) | 1025 | if (yPos + item->height() + cardSpacing >= height() - horizontalScrollBar()->height()) |
1026 | { | 1026 | { |
1027 | maxHeight = QMAX(maxHeight, yPos); | 1027 | maxHeight = QMAX(maxHeight, yPos); |
1028 | 1028 | ||
1029 | // Drawing in this column would be greater than the height | 1029 | // Drawing in this column would be greater than the height |
1030 | // of the scroll view, so move to next column | 1030 | // of the scroll view, so move to next column |
1031 | yPos = cardSpacing; | 1031 | yPos = cardSpacing; |
1032 | xPos += cardSpacing + maxWidth; | 1032 | xPos += cardSpacing + maxWidth; |
1033 | if (d->mDrawSeparators) | 1033 | if (d->mDrawSeparators) |
1034 | { | 1034 | { |
1035 | // Create a separator since the user asked | 1035 | // Create a separator since the user asked |
1036 | sep = new CardViewSeparator(this); | 1036 | sep = new CardViewSeparator(this); |
1037 | sep->mRect.moveTopLeft(QPoint(xPos, yPos+d->mItemMargin)); | 1037 | sep->mRect.moveTopLeft(QPoint(xPos, yPos+d->mItemMargin)); |
1038 | xPos += d->mSepWidth + cardSpacing; | 1038 | xPos += d->mSepWidth + cardSpacing; |
1039 | d->mSeparatorList.append(sep); | 1039 | d->mSeparatorList.append(sep); |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | maxWidth = 0; | 1042 | maxWidth = 0; |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | item->d->x = xPos; | 1045 | item->d->x = xPos; |
1046 | item->d->y = yPos; | 1046 | item->d->y = yPos; |
1047 | 1047 | ||
1048 | yPos += item->height(); | 1048 | yPos += item->height(); |
1049 | maxWidth = QMAX(maxWidth, d->mItemWidth); | 1049 | maxWidth = QMAX(maxWidth, d->mItemWidth); |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | xPos += maxWidth; | 1052 | xPos += maxWidth; |
1053 | resizeContents( xPos + cardSpacing, maxHeight ); | 1053 | resizeContents( xPos + cardSpacing, maxHeight ); |
1054 | 1054 | ||
1055 | // Update the height of all the separators now that we know the | 1055 | // Update the height of all the separators now that we know the |
1056 | // max height of a column | 1056 | // max height of a column |
1057 | QPtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList); | 1057 | QPtrListIterator<CardViewSeparator> sepIter(d->mSeparatorList); |
1058 | for (sepIter.toFirst(); sepIter.current(); ++sepIter) | 1058 | for (sepIter.toFirst(); sepIter.current(); ++sepIter) |
1059 | { | 1059 | { |
1060 | (*sepIter)->mRect.setHeight(maxHeight - 2*cardSpacing - 2*d->mItemMargin); | 1060 | (*sepIter)->mRect.setHeight(maxHeight - 2*cardSpacing - 2*d->mItemMargin); |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | d->mLayoutDirty = false; | 1063 | d->mLayoutDirty = false; |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | CardViewItem *CardView::itemAfter(CardViewItem *item) | 1066 | CardViewItem *CardView::itemAfter(CardViewItem *item) |
1067 | { | 1067 | { |
1068 | /*int pos = */d->mItemList.findRef(item); | 1068 | /*int pos = */d->mItemList.findRef(item); |
1069 | return d->mItemList.next();//at(pos+1); | 1069 | return d->mItemList.next();//at(pos+1); |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | uint CardView::itemMargin() | 1072 | uint CardView::itemMargin() |
1073 | { | 1073 | { |
1074 | return d->mItemMargin; | 1074 | return d->mItemMargin; |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | void CardView::setItemMargin( uint margin ) | 1077 | void CardView::setItemMargin( uint margin ) |
1078 | { | 1078 | { |
1079 | if ( margin == d->mItemMargin ) | 1079 | if ( margin == d->mItemMargin ) |
1080 | return; | 1080 | return; |
1081 | 1081 | ||
1082 | d->mItemMargin = margin; | 1082 | d->mItemMargin = margin; |
1083 | setLayoutDirty( true ); | 1083 | setLayoutDirty( true ); |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | uint CardView::itemSpacing() | 1086 | uint CardView::itemSpacing() |
1087 | { | 1087 | { |
1088 | return d->mItemSpacing; | 1088 | return d->mItemSpacing; |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | void CardView::setItemSpacing( uint spacing ) | 1091 | void CardView::setItemSpacing( uint spacing ) |
1092 | { | 1092 | { |
1093 | if ( spacing == d->mItemSpacing ) | 1093 | if ( spacing == d->mItemSpacing ) |
1094 | return; | 1094 | return; |
1095 | 1095 | ||
1096 | d->mItemSpacing = spacing; | 1096 | d->mItemSpacing = spacing; |
1097 | setLayoutDirty( true ); | 1097 | setLayoutDirty( true ); |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | void CardView::contentsMousePressEvent(QMouseEvent *e) | 1100 | void CardView::contentsMousePressEvent(QMouseEvent *e) |
1101 | { | 1101 | { |
1102 | QScrollView::contentsMousePressEvent(e); | 1102 | QScrollView::contentsMousePressEvent(e); |
1103 | 1103 | ||
1104 | QPoint pos = e->pos(); | 1104 | QPoint pos = e->pos(); |
1105 | d->mLastClickPos = pos; | 1105 | d->mLastClickPos = pos; |
1106 | 1106 | ||
1107 | CardViewItem *item = itemAt(pos); | 1107 | CardViewItem *item = itemAt(pos); |
1108 | 1108 | ||
1109 | if (item == 0) | 1109 | if (item == 0) |
1110 | { | 1110 | { |
1111 | d->mLastClickOnItem = false; | 1111 | d->mLastClickOnItem = false; |
1112 | if ( d->mOnSeparator) | 1112 | if ( d->mOnSeparator) |
1113 | { | 1113 | { |
1114 | d->mResizeAnchor = e->x()+contentsX(); | 1114 | d->mResizeAnchor = e->x()+contentsX(); |
1115 | d->colspace = (2*d->mItemSpacing) /*+ (2*d->mItemMargin)*/; | 1115 | d->colspace = (2*d->mItemSpacing) /*+ (2*d->mItemMargin)*/; |
1116 | int ccw = d->mItemWidth + d->colspace + d->mSepWidth; | 1116 | int ccw = d->mItemWidth + d->colspace + d->mSepWidth; |
1117 | d->first = (contentsX()+d->mSepWidth)/ccw; | 1117 | d->first = (contentsX()+d->mSepWidth)/ccw; |
1118 | d->pressed = (d->mResizeAnchor+d->mSepWidth)/ccw; | 1118 | d->pressed = (d->mResizeAnchor+d->mSepWidth)/ccw; |
1119 | d->span = d->pressed - d->first; | 1119 | d->span = d->pressed - d->first; |
1120 | d->firstX = d->first * ccw; | 1120 | d->firstX = d->first * ccw; |
1121 | if ( d->firstX ) d->firstX -= d->mSepWidth; // (no sep in col 0) | 1121 | if ( d->firstX ) d->firstX -= d->mSepWidth; // (no sep in col 0) |
1122 | } | 1122 | } |
1123 | else | 1123 | else |
1124 | { | 1124 | { |
1125 | selectAll(false); | 1125 | selectAll(false); |
1126 | } | 1126 | } |
1127 | return; | 1127 | return; |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | d->mLastClickOnItem = true; | 1130 | d->mLastClickOnItem = true; |
1131 | 1131 | ||
1132 | CardViewItem *other = d->mCurrentItem; | 1132 | CardViewItem *other = d->mCurrentItem; |
1133 | setCurrentItem( item ); | 1133 | setCurrentItem( item ); |
1134 | 1134 | ||
1135 | // Always emit the selection | 1135 | // Always emit the selection |
1136 | emit clicked(item); | 1136 | emit clicked(item); |
1137 | 1137 | ||
1138 | // Check the selection type and update accordingly | 1138 | // Check the selection type and update accordingly |
1139 | if (d->mSelectionMode == CardView::Single) | 1139 | if (d->mSelectionMode == CardView::Single) |
1140 | { | 1140 | { |
1141 | // make sure it isn't already selected | 1141 | // make sure it isn't already selected |
1142 | if (item->isSelected()) | 1142 | if (item->isSelected()) |
1143 | return; | 1143 | return; |
1144 | 1144 | ||
1145 | bool b = signalsBlocked(); | 1145 | bool b = signalsBlocked(); |
1146 | blockSignals(true); | 1146 | blockSignals(true); |
1147 | selectAll(false); | 1147 | selectAll(false); |
1148 | blockSignals(b); | 1148 | blockSignals(b); |
1149 | 1149 | ||
1150 | item->setSelected(true); | 1150 | item->setSelected(true); |
1151 | item->repaintCard(); | 1151 | item->repaintCard(); |
1152 | emit selectionChanged(item); | 1152 | emit selectionChanged(item); |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | else if (d->mSelectionMode == CardView::Multi) | 1155 | else if (d->mSelectionMode == CardView::Multi) |
1156 | { | 1156 | { |
1157 | // toggle the selection | 1157 | // toggle the selection |
1158 | item->setSelected(!item->isSelected()); | 1158 | item->setSelected(!item->isSelected()); |
1159 | item->repaintCard(); | 1159 | item->repaintCard(); |
1160 | emit selectionChanged(); | 1160 | emit selectionChanged(); |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | else if (d->mSelectionMode == CardView::Extended) | 1163 | else if (d->mSelectionMode == CardView::Extended) |
1164 | { | 1164 | { |
1165 | if ((e->button() & Qt::LeftButton) && | 1165 | if ((e->button() & Qt::LeftButton) && |
1166 | (e->state() & Qt::ShiftButton)) | 1166 | (e->state() & Qt::ShiftButton)) |
1167 | { | 1167 | { |
1168 | if ( item == other ) return; | 1168 | if ( item == other ) return; |
1169 | 1169 | ||
1170 | bool s = ! item->isSelected(); | 1170 | bool s = ! item->isSelected(); |
1171 | 1171 | ||
1172 | if ( s && ! (e->state() & ControlButton) ) | 1172 | if ( s && ! (e->state() & ControlButton) ) |
1173 | { | 1173 | { |
1174 | bool b = signalsBlocked(); | 1174 | bool b = signalsBlocked(); |
1175 | blockSignals(true); | 1175 | blockSignals(true); |
1176 | selectAll(false); | 1176 | selectAll(false); |
1177 | blockSignals(b); | 1177 | blockSignals(b); |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | int from, to, a, b; | 1180 | int from, to, a, b; |
1181 | a = d->mItemList.findRef( item ); | 1181 | a = d->mItemList.findRef( item ); |
1182 | b = d->mItemList.findRef( other ); | 1182 | b = d->mItemList.findRef( other ); |
1183 | from = a < b ? a : b; | 1183 | from = a < b ? a : b; |
1184 | to = a > b ? a : b; | 1184 | to = a > b ? a : b; |
1185 | //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl; | 1185 | //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl; |
1186 | CardViewItem *aItem; | 1186 | CardViewItem *aItem; |
1187 | for ( ; from <= to; from++ ) | 1187 | for ( ; from <= to; from++ ) |
1188 | { | 1188 | { |
1189 | aItem = d->mItemList.at( from ); | 1189 | aItem = d->mItemList.at( from ); |
1190 | aItem->setSelected( s ); | 1190 | aItem->setSelected( s ); |
1191 | repaintItem( aItem ); | 1191 | repaintItem( aItem ); |
1192 | } | 1192 | } |
1193 | emit selectionChanged(); | 1193 | emit selectionChanged(); |
1194 | } | 1194 | } |
1195 | else if ((e->button() & Qt::LeftButton) && | 1195 | else if ((e->button() & Qt::LeftButton) && |
1196 | (e->state() & Qt::ControlButton)) | 1196 | (e->state() & Qt::ControlButton)) |
1197 | { | 1197 | { |
1198 | item->setSelected(!item->isSelected()); | 1198 | item->setSelected(!item->isSelected()); |
1199 | item->repaintCard(); | 1199 | item->repaintCard(); |
1200 | emit selectionChanged(); | 1200 | emit selectionChanged(); |
1201 | } | 1201 | } |
1202 | 1202 | ||
1203 | else if (e->button() & Qt::LeftButton) | 1203 | else if (e->button() & Qt::LeftButton) |
1204 | { | 1204 | { |
1205 | bool b = signalsBlocked(); | 1205 | bool b = signalsBlocked(); |
1206 | blockSignals(true); | 1206 | blockSignals(true); |
1207 | selectAll(false); | 1207 | selectAll(false); |
1208 | blockSignals(b); | 1208 | blockSignals(b); |
1209 | 1209 | ||
1210 | item->setSelected(true); | 1210 | item->setSelected(true); |
1211 | item->repaintCard(); | 1211 | item->repaintCard(); |
1212 | emit selectionChanged(); | 1212 | emit selectionChanged(); |
1213 | } | 1213 | } |
1214 | } | 1214 | } |
1215 | 1215 | ||
1216 | } | 1216 | } |
1217 | 1217 | ||
1218 | void CardView::contentsMouseReleaseEvent(QMouseEvent *e) | 1218 | void CardView::contentsMouseReleaseEvent(QMouseEvent *e) |
1219 | { | 1219 | { |
1220 | QScrollView::contentsMouseReleaseEvent(e); | 1220 | QScrollView::contentsMouseReleaseEvent(e); |
1221 | 1221 | ||
1222 | if ( d->mResizeAnchor ) | 1222 | if ( d->mResizeAnchor ) |
1223 | { | 1223 | { |
1224 | // finish the resizing: | 1224 | // finish the resizing: |
1225 | unsetCursor(); | 1225 | unsetCursor(); |
1226 | // hide rubber bands | 1226 | // hide rubber bands |
1227 | int newiw = d->mItemWidth - ((d->mResizeAnchor - d->mRubberBandAnchor)/d->span); | 1227 | int newiw = d->mItemWidth - ((d->mResizeAnchor - d->mRubberBandAnchor)/d->span); |
1228 | drawRubberBands( 0 ); | 1228 | drawRubberBands( 0 ); |
1229 | // we should move to reflect the new position if we are scrolled. | 1229 | // we should move to reflect the new position if we are scrolled. |
1230 | if ( contentsX() ) | 1230 | if ( contentsX() ) |
1231 | { | 1231 | { |
1232 | int newX = QMAX( 0, ( d->pressed * ( newiw + d->colspace + d->mSepWidth ) ) - e->x() ); | 1232 | int newX = QMAX( 0, ( d->pressed * ( newiw + d->colspace + d->mSepWidth ) ) - e->x() ); |
1233 | setContentsPos( newX, contentsY() ); | 1233 | setContentsPos( newX, contentsY() ); |
1234 | } | 1234 | } |
1235 | // set new item width | 1235 | // set new item width |
1236 | setItemWidth( newiw ); | 1236 | setItemWidth( newiw ); |
1237 | // reset anchors | 1237 | // reset anchors |
1238 | d->mResizeAnchor = 0; | 1238 | d->mResizeAnchor = 0; |
1239 | d->mRubberBandAnchor = 0; | 1239 | d->mRubberBandAnchor = 0; |
1240 | return; | 1240 | return; |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | // If there are accel keys, we will not emit signals | 1243 | // If there are accel keys, we will not emit signals |
1244 | if ((e->state() & Qt::ShiftButton) || (e->state() & Qt::ControlButton)) | 1244 | if ((e->state() & Qt::ShiftButton) || (e->state() & Qt::ControlButton)) |
1245 | return; | 1245 | return; |
1246 | 1246 | ||
1247 | // Get the item at this position | 1247 | // Get the item at this position |
1248 | CardViewItem *item = itemAt(e->pos()); | 1248 | CardViewItem *item = itemAt(e->pos()); |
1249 | 1249 | ||
1250 | if (item && KABPrefs::instance()->mHonorSingleClick) | 1250 | if (item && KABPrefs::instance()->mHonorSingleClick) |
1251 | { | 1251 | { |
1252 | emit executed(item); | 1252 | emit executed(item); |
1253 | } | 1253 | } |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1256 | void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1257 | { | 1257 | { |
1258 | QScrollView::contentsMouseDoubleClickEvent(e); | 1258 | QScrollView::contentsMouseDoubleClickEvent(e); |
1259 | 1259 | ||
1260 | CardViewItem *item = itemAt(e->pos()); | 1260 | CardViewItem *item = itemAt(e->pos()); |
1261 | 1261 | ||
1262 | if (item) | 1262 | if (item) |
1263 | { | 1263 | { |
1264 | d->mCurrentItem = item; | 1264 | d->mCurrentItem = item; |
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | if (item && !KABPrefs::instance()->mHonorSingleClick) | 1267 | if (item && !KABPrefs::instance()->mHonorSingleClick) |
1268 | { | 1268 | { |
1269 | emit executed(item); | 1269 | emit executed(item); |
1270 | } else | 1270 | } else |
1271 | emit doubleClicked(item); | 1271 | emit doubleClicked(item); |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | void CardView::contentsMouseMoveEvent( QMouseEvent *e ) | 1274 | void CardView::contentsMouseMoveEvent( QMouseEvent *e ) |
1275 | { | 1275 | { |
1276 | // resizing | 1276 | // resizing |
1277 | if ( d->mResizeAnchor ) | 1277 | if ( d->mResizeAnchor ) |
1278 | { | 1278 | { |
1279 | int x = e->x(); | 1279 | int x = e->x(); |
1280 | if ( x != d->mRubberBandAnchor ) | 1280 | if ( x != d->mRubberBandAnchor ) |
1281 | drawRubberBands( x ); | 1281 | drawRubberBands( x ); |
1282 | return; | 1282 | return; |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | if (d->mLastClickOnItem && (e->state() & Qt::LeftButton) && | 1285 | if (d->mLastClickOnItem && (e->state() & Qt::LeftButton) && |
1286 | ((e->pos() - d->mLastClickPos).manhattanLength() > 4)) { | 1286 | ((e->pos() - d->mLastClickPos).manhattanLength() > 4)) { |
1287 | 1287 | ||
1288 | startDrag(); | 1288 | startDrag(); |
1289 | return; | 1289 | return; |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | d->mTimer->start( 500 ); | 1292 | d->mTimer->start( 500 ); |
1293 | 1293 | ||
1294 | // see if we are over a separator | 1294 | // see if we are over a separator |
1295 | // only if we actually have them painted? | 1295 | // only if we actually have them painted? |
1296 | if ( d->mDrawSeparators ) | 1296 | if ( d->mDrawSeparators ) |
1297 | { | 1297 | { |
1298 | int colcontentw = d->mItemWidth + (2*d->mItemSpacing); | 1298 | int colcontentw = d->mItemWidth + (2*d->mItemSpacing); |
1299 | int colw = colcontentw + d->mSepWidth; | 1299 | int colw = colcontentw + d->mSepWidth; |
1300 | int m = e->x()%colw; | 1300 | int m = e->x()%colw; |
1301 | if ( m >= colcontentw && m > 0 ) | 1301 | if ( m >= colcontentw && m > 0 ) |
1302 | { | 1302 | { |
1303 | setCursor( SplitVCursor ); // Why does this fail sometimes? | 1303 | setCursor( SplitVCursor ); // Why does this fail sometimes? |
1304 | d->mOnSeparator = true; | 1304 | d->mOnSeparator = true; |
1305 | } | 1305 | } |
1306 | else | 1306 | else |
1307 | { | 1307 | { |
1308 | setCursor( ArrowCursor ); | 1308 | setCursor( ArrowCursor ); |
1309 | d->mOnSeparator = false; | 1309 | d->mOnSeparator = false; |
1310 | } | 1310 | } |
1311 | } | 1311 | } |
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | void CardView::enterEvent( QEvent * ) | 1314 | void CardView::enterEvent( QEvent * ) |
1315 | { | 1315 | { |
1316 | d->mTimer->start( 500 ); | 1316 | d->mTimer->start( 500 ); |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | void CardView::leaveEvent( QEvent * ) | 1319 | void CardView::leaveEvent( QEvent * ) |
1320 | { | 1320 | { |
1321 | d->mTimer->stop(); | 1321 | d->mTimer->stop(); |
1322 | if (d->mOnSeparator) | 1322 | if (d->mOnSeparator) |
1323 | { | 1323 | { |
1324 | d->mOnSeparator = false; | 1324 | d->mOnSeparator = false; |
1325 | setCursor( ArrowCursor ); | 1325 | setCursor( ArrowCursor ); |
1326 | } | 1326 | } |
1327 | } | 1327 | } |
1328 | 1328 | ||
1329 | void CardView::focusInEvent( QFocusEvent * ) | 1329 | void CardView::focusInEvent( QFocusEvent * ) |
1330 | { | 1330 | { |
1331 | if (!d->mCurrentItem && d->mItemList.count() ) | 1331 | if (!d->mCurrentItem && d->mItemList.count() ) |
1332 | { | 1332 | { |
1333 | setCurrentItem( d->mItemList.first() ); | 1333 | setCurrentItem( d->mItemList.first() ); |
1334 | } | 1334 | } |
1335 | else if ( d->mCurrentItem ) | 1335 | else if ( d->mCurrentItem ) |
1336 | { | 1336 | { |
1337 | d->mCurrentItem->repaintCard(); | 1337 | d->mCurrentItem->repaintCard(); |
1338 | } | 1338 | } |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | void CardView::focusOutEvent( QFocusEvent * ) | 1341 | void CardView::focusOutEvent( QFocusEvent * ) |
1342 | { | 1342 | { |
1343 | if (d->mCurrentItem) | 1343 | if (d->mCurrentItem) |
1344 | d->mCurrentItem->repaintCard(); | 1344 | d->mCurrentItem->repaintCard(); |
1345 | } | 1345 | } |
1346 | 1346 | ||
1347 | void CardView::keyPressEvent( QKeyEvent *e ) | 1347 | void CardView::keyPressEvent( QKeyEvent *e ) |
1348 | { | 1348 | { |
1349 | if ( ! ( childCount() && d->mCurrentItem ) ) | 1349 | if ( ! ( childCount() && d->mCurrentItem ) ) |
1350 | { | 1350 | { |
1351 | e->ignore(); | 1351 | e->ignore(); |
1352 | return; | 1352 | return; |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | uint pos = d->mItemList.findRef( d->mCurrentItem ); | 1355 | uint pos = d->mItemList.findRef( d->mCurrentItem ); |
1356 | CardViewItem *aItem = 0L; // item that gets the focus | 1356 | CardViewItem *aItem = 0L; // item that gets the focus |
1357 | CardViewItem *old = d->mCurrentItem; | 1357 | CardViewItem *old = d->mCurrentItem; |
1358 | 1358 | ||
1359 | switch ( e->key() ) | 1359 | switch ( e->key() ) |
1360 | { | 1360 | { |
1361 | case Key_Up: | 1361 | case Key_Up: |
1362 | if ( pos > 0 ) | 1362 | if ( pos > 0 ) |
1363 | { | 1363 | { |
1364 | aItem = d->mItemList.at( pos - 1 ); | 1364 | aItem = d->mItemList.at( pos - 1 ); |
1365 | setCurrentItem( aItem ); | 1365 | setCurrentItem( aItem ); |
1366 | } | 1366 | } |
1367 | break; | 1367 | break; |
1368 | case Key_Down: | 1368 | case Key_Down: |
1369 | if ( pos < d->mItemList.count() - 1 ) | 1369 | if ( pos < d->mItemList.count() - 1 ) |
1370 | { | 1370 | { |
1371 | aItem = d->mItemList.at( pos + 1 ); | 1371 | aItem = d->mItemList.at( pos + 1 ); |
1372 | setCurrentItem( aItem ); | 1372 | setCurrentItem( aItem ); |
1373 | } | 1373 | } |
1374 | break; | 1374 | break; |
1375 | case Key_Left: | 1375 | case Key_Left: |
1376 | { | 1376 | { |
1377 | // look for an item in the previous/next column, starting from | 1377 | // look for an item in the previous/next column, starting from |
1378 | // the vertical middle of the current item. | 1378 | // the vertical middle of the current item. |
1379 | // FIXME use nice calculatd measures!!! | 1379 | // FIXME use nice calculatd measures!!! |
1380 | QPoint aPoint( d->mCurrentItem->d->x, d->mCurrentItem->d->y ); | 1380 | QPoint aPoint( d->mCurrentItem->d->x, d->mCurrentItem->d->y ); |
1381 | aPoint -= QPoint( 30,-(d->mCurrentItem->height()/2) ); | 1381 | aPoint -= QPoint( 30,-(d->mCurrentItem->height()/2) ); |
1382 | aItem = itemAt( aPoint ); | 1382 | aItem = itemAt( aPoint ); |
1383 | // maybe we hit some space below an item | 1383 | // maybe we hit some space below an item |
1384 | while ( !aItem && aPoint.y() > 27 ) | 1384 | while ( !aItem && aPoint.y() > 27 ) |
1385 | { | 1385 | { |
1386 | aPoint -= QPoint( 0, 16 ); | 1386 | aPoint -= QPoint( 0, 16 ); |
1387 | aItem = itemAt( aPoint ); | 1387 | aItem = itemAt( aPoint ); |
1388 | } | 1388 | } |
1389 | if ( aItem ) | 1389 | if ( aItem ) |
1390 | setCurrentItem( aItem ); | 1390 | setCurrentItem( aItem ); |
1391 | } | 1391 | } |
1392 | break; | 1392 | break; |
1393 | case Key_Right: | 1393 | case Key_Right: |
1394 | { | 1394 | { |
1395 | // FIXME use nice calculated measures!!! | 1395 | // FIXME use nice calculated measures!!! |
1396 | QPoint aPoint( d->mCurrentItem->d->x + d->mItemWidth, d->mCurrentItem->d->y ); | 1396 | QPoint aPoint( d->mCurrentItem->d->x + d->mItemWidth, d->mCurrentItem->d->y ); |
1397 | aPoint += QPoint( 30,(d->mCurrentItem->height()/2) ); | 1397 | aPoint += QPoint( 30,(d->mCurrentItem->height()/2) ); |
1398 | aItem = itemAt( aPoint ); | 1398 | aItem = itemAt( aPoint ); |
1399 | while ( !aItem && aPoint.y() > 27 ) | 1399 | while ( !aItem && aPoint.y() > 27 ) |
1400 | { | 1400 | { |
1401 | aPoint -= QPoint( 0, 16 ); | 1401 | aPoint -= QPoint( 0, 16 ); |
1402 | aItem = itemAt( aPoint ); | 1402 | aItem = itemAt( aPoint ); |
1403 | } | 1403 | } |
1404 | if ( aItem ) | 1404 | if ( aItem ) |
1405 | setCurrentItem( aItem ); | 1405 | setCurrentItem( aItem ); |
1406 | } | 1406 | } |
1407 | break; | 1407 | break; |
1408 | case Key_Home: | 1408 | case Key_Home: |
1409 | aItem = d->mItemList.first(); | 1409 | aItem = d->mItemList.first(); |
1410 | setCurrentItem( aItem ); | 1410 | setCurrentItem( aItem ); |
1411 | break; | 1411 | break; |
1412 | case Key_End: | 1412 | case Key_End: |
1413 | aItem = d->mItemList.last(); | 1413 | aItem = d->mItemList.last(); |
1414 | setCurrentItem( aItem ); | 1414 | setCurrentItem( aItem ); |
1415 | break; | 1415 | break; |
1416 | case Key_Prior: // PageUp | 1416 | case Key_Prior: // PageUp |
1417 | { | 1417 | { |
1418 | // QListView: "Make the item above the top visible and current" | 1418 | // QListView: "Make the item above the top visible and current" |
1419 | // TODO if contentsY(), pick the top item of the leftmost visible column | 1419 | // TODO if contentsY(), pick the top item of the leftmost visible column |
1420 | if ( contentsX() <= 0 ) | 1420 | if ( contentsX() <= 0 ) |
1421 | return; | 1421 | return; |
1422 | int cw = columnWidth(); | 1422 | int cw = columnWidth(); |
1423 | int theCol = ( QMAX( 0, ( contentsX()/cw) * cw ) ) + d->mItemSpacing; | 1423 | int theCol = ( QMAX( 0, ( contentsX()/cw) * cw ) ) + d->mItemSpacing; |
1424 | aItem = itemAt( QPoint( theCol + 1, d->mItemSpacing + 1 ) ); | 1424 | aItem = itemAt( QPoint( theCol + 1, d->mItemSpacing + 1 ) ); |
1425 | if ( aItem ) | 1425 | if ( aItem ) |
1426 | setCurrentItem( aItem ); | 1426 | setCurrentItem( aItem ); |
1427 | } | 1427 | } |
1428 | break; | 1428 | break; |
1429 | case Key_Next: // PageDown | 1429 | case Key_Next: // PageDown |
1430 | { | 1430 | { |
1431 | // QListView: "Make the item below the bottom visible and current" | 1431 | // QListView: "Make the item below the bottom visible and current" |
1432 | // find the first not fully visible column. | 1432 | // find the first not fully visible column. |
1433 | // TODO: consider if a partly visible (or even hidden) item at the | 1433 | // TODO: consider if a partly visible (or even hidden) item at the |
1434 | // bottom of the rightmost column exists | 1434 | // bottom of the rightmost column exists |
1435 | int cw = columnWidth(); | 1435 | int cw = columnWidth(); |
1436 | int theCol = ( (( contentsX() + visibleWidth() )/cw) * cw ) + d->mItemSpacing + 1; | 1436 | int theCol = ( (( contentsX() + visibleWidth() )/cw) * cw ) + d->mItemSpacing + 1; |
1437 | // if separators are on, we may need to we may be one column further right if only the spacing/sep is hidden | 1437 | // if separators are on, we may need to we may be one column further right if only the spacing/sep is hidden |
1438 | if ( d->mDrawSeparators && cw - (( contentsX() + visibleWidth() )%cw) <= int( d->mItemSpacing + d->mSepWidth ) ) | 1438 | if ( d->mDrawSeparators && cw - (( contentsX() + visibleWidth() )%cw) <= int( d->mItemSpacing + d->mSepWidth ) ) |
1439 | theCol += cw; | 1439 | theCol += cw; |
1440 | 1440 | ||
1441 | // make sure this is not too far right | 1441 | // make sure this is not too far right |
1442 | while ( theCol > contentsWidth() ) | 1442 | while ( theCol > contentsWidth() ) |
1443 | theCol -= columnWidth(); | 1443 | theCol -= columnWidth(); |
1444 | 1444 | ||
1445 | aItem = itemAt( QPoint( theCol, d->mItemSpacing + 1 ) ); | 1445 | aItem = itemAt( QPoint( theCol, d->mItemSpacing + 1 ) ); |
1446 | 1446 | ||
1447 | if ( aItem ) | 1447 | if ( aItem ) |
1448 | setCurrentItem( aItem ); | 1448 | setCurrentItem( aItem ); |
1449 | } | 1449 | } |
1450 | break; | 1450 | break; |
1451 | case Key_Space: | 1451 | case Key_Space: |
1452 | setSelected( d->mCurrentItem, !d->mCurrentItem->isSelected() ); | 1452 | setSelected( d->mCurrentItem, !d->mCurrentItem->isSelected() ); |
1453 | emit selectionChanged(); | 1453 | emit selectionChanged(); |
1454 | break; | 1454 | break; |
1455 | case Key_Return: | 1455 | case Key_Return: |
1456 | case Key_Enter: | 1456 | case Key_Enter: |
1457 | { | 1457 | { |
1458 | emit returnPressed( d->mCurrentItem ); | 1458 | emit returnPressed( d->mCurrentItem ); |
1459 | emit executed( d->mCurrentItem ); | 1459 | emit executed( d->mCurrentItem ); |
1460 | } | 1460 | } |
1461 | break; | 1461 | break; |
1462 | default: | 1462 | default: |
1463 | if ( (e->state() & ControlButton) && e->key() == Key_A ) | 1463 | if ( (e->state() & ControlButton) && e->key() == Key_A ) |
1464 | { | 1464 | { |
1465 | // select all | 1465 | // select all |
1466 | selectAll( true ); | 1466 | selectAll( true ); |
1467 | break; | 1467 | break; |
1468 | } | 1468 | } |
1469 | // if we have a string, do autosearch | 1469 | // if we have a string, do autosearch |
1470 | else if ( ! e->text().isEmpty() && e->text()[0].isPrint() ) | 1470 | else if ( ! e->text().isEmpty() && e->text()[0].isPrint() ) |
1471 | { | 1471 | { |
1472 | 1472 | ||
1473 | } | 1473 | } |
1474 | break; | 1474 | break; |
1475 | } | 1475 | } |
1476 | // handle selection | 1476 | // handle selection |
1477 | if ( aItem ) | 1477 | if ( aItem ) |
1478 | { | 1478 | { |
1479 | if ( d->mSelectionMode == CardView::Extended ) | 1479 | if ( d->mSelectionMode == CardView::Extended ) |
1480 | { | 1480 | { |
1481 | if ( (e->state() & ShiftButton) ) | 1481 | if ( (e->state() & ShiftButton) ) |
1482 | { | 1482 | { |
1483 | // shift button: toggle range | 1483 | // shift button: toggle range |
1484 | // if control button is pressed, leave all items | 1484 | // if control button is pressed, leave all items |
1485 | // and toggle selection current->old current | 1485 | // and toggle selection current->old current |
1486 | // otherwise, ?????? | 1486 | // otherwise, ?????? |
1487 | bool s = ! aItem->isSelected(); | 1487 | bool s = ! aItem->isSelected(); |
1488 | int from, to, a, b; | 1488 | int from, to, a, b; |
1489 | a = d->mItemList.findRef( aItem ); | 1489 | a = d->mItemList.findRef( aItem ); |
1490 | b = d->mItemList.findRef( old ); | 1490 | b = d->mItemList.findRef( old ); |
1491 | from = a < b ? a : b; | 1491 | from = a < b ? a : b; |
1492 | to = a > b ? a : b; | 1492 | to = a > b ? a : b; |
1493 | 1493 | ||
1494 | if ( to - from > 1 ) | 1494 | if ( to - from > 1 ) |
1495 | { | 1495 | { |
1496 | bool b = signalsBlocked(); | 1496 | bool b = signalsBlocked(); |
1497 | blockSignals(true); | 1497 | blockSignals(true); |
1498 | selectAll(false); | 1498 | selectAll(false); |
1499 | blockSignals(b); | 1499 | blockSignals(b); |
1500 | } | 1500 | } |
1501 | 1501 | ||
1502 | //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl; | 1502 | //kdDebug()<<"selecting items "<<from<<" - "<<to<<" ( "<<s<<" )"<<endl; |
1503 | CardViewItem *item; | 1503 | CardViewItem *item; |
1504 | for ( ; from <= to; from++ ) | 1504 | for ( ; from <= to; from++ ) |
1505 | { | 1505 | { |
1506 | item = d->mItemList.at( from ); | 1506 | item = d->mItemList.at( from ); |
1507 | item->setSelected( s ); | 1507 | item->setSelected( s ); |
1508 | repaintItem( item ); | 1508 | repaintItem( item ); |
1509 | } | 1509 | } |
1510 | emit selectionChanged(); | 1510 | emit selectionChanged(); |
1511 | } | 1511 | } |
1512 | else if ( (e->state() & ControlButton) ) | 1512 | else if ( (e->state() & ControlButton) ) |
1513 | { | 1513 | { |
1514 | // control button: do nothing | 1514 | // control button: do nothing |
1515 | } | 1515 | } |
1516 | else | 1516 | else |
1517 | { | 1517 | { |
1518 | // no button: move selection to this item | 1518 | // no button: move selection to this item |
1519 | bool b = signalsBlocked(); | 1519 | bool b = signalsBlocked(); |
1520 | blockSignals(true); | 1520 | blockSignals(true); |
1521 | selectAll(false); | 1521 | selectAll(false); |
1522 | blockSignals(b); | 1522 | blockSignals(b); |
1523 | 1523 | ||
1524 | setSelected( aItem, true ); | 1524 | setSelected( aItem, true ); |
1525 | emit selectionChanged(); | 1525 | emit selectionChanged(); |
1526 | } | 1526 | } |
1527 | } | 1527 | } |
1528 | } | 1528 | } |
1529 | } | 1529 | } |
1530 | 1530 | ||
1531 | void CardView::contentsWheelEvent( QWheelEvent * e ) | 1531 | void CardView::contentsWheelEvent( QWheelEvent * e ) |
1532 | { | 1532 | { |
1533 | scrollBy(2*e->delta()/-3, 0); | 1533 | scrollBy(2*e->delta()/-3, 0); |
1534 | } | 1534 | } |
1535 | 1535 | ||
1536 | void CardView::setLayoutDirty(bool dirty) | 1536 | void CardView::setLayoutDirty(bool dirty) |
1537 | { | 1537 | { |
1538 | if (d->mLayoutDirty != dirty) | 1538 | if (d->mLayoutDirty != dirty) |
1539 | { | 1539 | { |
1540 | d->mLayoutDirty = dirty; | 1540 | d->mLayoutDirty = dirty; |
1541 | repaint(); | 1541 | repaint(); |
1542 | } | 1542 | } |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | void CardView::setDrawCardBorder(bool enabled) | 1545 | void CardView::setDrawCardBorder(bool enabled) |
1546 | { | 1546 | { |
1547 | if (enabled != d->mDrawCardBorder) | 1547 | if (enabled != d->mDrawCardBorder) |
1548 | { | 1548 | { |
1549 | d->mDrawCardBorder = enabled; | 1549 | d->mDrawCardBorder = enabled; |
1550 | repaint(); | 1550 | repaint(); |
1551 | } | 1551 | } |
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | bool CardView::drawCardBorder() const | 1554 | bool CardView::drawCardBorder() const |
1555 | { | 1555 | { |
1556 | return d->mDrawCardBorder; | 1556 | return d->mDrawCardBorder; |
1557 | } | 1557 | } |
1558 | 1558 | ||
1559 | void CardView::setDrawColSeparators(bool enabled) | 1559 | void CardView::setDrawColSeparators(bool enabled) |
1560 | { | 1560 | { |
1561 | if (enabled != d->mDrawSeparators) | 1561 | if (enabled != d->mDrawSeparators) |
1562 | { | 1562 | { |
1563 | d->mDrawSeparators = enabled; | 1563 | d->mDrawSeparators = enabled; |
1564 | setLayoutDirty(true); | 1564 | setLayoutDirty(true); |
1565 | } | 1565 | } |
1566 | } | 1566 | } |
1567 | 1567 | ||
1568 | bool CardView::drawColSeparators() const | 1568 | bool CardView::drawColSeparators() const |
1569 | { | 1569 | { |
1570 | return d->mDrawSeparators; | 1570 | return d->mDrawSeparators; |
1571 | } | 1571 | } |
1572 | 1572 | ||
1573 | void CardView::setDrawFieldLabels(bool enabled) | 1573 | void CardView::setDrawFieldLabels(bool enabled) |
1574 | { | 1574 | { |
1575 | if (enabled != d->mDrawFieldLabels) | 1575 | if (enabled != d->mDrawFieldLabels) |
1576 | { | 1576 | { |
1577 | d->mDrawFieldLabels = enabled; | 1577 | d->mDrawFieldLabels = enabled; |
1578 | repaint(); | 1578 | repaint(); |
1579 | } | 1579 | } |
1580 | } | 1580 | } |
1581 | 1581 | ||
1582 | bool CardView::drawFieldLabels() const | 1582 | bool CardView::drawFieldLabels() const |
1583 | { | 1583 | { |
1584 | return d->mDrawFieldLabels; | 1584 | return d->mDrawFieldLabels; |
1585 | } | 1585 | } |
1586 | 1586 | ||
1587 | void CardView::setShowEmptyFields(bool show) | 1587 | void CardView::setShowEmptyFields(bool show) |
1588 | { | 1588 | { |
1589 | if (show != d->mShowEmptyFields) | 1589 | if (show != d->mShowEmptyFields) |
1590 | { | 1590 | { |
1591 | d->mShowEmptyFields = show; | 1591 | d->mShowEmptyFields = show; |
1592 | setLayoutDirty(true); | 1592 | setLayoutDirty(true); |
1593 | } | 1593 | } |
1594 | } | 1594 | } |
1595 | 1595 | ||
1596 | bool CardView::showEmptyFields() const | 1596 | bool CardView::showEmptyFields() const |
1597 | { | 1597 | { |
1598 | return d->mShowEmptyFields; | 1598 | return d->mShowEmptyFields; |
1599 | } | 1599 | } |
1600 | 1600 | ||
1601 | void CardView::startDrag() | 1601 | void CardView::startDrag() |
1602 | { | 1602 | { |
1603 | // The default implementation is a no-op. It must be | 1603 | // The default implementation is a no-op. It must be |
1604 | // reimplemented in a subclass to be useful | 1604 | // reimplemented in a subclass to be useful |
1605 | } | 1605 | } |
1606 | void CardView::tryShowFullText() | 1606 | void CardView::tryShowFullText() |
1607 | { | 1607 | { |
1608 | d->mTimer->stop(); | 1608 | d->mTimer->stop(); |
1609 | // if we have an item | 1609 | // if we have an item |
1610 | QPoint cpos = viewportToContents( viewport()->mapFromGlobal( QCursor::pos() ) ); | 1610 | QPoint cpos = viewportToContents( viewport()->mapFromGlobal( QCursor::pos() ) ); |
1611 | CardViewItem *item = itemAt( cpos ); | 1611 | CardViewItem *item = itemAt( cpos ); |
1612 | if ( item ) | 1612 | if ( item ) |
1613 | { | 1613 | { |
1614 | // query it for a value to display | 1614 | // query it for a value to display |
1615 | //QString s = item ? item->caption() : "(no item)"; | 1615 | //QString s = item ? item->caption() : "(no item)"; |
1616 | //kdDebug()<<"MOUSE REST: "<<s<<endl; | 1616 | //kdDebug()<<"MOUSE REST: "<<s<<endl; |
1617 | QPoint ipos = cpos - itemRect( item ).topLeft(); | 1617 | QPoint ipos = cpos - itemRect( item ).topLeft(); |
1618 | item->showFullString( ipos, d->mTip ); | 1618 | item->showFullString( ipos, d->mTip ); |
1619 | } | 1619 | } |
1620 | } | 1620 | } |
1621 | 1621 | ||
1622 | void CardView::drawRubberBands( int pos ) | 1622 | void CardView::drawRubberBands( int pos ) |
1623 | { | 1623 | { |
1624 | if ( pos && ((pos-d->firstX)/d->span) - d->colspace - d->mSepWidth < MIN_ITEM_WIDTH ) return; | 1624 | if ( pos && ((pos-d->firstX)/d->span) - d->colspace - d->mSepWidth < MIN_ITEM_WIDTH ) return; |
1625 | 1625 | ||
1626 | int tmpcw = (d->mRubberBandAnchor-d->firstX)/d->span; | 1626 | int tmpcw = (d->mRubberBandAnchor-d->firstX)/d->span; |
1627 | int x = d->firstX + tmpcw - d->mSepWidth - contentsX(); | 1627 | int x = d->firstX + tmpcw - d->mSepWidth - contentsX(); |
1628 | int h = visibleHeight(); | 1628 | int h = visibleHeight(); |
1629 | 1629 | ||
1630 | QPainter p( viewport() ); | 1630 | QPainter p( viewport() ); |
1631 | p.setRasterOp( XorROP ); | 1631 | p.setRasterOp( XorROP ); |
1632 | p.setPen( gray ); | 1632 | p.setPen( gray ); |
1633 | p.setBrush( gray ); | 1633 | p.setBrush( gray ); |
1634 | uint n = d->first; | 1634 | uint n = d->first; |
1635 | // erase | 1635 | // erase |
1636 | if ( d->mRubberBandAnchor ) | 1636 | if ( d->mRubberBandAnchor ) |
1637 | do { | 1637 | do { |
1638 | p.drawRect( x, 0, 2, h ); | 1638 | p.drawRect( x, 0, 2, h ); |
1639 | x += tmpcw; | 1639 | x += tmpcw; |
1640 | n++; | 1640 | n++; |
1641 | } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); | 1641 | } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); |
1642 | // paint new | 1642 | // paint new |
1643 | if ( ! pos ) return; | 1643 | if ( ! pos ) return; |
1644 | tmpcw = (pos - d->firstX)/d->span; | 1644 | tmpcw = (pos - d->firstX)/d->span; |
1645 | n = d->first; | 1645 | n = d->first; |
1646 | x = d->firstX + tmpcw - d->mSepWidth - contentsX(); | 1646 | x = d->firstX + tmpcw - d->mSepWidth - contentsX(); |
1647 | do { | 1647 | do { |
1648 | p.drawRect( x, 0, 2, h ); | 1648 | p.drawRect( x, 0, 2, h ); |
1649 | x += tmpcw; | 1649 | x += tmpcw; |
1650 | n++; | 1650 | n++; |
1651 | } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); | 1651 | } while ( x < visibleWidth() && n < d->mSeparatorList.count() ); |
1652 | d->mRubberBandAnchor = pos; | 1652 | d->mRubberBandAnchor = pos; |
1653 | } | 1653 | } |
1654 | 1654 | ||
1655 | 1655 | ||
1656 | int CardView::itemWidth() const | 1656 | int CardView::itemWidth() const |
1657 | { | 1657 | { |
1658 | return d->mItemWidth; | 1658 | return d->mItemWidth; |
1659 | } | 1659 | } |
1660 | 1660 | ||
1661 | void CardView::setItemWidth( int w ) | 1661 | void CardView::setItemWidth( int w ) |
1662 | { | 1662 | { |
1663 | if ( w == d->mItemWidth ) | 1663 | if ( w == d->mItemWidth ) |
1664 | return; | 1664 | return; |
1665 | if ( w < MIN_ITEM_WIDTH ) | 1665 | if ( w < MIN_ITEM_WIDTH ) |
1666 | w = MIN_ITEM_WIDTH; | 1666 | w = MIN_ITEM_WIDTH; |
1667 | d->mItemWidth = w; | 1667 | d->mItemWidth = w; |
1668 | setLayoutDirty( true ); | 1668 | setLayoutDirty( true ); |
1669 | #ifndef KAB_EMBEDDED | 1669 | #ifndef KAB_EMBEDDED |
1670 | updateContents(); | 1670 | updateContents(); |
1671 | #else //KAB_EMBEDDED | 1671 | #else //KAB_EMBEDDED |
1672 | //US updateContents( d->contentsX(), d->contentsY(), visibleWidth(), visibleHeight() ); | 1672 | //US updateContents( d->contentsX(), d->contentsY(), visibleWidth(), visibleHeight() ); |
1673 | qDebug("CardView::setItemWidth has to be verified"); | 1673 | qDebug("CardView::setItemWidth has to be verified"); |
1674 | updateContents( contentsX(), contentsY(), visibleWidth(), visibleHeight() ); | 1674 | updateContents( contentsX(), contentsY(), visibleWidth(), visibleHeight() ); |
1675 | #endif //KAB_EMBEDDED | 1675 | #endif //KAB_EMBEDDED |
1676 | } | 1676 | } |
1677 | 1677 | ||
1678 | void CardView::setHeaderFont( const QFont &fnt ) | 1678 | void CardView::setHeaderFont( const QFont &fnt ) |
1679 | { | 1679 | { |
1680 | d->mHeaderFont = fnt; | 1680 | d->mHeaderFont = fnt; |
1681 | delete d->mBFm; | 1681 | delete d->mBFm; |
1682 | d->mBFm = new QFontMetrics( fnt ); | 1682 | d->mBFm = new QFontMetrics( fnt ); |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | QFont CardView::headerFont() const | 1685 | QFont CardView::headerFont() const |
1686 | { | 1686 | { |
1687 | return d->mHeaderFont; | 1687 | return d->mHeaderFont; |
1688 | } | 1688 | } |
1689 | 1689 | ||
1690 | void CardView::setFont( const QFont &fnt ) | 1690 | void CardView::setFont( const QFont &fnt ) |
1691 | { | 1691 | { |
1692 | QScrollView::setFont( fnt ); | 1692 | QScrollView::setFont( fnt ); |
1693 | delete d->mFm; | 1693 | delete d->mFm; |
1694 | d->mFm = new QFontMetrics( fnt ); | 1694 | d->mFm = new QFontMetrics( fnt ); |
1695 | } | 1695 | } |
1696 | 1696 | ||
1697 | int CardView::separatorWidth() | 1697 | int CardView::separatorWidth() |
1698 | { | 1698 | { |
1699 | return d->mSepWidth; | 1699 | return d->mSepWidth; |
1700 | } | 1700 | } |
1701 | 1701 | ||
1702 | void CardView::setSeparatorWidth( int width ) | 1702 | void CardView::setSeparatorWidth( int width ) |
1703 | { | 1703 | { |
1704 | d->mSepWidth = width; | 1704 | d->mSepWidth = width; |
1705 | setLayoutDirty( true ); // hmm, actually I could just adjust the x'es... | 1705 | setLayoutDirty( true ); // hmm, actually I could just adjust the x'es... |
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | int CardView::maxFieldLines() const | 1708 | int CardView::maxFieldLines() const |
1709 | { | 1709 | { |
1710 | return d->mMaxFieldLines; | 1710 | return d->mMaxFieldLines; |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | void CardView::setMaxFieldLines( int howmany ) | 1713 | void CardView::setMaxFieldLines( int howmany ) |
1714 | { | 1714 | { |
1715 | d->mMaxFieldLines = howmany ? howmany : INT_MAX; | 1715 | d->mMaxFieldLines = howmany ? howmany : INT_MAX; |
1716 | // FIXME update, forcing the items to recalc height!! | 1716 | // FIXME update, forcing the items to recalc height!! |
1717 | } | 1717 | } |
1718 | //END Cardview | 1718 | //END Cardview |
1719 | 1719 | ||
1720 | #ifndef KAB_EMBEDDED | 1720 | #ifndef KAB_EMBEDDED |
1721 | #include "cardview.moc" | 1721 | #include "cardview.moc" |
1722 | #endif //KAB_EMBEDDED | 1722 | #endif //KAB_EMBEDDED |
diff --git a/kmicromail/koprefsdialog.cpp b/kmicromail/koprefsdialog.cpp index 4abf859..13d6681 100644 --- a/kmicromail/koprefsdialog.cpp +++ b/kmicromail/koprefsdialog.cpp | |||
@@ -1,1723 +1,1724 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #include <kdialog.h> | 23 | #include <kdialog.h> |
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qbuttongroup.h> | 27 | #include <qbuttongroup.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qfont.h> | 29 | #include <qfont.h> |
30 | #include <qslider.h> | 30 | #include <qslider.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | #include <qhbox.h> | 35 | #include <qhbox.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qstrlist.h> | 42 | #include <qstrlist.h> |
43 | #include <qapplication.h> | 43 | #include <qapplication.h> |
44 | 44 | ||
45 | #include <kcolorbutton.h> | 45 | #include <kcolorbutton.h> |
46 | #include <kdebug.h> | 46 | #include <kdebug.h> |
47 | #include <klocale.h> | 47 | #include <klocale.h> |
48 | #include <kglobal.h> | 48 | #include <kglobal.h> |
49 | #include <kfontdialog.h> | 49 | #include <kfontdialog.h> |
50 | #include <kfiledialog.h> | 50 | #include <kfiledialog.h> |
51 | #include <kmessagebox.h> | 51 | #include <kmessagebox.h> |
52 | #include <kcolordialog.h> | 52 | #include <kcolordialog.h> |
53 | #include <kiconloader.h> | 53 | #include <kiconloader.h> |
54 | #include <kemailsettings.h> | 54 | #include <kemailsettings.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | 56 | ||
57 | #include <klineedit.h> | 57 | #include <klineedit.h> |
58 | 58 | ||
59 | 59 | ||
60 | #include "koprefs.h" | 60 | #include "koprefs.h" |
61 | 61 | ||
62 | #include "koprefsdialog.h" | 62 | #include "koprefsdialog.h" |
63 | //#include <kprefswidget.h> | 63 | //#include <kprefswidget.h> |
64 | 64 | ||
65 | 65 | ||
66 | KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : | 66 | KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : |
67 | KPrefsDialog(KOPrefs::instance(),parent,name,true) | 67 | KPrefsDialog(KOPrefs::instance(),parent,name,true) |
68 | { | 68 | { |
69 | 69 | ||
70 | setCaption( i18n("Settings - some need a restart (nr)")); | 70 | setCaption( i18n("Settings - some need a restart (nr)")); |
71 | setupGlobalTab(); | 71 | setupGlobalTab(); |
72 | setupMainTab(); | 72 | setupMainTab(); |
73 | setupMailTab();; | 73 | setupMailTab();; |
74 | setupFontsTab(); | 74 | setupFontsTab(); |
75 | readConfig(); | 75 | readConfig(); |
76 | 76 | ||
77 | #if 0 | 77 | #if 0 |
78 | 78 | ||
79 | setupMainTab(); | 79 | setupMainTab(); |
80 | setupLocaleTab(); | 80 | setupLocaleTab(); |
81 | setupTimeZoneTab(); | 81 | setupTimeZoneTab(); |
82 | setupTimeTab(); | 82 | setupTimeTab(); |
83 | setupLocaleDateTab(); | 83 | setupLocaleDateTab(); |
84 | setupFontsTab(); | 84 | setupFontsTab(); |
85 | setupColorsTab(); | 85 | setupColorsTab(); |
86 | setupViewsTab(); | 86 | setupViewsTab(); |
87 | //setupSyncTab(); | 87 | //setupSyncTab(); |
88 | //setupSyncAlgTab(); | 88 | //setupSyncAlgTab(); |
89 | //setupPrinterTab(); | 89 | //setupPrinterTab(); |
90 | //setupGroupSchedulingTab(); | 90 | //setupGroupSchedulingTab(); |
91 | //setupGroupAutomationTab(); | 91 | //setupGroupAutomationTab(); |
92 | #endif | 92 | #endif |
93 | } | 93 | } |
94 | 94 | ||
95 | #include "kpimglobalprefs.h" | 95 | #include "kpimglobalprefs.h" |
96 | 96 | ||
97 | KOPrefsDialog::~KOPrefsDialog() | 97 | KOPrefsDialog::~KOPrefsDialog() |
98 | { | 98 | { |
99 | } | 99 | } |
100 | void KOPrefsDialog::setupGlobalTab() | 100 | void KOPrefsDialog::setupGlobalTab() |
101 | { | 101 | { |
102 | QFrame *topFrame = addPage(i18n("Global"),0,0); | 102 | QFrame *topFrame = addPage(i18n("Global"),0,0); |
103 | kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), topFrame, "KCMKdeLibConfig" ); | 103 | kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), topFrame, "KCMKdeLibConfig" ); |
104 | QVBoxLayout *topLayout = new QVBoxLayout(topFrame); | 104 | QVBoxLayout *topLayout = new QVBoxLayout(topFrame); |
105 | topLayout->addWidget( kdelibcfg ); | 105 | topLayout->addWidget( kdelibcfg ); |
106 | 106 | ||
107 | 107 | ||
108 | } | 108 | } |
109 | void KOPrefsDialog::setupMainTab() | 109 | void KOPrefsDialog::setupMainTab() |
110 | { | 110 | { |
111 | QFrame *topFrame = addPage(i18n("General"),0,0); | 111 | QFrame *topFrame = addPage(i18n("General"),0,0); |
112 | 112 | ||
113 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 113 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
114 | topLayout->setSpacing(spacingHint()); | 114 | topLayout->setSpacing(spacingHint()); |
115 | topLayout->setMargin(marginHint()); | 115 | topLayout->setMargin(marginHint()); |
116 | 116 | ||
117 | 117 | ||
118 | mNameEdit = new QLineEdit(topFrame); | 118 | mNameEdit = new QLineEdit(topFrame); |
119 | mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); | 119 | mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); |
120 | topLayout->addWidget(mNameLabel,0,0); | 120 | topLayout->addWidget(mNameLabel,0,0); |
121 | topLayout->addWidget(mNameEdit,0,1); | 121 | topLayout->addWidget(mNameEdit,0,1); |
122 | 122 | ||
123 | mEmailEdit = new QLineEdit(topFrame); | 123 | mEmailEdit = new QLineEdit(topFrame); |
124 | mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); | 124 | mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); |
125 | topLayout->addWidget(mEmailLabel,1,0); | 125 | topLayout->addWidget(mEmailLabel,1,0); |
126 | topLayout->addWidget(mEmailEdit,1,1); | 126 | topLayout->addWidget(mEmailEdit,1,1); |
127 | QLabel *lab = new QLabel( i18n("HINT: Separate multiple\neMail addresses by \";\""), topFrame); | 127 | QLabel *lab = new QLabel( i18n("HINT: Separate multiple\neMail addresses by \";\""), topFrame); |
128 | topLayout->addMultiCellWidget(lab,2,2,0,1); | 128 | topLayout->addMultiCellWidget(lab,2,2,0,1); |
129 | KPrefsDialogWidBool* ttt = addWidBool(i18n("Ignore above settings and\nuse KA/Pi \"Who am I\" instead!"), | 129 | KPrefsDialogWidBool* ttt = addWidBool(i18n("Ignore above settings and\nuse KA/Pi \"Who am I\" instead!"), |
130 | &(KOPrefs::instance()->mUseKapi),topFrame); | 130 | &(KOPrefs::instance()->mUseKapi),topFrame); |
131 | topLayout->addMultiCellWidget(ttt->checkBox(),3,3,0,1); | 131 | topLayout->addMultiCellWidget(ttt->checkBox(),3,3,0,1); |
132 | } | 132 | } |
133 | 133 | ||
134 | void KOPrefsDialog::setupMailTab() | 134 | void KOPrefsDialog::setupMailTab() |
135 | { | 135 | { |
136 | QFrame *topFrame = addPage(i18n("Mail"),0,0); | 136 | QFrame *topFrame = addPage(i18n("Mail"),0,0); |
137 | 137 | ||
138 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); | 138 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); |
139 | topLayout->setSpacing(spacingHint()); | 139 | topLayout->setSpacing(spacingHint()); |
140 | topLayout->setMargin(marginHint()); | 140 | topLayout->setMargin(marginHint()); |
141 | 141 | ||
142 | KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"), | 142 | KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"), |
143 | &(KOPrefs::instance()->mViewAsHtml),topFrame); | 143 | &(KOPrefs::instance()->mViewAsHtml),topFrame); |
144 | topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1); | 144 | topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1); |
145 | 145 | ||
146 | 146 | ||
147 | ttt = addWidBool(i18n("Send mails later"), | 147 | ttt = addWidBool(i18n("Send mails later"), |
148 | &(KOPrefs::instance()->mSendLater),topFrame); | 148 | &(KOPrefs::instance()->mSendLater),topFrame); |
149 | topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1); | 149 | topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1); |
150 | /* | ||
150 | mCodecEdit = new QLineEdit(topFrame); | 151 | mCodecEdit = new QLineEdit(topFrame); |
151 | topLayout->addMultiCellWidget( new QLabel(mCodecEdit, i18n("User defined codec for new mails:"), topFrame),2,2,0,1); | 152 | topLayout->addMultiCellWidget( new QLabel(mCodecEdit, i18n("User defined codec for new mails:"), topFrame),2,2,0,1); |
152 | topLayout->addMultiCellWidget(mCodecEdit,3,3,0,1); | 153 | topLayout->addMultiCellWidget(mCodecEdit,3,3,0,1); |
153 | topLayout->addMultiCellWidget( new QLabel(0, i18n("Example: iso-8859-15"), topFrame),4,4,0,1); | 154 | topLayout->addMultiCellWidget( new QLabel(0, i18n("Example: iso-8859-15"), topFrame),4,4,0,1); |
154 | 155 | */ | |
155 | } | 156 | } |
156 | void KOPrefsDialog::setupFontsTab() | 157 | void KOPrefsDialog::setupFontsTab() |
157 | { | 158 | { |
158 | 159 | ||
159 | QFrame *topFrame = addPage(i18n("Fonts"),0,0); | 160 | QFrame *topFrame = addPage(i18n("Fonts"),0,0); |
160 | // DesktopIcon("fonts",KIcon::SizeMedium)); | 161 | // DesktopIcon("fonts",KIcon::SizeMedium)); |
161 | 162 | ||
162 | QGridLayout *topLayout = new QGridLayout(topFrame,7,3); | 163 | QGridLayout *topLayout = new QGridLayout(topFrame,7,3); |
163 | topLayout->setSpacing(1); | 164 | topLayout->setSpacing(1); |
164 | topLayout->setMargin(3); | 165 | topLayout->setMargin(3); |
165 | KPrefsDialogWidFont * tVFont; | 166 | KPrefsDialogWidFont * tVFont; |
166 | int i = 0; | 167 | int i = 0; |
167 | KPrefsDialogWidFont *timeLabelsFont = | 168 | KPrefsDialogWidFont *timeLabelsFont = |
168 | addWidFont(i18n("OK"),i18n("Application(nr)"), | 169 | addWidFont(i18n("OK"),i18n("Application(nr)"), |
169 | &(KOPrefs::instance()->mAppFont),topFrame); | 170 | &(KOPrefs::instance()->mAppFont),topFrame); |
170 | topLayout->addWidget(timeLabelsFont->label(),i,0); | 171 | topLayout->addWidget(timeLabelsFont->label(),i,0); |
171 | topLayout->addWidget(timeLabelsFont->preview(),i,1); | 172 | topLayout->addWidget(timeLabelsFont->preview(),i,1); |
172 | topLayout->addWidget(timeLabelsFont->button(),i,2); | 173 | topLayout->addWidget(timeLabelsFont->button(),i,2); |
173 | ++i; | 174 | ++i; |
174 | 175 | ||
175 | 176 | ||
176 | timeLabelsFont = | 177 | timeLabelsFont = |
177 | addWidFont(i18n("Dear Mr."),i18n("Compose mail:"), | 178 | addWidFont(i18n("Dear Mr."),i18n("Compose mail:"), |
178 | &(KOPrefs::instance()->mComposeFont),topFrame); | 179 | &(KOPrefs::instance()->mComposeFont),topFrame); |
179 | topLayout->addWidget(timeLabelsFont->label(),i,0); | 180 | topLayout->addWidget(timeLabelsFont->label(),i,0); |
180 | topLayout->addWidget(timeLabelsFont->preview(),i,1); | 181 | topLayout->addWidget(timeLabelsFont->preview(),i,1); |
181 | topLayout->addWidget(timeLabelsFont->button(),i,2); | 182 | topLayout->addWidget(timeLabelsFont->button(),i,2); |
182 | ++i; | 183 | ++i; |
183 | 184 | ||
184 | KPrefsDialogWidFont *timeBarFont = | 185 | KPrefsDialogWidFont *timeBarFont = |
185 | addWidFont(i18n("Hello"),i18n("Read mail:"), | 186 | addWidFont(i18n("Hello"),i18n("Read mail:"), |
186 | &(KOPrefs::instance()->mReadFont),topFrame); | 187 | &(KOPrefs::instance()->mReadFont),topFrame); |
187 | topLayout->addWidget(timeBarFont->label(),i,0); | 188 | topLayout->addWidget(timeBarFont->label(),i,0); |
188 | topLayout->addWidget(timeBarFont->preview(),i,1); | 189 | topLayout->addWidget(timeBarFont->preview(),i,1); |
189 | topLayout->addWidget(timeBarFont->button(),i,2); | 190 | topLayout->addWidget(timeBarFont->button(),i,2); |
190 | ++i; | 191 | ++i; |
191 | 192 | ||
192 | topLayout->setColStretch(1,1); | 193 | topLayout->setColStretch(1,1); |
193 | topLayout->setRowStretch(4,1); | 194 | topLayout->setRowStretch(4,1); |
194 | 195 | ||
195 | } | 196 | } |
196 | void KOPrefsDialog::usrReadConfig() | 197 | void KOPrefsDialog::usrReadConfig() |
197 | { | 198 | { |
198 | 199 | ||
199 | mNameEdit->setText(KOPrefs::instance()->mName); | 200 | mNameEdit->setText(KOPrefs::instance()->mName); |
200 | mEmailEdit->setText(KOPrefs::instance()->mEmail); | 201 | mEmailEdit->setText(KOPrefs::instance()->mEmail); |
201 | mCodecEdit->setText(KOPrefs::instance()->mSendCodec); | 202 | //mCodecEdit->setText(KOPrefs::instance()->mSendCodec); |
202 | kdelibcfg->readConfig(); | 203 | kdelibcfg->readConfig(); |
203 | } | 204 | } |
204 | void KOPrefsDialog::usrWriteConfig() | 205 | void KOPrefsDialog::usrWriteConfig() |
205 | { | 206 | { |
206 | KOPrefs::instance()->mName = mNameEdit->text(); | 207 | KOPrefs::instance()->mName = mNameEdit->text(); |
207 | KOPrefs::instance()->mEmail = mEmailEdit->text(); | 208 | KOPrefs::instance()->mEmail = mEmailEdit->text(); |
208 | KOPrefs::instance()->mSendCodec = mCodecEdit->text(); | 209 | //KOPrefs::instance()->mSendCodec = mCodecEdit->text(); |
209 | kdelibcfg->writeConfig(); | 210 | kdelibcfg->writeConfig(); |
210 | 211 | ||
211 | 212 | ||
212 | } | 213 | } |
213 | 214 | ||
214 | #if 0 | 215 | #if 0 |
215 | void KOPrefsDialog::setupLocaleDateTab() | 216 | void KOPrefsDialog::setupLocaleDateTab() |
216 | { | 217 | { |
217 | QFrame *topFrame = addPage(i18n("Date Format"),0,0); | 218 | QFrame *topFrame = addPage(i18n("Date Format"),0,0); |
218 | QGridLayout *topLayout = new QGridLayout(topFrame,3,2); | 219 | QGridLayout *topLayout = new QGridLayout(topFrame,3,2); |
219 | topLayout->setSpacing(spacingHint()); | 220 | topLayout->setSpacing(spacingHint()); |
220 | topLayout->setMargin(marginHint()); | 221 | topLayout->setMargin(marginHint()); |
221 | int iii = 0; | 222 | int iii = 0; |
222 | 223 | ||
223 | 224 | ||
224 | KPrefsWidRadios *syncPrefsGroup = | 225 | KPrefsWidRadios *syncPrefsGroup = |
225 | addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); | 226 | addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); |
226 | QString format; | 227 | QString format; |
227 | if ( QApplication::desktop()->width() < 480 ) | 228 | if ( QApplication::desktop()->width() < 480 ) |
228 | format = "(%d.%m.%Y)"; | 229 | format = "(%d.%m.%Y)"; |
229 | else | 230 | else |
230 | format = "(%d.%m.%Y|%A %d %B %Y)"; | 231 | format = "(%d.%m.%Y|%A %d %B %Y)"; |
231 | syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); | 232 | syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); |
232 | if ( QApplication::desktop()->width() < 480 ) | 233 | if ( QApplication::desktop()->width() < 480 ) |
233 | format = "(%m.%d.%Y)"; | 234 | format = "(%m.%d.%Y)"; |
234 | else | 235 | else |
235 | format = "(%m.%d.%Y|%A %B %d %Y)"; | 236 | format = "(%m.%d.%Y|%A %B %d %Y)"; |
236 | syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); | 237 | syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); |
237 | if ( QApplication::desktop()->width() < 480 ) | 238 | if ( QApplication::desktop()->width() < 480 ) |
238 | format = "(%Y-%m-%d)"; | 239 | format = "(%Y-%m-%d)"; |
239 | else | 240 | else |
240 | format = "(%Y-%m-%d|%A %Y %B %d)"; | 241 | format = "(%Y-%m-%d|%A %Y %B %d)"; |
241 | syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); | 242 | syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); |
242 | syncPrefsGroup->addRadio(i18n("User defined")); | 243 | syncPrefsGroup->addRadio(i18n("User defined")); |
243 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); | 244 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); |
244 | ++iii; | 245 | ++iii; |
245 | ++iii; | 246 | ++iii; |
246 | QLabel * lab; | 247 | QLabel * lab; |
247 | mUserDateFormatLong = new QLineEdit(topFrame); | 248 | mUserDateFormatLong = new QLineEdit(topFrame); |
248 | lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); | 249 | lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); |
249 | topLayout->addWidget(lab ,iii,0); | 250 | topLayout->addWidget(lab ,iii,0); |
250 | topLayout->addWidget(mUserDateFormatLong,iii,1); | 251 | topLayout->addWidget(mUserDateFormatLong,iii,1); |
251 | ++iii; | 252 | ++iii; |
252 | mUserDateFormatShort = new QLineEdit(topFrame); | 253 | mUserDateFormatShort = new QLineEdit(topFrame); |
253 | lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); | 254 | lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); |
254 | topLayout->addWidget(lab ,iii,0); | 255 | topLayout->addWidget(lab ,iii,0); |
255 | topLayout->addWidget(mUserDateFormatShort,iii,1); | 256 | topLayout->addWidget(mUserDateFormatShort,iii,1); |
256 | ++iii; | 257 | ++iii; |
257 | lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); | 258 | lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); |
258 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); | 259 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); |
259 | ++iii; | 260 | ++iii; |
260 | lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); | 261 | lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); |
261 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); | 262 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); |
262 | ++iii; | 263 | ++iii; |
263 | lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); | 264 | lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); |
264 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); | 265 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); |
265 | ++iii; | 266 | ++iii; |
266 | 267 | ||
267 | } | 268 | } |
268 | 269 | ||
269 | void KOPrefsDialog::setupLocaleTab() | 270 | void KOPrefsDialog::setupLocaleTab() |
270 | { | 271 | { |
271 | QFrame *topFrame = addPage(i18n("Locale"),0,0); | 272 | QFrame *topFrame = addPage(i18n("Locale"),0,0); |
272 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); | 273 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); |
273 | topLayout->setSpacing(spacingHint()); | 274 | topLayout->setSpacing(spacingHint()); |
274 | topLayout->setMargin(marginHint()); | 275 | topLayout->setMargin(marginHint()); |
275 | int iii = 0; | 276 | int iii = 0; |
276 | KPrefsWidRadios *syncPrefsGroup = | 277 | KPrefsWidRadios *syncPrefsGroup = |
277 | addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame); | 278 | addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame); |
278 | syncPrefsGroup->addRadio(i18n("English")); | 279 | syncPrefsGroup->addRadio(i18n("English")); |
279 | syncPrefsGroup->addRadio(i18n("German")); | 280 | syncPrefsGroup->addRadio(i18n("German")); |
280 | syncPrefsGroup->addRadio(i18n("French")); | 281 | syncPrefsGroup->addRadio(i18n("French")); |
281 | syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); | 282 | syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); |
282 | if ( QApplication::desktop()->width() < 300 ) | 283 | if ( QApplication::desktop()->width() < 300 ) |
283 | ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); | 284 | ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); |
284 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); | 285 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); |
285 | ++iii; | 286 | ++iii; |
286 | 287 | ||
287 | syncPrefsGroup = | 288 | syncPrefsGroup = |
288 | addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame); | 289 | addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame); |
289 | if ( QApplication::desktop()->width() > 300 ) | 290 | if ( QApplication::desktop()->width() > 300 ) |
290 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); | 291 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); |
291 | syncPrefsGroup->addRadio(i18n("24:00")); | 292 | syncPrefsGroup->addRadio(i18n("24:00")); |
292 | syncPrefsGroup->addRadio(i18n("12:00am")); | 293 | syncPrefsGroup->addRadio(i18n("12:00am")); |
293 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); | 294 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); |
294 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); | 295 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); |
295 | ++iii; | 296 | ++iii; |
296 | KPrefsDialogWidBool *sb; | 297 | KPrefsDialogWidBool *sb; |
297 | if ( QApplication::desktop()->width() < 300 ) { | 298 | if ( QApplication::desktop()->width() < 300 ) { |
298 | sb = | 299 | sb = |
299 | addWidBool(i18n("Week starts on Sunday"), | 300 | addWidBool(i18n("Week starts on Sunday"), |
300 | &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame); | 301 | &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame); |
301 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 302 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
302 | ++iii; | 303 | ++iii; |
303 | sb = | 304 | sb = |
304 | addWidBool(i18n("Use short date in (WN/E) view"), | 305 | addWidBool(i18n("Use short date in (WN/E) view"), |
305 | &(KOPrefs::instance()->mShortDateInViewer),topFrame); | 306 | &(KOPrefs::instance()->mShortDateInViewer),topFrame); |
306 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 307 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
307 | } | 308 | } |
308 | else { | 309 | else { |
309 | QWidget * hb = new QWidget( topFrame ); | 310 | QWidget * hb = new QWidget( topFrame ); |
310 | QHBoxLayout *hbLayout = new QHBoxLayout(hb); | 311 | QHBoxLayout *hbLayout = new QHBoxLayout(hb); |
311 | sb = | 312 | sb = |
312 | addWidBool(i18n("Week starts on Sunday"), | 313 | addWidBool(i18n("Week starts on Sunday"), |
313 | &(KOPrefs::instance()->mWeekStartsOnSunday),hb); | 314 | &(KOPrefs::instance()->mWeekStartsOnSunday),hb); |
314 | hbLayout->addWidget(sb->checkBox() ); | 315 | hbLayout->addWidget(sb->checkBox() ); |
315 | sb = | 316 | sb = |
316 | addWidBool(i18n("Use short date in (WN/E) view"), | 317 | addWidBool(i18n("Use short date in (WN/E) view"), |
317 | &(KOPrefs::instance()->mShortDateInViewer),hb); | 318 | &(KOPrefs::instance()->mShortDateInViewer),hb); |
318 | hbLayout->addWidget(sb->checkBox() ); | 319 | hbLayout->addWidget(sb->checkBox() ); |
319 | topLayout->addMultiCellWidget(hb, iii,iii,0,1); | 320 | topLayout->addMultiCellWidget(hb, iii,iii,0,1); |
320 | 321 | ||
321 | } | 322 | } |
322 | //#ifndef DESKTOP_VERSION | 323 | //#ifndef DESKTOP_VERSION |
323 | #if 0 | 324 | #if 0 |
324 | ++iii; | 325 | ++iii; |
325 | sb = | 326 | sb = |
326 | addWidBool(i18n("Quick load/save (w/o Unicode)"), | 327 | addWidBool(i18n("Quick load/save (w/o Unicode)"), |
327 | &(KOPrefs::instance()->mUseQuicksave),topFrame); | 328 | &(KOPrefs::instance()->mUseQuicksave),topFrame); |
328 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 329 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
329 | #endif | 330 | #endif |
330 | } | 331 | } |
331 | void KOPrefsDialog::showSyncPage() | 332 | void KOPrefsDialog::showSyncPage() |
332 | { | 333 | { |
333 | showPage ( 2 ) ; | 334 | showPage ( 2 ) ; |
334 | 335 | ||
335 | } | 336 | } |
336 | void KOPrefsDialog::setupSyncAlgTab() | 337 | void KOPrefsDialog::setupSyncAlgTab() |
337 | { | 338 | { |
338 | #if 0 | 339 | #if 0 |
339 | QLabel * lab; | 340 | QLabel * lab; |
340 | QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0); | 341 | QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0); |
341 | mSetupSyncAlgTab = topFrame; | 342 | mSetupSyncAlgTab = topFrame; |
342 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 343 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
343 | topLayout->setSpacing(spacingHint()); | 344 | topLayout->setSpacing(spacingHint()); |
344 | topLayout->setMargin(marginHint()); | 345 | topLayout->setMargin(marginHint()); |
345 | int iii = 0; | 346 | int iii = 0; |
346 | 347 | ||
347 | KPrefsDialogWidBool *sb = | 348 | KPrefsDialogWidBool *sb = |
348 | addWidBool(i18n("Ask for preferences before syncing"), | 349 | addWidBool(i18n("Ask for preferences before syncing"), |
349 | &(KOPrefs::instance()->mAskForPreferences),topFrame); | 350 | &(KOPrefs::instance()->mAskForPreferences),topFrame); |
350 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 351 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
351 | 352 | ||
352 | ++iii; | 353 | ++iii; |
353 | 354 | ||
354 | KPrefsWidRadios *syncPrefsGroup = | 355 | KPrefsWidRadios *syncPrefsGroup = |
355 | addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs), | 356 | addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs), |
356 | topFrame); | 357 | topFrame); |
357 | syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 358 | syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
358 | syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 359 | syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
359 | syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 360 | syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
360 | syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 361 | syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
361 | syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 362 | syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
362 | syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 363 | syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
363 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); | 364 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); |
364 | ++iii; | 365 | ++iii; |
365 | sb = | 366 | sb = |
366 | addWidBool(i18n("Show summary after syncing"), | 367 | addWidBool(i18n("Show summary after syncing"), |
367 | &(KOPrefs::instance()->mShowSyncSummary),topFrame); | 368 | &(KOPrefs::instance()->mShowSyncSummary),topFrame); |
368 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 369 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
369 | 370 | ||
370 | ++iii; | 371 | ++iii; |
371 | #endif | 372 | #endif |
372 | 373 | ||
373 | 374 | ||
374 | 375 | ||
375 | } | 376 | } |
376 | 377 | ||
377 | 378 | ||
378 | void KOPrefsDialog::setupSyncTab() | 379 | void KOPrefsDialog::setupSyncTab() |
379 | { | 380 | { |
380 | #if 0 | 381 | #if 0 |
381 | QLabel * lab; | 382 | QLabel * lab; |
382 | QFrame *topFrame = addPage(i18n("Sync Network"),0,0); | 383 | QFrame *topFrame = addPage(i18n("Sync Network"),0,0); |
383 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 384 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
384 | topLayout->setSpacing(spacingHint()); | 385 | topLayout->setSpacing(spacingHint()); |
385 | topLayout->setMargin(marginHint()); | 386 | topLayout->setMargin(marginHint()); |
386 | lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame); | 387 | lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame); |
387 | int iii = 0; | 388 | int iii = 0; |
388 | topLayout->addMultiCellWidget(lab , iii,iii,0,1); | 389 | topLayout->addMultiCellWidget(lab , iii,iii,0,1); |
389 | ++iii; | 390 | ++iii; |
390 | 391 | ||
391 | mRemoteIPEdit = new QLineEdit(topFrame); | 392 | mRemoteIPEdit = new QLineEdit(topFrame); |
392 | lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame); | 393 | lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame); |
393 | topLayout->addWidget(lab ,iii,0); | 394 | topLayout->addWidget(lab ,iii,0); |
394 | topLayout->addWidget(mRemoteIPEdit,iii,1); | 395 | topLayout->addWidget(mRemoteIPEdit,iii,1); |
395 | ++iii; | 396 | ++iii; |
396 | mRemoteUser = new QLineEdit(topFrame); | 397 | mRemoteUser = new QLineEdit(topFrame); |
397 | lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame); | 398 | lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame); |
398 | topLayout->addWidget(lab ,iii,0); | 399 | topLayout->addWidget(lab ,iii,0); |
399 | topLayout->addWidget(mRemoteUser, iii,1); | 400 | topLayout->addWidget(mRemoteUser, iii,1); |
400 | ++iii; | 401 | ++iii; |
401 | 402 | ||
402 | mRemoteFile = new QLineEdit(topFrame); | 403 | mRemoteFile = new QLineEdit(topFrame); |
403 | lab = new QLabel(mRemoteFile, i18n("Remote file:"), topFrame); | 404 | lab = new QLabel(mRemoteFile, i18n("Remote file:"), topFrame); |
404 | topLayout->addWidget(lab ,iii,0); | 405 | topLayout->addWidget(lab ,iii,0); |
405 | topLayout->addWidget(mRemoteFile,iii,1); | 406 | topLayout->addWidget(mRemoteFile,iii,1); |
406 | ++iii; | 407 | ++iii; |
407 | 408 | ||
408 | mLocalTempFile = new QLineEdit(topFrame); | 409 | mLocalTempFile = new QLineEdit(topFrame); |
409 | lab = new QLabel(mLocalTempFile, i18n("Local temp file:"), topFrame); | 410 | lab = new QLabel(mLocalTempFile, i18n("Local temp file:"), topFrame); |
410 | topLayout->addWidget(lab ,iii,0); | 411 | topLayout->addWidget(lab ,iii,0); |
411 | topLayout->addWidget(mLocalTempFile,iii,1); | 412 | topLayout->addWidget(mLocalTempFile,iii,1); |
412 | ++iii; | 413 | ++iii; |
413 | 414 | ||
414 | KPrefsDialogWidBool *wb = | 415 | KPrefsDialogWidBool *wb = |
415 | addWidBool(i18n("Write back synced file"), | 416 | addWidBool(i18n("Write back synced file"), |
416 | &(KOPrefs::instance()->mWriteBackFile),topFrame); | 417 | &(KOPrefs::instance()->mWriteBackFile),topFrame); |
417 | topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); | 418 | topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); |
418 | ++iii; | 419 | ++iii; |
419 | wb = | 420 | wb = |
420 | addWidBool(i18n("Write back existing entries only"), | 421 | addWidBool(i18n("Write back existing entries only"), |
421 | &(KOPrefs::instance()->mWriteBackExistingOnly),topFrame); | 422 | &(KOPrefs::instance()->mWriteBackExistingOnly),topFrame); |
422 | topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); | 423 | topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); |
423 | ++iii; | 424 | ++iii; |
424 | 425 | ||
425 | #endif | 426 | #endif |
426 | } | 427 | } |
427 | 428 | ||
428 | void KOPrefsDialog::setupMainTab() | 429 | void KOPrefsDialog::setupMainTab() |
429 | { | 430 | { |
430 | QFrame *topFrame = addPage(i18n("General"),0,0); | 431 | QFrame *topFrame = addPage(i18n("General"),0,0); |
431 | // DesktopIcon("identity",KIcon::SizeMedium)); | 432 | // DesktopIcon("identity",KIcon::SizeMedium)); |
432 | 433 | ||
433 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 434 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
434 | topLayout->setSpacing(spacingHint()); | 435 | topLayout->setSpacing(spacingHint()); |
435 | topLayout->setMargin(marginHint()); | 436 | topLayout->setMargin(marginHint()); |
436 | 437 | ||
437 | // KPrefsDialogWidBool *emailControlCenter = | 438 | // KPrefsDialogWidBool *emailControlCenter = |
438 | // addWidBool(i18n("&Use email settings from Control Center"), | 439 | // addWidBool(i18n("&Use email settings from Control Center"), |
439 | // &(KOPrefs::instance()->mEmailControlCenter),topFrame); | 440 | // &(KOPrefs::instance()->mEmailControlCenter),topFrame); |
440 | // topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1); | 441 | // topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1); |
441 | // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), | 442 | // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), |
442 | // SLOT(toggleEmailSettings(bool))); | 443 | // SLOT(toggleEmailSettings(bool))); |
443 | 444 | ||
444 | mNameEdit = new QLineEdit(topFrame); | 445 | mNameEdit = new QLineEdit(topFrame); |
445 | mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); | 446 | mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); |
446 | topLayout->addWidget(mNameLabel,0,0); | 447 | topLayout->addWidget(mNameLabel,0,0); |
447 | topLayout->addWidget(mNameEdit,0,1); | 448 | topLayout->addWidget(mNameEdit,0,1); |
448 | 449 | ||
449 | mEmailEdit = new QLineEdit(topFrame); | 450 | mEmailEdit = new QLineEdit(topFrame); |
450 | mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); | 451 | mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); |
451 | topLayout->addWidget(mEmailLabel,1,0); | 452 | topLayout->addWidget(mEmailLabel,1,0); |
452 | topLayout->addWidget(mEmailEdit,1,1); | 453 | topLayout->addWidget(mEmailEdit,1,1); |
453 | KPrefsDialogWidBool *wb; | 454 | KPrefsDialogWidBool *wb; |
454 | QHBox *dummy; | 455 | QHBox *dummy; |
455 | if ( QApplication::desktop()->width() > 480 ) { | 456 | if ( QApplication::desktop()->width() > 480 ) { |
456 | dummy = new QHBox(topFrame); | 457 | dummy = new QHBox(topFrame); |
457 | } else { | 458 | } else { |
458 | dummy = new QVBox(topFrame); | 459 | dummy = new QVBox(topFrame); |
459 | } | 460 | } |
460 | 461 | ||
461 | topLayout->addMultiCellWidget(dummy, 2,2,0,1); | 462 | topLayout->addMultiCellWidget(dummy, 2,2,0,1); |
462 | addWidBool(i18n("Full menu bar(nr)"), | 463 | addWidBool(i18n("Full menu bar(nr)"), |
463 | &(KOPrefs::instance()->mShowFullMenu),dummy); | 464 | &(KOPrefs::instance()->mShowFullMenu),dummy); |
464 | 465 | ||
465 | 466 | ||
466 | addWidBool(i18n("Mini icons in toolbar(nr)"), | 467 | addWidBool(i18n("Mini icons in toolbar(nr)"), |
467 | &(KOPrefs::instance()->mToolBarMiniIcons),dummy); | 468 | &(KOPrefs::instance()->mToolBarMiniIcons),dummy); |
468 | 469 | ||
469 | 470 | ||
470 | dummy = new QHBox(topFrame); | 471 | dummy = new QHBox(topFrame); |
471 | new QLabel(i18n("Days in What's Next:"),dummy); | 472 | new QLabel(i18n("Days in What's Next:"),dummy); |
472 | mWhatsNextSpin = new QSpinBox(1,14,1,dummy); | 473 | mWhatsNextSpin = new QSpinBox(1,14,1,dummy); |
473 | 474 | ||
474 | topLayout->addMultiCellWidget(dummy,3,3,0,1); | 475 | topLayout->addMultiCellWidget(dummy,3,3,0,1); |
475 | 476 | ||
476 | 477 | ||
477 | 478 | ||
478 | dummy = new QHBox(topFrame); | 479 | dummy = new QHBox(topFrame); |
479 | new QLabel(i18n("Days in Next-X-Days:"),dummy); | 480 | new QLabel(i18n("Days in Next-X-Days:"),dummy); |
480 | mNextXDaysSpin = new QSpinBox(2,14,1,dummy); | 481 | mNextXDaysSpin = new QSpinBox(2,14,1,dummy); |
481 | 482 | ||
482 | topLayout->addMultiCellWidget(dummy,4,4,0,1); | 483 | topLayout->addMultiCellWidget(dummy,4,4,0,1); |
483 | 484 | ||
484 | QHBox *prioBox = new QHBox(topFrame); | 485 | QHBox *prioBox = new QHBox(topFrame); |
485 | // intervalBox->setSpacing(spacingHint()); | 486 | // intervalBox->setSpacing(spacingHint()); |
486 | topLayout->addMultiCellWidget(prioBox,5,5,0,1); | 487 | topLayout->addMultiCellWidget(prioBox,5,5,0,1); |
487 | QString messa = i18n("Show topmost todo prios in What's Next:"); | 488 | QString messa = i18n("Show topmost todo prios in What's Next:"); |
488 | 489 | ||
489 | if ( QApplication::desktop()->width() < 300 ) | 490 | if ( QApplication::desktop()->width() < 300 ) |
490 | messa = i18n("Show topmost todo prios in What's N.:"); | 491 | messa = i18n("Show topmost todo prios in What's N.:"); |
491 | QLabel *prioLabel = new QLabel(messa, prioBox); | 492 | QLabel *prioLabel = new QLabel(messa, prioBox); |
492 | mPrioSpin = new QSpinBox(0,5,1,prioBox); | 493 | mPrioSpin = new QSpinBox(0,5,1,prioBox); |
493 | if ( QApplication::desktop()->width() < 300 ) | 494 | if ( QApplication::desktop()->width() < 300 ) |
494 | mPrioSpin->setFixedWidth( 40 ); | 495 | mPrioSpin->setFixedWidth( 40 ); |
495 | 496 | ||
496 | // KPrefsDialogWidBool *bcc = | 497 | // KPrefsDialogWidBool *bcc = |
497 | // addWidBool(i18n("Send copy to owner when mailing events"), | 498 | // addWidBool(i18n("Send copy to owner when mailing events"), |
498 | // &(KOPrefs::instance()->mBcc),topFrame); | 499 | // &(KOPrefs::instance()->mBcc),topFrame); |
499 | // topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); | 500 | // topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); |
500 | 501 | ||
501 | 502 | ||
502 | // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame); | 503 | // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame); |
503 | //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); | 504 | //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); |
504 | 505 | ||
505 | // addWidBool(i18n("Enable automatic saving of calendar"), | 506 | // addWidBool(i18n("Enable automatic saving of calendar"), |
506 | // &(KOPrefs::instance()->mAutoSave),autoSaveGroup); | 507 | // &(KOPrefs::instance()->mAutoSave),autoSaveGroup); |
507 | 508 | ||
508 | QHBox *intervalBox = new QHBox(topFrame); | 509 | QHBox *intervalBox = new QHBox(topFrame); |
509 | // intervalBox->setSpacing(spacingHint()); | 510 | // intervalBox->setSpacing(spacingHint()); |
510 | topLayout->addMultiCellWidget(intervalBox,6,6,0,1); | 511 | topLayout->addMultiCellWidget(intervalBox,6,6,0,1); |
511 | QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox); | 512 | QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox); |
512 | mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); | 513 | mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); |
513 | autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin); | 514 | autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin); |
514 | /* | 515 | /* |
515 | QHBox * agendasize = new QHBox ( topFrame ); | 516 | QHBox * agendasize = new QHBox ( topFrame ); |
516 | 517 | ||
517 | new QLabel (i18n("AllDayAgenda Height:"), agendasize ); | 518 | new QLabel (i18n("AllDayAgenda Height:"), agendasize ); |
518 | 519 | ||
519 | 520 | ||
520 | mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize); | 521 | mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize); |
521 | topLayout->addMultiCellWidget(agendasize,7,7,0,1); | 522 | topLayout->addMultiCellWidget(agendasize,7,7,0,1); |
522 | */ | 523 | */ |
523 | KPrefsDialogWidBool *verticalScreen = | 524 | KPrefsDialogWidBool *verticalScreen = |
524 | addWidBool(i18n("Show vertical screen (Needs restart)"), | 525 | addWidBool(i18n("Show vertical screen (Needs restart)"), |
525 | &(KOPrefs::instance()->mVerticalScreen),topFrame); | 526 | &(KOPrefs::instance()->mVerticalScreen),topFrame); |
526 | //topLayout->addWidget(verticalScreen->checkBox(),ii++,0); | 527 | //topLayout->addWidget(verticalScreen->checkBox(),ii++,0); |
527 | topLayout->addMultiCellWidget(verticalScreen->checkBox(),7,7,0,1); | 528 | topLayout->addMultiCellWidget(verticalScreen->checkBox(),7,7,0,1); |
528 | 529 | ||
529 | KPrefsDialogWidBool *ask = | 530 | KPrefsDialogWidBool *ask = |
530 | addWidBool(i18n("Ask for quit when closing KO/Pi"), | 531 | addWidBool(i18n("Ask for quit when closing KO/Pi"), |
531 | &(KOPrefs::instance()->mAskForQuit),topFrame); | 532 | &(KOPrefs::instance()->mAskForQuit),topFrame); |
532 | topLayout->addMultiCellWidget(ask->checkBox(),8,8,0,1); | 533 | topLayout->addMultiCellWidget(ask->checkBox(),8,8,0,1); |
533 | 534 | ||
534 | 535 | ||
535 | /* | 536 | /* |
536 | KPrefsDialogWidBool *confirmCheck = | 537 | KPrefsDialogWidBool *confirmCheck = |
537 | addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm), | 538 | addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm), |
538 | topFrame); | 539 | topFrame); |
539 | topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); | 540 | topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); |
540 | 541 | ||
541 | 542 | ||
542 | mEnableGroupScheduling = | 543 | mEnableGroupScheduling = |
543 | addWidBool(i18n("Enable group scheduling"), | 544 | addWidBool(i18n("Enable group scheduling"), |
544 | &(KOPrefs::instance()->mEnableGroupScheduling),topFrame); | 545 | &(KOPrefs::instance()->mEnableGroupScheduling),topFrame); |
545 | topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0); | 546 | topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0); |
546 | connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()), | 547 | connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()), |
547 | SLOT(warningGroupScheduling())); | 548 | SLOT(warningGroupScheduling())); |
548 | 549 | ||
549 | mEnableProjectView = | 550 | mEnableProjectView = |
550 | addWidBool(i18n("Enable project view"), | 551 | addWidBool(i18n("Enable project view"), |
551 | &(KOPrefs::instance()->mEnableProjectView),topFrame); | 552 | &(KOPrefs::instance()->mEnableProjectView),topFrame); |
552 | topLayout->addWidget(mEnableProjectView->checkBox(),9,0); | 553 | topLayout->addWidget(mEnableProjectView->checkBox(),9,0); |
553 | connect(mEnableProjectView->checkBox(),SIGNAL(clicked()), | 554 | connect(mEnableProjectView->checkBox(),SIGNAL(clicked()), |
554 | SLOT(warningProjectView())); | 555 | SLOT(warningProjectView())); |
555 | 556 | ||
556 | // Can't be disabled anymore | 557 | // Can't be disabled anymore |
557 | mEnableGroupScheduling->checkBox()->hide(); | 558 | mEnableGroupScheduling->checkBox()->hide(); |
558 | 559 | ||
559 | // Disable setting, because this feature now becomes stable | 560 | // Disable setting, because this feature now becomes stable |
560 | mEnableProjectView->checkBox()->hide(); | 561 | mEnableProjectView->checkBox()->hide(); |
561 | 562 | ||
562 | KPrefsWidRadios *defaultFormatGroup = | 563 | KPrefsWidRadios *defaultFormatGroup = |
563 | addWidRadios(i18n("Default Calendar Format"), | 564 | addWidRadios(i18n("Default Calendar Format"), |
564 | &(KOPrefs::instance()->mDefaultFormat),topFrame); | 565 | &(KOPrefs::instance()->mDefaultFormat),topFrame); |
565 | defaultFormatGroup->addRadio(i18n("vCalendar")); | 566 | defaultFormatGroup->addRadio(i18n("vCalendar")); |
566 | defaultFormatGroup->addRadio(i18n("iCalendar")); | 567 | defaultFormatGroup->addRadio(i18n("iCalendar")); |
567 | 568 | ||
568 | topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1); | 569 | topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1); |
569 | 570 | ||
570 | // Default format unconditionally is iCalendar | 571 | // Default format unconditionally is iCalendar |
571 | defaultFormatGroup->groupBox()->hide(); | 572 | defaultFormatGroup->groupBox()->hide(); |
572 | 573 | ||
573 | KPrefsWidRadios *mailClientGroup = | 574 | KPrefsWidRadios *mailClientGroup = |
574 | addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient), | 575 | addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient), |
575 | topFrame); | 576 | topFrame); |
576 | mailClientGroup->addRadio(i18n("KMail")); | 577 | mailClientGroup->addRadio(i18n("KMail")); |
577 | mailClientGroup->addRadio(i18n("Sendmail")); | 578 | mailClientGroup->addRadio(i18n("Sendmail")); |
578 | topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); | 579 | topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); |
579 | 580 | ||
580 | KPrefsDialogWidBool *htmlsave = | 581 | KPrefsDialogWidBool *htmlsave = |
581 | addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave), | 582 | addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave), |
582 | topFrame); | 583 | topFrame); |
583 | topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1); | 584 | topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1); |
584 | 585 | ||
585 | KPrefsWidRadios *destinationGroup = | 586 | KPrefsWidRadios *destinationGroup = |
586 | addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination), | 587 | addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination), |
587 | topFrame); | 588 | topFrame); |
588 | destinationGroup->addRadio(i18n("be added to the standard resource")); | 589 | destinationGroup->addRadio(i18n("be added to the standard resource")); |
589 | destinationGroup->addRadio(i18n("be asked which resource to use")); | 590 | destinationGroup->addRadio(i18n("be asked which resource to use")); |
590 | topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1); | 591 | topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1); |
591 | 592 | ||
592 | topLayout->setRowStretch(14,1); | 593 | topLayout->setRowStretch(14,1); |
593 | */ | 594 | */ |
594 | } | 595 | } |
595 | 596 | ||
596 | 597 | ||
597 | void KOPrefsDialog::setupTimeTab() | 598 | void KOPrefsDialog::setupTimeTab() |
598 | { | 599 | { |
599 | QFrame *topFrame = addPage(i18n("Time"),0,0); | 600 | QFrame *topFrame = addPage(i18n("Time"),0,0); |
600 | // DesktopIcon("clock",KIcon::SizeMedium)); | 601 | // DesktopIcon("clock",KIcon::SizeMedium)); |
601 | 602 | ||
602 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); | 603 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); |
603 | topLayout->setSpacing(spacingHint()); | 604 | topLayout->setSpacing(spacingHint()); |
604 | topLayout->setMargin(marginHint()); | 605 | topLayout->setMargin(marginHint()); |
605 | 606 | ||
606 | QHBox *dummy = new QHBox(topFrame); | 607 | QHBox *dummy = new QHBox(topFrame); |
607 | KPrefsWidTime *dayBegins = | 608 | KPrefsWidTime *dayBegins = |
608 | addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), | 609 | addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), |
609 | dummy); | 610 | dummy); |
610 | //topLayout->addWidget(dayBegins->label(),2,0); | 611 | //topLayout->addWidget(dayBegins->label(),2,0); |
611 | 612 | ||
612 | //topLayout->addWidget(dayBegins->spinBox(),2,1); | 613 | //topLayout->addWidget(dayBegins->spinBox(),2,1); |
613 | topLayout->addMultiCellWidget(dummy,0,0,0,1); | 614 | topLayout->addMultiCellWidget(dummy,0,0,0,1); |
614 | 615 | ||
615 | topLayout->addWidget(new QLabel(i18n("Default appointment time:"), | 616 | topLayout->addWidget(new QLabel(i18n("Default appointment time:"), |
616 | topFrame),1,0); | 617 | topFrame),1,0); |
617 | mStartTimeSpin = new QSpinBox(0,23,1,topFrame); | 618 | mStartTimeSpin = new QSpinBox(0,23,1,topFrame); |
618 | mStartTimeSpin->setSuffix(":00"); | 619 | mStartTimeSpin->setSuffix(":00"); |
619 | topLayout->addWidget(mStartTimeSpin,1,1); | 620 | topLayout->addWidget(mStartTimeSpin,1,1); |
620 | 621 | ||
621 | topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"), | 622 | topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"), |
622 | topFrame),2,0); | 623 | topFrame),2,0); |
623 | mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame); | 624 | mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame); |
624 | mDefaultDurationSpin->setSuffix(":00"); | 625 | mDefaultDurationSpin->setSuffix(":00"); |
625 | topLayout->addWidget(mDefaultDurationSpin,2,1); | 626 | topLayout->addWidget(mDefaultDurationSpin,2,1); |
626 | 627 | ||
627 | QStringList alarmList; | 628 | QStringList alarmList; |
628 | alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes") | 629 | alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes") |
629 | << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ; | 630 | << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ; |
630 | topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame), | 631 | topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame), |
631 | 3,0); | 632 | 3,0); |
632 | mAlarmTimeCombo = new QComboBox(topFrame); | 633 | mAlarmTimeCombo = new QComboBox(topFrame); |
633 | mAlarmTimeCombo->insertStringList(alarmList); | 634 | mAlarmTimeCombo->insertStringList(alarmList); |
634 | topLayout->addWidget(mAlarmTimeCombo,3,1); | 635 | topLayout->addWidget(mAlarmTimeCombo,3,1); |
635 | 636 | ||
636 | 637 | ||
637 | QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal, | 638 | QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal, |
638 | i18n("Working Hours"), | 639 | i18n("Working Hours"), |
639 | topFrame); | 640 | topFrame); |
640 | topLayout->addMultiCellWidget(workingHoursGroup,4,4,0,1); | 641 | topLayout->addMultiCellWidget(workingHoursGroup,4,4,0,1); |
641 | workingHoursGroup->layout()->setSpacing( 0 ); | 642 | workingHoursGroup->layout()->setSpacing( 0 ); |
642 | workingHoursGroup->layout()->setMargin( 4 ); | 643 | workingHoursGroup->layout()->setMargin( 4 ); |
643 | QHBox *workStartBox = new QHBox(workingHoursGroup); | 644 | QHBox *workStartBox = new QHBox(workingHoursGroup); |
644 | // workStartBox->setMargin( 0 ); | 645 | // workStartBox->setMargin( 0 ); |
645 | addWidTime(i18n("Daily starting hour:"), | 646 | addWidTime(i18n("Daily starting hour:"), |
646 | &(KOPrefs::instance()->mWorkingHoursStart),workStartBox); | 647 | &(KOPrefs::instance()->mWorkingHoursStart),workStartBox); |
647 | 648 | ||
648 | QHBox *workEndBox = new QHBox(workingHoursGroup); | 649 | QHBox *workEndBox = new QHBox(workingHoursGroup); |
649 | //workEndBox->setMargin( 0 ); | 650 | //workEndBox->setMargin( 0 ); |
650 | addWidTime(i18n("Daily ending hour:"), | 651 | addWidTime(i18n("Daily ending hour:"), |
651 | &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox); | 652 | &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox); |
652 | QVBox *excludeBox = new QVBox(workingHoursGroup); | 653 | QVBox *excludeBox = new QVBox(workingHoursGroup); |
653 | //excludeBox->setMargin( 0 ); | 654 | //excludeBox->setMargin( 0 ); |
654 | addWidBool(i18n("Exclude holidays"), | 655 | addWidBool(i18n("Exclude holidays"), |
655 | &(KOPrefs::instance()->mExcludeHolidays),excludeBox); | 656 | &(KOPrefs::instance()->mExcludeHolidays),excludeBox); |
656 | 657 | ||
657 | addWidBool(i18n("Exclude Saturdays"), | 658 | addWidBool(i18n("Exclude Saturdays"), |
658 | &(KOPrefs::instance()->mExcludeSaturdays),excludeBox); | 659 | &(KOPrefs::instance()->mExcludeSaturdays),excludeBox); |
659 | 660 | ||
660 | // KPrefsDialogWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"), | 661 | // KPrefsDialogWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"), |
661 | // &(KOPrefs::instance()->mMarcusBainsShowSeconds), | 662 | // &(KOPrefs::instance()->mMarcusBainsShowSeconds), |
662 | // topFrame); | 663 | // topFrame); |
663 | // topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0); | 664 | // topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0); |
664 | 665 | ||
665 | // topLayout->setRowStretch(6,1); | 666 | // topLayout->setRowStretch(6,1); |
666 | } | 667 | } |
667 | 668 | ||
668 | 669 | ||
669 | void KOPrefsDialog::setupViewsTab() | 670 | void KOPrefsDialog::setupViewsTab() |
670 | { | 671 | { |
671 | 672 | ||
672 | QFrame *topFrame = addPage(i18n("Views"),0,0); | 673 | QFrame *topFrame = addPage(i18n("Views"),0,0); |
673 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 674 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
674 | 675 | ||
675 | QGridLayout *topLayout = new QGridLayout(topFrame,6,1); | 676 | QGridLayout *topLayout = new QGridLayout(topFrame,6,1); |
676 | topLayout->setSpacing(spacingHint()); | 677 | topLayout->setSpacing(spacingHint()); |
677 | topLayout->setMargin(marginHint()); | 678 | topLayout->setMargin(marginHint()); |
678 | 679 | ||
679 | // QBoxLayout *dayBeginsLayout = new QHBoxLayout; | 680 | // QBoxLayout *dayBeginsLayout = new QHBoxLayout; |
680 | // topLayout->addLayout(dayBeginsLayout,0,0); | 681 | // topLayout->addLayout(dayBeginsLayout,0,0); |
681 | 682 | ||
682 | // KPrefsWidTime *dayBegins = | 683 | // KPrefsWidTime *dayBegins = |
683 | // addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), | 684 | // addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), |
684 | // topFrame); | 685 | // topFrame); |
685 | // dayBeginsLayout->addWidget(dayBegins->label()); | 686 | // dayBeginsLayout->addWidget(dayBegins->label()); |
686 | // dayBeginsLayout->addStretch(1); | 687 | // dayBeginsLayout->addStretch(1); |
687 | // dayBeginsLayout->addWidget(dayBegins->spinBox()); | 688 | // dayBeginsLayout->addWidget(dayBegins->spinBox()); |
688 | 689 | ||
689 | // QBoxLayout *nextDaysLayout = new QHBoxLayout; | 690 | // QBoxLayout *nextDaysLayout = new QHBoxLayout; |
690 | // topLayout->addLayout(nextDaysLayout,1,0); | 691 | // topLayout->addLayout(nextDaysLayout,1,0); |
691 | // nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame)); | 692 | // nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame)); |
692 | // mNextXDaysSpin = new QSpinBox(2,14,1,topFrame); | 693 | // mNextXDaysSpin = new QSpinBox(2,14,1,topFrame); |
693 | // nextDaysLayout->addStretch(1); | 694 | // nextDaysLayout->addStretch(1); |
694 | // nextDaysLayout->addWidget(mNextXDaysSpin); | 695 | // nextDaysLayout->addWidget(mNextXDaysSpin); |
695 | 696 | ||
696 | 697 | ||
697 | int ii = 0; | 698 | int ii = 0; |
698 | KPrefsDialogWidBool *dummy = | 699 | KPrefsDialogWidBool *dummy = |
699 | addWidBool(i18n("Edit item on doubleclick (if not, show)"), | 700 | addWidBool(i18n("Edit item on doubleclick (if not, show)"), |
700 | &(KOPrefs::instance()->mEditOnDoubleClick),topFrame); | 701 | &(KOPrefs::instance()->mEditOnDoubleClick),topFrame); |
701 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 702 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
702 | 703 | ||
703 | dummy = | 704 | dummy = |
704 | addWidBool(i18n("Highlight current day in agenda"), | 705 | addWidBool(i18n("Highlight current day in agenda"), |
705 | &(KOPrefs::instance()->mHighlightCurrentDay),topFrame); | 706 | &(KOPrefs::instance()->mHighlightCurrentDay),topFrame); |
706 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 707 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
707 | 708 | ||
708 | dummy = | 709 | dummy = |
709 | addWidBool(i18n("Use light color for highlight current day"), | 710 | addWidBool(i18n("Use light color for highlight current day"), |
710 | &(KOPrefs::instance()->mUseHighlightLightColor),topFrame); | 711 | &(KOPrefs::instance()->mUseHighlightLightColor),topFrame); |
711 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 712 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
712 | 713 | ||
713 | KPrefsDialogWidBool *dailyRecur = | 714 | KPrefsDialogWidBool *dailyRecur = |
714 | addWidBool(i18n("Show events that recur daily in date nav."), | 715 | addWidBool(i18n("Show events that recur daily in date nav."), |
715 | &(KOPrefs::instance()->mDailyRecur),topFrame); | 716 | &(KOPrefs::instance()->mDailyRecur),topFrame); |
716 | topLayout->addWidget(dailyRecur->checkBox(),ii++,0); | 717 | topLayout->addWidget(dailyRecur->checkBox(),ii++,0); |
717 | 718 | ||
718 | KPrefsDialogWidBool *weeklyRecur = | 719 | KPrefsDialogWidBool *weeklyRecur = |
719 | addWidBool(i18n("Show ev. that recur weekly in date nav."), | 720 | addWidBool(i18n("Show ev. that recur weekly in date nav."), |
720 | &(KOPrefs::instance()->mWeeklyRecur),topFrame); | 721 | &(KOPrefs::instance()->mWeeklyRecur),topFrame); |
721 | topLayout->addWidget(weeklyRecur->checkBox(),ii++,0); | 722 | topLayout->addWidget(weeklyRecur->checkBox(),ii++,0); |
722 | if ( QApplication::desktop()->width() > 640 ) { | 723 | if ( QApplication::desktop()->width() > 640 ) { |
723 | 724 | ||
724 | KPrefsDialogWidBool *enableToolTips = | 725 | KPrefsDialogWidBool *enableToolTips = |
725 | addWidBool(i18n("Enable tooltips displaying summary of ev."), | 726 | addWidBool(i18n("Enable tooltips displaying summary of ev."), |
726 | &(KOPrefs::instance()->mEnableToolTips),topFrame); | 727 | &(KOPrefs::instance()->mEnableToolTips),topFrame); |
727 | topLayout->addWidget(enableToolTips->checkBox(),ii++,0); | 728 | topLayout->addWidget(enableToolTips->checkBox(),ii++,0); |
728 | 729 | ||
729 | } | 730 | } |
730 | KPrefsDialogWidBool *passwdk = | 731 | KPrefsDialogWidBool *passwdk = |
731 | addWidBool(i18n("Show parent To-Do's in What's Next view"), | 732 | addWidBool(i18n("Show parent To-Do's in What's Next view"), |
732 | &(KOPrefs::instance()->mWNViewShowsParents),topFrame); | 733 | &(KOPrefs::instance()->mWNViewShowsParents),topFrame); |
733 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 734 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
734 | 735 | ||
735 | passwdk = | 736 | passwdk = |
736 | addWidBool(i18n("Show location in What's Next view"), | 737 | addWidBool(i18n("Show location in What's Next view"), |
737 | &(KOPrefs::instance()->mWNViewShowLocation),topFrame); | 738 | &(KOPrefs::instance()->mWNViewShowLocation),topFrame); |
738 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 739 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
739 | 740 | ||
740 | passwdk = | 741 | passwdk = |
741 | addWidBool(i18n("Show Sync Events in WN/Agenda view"), | 742 | addWidBool(i18n("Show Sync Events in WN/Agenda view"), |
742 | &(KOPrefs::instance()->mShowSyncEvents),topFrame); | 743 | &(KOPrefs::instance()->mShowSyncEvents),topFrame); |
743 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 744 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
744 | 745 | ||
745 | 746 | ||
746 | KPrefsDialogWidBool *marcusBainsEnabled = | 747 | KPrefsDialogWidBool *marcusBainsEnabled = |
747 | addWidBool(i18n("Show Marcus Bains line"), | 748 | addWidBool(i18n("Show Marcus Bains line"), |
748 | &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame); | 749 | &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame); |
749 | topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0); | 750 | topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0); |
750 | 751 | ||
751 | 752 | ||
752 | // topLayout->addWidget(hourSizeGroup,ii++,0); | 753 | // topLayout->addWidget(hourSizeGroup,ii++,0); |
753 | // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0); | 754 | // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0); |
754 | //topLayout->setRowStretch(11,1); | 755 | //topLayout->setRowStretch(11,1); |
755 | 756 | ||
756 | 757 | ||
757 | 758 | ||
758 | 759 | ||
759 | 760 | ||
760 | 761 | ||
761 | topFrame = addPage(i18n("ViewChange"),0,0); | 762 | topFrame = addPage(i18n("ViewChange"),0,0); |
762 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 763 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
763 | 764 | ||
764 | topLayout = new QGridLayout(topFrame,6,1); | 765 | topLayout = new QGridLayout(topFrame,6,1); |
765 | topLayout->setSpacing(spacingHint()); | 766 | topLayout->setSpacing(spacingHint()); |
766 | topLayout->setMargin(marginHint()); | 767 | topLayout->setMargin(marginHint()); |
767 | ii = 0; | 768 | ii = 0; |
768 | 769 | ||
769 | 770 | ||
770 | dummy = | 771 | dummy = |
771 | addWidBool(i18n("Hold fullscreen on view change"), | 772 | addWidBool(i18n("Hold fullscreen on view change"), |
772 | &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame); | 773 | &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame); |
773 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 774 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
774 | 775 | ||
775 | dummy = | 776 | dummy = |
776 | addWidBool(i18n("Hold non-fullscreen on view change"), | 777 | addWidBool(i18n("Hold non-fullscreen on view change"), |
777 | &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame); | 778 | &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame); |
778 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 779 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
779 | 780 | ||
780 | 781 | ||
781 | KPrefsDialogWidBool *fullViewTodo = | 782 | KPrefsDialogWidBool *fullViewTodo = |
782 | addWidBool(i18n("Event list view uses full window"), | 783 | addWidBool(i18n("Event list view uses full window"), |
783 | &(KOPrefs::instance()->mFullViewTodo),topFrame); | 784 | &(KOPrefs::instance()->mFullViewTodo),topFrame); |
784 | topLayout->addWidget(fullViewTodo->checkBox(),ii++,0); | 785 | topLayout->addWidget(fullViewTodo->checkBox(),ii++,0); |
785 | 786 | ||
786 | KPrefsDialogWidBool *fullViewMonth = | 787 | KPrefsDialogWidBool *fullViewMonth = |
787 | addWidBool(i18n("Next days view uses full window"), | 788 | addWidBool(i18n("Next days view uses full window"), |
788 | &(KOPrefs::instance()->mFullViewMonth),topFrame); | 789 | &(KOPrefs::instance()->mFullViewMonth),topFrame); |
789 | topLayout->addWidget(fullViewMonth->checkBox(),ii++,0); | 790 | topLayout->addWidget(fullViewMonth->checkBox(),ii++,0); |
790 | 791 | ||
791 | dummy = | 792 | dummy = |
792 | addWidBool(i18n("Set agenda to DayBeginsAt on change"), | 793 | addWidBool(i18n("Set agenda to DayBeginsAt on change"), |
793 | &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame); | 794 | &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame); |
794 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 795 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
795 | 796 | ||
796 | dummy = | 797 | dummy = |
797 | addWidBool(i18n("Set agenda to current time on change"), | 798 | addWidBool(i18n("Set agenda to current time on change"), |
798 | &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame); | 799 | &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame); |
799 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 800 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
800 | 801 | ||
801 | dummy = | 802 | dummy = |
802 | addWidBool(i18n("Listview uses monthly timespan"), | 803 | addWidBool(i18n("Listview uses monthly timespan"), |
803 | &(KOPrefs::instance()->mListViewMonthTimespan),topFrame); | 804 | &(KOPrefs::instance()->mListViewMonthTimespan),topFrame); |
804 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 805 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
805 | dummy = | 806 | dummy = |
806 | addWidBool(i18n("Highlight selection in Time Edit"), | 807 | addWidBool(i18n("Highlight selection in Time Edit"), |
807 | &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame); | 808 | &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame); |
808 | topLayout->addWidget( dummy->checkBox(), ii++,0); | 809 | topLayout->addWidget( dummy->checkBox(), ii++,0); |
809 | 810 | ||
810 | 811 | ||
811 | 812 | ||
812 | 813 | ||
813 | 814 | ||
814 | topFrame = addPage(i18n("Month View"),0,0); | 815 | topFrame = addPage(i18n("Month View"),0,0); |
815 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 816 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
816 | 817 | ||
817 | topLayout = new QGridLayout(topFrame,5,1); | 818 | topLayout = new QGridLayout(topFrame,5,1); |
818 | topLayout->setSpacing(spacingHint()); | 819 | topLayout->setSpacing(spacingHint()); |
819 | topLayout->setMargin(marginHint()); | 820 | topLayout->setMargin(marginHint()); |
820 | ii = 0; | 821 | ii = 0; |
821 | QLabel *lab; | 822 | QLabel *lab; |
822 | QHBox *habo = new QHBox( topFrame ); | 823 | QHBox *habo = new QHBox( topFrame ); |
823 | if ( QApplication::desktop()->width() < 320 ) { | 824 | if ( QApplication::desktop()->width() < 320 ) { |
824 | lab = new QLabel ( i18n("Show events that recur "), topFrame ); | 825 | lab = new QLabel ( i18n("Show events that recur "), topFrame ); |
825 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); | 826 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); |
826 | ii++; | 827 | ii++; |
827 | 828 | ||
828 | } else { | 829 | } else { |
829 | new QLabel ( i18n("Show events that recur "), habo ); | 830 | new QLabel ( i18n("Show events that recur "), habo ); |
830 | 831 | ||
831 | } | 832 | } |
832 | dailyRecur = | 833 | dailyRecur = |
833 | addWidBool(i18n("daily"), | 834 | addWidBool(i18n("daily"), |
834 | &(KOPrefs::instance()->mMonthDailyRecur),habo); | 835 | &(KOPrefs::instance()->mMonthDailyRecur),habo); |
835 | // topLayout->addWidget(dailyRecur->checkBox(),ii++,0); | 836 | // topLayout->addWidget(dailyRecur->checkBox(),ii++,0); |
836 | 837 | ||
837 | weeklyRecur = | 838 | weeklyRecur = |
838 | addWidBool(i18n("weekly"), | 839 | addWidBool(i18n("weekly"), |
839 | &(KOPrefs::instance()->mMonthWeeklyRecur),habo); | 840 | &(KOPrefs::instance()->mMonthWeeklyRecur),habo); |
840 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); | 841 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); |
841 | ii++; | 842 | ii++; |
842 | 843 | ||
843 | 844 | ||
844 | habo = new QHBox( topFrame ); | 845 | habo = new QHBox( topFrame ); |
845 | if ( QApplication::desktop()->width() < 320 ) { | 846 | if ( QApplication::desktop()->width() < 320 ) { |
846 | lab = new QLabel (i18n("Show in every cell ") , topFrame ); | 847 | lab = new QLabel (i18n("Show in every cell ") , topFrame ); |
847 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); | 848 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); |
848 | ii++; | 849 | ii++; |
849 | 850 | ||
850 | } else { | 851 | } else { |
851 | new QLabel ( i18n("Show in every cell "), habo ); | 852 | new QLabel ( i18n("Show in every cell "), habo ); |
852 | } | 853 | } |
853 | weeklyRecur = | 854 | weeklyRecur = |
854 | addWidBool(i18n("short month"), | 855 | addWidBool(i18n("short month"), |
855 | &(KOPrefs::instance()->mMonthShowShort),habo); | 856 | &(KOPrefs::instance()->mMonthShowShort),habo); |
856 | weeklyRecur = | 857 | weeklyRecur = |
857 | addWidBool(i18n("icons"), | 858 | addWidBool(i18n("icons"), |
858 | &(KOPrefs::instance()->mMonthShowIcons),habo); | 859 | &(KOPrefs::instance()->mMonthShowIcons),habo); |
859 | 860 | ||
860 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); | 861 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); |
861 | ii++; | 862 | ii++; |
862 | #ifdef DESKTOP_VERSION | 863 | #ifdef DESKTOP_VERSION |
863 | KPrefsDialogWidBool *enableMonthScroll = | 864 | KPrefsDialogWidBool *enableMonthScroll = |
864 | addWidBool(i18n("Enable scrollbars in month view cells"), | 865 | addWidBool(i18n("Enable scrollbars in month view cells"), |
865 | &(KOPrefs::instance()->mEnableMonthScroll),topFrame); | 866 | &(KOPrefs::instance()->mEnableMonthScroll),topFrame); |
866 | topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0); | 867 | topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0); |
867 | #endif | 868 | #endif |
868 | 869 | ||
869 | dummy = | 870 | dummy = |
870 | addWidBool(i18n("Show Sat/Sun together"), | 871 | addWidBool(i18n("Show Sat/Sun together"), |
871 | &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame); | 872 | &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame); |
872 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 873 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
873 | 874 | ||
874 | KPrefsDialogWidBool *coloredCategoriesInMonthView = | 875 | KPrefsDialogWidBool *coloredCategoriesInMonthView = |
875 | addWidBool(i18n("Month view uses category colors"), | 876 | addWidBool(i18n("Month view uses category colors"), |
876 | &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame); | 877 | &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame); |
877 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); | 878 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); |
878 | 879 | ||
879 | dummy = | 880 | dummy = |
880 | addWidBool(i18n("Categorie colors are applied to text"), | 881 | addWidBool(i18n("Categorie colors are applied to text"), |
881 | &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame); | 882 | &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame); |
882 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 883 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
883 | coloredCategoriesInMonthView = | 884 | coloredCategoriesInMonthView = |
884 | addWidBool(i18n("Month view uses day colors"), | 885 | addWidBool(i18n("Month view uses day colors"), |
885 | &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame); | 886 | &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame); |
886 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); | 887 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); |
887 | 888 | ||
888 | KPrefsWidColor *holidayColor = | 889 | KPrefsWidColor *holidayColor = |
889 | addWidColor(i18n("Day color odd months"), | 890 | addWidColor(i18n("Day color odd months"), |
890 | &(KOPrefs::instance()->mMonthViewOddColor),topFrame); | 891 | &(KOPrefs::instance()->mMonthViewOddColor),topFrame); |
891 | topLayout->addWidget(holidayColor->label(),ii,0); | 892 | topLayout->addWidget(holidayColor->label(),ii,0); |
892 | topLayout->addWidget(holidayColor->button(),ii++,1); | 893 | topLayout->addWidget(holidayColor->button(),ii++,1); |
893 | 894 | ||
894 | holidayColor = | 895 | holidayColor = |
895 | addWidColor(i18n("Day color even months"), | 896 | addWidColor(i18n("Day color even months"), |
896 | &(KOPrefs::instance()->mMonthViewEvenColor),topFrame); | 897 | &(KOPrefs::instance()->mMonthViewEvenColor),topFrame); |
897 | topLayout->addWidget(holidayColor->label(),ii,0); | 898 | topLayout->addWidget(holidayColor->label(),ii,0); |
898 | topLayout->addWidget(holidayColor->button(),ii++,1); | 899 | topLayout->addWidget(holidayColor->button(),ii++,1); |
899 | 900 | ||
900 | 901 | ||
901 | holidayColor = | 902 | holidayColor = |
902 | addWidColor(i18n("Color for Sundays + category \"Holiday\""), | 903 | addWidColor(i18n("Color for Sundays + category \"Holiday\""), |
903 | &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame); | 904 | &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame); |
904 | topLayout->addWidget(holidayColor->label(),ii,0); | 905 | topLayout->addWidget(holidayColor->label(),ii,0); |
905 | topLayout->addWidget(holidayColor->button(),ii++,1); | 906 | topLayout->addWidget(holidayColor->button(),ii++,1); |
906 | 907 | ||
907 | // *********************** Todo View | 908 | // *********************** Todo View |
908 | 909 | ||
909 | topFrame = addPage(i18n("Todo View"),0,0); | 910 | topFrame = addPage(i18n("Todo View"),0,0); |
910 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 911 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
911 | 912 | ||
912 | topLayout = new QGridLayout(topFrame,4,1); | 913 | topLayout = new QGridLayout(topFrame,4,1); |
913 | topLayout->setSpacing(spacingHint()); | 914 | topLayout->setSpacing(spacingHint()); |
914 | topLayout->setMargin(marginHint()); | 915 | topLayout->setMargin(marginHint()); |
915 | ii = 0; | 916 | ii = 0; |
916 | 917 | ||
917 | KPrefsDialogWidBool *showCompletedTodo = | 918 | KPrefsDialogWidBool *showCompletedTodo = |
918 | addWidBool(i18n("To-do view shows completed Todos"), | 919 | addWidBool(i18n("To-do view shows completed Todos"), |
919 | &(KOPrefs::instance()->mShowCompletedTodo),topFrame); | 920 | &(KOPrefs::instance()->mShowCompletedTodo),topFrame); |
920 | topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0); | 921 | topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0); |
921 | dummy = | 922 | dummy = |
922 | addWidBool(i18n("To-do view shows complete as 'xx %'"), | 923 | addWidBool(i18n("To-do view shows complete as 'xx %'"), |
923 | &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame); | 924 | &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame); |
924 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 925 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
925 | 926 | ||
926 | dummy = | 927 | dummy = |
927 | addWidBool(i18n("Small To-do view uses smaller font"), | 928 | addWidBool(i18n("Small To-do view uses smaller font"), |
928 | &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame); | 929 | &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame); |
929 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 930 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
930 | 931 | ||
931 | 932 | ||
932 | 933 | ||
933 | dummy = | 934 | dummy = |
934 | addWidBool(i18n("Todo view uses category colors"), | 935 | addWidBool(i18n("Todo view uses category colors"), |
935 | &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame); | 936 | &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame); |
936 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 937 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
937 | 938 | ||
938 | 939 | ||
939 | QWidget* wid = new QWidget( topFrame ); | 940 | QWidget* wid = new QWidget( topFrame ); |
940 | // Todo due today color | 941 | // Todo due today color |
941 | KPrefsWidColor *todoDueTodayColor = | 942 | KPrefsWidColor *todoDueTodayColor = |
942 | addWidColor(i18n("Todo due today color:"), | 943 | addWidColor(i18n("Todo due today color:"), |
943 | &(KOPrefs::instance()->mTodoDueTodayColor),wid); | 944 | &(KOPrefs::instance()->mTodoDueTodayColor),wid); |
944 | QHBoxLayout *widLayout = new QHBoxLayout(wid); | 945 | QHBoxLayout *widLayout = new QHBoxLayout(wid); |
945 | widLayout->addWidget( todoDueTodayColor->label() ); | 946 | widLayout->addWidget( todoDueTodayColor->label() ); |
946 | widLayout->addWidget( todoDueTodayColor->button() ); | 947 | widLayout->addWidget( todoDueTodayColor->button() ); |
947 | topLayout->addWidget(wid,ii++,0); | 948 | topLayout->addWidget(wid,ii++,0); |
948 | //topLayout->addWidget(todoDueTodayColor->button(),ii++,1); | 949 | //topLayout->addWidget(todoDueTodayColor->button(),ii++,1); |
949 | 950 | ||
950 | // Todo overdue color | 951 | // Todo overdue color |
951 | wid = new QWidget( topFrame ); | 952 | wid = new QWidget( topFrame ); |
952 | widLayout = new QHBoxLayout(wid); | 953 | widLayout = new QHBoxLayout(wid); |
953 | KPrefsWidColor *todoOverdueColor = | 954 | KPrefsWidColor *todoOverdueColor = |
954 | addWidColor(i18n("Todo overdue color:"), | 955 | addWidColor(i18n("Todo overdue color:"), |
955 | &(KOPrefs::instance()->mTodoOverdueColor),wid); | 956 | &(KOPrefs::instance()->mTodoOverdueColor),wid); |
956 | widLayout->addWidget(todoOverdueColor->label()); | 957 | widLayout->addWidget(todoOverdueColor->label()); |
957 | widLayout->addWidget(todoOverdueColor->button()); | 958 | widLayout->addWidget(todoOverdueColor->button()); |
958 | topLayout->addWidget(wid,ii++,0); | 959 | topLayout->addWidget(wid,ii++,0); |
959 | 960 | ||
960 | dummy = | 961 | dummy = |
961 | addWidBool(i18n("Colors are applied to text"), | 962 | addWidBool(i18n("Colors are applied to text"), |
962 | &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame); | 963 | &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame); |
963 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 964 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
964 | 965 | ||
965 | dummy = | 966 | dummy = |
966 | addWidBool(i18n("Allday Agenda view shows todos"), | 967 | addWidBool(i18n("Allday Agenda view shows todos"), |
967 | &(KOPrefs::instance()->mShowTodoInAgenda),topFrame); | 968 | &(KOPrefs::instance()->mShowTodoInAgenda),topFrame); |
968 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 969 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
969 | 970 | ||
970 | 971 | ||
971 | 972 | ||
972 | 973 | ||
973 | topFrame = addPage(i18n("Alarm"),0,0); | 974 | topFrame = addPage(i18n("Alarm"),0,0); |
974 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 975 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
975 | 976 | ||
976 | topLayout = new QGridLayout(topFrame,2,1); | 977 | topLayout = new QGridLayout(topFrame,2,1); |
977 | topLayout->setSpacing(spacingHint()); | 978 | topLayout->setSpacing(spacingHint()); |
978 | topLayout->setMargin(marginHint()); | 979 | topLayout->setMargin(marginHint()); |
979 | int iii = 0; | 980 | int iii = 0; |
980 | 981 | ||
981 | dummy = | 982 | dummy = |
982 | addWidBool(i18n("Use internal alarm notification"), | 983 | addWidBool(i18n("Use internal alarm notification"), |
983 | &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame); | 984 | &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame); |
984 | topLayout->addWidget(dummy->checkBox(),iii++,0); | 985 | topLayout->addWidget(dummy->checkBox(),iii++,0); |
985 | lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame); | 986 | lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame); |
986 | 987 | ||
987 | topLayout->addWidget(lab ,iii++,0); | 988 | topLayout->addWidget(lab ,iii++,0); |
988 | #ifndef DESKTOP_VERSION | 989 | #ifndef DESKTOP_VERSION |
989 | lab->setAlignment( AlignLeft|WordBreak|AlignTop); | 990 | lab->setAlignment( AlignLeft|WordBreak|AlignTop); |
990 | #else | 991 | #else |
991 | lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 992 | lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
992 | lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); | 993 | lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); |
993 | #endif | 994 | #endif |
994 | 995 | ||
995 | QHBox* dummyBox = new QHBox(topFrame); | 996 | QHBox* dummyBox = new QHBox(topFrame); |
996 | new QLabel(i18n("Play beeps count:"),dummyBox); | 997 | new QLabel(i18n("Play beeps count:"),dummyBox); |
997 | mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox); | 998 | mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox); |
998 | topLayout->addWidget(dummyBox,iii++,0); | 999 | topLayout->addWidget(dummyBox,iii++,0); |
999 | 1000 | ||
1000 | dummyBox = new QHBox(topFrame); | 1001 | dummyBox = new QHBox(topFrame); |
1001 | new QLabel(i18n("Beeps interval in sec:"),dummyBox); | 1002 | new QLabel(i18n("Beeps interval in sec:"),dummyBox); |
1002 | mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox); | 1003 | mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox); |
1003 | topLayout->addWidget(dummyBox,iii++,0); | 1004 | topLayout->addWidget(dummyBox,iii++,0); |
1004 | 1005 | ||
1005 | dummyBox = new QHBox(topFrame); | 1006 | dummyBox = new QHBox(topFrame); |
1006 | new QLabel(i18n("Default suspend time in min:"),dummyBox); | 1007 | new QLabel(i18n("Default suspend time in min:"),dummyBox); |
1007 | mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox); | 1008 | mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox); |
1008 | topLayout->addWidget(dummyBox,iii++,0); | 1009 | topLayout->addWidget(dummyBox,iii++,0); |
1009 | 1010 | ||
1010 | dummyBox = new QHBox(topFrame); | 1011 | dummyBox = new QHBox(topFrame); |
1011 | new QLabel(i18n("Auto suspend count:"),dummyBox); | 1012 | new QLabel(i18n("Auto suspend count:"),dummyBox); |
1012 | mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox); | 1013 | mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox); |
1013 | topLayout->addWidget(dummyBox,iii++,0); | 1014 | topLayout->addWidget(dummyBox,iii++,0); |
1014 | 1015 | ||
1015 | 1016 | ||
1016 | 1017 | ||
1017 | 1018 | ||
1018 | 1019 | ||
1019 | 1020 | ||
1020 | 1021 | ||
1021 | QHBox* hbo = new QHBox ( topFrame ); | 1022 | QHBox* hbo = new QHBox ( topFrame ); |
1022 | mDefaultAlarmFile = new QLineEdit(hbo); | 1023 | mDefaultAlarmFile = new QLineEdit(hbo); |
1023 | QPushButton * loadTemplate = new QPushButton(hbo); | 1024 | QPushButton * loadTemplate = new QPushButton(hbo); |
1024 | QPixmap icon; | 1025 | QPixmap icon; |
1025 | if ( QApplication::desktop()->width() < 321 ) | 1026 | if ( QApplication::desktop()->width() < 321 ) |
1026 | icon = SmallIcon("fileimport16"); | 1027 | icon = SmallIcon("fileimport16"); |
1027 | else | 1028 | else |
1028 | icon = SmallIcon("fileimport"); | 1029 | icon = SmallIcon("fileimport"); |
1029 | loadTemplate->setIconSet (icon ) ; | 1030 | loadTemplate->setIconSet (icon ) ; |
1030 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) ); | 1031 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) ); |
1031 | int size = loadTemplate->sizeHint().height(); | 1032 | int size = loadTemplate->sizeHint().height(); |
1032 | loadTemplate->setFixedSize( size, size ); | 1033 | loadTemplate->setFixedSize( size, size ); |
1033 | //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame); | 1034 | //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame); |
1034 | // topLayout->addWidget(lab ,iii++,0); | 1035 | // topLayout->addWidget(lab ,iii++,0); |
1035 | lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame); | 1036 | lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame); |
1036 | topLayout->addWidget(lab ,iii++,0); | 1037 | topLayout->addWidget(lab ,iii++,0); |
1037 | topLayout->addWidget(hbo,iii++,0); | 1038 | topLayout->addWidget(hbo,iii++,0); |
1038 | // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame); | 1039 | // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame); |
1039 | 1040 | ||
1040 | // topLayout->addWidget(lab ,iii++,0); | 1041 | // topLayout->addWidget(lab ,iii++,0); |
1041 | // #ifndef DESKTOP_VERSION | 1042 | // #ifndef DESKTOP_VERSION |
1042 | // lab->setAlignment( AlignLeft|WordBreak|AlignTop); | 1043 | // lab->setAlignment( AlignLeft|WordBreak|AlignTop); |
1043 | // #else | 1044 | // #else |
1044 | // lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 1045 | // lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
1045 | // lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); | 1046 | // lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); |
1046 | // #endif | 1047 | // #endif |
1047 | 1048 | ||
1048 | 1049 | ||
1049 | } | 1050 | } |
1050 | 1051 | ||
1051 | void KOPrefsDialog::selectSoundFile() | 1052 | void KOPrefsDialog::selectSoundFile() |
1052 | { | 1053 | { |
1053 | QString fileName = mDefaultAlarmFile->text(); | 1054 | QString fileName = mDefaultAlarmFile->text(); |
1054 | fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this ); | 1055 | fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this ); |
1055 | if ( fileName.length() > 0 ) | 1056 | if ( fileName.length() > 0 ) |
1056 | mDefaultAlarmFile->setText( fileName ); | 1057 | mDefaultAlarmFile->setText( fileName ); |
1057 | } | 1058 | } |
1058 | void KOPrefsDialog::setupFontsTab() | 1059 | void KOPrefsDialog::setupFontsTab() |
1059 | { | 1060 | { |
1060 | 1061 | ||
1061 | QFrame *topFrame = addPage(i18n("Fonts"),0,0); | 1062 | QFrame *topFrame = addPage(i18n("Fonts"),0,0); |
1062 | // DesktopIcon("fonts",KIcon::SizeMedium)); | 1063 | // DesktopIcon("fonts",KIcon::SizeMedium)); |
1063 | 1064 | ||
1064 | QGridLayout *topLayout = new QGridLayout(topFrame,7,3); | 1065 | QGridLayout *topLayout = new QGridLayout(topFrame,7,3); |
1065 | topLayout->setSpacing(1); | 1066 | topLayout->setSpacing(1); |
1066 | topLayout->setMargin(3); | 1067 | topLayout->setMargin(3); |
1067 | KPrefsDialogWidFont * tVFont; | 1068 | KPrefsDialogWidFont * tVFont; |
1068 | int i = 0; | 1069 | int i = 0; |
1069 | KPrefsDialogWidFont *timeLabelsFont = | 1070 | KPrefsDialogWidFont *timeLabelsFont = |
1070 | addWidFont(i18n("23"),i18n("DateNavigator:(nr)"), | 1071 | addWidFont(i18n("23"),i18n("DateNavigator:(nr)"), |
1071 | &(KOPrefs::instance()->mDateNavigatorFont),topFrame); | 1072 | &(KOPrefs::instance()->mDateNavigatorFont),topFrame); |
1072 | topLayout->addWidget(timeLabelsFont->label(),i,0); | 1073 | topLayout->addWidget(timeLabelsFont->label(),i,0); |
1073 | topLayout->addWidget(timeLabelsFont->preview(),i,1); | 1074 | topLayout->addWidget(timeLabelsFont->preview(),i,1); |
1074 | topLayout->addWidget(timeLabelsFont->button(),i,2); | 1075 | topLayout->addWidget(timeLabelsFont->button(),i,2); |
1075 | ++i; | 1076 | ++i; |
1076 | 1077 | ||
1077 | 1078 | ||
1078 | timeLabelsFont = | 1079 | timeLabelsFont = |
1079 | addWidFont(i18n("Mon 15"),i18n("Date Labels:"), | 1080 | addWidFont(i18n("Mon 15"),i18n("Date Labels:"), |
1080 | &(KOPrefs::instance()->mTimeLabelsFont),topFrame); | 1081 | &(KOPrefs::instance()->mTimeLabelsFont),topFrame); |
1081 | topLayout->addWidget(timeLabelsFont->label(),i,0); | 1082 | topLayout->addWidget(timeLabelsFont->label(),i,0); |
1082 | topLayout->addWidget(timeLabelsFont->preview(),i,1); | 1083 | topLayout->addWidget(timeLabelsFont->preview(),i,1); |
1083 | topLayout->addWidget(timeLabelsFont->button(),i,2); | 1084 | topLayout->addWidget(timeLabelsFont->button(),i,2); |
1084 | ++i; | 1085 | ++i; |
1085 | 1086 | ||
1086 | KPrefsDialogWidFont *timeBarFont = | 1087 | KPrefsDialogWidFont *timeBarFont = |
1087 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"), | 1088 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"), |
1088 | &(KOPrefs::instance()->mTimeBarFont),topFrame); | 1089 | &(KOPrefs::instance()->mTimeBarFont),topFrame); |
1089 | topLayout->addWidget(timeBarFont->label(),i,0); | 1090 | topLayout->addWidget(timeBarFont->label(),i,0); |
1090 | topLayout->addWidget(timeBarFont->preview(),i,1); | 1091 | topLayout->addWidget(timeBarFont->preview(),i,1); |
1091 | topLayout->addWidget(timeBarFont->button(),i,2); | 1092 | topLayout->addWidget(timeBarFont->button(),i,2); |
1092 | ++i; | 1093 | ++i; |
1093 | 1094 | ||
1094 | 1095 | ||
1095 | KPrefsDialogWidFont *marcusBainsFont = | 1096 | KPrefsDialogWidFont *marcusBainsFont = |
1096 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"), | 1097 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"), |
1097 | &(KOPrefs::instance()->mMarcusBainsFont),topFrame); | 1098 | &(KOPrefs::instance()->mMarcusBainsFont),topFrame); |
1098 | topLayout->addWidget(marcusBainsFont->label(),i,0); | 1099 | topLayout->addWidget(marcusBainsFont->label(),i,0); |
1099 | topLayout->addWidget(marcusBainsFont->preview(),i,1); | 1100 | topLayout->addWidget(marcusBainsFont->preview(),i,1); |
1100 | topLayout->addWidget(marcusBainsFont->button(),i,2); | 1101 | topLayout->addWidget(marcusBainsFont->button(),i,2); |
1101 | ++i; | 1102 | ++i; |
1102 | 1103 | ||
1103 | tVFont = | 1104 | tVFont = |
1104 | addWidFont(i18n("Summary"),i18n("Event Viewer:"), | 1105 | addWidFont(i18n("Summary"),i18n("Event Viewer:"), |
1105 | &(KOPrefs::instance()->mEventViewFont),topFrame); | 1106 | &(KOPrefs::instance()->mEventViewFont),topFrame); |
1106 | topLayout->addWidget(tVFont->label(),i,0); | 1107 | topLayout->addWidget(tVFont->label(),i,0); |
1107 | topLayout->addWidget(tVFont->preview(),i,1); | 1108 | topLayout->addWidget(tVFont->preview(),i,1); |
1108 | topLayout->addWidget(tVFont->button(),i,2); | 1109 | topLayout->addWidget(tVFont->button(),i,2); |
1109 | ++i; | 1110 | ++i; |
1110 | 1111 | ||
1111 | 1112 | ||
1112 | 1113 | ||
1113 | tVFont = | 1114 | tVFont = |
1114 | addWidFont(i18n("Details"),i18n("EditorBox:"), | 1115 | addWidFont(i18n("Details"),i18n("EditorBox:"), |
1115 | &(KOPrefs::instance()->mEditBoxFont),topFrame); | 1116 | &(KOPrefs::instance()->mEditBoxFont),topFrame); |
1116 | topLayout->addWidget(tVFont->label(),i,0); | 1117 | topLayout->addWidget(tVFont->label(),i,0); |
1117 | topLayout->addWidget(tVFont->preview(),i,1); | 1118 | topLayout->addWidget(tVFont->preview(),i,1); |
1118 | topLayout->addWidget(tVFont->button(),i,2); | 1119 | topLayout->addWidget(tVFont->button(),i,2); |
1119 | ++i; | 1120 | ++i; |
1120 | 1121 | ||
1121 | 1122 | ||
1122 | 1123 | ||
1123 | topLayout->setColStretch(1,1); | 1124 | topLayout->setColStretch(1,1); |
1124 | topLayout->setRowStretch(4,1); | 1125 | topLayout->setRowStretch(4,1); |
1125 | 1126 | ||
1126 | 1127 | ||
1127 | i = 0; | 1128 | i = 0; |
1128 | topFrame = addPage(i18n("View Fonts"),0, | 1129 | topFrame = addPage(i18n("View Fonts"),0, |
1129 | DesktopIcon("fonts",KIcon::SizeMedium)); | 1130 | DesktopIcon("fonts",KIcon::SizeMedium)); |
1130 | 1131 | ||
1131 | topLayout = new QGridLayout(topFrame,7,3); | 1132 | topLayout = new QGridLayout(topFrame,7,3); |
1132 | topLayout->setSpacing(1); | 1133 | topLayout->setSpacing(1); |
1133 | topLayout->setMargin(3); | 1134 | topLayout->setMargin(3); |
1134 | 1135 | ||
1135 | tVFont = | 1136 | tVFont = |
1136 | addWidFont(i18n("Configure KO"),i18n("What's Next View:"), | 1137 | addWidFont(i18n("Configure KO"),i18n("What's Next View:"), |
1137 | &(KOPrefs::instance()->mWhatsNextFont),topFrame); | 1138 | &(KOPrefs::instance()->mWhatsNextFont),topFrame); |
1138 | topLayout->addWidget(tVFont->label(),i,0); | 1139 | topLayout->addWidget(tVFont->label(),i,0); |
1139 | topLayout->addWidget(tVFont->preview(),i,1); | 1140 | topLayout->addWidget(tVFont->preview(),i,1); |
1140 | topLayout->addWidget(tVFont->button(),i,2); | 1141 | topLayout->addWidget(tVFont->button(),i,2); |
1141 | ++i; | 1142 | ++i; |
1142 | KPrefsDialogWidFont *agendaViewFont = | 1143 | KPrefsDialogWidFont *agendaViewFont = |
1143 | addWidFont(i18n("Event text"),i18n("Agenda view:"), | 1144 | addWidFont(i18n("Event text"),i18n("Agenda view:"), |
1144 | &(KOPrefs::instance()->mAgendaViewFont),topFrame); | 1145 | &(KOPrefs::instance()->mAgendaViewFont),topFrame); |
1145 | topLayout->addWidget(agendaViewFont->label(),i,0); | 1146 | topLayout->addWidget(agendaViewFont->label(),i,0); |
1146 | topLayout->addWidget(agendaViewFont->preview(),i,1); | 1147 | topLayout->addWidget(agendaViewFont->preview(),i,1); |
1147 | topLayout->addWidget(agendaViewFont->button(),i,2); | 1148 | topLayout->addWidget(agendaViewFont->button(),i,2); |
1148 | ++i; | 1149 | ++i; |
1149 | 1150 | ||
1150 | 1151 | ||
1151 | KPrefsDialogWidFont *monthViewFont = | 1152 | KPrefsDialogWidFont *monthViewFont = |
1152 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"), | 1153 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"), |
1153 | i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame); | 1154 | i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame); |
1154 | topLayout->addWidget(monthViewFont->label(),i,0); | 1155 | topLayout->addWidget(monthViewFont->label(),i,0); |
1155 | topLayout->addWidget(monthViewFont->preview(),i,1); | 1156 | topLayout->addWidget(monthViewFont->preview(),i,1); |
1156 | topLayout->addWidget(monthViewFont->button(),i,2); | 1157 | topLayout->addWidget(monthViewFont->button(),i,2); |
1157 | ++i; | 1158 | ++i; |
1158 | 1159 | ||
1159 | 1160 | ||
1160 | KPrefsDialogWidFont *lVFont = | 1161 | KPrefsDialogWidFont *lVFont = |
1161 | addWidFont(i18n("Event"),i18n("List View:"), | 1162 | addWidFont(i18n("Event"),i18n("List View:"), |
1162 | &(KOPrefs::instance()->mListViewFont),topFrame); | 1163 | &(KOPrefs::instance()->mListViewFont),topFrame); |
1163 | topLayout->addWidget(lVFont->label(),i,0); | 1164 | topLayout->addWidget(lVFont->label(),i,0); |
1164 | topLayout->addWidget(lVFont->preview(),i,1); | 1165 | topLayout->addWidget(lVFont->preview(),i,1); |
1165 | topLayout->addWidget(lVFont->button(),i,2); | 1166 | topLayout->addWidget(lVFont->button(),i,2); |
1166 | ++i; | 1167 | ++i; |
1167 | 1168 | ||
1168 | 1169 | ||
1169 | tVFont = | 1170 | tVFont = |
1170 | addWidFont(i18n("ToDo"),i18n("ToDoView:"), | 1171 | addWidFont(i18n("ToDo"),i18n("ToDoView:"), |
1171 | &(KOPrefs::instance()->mTodoViewFont),topFrame); | 1172 | &(KOPrefs::instance()->mTodoViewFont),topFrame); |
1172 | topLayout->addWidget(tVFont->label(),i,0); | 1173 | topLayout->addWidget(tVFont->label(),i,0); |
1173 | topLayout->addWidget(tVFont->preview(),i,1); | 1174 | topLayout->addWidget(tVFont->preview(),i,1); |
1174 | topLayout->addWidget(tVFont->button(),i,2); | 1175 | topLayout->addWidget(tVFont->button(),i,2); |
1175 | ++i; | 1176 | ++i; |
1176 | 1177 | ||
1177 | 1178 | ||
1178 | tVFont = | 1179 | tVFont = |
1179 | addWidFont(i18n("Today"),i18n("JournalView:"), | 1180 | addWidFont(i18n("Today"),i18n("JournalView:"), |
1180 | &(KOPrefs::instance()->mJornalViewFont),topFrame); | 1181 | &(KOPrefs::instance()->mJornalViewFont),topFrame); |
1181 | topLayout->addWidget(tVFont->label(),i,0); | 1182 | topLayout->addWidget(tVFont->label(),i,0); |
1182 | topLayout->addWidget(tVFont->preview(),i,1); | 1183 | topLayout->addWidget(tVFont->preview(),i,1); |
1183 | topLayout->addWidget(tVFont->button(),i,2); | 1184 | topLayout->addWidget(tVFont->button(),i,2); |
1184 | ++i; | 1185 | ++i; |
1185 | 1186 | ||
1186 | 1187 | ||
1187 | 1188 | ||
1188 | 1189 | ||
1189 | topLayout->setColStretch(1,1); | 1190 | topLayout->setColStretch(1,1); |
1190 | topLayout->setRowStretch(4,1); | 1191 | topLayout->setRowStretch(4,1); |
1191 | 1192 | ||
1192 | 1193 | ||
1193 | 1194 | ||
1194 | 1195 | ||
1195 | } | 1196 | } |
1196 | 1197 | ||
1197 | void KOPrefsDialog::setupColorsTab() | 1198 | void KOPrefsDialog::setupColorsTab() |
1198 | { | 1199 | { |
1199 | QFrame *topFrame = addPage(i18n("Colors"),0,0); | 1200 | QFrame *topFrame = addPage(i18n("Colors"),0,0); |
1200 | // DesktopIcon("colorize",KIcon::SizeMedium)); | 1201 | // DesktopIcon("colorize",KIcon::SizeMedium)); |
1201 | 1202 | ||
1202 | QGridLayout *topLayout = new QGridLayout(topFrame,5,2); | 1203 | QGridLayout *topLayout = new QGridLayout(topFrame,5,2); |
1203 | // topLayout->setSpacing(spacingHint()); | 1204 | // topLayout->setSpacing(spacingHint()); |
1204 | // topLayout->setMargin(marginHint()); | 1205 | // topLayout->setMargin(marginHint()); |
1205 | 1206 | ||
1206 | topLayout->setSpacing(2); | 1207 | topLayout->setSpacing(2); |
1207 | topLayout->setMargin(3); | 1208 | topLayout->setMargin(3); |
1208 | 1209 | ||
1209 | int ii = 1; | 1210 | int ii = 1; |
1210 | QGroupBox *categoryGroup ; | 1211 | QGroupBox *categoryGroup ; |
1211 | 1212 | ||
1212 | categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"), | 1213 | categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"), |
1213 | topFrame); | 1214 | topFrame); |
1214 | topLayout->addMultiCellWidget(categoryGroup,0,0,0,1); | 1215 | topLayout->addMultiCellWidget(categoryGroup,0,0,0,1); |
1215 | 1216 | ||
1216 | mCategoryCombo = new QComboBox(categoryGroup); | 1217 | mCategoryCombo = new QComboBox(categoryGroup); |
1217 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); | 1218 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); |
1218 | connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); | 1219 | connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); |
1219 | 1220 | ||
1220 | mCategoryButton = new KColorButton(categoryGroup); | 1221 | mCategoryButton = new KColorButton(categoryGroup); |
1221 | connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); | 1222 | connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); |
1222 | updateCategoryColor(); | 1223 | updateCategoryColor(); |
1223 | 1224 | ||
1224 | 1225 | ||
1225 | // Holiday Color | 1226 | // Holiday Color |
1226 | 1227 | ||
1227 | KPrefsWidColor *holidayColor = | 1228 | KPrefsWidColor *holidayColor = |
1228 | addWidColor(i18n("Holiday color:"), | 1229 | addWidColor(i18n("Holiday color:"), |
1229 | &(KOPrefs::instance()->mHolidayColor),topFrame); | 1230 | &(KOPrefs::instance()->mHolidayColor),topFrame); |
1230 | topLayout->addWidget(holidayColor->label(),ii,0); | 1231 | topLayout->addWidget(holidayColor->label(),ii,0); |
1231 | topLayout->addWidget(holidayColor->button(),ii++,1); | 1232 | topLayout->addWidget(holidayColor->button(),ii++,1); |
1232 | 1233 | ||
1233 | // Highlight Color | 1234 | // Highlight Color |
1234 | KPrefsWidColor *highlightColor = | 1235 | KPrefsWidColor *highlightColor = |
1235 | addWidColor(i18n("Highlight color:"), | 1236 | addWidColor(i18n("Highlight color:"), |
1236 | &(KOPrefs::instance()->mHighlightColor),topFrame); | 1237 | &(KOPrefs::instance()->mHighlightColor),topFrame); |
1237 | topLayout->addWidget(highlightColor->label(),ii,0); | 1238 | topLayout->addWidget(highlightColor->label(),ii,0); |
1238 | topLayout->addWidget(highlightColor->button(),ii++,1); | 1239 | topLayout->addWidget(highlightColor->button(),ii++,1); |
1239 | 1240 | ||
1240 | // Event color | 1241 | // Event color |
1241 | KPrefsWidColor *eventColor = | 1242 | KPrefsWidColor *eventColor = |
1242 | addWidColor(i18n("Default event color:"), | 1243 | addWidColor(i18n("Default event color:"), |
1243 | &(KOPrefs::instance()->mEventColor),topFrame); | 1244 | &(KOPrefs::instance()->mEventColor),topFrame); |
1244 | topLayout->addWidget(eventColor->label(),ii,0); | 1245 | topLayout->addWidget(eventColor->label(),ii,0); |
1245 | topLayout->addWidget(eventColor->button(),ii++,1); | 1246 | topLayout->addWidget(eventColor->button(),ii++,1); |
1246 | 1247 | ||
1247 | // agenda view background color | 1248 | // agenda view background color |
1248 | KPrefsWidColor *agendaBgColor = | 1249 | KPrefsWidColor *agendaBgColor = |
1249 | addWidColor(i18n("Agenda view background color:"), | 1250 | addWidColor(i18n("Agenda view background color:"), |
1250 | &(KOPrefs::instance()->mAgendaBgColor),topFrame); | 1251 | &(KOPrefs::instance()->mAgendaBgColor),topFrame); |
1251 | topLayout->addWidget(agendaBgColor->label(),ii,0); | 1252 | topLayout->addWidget(agendaBgColor->label(),ii,0); |
1252 | topLayout->addWidget(agendaBgColor->button(),ii++,1); | 1253 | topLayout->addWidget(agendaBgColor->button(),ii++,1); |
1253 | 1254 | ||
1254 | // working hours color | 1255 | // working hours color |
1255 | KPrefsWidColor *workingHoursColor = | 1256 | KPrefsWidColor *workingHoursColor = |
1256 | addWidColor(i18n("Working hours color:"), | 1257 | addWidColor(i18n("Working hours color:"), |
1257 | &(KOPrefs::instance()->mWorkingHoursColor),topFrame); | 1258 | &(KOPrefs::instance()->mWorkingHoursColor),topFrame); |
1258 | topLayout->addWidget(workingHoursColor->label(),ii,0); | 1259 | topLayout->addWidget(workingHoursColor->label(),ii,0); |
1259 | topLayout->addWidget(workingHoursColor->button(),ii++,1); | 1260 | topLayout->addWidget(workingHoursColor->button(),ii++,1); |
1260 | 1261 | ||
1261 | KPrefsDialogWidBool *sb = | 1262 | KPrefsDialogWidBool *sb = |
1262 | addWidBool(i18n("Use colors for application:"), | 1263 | addWidBool(i18n("Use colors for application:"), |
1263 | &(KOPrefs::instance()->mUseAppColors),topFrame); | 1264 | &(KOPrefs::instance()->mUseAppColors),topFrame); |
1264 | topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 ); | 1265 | topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 ); |
1265 | 1266 | ||
1266 | ii++; | 1267 | ii++; |
1267 | KPrefsWidColor * workingHoursColor1 = | 1268 | KPrefsWidColor * workingHoursColor1 = |
1268 | addWidColor(i18n("Buttons, menus, etc.:"), | 1269 | addWidColor(i18n("Buttons, menus, etc.:"), |
1269 | &(KOPrefs::instance()->mAppColor1),topFrame); | 1270 | &(KOPrefs::instance()->mAppColor1),topFrame); |
1270 | topLayout->addWidget(workingHoursColor1->label(),ii,0); | 1271 | topLayout->addWidget(workingHoursColor1->label(),ii,0); |
1271 | topLayout->addWidget(workingHoursColor1->button(),ii++,1); | 1272 | topLayout->addWidget(workingHoursColor1->button(),ii++,1); |
1272 | 1273 | ||
1273 | KPrefsWidColor * workingHoursColor2 = | 1274 | KPrefsWidColor * workingHoursColor2 = |
1274 | addWidColor(i18n("Frames, labels, etc.:"), | 1275 | addWidColor(i18n("Frames, labels, etc.:"), |
1275 | &(KOPrefs::instance()->mAppColor2),topFrame); | 1276 | &(KOPrefs::instance()->mAppColor2),topFrame); |
1276 | topLayout->addWidget(workingHoursColor2->label(),ii,0); | 1277 | topLayout->addWidget(workingHoursColor2->label(),ii,0); |
1277 | topLayout->addWidget(workingHoursColor2->button(),ii++,1); | 1278 | topLayout->addWidget(workingHoursColor2->button(),ii++,1); |
1278 | 1279 | ||
1279 | 1280 | ||
1280 | 1281 | ||
1281 | } | 1282 | } |
1282 | 1283 | ||
1283 | void KOPrefsDialog::setCategoryColor() | 1284 | void KOPrefsDialog::setCategoryColor() |
1284 | { | 1285 | { |
1285 | mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); | 1286 | mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); |
1286 | } | 1287 | } |
1287 | 1288 | ||
1288 | void KOPrefsDialog::updateCategoryColor() | 1289 | void KOPrefsDialog::updateCategoryColor() |
1289 | { | 1290 | { |
1290 | QString cat = mCategoryCombo->currentText(); | 1291 | QString cat = mCategoryCombo->currentText(); |
1291 | QColor *color = mCategoryDict.find(cat); | 1292 | QColor *color = mCategoryDict.find(cat); |
1292 | if (!color) { | 1293 | if (!color) { |
1293 | color = KOPrefs::instance()->categoryColor(cat); | 1294 | color = KOPrefs::instance()->categoryColor(cat); |
1294 | } | 1295 | } |
1295 | if (color) { | 1296 | if (color) { |
1296 | mCategoryButton->setColor(*color); | 1297 | mCategoryButton->setColor(*color); |
1297 | } | 1298 | } |
1298 | } | 1299 | } |
1299 | 1300 | ||
1300 | void KOPrefsDialog::setupPrinterTab() | 1301 | void KOPrefsDialog::setupPrinterTab() |
1301 | { | 1302 | { |
1302 | mPrinterTab = addPage(i18n("Printing"),0, | 1303 | mPrinterTab = addPage(i18n("Printing"),0, |
1303 | DesktopIcon("fileprint",KIcon::SizeMedium)); | 1304 | DesktopIcon("fileprint",KIcon::SizeMedium)); |
1304 | 1305 | ||
1305 | QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2); | 1306 | QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2); |
1306 | topLayout->setSpacing(spacingHint()); | 1307 | topLayout->setSpacing(spacingHint()); |
1307 | topLayout->setMargin(marginHint()); | 1308 | topLayout->setMargin(marginHint()); |
1308 | 1309 | ||
1309 | topLayout->setRowStretch(4,1); | 1310 | topLayout->setRowStretch(4,1); |
1310 | } | 1311 | } |
1311 | 1312 | ||
1312 | void KOPrefsDialog::setupGroupSchedulingTab() | 1313 | void KOPrefsDialog::setupGroupSchedulingTab() |
1313 | { | 1314 | { |
1314 | #if 0 | 1315 | #if 0 |
1315 | QFrame *topFrame = addPage(i18n("Group Scheduling"),0, | 1316 | QFrame *topFrame = addPage(i18n("Group Scheduling"),0, |
1316 | DesktopIcon("personal",KIcon::SizeMedium)); | 1317 | DesktopIcon("personal",KIcon::SizeMedium)); |
1317 | 1318 | ||
1318 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 1319 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
1319 | topLayout->setSpacing(spacingHint()); | 1320 | topLayout->setSpacing(spacingHint()); |
1320 | topLayout->setMargin(marginHint()); | 1321 | topLayout->setMargin(marginHint()); |
1321 | 1322 | ||
1322 | #if 0 | 1323 | #if 0 |
1323 | KPrefsWidRadios *schedulerGroup = | 1324 | KPrefsWidRadios *schedulerGroup = |
1324 | addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler), | 1325 | addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler), |
1325 | topFrame); | 1326 | topFrame); |
1326 | schedulerGroup->addRadio("Dummy"); // Only for debugging | 1327 | schedulerGroup->addRadio("Dummy"); // Only for debugging |
1327 | schedulerGroup->addRadio(i18n("Mail client")); | 1328 | schedulerGroup->addRadio(i18n("Mail client")); |
1328 | 1329 | ||
1329 | topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); | 1330 | topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); |
1330 | #endif | 1331 | #endif |
1331 | 1332 | ||
1332 | KPrefsWidRadios *sendGroup = | 1333 | KPrefsWidRadios *sendGroup = |
1333 | addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend), | 1334 | addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend), |
1334 | topFrame); | 1335 | topFrame); |
1335 | sendGroup->addRadio(i18n("Send to outbox")); | 1336 | sendGroup->addRadio(i18n("Send to outbox")); |
1336 | sendGroup->addRadio(i18n("Send directly")); | 1337 | sendGroup->addRadio(i18n("Send directly")); |
1337 | 1338 | ||
1338 | topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); | 1339 | topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); |
1339 | 1340 | ||
1340 | topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); | 1341 | topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); |
1341 | mAMails = new QListView(topFrame); | 1342 | mAMails = new QListView(topFrame); |
1342 | mAMails->addColumn(i18n("Email"),300); | 1343 | mAMails->addColumn(i18n("Email"),300); |
1343 | topLayout->addMultiCellWidget(mAMails,3,3,0,1); | 1344 | topLayout->addMultiCellWidget(mAMails,3,3,0,1); |
1344 | 1345 | ||
1345 | topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); | 1346 | topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); |
1346 | aEmailsEdit = new QLineEdit(topFrame); | 1347 | aEmailsEdit = new QLineEdit(topFrame); |
1347 | aEmailsEdit->setEnabled(false); | 1348 | aEmailsEdit->setEnabled(false); |
1348 | topLayout->addWidget(aEmailsEdit,4,1); | 1349 | topLayout->addWidget(aEmailsEdit,4,1); |
1349 | 1350 | ||
1350 | QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); | 1351 | QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); |
1351 | topLayout->addWidget(add,5,0); | 1352 | topLayout->addWidget(add,5,0); |
1352 | QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); | 1353 | QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); |
1353 | topLayout->addWidget(del,5,1); | 1354 | topLayout->addWidget(del,5,1); |
1354 | 1355 | ||
1355 | //topLayout->setRowStretch(2,1); | 1356 | //topLayout->setRowStretch(2,1); |
1356 | connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); | 1357 | connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); |
1357 | connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); | 1358 | connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); |
1358 | connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); | 1359 | connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); |
1359 | connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); | 1360 | connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); |
1360 | #endif | 1361 | #endif |
1361 | } | 1362 | } |
1362 | 1363 | ||
1363 | void KOPrefsDialog::setupGroupAutomationTab() | 1364 | void KOPrefsDialog::setupGroupAutomationTab() |
1364 | { | 1365 | { |
1365 | return; | 1366 | return; |
1366 | QFrame *topFrame = addPage(i18n("Group Automation"),0, | 1367 | QFrame *topFrame = addPage(i18n("Group Automation"),0, |
1367 | DesktopIcon("personal",KIcon::SizeMedium)); | 1368 | DesktopIcon("personal",KIcon::SizeMedium)); |
1368 | 1369 | ||
1369 | QGridLayout *topLayout = new QGridLayout(topFrame,5,1); | 1370 | QGridLayout *topLayout = new QGridLayout(topFrame,5,1); |
1370 | topLayout->setSpacing(spacingHint()); | 1371 | topLayout->setSpacing(spacingHint()); |
1371 | topLayout->setMargin(marginHint()); | 1372 | topLayout->setMargin(marginHint()); |
1372 | 1373 | ||
1373 | KPrefsWidRadios *autoRefreshGroup = | 1374 | KPrefsWidRadios *autoRefreshGroup = |
1374 | addWidRadios(i18n("Auto Send Refresh"), | 1375 | addWidRadios(i18n("Auto Send Refresh"), |
1375 | &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame); | 1376 | &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame); |
1376 | autoRefreshGroup->addRadio(i18n("Never")); | 1377 | autoRefreshGroup->addRadio(i18n("Never")); |
1377 | autoRefreshGroup->addRadio(i18n("If attendee is in addressbook")); | 1378 | autoRefreshGroup->addRadio(i18n("If attendee is in addressbook")); |
1378 | //autoRefreshGroup->addRadio(i18n("selected emails")); | 1379 | //autoRefreshGroup->addRadio(i18n("selected emails")); |
1379 | topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0); | 1380 | topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0); |
1380 | 1381 | ||
1381 | KPrefsWidRadios *autoInsertGroup = | 1382 | KPrefsWidRadios *autoInsertGroup = |
1382 | addWidRadios(i18n("Auto Insert IMIP Replies"), | 1383 | addWidRadios(i18n("Auto Insert IMIP Replies"), |
1383 | &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame); | 1384 | &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame); |
1384 | autoInsertGroup->addRadio(i18n("Never")); | 1385 | autoInsertGroup->addRadio(i18n("Never")); |
1385 | autoInsertGroup->addRadio(i18n("If attendee is in addressbook")); | 1386 | autoInsertGroup->addRadio(i18n("If attendee is in addressbook")); |
1386 | //autoInsertGroup->addRadio(i18n("selected emails")); | 1387 | //autoInsertGroup->addRadio(i18n("selected emails")); |
1387 | topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0); | 1388 | topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0); |
1388 | 1389 | ||
1389 | KPrefsWidRadios *autoRequestGroup = | 1390 | KPrefsWidRadios *autoRequestGroup = |
1390 | addWidRadios(i18n("Auto Insert IMIP Requests"), | 1391 | addWidRadios(i18n("Auto Insert IMIP Requests"), |
1391 | &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame); | 1392 | &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame); |
1392 | autoRequestGroup->addRadio(i18n("Never")); | 1393 | autoRequestGroup->addRadio(i18n("Never")); |
1393 | autoRequestGroup->addRadio(i18n("If organizer is in addressbook")); | 1394 | autoRequestGroup->addRadio(i18n("If organizer is in addressbook")); |
1394 | //autoInsertGroup->addRadio(i18n("selected emails")); | 1395 | //autoInsertGroup->addRadio(i18n("selected emails")); |
1395 | topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0); | 1396 | topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0); |
1396 | 1397 | ||
1397 | KPrefsWidRadios *autoFreeBusyGroup = | 1398 | KPrefsWidRadios *autoFreeBusyGroup = |
1398 | addWidRadios(i18n("Auto Send FreeBusy Information"), | 1399 | addWidRadios(i18n("Auto Send FreeBusy Information"), |
1399 | &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame); | 1400 | &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame); |
1400 | autoFreeBusyGroup->addRadio(i18n("Never")); | 1401 | autoFreeBusyGroup->addRadio(i18n("Never")); |
1401 | autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook")); | 1402 | autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook")); |
1402 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); | 1403 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); |
1403 | topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0); | 1404 | topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0); |
1404 | 1405 | ||
1405 | KPrefsWidRadios *autoFreeBusyReplyGroup = | 1406 | KPrefsWidRadios *autoFreeBusyReplyGroup = |
1406 | addWidRadios(i18n("Auto Save FreeBusy Replies"), | 1407 | addWidRadios(i18n("Auto Save FreeBusy Replies"), |
1407 | &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame); | 1408 | &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame); |
1408 | autoFreeBusyReplyGroup->addRadio(i18n("Never")); | 1409 | autoFreeBusyReplyGroup->addRadio(i18n("Never")); |
1409 | autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook")); | 1410 | autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook")); |
1410 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); | 1411 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); |
1411 | topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0); | 1412 | topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0); |
1412 | } | 1413 | } |
1413 | 1414 | ||
1414 | void KOPrefsDialog::showPrinterTab() | 1415 | void KOPrefsDialog::showPrinterTab() |
1415 | { | 1416 | { |
1416 | showPage(pageIndex(mPrinterTab)); | 1417 | showPage(pageIndex(mPrinterTab)); |
1417 | } | 1418 | } |
1418 | 1419 | ||
1419 | 1420 | ||
1420 | void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text, | 1421 | void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text, |
1421 | const QStringList *tags) | 1422 | const QStringList *tags) |
1422 | { | 1423 | { |
1423 | if (tags) { | 1424 | if (tags) { |
1424 | int i = tags->findIndex(text); | 1425 | int i = tags->findIndex(text); |
1425 | if (i > 0) combo->setCurrentItem(i); | 1426 | if (i > 0) combo->setCurrentItem(i); |
1426 | } else { | 1427 | } else { |
1427 | for(int i=0;i<combo->count();++i) { | 1428 | for(int i=0;i<combo->count();++i) { |
1428 | if (combo->text(i) == text) { | 1429 | if (combo->text(i) == text) { |
1429 | combo->setCurrentItem(i); | 1430 | combo->setCurrentItem(i); |
1430 | break; | 1431 | break; |
1431 | } | 1432 | } |
1432 | } | 1433 | } |
1433 | } | 1434 | } |
1434 | } | 1435 | } |
1435 | 1436 | ||
1436 | void KOPrefsDialog::usrReadConfig() | 1437 | void KOPrefsDialog::usrReadConfig() |
1437 | { | 1438 | { |
1438 | mNameEdit->setText(KOPrefs::instance()->fullName()); | 1439 | mNameEdit->setText(KOPrefs::instance()->fullName()); |
1439 | mEmailEdit->setText(KOPrefs::instance()->email()); | 1440 | mEmailEdit->setText(KOPrefs::instance()->email()); |
1440 | 1441 | ||
1441 | mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); | 1442 | mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); |
1442 | QDate current ( 2001, 1,1); | 1443 | QDate current ( 2001, 1,1); |
1443 | mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1)); | 1444 | mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1)); |
1444 | mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1)); | 1445 | mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1)); |
1445 | setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId)); | 1446 | setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId)); |
1446 | //mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset); | 1447 | //mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset); |
1447 | mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); | 1448 | mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); |
1448 | mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); | 1449 | mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); |
1449 | mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); | 1450 | mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); |
1450 | // if (KOPrefs::instance()->mAllDaySize > 47 ) | 1451 | // if (KOPrefs::instance()->mAllDaySize > 47 ) |
1451 | // KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize/2; | 1452 | // KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize/2; |
1452 | //mHourSizeSlider->setValue(KOPrefs::instance()->mAllDaySize); | 1453 | //mHourSizeSlider->setValue(KOPrefs::instance()->mAllDaySize); |
1453 | 1454 | ||
1454 | mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays); | 1455 | mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays); |
1455 | mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays); | 1456 | mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays); |
1456 | mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios); | 1457 | mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios); |
1457 | // mAMails->clear(); | 1458 | // mAMails->clear(); |
1458 | // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); | 1459 | // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); |
1459 | // it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { | 1460 | // it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { |
1460 | // QListViewItem *item = new QListViewItem(mAMails); | 1461 | // QListViewItem *item = new QListViewItem(mAMails); |
1461 | // item->setText(0,*it); | 1462 | // item->setText(0,*it); |
1462 | // mAMails->insertItem(item); | 1463 | // mAMails->insertItem(item); |
1463 | // } | 1464 | // } |
1464 | 1465 | ||
1465 | // mRemoteIPEdit->setText(KOPrefs::instance()->mRemoteIP); | 1466 | // mRemoteIPEdit->setText(KOPrefs::instance()->mRemoteIP); |
1466 | //mRemoteUser->setText(KOPrefs::instance()->mRemoteUser); | 1467 | //mRemoteUser->setText(KOPrefs::instance()->mRemoteUser); |
1467 | //mRemotePassWd->setText(KOPrefs::instance()->mRemotePassWd); | 1468 | //mRemotePassWd->setText(KOPrefs::instance()->mRemotePassWd); |
1468 | //mRemoteFile->setText(KOPrefs::instance()->mRemoteFile); | 1469 | //mRemoteFile->setText(KOPrefs::instance()->mRemoteFile); |
1469 | 1470 | ||
1470 | //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile); | 1471 | //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile); |
1471 | mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile); | 1472 | mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile); |
1472 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1473 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1473 | mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); | 1474 | mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); |
1474 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1475 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1475 | mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); | 1476 | mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); |
1476 | updateCategories(); | 1477 | updateCategories(); |
1477 | mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps ); | 1478 | mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps ); |
1478 | mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime ); | 1479 | mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime ); |
1479 | mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount ); | 1480 | mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount ); |
1480 | mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval ); | 1481 | mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval ); |
1481 | } | 1482 | } |
1482 | 1483 | ||
1483 | 1484 | ||
1484 | void KOPrefsDialog::usrWriteConfig() | 1485 | void KOPrefsDialog::usrWriteConfig() |
1485 | { | 1486 | { |
1486 | 1487 | ||
1487 | // KOPrefs::instance()->mRemoteIP = mRemoteIPEdit->text(); | 1488 | // KOPrefs::instance()->mRemoteIP = mRemoteIPEdit->text(); |
1488 | //KOPrefs::instance()->mRemoteUser = mRemoteUser->text(); | 1489 | //KOPrefs::instance()->mRemoteUser = mRemoteUser->text(); |
1489 | //KOPrefs::instance()->mRemotePassWd = mRemotePassWd->text(); | 1490 | //KOPrefs::instance()->mRemotePassWd = mRemotePassWd->text(); |
1490 | //KOPrefs::instance()->mRemoteFile= mRemoteFile->text(); | 1491 | //KOPrefs::instance()->mRemoteFile= mRemoteFile->text(); |
1491 | //KOPrefs::instance()->mLocalTempFile =mLocalTempFile->text(); | 1492 | //KOPrefs::instance()->mLocalTempFile =mLocalTempFile->text(); |
1492 | KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text(); | 1493 | KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text(); |
1493 | 1494 | ||
1494 | KOPrefs::instance()->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); | 1495 | KOPrefs::instance()->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); |
1495 | KOPrefs::instance()->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); | 1496 | KOPrefs::instance()->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); |
1496 | KOPrefs::instance()->setFullName(mNameEdit->text()); | 1497 | KOPrefs::instance()->setFullName(mNameEdit->text()); |
1497 | KOPrefs::instance()->setEmail(mEmailEdit->text()); | 1498 | KOPrefs::instance()->setEmail(mEmailEdit->text()); |
1498 | 1499 | ||
1499 | KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); | 1500 | KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); |
1500 | 1501 | ||
1501 | KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText(); | 1502 | KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText(); |
1502 | QDate date; | 1503 | QDate date; |
1503 | date = mStartDateSavingEdit->date(); | 1504 | date = mStartDateSavingEdit->date(); |
1504 | int sub = 0; | 1505 | int sub = 0; |
1505 | if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) | 1506 | if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) |
1506 | sub = 1; | 1507 | sub = 1; |
1507 | KOPrefs::instance()->mDaylightsavingStart = date.dayOfYear()-sub; | 1508 | KOPrefs::instance()->mDaylightsavingStart = date.dayOfYear()-sub; |
1508 | date = mEndDateSavingEdit->date(); | 1509 | date = mEndDateSavingEdit->date(); |
1509 | if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) | 1510 | if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) |
1510 | sub = 1; | 1511 | sub = 1; |
1511 | else | 1512 | else |
1512 | sub = 0; | 1513 | sub = 0; |
1513 | KOPrefs::instance()->mDaylightsavingEnd = date.dayOfYear()-sub; | 1514 | KOPrefs::instance()->mDaylightsavingEnd = date.dayOfYear()-sub; |
1514 | // KOPrefs::instance()->mTimeZoneOffset = mTimezoneOffsetSpin->value(); | 1515 | // KOPrefs::instance()->mTimeZoneOffset = mTimezoneOffsetSpin->value(); |
1515 | 1516 | ||
1516 | KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); | 1517 | KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); |
1517 | KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); | 1518 | KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); |
1518 | KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); | 1519 | KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); |
1519 | 1520 | ||
1520 | //KOPrefs::instance()->mAllDaySize = mHourSizeSlider->value(); | 1521 | //KOPrefs::instance()->mAllDaySize = mHourSizeSlider->value(); |
1521 | 1522 | ||
1522 | QDictIterator<QColor> it(mCategoryDict); | 1523 | QDictIterator<QColor> it(mCategoryDict); |
1523 | while (it.current()) { | 1524 | while (it.current()) { |
1524 | KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); | 1525 | KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); |
1525 | ++it; | 1526 | ++it; |
1526 | } | 1527 | } |
1527 | 1528 | ||
1528 | KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value(); | 1529 | KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value(); |
1529 | KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value(); | 1530 | KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value(); |
1530 | KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value(); | 1531 | KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value(); |
1531 | 1532 | ||
1532 | KOPrefs::instance()->mAdditionalMails.clear(); | 1533 | KOPrefs::instance()->mAdditionalMails.clear(); |
1533 | // QListViewItem *item; | 1534 | // QListViewItem *item; |
1534 | // item = mAMails->firstChild(); | 1535 | // item = mAMails->firstChild(); |
1535 | // while (item) | 1536 | // while (item) |
1536 | // { | 1537 | // { |
1537 | // KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); | 1538 | // KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); |
1538 | // item = item->nextSibling(); | 1539 | // item = item->nextSibling(); |
1539 | // } | 1540 | // } |
1540 | KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value(); | 1541 | KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value(); |
1541 | KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ; | 1542 | KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ; |
1542 | KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ; | 1543 | KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ; |
1543 | KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ; | 1544 | KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ; |
1544 | 1545 | ||
1545 | } | 1546 | } |
1546 | 1547 | ||
1547 | void KOPrefsDialog::updateCategories() | 1548 | void KOPrefsDialog::updateCategories() |
1548 | { | 1549 | { |
1549 | mCategoryCombo->clear(); | 1550 | mCategoryCombo->clear(); |
1550 | mCategoryDict.clear(); | 1551 | mCategoryDict.clear(); |
1551 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); | 1552 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); |
1552 | updateCategoryColor(); | 1553 | updateCategoryColor(); |
1553 | } | 1554 | } |
1554 | 1555 | ||
1555 | void KOPrefsDialog::warningGroupScheduling() | 1556 | void KOPrefsDialog::warningGroupScheduling() |
1556 | { | 1557 | { |
1557 | warningExperimental(mEnableGroupScheduling->checkBox()->isChecked()); | 1558 | warningExperimental(mEnableGroupScheduling->checkBox()->isChecked()); |
1558 | } | 1559 | } |
1559 | 1560 | ||
1560 | void KOPrefsDialog::warningProjectView() | 1561 | void KOPrefsDialog::warningProjectView() |
1561 | { | 1562 | { |
1562 | warningExperimental(mEnableProjectView->checkBox()->isChecked()); | 1563 | warningExperimental(mEnableProjectView->checkBox()->isChecked()); |
1563 | } | 1564 | } |
1564 | 1565 | ||
1565 | void KOPrefsDialog::warningExperimental(bool on) | 1566 | void KOPrefsDialog::warningExperimental(bool on) |
1566 | { | 1567 | { |
1567 | if (on) { | 1568 | if (on) { |
1568 | KMessageBox::information(this,i18n("This is an experimental feature. " | 1569 | KMessageBox::information(this,i18n("This is an experimental feature. " |
1569 | "It may not work, it may do nothing useful and it may cause data loss. " | 1570 | "It may not work, it may do nothing useful and it may cause data loss. " |
1570 | "Use with care.\n" | 1571 | "Use with care.\n" |
1571 | "You have to restart KOrganizer for this setting to take effect.")); | 1572 | "You have to restart KOrganizer for this setting to take effect.")); |
1572 | } else { | 1573 | } else { |
1573 | KMessageBox::information(this, | 1574 | KMessageBox::information(this, |
1574 | i18n("You have to restart KOrganizer for this setting to take effect.")); | 1575 | i18n("You have to restart KOrganizer for this setting to take effect.")); |
1575 | } | 1576 | } |
1576 | } | 1577 | } |
1577 | 1578 | ||
1578 | void KOPrefsDialog::toggleEmailSettings(bool on) | 1579 | void KOPrefsDialog::toggleEmailSettings(bool on) |
1579 | { | 1580 | { |
1580 | if (on) { | 1581 | if (on) { |
1581 | mEmailEdit->setEnabled(false); | 1582 | mEmailEdit->setEnabled(false); |
1582 | mNameEdit->setEnabled(false); | 1583 | mNameEdit->setEnabled(false); |
1583 | mEmailLabel->setEnabled(false); | 1584 | mEmailLabel->setEnabled(false); |
1584 | mNameLabel->setEnabled(false); | 1585 | mNameLabel->setEnabled(false); |
1585 | 1586 | ||
1586 | KEMailSettings settings; | 1587 | KEMailSettings settings; |
1587 | mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); | 1588 | mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); |
1588 | mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); | 1589 | mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); |
1589 | } else { | 1590 | } else { |
1590 | mEmailEdit->setEnabled(true); | 1591 | mEmailEdit->setEnabled(true); |
1591 | mNameEdit->setEnabled(true); | 1592 | mNameEdit->setEnabled(true); |
1592 | mEmailLabel->setEnabled(true); | 1593 | mEmailLabel->setEnabled(true); |
1593 | mNameLabel->setEnabled(true); | 1594 | mNameLabel->setEnabled(true); |
1594 | } | 1595 | } |
1595 | } | 1596 | } |
1596 | 1597 | ||
1597 | void KOPrefsDialog::addItem() | 1598 | void KOPrefsDialog::addItem() |
1598 | { | 1599 | { |
1599 | // aEmailsEdit->setEnabled(true); | 1600 | // aEmailsEdit->setEnabled(true); |
1600 | // QListViewItem *item = new QListViewItem(mAMails); | 1601 | // QListViewItem *item = new QListViewItem(mAMails); |
1601 | // mAMails->insertItem(item); | 1602 | // mAMails->insertItem(item); |
1602 | // mAMails->setSelected(item,true); | 1603 | // mAMails->setSelected(item,true); |
1603 | // aEmailsEdit->setText(i18n("(EmptyEmail)")); | 1604 | // aEmailsEdit->setText(i18n("(EmptyEmail)")); |
1604 | } | 1605 | } |
1605 | 1606 | ||
1606 | void KOPrefsDialog::removeItem() | 1607 | void KOPrefsDialog::removeItem() |
1607 | { | 1608 | { |
1608 | // QListViewItem *item; | 1609 | // QListViewItem *item; |
1609 | // item = mAMails->selectedItem(); | 1610 | // item = mAMails->selectedItem(); |
1610 | // if (!item) return; | 1611 | // if (!item) return; |
1611 | // mAMails->takeItem(item); | 1612 | // mAMails->takeItem(item); |
1612 | // item = mAMails->selectedItem(); | 1613 | // item = mAMails->selectedItem(); |
1613 | // if (!item) { | 1614 | // if (!item) { |
1614 | // aEmailsEdit->setText(""); | 1615 | // aEmailsEdit->setText(""); |
1615 | // aEmailsEdit->setEnabled(false); | 1616 | // aEmailsEdit->setEnabled(false); |
1616 | // } | 1617 | // } |
1617 | // if (mAMails->childCount() == 0) { | 1618 | // if (mAMails->childCount() == 0) { |
1618 | // aEmailsEdit->setEnabled(false); | 1619 | // aEmailsEdit->setEnabled(false); |
1619 | // } | 1620 | // } |
1620 | } | 1621 | } |
1621 | 1622 | ||
1622 | void KOPrefsDialog::updateItem() | 1623 | void KOPrefsDialog::updateItem() |
1623 | { | 1624 | { |
1624 | // QListViewItem *item; | 1625 | // QListViewItem *item; |
1625 | // item = mAMails->selectedItem(); | 1626 | // item = mAMails->selectedItem(); |
1626 | // if (!item) return; | 1627 | // if (!item) return; |
1627 | // item->setText(0,aEmailsEdit->text()); | 1628 | // item->setText(0,aEmailsEdit->text()); |
1628 | } | 1629 | } |
1629 | 1630 | ||
1630 | void KOPrefsDialog::updateInput() | 1631 | void KOPrefsDialog::updateInput() |
1631 | { | 1632 | { |
1632 | // QListViewItem *item; | 1633 | // QListViewItem *item; |
1633 | // item = mAMails->selectedItem(); | 1634 | // item = mAMails->selectedItem(); |
1634 | // if (!item) return; | 1635 | // if (!item) return; |
1635 | // aEmailsEdit->setEnabled(true); | 1636 | // aEmailsEdit->setEnabled(true); |
1636 | // aEmailsEdit->setText(item->text(0)); | 1637 | // aEmailsEdit->setText(item->text(0)); |
1637 | } | 1638 | } |
1638 | void KOPrefsDialog::updateTimezoneOffset( int index ) | 1639 | void KOPrefsDialog::updateTimezoneOffset( int index ) |
1639 | { | 1640 | { |
1640 | /* | 1641 | /* |
1641 | qDebug("updateTimezoneOffset %d ", index); | 1642 | qDebug("updateTimezoneOffset %d ", index); |
1642 | if ( index < 24 ) { | 1643 | if ( index < 24 ) { |
1643 | mTimezoneOffsetSpin->setEnabled ( false ); | 1644 | mTimezoneOffsetSpin->setEnabled ( false ); |
1644 | mTimezoneOffsetSpin->setValue( ( index-11 ) * 60 ); | 1645 | mTimezoneOffsetSpin->setValue( ( index-11 ) * 60 ); |
1645 | 1646 | ||
1646 | 1647 | ||
1647 | } else { | 1648 | } else { |
1648 | if ( index == 24 ) { | 1649 | if ( index == 24 ) { |
1649 | mTimezoneOffsetSpin->setEnabled ( true ); | 1650 | mTimezoneOffsetSpin->setEnabled ( true ); |
1650 | mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset); | 1651 | mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset); |
1651 | 1652 | ||
1652 | } else { | 1653 | } else { |
1653 | mTimezoneOffsetSpin->setEnabled ( false ); | 1654 | mTimezoneOffsetSpin->setEnabled ( false ); |
1654 | mTimezoneOffsetSpin->setValue( 0 ); | 1655 | mTimezoneOffsetSpin->setValue( 0 ); |
1655 | } | 1656 | } |
1656 | } | 1657 | } |
1657 | */ | 1658 | */ |
1658 | } | 1659 | } |
1659 | 1660 | ||
1660 | void KOPrefsDialog::setupTimeZoneTab() | 1661 | void KOPrefsDialog::setupTimeZoneTab() |
1661 | { | 1662 | { |
1662 | QFrame *topFrame = addPage(i18n("Time Zone"),0,0); | 1663 | QFrame *topFrame = addPage(i18n("Time Zone"),0,0); |
1663 | // DesktopIcon("clock",KIcon::SizeMedium)); | 1664 | // DesktopIcon("clock",KIcon::SizeMedium)); |
1664 | 1665 | ||
1665 | QGridLayout *topLayout = new QGridLayout(topFrame,5,2); | 1666 | QGridLayout *topLayout = new QGridLayout(topFrame,5,2); |
1666 | topLayout->setSpacing(spacingHint()); | 1667 | topLayout->setSpacing(spacingHint()); |
1667 | topLayout->setMargin(marginHint()); | 1668 | topLayout->setMargin(marginHint()); |
1668 | 1669 | ||
1669 | QHBox *timeZoneBox = new QHBox( topFrame ); | 1670 | QHBox *timeZoneBox = new QHBox( topFrame ); |
1670 | topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); | 1671 | topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); |
1671 | 1672 | ||
1672 | new QLabel( i18n("Timezone:"), timeZoneBox ); | 1673 | new QLabel( i18n("Timezone:"), timeZoneBox ); |
1673 | mTimeZoneCombo = new QComboBox( timeZoneBox ); | 1674 | mTimeZoneCombo = new QComboBox( timeZoneBox ); |
1674 | if ( QApplication::desktop()->width() < 300 ) { | 1675 | if ( QApplication::desktop()->width() < 300 ) { |
1675 | mTimeZoneCombo->setMaximumWidth(150); | 1676 | mTimeZoneCombo->setMaximumWidth(150); |
1676 | } | 1677 | } |
1677 | 1678 | ||
1678 | QStringList list; | 1679 | QStringList list; |
1679 | list = KGlobal::locale()->timeZoneList(); | 1680 | list = KGlobal::locale()->timeZoneList(); |
1680 | mTimeZoneCombo->insertStringList(list); | 1681 | mTimeZoneCombo->insertStringList(list); |
1681 | 1682 | ||
1682 | // find the currently set time zone and select it | 1683 | // find the currently set time zone and select it |
1683 | QString sCurrentlySet = KOPrefs::instance()->mTimeZoneId; | 1684 | QString sCurrentlySet = KOPrefs::instance()->mTimeZoneId; |
1684 | int nCurrentlySet = 11; | 1685 | int nCurrentlySet = 11; |
1685 | for (int i = 0; i < mTimeZoneCombo->count(); i++) | 1686 | for (int i = 0; i < mTimeZoneCombo->count(); i++) |
1686 | { | 1687 | { |
1687 | if (mTimeZoneCombo->text(i) == sCurrentlySet) | 1688 | if (mTimeZoneCombo->text(i) == sCurrentlySet) |
1688 | { | 1689 | { |
1689 | nCurrentlySet = i; | 1690 | nCurrentlySet = i; |
1690 | break; | 1691 | break; |
1691 | } | 1692 | } |
1692 | } | 1693 | } |
1693 | mTimeZoneCombo->setCurrentItem(nCurrentlySet); | 1694 | mTimeZoneCombo->setCurrentItem(nCurrentlySet); |
1694 | int iii = 1; | 1695 | int iii = 1; |
1695 | KPrefsDialogWidBool *sb = | 1696 | KPrefsDialogWidBool *sb = |
1696 | addWidBool(i18n("Timezone has daylight saving"), | 1697 | addWidBool(i18n("Timezone has daylight saving"), |
1697 | &(KOPrefs::instance()->mUseDaylightsaving),topFrame); | 1698 | &(KOPrefs::instance()->mUseDaylightsaving),topFrame); |
1698 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 1699 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
1699 | ++iii; | 1700 | ++iii; |
1700 | QLabel* lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame ); | 1701 | QLabel* lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame ); |
1701 | topLayout->addMultiCellWidget(lab, iii,iii,0,1); | 1702 | topLayout->addMultiCellWidget(lab, iii,iii,0,1); |
1702 | ++iii; | 1703 | ++iii; |
1703 | lab = new QLabel( i18n("The year in the date is ignored."), topFrame ); | 1704 | lab = new QLabel( i18n("The year in the date is ignored."), topFrame ); |
1704 | topLayout->addMultiCellWidget(lab, iii,iii,0,1); | 1705 | topLayout->addMultiCellWidget(lab, iii,iii,0,1); |
1705 | ++iii; | 1706 | ++iii; |
1706 | lab = new QLabel( i18n("Daylight start:"), topFrame ); | 1707 | lab = new QLabel( i18n("Daylight start:"), topFrame ); |
1707 | topLayout->addWidget(lab, iii,0); | 1708 | topLayout->addWidget(lab, iii,0); |
1708 | mStartDateSavingEdit = new KDateEdit(topFrame); | 1709 | mStartDateSavingEdit = new KDateEdit(topFrame); |
1709 | topLayout->addWidget(mStartDateSavingEdit, iii,1); | 1710 | topLayout->addWidget(mStartDateSavingEdit, iii,1); |
1710 | ++iii; | 1711 | ++iii; |
1711 | 1712 | ||
1712 | lab = new QLabel( i18n("Daylight end:"), topFrame ); | 1713 | lab = new QLabel( i18n("Daylight end:"), topFrame ); |
1713 | topLayout->addWidget(lab, iii,0); | 1714 | topLayout->addWidget(lab, iii,0); |
1714 | mEndDateSavingEdit = new KDateEdit(topFrame); | 1715 | mEndDateSavingEdit = new KDateEdit(topFrame); |
1715 | topLayout->addWidget(mEndDateSavingEdit, iii,1); | 1716 | topLayout->addWidget(mEndDateSavingEdit, iii,1); |
1716 | ++iii; | 1717 | ++iii; |
1717 | QDate current ( 2001, 1,1); | 1718 | QDate current ( 2001, 1,1); |
1718 | mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1)); | 1719 | mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1)); |
1719 | mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1)); | 1720 | mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1)); |
1720 | 1721 | ||
1721 | 1722 | ||
1722 | } | 1723 | } |
1723 | #endif | 1724 | #endif |
diff --git a/kmicromail/libmailwrapper/generatemail.cpp b/kmicromail/libmailwrapper/generatemail.cpp index 32311d7..2d213fe 100644 --- a/kmicromail/libmailwrapper/generatemail.cpp +++ b/kmicromail/libmailwrapper/generatemail.cpp | |||
@@ -1,461 +1,467 @@ | |||
1 | #include "generatemail.h" | 1 | #include "generatemail.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | 3 | ||
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | 5 | ||
6 | //#include <qt.h> | 6 | //#include <qt.h> |
7 | 7 | ||
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qfileinfo.h> | 9 | #include <qfileinfo.h> |
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | const char* Generatemail::USER_AGENT="KOpieMail 33 1/3"; | 12 | const char* Generatemail::USER_AGENT="KOpieMail 33 1/3"; |
13 | 13 | ||
14 | Generatemail::Generatemail() | 14 | Generatemail::Generatemail() |
15 | { | 15 | { |
16 | mCharset = "iso-8859-1"; | ||
16 | } | 17 | } |
17 | 18 | ||
18 | Generatemail::~Generatemail() | 19 | Generatemail::~Generatemail() |
19 | { | 20 | { |
20 | } | 21 | } |
21 | 22 | ||
22 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { | 23 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { |
23 | clistiter *it, *it2; | 24 | clistiter *it, *it2; |
24 | 25 | ||
25 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { | 26 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { |
26 | mailimf_address *addr; | 27 | mailimf_address *addr; |
27 | addr = (mailimf_address *) it->data; | 28 | addr = (mailimf_address *) it->data; |
28 | 29 | ||
29 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { | 30 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { |
30 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); | 31 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); |
31 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { | 32 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { |
32 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; | 33 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; |
33 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { | 34 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { |
34 | mailimf_mailbox *mbox; | 35 | mailimf_mailbox *mbox; |
35 | mbox = (mailimf_mailbox *) it2->data; | 36 | mbox = (mailimf_mailbox *) it2->data; |
36 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); | 37 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); |
37 | } | 38 | } |
38 | } | 39 | } |
39 | } | 40 | } |
40 | } | 41 | } |
41 | 42 | ||
42 | char *Generatemail::getFrom( mailimf_field *ffrom) { | 43 | char *Generatemail::getFrom( mailimf_field *ffrom) { |
43 | char *from = NULL; | 44 | char *from = NULL; |
44 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) | 45 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) |
45 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { | 46 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { |
46 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; | 47 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; |
47 | clistiter *it; | 48 | clistiter *it; |
48 | for ( it = clist_begin( cl ); it; it = it->next ) { | 49 | for ( it = clist_begin( cl ); it; it = it->next ) { |
49 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; | 50 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; |
50 | from = strdup( mb->mb_addr_spec ); | 51 | from = strdup( mb->mb_addr_spec ); |
51 | } | 52 | } |
52 | } | 53 | } |
53 | 54 | ||
54 | return from; | 55 | return from; |
55 | } | 56 | } |
56 | 57 | ||
57 | char *Generatemail::getFrom( mailmime *mail ) { | 58 | char *Generatemail::getFrom( mailmime *mail ) { |
58 | /* no need to delete - its just a pointer to structure content */ | 59 | /* no need to delete - its just a pointer to structure content */ |
59 | mailimf_field *ffrom = 0; | 60 | mailimf_field *ffrom = 0; |
60 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); | 61 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); |
61 | return getFrom(ffrom); | 62 | return getFrom(ffrom); |
62 | } | 63 | } |
63 | 64 | ||
64 | mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) { | 65 | mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) { |
65 | mailimf_field *field; | 66 | mailimf_field *field; |
66 | clistiter *it; | 67 | clistiter *it; |
67 | 68 | ||
68 | it = clist_begin( fields->fld_list ); | 69 | it = clist_begin( fields->fld_list ); |
69 | while ( it ) { | 70 | while ( it ) { |
70 | field = (mailimf_field *) it->data; | 71 | field = (mailimf_field *) it->data; |
71 | if ( field->fld_type == type ) { | 72 | if ( field->fld_type == type ) { |
72 | return field; | 73 | return field; |
73 | } | 74 | } |
74 | it = it->next; | 75 | it = it->next; |
75 | } | 76 | } |
76 | 77 | ||
77 | return NULL; | 78 | return NULL; |
78 | } | 79 | } |
79 | 80 | ||
80 | mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) { | 81 | mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) { |
81 | mailimf_address_list *addresses; | 82 | mailimf_address_list *addresses; |
82 | 83 | ||
83 | if ( addr.isEmpty() ) | 84 | if ( addr.isEmpty() ) |
84 | return NULL; | 85 | return NULL; |
85 | 86 | ||
86 | addresses = mailimf_address_list_new_empty(); | 87 | addresses = mailimf_address_list_new_empty(); |
87 | 88 | ||
88 | bool literal_open = false; | 89 | bool literal_open = false; |
89 | unsigned int startpos = 0; | 90 | unsigned int startpos = 0; |
90 | QStringList list; | 91 | QStringList list; |
91 | QString s; | 92 | QString s; |
92 | unsigned int i = 0; | 93 | unsigned int i = 0; |
93 | for (; i < addr.length();++i) { | 94 | for (; i < addr.length();++i) { |
94 | switch (addr[i]) { | 95 | switch (addr[i]) { |
95 | case '\"': | 96 | case '\"': |
96 | literal_open = !literal_open; | 97 | literal_open = !literal_open; |
97 | break; | 98 | break; |
98 | case ',': | 99 | case ',': |
99 | if (!literal_open) { | 100 | if (!literal_open) { |
100 | s = addr.mid(startpos,i-startpos); | 101 | s = addr.mid(startpos,i-startpos); |
101 | if (!s.isEmpty()) { | 102 | if (!s.isEmpty()) { |
102 | list.append(s); | 103 | list.append(s); |
103 | } | 104 | } |
104 | // !!!! this is a MUST BE! | 105 | // !!!! this is a MUST BE! |
105 | startpos = ++i; | 106 | startpos = ++i; |
106 | } | 107 | } |
107 | break; | 108 | break; |
108 | default: | 109 | default: |
109 | break; | 110 | break; |
110 | } | 111 | } |
111 | } | 112 | } |
112 | s = addr.mid(startpos,i-startpos); | 113 | s = addr.mid(startpos,i-startpos); |
113 | if (!s.isEmpty()) { | 114 | if (!s.isEmpty()) { |
114 | list.append(s); | 115 | list.append(s); |
115 | } | 116 | } |
116 | QStringList::Iterator it; | 117 | QStringList::Iterator it; |
117 | for ( it = list.begin(); it != list.end(); it++ ) { | 118 | for ( it = list.begin(); it != list.end(); it++ ) { |
118 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); | 119 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); |
119 | if ( err != MAILIMF_NO_ERROR ) { | 120 | if ( err != MAILIMF_NO_ERROR ) { |
120 | qDebug(" Error parsing"); // *it | 121 | qDebug(" Error parsing"); // *it |
121 | } else { | 122 | } else { |
122 | } | 123 | } |
123 | } | 124 | } |
124 | return addresses; | 125 | return addresses; |
125 | } | 126 | } |
126 | 127 | ||
127 | mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { | 128 | mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { |
128 | mailmime * filePart = 0; | 129 | mailmime * filePart = 0; |
129 | mailmime_fields * fields = 0; | 130 | mailmime_fields * fields = 0; |
130 | mailmime_content * content = 0; | 131 | mailmime_content * content = 0; |
131 | mailmime_parameter * param = 0; | 132 | mailmime_parameter * param = 0; |
132 | char*name = 0; | 133 | char*name = 0; |
133 | char*file = 0; | 134 | char*file = 0; |
134 | int err; | 135 | int err; |
135 | int pos = filename.findRev( '/' ); | 136 | int pos = filename.findRev( '/' ); |
136 | 137 | ||
137 | if (filename.length()>0) { | 138 | if (filename.length()>0) { |
138 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); | 139 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); |
139 | name = strdup( tmp.latin1() ); // just filename | 140 | name = strdup( tmp.latin1() ); // just filename |
140 | file = strdup( filename.latin1() ); // full name with path | 141 | file = strdup( filename.latin1() ); // full name with path |
141 | } | 142 | } |
142 | 143 | ||
143 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; | 144 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; |
144 | int mechanism = MAILMIME_MECHANISM_BASE64; | 145 | int mechanism = MAILMIME_MECHANISM_BASE64; |
145 | 146 | ||
146 | if ( mimetype.startsWith( "text/" ) ) { | 147 | if ( mimetype.startsWith( "text/" ) ) { |
147 | param = mailmime_parameter_new( strdup( "charset" ), | 148 | param = mailmime_parameter_new( strdup( "charset" ), |
148 | strdup( "iso-8859-1" ) ); | 149 | strdup( mCharset.latin1() ) ); |
149 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 150 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
150 | } | 151 | } |
151 | 152 | ||
152 | fields = mailmime_fields_new_filename( | 153 | fields = mailmime_fields_new_filename( |
153 | disptype, name, | 154 | disptype, name, |
154 | mechanism ); | 155 | mechanism ); |
155 | content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); | 156 | content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); |
156 | if (content!=0 && fields != 0) { | 157 | if (content!=0 && fields != 0) { |
157 | if (param) { | 158 | if (param) { |
158 | clist_append(content->ct_parameters,param); | 159 | clist_append(content->ct_parameters,param); |
159 | param = 0; | 160 | param = 0; |
160 | } | 161 | } |
161 | if (filename.length()>0) { | 162 | if (filename.length()>0) { |
162 | QFileInfo f(filename); | 163 | QFileInfo f(filename); |
163 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); | 164 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); |
164 | clist_append(content->ct_parameters,param); | 165 | clist_append(content->ct_parameters,param); |
165 | param = 0; | 166 | param = 0; |
166 | } | 167 | } |
167 | filePart = mailmime_new_empty( content, fields ); | 168 | filePart = mailmime_new_empty( content, fields ); |
168 | } | 169 | } |
169 | if (filePart) { | 170 | if (filePart) { |
170 | if (filename.length()>0) { | 171 | if (filename.length()>0) { |
171 | err = mailmime_set_body_file( filePart, file ); | 172 | err = mailmime_set_body_file( filePart, file ); |
172 | } else { | 173 | } else { |
173 | err = mailmime_set_body_text(filePart,strdup( TextContent.utf8()),TextContent.utf8().length()); | 174 | err = mailmime_set_body_text(filePart,strdup( TextContent.utf8().data()),TextContent.utf8().length()); |
175 | //err = mailmime_set_body_text(filePart,strdup( TextContent.latin1()),TextContent.length()); | ||
174 | } | 176 | } |
175 | if (err != MAILIMF_NO_ERROR) { | 177 | if (err != MAILIMF_NO_ERROR) { |
176 | qDebug("Error setting body with file "); | 178 | qDebug("Error setting body with file "); |
177 | mailmime_free( filePart ); | 179 | mailmime_free( filePart ); |
178 | filePart = 0; | 180 | filePart = 0; |
179 | } | 181 | } |
180 | } | 182 | } |
181 | 183 | ||
182 | if (!filePart) { | 184 | if (!filePart) { |
183 | if ( param != NULL ) { | 185 | if ( param != NULL ) { |
184 | mailmime_parameter_free( param ); | 186 | mailmime_parameter_free( param ); |
185 | } | 187 | } |
186 | if (content) { | 188 | if (content) { |
187 | mailmime_content_free( content ); | 189 | mailmime_content_free( content ); |
188 | } | 190 | } |
189 | if (fields) { | 191 | if (fields) { |
190 | mailmime_fields_free( fields ); | 192 | mailmime_fields_free( fields ); |
191 | } else { | 193 | } else { |
192 | if (name) { | 194 | if (name) { |
193 | free( name ); | 195 | free( name ); |
194 | } | 196 | } |
195 | if (file) { | 197 | if (file) { |
196 | free( file ); | 198 | free( file ); |
197 | } | 199 | } |
198 | } | 200 | } |
199 | } | 201 | } |
200 | return filePart; // Success :) | 202 | return filePart; // Success :) |
201 | 203 | ||
202 | } | 204 | } |
203 | 205 | ||
204 | void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) { | 206 | void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) { |
205 | const Attachment *it; | 207 | const Attachment *it; |
206 | unsigned int count = files.count(); | 208 | unsigned int count = files.count(); |
207 | for ( unsigned int i = 0; i < count; ++i ) { | 209 | for ( unsigned int i = 0; i < count; ++i ) { |
208 | mailmime *filePart; | 210 | mailmime *filePart; |
209 | int err; | 211 | int err; |
210 | it = ((QList<Attachment>)files).at(i); | 212 | it = ((QList<Attachment>)files).at(i); |
211 | 213 | ||
212 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); | 214 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); |
213 | if ( filePart == NULL ) { | 215 | if ( filePart == NULL ) { |
214 | continue; | 216 | continue; |
215 | } | 217 | } |
216 | err = mailmime_smart_add_part( message, filePart ); | 218 | err = mailmime_smart_add_part( message, filePart ); |
217 | if ( err != MAILIMF_NO_ERROR ) { | 219 | if ( err != MAILIMF_NO_ERROR ) { |
218 | mailmime_free( filePart ); | 220 | mailmime_free( filePart ); |
219 | } | 221 | } |
220 | } | 222 | } |
221 | } | 223 | } |
222 | 224 | ||
223 | mailmime *Generatemail::buildTxtPart(const QString&str ) { | 225 | mailmime *Generatemail::buildTxtPart(const QString&str ) { |
224 | mailmime *txtPart; | 226 | mailmime *txtPart; |
225 | mailmime_fields *fields; | 227 | mailmime_fields *fields; |
226 | mailmime_content *content; | 228 | mailmime_content *content; |
227 | mailmime_parameter *param; | 229 | mailmime_parameter *param; |
228 | int err; | 230 | int err; |
229 | QCString __str; | 231 | QCString __str; |
232 | //qDebug(" Generatemail::buildTxtPart %s", str.latin1()); | ||
230 | param = mailmime_parameter_new( strdup( "charset" ), | 233 | param = mailmime_parameter_new( strdup( "charset" ), |
231 | strdup( "iso-8859-1" ) ); | 234 | strdup( mCharset.latin1() ) ); |
232 | if ( param == NULL ) | 235 | if ( param == NULL ) |
233 | goto err_free; | 236 | goto err_free; |
234 | 237 | ||
235 | content = mailmime_content_new_with_str( "text/plain" ); | 238 | content = mailmime_content_new_with_str( "text/plain" ); |
236 | if ( content == NULL ) | 239 | if ( content == NULL ) |
237 | goto err_free_param; | 240 | goto err_free_param; |
238 | 241 | ||
239 | err = clist_append( content->ct_parameters, param ); | 242 | err = clist_append( content->ct_parameters, param ); |
240 | if ( err != MAILIMF_NO_ERROR ) | 243 | if ( err != MAILIMF_NO_ERROR ) |
241 | goto err_free_content; | 244 | goto err_free_content; |
242 | 245 | ||
243 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); | 246 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); |
244 | if ( fields == NULL ) | 247 | if ( fields == NULL ) |
245 | goto err_free_content; | 248 | goto err_free_content; |
246 | 249 | ||
247 | txtPart = mailmime_new_empty( content, fields ); | 250 | txtPart = mailmime_new_empty( content, fields ); |
248 | if ( txtPart == NULL ) | 251 | if ( txtPart == NULL ) |
249 | goto err_free_fields; | 252 | goto err_free_fields; |
250 | { | 253 | { |
251 | __str = str.utf8(); | 254 | //__str = str.utf8(); |
252 | err = mailmime_set_body_text( txtPart, __str.data(), __str.length() ); | 255 | __str = QCString (str.latin1()); |
256 | err = mailmime_set_body_text( txtPart, strdup(__str.data()), __str.length() ); | ||
253 | } | 257 | } |
254 | if ( err != MAILIMF_NO_ERROR ) | 258 | if ( err != MAILIMF_NO_ERROR ) |
255 | goto err_free_txtPart; | 259 | goto err_free_txtPart; |
256 | 260 | ||
257 | return txtPart; // Success :) | 261 | return txtPart; // Success :) |
258 | 262 | ||
259 | err_free_txtPart: | 263 | err_free_txtPart: |
260 | mailmime_free( txtPart ); | 264 | mailmime_free( txtPart ); |
261 | err_free_fields: | 265 | err_free_fields: |
262 | mailmime_fields_free( fields ); | 266 | mailmime_fields_free( fields ); |
263 | err_free_content: | 267 | err_free_content: |
264 | mailmime_content_free( content ); | 268 | mailmime_content_free( content ); |
265 | err_free_param: | 269 | err_free_param: |
266 | mailmime_parameter_free( param ); | 270 | mailmime_parameter_free( param ); |
267 | err_free: | 271 | err_free: |
268 | ; | 272 | ; |
269 | 273 | ||
270 | return NULL; // Error :( | 274 | return NULL; // Error :( |
271 | } | 275 | } |
272 | 276 | ||
273 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { | 277 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { |
274 | return mailimf_mailbox_new( strdup( name.latin1() ), | 278 | return mailimf_mailbox_new( strdup( name.latin1() ), |
275 | strdup( mail.latin1() ) ); | 279 | strdup( mail.latin1() ) ); |
276 | } | 280 | } |
277 | 281 | ||
278 | mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail ) | 282 | mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail ) |
279 | { | 283 | { |
280 | mailimf_fields *fields = NULL; | 284 | mailimf_fields *fields = NULL; |
281 | mailimf_field *xmailer = NULL; | 285 | mailimf_field *xmailer = NULL; |
282 | mailimf_mailbox *sender=0,*fromBox=0; | 286 | mailimf_mailbox *sender=0,*fromBox=0; |
283 | mailimf_mailbox_list *from=0; | 287 | mailimf_mailbox_list *from=0; |
284 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; | 288 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; |
285 | clist*in_reply_to = 0; | 289 | clist*in_reply_to = 0; |
286 | char *subject = strdup( mail->getSubject().latin1() ); | 290 | char *subject = strdup( mail->getSubject().latin1() ); |
287 | int err; | 291 | int err; |
288 | int res = 1; | 292 | int res = 1; |
289 | 293 | ||
290 | sender = newMailbox( mail->getName(), mail->getMail() ); | 294 | sender = newMailbox( mail->getName(), mail->getMail() ); |
291 | if ( sender == NULL ) { | 295 | if ( sender == NULL ) { |
292 | res = 0; | 296 | res = 0; |
293 | } | 297 | } |
294 | 298 | ||
295 | if (res) { | 299 | if (res) { |
296 | fromBox = newMailbox( mail->getName(), mail->getMail() ); | 300 | fromBox = newMailbox( mail->getName(), mail->getMail() ); |
297 | } | 301 | } |
298 | if ( fromBox == NULL ) { | 302 | if ( fromBox == NULL ) { |
299 | res = 0; | 303 | res = 0; |
300 | } | 304 | } |
301 | 305 | ||
302 | if (res) { | 306 | if (res) { |
303 | from = mailimf_mailbox_list_new_empty(); | 307 | from = mailimf_mailbox_list_new_empty(); |
304 | } | 308 | } |
305 | if ( from == NULL ) { | 309 | if ( from == NULL ) { |
306 | res = 0; | 310 | res = 0; |
307 | } | 311 | } |
308 | 312 | ||
309 | if (res && from) { | 313 | if (res && from) { |
310 | err = mailimf_mailbox_list_add( from, fromBox ); | 314 | err = mailimf_mailbox_list_add( from, fromBox ); |
311 | if ( err != MAILIMF_NO_ERROR ) { | 315 | if ( err != MAILIMF_NO_ERROR ) { |
312 | res = 0; | 316 | res = 0; |
313 | } | 317 | } |
314 | } | 318 | } |
315 | 319 | ||
316 | if (res) to = parseAddresses( mail->getTo() ); | 320 | if (res) to = parseAddresses( mail->getTo() ); |
317 | if (res) cc = parseAddresses( mail->getCC() ); | 321 | if (res) cc = parseAddresses( mail->getCC() ); |
318 | if (res) bcc = parseAddresses( mail->getBCC() ); | 322 | if (res) bcc = parseAddresses( mail->getBCC() ); |
319 | if (res) reply = parseAddresses( mail->getReply() ); | 323 | if (res) reply = parseAddresses( mail->getReply() ); |
320 | 324 | ||
321 | if (res && mail->Inreply().count()>0) { | 325 | if (res && mail->Inreply().count()>0) { |
322 | in_reply_to = clist_new(); | 326 | in_reply_to = clist_new(); |
323 | char*c_reply; | 327 | char*c_reply; |
324 | unsigned int nsize = 0; | 328 | unsigned int nsize = 0; |
325 | for (QStringList::ConstIterator it=mail->Inreply().begin(); | 329 | for (QStringList::ConstIterator it=mail->Inreply().begin(); |
326 | it != mail->Inreply().end();++it) { | 330 | it != mail->Inreply().end();++it) { |
327 | if ((*it).isEmpty()) | 331 | if ((*it).isEmpty()) |
328 | continue; | 332 | continue; |
329 | QString h((*it)); | 333 | QString h((*it)); |
330 | while (h.length()>0 && h[0]=='<') { | 334 | while (h.length()>0 && h[0]=='<') { |
331 | h.remove(0,1); | 335 | h.remove(0,1); |
332 | } | 336 | } |
333 | while (h.length()>0 && h[h.length()-1]=='>') { | 337 | while (h.length()>0 && h[h.length()-1]=='>') { |
334 | h.remove(h.length()-1,1); | 338 | h.remove(h.length()-1,1); |
335 | } | 339 | } |
336 | if (h.isEmpty()) continue; | 340 | if (h.isEmpty()) continue; |
337 | nsize = strlen(h.latin1()); | 341 | nsize = strlen(h.latin1()); |
338 | /* yes! must be malloc! */ | 342 | /* yes! must be malloc! */ |
339 | c_reply = (char*)malloc( (nsize+1)*sizeof(char)); | 343 | c_reply = (char*)malloc( (nsize+1)*sizeof(char)); |
340 | memset(c_reply,0,nsize+1); | 344 | memset(c_reply,0,nsize+1); |
341 | memcpy(c_reply,h.latin1(),nsize); | 345 | memcpy(c_reply,h.latin1(),nsize); |
342 | clist_append(in_reply_to,c_reply); | 346 | clist_append(in_reply_to,c_reply); |
343 | } | 347 | } |
344 | } | 348 | } |
345 | 349 | ||
346 | if (res) { | 350 | if (res) { |
347 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, | 351 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, |
348 | in_reply_to, NULL, subject ); | 352 | in_reply_to, NULL, subject ); |
349 | if ( fields == NULL ) { | 353 | if ( fields == NULL ) { |
350 | res = 0; | 354 | res = 0; |
351 | } | 355 | } |
352 | } | 356 | } |
353 | if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), | 357 | if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), |
354 | strdup( USER_AGENT ) ); | 358 | strdup( USER_AGENT ) ); |
355 | if ( xmailer == NULL ) { | 359 | if ( xmailer == NULL ) { |
356 | res = 0; | 360 | res = 0; |
357 | } else { | 361 | } else { |
358 | err = mailimf_fields_add( fields, xmailer ); | 362 | err = mailimf_fields_add( fields, xmailer ); |
359 | if ( err != MAILIMF_NO_ERROR ) { | 363 | if ( err != MAILIMF_NO_ERROR ) { |
360 | res = 0; | 364 | res = 0; |
361 | } | 365 | } |
362 | } | 366 | } |
363 | if (!res ) { | 367 | if (!res ) { |
364 | if (xmailer) { | 368 | if (xmailer) { |
365 | mailimf_field_free( xmailer ); | 369 | mailimf_field_free( xmailer ); |
366 | xmailer = NULL; | 370 | xmailer = NULL; |
367 | } | 371 | } |
368 | if (fields) { | 372 | if (fields) { |
369 | mailimf_fields_free( fields ); | 373 | mailimf_fields_free( fields ); |
370 | fields = NULL; | 374 | fields = NULL; |
371 | } else { | 375 | } else { |
372 | if (reply) | 376 | if (reply) |
373 | mailimf_address_list_free( reply ); | 377 | mailimf_address_list_free( reply ); |
374 | if (bcc) | 378 | if (bcc) |
375 | mailimf_address_list_free( bcc ); | 379 | mailimf_address_list_free( bcc ); |
376 | if (cc) | 380 | if (cc) |
377 | mailimf_address_list_free( cc ); | 381 | mailimf_address_list_free( cc ); |
378 | if (to) | 382 | if (to) |
379 | mailimf_address_list_free( to ); | 383 | mailimf_address_list_free( to ); |
380 | if (fromBox) { | 384 | if (fromBox) { |
381 | mailimf_mailbox_free( fromBox ); | 385 | mailimf_mailbox_free( fromBox ); |
382 | } else if (from) { | 386 | } else if (from) { |
383 | mailimf_mailbox_list_free( from ); | 387 | mailimf_mailbox_list_free( from ); |
384 | } | 388 | } |
385 | if (sender) { | 389 | if (sender) { |
386 | mailimf_mailbox_free( sender ); | 390 | mailimf_mailbox_free( sender ); |
387 | } | 391 | } |
388 | if (subject) { | 392 | if (subject) { |
389 | free( subject ); | 393 | free( subject ); |
390 | } | 394 | } |
391 | } | 395 | } |
392 | } | 396 | } |
393 | return fields; | 397 | return fields; |
394 | } | 398 | } |
395 | 399 | ||
396 | mailmime *Generatemail::createMimeMail(const Opie::Core::OSmartPointer<Mail> &mail ) { | 400 | mailmime *Generatemail::createMimeMail(const Opie::Core::OSmartPointer<Mail> &mail ) { |
397 | mailmime *message, *txtPart; | 401 | mailmime *message, *txtPart; |
398 | mailimf_fields *fields; | 402 | mailimf_fields *fields; |
399 | int err; | 403 | int err; |
400 | 404 | ||
405 | //LR disabled for now | ||
406 | //mCharset = mail->getCharset().lower(); | ||
401 | fields = createImfFields( mail ); | 407 | fields = createImfFields( mail ); |
402 | if ( fields == NULL ) | 408 | if ( fields == NULL ) |
403 | goto err_free; | 409 | goto err_free; |
404 | 410 | ||
405 | message = mailmime_new_message_data( NULL ); | 411 | message = mailmime_new_message_data( NULL ); |
406 | if ( message == NULL ) | 412 | if ( message == NULL ) |
407 | goto err_free_fields; | 413 | goto err_free_fields; |
408 | 414 | ||
409 | mailmime_set_imf_fields( message, fields ); | 415 | mailmime_set_imf_fields( message, fields ); |
410 | 416 | ||
411 | txtPart = buildTxtPart( mail->getMessage() ); | 417 | txtPart = buildTxtPart( mail->getMessage() ); |
412 | 418 | ||
413 | if ( txtPart == NULL ) | 419 | if ( txtPart == NULL ) |
414 | goto err_free_message; | 420 | goto err_free_message; |
415 | 421 | ||
416 | err = mailmime_smart_add_part( message, txtPart ); | 422 | err = mailmime_smart_add_part( message, txtPart ); |
417 | if ( err != MAILIMF_NO_ERROR ) | 423 | if ( err != MAILIMF_NO_ERROR ) |
418 | goto err_free_txtPart; | 424 | goto err_free_txtPart; |
419 | 425 | ||
420 | addFileParts( message, mail->getAttachments() ); | 426 | addFileParts( message, mail->getAttachments() ); |
421 | 427 | ||
422 | return message; // Success :) | 428 | return message; // Success :) |
423 | 429 | ||
424 | err_free_txtPart: | 430 | err_free_txtPart: |
425 | mailmime_free( txtPart ); | 431 | mailmime_free( txtPart ); |
426 | err_free_message: | 432 | err_free_message: |
427 | mailmime_free( message ); | 433 | mailmime_free( message ); |
428 | err_free_fields: | 434 | err_free_fields: |
429 | mailimf_fields_free( fields ); | 435 | mailimf_fields_free( fields ); |
430 | err_free: | 436 | err_free: |
431 | ; | 437 | ; |
432 | 438 | ||
433 | return NULL; // Error :( | 439 | return NULL; // Error :( |
434 | } | 440 | } |
435 | 441 | ||
436 | clist *Generatemail::createRcptList( mailimf_fields *fields ) { | 442 | clist *Generatemail::createRcptList( mailimf_fields *fields ) { |
437 | clist *rcptList; | 443 | clist *rcptList; |
438 | mailimf_field *field; | 444 | mailimf_field *field; |
439 | 445 | ||
440 | rcptList = esmtp_address_list_new(); | 446 | rcptList = esmtp_address_list_new(); |
441 | 447 | ||
442 | field = getField( fields, MAILIMF_FIELD_TO ); | 448 | field = getField( fields, MAILIMF_FIELD_TO ); |
443 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) | 449 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) |
444 | && field->fld_data.fld_to->to_addr_list ) { | 450 | && field->fld_data.fld_to->to_addr_list ) { |
445 | addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); | 451 | addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); |
446 | } | 452 | } |
447 | 453 | ||
448 | field = getField( fields, MAILIMF_FIELD_CC ); | 454 | field = getField( fields, MAILIMF_FIELD_CC ); |
449 | if ( field && (field->fld_type == MAILIMF_FIELD_CC) | 455 | if ( field && (field->fld_type == MAILIMF_FIELD_CC) |
450 | && field->fld_data.fld_cc->cc_addr_list ) { | 456 | && field->fld_data.fld_cc->cc_addr_list ) { |
451 | addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); | 457 | addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); |
452 | } | 458 | } |
453 | 459 | ||
454 | field = getField( fields, MAILIMF_FIELD_BCC ); | 460 | field = getField( fields, MAILIMF_FIELD_BCC ); |
455 | if ( field && (field->fld_type == MAILIMF_FIELD_BCC) | 461 | if ( field && (field->fld_type == MAILIMF_FIELD_BCC) |
456 | && field->fld_data.fld_bcc->bcc_addr_list ) { | 462 | && field->fld_data.fld_bcc->bcc_addr_list ) { |
457 | addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); | 463 | addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); |
458 | } | 464 | } |
459 | 465 | ||
460 | return rcptList; | 466 | return rcptList; |
461 | } | 467 | } |
diff --git a/kmicromail/libmailwrapper/generatemail.h b/kmicromail/libmailwrapper/generatemail.h index b9f8285..a9fb648 100644 --- a/kmicromail/libmailwrapper/generatemail.h +++ b/kmicromail/libmailwrapper/generatemail.h | |||
@@ -1,47 +1,48 @@ | |||
1 | #ifndef __GENERATE_MAIL_H | 1 | #ifndef __GENERATE_MAIL_H |
2 | #define __GENERATE_MAIL_H | 2 | #define __GENERATE_MAIL_H |
3 | 3 | ||
4 | //#include <qpe/applnk.h> | 4 | //#include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qobject.h> | 6 | #include <qobject.h> |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | #include "mailwrapper.h" | 8 | #include "mailwrapper.h" |
9 | 9 | ||
10 | #include <opie2/osmartpointer.h> | 10 | #include <opie2/osmartpointer.h> |
11 | 11 | ||
12 | class Mail; | 12 | class Mail; |
13 | class RecMail; | 13 | class RecMail; |
14 | 14 | ||
15 | struct mailimf_fields; | 15 | struct mailimf_fields; |
16 | struct mailimf_field; | 16 | struct mailimf_field; |
17 | struct mailimf_mailbox; | 17 | struct mailimf_mailbox; |
18 | struct mailmime; | 18 | struct mailmime; |
19 | struct mailimf_address_list; | 19 | struct mailimf_address_list; |
20 | class progressMailSend; | 20 | class progressMailSend; |
21 | struct mailsmtp; | 21 | struct mailsmtp; |
22 | 22 | ||
23 | class Generatemail : public QObject | 23 | class Generatemail : public QObject |
24 | { | 24 | { |
25 | Q_OBJECT | 25 | Q_OBJECT |
26 | public: | 26 | public: |
27 | Generatemail(); | 27 | Generatemail(); |
28 | virtual ~Generatemail(); | 28 | virtual ~Generatemail(); |
29 | 29 | ||
30 | protected: | 30 | protected: |
31 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); | 31 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); |
32 | static char *getFrom( mailmime *mail ); | 32 | static char *getFrom( mailmime *mail ); |
33 | static char *getFrom( mailimf_field *ffrom); | 33 | static char *getFrom( mailimf_field *ffrom); |
34 | static mailimf_field *getField( mailimf_fields *fields, int type ); | 34 | static mailimf_field *getField( mailimf_fields *fields, int type ); |
35 | mailimf_address_list *parseAddresses(const QString&addr ); | 35 | mailimf_address_list *parseAddresses(const QString&addr ); |
36 | void addFileParts( mailmime *message,const QList<Attachment>&files ); | 36 | void addFileParts( mailmime *message,const QList<Attachment>&files ); |
37 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); | 37 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); |
38 | mailmime *buildTxtPart(const QString&str ); | 38 | mailmime *buildTxtPart(const QString&str ); |
39 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); | 39 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); |
40 | mailimf_fields *createImfFields(const Opie::Core::OSmartPointer<Mail> &mail ); | 40 | mailimf_fields *createImfFields(const Opie::Core::OSmartPointer<Mail> &mail ); |
41 | mailmime *createMimeMail(const Opie::Core::OSmartPointer<Mail>&mail ); | 41 | mailmime *createMimeMail(const Opie::Core::OSmartPointer<Mail>&mail ); |
42 | clist *createRcptList( mailimf_fields *fields ); | 42 | clist *createRcptList( mailimf_fields *fields ); |
43 | 43 | ||
44 | static const char* USER_AGENT; | 44 | static const char* USER_AGENT; |
45 | QString mCharset; | ||
45 | }; | 46 | }; |
46 | 47 | ||
47 | #endif | 48 | #endif |
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index 28d45ce..eac05e5 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,545 +1,546 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "genericwrapper.h" | 2 | #include "genericwrapper.h" |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <kconfig.h> | 6 | #include <kconfig.h> |
7 | #include <kglobal.h> | 7 | #include <kglobal.h> |
8 | #include <kstandarddirs.h> | 8 | #include <kstandarddirs.h> |
9 | 9 | ||
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | Genericwrapper::Genericwrapper() | 12 | Genericwrapper::Genericwrapper() |
13 | : AbstractMail() | 13 | : AbstractMail() |
14 | { | 14 | { |
15 | bodyCache.clear(); | 15 | bodyCache.clear(); |
16 | m_storage = 0; | 16 | m_storage = 0; |
17 | m_folder = 0; | 17 | m_folder = 0; |
18 | } | 18 | } |
19 | 19 | ||
20 | Genericwrapper::~Genericwrapper() | 20 | Genericwrapper::~Genericwrapper() |
21 | { | 21 | { |
22 | if (m_folder) { | 22 | if (m_folder) { |
23 | mailfolder_free(m_folder); | 23 | mailfolder_free(m_folder); |
24 | } | 24 | } |
25 | if (m_storage) { | 25 | if (m_storage) { |
26 | mailstorage_free(m_storage); | 26 | mailstorage_free(m_storage); |
27 | } | 27 | } |
28 | cleanMimeCache(); | 28 | cleanMimeCache(); |
29 | } | 29 | } |
30 | const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) | 30 | const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) |
31 | { | 31 | { |
32 | 32 | ||
33 | QDate da (date->dt_year,date->dt_month, date->dt_day ); | 33 | QDate da (date->dt_year,date->dt_month, date->dt_day ); |
34 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); | 34 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); |
35 | QDateTime dt ( da ,ti ); | 35 | QDateTime dt ( da ,ti ); |
36 | int addsec = -date->dt_zone*36; | 36 | int addsec = -date->dt_zone*36; |
37 | //qDebug("adsec1 %d ",addsec ); | 37 | //qDebug("adsec1 %d ",addsec ); |
38 | dt = dt.addSecs( addsec ); | 38 | dt = dt.addSecs( addsec ); |
39 | int off = KGlobal::locale()->localTimeOffset( dt ); | 39 | int off = KGlobal::locale()->localTimeOffset( dt ); |
40 | //qDebug("adsec2 %d ",off*60 ); | 40 | //qDebug("adsec2 %d ",off*60 ); |
41 | 41 | ||
42 | dt = dt.addSecs( off*60 ); | 42 | dt = dt.addSecs( off*60 ); |
43 | return dt; | 43 | return dt; |
44 | #if 0 | 44 | #if 0 |
45 | QString ret; | 45 | QString ret; |
46 | if ( dt.date() == QDate::currentDate () ) | 46 | if ( dt.date() == QDate::currentDate () ) |
47 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 47 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
48 | 48 | ||
49 | else { | 49 | else { |
50 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 50 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
51 | } | 51 | } |
52 | #endif | 52 | #endif |
53 | #if 0 | 53 | #if 0 |
54 | if ( off < 0 ) | 54 | if ( off < 0 ) |
55 | ret += " -"; | 55 | ret += " -"; |
56 | else | 56 | else |
57 | ret += " +"; | 57 | ret += " +"; |
58 | ret += QString::number( off / 60 ); | 58 | ret += QString::number( off / 60 ); |
59 | ret += "h"; | 59 | ret += "h"; |
60 | #endif | 60 | #endif |
61 | #if 0 | 61 | #if 0 |
62 | char tmp[23]; | 62 | char tmp[23]; |
63 | 63 | ||
64 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 64 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
65 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 65 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
66 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | 66 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", |
67 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 67 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
68 | 68 | ||
69 | 69 | ||
70 | return QString( tmp ); | 70 | return QString( tmp ); |
71 | #endif | 71 | #endif |
72 | //return ret; | 72 | //return ret; |
73 | } | 73 | } |
74 | 74 | ||
75 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 75 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
76 | { | 76 | { |
77 | if (!mime) { | 77 | if (!mime) { |
78 | return; | 78 | return; |
79 | } | 79 | } |
80 | mailmime_field*field = 0; | 80 | mailmime_field*field = 0; |
81 | mailmime_single_fields fields; | 81 | mailmime_single_fields fields; |
82 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 82 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
83 | if (mime->mm_mime_fields != NULL) { | 83 | if (mime->mm_mime_fields != NULL) { |
84 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 84 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
85 | mime->mm_content_type); | 85 | mime->mm_content_type); |
86 | } | 86 | } |
87 | 87 | ||
88 | mailmime_content*type = fields.fld_content; | 88 | mailmime_content*type = fields.fld_content; |
89 | clistcell*current; | 89 | clistcell*current; |
90 | if (!type) { | 90 | if (!type) { |
91 | target->setType("text"); | 91 | target->setType("text"); |
92 | target->setSubtype("plain"); | 92 | target->setSubtype("plain"); |
93 | } else { | 93 | } else { |
94 | target->setSubtype(type->ct_subtype); | 94 | target->setSubtype(type->ct_subtype); |
95 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 95 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
96 | case MAILMIME_DISCRETE_TYPE_TEXT: | 96 | case MAILMIME_DISCRETE_TYPE_TEXT: |
97 | target->setType("text"); | 97 | target->setType("text"); |
98 | break; | 98 | break; |
99 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 99 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
100 | target->setType("image"); | 100 | target->setType("image"); |
101 | break; | 101 | break; |
102 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 102 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
103 | target->setType("audio"); | 103 | target->setType("audio"); |
104 | break; | 104 | break; |
105 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 105 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
106 | target->setType("video"); | 106 | target->setType("video"); |
107 | break; | 107 | break; |
108 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 108 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
109 | target->setType("application"); | 109 | target->setType("application"); |
110 | break; | 110 | break; |
111 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 111 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
112 | default: | 112 | default: |
113 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 113 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
114 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 114 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
115 | } | 115 | } |
116 | break; | 116 | break; |
117 | } | 117 | } |
118 | if (type->ct_parameters) { | 118 | if (type->ct_parameters) { |
119 | fillParameters(target,type->ct_parameters); | 119 | fillParameters(target,type->ct_parameters); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { | 122 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { |
123 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { | 123 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { |
124 | field = (mailmime_field*)current->data; | 124 | field = (mailmime_field*)current->data; |
125 | switch(field->fld_type) { | 125 | switch(field->fld_type) { |
126 | case MAILMIME_FIELD_TRANSFER_ENCODING: | 126 | case MAILMIME_FIELD_TRANSFER_ENCODING: |
127 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); | 127 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); |
128 | break; | 128 | break; |
129 | case MAILMIME_FIELD_ID: | 129 | case MAILMIME_FIELD_ID: |
130 | target->setIdentifier(field->fld_data.fld_id); | 130 | target->setIdentifier(field->fld_data.fld_id); |
131 | break; | 131 | break; |
132 | case MAILMIME_FIELD_DESCRIPTION: | 132 | case MAILMIME_FIELD_DESCRIPTION: |
133 | target->setDescription(field->fld_data.fld_description); | 133 | target->setDescription(field->fld_data.fld_description); |
134 | break; | 134 | break; |
135 | default: | 135 | default: |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) | 142 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) |
143 | { | 143 | { |
144 | if (!parameters) {return;} | 144 | if (!parameters) {return;} |
145 | clistcell*current=0; | 145 | clistcell*current=0; |
146 | mailmime_parameter*param; | 146 | mailmime_parameter*param; |
147 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { | 147 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { |
148 | param = (mailmime_parameter*)current->data; | 148 | param = (mailmime_parameter*)current->data; |
149 | if (param) { | 149 | if (param) { |
150 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 150 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | 155 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) |
156 | { | 156 | { |
157 | QString enc="7bit"; | 157 | QString enc="7bit"; |
158 | if (!aEnc) return enc; | 158 | if (!aEnc) return enc; |
159 | switch(aEnc->enc_type) { | 159 | switch(aEnc->enc_type) { |
160 | case MAILMIME_MECHANISM_7BIT: | 160 | case MAILMIME_MECHANISM_7BIT: |
161 | enc = "7bit"; | 161 | enc = "7bit"; |
162 | break; | 162 | break; |
163 | case MAILMIME_MECHANISM_8BIT: | 163 | case MAILMIME_MECHANISM_8BIT: |
164 | enc = "8bit"; | 164 | enc = "8bit"; |
165 | break; | 165 | break; |
166 | case MAILMIME_MECHANISM_BINARY: | 166 | case MAILMIME_MECHANISM_BINARY: |
167 | enc = "binary"; | 167 | enc = "binary"; |
168 | break; | 168 | break; |
169 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 169 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
170 | enc = "quoted-printable"; | 170 | enc = "quoted-printable"; |
171 | break; | 171 | break; |
172 | case MAILMIME_MECHANISM_BASE64: | 172 | case MAILMIME_MECHANISM_BASE64: |
173 | enc = "base64"; | 173 | enc = "base64"; |
174 | break; | 174 | break; |
175 | case MAILMIME_MECHANISM_TOKEN: | 175 | case MAILMIME_MECHANISM_TOKEN: |
176 | default: | 176 | default: |
177 | if (aEnc->enc_token) { | 177 | if (aEnc->enc_token) { |
178 | enc = QString(aEnc->enc_token); | 178 | enc = QString(aEnc->enc_token); |
179 | } | 179 | } |
180 | break; | 180 | break; |
181 | } | 181 | } |
182 | return enc; | 182 | return enc; |
183 | } | 183 | } |
184 | 184 | ||
185 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 185 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
186 | { | 186 | { |
187 | if (current_rec >= 10) { | 187 | if (current_rec >= 10) { |
188 | ; // odebug << "too deep recursion!" << oendl; | 188 | ; // odebug << "too deep recursion!" << oendl; |
189 | } | 189 | } |
190 | if (!message || !mime) { | 190 | if (!message || !mime) { |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | int r; | 193 | int r; |
194 | char*data = 0; | 194 | char*data = 0; |
195 | size_t len; | 195 | size_t len; |
196 | clistiter * cur = 0; | 196 | clistiter * cur = 0; |
197 | QString b; | 197 | QString b; |
198 | RecPartP part = new RecPart(); | 198 | RecPartP part = new RecPart(); |
199 | 199 | ||
200 | switch (mime->mm_type) { | 200 | switch (mime->mm_type) { |
201 | case MAILMIME_SINGLE: | 201 | case MAILMIME_SINGLE: |
202 | { | 202 | { |
203 | QValueList<int>countlist = recList; | 203 | QValueList<int>countlist = recList; |
204 | countlist.append(current_count); | 204 | countlist.append(current_count); |
205 | r = mailmessage_fetch_section(message,mime,&data,&len); | 205 | r = mailmessage_fetch_section(message,mime,&data,&len); |
206 | part->setSize(len); | 206 | part->setSize(len); |
207 | part->setPositionlist(countlist); | 207 | part->setPositionlist(countlist); |
208 | b = gen_attachment_id(); | 208 | b = gen_attachment_id(); |
209 | part->setIdentifier(b); | 209 | part->setIdentifier(b); |
210 | fillSingleBody(part,message,mime); | 210 | fillSingleBody(part,message,mime); |
211 | if (part->Type()=="text" && target->Bodytext().isNull()) { | 211 | if (part->Type()=="text" && target->Bodytext().isNull()) { |
212 | encodedString*rs = new encodedString(); | 212 | encodedString*rs = new encodedString(); |
213 | rs->setContent(data,len); | 213 | rs->setContent(data,len); |
214 | encodedString*res = decode_String(rs,part->Encoding()); | 214 | encodedString*res = decode_String(rs,part->Encoding()); |
215 | if (countlist.count()>2) { | 215 | if (countlist.count()>2) { |
216 | bodyCache[b]=rs; | 216 | bodyCache[b]=rs; |
217 | target->addPart(part); | 217 | target->addPart(part); |
218 | } else { | 218 | } else { |
219 | delete rs; | 219 | delete rs; |
220 | } | 220 | } |
221 | b = QString(res->Content()); | 221 | b = QString(res->Content()); |
222 | delete res; | 222 | delete res; |
223 | size_t index = 0; | 223 | size_t index = 0; |
224 | char*resu = 0; | 224 | char*resu = 0; |
225 | int err = MAILIMF_NO_ERROR; | 225 | int err = MAILIMF_NO_ERROR; |
226 | QString charset = part->searchParamter( "charset"); | 226 | QString charset = part->searchParamter( "charset"); |
227 | qDebug("CHARSET %s ",charset.latin1() ); | 227 | qDebug("CHARSET %s ",charset.latin1() ); |
228 | if ( !charset.isEmpty() ) { | 228 | if (false ) { |
229 | //if ( !charset.isEmpty() ) { | ||
229 | target->setCharset( charset ); | 230 | target->setCharset( charset ); |
230 | err = mailmime_encoded_phrase_parse(charset.latin1(), | 231 | err = mailmime_encoded_phrase_parse(charset.latin1(), |
231 | b.latin1(), b.length(),&index, "utf-8",&resu); | 232 | b.latin1(), b.length(),&index, "utf-8",&resu); |
232 | if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) { | 233 | if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) { |
233 | //qDebug("res %d %s ", index, resu); | 234 | //qDebug("res %d %s ", index, resu); |
234 | b = QString::fromUtf8(resu); | 235 | b = QString::fromUtf8(resu); |
235 | } | 236 | } |
236 | if (resu) free(resu); | 237 | if (resu) free(resu); |
237 | } | 238 | } |
238 | target->setBodytext(b); | 239 | target->setBodytext(b); |
239 | target->setDescription(part); | 240 | target->setDescription(part); |
240 | } else { | 241 | } else { |
241 | bodyCache[b]=new encodedString(data,len); | 242 | bodyCache[b]=new encodedString(data,len); |
242 | target->addPart(part); | 243 | target->addPart(part); |
243 | } | 244 | } |
244 | } | 245 | } |
245 | break; | 246 | break; |
246 | case MAILMIME_MULTIPLE: | 247 | case MAILMIME_MULTIPLE: |
247 | { | 248 | { |
248 | unsigned int ccount = 1; | 249 | unsigned int ccount = 1; |
249 | mailmime*cbody=0; | 250 | mailmime*cbody=0; |
250 | QValueList<int>countlist = recList; | 251 | QValueList<int>countlist = recList; |
251 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 252 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
252 | cbody = (mailmime*)clist_content(cur); | 253 | cbody = (mailmime*)clist_content(cur); |
253 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 254 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
254 | RecPartP targetPart = new RecPart(); | 255 | RecPartP targetPart = new RecPart(); |
255 | targetPart->setType("multipart"); | 256 | targetPart->setType("multipart"); |
256 | countlist.append(current_count); | 257 | countlist.append(current_count); |
257 | targetPart->setPositionlist(countlist); | 258 | targetPart->setPositionlist(countlist); |
258 | target->addPart(targetPart); | 259 | target->addPart(targetPart); |
259 | } | 260 | } |
260 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 261 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
261 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 262 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
262 | countlist = recList; | 263 | countlist = recList; |
263 | } | 264 | } |
264 | ++ccount; | 265 | ++ccount; |
265 | } | 266 | } |
266 | } | 267 | } |
267 | break; | 268 | break; |
268 | case MAILMIME_MESSAGE: | 269 | case MAILMIME_MESSAGE: |
269 | { | 270 | { |
270 | QValueList<int>countlist = recList; | 271 | QValueList<int>countlist = recList; |
271 | countlist.append(current_count); | 272 | countlist.append(current_count); |
272 | /* the own header is always at recursion 0 - we don't need that */ | 273 | /* the own header is always at recursion 0 - we don't need that */ |
273 | if (current_rec > 0) { | 274 | if (current_rec > 0) { |
274 | part->setPositionlist(countlist); | 275 | part->setPositionlist(countlist); |
275 | r = mailmessage_fetch_section(message,mime,&data,&len); | 276 | r = mailmessage_fetch_section(message,mime,&data,&len); |
276 | part->setSize(len); | 277 | part->setSize(len); |
277 | part->setPositionlist(countlist); | 278 | part->setPositionlist(countlist); |
278 | b = gen_attachment_id(); | 279 | b = gen_attachment_id(); |
279 | part->setIdentifier(b); | 280 | part->setIdentifier(b); |
280 | part->setType("message"); | 281 | part->setType("message"); |
281 | part->setSubtype("rfc822"); | 282 | part->setSubtype("rfc822"); |
282 | bodyCache[b]=new encodedString(data,len); | 283 | bodyCache[b]=new encodedString(data,len); |
283 | target->addPart(part); | 284 | target->addPart(part); |
284 | } | 285 | } |
285 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 286 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
286 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 287 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
287 | } | 288 | } |
288 | } | 289 | } |
289 | break; | 290 | break; |
290 | } | 291 | } |
291 | } | 292 | } |
292 | 293 | ||
293 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) | 294 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) |
294 | { | 295 | { |
295 | int err = MAILIMF_NO_ERROR; | 296 | int err = MAILIMF_NO_ERROR; |
296 | //mailmime_single_fields fields; | 297 | //mailmime_single_fields fields; |
297 | /* is bound to msg and will be freed there */ | 298 | /* is bound to msg and will be freed there */ |
298 | mailmime * mime=0; | 299 | mailmime * mime=0; |
299 | RecBodyP body = new RecBody(); | 300 | RecBodyP body = new RecBody(); |
300 | //memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 301 | //memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
301 | err = mailmessage_get_bodystructure(msg,&mime); | 302 | err = mailmessage_get_bodystructure(msg,&mime); |
302 | QValueList<int>recList; | 303 | QValueList<int>recList; |
303 | traverseBody(body,msg,mime,recList); | 304 | traverseBody(body,msg,mime,recList); |
304 | return body; | 305 | return body; |
305 | } | 306 | } |
306 | 307 | ||
307 | 308 | ||
308 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 309 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
309 | { | 310 | { |
310 | QString result( "" ); | 311 | QString result( "" ); |
311 | 312 | ||
312 | bool first = true; | 313 | bool first = true; |
313 | if (list == 0) return result; | 314 | if (list == 0) return result; |
314 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 315 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
315 | mailimf_address *addr = (mailimf_address *) current->data; | 316 | mailimf_address *addr = (mailimf_address *) current->data; |
316 | 317 | ||
317 | if ( !first ) { | 318 | if ( !first ) { |
318 | result.append( "," ); | 319 | result.append( "," ); |
319 | } else { | 320 | } else { |
320 | first = false; | 321 | first = false; |
321 | } | 322 | } |
322 | 323 | ||
323 | switch ( addr->ad_type ) { | 324 | switch ( addr->ad_type ) { |
324 | case MAILIMF_ADDRESS_MAILBOX: | 325 | case MAILIMF_ADDRESS_MAILBOX: |
325 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 326 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
326 | break; | 327 | break; |
327 | case MAILIMF_ADDRESS_GROUP: | 328 | case MAILIMF_ADDRESS_GROUP: |
328 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 329 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
329 | break; | 330 | break; |
330 | default: | 331 | default: |
331 | ; // odebug << "Generic: unkown mailimf address type" << oendl; | 332 | ; // odebug << "Generic: unkown mailimf address type" << oendl; |
332 | break; | 333 | break; |
333 | } | 334 | } |
334 | } | 335 | } |
335 | 336 | ||
336 | return result; | 337 | return result; |
337 | } | 338 | } |
338 | 339 | ||
339 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 340 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
340 | { | 341 | { |
341 | QString result( "" ); | 342 | QString result( "" ); |
342 | 343 | ||
343 | result.append( group->grp_display_name ); | 344 | result.append( group->grp_display_name ); |
344 | result.append( ": " ); | 345 | result.append( ": " ); |
345 | 346 | ||
346 | if ( group->grp_mb_list != NULL ) { | 347 | if ( group->grp_mb_list != NULL ) { |
347 | result.append( parseMailboxList( group->grp_mb_list ) ); | 348 | result.append( parseMailboxList( group->grp_mb_list ) ); |
348 | } | 349 | } |
349 | 350 | ||
350 | result.append( ";" ); | 351 | result.append( ";" ); |
351 | 352 | ||
352 | return result; | 353 | return result; |
353 | } | 354 | } |
354 | 355 | ||
355 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 356 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) |
356 | { | 357 | { |
357 | QString result( "" ); | 358 | QString result( "" ); |
358 | 359 | ||
359 | if ( box->mb_display_name == NULL ) { | 360 | if ( box->mb_display_name == NULL ) { |
360 | result.append( box->mb_addr_spec ); | 361 | result.append( box->mb_addr_spec ); |
361 | } else { | 362 | } else { |
362 | result.append( convert_String(box->mb_display_name) ); | 363 | result.append( convert_String(box->mb_display_name) ); |
363 | result.append( " <" ); | 364 | result.append( " <" ); |
364 | result.append( box->mb_addr_spec ); | 365 | result.append( box->mb_addr_spec ); |
365 | result.append( ">" ); | 366 | result.append( ">" ); |
366 | } | 367 | } |
367 | 368 | ||
368 | return result; | 369 | return result; |
369 | } | 370 | } |
370 | 371 | ||
371 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | 372 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) |
372 | { | 373 | { |
373 | QString result( "" ); | 374 | QString result( "" ); |
374 | 375 | ||
375 | bool first = true; | 376 | bool first = true; |
376 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { | 377 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { |
377 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; | 378 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; |
378 | 379 | ||
379 | if ( !first ) { | 380 | if ( !first ) { |
380 | result.append( "," ); | 381 | result.append( "," ); |
381 | } else { | 382 | } else { |
382 | first = false; | 383 | first = false; |
383 | } | 384 | } |
384 | 385 | ||
385 | result.append( parseMailbox( box ) ); | 386 | result.append( parseMailbox( box ) ); |
386 | } | 387 | } |
387 | 388 | ||
388 | return result; | 389 | return result; |
389 | } | 390 | } |
390 | 391 | ||
391 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) | 392 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) |
392 | { | 393 | { |
393 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 394 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
394 | if (it==bodyCache.end()) return new encodedString(); | 395 | if (it==bodyCache.end()) return new encodedString(); |
395 | encodedString*t = decode_String(it.data(),part->Encoding()); | 396 | encodedString*t = decode_String(it.data(),part->Encoding()); |
396 | return t; | 397 | return t; |
397 | } | 398 | } |
398 | 399 | ||
399 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) | 400 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) |
400 | { | 401 | { |
401 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 402 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
402 | if (it==bodyCache.end()) return new encodedString(); | 403 | if (it==bodyCache.end()) return new encodedString(); |
403 | encodedString*t = it.data(); | 404 | encodedString*t = it.data(); |
404 | return t; | 405 | return t; |
405 | } | 406 | } |
406 | 407 | ||
407 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 408 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
408 | { | 409 | { |
409 | encodedString*t = fetchDecodedPart(mail,part); | 410 | encodedString*t = fetchDecodedPart(mail,part); |
410 | QString text=t->Content(); | 411 | QString text=t->Content(); |
411 | delete t; | 412 | delete t; |
412 | return text; | 413 | return text; |
413 | } | 414 | } |
414 | 415 | ||
415 | void Genericwrapper::cleanMimeCache() | 416 | void Genericwrapper::cleanMimeCache() |
416 | { | 417 | { |
417 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); | 418 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); |
418 | for (;it!=bodyCache.end();++it) { | 419 | for (;it!=bodyCache.end();++it) { |
419 | encodedString*t = it.data(); | 420 | encodedString*t = it.data(); |
420 | //it.setValue(0); | 421 | //it.setValue(0); |
421 | if (t) delete t; | 422 | if (t) delete t; |
422 | } | 423 | } |
423 | bodyCache.clear(); | 424 | bodyCache.clear(); |
424 | ; // odebug << "Genericwrapper: cache cleaned" << oendl; | 425 | ; // odebug << "Genericwrapper: cache cleaned" << oendl; |
425 | } | 426 | } |
426 | 427 | ||
427 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | 428 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) |
428 | { | 429 | { |
429 | QStringList res; | 430 | QStringList res; |
430 | if (!in_replies || !in_replies->mid_list) return res; | 431 | if (!in_replies || !in_replies->mid_list) return res; |
431 | clistiter * current = 0; | 432 | clistiter * current = 0; |
432 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { | 433 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { |
433 | QString h((char*)current->data); | 434 | QString h((char*)current->data); |
434 | while (h.length()>0 && h[0]=='<') { | 435 | while (h.length()>0 && h[0]=='<') { |
435 | h.remove(0,1); | 436 | h.remove(0,1); |
436 | } | 437 | } |
437 | while (h.length()>0 && h[h.length()-1]=='>') { | 438 | while (h.length()>0 && h[h.length()-1]=='>') { |
438 | h.remove(h.length()-1,1); | 439 | h.remove(h.length()-1,1); |
439 | } | 440 | } |
440 | if (h.length()>0) { | 441 | if (h.length()>0) { |
441 | res.append(h); | 442 | res.append(h); |
442 | } | 443 | } |
443 | } | 444 | } |
444 | return res; | 445 | return res; |
445 | } | 446 | } |
446 | 447 | ||
447 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) | 448 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) |
448 | { | 449 | { |
449 | int r; | 450 | int r; |
450 | mailmessage_list * env_list = 0; | 451 | mailmessage_list * env_list = 0; |
451 | r = mailsession_get_messages_list(session,&env_list); | 452 | r = mailsession_get_messages_list(session,&env_list); |
452 | if (r != MAIL_NO_ERROR) { | 453 | if (r != MAIL_NO_ERROR) { |
453 | ; // odebug << "Error message list" << oendl; | 454 | ; // odebug << "Error message list" << oendl; |
454 | return; | 455 | return; |
455 | } | 456 | } |
456 | r = mailsession_get_envelopes_list(session, env_list); | 457 | r = mailsession_get_envelopes_list(session, env_list); |
457 | if (r != MAIL_NO_ERROR) { | 458 | if (r != MAIL_NO_ERROR) { |
458 | ; // odebug << "Error filling message list" << oendl; | 459 | ; // odebug << "Error filling message list" << oendl; |
459 | if (env_list) { | 460 | if (env_list) { |
460 | mailmessage_list_free(env_list); | 461 | mailmessage_list_free(env_list); |
461 | } | 462 | } |
462 | return; | 463 | return; |
463 | } | 464 | } |
464 | mailimf_references * refs = 0; | 465 | mailimf_references * refs = 0; |
465 | mailimf_in_reply_to * in_replies = 0; | 466 | mailimf_in_reply_to * in_replies = 0; |
466 | uint32_t i = 0; | 467 | uint32_t i = 0; |
467 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 468 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
468 | mailmessage * msg; | 469 | mailmessage * msg; |
469 | QBitArray mFlags(7); | 470 | QBitArray mFlags(7); |
470 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 471 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
471 | if (msg->msg_fields == NULL) { | 472 | if (msg->msg_fields == NULL) { |
472 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; | 473 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; |
473 | continue; | 474 | continue; |
474 | } | 475 | } |
475 | RecMailP mail = new RecMail(); | 476 | RecMailP mail = new RecMail(); |
476 | mail->setWrapper(this); | 477 | mail->setWrapper(this); |
477 | mail_flags * flag_result = 0; | 478 | mail_flags * flag_result = 0; |
478 | r = mailmessage_get_flags(msg,&flag_result); | 479 | r = mailmessage_get_flags(msg,&flag_result); |
479 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 480 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
480 | mFlags.setBit(FLAG_SEEN); | 481 | mFlags.setBit(FLAG_SEEN); |
481 | } | 482 | } |
482 | mailimf_single_fields single_fields; | 483 | mailimf_single_fields single_fields; |
483 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 484 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
484 | mail->setMsgsize(msg->msg_size); | 485 | mail->setMsgsize(msg->msg_size); |
485 | mail->setFlags(mFlags); | 486 | mail->setFlags(mFlags); |
486 | mail->setMbox(mailbox); | 487 | mail->setMbox(mailbox); |
487 | mail->setNumber(msg->msg_index); | 488 | mail->setNumber(msg->msg_index); |
488 | if (single_fields.fld_subject) | 489 | if (single_fields.fld_subject) |
489 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 490 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
490 | if (single_fields.fld_from) | 491 | if (single_fields.fld_from) |
491 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 492 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
492 | if (!mbox_as_to) { | 493 | if (!mbox_as_to) { |
493 | if (single_fields.fld_to) | 494 | if (single_fields.fld_to) |
494 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 495 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
495 | } else { | 496 | } else { |
496 | mail->setTo(mailbox); | 497 | mail->setTo(mailbox); |
497 | } | 498 | } |
498 | if (single_fields.fld_cc) | 499 | if (single_fields.fld_cc) |
499 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 500 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
500 | if (single_fields.fld_bcc) | 501 | if (single_fields.fld_bcc) |
501 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 502 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
502 | if (single_fields.fld_orig_date) { | 503 | if (single_fields.fld_orig_date) { |
503 | QDateTime dt = Genericwrapper::parseDateTime( single_fields.fld_orig_date->dt_date_time ); | 504 | QDateTime dt = Genericwrapper::parseDateTime( single_fields.fld_orig_date->dt_date_time ); |
504 | QString ret; | 505 | QString ret; |
505 | if ( dt.date() == QDate::currentDate () ) | 506 | if ( dt.date() == QDate::currentDate () ) |
506 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 507 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
507 | else { | 508 | else { |
508 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 509 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
509 | } | 510 | } |
510 | mail->setDate( ret ); | 511 | mail->setDate( ret ); |
511 | char tmp[20]; | 512 | char tmp[20]; |
512 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | 513 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", |
513 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | 514 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); |
514 | //qDebug(" iso %s ", tmp); | 515 | //qDebug(" iso %s ", tmp); |
515 | mail->setIsoDate( QString( tmp ) ); | 516 | mail->setIsoDate( QString( tmp ) ); |
516 | } | 517 | } |
517 | // crashes when accessing pop3 account? | 518 | // crashes when accessing pop3 account? |
518 | if (single_fields.fld_message_id) { | 519 | if (single_fields.fld_message_id) { |
519 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 520 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
520 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; | 521 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; |
521 | } | 522 | } |
522 | if (single_fields.fld_reply_to) { | 523 | if (single_fields.fld_reply_to) { |
523 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | 524 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); |
524 | if (t.count()>0) { | 525 | if (t.count()>0) { |
525 | mail->setReplyto(t[0]); | 526 | mail->setReplyto(t[0]); |
526 | } | 527 | } |
527 | } | 528 | } |
528 | #if 0 | 529 | #if 0 |
529 | refs = single_fields.fld_references; | 530 | refs = single_fields.fld_references; |
530 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 531 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
531 | char * text = (char*)refs->mid_list->first->data; | 532 | char * text = (char*)refs->mid_list->first->data; |
532 | mail->setReplyto(QString(text)); | 533 | mail->setReplyto(QString(text)); |
533 | } | 534 | } |
534 | #endif | 535 | #endif |
535 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && | 536 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && |
536 | clist_count(single_fields.fld_in_reply_to->mid_list)) { | 537 | clist_count(single_fields.fld_in_reply_to->mid_list)) { |
537 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); | 538 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); |
538 | } | 539 | } |
539 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) | 540 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) |
540 | target.append(mail); | 541 | target.append(mail); |
541 | } | 542 | } |
542 | if (env_list) { | 543 | if (env_list) { |
543 | mailmessage_list_free(env_list); | 544 | mailmessage_list_free(env_list); |
544 | } | 545 | } |
545 | } | 546 | } |
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 2a54381..da7065f 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,1359 +1,1359 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | #include "genericwrapper.h" | 10 | #include "genericwrapper.h" |
11 | #include <kglobal.h> | 11 | #include <kglobal.h> |
12 | 12 | ||
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | int IMAPwrapper::mMax = 0; | 14 | int IMAPwrapper::mMax = 0; |
15 | int IMAPwrapper::mCurrent = 0; | 15 | int IMAPwrapper::mCurrent = 0; |
16 | 16 | ||
17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
18 | : AbstractMail() | 18 | : AbstractMail() |
19 | { | 19 | { |
20 | account = a; | 20 | account = a; |
21 | m_imap = 0; | 21 | m_imap = 0; |
22 | m_Lastmbox = ""; | 22 | m_Lastmbox = ""; |
23 | mCurrent = 0; | 23 | mCurrent = 0; |
24 | mMax = 0; | 24 | mMax = 0; |
25 | } | 25 | } |
26 | 26 | ||
27 | IMAPwrapper::~IMAPwrapper() | 27 | IMAPwrapper::~IMAPwrapper() |
28 | { | 28 | { |
29 | logout(); | 29 | logout(); |
30 | } | 30 | } |
31 | 31 | ||
32 | /* to avoid to often select statements in loops etc. | 32 | /* to avoid to often select statements in loops etc. |
33 | we trust that we are logged in and connection is established!*/ | 33 | we trust that we are logged in and connection is established!*/ |
34 | int IMAPwrapper::selectMbox(const QString&mbox) | 34 | int IMAPwrapper::selectMbox(const QString&mbox) |
35 | { | 35 | { |
36 | if (mbox == m_Lastmbox) { | 36 | if (mbox == m_Lastmbox) { |
37 | return MAILIMAP_NO_ERROR; | 37 | return MAILIMAP_NO_ERROR; |
38 | } | 38 | } |
39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
40 | if ( err != MAILIMAP_NO_ERROR ) { | 40 | if ( err != MAILIMAP_NO_ERROR ) { |
41 | m_Lastmbox = ""; | 41 | m_Lastmbox = ""; |
42 | return err; | 42 | return err; |
43 | } | 43 | } |
44 | m_Lastmbox = mbox; | 44 | m_Lastmbox = mbox; |
45 | return err; | 45 | return err; |
46 | } | 46 | } |
47 | 47 | ||
48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
49 | { | 49 | { |
50 | //qDebug("imap progress %d of %d ",current,maximum ); | 50 | //qDebug("imap progress %d of %d ",current,maximum ); |
51 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); | 51 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); |
52 | //qApp->processEvents() | 52 | //qApp->processEvents() |
53 | static unsigned int last = 0; | 53 | static unsigned int last = 0; |
54 | if ( last != current ) | 54 | if ( last != current ) |
55 | IMAPwrapper::progress(); | 55 | IMAPwrapper::progress(); |
56 | last = current; | 56 | last = current; |
57 | } | 57 | } |
58 | void IMAPwrapper::progress( QString m ) | 58 | void IMAPwrapper::progress( QString m ) |
59 | { | 59 | { |
60 | 60 | ||
61 | static QString mProgrMess; | 61 | static QString mProgrMess; |
62 | if ( m != QString::null ) { | 62 | if ( m != QString::null ) { |
63 | mProgrMess = m; | 63 | mProgrMess = m; |
64 | mCurrent = 1; | 64 | mCurrent = 1; |
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | QString mess; | 67 | QString mess; |
68 | //qDebug("progress "); | 68 | //qDebug("progress "); |
69 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); | 69 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); |
70 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); | 70 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); |
71 | Global::statusMessage(mess); | 71 | Global::statusMessage(mess); |
72 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); | 72 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); |
73 | qApp->processEvents(); | 73 | qApp->processEvents(); |
74 | } | 74 | } |
75 | bool IMAPwrapper::start_tls(bool force_tls) | 75 | bool IMAPwrapper::start_tls(bool force_tls) |
76 | { | 76 | { |
77 | int err; | 77 | int err; |
78 | bool try_tls = force_tls; | 78 | bool try_tls = force_tls; |
79 | mailimap_capability_data * cap_data = 0; | 79 | mailimap_capability_data * cap_data = 0; |
80 | 80 | ||
81 | err = mailimap_capability(m_imap,&cap_data); | 81 | err = mailimap_capability(m_imap,&cap_data); |
82 | if (err != MAILIMAP_NO_ERROR) { | 82 | if (err != MAILIMAP_NO_ERROR) { |
83 | Global::statusMessage("error getting capabilities!"); | 83 | Global::statusMessage("error getting capabilities!"); |
84 | return false; | 84 | return false; |
85 | } | 85 | } |
86 | clistiter * cur; | 86 | clistiter * cur; |
87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
88 | struct mailimap_capability * cap; | 88 | struct mailimap_capability * cap; |
89 | cap = (struct mailimap_capability *)clist_content(cur); | 89 | cap = (struct mailimap_capability *)clist_content(cur); |
90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
92 | try_tls = true; | 92 | try_tls = true; |
93 | break; | 93 | break; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | if (cap_data) { | 97 | if (cap_data) { |
98 | mailimap_capability_data_free(cap_data); | 98 | mailimap_capability_data_free(cap_data); |
99 | } | 99 | } |
100 | if (try_tls) { | 100 | if (try_tls) { |
101 | err = mailimap_starttls(m_imap); | 101 | err = mailimap_starttls(m_imap); |
102 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 102 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
103 | Global::statusMessage(i18n("Server has no TLS support!")); | 103 | Global::statusMessage(i18n("Server has no TLS support!")); |
104 | try_tls = false; | 104 | try_tls = false; |
105 | } else { | 105 | } else { |
106 | mailstream_low * low; | 106 | mailstream_low * low; |
107 | mailstream_low * new_low; | 107 | mailstream_low * new_low; |
108 | low = mailstream_get_low(m_imap->imap_stream); | 108 | low = mailstream_get_low(m_imap->imap_stream); |
109 | if (!low) { | 109 | if (!low) { |
110 | try_tls = false; | 110 | try_tls = false; |
111 | } else { | 111 | } else { |
112 | int fd = mailstream_low_get_fd(low); | 112 | int fd = mailstream_low_get_fd(low); |
113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
114 | mailstream_low_free(low); | 114 | mailstream_low_free(low); |
115 | mailstream_set_low(m_imap->imap_stream, new_low); | 115 | mailstream_set_low(m_imap->imap_stream, new_low); |
116 | } else { | 116 | } else { |
117 | try_tls = false; | 117 | try_tls = false; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | return try_tls; | 122 | return try_tls; |
123 | } | 123 | } |
124 | 124 | ||
125 | void IMAPwrapper::login() | 125 | void IMAPwrapper::login() |
126 | { | 126 | { |
127 | QString server, user, pass; | 127 | QString server, user, pass; |
128 | uint16_t port; | 128 | uint16_t port; |
129 | int err = MAILIMAP_NO_ERROR; | 129 | int err = MAILIMAP_NO_ERROR; |
130 | 130 | ||
131 | if (account->getOffline()) return; | 131 | if (account->getOffline()) return; |
132 | /* we are connected this moment */ | 132 | /* we are connected this moment */ |
133 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 133 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
134 | if (m_imap) { | 134 | if (m_imap) { |
135 | err = mailimap_noop(m_imap); | 135 | err = mailimap_noop(m_imap); |
136 | if (err!=MAILIMAP_NO_ERROR) { | 136 | if (err!=MAILIMAP_NO_ERROR) { |
137 | logout(); | 137 | logout(); |
138 | } else { | 138 | } else { |
139 | mailstream_flush(m_imap->imap_stream); | 139 | mailstream_flush(m_imap->imap_stream); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | server = account->getServer(); | 143 | server = account->getServer(); |
144 | port = account->getPort().toUInt(); | 144 | port = account->getPort().toUInt(); |
145 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 145 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
146 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 146 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
147 | login.show(); | 147 | login.show(); |
148 | if ( QDialog::Accepted == login.exec() ) { | 148 | if ( QDialog::Accepted == login.exec() ) { |
149 | // ok | 149 | // ok |
150 | user = login.getUser(); | 150 | user = login.getUser(); |
151 | pass = login.getPassword(); | 151 | pass = login.getPassword(); |
152 | } else { | 152 | } else { |
153 | // cancel | 153 | // cancel |
154 | return; | 154 | return; |
155 | } | 155 | } |
156 | } else { | 156 | } else { |
157 | user = account->getUser(); | 157 | user = account->getUser(); |
158 | pass = account->getPassword(); | 158 | pass = account->getPassword(); |
159 | } | 159 | } |
160 | 160 | ||
161 | m_imap = mailimap_new( 20, &imap_progress ); | 161 | m_imap = mailimap_new( 20, &imap_progress ); |
162 | 162 | ||
163 | /* connect */ | 163 | /* connect */ |
164 | bool ssl = false; | 164 | bool ssl = false; |
165 | bool try_tls = false; | 165 | bool try_tls = false; |
166 | bool force_tls = false; | 166 | bool force_tls = false; |
167 | 167 | ||
168 | if ( account->ConnectionType() == 2 ) { | 168 | if ( account->ConnectionType() == 2 ) { |
169 | ssl = true; | 169 | ssl = true; |
170 | } | 170 | } |
171 | if (account->ConnectionType()==1) { | 171 | if (account->ConnectionType()==1) { |
172 | force_tls = true; | 172 | force_tls = true; |
173 | } | 173 | } |
174 | 174 | ||
175 | if ( ssl ) { | 175 | if ( ssl ) { |
176 | qDebug("using ssl "); | 176 | qDebug("using ssl "); |
177 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); | 177 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); |
178 | qDebug("back "); | 178 | qDebug("back "); |
179 | } else { | 179 | } else { |
180 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); | 180 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); |
181 | } | 181 | } |
182 | 182 | ||
183 | if ( err != MAILIMAP_NO_ERROR && | 183 | if ( err != MAILIMAP_NO_ERROR && |
184 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 184 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
185 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 185 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
186 | QString failure = ""; | 186 | QString failure = ""; |
187 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 187 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
188 | failure="Connection refused"; | 188 | failure="Connection refused"; |
189 | } else { | 189 | } else { |
190 | failure="Unknown failure"; | 190 | failure="Unknown failure"; |
191 | } | 191 | } |
192 | Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); | 192 | Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); |
193 | mailimap_free( m_imap ); | 193 | mailimap_free( m_imap ); |
194 | m_imap = 0; | 194 | m_imap = 0; |
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | 197 | ||
198 | if (!ssl) { | 198 | if (!ssl) { |
199 | try_tls = start_tls(force_tls); | 199 | try_tls = start_tls(force_tls); |
200 | } | 200 | } |
201 | 201 | ||
202 | bool ok = true; | 202 | bool ok = true; |
203 | if (force_tls && !try_tls) { | 203 | if (force_tls && !try_tls) { |
204 | Global::statusMessage(i18n("Server has no TLS support!")); | 204 | Global::statusMessage(i18n("Server has no TLS support!")); |
205 | ok = false; | 205 | ok = false; |
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
209 | /* login */ | 209 | /* login */ |
210 | 210 | ||
211 | if (ok) { | 211 | if (ok) { |
212 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); | 212 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); |
213 | if ( err != MAILIMAP_NO_ERROR ) { | 213 | if ( err != MAILIMAP_NO_ERROR ) { |
214 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); | 214 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); |
215 | ok = false; | 215 | ok = false; |
216 | } | 216 | } |
217 | } | 217 | } |
218 | if (!ok) { | 218 | if (!ok) { |
219 | err = mailimap_close( m_imap ); | 219 | err = mailimap_close( m_imap ); |
220 | mailimap_free( m_imap ); | 220 | mailimap_free( m_imap ); |
221 | m_imap = 0; | 221 | m_imap = 0; |
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | void IMAPwrapper::logout() | 225 | void IMAPwrapper::logout() |
226 | { | 226 | { |
227 | int err = MAILIMAP_NO_ERROR; | 227 | int err = MAILIMAP_NO_ERROR; |
228 | if (!m_imap) return; | 228 | if (!m_imap) return; |
229 | err = mailimap_logout( m_imap ); | 229 | err = mailimap_logout( m_imap ); |
230 | err = mailimap_close( m_imap ); | 230 | err = mailimap_close( m_imap ); |
231 | mailimap_free( m_imap ); | 231 | mailimap_free( m_imap ); |
232 | m_imap = 0; | 232 | m_imap = 0; |
233 | m_Lastmbox = ""; | 233 | m_Lastmbox = ""; |
234 | } | 234 | } |
235 | 235 | ||
236 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 236 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
237 | { | 237 | { |
238 | 238 | ||
239 | int tryAgain = 1; | 239 | int tryAgain = 1; |
240 | while ( tryAgain >= 0 ) { | 240 | while ( tryAgain >= 0 ) { |
241 | int err = MAILIMAP_NO_ERROR; | 241 | int err = MAILIMAP_NO_ERROR; |
242 | clist *result = 0; | 242 | clist *result = 0; |
243 | clistcell *current; | 243 | clistcell *current; |
244 | mailimap_fetch_type *fetchType = 0; | 244 | mailimap_fetch_type *fetchType = 0; |
245 | mailimap_set *set = 0; | 245 | mailimap_set *set = 0; |
246 | 246 | ||
247 | login(); | 247 | login(); |
248 | if (!m_imap) { | 248 | if (!m_imap) { |
249 | return; | 249 | return; |
250 | } | 250 | } |
251 | /* select mailbox READONLY for operations */ | 251 | /* select mailbox READONLY for operations */ |
252 | err = selectMbox(mailbox); | 252 | err = selectMbox(mailbox); |
253 | if ( err != MAILIMAP_NO_ERROR ) { | 253 | if ( err != MAILIMAP_NO_ERROR ) { |
254 | return; | 254 | return; |
255 | } | 255 | } |
256 | 256 | ||
257 | int last = m_imap->imap_selection_info->sel_exists; | 257 | int last = m_imap->imap_selection_info->sel_exists; |
258 | 258 | ||
259 | if (last == 0) { | 259 | if (last == 0) { |
260 | Global::statusMessage(i18n("Mailbox has no mails")); | 260 | Global::statusMessage(i18n("Mailbox has no mails")); |
261 | return; | 261 | return; |
262 | } else { | 262 | } else { |
263 | } | 263 | } |
264 | progress( i18n("Fetch ")); | 264 | progress( i18n("Fetch ")); |
265 | mMax = last; | 265 | mMax = last; |
266 | //qDebug("last %d ", last); | 266 | //qDebug("last %d ", last); |
267 | Global::statusMessage(i18n("Fetching header list")); | 267 | Global::statusMessage(i18n("Fetching header list")); |
268 | qApp->processEvents(); | 268 | qApp->processEvents(); |
269 | /* the range has to start at 1!!! not with 0!!!! */ | 269 | /* the range has to start at 1!!! not with 0!!!! */ |
270 | //LR the access to web.de imap server is no working with value 1 | 270 | //LR the access to web.de imap server is no working with value 1 |
271 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); | 271 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); |
272 | set = mailimap_set_new_interval( tryAgain, last ); | 272 | set = mailimap_set_new_interval( tryAgain, last ); |
273 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 273 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
274 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 274 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
277 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 277 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
278 | 278 | ||
279 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 279 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
280 | mailimap_set_free( set ); | 280 | mailimap_set_free( set ); |
281 | mailimap_fetch_type_free( fetchType ); | 281 | mailimap_fetch_type_free( fetchType ); |
282 | 282 | ||
283 | QString date,subject,from; | 283 | QString date,subject,from; |
284 | 284 | ||
285 | if ( err == MAILIMAP_NO_ERROR ) { | 285 | if ( err == MAILIMAP_NO_ERROR ) { |
286 | tryAgain = -1; | 286 | tryAgain = -1; |
287 | mailimap_msg_att * msg_att; | 287 | mailimap_msg_att * msg_att; |
288 | int i = 0; | 288 | int i = 0; |
289 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 289 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
290 | ++i; | 290 | ++i; |
291 | //qDebug("iii %d ",i); | 291 | //qDebug("iii %d ",i); |
292 | msg_att = (mailimap_msg_att*)current->data; | 292 | msg_att = (mailimap_msg_att*)current->data; |
293 | RecMail*m = parse_list_result(msg_att); | 293 | RecMail*m = parse_list_result(msg_att); |
294 | if (m) { | 294 | if (m) { |
295 | if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) { | 295 | if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) { |
296 | m->setNumber(i); | 296 | m->setNumber(i); |
297 | m->setMbox(mailbox); | 297 | m->setMbox(mailbox); |
298 | m->setWrapper(this); | 298 | m->setWrapper(this); |
299 | target.append(m); | 299 | target.append(m); |
300 | } | 300 | } |
301 | } | 301 | } |
302 | } | 302 | } |
303 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); | 303 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); |
304 | } else { | 304 | } else { |
305 | --tryAgain; | 305 | --tryAgain; |
306 | --tryAgain;//disabled tryagain by adding this line | 306 | --tryAgain;//disabled tryagain by adding this line |
307 | if ( tryAgain < 0 ) | 307 | if ( tryAgain < 0 ) |
308 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); | 308 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); |
309 | else | 309 | else |
310 | qDebug("try again... "); | 310 | qDebug("try again... "); |
311 | } | 311 | } |
312 | 312 | ||
313 | if (result) mailimap_fetch_list_free(result); | 313 | if (result) mailimap_fetch_list_free(result); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 317 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
318 | { | 318 | { |
319 | const char *path, *mask; | 319 | const char *path, *mask; |
320 | int err = MAILIMAP_NO_ERROR; | 320 | int err = MAILIMAP_NO_ERROR; |
321 | clist *result = 0; | 321 | clist *result = 0; |
322 | clistcell *current = 0; | 322 | clistcell *current = 0; |
323 | clistcell*cur_flag = 0; | 323 | clistcell*cur_flag = 0; |
324 | mailimap_mbx_list_flags*bflags = 0; | 324 | mailimap_mbx_list_flags*bflags = 0; |
325 | 325 | ||
326 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 326 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
327 | login(); | 327 | login(); |
328 | if (!m_imap) { | 328 | if (!m_imap) { |
329 | return folders; | 329 | return folders; |
330 | } | 330 | } |
331 | 331 | ||
332 | /* | 332 | /* |
333 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 333 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
334 | * We must not forget to filter them out in next loop! | 334 | * We must not forget to filter them out in next loop! |
335 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 335 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
336 | */ | 336 | */ |
337 | Global::statusMessage(i18n("Fetching folder list")); | 337 | Global::statusMessage(i18n("Fetching folder list")); |
338 | qApp->processEvents(); | 338 | qApp->processEvents(); |
339 | QString temp; | 339 | QString temp; |
340 | mask = "INBOX" ; | 340 | mask = "INBOX" ; |
341 | mailimap_mailbox_list *list; | 341 | mailimap_mailbox_list *list; |
342 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 342 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
343 | QString del; | 343 | QString del; |
344 | bool selectable = true; | 344 | bool selectable = true; |
345 | bool no_inferiors = false; | 345 | bool no_inferiors = false; |
346 | if ( err == MAILIMAP_NO_ERROR ) { | 346 | if ( err == MAILIMAP_NO_ERROR ) { |
347 | current = result->first; | 347 | current = result->first; |
348 | for ( int i = result->count; i > 0; i-- ) { | 348 | for ( int i = result->count; i > 0; i-- ) { |
349 | list = (mailimap_mailbox_list *) current->data; | 349 | list = (mailimap_mailbox_list *) current->data; |
350 | // it is better use the deep copy mechanism of qt itself | 350 | // it is better use the deep copy mechanism of qt itself |
351 | // instead of using strdup! | 351 | // instead of using strdup! |
352 | temp = list->mb_name; | 352 | temp = list->mb_name; |
353 | del = list->mb_delimiter; | 353 | del = list->mb_delimiter; |
354 | current = current->next; | 354 | current = current->next; |
355 | if ( (bflags = list->mb_flag) ) { | 355 | if ( (bflags = list->mb_flag) ) { |
356 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 356 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
357 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 357 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
358 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 358 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
359 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 359 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
360 | no_inferiors = true; | 360 | no_inferiors = true; |
361 | } | 361 | } |
362 | } | 362 | } |
363 | } | 363 | } |
364 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 364 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
365 | } | 365 | } |
366 | } else { | 366 | } else { |
367 | qDebug("error fetching folders: "); | 367 | qDebug("error fetching folders: "); |
368 | 368 | ||
369 | } | 369 | } |
370 | mailimap_list_result_free( result ); | 370 | mailimap_list_result_free( result ); |
371 | 371 | ||
372 | /* | 372 | /* |
373 | * second stage - get the other then inbox folders | 373 | * second stage - get the other then inbox folders |
374 | */ | 374 | */ |
375 | mask = "*" ; | 375 | mask = "*" ; |
376 | path = account->getPrefix().latin1(); | 376 | path = account->getPrefix().latin1(); |
377 | if (!path) path = ""; | 377 | if (!path) path = ""; |
378 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 378 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
379 | if ( err == MAILIMAP_NO_ERROR ) { | 379 | if ( err == MAILIMAP_NO_ERROR ) { |
380 | current = result->first; | 380 | current = result->first; |
381 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 381 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
382 | no_inferiors = false; | 382 | no_inferiors = false; |
383 | list = (mailimap_mailbox_list *) current->data; | 383 | list = (mailimap_mailbox_list *) current->data; |
384 | // it is better use the deep copy mechanism of qt itself | 384 | // it is better use the deep copy mechanism of qt itself |
385 | // instead of using strdup! | 385 | // instead of using strdup! |
386 | temp = list->mb_name; | 386 | temp = list->mb_name; |
387 | if (temp.lower()=="inbox") | 387 | if (temp.lower()=="inbox") |
388 | continue; | 388 | continue; |
389 | if (temp.lower()==account->getPrefix().lower()) | 389 | if (temp.lower()==account->getPrefix().lower()) |
390 | continue; | 390 | continue; |
391 | if ( (bflags = list->mb_flag) ) { | 391 | if ( (bflags = list->mb_flag) ) { |
392 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 392 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
393 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 393 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
394 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 394 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
395 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 395 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
396 | no_inferiors = true; | 396 | no_inferiors = true; |
397 | } | 397 | } |
398 | } | 398 | } |
399 | } | 399 | } |
400 | del = list->mb_delimiter; | 400 | del = list->mb_delimiter; |
401 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 401 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
402 | } | 402 | } |
403 | } else { | 403 | } else { |
404 | qDebug("error fetching folders "); | 404 | qDebug("error fetching folders "); |
405 | 405 | ||
406 | } | 406 | } |
407 | if (result) mailimap_list_result_free( result ); | 407 | if (result) mailimap_list_result_free( result ); |
408 | return folders; | 408 | return folders; |
409 | } | 409 | } |
410 | 410 | ||
411 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 411 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
412 | { | 412 | { |
413 | RecMail * m = 0; | 413 | RecMail * m = 0; |
414 | mailimap_msg_att_item *item=0; | 414 | mailimap_msg_att_item *item=0; |
415 | clistcell *current,*c,*cf; | 415 | clistcell *current,*c,*cf; |
416 | mailimap_msg_att_dynamic*flist; | 416 | mailimap_msg_att_dynamic*flist; |
417 | mailimap_flag_fetch*cflag; | 417 | mailimap_flag_fetch*cflag; |
418 | int size = 0; | 418 | int size = 0; |
419 | QBitArray mFlags(7); | 419 | QBitArray mFlags(7); |
420 | QStringList addresslist; | 420 | QStringList addresslist; |
421 | 421 | ||
422 | if (!m_att) { | 422 | if (!m_att) { |
423 | return m; | 423 | return m; |
424 | } | 424 | } |
425 | m = new RecMail(); | 425 | m = new RecMail(); |
426 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 426 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
427 | current = c; | 427 | current = c; |
428 | size = 0; | 428 | size = 0; |
429 | item = (mailimap_msg_att_item*)current->data; | 429 | item = (mailimap_msg_att_item*)current->data; |
430 | if ( !item ) | 430 | if ( !item ) |
431 | continue; | 431 | continue; |
432 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 432 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
433 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 433 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
434 | if (!flist || !flist->att_list) { | 434 | if (!flist || !flist->att_list) { |
435 | continue; | 435 | continue; |
436 | } | 436 | } |
437 | cf = flist->att_list->first; | 437 | cf = flist->att_list->first; |
438 | if( ! cf ) | 438 | if( ! cf ) |
439 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 439 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
440 | cflag = (mailimap_flag_fetch*)cf->data; | 440 | cflag = (mailimap_flag_fetch*)cf->data; |
441 | if( ! cflag ) | 441 | if( ! cflag ) |
442 | qDebug("imap:not cflag "); | 442 | qDebug("imap:not cflag "); |
443 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 443 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
444 | switch (cflag->fl_flag->fl_type) { | 444 | switch (cflag->fl_flag->fl_type) { |
445 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 445 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
446 | mFlags.setBit(FLAG_ANSWERED); | 446 | mFlags.setBit(FLAG_ANSWERED); |
447 | break; | 447 | break; |
448 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 448 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
449 | mFlags.setBit(FLAG_FLAGGED); | 449 | mFlags.setBit(FLAG_FLAGGED); |
450 | break; | 450 | break; |
451 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 451 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
452 | mFlags.setBit(FLAG_DELETED); | 452 | mFlags.setBit(FLAG_DELETED); |
453 | break; | 453 | break; |
454 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 454 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
455 | mFlags.setBit(FLAG_SEEN); | 455 | mFlags.setBit(FLAG_SEEN); |
456 | break; | 456 | break; |
457 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 457 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
458 | mFlags.setBit(FLAG_DRAFT); | 458 | mFlags.setBit(FLAG_DRAFT); |
459 | break; | 459 | break; |
460 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 460 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
461 | break; | 461 | break; |
462 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 462 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
463 | break; | 463 | break; |
464 | default: | 464 | default: |
465 | break; | 465 | break; |
466 | } | 466 | } |
467 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 467 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
468 | mFlags.setBit(FLAG_RECENT); | 468 | mFlags.setBit(FLAG_RECENT); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | continue; | 471 | continue; |
472 | } | 472 | } |
473 | if ( item->att_data.att_static == NULL ) | 473 | if ( item->att_data.att_static == NULL ) |
474 | continue; | 474 | continue; |
475 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 475 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
476 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 476 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
477 | if ( head == NULL ) | 477 | if ( head == NULL ) |
478 | continue; | 478 | continue; |
479 | if ( head->env_date != NULL ) { | 479 | if ( head->env_date != NULL ) { |
480 | m->setDate(head->env_date); | 480 | m->setDate(head->env_date); |
481 | //struct mailimf_date_time result; | 481 | //struct mailimf_date_time result; |
482 | struct mailimf_date_time* date;// = &result; | 482 | struct mailimf_date_time* date;// = &result; |
483 | struct mailimf_date_time **re = &date; | 483 | struct mailimf_date_time **re = &date; |
484 | size_t length = m->getDate().length(); | 484 | size_t length = m->getDate().length(); |
485 | size_t index = 0; | 485 | size_t index = 0; |
486 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | 486 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { |
487 | QDateTime dt = Genericwrapper::parseDateTime( date ); | 487 | QDateTime dt = Genericwrapper::parseDateTime( date ); |
488 | QString ret; | 488 | QString ret; |
489 | if ( dt.date() == QDate::currentDate () ) | 489 | if ( dt.date() == QDate::currentDate () ) |
490 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 490 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
491 | else { | 491 | else { |
492 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 492 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
493 | } | 493 | } |
494 | m->setDate( ret ); | 494 | m->setDate( ret ); |
495 | char tmp[20]; | 495 | char tmp[20]; |
496 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | 496 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", |
497 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | 497 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); |
498 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); | 498 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); |
499 | m->setIsoDate( QString( tmp ) ); | 499 | m->setIsoDate( QString( tmp ) ); |
500 | mailimf_date_time_free ( date ); | 500 | mailimf_date_time_free ( date ); |
501 | } else { | 501 | } else { |
502 | m->setIsoDate(head->env_date); | 502 | m->setIsoDate(head->env_date); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | if ( head->env_subject != NULL ) | 505 | if ( head->env_subject != NULL ) |
506 | m->setSubject(convert_String((const char*)head->env_subject)); | 506 | m->setSubject(convert_String((const char*)head->env_subject)); |
507 | //m->setSubject(head->env_subject); | 507 | //m->setSubject(head->env_subject); |
508 | if (head->env_from!=NULL) { | 508 | if (head->env_from!=NULL) { |
509 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 509 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
510 | if (addresslist.count()) { | 510 | if (addresslist.count()) { |
511 | m->setFrom(addresslist.first()); | 511 | m->setFrom(addresslist.first()); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | if (head->env_to!=NULL) { | 514 | if (head->env_to!=NULL) { |
515 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 515 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
516 | m->setTo(addresslist); | 516 | m->setTo(addresslist); |
517 | } | 517 | } |
518 | if (head->env_cc!=NULL) { | 518 | if (head->env_cc!=NULL) { |
519 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 519 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
520 | m->setCC(addresslist); | 520 | m->setCC(addresslist); |
521 | } | 521 | } |
522 | if (head->env_bcc!=NULL) { | 522 | if (head->env_bcc!=NULL) { |
523 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 523 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
524 | m->setBcc(addresslist); | 524 | m->setBcc(addresslist); |
525 | } | 525 | } |
526 | /* reply to address, eg. email. */ | 526 | /* reply to address, eg. email. */ |
527 | if (head->env_reply_to!=NULL) { | 527 | if (head->env_reply_to!=NULL) { |
528 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 528 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
529 | if (addresslist.count()) { | 529 | if (addresslist.count()) { |
530 | m->setReplyto(addresslist.first()); | 530 | m->setReplyto(addresslist.first()); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | if (head->env_in_reply_to!=NULL) { | 533 | if (head->env_in_reply_to!=NULL) { |
534 | QString h(head->env_in_reply_to); | 534 | QString h(head->env_in_reply_to); |
535 | while (h.length()>0 && h[0]=='<') { | 535 | while (h.length()>0 && h[0]=='<') { |
536 | h.remove(0,1); | 536 | h.remove(0,1); |
537 | } | 537 | } |
538 | while (h.length()>0 && h[h.length()-1]=='>') { | 538 | while (h.length()>0 && h[h.length()-1]=='>') { |
539 | h.remove(h.length()-1,1); | 539 | h.remove(h.length()-1,1); |
540 | } | 540 | } |
541 | if (h.length()>0) { | 541 | if (h.length()>0) { |
542 | m->setInreply(QStringList(h)); | 542 | m->setInreply(QStringList(h)); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | if (head->env_message_id != NULL) { | 545 | if (head->env_message_id != NULL) { |
546 | m->setMsgid(QString(head->env_message_id)); | 546 | m->setMsgid(QString(head->env_message_id)); |
547 | } | 547 | } |
548 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 548 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
549 | #if 0 | 549 | #if 0 |
550 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 550 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
551 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 551 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
552 | qDebug("time %s ",da.toString().latin1() ); | 552 | qDebug("time %s ",da.toString().latin1() ); |
553 | #endif | 553 | #endif |
554 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 554 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
555 | size = item->att_data.att_static->att_data.att_rfc822_size; | 555 | size = item->att_data.att_static->att_data.att_rfc822_size; |
556 | } | 556 | } |
557 | } | 557 | } |
558 | /* msg is already deleted */ | 558 | /* msg is already deleted */ |
559 | if (mFlags.testBit(FLAG_DELETED) && m) { | 559 | if (mFlags.testBit(FLAG_DELETED) && m) { |
560 | delete m; | 560 | delete m; |
561 | m = 0; | 561 | m = 0; |
562 | } | 562 | } |
563 | if (m) { | 563 | if (m) { |
564 | m->setFlags(mFlags); | 564 | m->setFlags(mFlags); |
565 | m->setMsgsize(size); | 565 | m->setMsgsize(size); |
566 | } | 566 | } |
567 | return m; | 567 | return m; |
568 | } | 568 | } |
569 | 569 | ||
570 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 570 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
571 | { | 571 | { |
572 | RecBodyP body = new RecBody(); | 572 | RecBodyP body = new RecBody(); |
573 | const char *mb; | 573 | const char *mb; |
574 | int err = MAILIMAP_NO_ERROR; | 574 | int err = MAILIMAP_NO_ERROR; |
575 | clist *result = 0; | 575 | clist *result = 0; |
576 | clistcell *current; | 576 | clistcell *current; |
577 | mailimap_fetch_att *fetchAtt = 0; | 577 | mailimap_fetch_att *fetchAtt = 0; |
578 | mailimap_fetch_type *fetchType = 0; | 578 | mailimap_fetch_type *fetchType = 0; |
579 | mailimap_set *set = 0; | 579 | mailimap_set *set = 0; |
580 | mailimap_body*body_desc = 0; | 580 | mailimap_body*body_desc = 0; |
581 | 581 | ||
582 | mb = mail->getMbox().latin1(); | 582 | mb = mail->getMbox().latin1(); |
583 | 583 | ||
584 | login(); | 584 | login(); |
585 | if (!m_imap) { | 585 | if (!m_imap) { |
586 | return body; | 586 | return body; |
587 | } | 587 | } |
588 | err = selectMbox(mail->getMbox()); | 588 | err = selectMbox(mail->getMbox()); |
589 | if ( err != MAILIMAP_NO_ERROR ) { | 589 | if ( err != MAILIMAP_NO_ERROR ) { |
590 | return body; | 590 | return body; |
591 | } | 591 | } |
592 | 592 | ||
593 | /* the range has to start at 1!!! not with 0!!!! */ | 593 | /* the range has to start at 1!!! not with 0!!!! */ |
594 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 594 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
595 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 595 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
596 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 596 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
597 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 597 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
598 | mailimap_set_free( set ); | 598 | mailimap_set_free( set ); |
599 | mailimap_fetch_type_free( fetchType ); | 599 | mailimap_fetch_type_free( fetchType ); |
600 | 600 | ||
601 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 601 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
602 | mailimap_msg_att * msg_att; | 602 | mailimap_msg_att * msg_att; |
603 | msg_att = (mailimap_msg_att*)current->data; | 603 | msg_att = (mailimap_msg_att*)current->data; |
604 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 604 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
605 | QValueList<int> path; | 605 | QValueList<int> path; |
606 | body_desc = item->att_data.att_static->att_data.att_body; | 606 | body_desc = item->att_data.att_static->att_data.att_body; |
607 | traverseBody(mail,body_desc,body,0,path); | 607 | traverseBody(mail,body_desc,body,0,path); |
608 | } else { | 608 | } else { |
609 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 609 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; |
610 | } | 610 | } |
611 | if (result) mailimap_fetch_list_free(result); | 611 | if (result) mailimap_fetch_list_free(result); |
612 | return body; | 612 | return body; |
613 | } | 613 | } |
614 | 614 | ||
615 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 615 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
616 | { | 616 | { |
617 | QStringList l; | 617 | QStringList l; |
618 | QString from; | 618 | QString from; |
619 | bool named_from; | 619 | bool named_from; |
620 | clistcell *current = NULL; | 620 | clistcell *current = NULL; |
621 | mailimap_address * current_address=NULL; | 621 | mailimap_address * current_address=NULL; |
622 | if (!list) { | 622 | if (!list) { |
623 | return l; | 623 | return l; |
624 | } | 624 | } |
625 | unsigned int count = 0; | 625 | unsigned int count = 0; |
626 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 626 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
627 | from = ""; | 627 | from = ""; |
628 | named_from = false; | 628 | named_from = false; |
629 | current_address=(mailimap_address*)current->data; | 629 | current_address=(mailimap_address*)current->data; |
630 | if (current_address->ad_personal_name){ | 630 | if (current_address->ad_personal_name){ |
631 | from+=convert_String((const char*)current_address->ad_personal_name); | 631 | from+=convert_String((const char*)current_address->ad_personal_name); |
632 | from+=" "; | 632 | from+=" "; |
633 | named_from = true; | 633 | named_from = true; |
634 | } | 634 | } |
635 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 635 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
636 | from+="<"; | 636 | from+="<"; |
637 | } | 637 | } |
638 | if (current_address->ad_mailbox_name) { | 638 | if (current_address->ad_mailbox_name) { |
639 | from+=QString(current_address->ad_mailbox_name); | 639 | from+=QString(current_address->ad_mailbox_name); |
640 | from+="@"; | 640 | from+="@"; |
641 | } | 641 | } |
642 | if (current_address->ad_host_name) { | 642 | if (current_address->ad_host_name) { |
643 | from+=QString(current_address->ad_host_name); | 643 | from+=QString(current_address->ad_host_name); |
644 | } | 644 | } |
645 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 645 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
646 | from+=">"; | 646 | from+=">"; |
647 | } | 647 | } |
648 | l.append(QString(from)); | 648 | l.append(QString(from)); |
649 | if (++count > 99) { | 649 | if (++count > 99) { |
650 | break; | 650 | break; |
651 | } | 651 | } |
652 | } | 652 | } |
653 | return l; | 653 | return l; |
654 | } | 654 | } |
655 | 655 | ||
656 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) | 656 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
657 | { | 657 | { |
658 | encodedString*res=new encodedString; | 658 | encodedString*res=new encodedString; |
659 | int err; | 659 | int err; |
660 | mailimap_fetch_type *fetchType; | 660 | mailimap_fetch_type *fetchType; |
661 | mailimap_set *set; | 661 | mailimap_set *set; |
662 | clistcell*current,*cur; | 662 | clistcell*current,*cur; |
663 | mailimap_section_part * section_part = 0; | 663 | mailimap_section_part * section_part = 0; |
664 | mailimap_section_spec * section_spec = 0; | 664 | mailimap_section_spec * section_spec = 0; |
665 | mailimap_section * section = 0; | 665 | mailimap_section * section = 0; |
666 | mailimap_fetch_att * fetch_att = 0; | 666 | mailimap_fetch_att * fetch_att = 0; |
667 | 667 | ||
668 | login(); | 668 | login(); |
669 | if (!m_imap) { | 669 | if (!m_imap) { |
670 | return res; | 670 | return res; |
671 | } | 671 | } |
672 | if (!internal_call) { | 672 | if (!internal_call) { |
673 | err = selectMbox(mail->getMbox()); | 673 | err = selectMbox(mail->getMbox()); |
674 | if ( err != MAILIMAP_NO_ERROR ) { | 674 | if ( err != MAILIMAP_NO_ERROR ) { |
675 | return res; | 675 | return res; |
676 | } | 676 | } |
677 | } | 677 | } |
678 | set = mailimap_set_new_single(mail->getNumber()); | 678 | set = mailimap_set_new_single(mail->getNumber()); |
679 | 679 | ||
680 | clist*id_list = 0; | 680 | clist*id_list = 0; |
681 | 681 | ||
682 | /* if path == empty then its a request for the whole rfc822 mail and generates | 682 | /* if path == empty then its a request for the whole rfc822 mail and generates |
683 | a "fetch <id> (body[])" statement on imap server */ | 683 | a "fetch <id> (body[])" statement on imap server */ |
684 | if (path.count()>0 ) { | 684 | if (path.count()>0 ) { |
685 | id_list = clist_new(); | 685 | id_list = clist_new(); |
686 | for (unsigned j=0; j < path.count();++j) { | 686 | for (unsigned j=0; j < path.count();++j) { |
687 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 687 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
688 | *p_id = path[j]; | 688 | *p_id = path[j]; |
689 | clist_append(id_list,p_id); | 689 | clist_append(id_list,p_id); |
690 | } | 690 | } |
691 | section_part = mailimap_section_part_new(id_list); | 691 | section_part = mailimap_section_part_new(id_list); |
692 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 692 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
693 | } | 693 | } |
694 | 694 | ||
695 | section = mailimap_section_new(section_spec); | 695 | section = mailimap_section_new(section_spec); |
696 | fetch_att = mailimap_fetch_att_new_body_section(section); | 696 | fetch_att = mailimap_fetch_att_new_body_section(section); |
697 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 697 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
698 | 698 | ||
699 | clist*result = 0; | 699 | clist*result = 0; |
700 | 700 | ||
701 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 701 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
702 | mailimap_set_free( set ); | 702 | mailimap_set_free( set ); |
703 | mailimap_fetch_type_free( fetchType ); | 703 | mailimap_fetch_type_free( fetchType ); |
704 | 704 | ||
705 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 705 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
706 | mailimap_msg_att * msg_att; | 706 | mailimap_msg_att * msg_att; |
707 | msg_att = (mailimap_msg_att*)current->data; | 707 | msg_att = (mailimap_msg_att*)current->data; |
708 | mailimap_msg_att_item*msg_att_item; | 708 | mailimap_msg_att_item*msg_att_item; |
709 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 709 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
710 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 710 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
711 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 711 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
712 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 712 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
713 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 713 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
714 | /* detach - we take over the content */ | 714 | /* detach - we take over the content */ |
715 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 715 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
716 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 716 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
717 | } | 717 | } |
718 | } | 718 | } |
719 | } | 719 | } |
720 | } else { | 720 | } else { |
721 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; | 721 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; |
722 | } | 722 | } |
723 | if (result) mailimap_fetch_list_free(result); | 723 | if (result) mailimap_fetch_list_free(result); |
724 | return res; | 724 | return res; |
725 | } | 725 | } |
726 | 726 | ||
727 | /* current_recursion is for recursive calls. | 727 | /* current_recursion is for recursive calls. |
728 | current_count means the position inside the internal loop! */ | 728 | current_count means the position inside the internal loop! */ |
729 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, | 729 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, |
730 | int current_recursion,QValueList<int>recList,int current_count) | 730 | int current_recursion,QValueList<int>recList,int current_count) |
731 | { | 731 | { |
732 | if (!body || current_recursion>=10) { | 732 | if (!body || current_recursion>=10) { |
733 | return; | 733 | return; |
734 | } | 734 | } |
735 | switch (body->bd_type) { | 735 | switch (body->bd_type) { |
736 | case MAILIMAP_BODY_1PART: | 736 | case MAILIMAP_BODY_1PART: |
737 | { | 737 | { |
738 | QValueList<int>countlist = recList; | 738 | QValueList<int>countlist = recList; |
739 | countlist.append(current_count); | 739 | countlist.append(current_count); |
740 | RecPartP currentPart = new RecPart(); | 740 | RecPartP currentPart = new RecPart(); |
741 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 741 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
742 | QString id(""); | 742 | QString id(""); |
743 | currentPart->setPositionlist(countlist); | 743 | currentPart->setPositionlist(countlist); |
744 | for (unsigned int j = 0; j < countlist.count();++j) { | 744 | for (unsigned int j = 0; j < countlist.count();++j) { |
745 | id+=(j>0?" ":""); | 745 | id+=(j>0?" ":""); |
746 | id+=QString("%1").arg(countlist[j]); | 746 | id+=QString("%1").arg(countlist[j]); |
747 | } | 747 | } |
748 | //odebug << "ID = " << id.latin1() << "" << oendl; | 748 | //odebug << "ID = " << id.latin1() << "" << oendl; |
749 | currentPart->setIdentifier(id); | 749 | currentPart->setIdentifier(id); |
750 | fillSinglePart(currentPart,part1); | 750 | fillSinglePart(currentPart,part1); |
751 | /* important: Check for is NULL 'cause a body can be empty! | 751 | /* important: Check for is NULL 'cause a body can be empty! |
752 | And we put it only into the mail if it is the FIRST part */ | 752 | And we put it only into the mail if it is the FIRST part */ |
753 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { | 753 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
754 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); | 754 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
755 | 755 | ||
756 | size_t index = 0; | 756 | size_t index = 0; |
757 | char*res = 0; | 757 | char*res = 0; |
758 | int err = MAILIMF_NO_ERROR; | 758 | int err = MAILIMF_NO_ERROR; |
759 | 759 | ||
760 | QString charset = currentPart->searchParamter( "charset"); | 760 | QString charset = currentPart->searchParamter( "charset"); |
761 | qDebug("CHARSET %s ",charset.latin1() ); | 761 | qDebug("CHARSET %s ",charset.latin1() ); |
762 | //if ( false ) { | 762 | if ( false ) { |
763 | if ( !charset.isEmpty() ) { | 763 | //if ( !charset.isEmpty() ) { |
764 | target_body->setCharset( charset ); | 764 | target_body->setCharset( charset ); |
765 | //err = mailmime_encoded_phrase_parse("iso-8859-1", | 765 | //err = mailmime_encoded_phrase_parse("iso-8859-1", |
766 | // text, strlen(text),&index, "iso-8859-1",&res); | 766 | // text, strlen(text),&index, "iso-8859-1",&res); |
767 | err = mailmime_encoded_phrase_parse(charset.latin1(), | 767 | err = mailmime_encoded_phrase_parse(charset.latin1(), |
768 | body_text.latin1(), body_text.length(),&index, "utf-8",&res); | 768 | body_text.latin1(), body_text.length(),&index, "utf-8",&res); |
769 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 769 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
770 | //qDebug("res %d %s ", index, res); | 770 | //qDebug("res %d %s ", index, res); |
771 | body_text = QString::fromUtf8(res); | 771 | body_text = QString::fromUtf8(res); |
772 | } | 772 | } |
773 | if (res) free(res); | 773 | if (res) free(res); |
774 | } | 774 | } |
775 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); | 775 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); |
776 | target_body->setDescription(currentPart); | 776 | target_body->setDescription(currentPart); |
777 | target_body->setBodytext(body_text); | 777 | target_body->setBodytext(body_text); |
778 | if (countlist.count()>1) { | 778 | if (countlist.count()>1) { |
779 | target_body->addPart(currentPart); | 779 | target_body->addPart(currentPart); |
780 | } | 780 | } |
781 | } else { | 781 | } else { |
782 | target_body->addPart(currentPart); | 782 | target_body->addPart(currentPart); |
783 | } | 783 | } |
784 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 784 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
785 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 785 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
786 | } | 786 | } |
787 | } | 787 | } |
788 | break; | 788 | break; |
789 | case MAILIMAP_BODY_MPART: | 789 | case MAILIMAP_BODY_MPART: |
790 | { | 790 | { |
791 | QValueList<int>countlist = recList; | 791 | QValueList<int>countlist = recList; |
792 | clistcell*current=0; | 792 | clistcell*current=0; |
793 | mailimap_body*current_body=0; | 793 | mailimap_body*current_body=0; |
794 | unsigned int ccount = 1; | 794 | unsigned int ccount = 1; |
795 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 795 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
796 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 796 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
797 | current_body = (mailimap_body*)current->data; | 797 | current_body = (mailimap_body*)current->data; |
798 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 798 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
799 | RecPartP targetPart = new RecPart(); | 799 | RecPartP targetPart = new RecPart(); |
800 | targetPart->setType("multipart"); | 800 | targetPart->setType("multipart"); |
801 | fillMultiPart(targetPart,mailDescription); | 801 | fillMultiPart(targetPart,mailDescription); |
802 | countlist.append(current_count); | 802 | countlist.append(current_count); |
803 | targetPart->setPositionlist(countlist); | 803 | targetPart->setPositionlist(countlist); |
804 | target_body->addPart(targetPart); | 804 | target_body->addPart(targetPart); |
805 | QString id(""); | 805 | QString id(""); |
806 | for (unsigned int j = 0; j < countlist.count();++j) { | 806 | for (unsigned int j = 0; j < countlist.count();++j) { |
807 | id+=(j>0?" ":""); | 807 | id+=(j>0?" ":""); |
808 | id+=QString("%1").arg(countlist[j]); | 808 | id+=QString("%1").arg(countlist[j]); |
809 | } | 809 | } |
810 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; | 810 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; |
811 | } | 811 | } |
812 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 812 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
813 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 813 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
814 | countlist = recList; | 814 | countlist = recList; |
815 | } | 815 | } |
816 | ++ccount; | 816 | ++ccount; |
817 | } | 817 | } |
818 | } | 818 | } |
819 | break; | 819 | break; |
820 | default: | 820 | default: |
821 | break; | 821 | break; |
822 | } | 822 | } |
823 | } | 823 | } |
824 | 824 | ||
825 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) | 825 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) |
826 | { | 826 | { |
827 | if (!Description) { | 827 | if (!Description) { |
828 | return; | 828 | return; |
829 | } | 829 | } |
830 | switch (Description->bd_type) { | 830 | switch (Description->bd_type) { |
831 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 831 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
832 | target_part->setType("text"); | 832 | target_part->setType("text"); |
833 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 833 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
834 | break; | 834 | break; |
835 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 835 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
836 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 836 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
837 | break; | 837 | break; |
838 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 838 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
839 | target_part->setType("message"); | 839 | target_part->setType("message"); |
840 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 840 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
841 | break; | 841 | break; |
842 | default: | 842 | default: |
843 | break; | 843 | break; |
844 | } | 844 | } |
845 | } | 845 | } |
846 | 846 | ||
847 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) | 847 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) |
848 | { | 848 | { |
849 | if (!which) { | 849 | if (!which) { |
850 | return; | 850 | return; |
851 | } | 851 | } |
852 | QString sub; | 852 | QString sub; |
853 | sub = which->bd_media_text; | 853 | sub = which->bd_media_text; |
854 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; | 854 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; |
855 | target_part->setSubtype(sub.lower()); | 855 | target_part->setSubtype(sub.lower()); |
856 | target_part->setLines(which->bd_lines); | 856 | target_part->setLines(which->bd_lines); |
857 | fillBodyFields(target_part,which->bd_fields); | 857 | fillBodyFields(target_part,which->bd_fields); |
858 | } | 858 | } |
859 | 859 | ||
860 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) | 860 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) |
861 | { | 861 | { |
862 | if (!which) { | 862 | if (!which) { |
863 | return; | 863 | return; |
864 | } | 864 | } |
865 | target_part->setSubtype("rfc822"); | 865 | target_part->setSubtype("rfc822"); |
866 | //odebug << "Message part" << oendl; | 866 | //odebug << "Message part" << oendl; |
867 | /* we set this type to text/plain */ | 867 | /* we set this type to text/plain */ |
868 | target_part->setLines(which->bd_lines); | 868 | target_part->setLines(which->bd_lines); |
869 | fillBodyFields(target_part,which->bd_fields); | 869 | fillBodyFields(target_part,which->bd_fields); |
870 | } | 870 | } |
871 | 871 | ||
872 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) | 872 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) |
873 | { | 873 | { |
874 | if (!which) return; | 874 | if (!which) return; |
875 | QString sub = which->bd_media_subtype; | 875 | QString sub = which->bd_media_subtype; |
876 | target_part->setSubtype(sub.lower()); | 876 | target_part->setSubtype(sub.lower()); |
877 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 877 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
878 | clistcell*cur = 0; | 878 | clistcell*cur = 0; |
879 | mailimap_single_body_fld_param*param=0; | 879 | mailimap_single_body_fld_param*param=0; |
880 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 880 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
881 | param = (mailimap_single_body_fld_param*)cur->data; | 881 | param = (mailimap_single_body_fld_param*)cur->data; |
882 | if (param) { | 882 | if (param) { |
883 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 883 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
884 | } | 884 | } |
885 | } | 885 | } |
886 | } | 886 | } |
887 | } | 887 | } |
888 | 888 | ||
889 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) | 889 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) |
890 | { | 890 | { |
891 | if (!which) { | 891 | if (!which) { |
892 | return; | 892 | return; |
893 | } | 893 | } |
894 | QString type,sub; | 894 | QString type,sub; |
895 | switch (which->bd_media_basic->med_type) { | 895 | switch (which->bd_media_basic->med_type) { |
896 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 896 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
897 | type = "application"; | 897 | type = "application"; |
898 | break; | 898 | break; |
899 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 899 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
900 | type = "audio"; | 900 | type = "audio"; |
901 | break; | 901 | break; |
902 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 902 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
903 | type = "image"; | 903 | type = "image"; |
904 | break; | 904 | break; |
905 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 905 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
906 | type = "message"; | 906 | type = "message"; |
907 | break; | 907 | break; |
908 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 908 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
909 | type = "video"; | 909 | type = "video"; |
910 | break; | 910 | break; |
911 | case MAILIMAP_MEDIA_BASIC_OTHER: | 911 | case MAILIMAP_MEDIA_BASIC_OTHER: |
912 | default: | 912 | default: |
913 | if (which->bd_media_basic->med_basic_type) { | 913 | if (which->bd_media_basic->med_basic_type) { |
914 | type = which->bd_media_basic->med_basic_type; | 914 | type = which->bd_media_basic->med_basic_type; |
915 | } else { | 915 | } else { |
916 | type = ""; | 916 | type = ""; |
917 | } | 917 | } |
918 | break; | 918 | break; |
919 | } | 919 | } |
920 | if (which->bd_media_basic->med_subtype) { | 920 | if (which->bd_media_basic->med_subtype) { |
921 | sub = which->bd_media_basic->med_subtype; | 921 | sub = which->bd_media_basic->med_subtype; |
922 | } else { | 922 | } else { |
923 | sub = ""; | 923 | sub = ""; |
924 | } | 924 | } |
925 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; | 925 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; |
926 | target_part->setType(type.lower()); | 926 | target_part->setType(type.lower()); |
927 | target_part->setSubtype(sub.lower()); | 927 | target_part->setSubtype(sub.lower()); |
928 | fillBodyFields(target_part,which->bd_fields); | 928 | fillBodyFields(target_part,which->bd_fields); |
929 | } | 929 | } |
930 | 930 | ||
931 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) | 931 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
932 | { | 932 | { |
933 | if (!which) return; | 933 | if (!which) return; |
934 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 934 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
935 | clistcell*cur; | 935 | clistcell*cur; |
936 | mailimap_single_body_fld_param*param=0; | 936 | mailimap_single_body_fld_param*param=0; |
937 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 937 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
938 | param = (mailimap_single_body_fld_param*)cur->data; | 938 | param = (mailimap_single_body_fld_param*)cur->data; |
939 | if (param) { | 939 | if (param) { |
940 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 940 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
941 | } | 941 | } |
942 | } | 942 | } |
943 | } | 943 | } |
944 | mailimap_body_fld_enc*enc = which->bd_encoding; | 944 | mailimap_body_fld_enc*enc = which->bd_encoding; |
945 | QString encoding(""); | 945 | QString encoding(""); |
946 | switch (enc->enc_type) { | 946 | switch (enc->enc_type) { |
947 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 947 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
948 | encoding = "7bit"; | 948 | encoding = "7bit"; |
949 | break; | 949 | break; |
950 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 950 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
951 | encoding = "8bit"; | 951 | encoding = "8bit"; |
952 | break; | 952 | break; |
953 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 953 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
954 | encoding="binary"; | 954 | encoding="binary"; |
955 | break; | 955 | break; |
956 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 956 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
957 | encoding="base64"; | 957 | encoding="base64"; |
958 | break; | 958 | break; |
959 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 959 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
960 | encoding="quoted-printable"; | 960 | encoding="quoted-printable"; |
961 | break; | 961 | break; |
962 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 962 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
963 | default: | 963 | default: |
964 | if (enc->enc_value) { | 964 | if (enc->enc_value) { |
965 | char*t=enc->enc_value; | 965 | char*t=enc->enc_value; |
966 | encoding=QString(enc->enc_value); | 966 | encoding=QString(enc->enc_value); |
967 | enc->enc_value=0L; | 967 | enc->enc_value=0L; |
968 | free(t); | 968 | free(t); |
969 | } | 969 | } |
970 | } | 970 | } |
971 | if (which->bd_description) { | 971 | if (which->bd_description) { |
972 | target_part->setDescription(QString(which->bd_description)); | 972 | target_part->setDescription(QString(which->bd_description)); |
973 | } | 973 | } |
974 | target_part->setEncoding(encoding); | 974 | target_part->setEncoding(encoding); |
975 | target_part->setSize(which->bd_size); | 975 | target_part->setSize(which->bd_size); |
976 | } | 976 | } |
977 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | 977 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) |
978 | { | 978 | { |
979 | //#if 0 | 979 | //#if 0 |
980 | mailimap_flag_list*flist; | 980 | mailimap_flag_list*flist; |
981 | mailimap_set *set; | 981 | mailimap_set *set; |
982 | mailimap_store_att_flags * store_flags; | 982 | mailimap_store_att_flags * store_flags; |
983 | int err; | 983 | int err; |
984 | login(); | 984 | login(); |
985 | //#endif | 985 | //#endif |
986 | if (!m_imap) { | 986 | if (!m_imap) { |
987 | return; | 987 | return; |
988 | } | 988 | } |
989 | int iii = 0; | 989 | int iii = 0; |
990 | int count = target.count(); | 990 | int count = target.count(); |
991 | // qDebug("imap remove count %d ", count); | 991 | // qDebug("imap remove count %d ", count); |
992 | 992 | ||
993 | 993 | ||
994 | mMax = count; | 994 | mMax = count; |
995 | progress( i18n("Delete")); | 995 | progress( i18n("Delete")); |
996 | 996 | ||
997 | QProgressBar wid ( count ); | 997 | QProgressBar wid ( count ); |
998 | wid.setCaption( i18n("Deleting ...")); | 998 | wid.setCaption( i18n("Deleting ...")); |
999 | wid.show(); | 999 | wid.show(); |
1000 | while (iii < count ) { | 1000 | while (iii < count ) { |
1001 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); | 1001 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
1002 | wid.setProgress( iii ); | 1002 | wid.setProgress( iii ); |
1003 | wid.raise(); | 1003 | wid.raise(); |
1004 | qApp->processEvents(); | 1004 | qApp->processEvents(); |
1005 | RecMailP mail = (*target.at( iii )); | 1005 | RecMailP mail = (*target.at( iii )); |
1006 | //#if 0 | 1006 | //#if 0 |
1007 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | 1007 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); |
1008 | err = selectMbox(mail->getMbox()); | 1008 | err = selectMbox(mail->getMbox()); |
1009 | if ( err != MAILIMAP_NO_ERROR ) { | 1009 | if ( err != MAILIMAP_NO_ERROR ) { |
1010 | return; | 1010 | return; |
1011 | } | 1011 | } |
1012 | flist = mailimap_flag_list_new_empty(); | 1012 | flist = mailimap_flag_list_new_empty(); |
1013 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1013 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1014 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1014 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1015 | set = mailimap_set_new_single(mail->getNumber()); | 1015 | set = mailimap_set_new_single(mail->getNumber()); |
1016 | err = mailimap_store(m_imap,set,store_flags); | 1016 | err = mailimap_store(m_imap,set,store_flags); |
1017 | mailimap_set_free( set ); | 1017 | mailimap_set_free( set ); |
1018 | mailimap_store_att_flags_free(store_flags); | 1018 | mailimap_store_att_flags_free(store_flags); |
1019 | 1019 | ||
1020 | if (err != MAILIMAP_NO_ERROR) { | 1020 | if (err != MAILIMAP_NO_ERROR) { |
1021 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1021 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1022 | return; | 1022 | return; |
1023 | } | 1023 | } |
1024 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1024 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1025 | /* should we realy do that at this moment? */ | 1025 | /* should we realy do that at this moment? */ |
1026 | 1026 | ||
1027 | // err = mailimap_expunge(m_imap); | 1027 | // err = mailimap_expunge(m_imap); |
1028 | //if (err != MAILIMAP_NO_ERROR) { | 1028 | //if (err != MAILIMAP_NO_ERROR) { |
1029 | // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); | 1029 | // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1030 | // } | 1030 | // } |
1031 | //#endif | 1031 | //#endif |
1032 | //deleteMail( mail); | 1032 | //deleteMail( mail); |
1033 | ++iii; | 1033 | ++iii; |
1034 | } | 1034 | } |
1035 | //qDebug("Deleting imap mails... "); | 1035 | //qDebug("Deleting imap mails... "); |
1036 | err = mailimap_expunge(m_imap); | 1036 | err = mailimap_expunge(m_imap); |
1037 | if (err != MAILIMAP_NO_ERROR) { | 1037 | if (err != MAILIMAP_NO_ERROR) { |
1038 | Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); | 1038 | Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1039 | } | 1039 | } |
1040 | } | 1040 | } |
1041 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 1041 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
1042 | { | 1042 | { |
1043 | mailimap_flag_list*flist; | 1043 | mailimap_flag_list*flist; |
1044 | mailimap_set *set; | 1044 | mailimap_set *set; |
1045 | mailimap_store_att_flags * store_flags; | 1045 | mailimap_store_att_flags * store_flags; |
1046 | int err; | 1046 | int err; |
1047 | login(); | 1047 | login(); |
1048 | if (!m_imap) { | 1048 | if (!m_imap) { |
1049 | return; | 1049 | return; |
1050 | } | 1050 | } |
1051 | err = selectMbox(mail->getMbox()); | 1051 | err = selectMbox(mail->getMbox()); |
1052 | if ( err != MAILIMAP_NO_ERROR ) { | 1052 | if ( err != MAILIMAP_NO_ERROR ) { |
1053 | return; | 1053 | return; |
1054 | } | 1054 | } |
1055 | flist = mailimap_flag_list_new_empty(); | 1055 | flist = mailimap_flag_list_new_empty(); |
1056 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1056 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1057 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1057 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1058 | set = mailimap_set_new_single(mail->getNumber()); | 1058 | set = mailimap_set_new_single(mail->getNumber()); |
1059 | err = mailimap_store(m_imap,set,store_flags); | 1059 | err = mailimap_store(m_imap,set,store_flags); |
1060 | mailimap_set_free( set ); | 1060 | mailimap_set_free( set ); |
1061 | mailimap_store_att_flags_free(store_flags); | 1061 | mailimap_store_att_flags_free(store_flags); |
1062 | 1062 | ||
1063 | if (err != MAILIMAP_NO_ERROR) { | 1063 | if (err != MAILIMAP_NO_ERROR) { |
1064 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1064 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1065 | return; | 1065 | return; |
1066 | } | 1066 | } |
1067 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1067 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1068 | /* should we realy do that at this moment? */ | 1068 | /* should we realy do that at this moment? */ |
1069 | 1069 | ||
1070 | err = mailimap_expunge(m_imap); | 1070 | err = mailimap_expunge(m_imap); |
1071 | if (err != MAILIMAP_NO_ERROR) { | 1071 | if (err != MAILIMAP_NO_ERROR) { |
1072 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1072 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1073 | } | 1073 | } |
1074 | //qDebug("IMAPwrapper::deleteMail 2"); | 1074 | //qDebug("IMAPwrapper::deleteMail 2"); |
1075 | 1075 | ||
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 1078 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
1079 | { | 1079 | { |
1080 | mailimap_flag_list*flist; | 1080 | mailimap_flag_list*flist; |
1081 | mailimap_set *set; | 1081 | mailimap_set *set; |
1082 | mailimap_store_att_flags * store_flags; | 1082 | mailimap_store_att_flags * store_flags; |
1083 | int err; | 1083 | int err; |
1084 | login(); | 1084 | login(); |
1085 | if (!m_imap) { | 1085 | if (!m_imap) { |
1086 | return; | 1086 | return; |
1087 | } | 1087 | } |
1088 | err = selectMbox(mail->getMbox()); | 1088 | err = selectMbox(mail->getMbox()); |
1089 | if ( err != MAILIMAP_NO_ERROR ) { | 1089 | if ( err != MAILIMAP_NO_ERROR ) { |
1090 | return; | 1090 | return; |
1091 | } | 1091 | } |
1092 | flist = mailimap_flag_list_new_empty(); | 1092 | flist = mailimap_flag_list_new_empty(); |
1093 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 1093 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
1094 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 1094 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
1095 | set = mailimap_set_new_single(mail->getNumber()); | 1095 | set = mailimap_set_new_single(mail->getNumber()); |
1096 | err = mailimap_store(m_imap,set,store_flags); | 1096 | err = mailimap_store(m_imap,set,store_flags); |
1097 | mailimap_set_free( set ); | 1097 | mailimap_set_free( set ); |
1098 | mailimap_store_att_flags_free(store_flags); | 1098 | mailimap_store_att_flags_free(store_flags); |
1099 | 1099 | ||
1100 | if (err != MAILIMAP_NO_ERROR) { | 1100 | if (err != MAILIMAP_NO_ERROR) { |
1101 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; | 1101 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; |
1102 | return; | 1102 | return; |
1103 | } | 1103 | } |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 1106 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
1107 | { | 1107 | { |
1108 | QString body(""); | 1108 | QString body(""); |
1109 | encodedString*res = fetchRawPart(mail,path,internal_call); | 1109 | encodedString*res = fetchRawPart(mail,path,internal_call); |
1110 | encodedString*r = decode_String(res,enc); | 1110 | encodedString*r = decode_String(res,enc); |
1111 | delete res; | 1111 | delete res; |
1112 | if (r) { | 1112 | if (r) { |
1113 | if (r->Length()>0) { | 1113 | if (r->Length()>0) { |
1114 | body = r->Content(); | 1114 | body = r->Content(); |
1115 | } | 1115 | } |
1116 | delete r; | 1116 | delete r; |
1117 | } | 1117 | } |
1118 | return body; | 1118 | return body; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 1121 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
1122 | { | 1122 | { |
1123 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); | 1123 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); |
1124 | } | 1124 | } |
1125 | 1125 | ||
1126 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) | 1126 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) |
1127 | { | 1127 | { |
1128 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); | 1128 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); |
1129 | encodedString*r = decode_String(res,part->Encoding()); | 1129 | encodedString*r = decode_String(res,part->Encoding()); |
1130 | delete res; | 1130 | delete res; |
1131 | return r; | 1131 | return r; |
1132 | } | 1132 | } |
1133 | 1133 | ||
1134 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) | 1134 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) |
1135 | { | 1135 | { |
1136 | return fetchRawPart(mail,part->Positionlist(),false); | 1136 | return fetchRawPart(mail,part->Positionlist(),false); |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 1139 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
1140 | { | 1140 | { |
1141 | login(); | 1141 | login(); |
1142 | if (!m_imap) { | 1142 | if (!m_imap) { |
1143 | return 0; | 1143 | return 0; |
1144 | } | 1144 | } |
1145 | mailimap_flag_list*flist; | 1145 | mailimap_flag_list*flist; |
1146 | mailimap_set *set; | 1146 | mailimap_set *set; |
1147 | mailimap_store_att_flags * store_flags; | 1147 | mailimap_store_att_flags * store_flags; |
1148 | int err = selectMbox(folder->getName()); | 1148 | int err = selectMbox(folder->getName()); |
1149 | if ( err != MAILIMAP_NO_ERROR ) { | 1149 | if ( err != MAILIMAP_NO_ERROR ) { |
1150 | return 0; | 1150 | return 0; |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | int last = m_imap->imap_selection_info->sel_exists; | 1153 | int last = m_imap->imap_selection_info->sel_exists; |
1154 | if (last == 0) { | 1154 | if (last == 0) { |
1155 | Global::statusMessage(i18n("Mailbox has no mails!")); | 1155 | Global::statusMessage(i18n("Mailbox has no mails!")); |
1156 | return 0; | 1156 | return 0; |
1157 | } | 1157 | } |
1158 | flist = mailimap_flag_list_new_empty(); | 1158 | flist = mailimap_flag_list_new_empty(); |
1159 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1159 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1160 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1160 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1161 | set = mailimap_set_new_interval( 1, last ); | 1161 | set = mailimap_set_new_interval( 1, last ); |
1162 | err = mailimap_store(m_imap,set,store_flags); | 1162 | err = mailimap_store(m_imap,set,store_flags); |
1163 | mailimap_set_free( set ); | 1163 | mailimap_set_free( set ); |
1164 | mailimap_store_att_flags_free(store_flags); | 1164 | mailimap_store_att_flags_free(store_flags); |
1165 | if (err != MAILIMAP_NO_ERROR) { | 1165 | if (err != MAILIMAP_NO_ERROR) { |
1166 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1166 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1167 | return 0; | 1167 | return 0; |
1168 | } | 1168 | } |
1169 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1169 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1170 | /* should we realy do that at this moment? */ | 1170 | /* should we realy do that at this moment? */ |
1171 | err = mailimap_expunge(m_imap); | 1171 | err = mailimap_expunge(m_imap); |
1172 | if (err != MAILIMAP_NO_ERROR) { | 1172 | if (err != MAILIMAP_NO_ERROR) { |
1173 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1173 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1174 | return 0; | 1174 | return 0; |
1175 | } | 1175 | } |
1176 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 1176 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
1177 | return 1; | 1177 | return 1; |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) | 1180 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) |
1181 | { | 1181 | { |
1182 | if (folder.length()==0) return 0; | 1182 | if (folder.length()==0) return 0; |
1183 | login(); | 1183 | login(); |
1184 | if (!m_imap) {return 0;} | 1184 | if (!m_imap) {return 0;} |
1185 | QString pre = account->getPrefix(); | 1185 | QString pre = account->getPrefix(); |
1186 | if (delemiter.length()>0 && pre.findRev(delemiter)!=((int)pre.length())-1) { | 1186 | if (delemiter.length()>0 && pre.findRev(delemiter)!=((int)pre.length())-1) { |
1187 | pre+=delemiter; | 1187 | pre+=delemiter; |
1188 | } | 1188 | } |
1189 | if (parentfolder) { | 1189 | if (parentfolder) { |
1190 | pre += parentfolder->getDisplayName()+delemiter; | 1190 | pre += parentfolder->getDisplayName()+delemiter; |
1191 | } | 1191 | } |
1192 | pre+=folder; | 1192 | pre+=folder; |
1193 | if (getsubfolder) { | 1193 | if (getsubfolder) { |
1194 | if (delemiter.length()>0) { | 1194 | if (delemiter.length()>0) { |
1195 | pre+=delemiter; | 1195 | pre+=delemiter; |
1196 | } else { | 1196 | } else { |
1197 | Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre)); | 1197 | Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre)); |
1198 | return 0; | 1198 | return 0; |
1199 | } | 1199 | } |
1200 | } | 1200 | } |
1201 | // odebug << "Creating " << pre.latin1() << "" << oendl; | 1201 | // odebug << "Creating " << pre.latin1() << "" << oendl; |
1202 | int res = mailimap_create(m_imap,pre.latin1()); | 1202 | int res = mailimap_create(m_imap,pre.latin1()); |
1203 | if (res != MAILIMAP_NO_ERROR) { | 1203 | if (res != MAILIMAP_NO_ERROR) { |
1204 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); | 1204 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); |
1205 | return 0; | 1205 | return 0; |
1206 | } | 1206 | } |
1207 | return 1; | 1207 | return 1; |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | int IMAPwrapper::deleteMbox(const FolderP&folder) | 1210 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1211 | { | 1211 | { |
1212 | if (!folder) return 0; | 1212 | if (!folder) return 0; |
1213 | login(); | 1213 | login(); |
1214 | if (!m_imap) {return 0;} | 1214 | if (!m_imap) {return 0;} |
1215 | int res = mailimap_delete(m_imap,folder->getName()); | 1215 | int res = mailimap_delete(m_imap,folder->getName()); |
1216 | if (res != MAILIMAP_NO_ERROR) { | 1216 | if (res != MAILIMAP_NO_ERROR) { |
1217 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); | 1217 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); |
1218 | return 0; | 1218 | return 0; |
1219 | } | 1219 | } |
1220 | return 1; | 1220 | return 1; |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1223 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1224 | { | 1224 | { |
1225 | mailimap_status_att_list * att_list =0; | 1225 | mailimap_status_att_list * att_list =0; |
1226 | mailimap_mailbox_data_status * status=0; | 1226 | mailimap_mailbox_data_status * status=0; |
1227 | clistiter * cur = 0; | 1227 | clistiter * cur = 0; |
1228 | int r = 0; | 1228 | int r = 0; |
1229 | target_stat.message_count = 0; | 1229 | target_stat.message_count = 0; |
1230 | target_stat.message_unseen = 0; | 1230 | target_stat.message_unseen = 0; |
1231 | target_stat.message_recent = 0; | 1231 | target_stat.message_recent = 0; |
1232 | login(); | 1232 | login(); |
1233 | if (!m_imap) { | 1233 | if (!m_imap) { |
1234 | return; | 1234 | return; |
1235 | } | 1235 | } |
1236 | att_list = mailimap_status_att_list_new_empty(); | 1236 | att_list = mailimap_status_att_list_new_empty(); |
1237 | if (!att_list) return; | 1237 | if (!att_list) return; |
1238 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 1238 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
1239 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 1239 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
1240 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 1240 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
1241 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 1241 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
1242 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { | 1242 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
1243 | for (cur = clist_begin(status->st_info_list); | 1243 | for (cur = clist_begin(status->st_info_list); |
1244 | cur != NULL ; cur = clist_next(cur)) { | 1244 | cur != NULL ; cur = clist_next(cur)) { |
1245 | mailimap_status_info * status_info; | 1245 | mailimap_status_info * status_info; |
1246 | status_info = (mailimap_status_info *)clist_content(cur); | 1246 | status_info = (mailimap_status_info *)clist_content(cur); |
1247 | switch (status_info->st_att) { | 1247 | switch (status_info->st_att) { |
1248 | case MAILIMAP_STATUS_ATT_MESSAGES: | 1248 | case MAILIMAP_STATUS_ATT_MESSAGES: |
1249 | target_stat.message_count = status_info->st_value; | 1249 | target_stat.message_count = status_info->st_value; |
1250 | break; | 1250 | break; |
1251 | case MAILIMAP_STATUS_ATT_RECENT: | 1251 | case MAILIMAP_STATUS_ATT_RECENT: |
1252 | target_stat.message_recent = status_info->st_value; | 1252 | target_stat.message_recent = status_info->st_value; |
1253 | break; | 1253 | break; |
1254 | case MAILIMAP_STATUS_ATT_UNSEEN: | 1254 | case MAILIMAP_STATUS_ATT_UNSEEN: |
1255 | target_stat.message_unseen = status_info->st_value; | 1255 | target_stat.message_unseen = status_info->st_value; |
1256 | break; | 1256 | break; |
1257 | } | 1257 | } |
1258 | } | 1258 | } |
1259 | } else { | 1259 | } else { |
1260 | // odebug << "Error retrieving status" << oendl; | 1260 | // odebug << "Error retrieving status" << oendl; |
1261 | } | 1261 | } |
1262 | if (status) mailimap_mailbox_data_status_free(status); | 1262 | if (status) mailimap_mailbox_data_status_free(status); |
1263 | if (att_list) mailimap_status_att_list_free(att_list); | 1263 | if (att_list) mailimap_status_att_list_free(att_list); |
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1266 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
1267 | { | 1267 | { |
1268 | login(); | 1268 | login(); |
1269 | if (!m_imap) return; | 1269 | if (!m_imap) return; |
1270 | if (!msg) return; | 1270 | if (!msg) return; |
1271 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1271 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1272 | if (r != MAILIMAP_NO_ERROR) { | 1272 | if (r != MAILIMAP_NO_ERROR) { |
1273 | Global::statusMessage("Error storing mail!"); | 1273 | Global::statusMessage("Error storing mail!"); |
1274 | } | 1274 | } |
1275 | } | 1275 | } |
1276 | 1276 | ||
1277 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1277 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1278 | { | 1278 | { |
1279 | return account->getType(); | 1279 | return account->getType(); |
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | const QString&IMAPwrapper::getName()const | 1282 | const QString&IMAPwrapper::getName()const |
1283 | { | 1283 | { |
1284 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1284 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1285 | return account->getAccountName(); | 1285 | return account->getAccountName(); |
1286 | } | 1286 | } |
1287 | 1287 | ||
1288 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1288 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1289 | { | 1289 | { |
1290 | // dummy | 1290 | // dummy |
1291 | QValueList<int> path; | 1291 | QValueList<int> path; |
1292 | return fetchRawPart(mail,path,false); | 1292 | return fetchRawPart(mail,path,false); |
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1295 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1296 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 1296 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
1297 | { | 1297 | { |
1298 | if (targetWrapper != this || maxSizeInKb > 0 ) { | 1298 | if (targetWrapper != this || maxSizeInKb > 0 ) { |
1299 | mMax = 0; | 1299 | mMax = 0; |
1300 | progress( i18n("Copy")); | 1300 | progress( i18n("Copy")); |
1301 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); | 1301 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); |
1302 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); | 1302 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); |
1303 | // odebug << "Using generic" << oendl; | 1303 | // odebug << "Using generic" << oendl; |
1304 | return; | 1304 | return; |
1305 | } | 1305 | } |
1306 | mailimap_set *set = 0; | 1306 | mailimap_set *set = 0; |
1307 | login(); | 1307 | login(); |
1308 | if (!m_imap) { | 1308 | if (!m_imap) { |
1309 | return; | 1309 | return; |
1310 | } | 1310 | } |
1311 | int err = selectMbox(fromFolder->getName()); | 1311 | int err = selectMbox(fromFolder->getName()); |
1312 | if ( err != MAILIMAP_NO_ERROR ) { | 1312 | if ( err != MAILIMAP_NO_ERROR ) { |
1313 | return; | 1313 | return; |
1314 | } | 1314 | } |
1315 | Global::statusMessage( i18n("Copying mails on server...") ); | 1315 | Global::statusMessage( i18n("Copying mails on server...") ); |
1316 | int last = m_imap->imap_selection_info->sel_exists; | 1316 | int last = m_imap->imap_selection_info->sel_exists; |
1317 | set = mailimap_set_new_interval( 1, last ); | 1317 | set = mailimap_set_new_interval( 1, last ); |
1318 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1318 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1319 | mailimap_set_free( set ); | 1319 | mailimap_set_free( set ); |
1320 | if ( err != MAILIMAP_NO_ERROR ) { | 1320 | if ( err != MAILIMAP_NO_ERROR ) { |
1321 | QString error_msg = i18n("Error copy mails: %1").arg(m_imap->imap_response); | 1321 | QString error_msg = i18n("Error copy mails: %1").arg(m_imap->imap_response); |
1322 | Global::statusMessage(error_msg); | 1322 | Global::statusMessage(error_msg); |
1323 | // odebug << error_msg << oendl; | 1323 | // odebug << error_msg << oendl; |
1324 | return; | 1324 | return; |
1325 | } | 1325 | } |
1326 | if (moveit) { | 1326 | if (moveit) { |
1327 | deleteAllMail(fromFolder); | 1327 | deleteAllMail(fromFolder); |
1328 | } | 1328 | } |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1331 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1332 | { | 1332 | { |
1333 | if (targetWrapper != this) { | 1333 | if (targetWrapper != this) { |
1334 | // odebug << "Using generic" << oendl; | 1334 | // odebug << "Using generic" << oendl; |
1335 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1335 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1336 | return; | 1336 | return; |
1337 | } | 1337 | } |
1338 | mailimap_set *set = 0; | 1338 | mailimap_set *set = 0; |
1339 | login(); | 1339 | login(); |
1340 | if (!m_imap) { | 1340 | if (!m_imap) { |
1341 | return; | 1341 | return; |
1342 | } | 1342 | } |
1343 | int err = selectMbox(mail->getMbox()); | 1343 | int err = selectMbox(mail->getMbox()); |
1344 | if ( err != MAILIMAP_NO_ERROR ) { | 1344 | if ( err != MAILIMAP_NO_ERROR ) { |
1345 | return; | 1345 | return; |
1346 | } | 1346 | } |
1347 | set = mailimap_set_new_single(mail->getNumber()); | 1347 | set = mailimap_set_new_single(mail->getNumber()); |
1348 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1348 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1349 | mailimap_set_free( set ); | 1349 | mailimap_set_free( set ); |
1350 | if ( err != MAILIMAP_NO_ERROR ) { | 1350 | if ( err != MAILIMAP_NO_ERROR ) { |
1351 | QString error_msg = i18n("error copy mail: %1").arg(m_imap->imap_response); | 1351 | QString error_msg = i18n("error copy mail: %1").arg(m_imap->imap_response); |
1352 | Global::statusMessage(error_msg); | 1352 | Global::statusMessage(error_msg); |
1353 | // odebug << error_msg << oendl; | 1353 | // odebug << error_msg << oendl; |
1354 | return; | 1354 | return; |
1355 | } | 1355 | } |
1356 | if (moveit) { | 1356 | if (moveit) { |
1357 | deleteMail(mail); | 1357 | deleteMail(mail); |
1358 | } | 1358 | } |
1359 | } | 1359 | } |
diff --git a/kmicromail/libmailwrapper/mailwrapper.h b/kmicromail/libmailwrapper/mailwrapper.h index ea6bf36..3e8b51f 100644 --- a/kmicromail/libmailwrapper/mailwrapper.h +++ b/kmicromail/libmailwrapper/mailwrapper.h | |||
@@ -1,131 +1,131 @@ | |||
1 | #ifndef MAILWRAPPER_H | 1 | #ifndef MAILWRAPPER_H |
2 | #define MAILWRAPPER_H | 2 | #define MAILWRAPPER_H |
3 | 3 | ||
4 | //#include <qpe/applnk.h> | 4 | //#include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qbitarray.h> | 6 | #include <qbitarray.h> |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | #include <qfileinfo.h> | 8 | #include <qfileinfo.h> |
9 | #include <kiconloader.h> | 9 | #include <kiconloader.h> |
10 | 10 | ||
11 | #include "settings.h" | 11 | #include "settings.h" |
12 | 12 | ||
13 | #include <opie2/osmartpointer.h> | 13 | #include <opie2/osmartpointer.h> |
14 | /* | 14 | /* |
15 | class Attachment | 15 | class Attachment |
16 | { | 16 | { |
17 | public: | 17 | public: |
18 | Attachment( DocLnk lnk ); | 18 | Attachment( DocLnk lnk ); |
19 | virtual ~Attachment(){} | 19 | virtual ~Attachment(){} |
20 | const QString getFileName()const{ return doc.file(); } | 20 | const QString getFileName()const{ return doc.file(); } |
21 | const QString getName()const{ return doc.name(); } | 21 | const QString getName()const{ return doc.name(); } |
22 | const QString getMimeType()const{ return doc.type(); } | 22 | const QString getMimeType()const{ return doc.type(); } |
23 | const QPixmap getPixmap()const{ return doc.pixmap(); } | 23 | const QPixmap getPixmap()const{ return doc.pixmap(); } |
24 | const int getSize()const { return size; } | 24 | const int getSize()const { return size; } |
25 | DocLnk getDocLnk() { return doc; } | 25 | DocLnk getDocLnk() { return doc; } |
26 | 26 | ||
27 | protected: | 27 | protected: |
28 | DocLnk doc; | 28 | DocLnk doc; |
29 | int size; | 29 | int size; |
30 | 30 | ||
31 | }; | 31 | }; |
32 | */ | 32 | */ |
33 | 33 | ||
34 | class Attachment | 34 | class Attachment |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | Attachment( QString lnk ); | 37 | Attachment( QString lnk ); |
38 | virtual ~Attachment(){} | 38 | virtual ~Attachment(){} |
39 | const QString getFileName()const{ return doc; } | 39 | const QString getFileName()const{ return doc; } |
40 | const QString getName()const{ return QFileInfo( doc ).baseName (); } | 40 | const QString getName()const{ return QFileInfo( doc ).baseName (); } |
41 | const QString getMimeType()const{ return QFileInfo( doc ).extension(false); } | 41 | const QString getMimeType()const{ return QFileInfo( doc ).extension(false); } |
42 | const QPixmap getPixmap()const{ return mPix; } | 42 | const QPixmap getPixmap()const{ return mPix; } |
43 | const int getSize()const { return size; } | 43 | const int getSize()const { return size; } |
44 | QString getDocLnk() { return doc; } | 44 | QString getDocLnk() { return doc; } |
45 | 45 | ||
46 | protected: | 46 | protected: |
47 | QPixmap mPix; | 47 | QPixmap mPix; |
48 | QString doc; | 48 | QString doc; |
49 | int size; | 49 | int size; |
50 | 50 | ||
51 | }; | 51 | }; |
52 | 52 | ||
53 | class Mail:public Opie::Core::ORefCount | 53 | class Mail:public Opie::Core::ORefCount |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | Mail(); | 56 | Mail(); |
57 | /* Possible that this destructor must not be declared virtual | 57 | /* Possible that this destructor must not be declared virtual |
58 | * 'cause it seems that it will never have some child classes. | 58 | * 'cause it seems that it will never have some child classes. |
59 | * in this case this object will not get a virtual table -> memory and | 59 | * in this case this object will not get a virtual table -> memory and |
60 | * speed will be a little bit better? | 60 | * speed will be a little bit better? |
61 | */ | 61 | */ |
62 | virtual ~Mail(){} | 62 | virtual ~Mail(){} |
63 | void addAttachment( Attachment *att ) { attList.append( att ); } | 63 | void addAttachment( Attachment *att ) { attList.append( att ); } |
64 | const QList<Attachment>& getAttachments()const { return attList; } | 64 | const QList<Attachment>& getAttachments()const { return attList; } |
65 | void removeAttachment( Attachment *att ) { attList.remove( att ); } | 65 | void removeAttachment( Attachment *att ) { attList.remove( att ); } |
66 | const QString&getName()const { return name; } | 66 | const QString&getName()const { return name; } |
67 | void setName( QString s ) { name = s; } | 67 | void setName( QString s ) { name = s; } |
68 | const QString&getMail()const{ return mail; } | 68 | const QString&getMail()const{ return mail; } |
69 | void setMail( const QString&s ) { mail = s; } | 69 | void setMail( const QString&s ) { mail = s; } |
70 | const QString&getTo()const{ return to; } | 70 | const QString&getTo()const{ return to; } |
71 | void setTo( const QString&s ) { to = s; } | 71 | void setTo( const QString&s ) { to = s; } |
72 | const QString&getCC()const{ return cc; } | 72 | const QString&getCC()const{ return cc; } |
73 | void setCC( const QString&s ) { cc = s; } | 73 | void setCC( const QString&s ) { cc = s; } |
74 | const QString&getBCC()const { return bcc; } | 74 | const QString&getBCC()const { return bcc; } |
75 | void setBCC( const QString&s ) { bcc = s; } | 75 | void setBCC( const QString&s ) { bcc = s; } |
76 | const QString&getMessage()const { return message; } | 76 | const QString&getMessage()const { return message; } |
77 | void setMessage( const QString&s ) { message = s; } | 77 | void setMessage( const QString&s ) { message = s; } |
78 | const QString&getSubject()const { return subject; } | 78 | const QString&getSubject()const { return subject; } |
79 | void setSubject( const QString&s ) { subject = s; } | 79 | void setSubject( const QString&s ) { subject = s; } |
80 | const QString&getReply()const{ return reply; } | 80 | const QString&getReply()const{ return reply; } |
81 | void setReply( const QString&a ) { reply = a; } | 81 | void setReply( const QString&a ) { reply = a; } |
82 | void setInreply(const QStringList&list){m_in_reply_to = list;} | 82 | void setInreply(const QStringList&list){m_in_reply_to = list;} |
83 | const QStringList&Inreply()const{return m_in_reply_to;} | 83 | const QStringList&Inreply()const{return m_in_reply_to;} |
84 | 84 | ||
85 | void setCharset( const QString&a ) { charset= a; } | 85 | void setCharset( const QString&a ) { charset= a; } |
86 | const QString& getCharset() { return charset; } | 86 | const QString& getCharset() const { return charset; } |
87 | 87 | ||
88 | private: | 88 | private: |
89 | QList<Attachment> attList; | 89 | QList<Attachment> attList; |
90 | QString name, mail, to, cc, bcc, reply, subject, message, charset; | 90 | QString name, mail, to, cc, bcc, reply, subject, message, charset; |
91 | QStringList m_in_reply_to; | 91 | QStringList m_in_reply_to; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | class Folder:public Opie::Core::ORefCount | 94 | class Folder:public Opie::Core::ORefCount |
95 | { | 95 | { |
96 | public: | 96 | public: |
97 | Folder( const QString&init_name,const QString&sep ); | 97 | Folder( const QString&init_name,const QString&sep ); |
98 | virtual ~Folder(); | 98 | virtual ~Folder(); |
99 | const QString&getDisplayName()const { return nameDisplay; } | 99 | const QString&getDisplayName()const { return nameDisplay; } |
100 | const QString&getName()const { return name; } | 100 | const QString&getName()const { return name; } |
101 | const QString&getPrefix()const{return prefix; } | 101 | const QString&getPrefix()const{return prefix; } |
102 | virtual bool may_select()const{return true;} | 102 | virtual bool may_select()const{return true;} |
103 | virtual bool no_inferior()const{return true;} | 103 | virtual bool no_inferior()const{return true;} |
104 | const QString&Separator()const; | 104 | const QString&Separator()const; |
105 | 105 | ||
106 | protected: | 106 | protected: |
107 | QString nameDisplay, name, separator,prefix; | 107 | QString nameDisplay, name, separator,prefix; |
108 | }; | 108 | }; |
109 | 109 | ||
110 | typedef Opie::Core::OSmartPointer<Folder> FolderP; | 110 | typedef Opie::Core::OSmartPointer<Folder> FolderP; |
111 | 111 | ||
112 | class MHFolder : public Folder | 112 | class MHFolder : public Folder |
113 | { | 113 | { |
114 | public: | 114 | public: |
115 | MHFolder(const QString&disp_name,const QString&mbox); | 115 | MHFolder(const QString&disp_name,const QString&mbox); |
116 | virtual ~MHFolder(); | 116 | virtual ~MHFolder(); |
117 | }; | 117 | }; |
118 | 118 | ||
119 | class IMAPFolder : public Folder | 119 | class IMAPFolder : public Folder |
120 | { | 120 | { |
121 | public: | 121 | public: |
122 | IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); | 122 | IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); |
123 | virtual ~IMAPFolder(); | 123 | virtual ~IMAPFolder(); |
124 | virtual bool may_select()const{return m_MaySelect;} | 124 | virtual bool may_select()const{return m_MaySelect;} |
125 | virtual bool no_inferior()const{return m_NoInferior;} | 125 | virtual bool no_inferior()const{return m_NoInferior;} |
126 | static QString decodeFolderName( const QString &name ); | 126 | static QString decodeFolderName( const QString &name ); |
127 | private: | 127 | private: |
128 | bool m_MaySelect,m_NoInferior; | 128 | bool m_MaySelect,m_NoInferior; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | #endif | 131 | #endif |
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 3013931..8c0a4cb 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp | |||
@@ -1,353 +1,354 @@ | |||
1 | 1 | ||
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qvbox.h> | 4 | #include <qvbox.h> |
5 | #include <qheader.h> | 5 | #include <qheader.h> |
6 | #include <qtimer.h> | 6 | #include <qtimer.h> |
7 | #include <qlayout.h> | 7 | #include <qlayout.h> |
8 | //#include <kdialog.h> | 8 | //#include <kdialog.h> |
9 | #include <kiconloader.h> | 9 | #include <kiconloader.h> |
10 | #include <kapplication.h> | 10 | #include <kapplication.h> |
11 | 11 | ||
12 | #ifdef DESKTOP_VERSION | 12 | #ifdef DESKTOP_VERSION |
13 | #include <qapplication.h> | 13 | #include <qapplication.h> |
14 | #include <qstatusbar.h> | 14 | #include <qstatusbar.h> |
15 | #include <kabc/stdaddressbook.h> | 15 | #include <kabc/stdaddressbook.h> |
16 | extern QStatusBar* globalSstatusBarMainWindow; | 16 | extern QStatusBar* globalSstatusBarMainWindow; |
17 | #else | 17 | #else |
18 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
19 | #endif | 19 | #endif |
20 | #include "defines.h" | 20 | #include "defines.h" |
21 | #include "mainwindow.h" | 21 | #include "mainwindow.h" |
22 | #include <KDGanttMinimizeSplitter.h> | 22 | #include <KDGanttMinimizeSplitter.h> |
23 | 23 | ||
24 | #include "koprefs.h" | 24 | #include "koprefs.h" |
25 | 25 | ||
26 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 26 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
27 | : QMainWindow( parent, name ) //, flags ) | 27 | : QMainWindow( parent, name ) //, flags ) |
28 | { | 28 | { |
29 | #ifdef DESKTOP_VERSION | 29 | #ifdef DESKTOP_VERSION |
30 | globalSstatusBarMainWindow = statusBar(); | 30 | globalSstatusBarMainWindow = statusBar(); |
31 | #endif | 31 | #endif |
32 | setCaption( i18n( "KOpieMail/Pi" ) ); | 32 | setCaption( i18n( "KOpieMail/Pi" ) ); |
33 | setToolBarsMovable( false ); | 33 | setToolBarsMovable( false ); |
34 | //KABC::StdAddressBook::self(); | 34 | //KABC::StdAddressBook::self(); |
35 | toolBar = new QToolBar( this ); | 35 | toolBar = new QToolBar( this ); |
36 | menuBar = new QPEMenuBar( toolBar ); | 36 | menuBar = new QPEMenuBar( toolBar ); |
37 | mailMenu = new QPopupMenu( menuBar ); | 37 | mailMenu = new QPopupMenu( menuBar ); |
38 | menuBar->insertItem( i18n( "Mail" ), mailMenu ); | 38 | menuBar->insertItem( i18n( "Mail" ), mailMenu ); |
39 | settingsMenu = new QPopupMenu( menuBar ); | 39 | settingsMenu = new QPopupMenu( menuBar ); |
40 | menuBar->insertItem( i18n( "Settings" ), settingsMenu ); | 40 | menuBar->insertItem( i18n( "Settings" ), settingsMenu ); |
41 | 41 | ||
42 | addToolBar( toolBar ); | 42 | addToolBar( toolBar ); |
43 | toolBar->setHorizontalStretchable( true ); | 43 | toolBar->setHorizontalStretchable( true ); |
44 | QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), | 44 | QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), |
45 | 0, 0, this ); | 45 | 0, 0, this ); |
46 | connect(getMail, SIGNAL( activated() ), | 46 | connect(getMail, SIGNAL( activated() ), |
47 | SLOT( slotGetAllMail() ) ); | 47 | SLOT( slotGetAllMail() ) ); |
48 | getMail->addTo( mailMenu ); | 48 | getMail->addTo( mailMenu ); |
49 | 49 | ||
50 | getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), | 50 | getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), |
51 | 0, 0, this ); | 51 | 0, 0, this ); |
52 | getMail->addTo( toolBar ); | 52 | getMail->addTo( toolBar ); |
53 | getMail->addTo( mailMenu ); | 53 | getMail->addTo( mailMenu ); |
54 | connect(getMail, SIGNAL( activated() ), | 54 | connect(getMail, SIGNAL( activated() ), |
55 | SLOT( slotGetMail() ) ); | 55 | SLOT( slotGetMail() ) ); |
56 | 56 | ||
57 | composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), | 57 | composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), |
58 | 0, 0, this ); | 58 | 0, 0, this ); |
59 | composeMail->addTo( toolBar ); | 59 | composeMail->addTo( toolBar ); |
60 | composeMail->addTo( mailMenu ); | 60 | composeMail->addTo( mailMenu ); |
61 | 61 | ||
62 | sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , | 62 | sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , |
63 | 0, 0, this ); | 63 | 0, 0, this ); |
64 | sendQueued->addTo( toolBar ); | 64 | sendQueued->addTo( toolBar ); |
65 | sendQueued->addTo( mailMenu ); | 65 | sendQueued->addTo( mailMenu ); |
66 | 66 | ||
67 | /* | 67 | /* |
68 | syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, | 68 | syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, |
69 | 0, 0, this ); | 69 | 0, 0, this ); |
70 | syncFolders->addTo( toolBar ); | 70 | syncFolders->addTo( toolBar ); |
71 | syncFolders->addTo( mailMenu ); | 71 | syncFolders->addTo( mailMenu ); |
72 | */ | 72 | */ |
73 | 73 | ||
74 | showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , | 74 | showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , |
75 | 0, 0, this, 0, true ); | 75 | 0, 0, this, 0, true ); |
76 | showFolders->addTo( toolBar ); | 76 | showFolders->addTo( toolBar ); |
77 | showFolders->addTo( mailMenu ); | 77 | showFolders->addTo( mailMenu ); |
78 | showFolders->setOn( true ); | 78 | showFolders->setOn( true ); |
79 | connect(showFolders, SIGNAL( toggled(bool) ), | 79 | connect(showFolders, SIGNAL( toggled(bool) ), |
80 | SLOT( slotShowFolders(bool) ) ); | 80 | SLOT( slotShowFolders(bool) ) ); |
81 | 81 | ||
82 | /* | 82 | /* |
83 | searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), | 83 | searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), |
84 | 0, 0, this ); | 84 | 0, 0, this ); |
85 | searchMails->addTo( toolBar ); | 85 | searchMails->addTo( toolBar ); |
86 | searchMails->addTo( mailMenu ); | 86 | searchMails->addTo( mailMenu ); |
87 | */ | 87 | */ |
88 | 88 | ||
89 | deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); | 89 | deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); |
90 | deleteMails->addTo( toolBar ); | 90 | deleteMails->addTo( toolBar ); |
91 | deleteMails->addTo( mailMenu ); | 91 | deleteMails->addTo( mailMenu ); |
92 | connect( deleteMails, SIGNAL( activated() ), | 92 | connect( deleteMails, SIGNAL( activated() ), |
93 | SLOT( slotDeleteMail() ) ); | 93 | SLOT( slotDeleteMail() ) ); |
94 | 94 | ||
95 | editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , | 95 | editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , |
96 | 0, 0, this ); | 96 | 0, 0, this ); |
97 | editSettings->addTo( settingsMenu ); | 97 | editSettings->addTo( settingsMenu ); |
98 | connect( editSettings, SIGNAL( activated() ), | 98 | connect( editSettings, SIGNAL( activated() ), |
99 | SLOT( slotEditSettings() ) ); | 99 | SLOT( slotEditSettings() ) ); |
100 | editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , | 100 | editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , |
101 | 0, 0, this ); | 101 | 0, 0, this ); |
102 | editAccounts->addTo( settingsMenu ); | 102 | editAccounts->addTo( settingsMenu ); |
103 | codecMenu = new QPopupMenu( menuBar ); | 103 | codecMenu = new QPopupMenu( menuBar ); |
104 | codecMenu->insertItem( "Western (iso-8859-1)",0,0); | 104 | codecMenu->insertItem( "Western (iso-8859-1)",0,0); |
105 | codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1); | 105 | codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1); |
106 | codecMenu->insertItem( "Western (iso-8859-15)",2,2); | 106 | codecMenu->insertItem( "Western (iso-8859-15)",2,2); |
107 | codecMenu->insertItem( "Chinese (big-5)",3,3); | 107 | codecMenu->insertItem( "Chinese (big-5)",3,3); |
108 | codecMenu->insertItem( "Unicode (utf-8)",4,4); | 108 | codecMenu->insertItem( "Unicode (utf-8)",4,4); |
109 | codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5); | 109 | codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5); |
110 | settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu); | 110 | //disabled |
111 | //settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu); | ||
111 | //setCentralWidget( view ); | 112 | //setCentralWidget( view ); |
112 | 113 | ||
113 | QVBox* wrapperBox = new QVBox( this ); | 114 | QVBox* wrapperBox = new QVBox( this ); |
114 | setCentralWidget( wrapperBox ); | 115 | setCentralWidget( wrapperBox ); |
115 | 116 | ||
116 | // QWidget *view = new QWidget( wrapperBox ); | 117 | // QWidget *view = new QWidget( wrapperBox ); |
117 | KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); | 118 | KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); |
118 | split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); | 119 | split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); |
119 | //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); | 120 | //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); |
120 | 121 | ||
121 | folderView = new AccountView( split ); | 122 | folderView = new AccountView( split ); |
122 | folderView->header()->hide(); | 123 | folderView->header()->hide(); |
123 | folderView->setRootIsDecorated( false ); | 124 | folderView->setRootIsDecorated( false ); |
124 | folderView->addColumn( i18n( "Mailbox" ) ); | 125 | folderView->addColumn( i18n( "Mailbox" ) ); |
125 | 126 | ||
126 | //layout->addWidget( folderView ); | 127 | //layout->addWidget( folderView ); |
127 | 128 | ||
128 | mailView = new QListView( split ); | 129 | mailView = new QListView( split ); |
129 | mailView->addColumn( i18n( " " ) ); | 130 | mailView->addColumn( i18n( " " ) ); |
130 | mailView->addColumn( i18n( "Subject" ),QListView::Manual ); | 131 | mailView->addColumn( i18n( "Subject" ),QListView::Manual ); |
131 | mailView->addColumn( i18n( "Sender" ),QListView::Manual ); | 132 | mailView->addColumn( i18n( "Sender" ),QListView::Manual ); |
132 | mailView->addColumn( i18n( "Size" ),QListView::Manual); | 133 | mailView->addColumn( i18n( "Size" ),QListView::Manual); |
133 | mailView->addColumn( i18n( "Date" ),QListView::Manual); | 134 | mailView->addColumn( i18n( "Date" ),QListView::Manual); |
134 | mailView->setAllColumnsShowFocus(true); | 135 | mailView->setAllColumnsShowFocus(true); |
135 | //mailView->setSorting(-1); | 136 | //mailView->setSorting(-1); |
136 | mailView->setRootIsDecorated( false ); | 137 | mailView->setRootIsDecorated( false ); |
137 | statusWidget = new StatusWidget( wrapperBox ); | 138 | statusWidget = new StatusWidget( wrapperBox ); |
138 | statusWidget->hide(); | 139 | statusWidget->hide(); |
139 | 140 | ||
140 | //layout->addWidget( mailView ); | 141 | //layout->addWidget( mailView ); |
141 | //layout->setStretchFactor( folderView, 1 ); | 142 | //layout->setStretchFactor( folderView, 1 ); |
142 | //layout->setStretchFactor( mailView, 2 ); | 143 | //layout->setStretchFactor( mailView, 2 ); |
143 | 144 | ||
144 | slotAdjustLayout(); | 145 | slotAdjustLayout(); |
145 | #ifndef DESKTOP_VERSION | 146 | #ifndef DESKTOP_VERSION |
146 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); | 147 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
147 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); | 148 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); |
148 | #endif | 149 | #endif |
149 | connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, | 150 | connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, |
150 | SLOT( mailLeftClicked(QListViewItem*) ) ); | 151 | SLOT( mailLeftClicked(QListViewItem*) ) ); |
151 | connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, | 152 | connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, |
152 | SLOT( mailLeftClicked(QListViewItem*) ) ); | 153 | SLOT( mailLeftClicked(QListViewItem*) ) ); |
153 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 154 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
154 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); | 155 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); |
155 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), | 156 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), |
156 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); | 157 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); |
157 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | 158 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); |
158 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | 159 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); |
159 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | 160 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); |
160 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | 161 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); |
161 | //mailView->setMultiSelection ( true ); | 162 | //mailView->setMultiSelection ( true ); |
162 | mailView->setSelectionMode( QListView::Extended ); | 163 | mailView->setSelectionMode( QListView::Extended ); |
163 | QValueList<int> list; | 164 | QValueList<int> list; |
164 | int fw = 100; | 165 | int fw = 100; |
165 | if ( QApplication::desktop()->width() > 320 ) | 166 | if ( QApplication::desktop()->width() > 320 ) |
166 | fw = 50; | 167 | fw = 50; |
167 | list.append( fw ); | 168 | list.append( fw ); |
168 | list.append( 100 ); | 169 | list.append( 100 ); |
169 | split->setSizes( list ); | 170 | split->setSizes( list ); |
170 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 171 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
171 | mailView->setShowSortIndicator ( true ); | 172 | mailView->setShowSortIndicator ( true ); |
172 | QLabel *spacer = new QLabel( toolBar ); | 173 | QLabel *spacer = new QLabel( toolBar ); |
173 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 174 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
174 | toolBar->setStretchableWidget( spacer ); | 175 | toolBar->setStretchableWidget( spacer ); |
175 | 176 | ||
176 | QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); | 177 | QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); |
177 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 178 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
178 | if ( QApplication::desktop()->width() > 320 ) | 179 | if ( QApplication::desktop()->width() > 320 ) |
179 | closeMail->addTo(toolBar); | 180 | closeMail->addTo(toolBar); |
180 | closeMail->addTo(mailMenu); | 181 | closeMail->addTo(mailMenu); |
181 | 182 | ||
182 | 183 | ||
183 | QPopupMenu* helpMenu = new QPopupMenu( menuBar ); | 184 | QPopupMenu* helpMenu = new QPopupMenu( menuBar ); |
184 | menuBar->insertItem( i18n( "Help" ), helpMenu ); | 185 | menuBar->insertItem( i18n( "Help" ), helpMenu ); |
185 | QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); | 186 | QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); |
186 | connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); | 187 | connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); |
187 | li->addTo(helpMenu); | 188 | li->addTo(helpMenu); |
188 | li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); | 189 | li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); |
189 | connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); | 190 | connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); |
190 | li->addTo(helpMenu); | 191 | li->addTo(helpMenu); |
191 | li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); | 192 | li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); |
192 | connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); | 193 | connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); |
193 | li->addTo(helpMenu); | 194 | li->addTo(helpMenu); |
194 | connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) ); | 195 | connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) ); |
195 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 196 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
196 | #ifdef DESKTOP_VERSION | 197 | #ifdef DESKTOP_VERSION |
197 | resize ( 640, 480 ); | 198 | resize ( 640, 480 ); |
198 | #endif | 199 | #endif |
199 | } | 200 | } |
200 | 201 | ||
201 | MainWindow::~MainWindow() | 202 | MainWindow::~MainWindow() |
202 | { | 203 | { |
203 | } | 204 | } |
204 | 205 | ||
205 | void MainWindow::slotSetCodec( int codec ) | 206 | void MainWindow::slotSetCodec( int codec ) |
206 | { | 207 | { |
207 | codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false ); | 208 | codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false ); |
208 | //qDebug("codec %d ", codec); | 209 | //qDebug("codec %d ", codec); |
209 | KOPrefs::instance()->mCurrentCodec = codec; | 210 | KOPrefs::instance()->mCurrentCodec = codec; |
210 | KOPrefs::instance()->isDirty = true; | 211 | KOPrefs::instance()->isDirty = true; |
211 | QString name; | 212 | QString name; |
212 | switch ( codec ) { | 213 | switch ( codec ) { |
213 | case 0: | 214 | case 0: |
214 | name = "iso-8859-1"; | 215 | name = "iso-8859-1"; |
215 | break; | 216 | break; |
216 | case 1: | 217 | case 1: |
217 | name = "iso-8859-5"; | 218 | name = "iso-8859-5"; |
218 | break; | 219 | break; |
219 | case 2: | 220 | case 2: |
220 | name = "iso-8859-15"; | 221 | name = "iso-8859-15"; |
221 | break; | 222 | break; |
222 | case 3: | 223 | case 3: |
223 | name = "big-5"; | 224 | name = "big-5"; |
224 | break; | 225 | break; |
225 | case 4: | 226 | case 4: |
226 | name = "utf-8"; | 227 | name = "utf-8"; |
227 | break; | 228 | break; |
228 | case 5: | 229 | case 5: |
229 | name = KOPrefs::instance()->mSendCodec.lower(); | 230 | name = KOPrefs::instance()->mSendCodec.lower(); |
230 | break; | 231 | break; |
231 | } | 232 | } |
232 | KOPrefs::instance()->mCurrentCodeName = name ; | 233 | KOPrefs::instance()->mCurrentCodeName = name ; |
233 | codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")"); | 234 | codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")"); |
234 | codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true ); | 235 | codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true ); |
235 | } | 236 | } |
236 | void MainWindow::showLicence() | 237 | void MainWindow::showLicence() |
237 | { | 238 | { |
238 | KApplication::showLicence(); | 239 | KApplication::showLicence(); |
239 | } | 240 | } |
240 | void MainWindow::showAbout() | 241 | void MainWindow::showAbout() |
241 | { | 242 | { |
242 | QString version; | 243 | QString version; |
243 | #include <../version> | 244 | #include <../version> |
244 | 245 | ||
245 | QString cap = "About KOpieMail/Pi"; | 246 | QString cap = "About KOpieMail/Pi"; |
246 | QString text =i18n("KOpieMail/Platform-independent\n") + | 247 | QString text =i18n("KOpieMail/Platform-independent\n") + |
247 | "(OM/Pi) " + version + " - " | 248 | "(OM/Pi) " + version + " - " |
248 | 249 | ||
249 | #ifdef DESKTOP_VERSION | 250 | #ifdef DESKTOP_VERSION |
250 | "Desktop Edition\n" | 251 | "Desktop Edition\n" |
251 | #else | 252 | #else |
252 | "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" | 253 | "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" |
253 | #endif | 254 | #endif |
254 | "www.pi-sync.net\n\n" | 255 | "www.pi-sync.net\n\n" |
255 | 256 | ||
256 | 257 | ||
257 | 258 | ||
258 | "Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" | 259 | "Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" |
259 | "KOpieMail/Pi is based on Opie Mail\n" | 260 | "KOpieMail/Pi is based on Opie Mail\n" |
260 | "Copyright (c) Rajko Albrecht and the Opie team\n" | 261 | "Copyright (c) Rajko Albrecht and the Opie team\n" |
261 | "KOpieMail/Pi is licensed under the GPL\n" | 262 | "KOpieMail/Pi is licensed under the GPL\n" |
262 | "\n" | 263 | "\n" |
263 | "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" | 264 | "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" |
264 | "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" | 265 | "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" |
265 | "libEtPan has its own licence - see LibEtPan licence\n"; | 266 | "libEtPan has its own licence - see LibEtPan licence\n"; |
266 | 267 | ||
267 | KApplication::showText( cap, text ); | 268 | KApplication::showText( cap, text ); |
268 | } | 269 | } |
269 | void MainWindow::showEtpanLicence() | 270 | void MainWindow::showEtpanLicence() |
270 | { | 271 | { |
271 | KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); | 272 | KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); |
272 | 273 | ||
273 | } | 274 | } |
274 | void MainWindow::appMessage(const QCString &, const QByteArray &) | 275 | void MainWindow::appMessage(const QCString &, const QByteArray &) |
275 | { | 276 | { |
276 | qDebug("appMessage implemented by subclass"); | 277 | qDebug("appMessage implemented by subclass"); |
277 | } | 278 | } |
278 | 279 | ||
279 | void MainWindow::slotAdjustLayout() { | 280 | void MainWindow::slotAdjustLayout() { |
280 | 281 | ||
281 | /* | 282 | /* |
282 | QWidget *d = QApplication::desktop(); | 283 | QWidget *d = QApplication::desktop(); |
283 | 284 | ||
284 | if ( d->width() < d->height() ) { | 285 | if ( d->width() < d->height() ) { |
285 | layout->setDirection( QBoxLayout::TopToBottom ); | 286 | layout->setDirection( QBoxLayout::TopToBottom ); |
286 | } else { | 287 | } else { |
287 | layout->setDirection( QBoxLayout::LeftToRight ); | 288 | layout->setDirection( QBoxLayout::LeftToRight ); |
288 | } | 289 | } |
289 | */ | 290 | */ |
290 | } | 291 | } |
291 | 292 | ||
292 | void MainWindow::slotAdjustColumns() | 293 | void MainWindow::slotAdjustColumns() |
293 | { | 294 | { |
294 | bool hidden = folderView->isHidden(); | 295 | bool hidden = folderView->isHidden(); |
295 | if ( hidden ) folderView->show(); | 296 | if ( hidden ) folderView->show(); |
296 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 297 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
297 | if ( hidden ) folderView->hide(); | 298 | if ( hidden ) folderView->hide(); |
298 | 299 | ||
299 | mailView->setColumnWidth( 0, 10 ); | 300 | mailView->setColumnWidth( 0, 10 ); |
300 | mailView->setColumnWidth( 1, 100 ); | 301 | mailView->setColumnWidth( 1, 100 ); |
301 | mailView->setColumnWidth( 2, 100 ); | 302 | mailView->setColumnWidth( 2, 100 ); |
302 | mailView->setColumnWidth( 3, 50 ); | 303 | mailView->setColumnWidth( 3, 50 ); |
303 | mailView->setColumnWidth( 4, 120 ); | 304 | mailView->setColumnWidth( 4, 120 ); |
304 | } | 305 | } |
305 | 306 | ||
306 | void MainWindow::slotEditSettings() | 307 | void MainWindow::slotEditSettings() |
307 | { | 308 | { |
308 | } | 309 | } |
309 | 310 | ||
310 | void MainWindow::slotShowFolders( bool ) | 311 | void MainWindow::slotShowFolders( bool ) |
311 | { | 312 | { |
312 | qDebug("not implemented: "); | 313 | qDebug("not implemented: "); |
313 | } | 314 | } |
314 | 315 | ||
315 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) | 316 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) |
316 | { | 317 | { |
317 | qDebug("not implemented: "); | 318 | qDebug("not implemented: "); |
318 | } | 319 | } |
319 | 320 | ||
320 | void MainWindow::mailLeftClicked(QListViewItem * ) | 321 | void MainWindow::mailLeftClicked(QListViewItem * ) |
321 | { | 322 | { |
322 | qDebug("not implemented: "); | 323 | qDebug("not implemented: "); |
323 | } | 324 | } |
324 | 325 | ||
325 | void MainWindow::displayMail() | 326 | void MainWindow::displayMail() |
326 | { | 327 | { |
327 | qDebug("not implemented: "); | 328 | qDebug("not implemented: "); |
328 | } | 329 | } |
329 | 330 | ||
330 | void MainWindow::slotDeleteMail() | 331 | void MainWindow::slotDeleteMail() |
331 | { | 332 | { |
332 | qDebug("not implemented: "); | 333 | qDebug("not implemented: "); |
333 | } | 334 | } |
334 | 335 | ||
335 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) | 336 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) |
336 | { | 337 | { |
337 | qDebug("not implemented: "); | 338 | qDebug("not implemented: "); |
338 | } | 339 | } |
339 | 340 | ||
340 | void MainWindow::slotSendQueued() | 341 | void MainWindow::slotSendQueued() |
341 | { | 342 | { |
342 | qDebug("not implemented: "); | 343 | qDebug("not implemented: "); |
343 | } | 344 | } |
344 | 345 | ||
345 | void MainWindow::slotEditAccounts() | 346 | void MainWindow::slotEditAccounts() |
346 | { | 347 | { |
347 | qDebug("not implemented: "); | 348 | qDebug("not implemented: "); |
348 | } | 349 | } |
349 | 350 | ||
350 | void MainWindow::slotComposeMail() | 351 | void MainWindow::slotComposeMail() |
351 | { | 352 | { |
352 | qDebug("not implemented: "); | 353 | qDebug("not implemented: "); |
353 | } | 354 | } |
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index 1da1e99..d7e384c 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp | |||
@@ -1,1084 +1,1085 @@ | |||
1 | #include <qregexp.h> | 1 | #include <qregexp.h> |
2 | #include <qapplication.h> | 2 | #include <qapplication.h> |
3 | 3 | ||
4 | #include "kdebug.h" | 4 | #include "kdebug.h" |
5 | #include "kcalendarsystemgregorian.h" | 5 | #include "kcalendarsystemgregorian.h" |
6 | 6 | ||
7 | #include "klocale.h" | 7 | #include "klocale.h" |
8 | 8 | ||
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | 10 | ||
11 | //#define COLLECT_TRANSLATION | 11 | //#define COLLECT_TRANSLATION |
12 | 12 | ||
13 | 13 | ||
14 | QDict<QString> *mLocaleDict = 0; | 14 | QDict<QString> *mLocaleDict = 0; |
15 | void setLocaleDict( QDict<QString> * dict ) | 15 | void setLocaleDict( QDict<QString> * dict ) |
16 | { | 16 | { |
17 | mLocaleDict = dict; | 17 | mLocaleDict = dict; |
18 | 18 | ||
19 | } | 19 | } |
20 | 20 | ||
21 | #ifdef COLLECT_TRANSLATION | 21 | #ifdef COLLECT_TRANSLATION |
22 | 22 | ||
23 | QStringList missingTrans; | 23 | QStringList missingTrans; |
24 | QStringList existingTrans1; | 24 | QStringList existingTrans1; |
25 | QStringList existingTrans2; | 25 | QStringList existingTrans2; |
26 | 26 | ||
27 | void addMissing(const char *text) | 27 | void addMissing(const char *text) |
28 | { | 28 | { |
29 | 29 | ||
30 | QString mis ( text ); | 30 | QString mis ( text ); |
31 | if ( !missingTrans.contains( mis ) ) | 31 | if ( !missingTrans.contains( mis ) ) |
32 | missingTrans.append(mis); | 32 | missingTrans.append(mis); |
33 | 33 | ||
34 | } | 34 | } |
35 | void addExist(const char *text,QString trans ) | 35 | void addExist(const char *text,QString trans ) |
36 | { | 36 | { |
37 | //return; | 37 | //return; |
38 | QString mis ( text ); | 38 | QString mis ( text ); |
39 | if ( !existingTrans1.contains( mis ) ) { | 39 | if ( !existingTrans1.contains( mis ) ) { |
40 | existingTrans1.append(mis); | 40 | existingTrans1.append(mis); |
41 | existingTrans2.append(trans); | 41 | existingTrans2.append(trans); |
42 | 42 | ||
43 | } | 43 | } |
44 | 44 | ||
45 | } | 45 | } |
46 | 46 | ||
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qtextstream.h> | 48 | #include <qtextstream.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #endif | 50 | #endif |
51 | void dumpMissing() | 51 | void dumpMissing() |
52 | { | 52 | { |
53 | #ifdef COLLECT_TRANSLATION | 53 | #ifdef COLLECT_TRANSLATION |
54 | QString fileName = "/tmp/usernewtrans.txt"; | 54 | QString fileName = "/tmp/usernewtrans.txt"; |
55 | QFile file( fileName ); | 55 | QFile file( fileName ); |
56 | if (!file.open( IO_WriteOnly ) ) { | 56 | if (!file.open( IO_WriteOnly ) ) { |
57 | return ; | 57 | return ; |
58 | } | 58 | } |
59 | QTextStream ts( &file ); | 59 | QTextStream ts( &file ); |
60 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 60 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
61 | 61 | ||
62 | int i; | 62 | int i; |
63 | for ( i = 0; i< missingTrans.count(); ++i ) { | 63 | for ( i = 0; i< missingTrans.count(); ++i ) { |
64 | 64 | ||
65 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); | 65 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); |
66 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; | 66 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; |
67 | 67 | ||
68 | } | 68 | } |
69 | file.close(); | 69 | file.close(); |
70 | { | 70 | { |
71 | QString fileName = "/tmp/usertrans.txt"; | 71 | QString fileName = "/tmp/usertrans.txt"; |
72 | QFile file( fileName ); | 72 | QFile file( fileName ); |
73 | if (!file.open( IO_WriteOnly ) ) { | 73 | if (!file.open( IO_WriteOnly ) ) { |
74 | return ; | 74 | return ; |
75 | } | 75 | } |
76 | QTextStream ts( &file ); | 76 | QTextStream ts( &file ); |
77 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 77 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
78 | 78 | ||
79 | int i; | 79 | int i; |
80 | for ( i = 0; i< existingTrans1.count(); ++i ) { | 80 | for ( i = 0; i< existingTrans1.count(); ++i ) { |
81 | 81 | ||
82 | QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" ); | 82 | QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" ); |
83 | QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" ); | 83 | QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" ); |
84 | ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n"; | 84 | ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n"; |
85 | 85 | ||
86 | } | 86 | } |
87 | file.close(); | 87 | file.close(); |
88 | } | 88 | } |
89 | #endif | 89 | #endif |
90 | } | 90 | } |
91 | QString i18n(const char *text) | 91 | QString i18n(const char *text) |
92 | { | 92 | { |
93 | if ( ! mLocaleDict ) { | 93 | if ( ! mLocaleDict ) { |
94 | #ifdef COLLECT_TRANSLATION | 94 | #ifdef COLLECT_TRANSLATION |
95 | addMissing( text ); | 95 | addMissing( text ); |
96 | #endif | 96 | #endif |
97 | return QString( text ); | 97 | return QString( text ); |
98 | } | 98 | } |
99 | else { | 99 | else { |
100 | QString* ret = mLocaleDict->find(QString(text)) ; | 100 | QString* ret = mLocaleDict->find(QString(text)) ; |
101 | if ( ret == 0 ) { | 101 | if ( ret == 0 ) { |
102 | #ifdef COLLECT_TRANSLATION | 102 | #ifdef COLLECT_TRANSLATION |
103 | addMissing( text ); | 103 | addMissing( text ); |
104 | #endif | 104 | #endif |
105 | return QString( text ); | 105 | return QString( text ); |
106 | } | 106 | } |
107 | else { | 107 | else { |
108 | if ( (*ret).isEmpty() ) { | 108 | if ( (*ret).isEmpty() ) { |
109 | #ifdef COLLECT_TRANSLATION | 109 | #ifdef COLLECT_TRANSLATION |
110 | addMissing( text ); | 110 | addMissing( text ); |
111 | #endif | 111 | #endif |
112 | return QString( text ); | 112 | return QString( text ); |
113 | } | 113 | } |
114 | else { | 114 | else { |
115 | #ifdef COLLECT_TRANSLATION | 115 | #ifdef COLLECT_TRANSLATION |
116 | addExist( text, *ret ); | 116 | addExist( text, *ret ); |
117 | #endif | 117 | #endif |
118 | return (*ret); | 118 | return (*ret); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | } | 123 | } |
124 | 124 | ||
125 | QString i18n(const char *,const char *text) | 125 | QString i18n(const char *,const char *text) |
126 | { | 126 | { |
127 | return i18n( text ); | 127 | return i18n( text ); |
128 | } | 128 | } |
129 | 129 | ||
130 | QString i18n(const char *text1, const char *textn, int num) | 130 | QString i18n(const char *text1, const char *textn, int num) |
131 | { | 131 | { |
132 | if ( num == 1 ) return i18n( text1 ); | 132 | if ( num == 1 ) return i18n( text1 ); |
133 | else { | 133 | else { |
134 | QString text = i18n( textn ); | 134 | QString text = i18n( textn ); |
135 | int pos = text.find( "%n" ); | 135 | int pos = text.find( "%n" ); |
136 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); | 136 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); |
137 | return text; | 137 | return text; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) | 141 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) |
142 | { | 142 | { |
143 | for ( uint l = 0; l < s.length(); l++ ) | 143 | for ( uint l = 0; l < s.length(); l++ ) |
144 | buffer[index++] = s.at( l ); | 144 | buffer[index++] = s.at( l ); |
145 | } | 145 | } |
146 | 146 | ||
147 | inline void put_it_in( QChar *buffer, uint& index, int number ) | 147 | inline void put_it_in( QChar *buffer, uint& index, int number ) |
148 | { | 148 | { |
149 | buffer[index++] = number / 10 + '0'; | 149 | buffer[index++] = number / 10 + '0'; |
150 | buffer[index++] = number % 10 + '0'; | 150 | buffer[index++] = number % 10 + '0'; |
151 | } | 151 | } |
152 | 152 | ||
153 | static int readInt(const QString &str, uint &pos) | 153 | static int readInt(const QString &str, uint &pos) |
154 | { | 154 | { |
155 | if (!str.at(pos).isDigit()) return -1; | 155 | if (!str.at(pos).isDigit()) return -1; |
156 | int result = 0; | 156 | int result = 0; |
157 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) | 157 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) |
158 | { | 158 | { |
159 | result *= 10; | 159 | result *= 10; |
160 | result += str.at(pos).digitValue(); | 160 | result += str.at(pos).digitValue(); |
161 | } | 161 | } |
162 | 162 | ||
163 | return result; | 163 | return result; |
164 | } | 164 | } |
165 | 165 | ||
166 | KLocale::KLocale() : mCalendarSystem( 0 ) | 166 | KLocale::KLocale() : mCalendarSystem( 0 ) |
167 | { | 167 | { |
168 | 168 | ||
169 | m_decimalSymbol = "."; | 169 | m_decimalSymbol = "."; |
170 | m_positiveSign = ""; | 170 | m_positiveSign = ""; |
171 | m_negativeSign = "-"; | 171 | m_negativeSign = "-"; |
172 | m_thousandsSeparator = ","; | 172 | m_thousandsSeparator = ","; |
173 | 173 | ||
174 | 174 | ||
175 | 175 | ||
176 | 176 | ||
177 | mWeekStartsMonday = true; | 177 | mWeekStartsMonday = true; |
178 | mHourF24Format = true; | 178 | mHourF24Format = true; |
179 | mIntDateFormat = Default; | 179 | mIntDateFormat = Default; |
180 | mIntTimeFormat = Default; | 180 | mIntTimeFormat = Default; |
181 | mLanguage = 0; | 181 | mLanguage = 0; |
182 | mDateFormat = "%a %Y %b %d"; | 182 | mDateFormat = "%a %Y %b %d"; |
183 | mDateFormatShort = "%Y-%m-%d"; | 183 | mDateFormatShort = "%Y-%m-%d"; |
184 | mTimeZoneList << ("-11:00 US/Samoa") | 184 | mTimeZoneList << ("-11:00 US/Samoa") |
185 | << ("-10:00 US/Hawaii") | 185 | << ("-10:00 US/Hawaii") |
186 | << ("-09:00 US/Alaska") | 186 | << ("-09:00 US/Alaska") |
187 | << ("-08:00 US/Pacific") | 187 | << ("-08:00 US/Pacific") |
188 | << ("-07:00 US/Mountain") | 188 | << ("-07:00 US/Mountain") |
189 | << ("-06:00 US/Central") | 189 | << ("-06:00 US/Central") |
190 | << ("-05:00 US/Eastern") | 190 | << ("-05:00 US/Eastern") |
191 | << ("-04:00 Brazil/West") | 191 | << ("-04:00 Brazil/West") |
192 | << ("-03:00 Brazil/East") | 192 | << ("-03:00 Brazil/East") |
193 | << ("-02:00 Brazil/DeNoronha") | 193 | << ("-02:00 Brazil/DeNoronha") |
194 | << ("-01:00 Atlantic/Azores") | 194 | << ("-01:00 Atlantic/Azores") |
195 | << (" 00:00 Europe/London(UTC)") | 195 | << (" 00:00 Europe/London(UTC)") |
196 | << ("+01:00 Europe/Oslo(CET)") | 196 | << ("+01:00 Europe/Oslo(CET)") |
197 | << ("+02:00 Europe/Helsinki") | 197 | << ("+02:00 Europe/Helsinki") |
198 | << ("+03:00 Europe/Moscow") | 198 | << ("+03:00 Europe/Moscow") |
199 | << ("+04:00 Indian/Mauritius") | 199 | << ("+04:00 Indian/Mauritius") |
200 | << ("+05:00 Indian/Maldives") | 200 | << ("+05:00 Indian/Maldives") |
201 | << ("+06:00 Indian/Chagos") | 201 | << ("+06:00 Indian/Chagos") |
202 | << ("+07:00 Asia/Bangkok") | 202 | << ("+07:00 Asia/Bangkok") |
203 | << ("+08:00 Asia/Hongkong") | 203 | << ("+08:00 Asia/Hongkong") |
204 | << ("+09:00 Asia/Tokyo") | 204 | << ("+09:00 Asia/Tokyo") |
205 | << ("+10:00 Asia/Vladivostok") | 205 | << ("+10:00 Asia/Vladivostok") |
206 | << ("+11:00 Asia/Magadan") | 206 | << ("+11:00 Asia/Magadan") |
207 | << ("+12:00 Asia/Kamchatka") | 207 | << ("+12:00 Asia/Kamchatka") |
208 | // << (" xx:xx User defined offset") | 208 | // << (" xx:xx User defined offset") |
209 | << i18n (" Local Time"); | 209 | << i18n (" Local Time"); |
210 | mSouthDaylight = false; | 210 | mSouthDaylight = false; |
211 | mTimeZoneOffset = 0; | 211 | mTimeZoneOffset = 0; |
212 | daylightEnabled = false; | 212 | daylightEnabled = false; |
213 | } | 213 | } |
214 | 214 | ||
215 | void KLocale::setDateFormat( QString s ) | 215 | void KLocale::setDateFormat( QString s ) |
216 | { | 216 | { |
217 | mDateFormat = s; | 217 | mDateFormat = s; |
218 | } | 218 | } |
219 | 219 | ||
220 | void KLocale::setDateFormatShort( QString s ) | 220 | void KLocale::setDateFormatShort( QString s ) |
221 | { | 221 | { |
222 | mDateFormatShort = s; | 222 | mDateFormatShort = s; |
223 | } | 223 | } |
224 | 224 | ||
225 | void KLocale::setHore24Format ( bool b ) | 225 | void KLocale::setHore24Format ( bool b ) |
226 | { | 226 | { |
227 | mHourF24Format = b; | 227 | mHourF24Format = b; |
228 | } | 228 | } |
229 | void KLocale::setWeekStartMonday( bool b ) | 229 | void KLocale::setWeekStartMonday( bool b ) |
230 | { | 230 | { |
231 | mWeekStartsMonday = b; | 231 | mWeekStartsMonday = b; |
232 | } | 232 | } |
233 | 233 | ||
234 | KLocale::IntDateFormat KLocale::getIntDateFormat( ) | 234 | KLocale::IntDateFormat KLocale::getIntDateFormat( ) |
235 | { | 235 | { |
236 | return mIntDateFormat; | 236 | return mIntDateFormat; |
237 | 237 | ||
238 | } | 238 | } |
239 | void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) | 239 | void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) |
240 | { | 240 | { |
241 | mIntDateFormat = i; | 241 | mIntDateFormat = i; |
242 | } | 242 | } |
243 | KLocale::IntDateFormat KLocale::getIntTimeFormat( ) | 243 | KLocale::IntDateFormat KLocale::getIntTimeFormat( ) |
244 | { | 244 | { |
245 | return mIntTimeFormat; | 245 | return mIntTimeFormat; |
246 | 246 | ||
247 | } | 247 | } |
248 | void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) | 248 | void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) |
249 | { | 249 | { |
250 | mIntTimeFormat = i; | 250 | mIntTimeFormat = i; |
251 | } | 251 | } |
252 | 252 | ||
253 | void KLocale::setLanguage( int i ) | 253 | void KLocale::setLanguage( int i ) |
254 | { | 254 | { |
255 | mLanguage = i; | 255 | mLanguage = i; |
256 | } | 256 | } |
257 | int KLocale::language( ) | 257 | int KLocale::language( ) |
258 | { | 258 | { |
259 | return mLanguage; | 259 | return mLanguage; |
260 | } | 260 | } |
261 | QString KLocale::translate( const char *index ) const | 261 | QString KLocale::translate( const char *index ) const |
262 | { | 262 | { |
263 | return i18n( index ); | 263 | return i18n( index ); |
264 | } | 264 | } |
265 | 265 | ||
266 | QString KLocale::translate( const char *, const char *fallback) const | 266 | QString KLocale::translate( const char *, const char *fallback) const |
267 | { | 267 | { |
268 | return i18n( fallback ); | 268 | return i18n( fallback ); |
269 | } | 269 | } |
270 | 270 | ||
271 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const | 271 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const |
272 | { | 272 | { |
273 | const QString rst = timeFormat(intIntDateFormat); | 273 | const QString rst = timeFormat(intIntDateFormat); |
274 | 274 | ||
275 | // only "pm/am" here can grow, the rest shrinks, but | 275 | // only "pm/am" here can grow, the rest shrinks, but |
276 | // I'm rather safe than sorry | 276 | // I'm rather safe than sorry |
277 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; | 277 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; |
278 | 278 | ||
279 | uint index = 0; | 279 | uint index = 0; |
280 | bool escape = false; | 280 | bool escape = false; |
281 | int number = 0; | 281 | int number = 0; |
282 | 282 | ||
283 | for ( uint format_index = 0; format_index < rst.length(); format_index++ ) | 283 | for ( uint format_index = 0; format_index < rst.length(); format_index++ ) |
284 | { | 284 | { |
285 | if ( !escape ) | 285 | if ( !escape ) |
286 | { | 286 | { |
287 | if ( rst.at( format_index ).unicode() == '%' ) | 287 | if ( rst.at( format_index ).unicode() == '%' ) |
288 | escape = true; | 288 | escape = true; |
289 | else | 289 | else |
290 | buffer[index++] = rst.at( format_index ); | 290 | buffer[index++] = rst.at( format_index ); |
291 | } | 291 | } |
292 | else | 292 | else |
293 | { | 293 | { |
294 | switch ( rst.at( format_index ).unicode() ) | 294 | switch ( rst.at( format_index ).unicode() ) |
295 | { | 295 | { |
296 | case '%': | 296 | case '%': |
297 | buffer[index++] = '%'; | 297 | buffer[index++] = '%'; |
298 | break; | 298 | break; |
299 | case 'H': | 299 | case 'H': |
300 | put_it_in( buffer, index, pTime.hour() ); | 300 | put_it_in( buffer, index, pTime.hour() ); |
301 | break; | 301 | break; |
302 | case 'I': | 302 | case 'I': |
303 | put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); | 303 | put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); |
304 | break; | 304 | break; |
305 | case 'M': | 305 | case 'M': |
306 | put_it_in( buffer, index, pTime.minute() ); | 306 | put_it_in( buffer, index, pTime.minute() ); |
307 | break; | 307 | break; |
308 | case 'S': | 308 | case 'S': |
309 | if (includeSecs) | 309 | if (includeSecs) |
310 | put_it_in( buffer, index, pTime.second() ); | 310 | put_it_in( buffer, index, pTime.second() ); |
311 | else | 311 | else |
312 | { | 312 | { |
313 | // we remove the seperator sign before the seconds and | 313 | // we remove the seperator sign before the seconds and |
314 | // assume that works everywhere | 314 | // assume that works everywhere |
315 | --index; | 315 | --index; |
316 | break; | 316 | break; |
317 | } | 317 | } |
318 | break; | 318 | break; |
319 | case 'k': | 319 | case 'k': |
320 | number = pTime.hour(); | 320 | number = pTime.hour(); |
321 | case 'l': | 321 | case 'l': |
322 | // to share the code | 322 | // to share the code |
323 | if ( rst.at( format_index ).unicode() == 'l' ) | 323 | if ( rst.at( format_index ).unicode() == 'l' ) |
324 | number = (pTime.hour() + 11) % 12 + 1; | 324 | number = (pTime.hour() + 11) % 12 + 1; |
325 | if ( number / 10 ) | 325 | if ( number / 10 ) |
326 | buffer[index++] = number / 10 + '0'; | 326 | buffer[index++] = number / 10 + '0'; |
327 | buffer[index++] = number % 10 + '0'; | 327 | buffer[index++] = number % 10 + '0'; |
328 | break; | 328 | break; |
329 | case 'p': | 329 | case 'p': |
330 | { | 330 | { |
331 | QString s; | 331 | QString s; |
332 | if ( pTime.hour() >= 12 ) | 332 | if ( pTime.hour() >= 12 ) |
333 | put_it_in( buffer, index, i18n("pm") ); | 333 | put_it_in( buffer, index, i18n("pm") ); |
334 | else | 334 | else |
335 | put_it_in( buffer, index, i18n("am") ); | 335 | put_it_in( buffer, index, i18n("am") ); |
336 | break; | 336 | break; |
337 | } | 337 | } |
338 | default: | 338 | default: |
339 | buffer[index++] = rst.at( format_index ); | 339 | buffer[index++] = rst.at( format_index ); |
340 | break; | 340 | break; |
341 | } | 341 | } |
342 | escape = false; | 342 | escape = false; |
343 | } | 343 | } |
344 | } | 344 | } |
345 | QString ret( buffer, index ); | 345 | QString ret( buffer, index ); |
346 | delete [] buffer; | 346 | delete [] buffer; |
347 | return ret; | 347 | return ret; |
348 | } | 348 | } |
349 | 349 | ||
350 | QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const | 350 | QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const |
351 | { | 351 | { |
352 | const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); | 352 | const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); |
353 | 353 | ||
354 | // I'm rather safe than sorry | 354 | // I'm rather safe than sorry |
355 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; | 355 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; |
356 | 356 | ||
357 | unsigned int index = 0; | 357 | unsigned int index = 0; |
358 | bool escape = false; | 358 | bool escape = false; |
359 | int number = 0; | 359 | int number = 0; |
360 | 360 | ||
361 | for ( uint format_index = 0; format_index < rst.length(); ++format_index ) | 361 | for ( uint format_index = 0; format_index < rst.length(); ++format_index ) |
362 | { | 362 | { |
363 | if ( !escape ) | 363 | if ( !escape ) |
364 | { | 364 | { |
365 | if ( rst.at( format_index ).unicode() == '%' ) | 365 | if ( rst.at( format_index ).unicode() == '%' ) |
366 | escape = true; | 366 | escape = true; |
367 | else | 367 | else |
368 | buffer[index++] = rst.at( format_index ); | 368 | buffer[index++] = rst.at( format_index ); |
369 | } | 369 | } |
370 | else | 370 | else |
371 | { | 371 | { |
372 | switch ( rst.at( format_index ).unicode() ) | 372 | switch ( rst.at( format_index ).unicode() ) |
373 | { | 373 | { |
374 | case '%': | 374 | case '%': |
375 | buffer[index++] = '%'; | 375 | buffer[index++] = '%'; |
376 | break; | 376 | break; |
377 | case 'Y': | 377 | case 'Y': |
378 | put_it_in( buffer, index, pDate.year() / 100 ); | 378 | put_it_in( buffer, index, pDate.year() / 100 ); |
379 | case 'y': | 379 | case 'y': |
380 | put_it_in( buffer, index, pDate.year() % 100 ); | 380 | put_it_in( buffer, index, pDate.year() % 100 ); |
381 | break; | 381 | break; |
382 | case 'n': | 382 | case 'n': |
383 | number = pDate.month(); | 383 | number = pDate.month(); |
384 | case 'e': | 384 | case 'e': |
385 | // to share the code | 385 | // to share the code |
386 | if ( rst.at( format_index ).unicode() == 'e' ) | 386 | if ( rst.at( format_index ).unicode() == 'e' ) |
387 | number = pDate.day(); | 387 | number = pDate.day(); |
388 | if ( number / 10 ) | 388 | if ( number / 10 ) |
389 | buffer[index++] = number / 10 + '0'; | 389 | buffer[index++] = number / 10 + '0'; |
390 | buffer[index++] = number % 10 + '0'; | 390 | buffer[index++] = number % 10 + '0'; |
391 | break; | 391 | break; |
392 | case 'm': | 392 | case 'm': |
393 | put_it_in( buffer, index, pDate.month() ); | 393 | put_it_in( buffer, index, pDate.month() ); |
394 | break; | 394 | break; |
395 | case 'b': | 395 | case 'b': |
396 | put_it_in( buffer, index, monthName(pDate.month(), true) ); | 396 | put_it_in( buffer, index, monthName(pDate.month(), true) ); |
397 | break; | 397 | break; |
398 | case 'B': | 398 | case 'B': |
399 | put_it_in( buffer, index, monthName(pDate.month(), false) ); | 399 | put_it_in( buffer, index, monthName(pDate.month(), false) ); |
400 | break; | 400 | break; |
401 | case 'd': | 401 | case 'd': |
402 | put_it_in( buffer, index, pDate.day() ); | 402 | put_it_in( buffer, index, pDate.day() ); |
403 | break; | 403 | break; |
404 | case 'a': | 404 | case 'a': |
405 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); | 405 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); |
406 | break; | 406 | break; |
407 | case 'A': | 407 | case 'A': |
408 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); | 408 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); |
409 | break; | 409 | break; |
410 | default: | 410 | default: |
411 | buffer[index++] = rst.at( format_index ); | 411 | buffer[index++] = rst.at( format_index ); |
412 | break; | 412 | break; |
413 | } | 413 | } |
414 | escape = false; | 414 | escape = false; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | QString ret( buffer, index ); | 417 | QString ret( buffer, index ); |
418 | delete [] buffer; | 418 | delete [] buffer; |
419 | return ret; | 419 | return ret; |
420 | } | 420 | } |
421 | 421 | ||
422 | QString KLocale::formatDateTime(const QDateTime &pDateTime, | 422 | QString KLocale::formatDateTime(const QDateTime &pDateTime, |
423 | bool shortFormat, | 423 | bool shortFormat, |
424 | bool includeSeconds, | 424 | bool includeSeconds, |
425 | IntDateFormat intIntDateFormat) const | 425 | IntDateFormat intIntDateFormat) const |
426 | { | 426 | { |
427 | QString format("%1 %2"); | 427 | QString format("%1 %2"); |
428 | 428 | ||
429 | if ( intIntDateFormat == Default ) | 429 | if ( intIntDateFormat == Default ) |
430 | format = "%1 %2"; | 430 | format = "%1 %2"; |
431 | else if ( intIntDateFormat == Format1 ) | 431 | else if ( intIntDateFormat == Format1 ) |
432 | format = "%1 %2"; | 432 | format = "%1 %2"; |
433 | else if ( intIntDateFormat == ISODate ) | 433 | else if ( intIntDateFormat == ISODate ) |
434 | format = "%1T%2"; | 434 | format = "%1T%2"; |
435 | 435 | ||
436 | QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) | 436 | QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) |
437 | .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); | 437 | .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); |
438 | 438 | ||
439 | //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); | 439 | //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); |
440 | 440 | ||
441 | return res; | 441 | return res; |
442 | } | 442 | } |
443 | 443 | ||
444 | QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const | 444 | QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const |
445 | { | 445 | { |
446 | return formatDateTime(pDateTime, true, true, intIntDateFormat); | 446 | return formatDateTime(pDateTime, true, true, intIntDateFormat); |
447 | } | 447 | } |
448 | 448 | ||
449 | QDate KLocale::readDate(const QString &intstr, bool* ok) const | 449 | QDate KLocale::readDate(const QString &intstr, bool* ok) const |
450 | { | 450 | { |
451 | QDate date; | 451 | QDate date; |
452 | date = readDate(intstr, true, ok); | 452 | date = readDate(intstr, true, ok); |
453 | if (date.isValid()) return date; | 453 | if (date.isValid()) return date; |
454 | return readDate(intstr, false, ok); | 454 | return readDate(intstr, false, ok); |
455 | } | 455 | } |
456 | 456 | ||
457 | QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const | 457 | QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const |
458 | { | 458 | { |
459 | QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); | 459 | QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); |
460 | return readDate( intstr, fmt, ok ); | 460 | return readDate( intstr, fmt, ok ); |
461 | } | 461 | } |
462 | 462 | ||
463 | QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const | 463 | QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const |
464 | { | 464 | { |
465 | //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; | 465 | //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; |
466 | QString str = intstr.simplifyWhiteSpace().lower(); | 466 | QString str = intstr.simplifyWhiteSpace().lower(); |
467 | int day = -1, month = -1; | 467 | int day = -1, month = -1; |
468 | // allow the year to be omitted if not in the format | 468 | // allow the year to be omitted if not in the format |
469 | int year = QDate::currentDate().year(); | 469 | int year = QDate::currentDate().year(); |
470 | uint strpos = 0; | 470 | uint strpos = 0; |
471 | uint fmtpos = 0; | 471 | uint fmtpos = 0; |
472 | 472 | ||
473 | while (fmt.length() > fmtpos || str.length() > strpos) | 473 | while (fmt.length() > fmtpos || str.length() > strpos) |
474 | { | 474 | { |
475 | if ( !(fmt.length() > fmtpos && str.length() > strpos) ) | 475 | if ( !(fmt.length() > fmtpos && str.length() > strpos) ) |
476 | goto error; | 476 | goto error; |
477 | 477 | ||
478 | QChar c = fmt.at(fmtpos++); | 478 | QChar c = fmt.at(fmtpos++); |
479 | 479 | ||
480 | if (c != '%') { | 480 | if (c != '%') { |
481 | if (c.isSpace()) | 481 | if (c.isSpace()) |
482 | strpos++; | 482 | strpos++; |
483 | else if (c != str.at(strpos++)) | 483 | else if (c != str.at(strpos++)) |
484 | goto error; | 484 | goto error; |
485 | continue; | 485 | continue; |
486 | } | 486 | } |
487 | 487 | ||
488 | // remove space at the begining | 488 | // remove space at the begining |
489 | if (str.length() > strpos && str.at(strpos).isSpace()) | 489 | if (str.length() > strpos && str.at(strpos).isSpace()) |
490 | strpos++; | 490 | strpos++; |
491 | 491 | ||
492 | c = fmt.at(fmtpos++); | 492 | c = fmt.at(fmtpos++); |
493 | switch (c) | 493 | switch (c) |
494 | { | 494 | { |
495 | case 'a': | 495 | case 'a': |
496 | case 'A': | 496 | case 'A': |
497 | // this will just be ignored | 497 | // this will just be ignored |
498 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | 498 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition |
499 | for (int j = 1; j < 8; j++) { | 499 | for (int j = 1; j < 8; j++) { |
500 | QString s = weekDayName(j, c == 'a').lower(); | 500 | QString s = weekDayName(j, c == 'a').lower(); |
501 | int len = s.length(); | 501 | int len = s.length(); |
502 | if (str.mid(strpos, len) == s) | 502 | if (str.mid(strpos, len) == s) |
503 | strpos += len; | 503 | strpos += len; |
504 | } | 504 | } |
505 | break; | 505 | break; |
506 | } | 506 | } |
507 | case 'b': | 507 | case 'b': |
508 | case 'B': | 508 | case 'B': |
509 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | 509 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition |
510 | for (int j = 1; j < 13; j++) { | 510 | for (int j = 1; j < 13; j++) { |
511 | QString s = monthName(j, c == 'b').lower(); | 511 | QString s = monthName(j, c == 'b').lower(); |
512 | int len = s.length(); | 512 | int len = s.length(); |
513 | if (str.mid(strpos, len) == s) { | 513 | if (str.mid(strpos, len) == s) { |
514 | month = j; | 514 | month = j; |
515 | strpos += len; | 515 | strpos += len; |
516 | } | 516 | } |
517 | } | 517 | } |
518 | break; | 518 | break; |
519 | } | 519 | } |
520 | case 'd': | 520 | case 'd': |
521 | case 'e': | 521 | case 'e': |
522 | day = readInt(str, strpos); | 522 | day = readInt(str, strpos); |
523 | if (day < 1 || day > 31) | 523 | if (day < 1 || day > 31) |
524 | goto error; | 524 | goto error; |
525 | 525 | ||
526 | break; | 526 | break; |
527 | 527 | ||
528 | case 'n': | 528 | case 'n': |
529 | case 'm': | 529 | case 'm': |
530 | month = readInt(str, strpos); | 530 | month = readInt(str, strpos); |
531 | if (month < 1 || month > 12) | 531 | if (month < 1 || month > 12) |
532 | goto error; | 532 | goto error; |
533 | 533 | ||
534 | break; | 534 | break; |
535 | 535 | ||
536 | case 'Y': | 536 | case 'Y': |
537 | case 'y': | 537 | case 'y': |
538 | year = readInt(str, strpos); | 538 | year = readInt(str, strpos); |
539 | if (year < 0) | 539 | if (year < 0) |
540 | goto error; | 540 | goto error; |
541 | // Qt treats a year in the range 0-100 as 1900-1999. | 541 | // Qt treats a year in the range 0-100 as 1900-1999. |
542 | // It is nicer for the user if we treat 0-68 as 2000-2068 | 542 | // It is nicer for the user if we treat 0-68 as 2000-2068 |
543 | if (year < 69) | 543 | if (year < 69) |
544 | year += 2000; | 544 | year += 2000; |
545 | else if (c == 'y') | 545 | else if (c == 'y') |
546 | year += 1900; | 546 | year += 1900; |
547 | 547 | ||
548 | break; | 548 | break; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; | 551 | //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; |
552 | if ( year != -1 && month != -1 && day != -1 ) | 552 | if ( year != -1 && month != -1 && day != -1 ) |
553 | { | 553 | { |
554 | if (ok) *ok = true; | 554 | if (ok) *ok = true; |
555 | return QDate(year, month, day); | 555 | return QDate(year, month, day); |
556 | } | 556 | } |
557 | error: | 557 | error: |
558 | if (ok) *ok = false; | 558 | if (ok) *ok = false; |
559 | return QDate(); // invalid date | 559 | return QDate(); // invalid date |
560 | } | 560 | } |
561 | 561 | ||
562 | QTime KLocale::readTime(const QString &intstr, bool *ok) const | 562 | QTime KLocale::readTime(const QString &intstr, bool *ok) const |
563 | { | 563 | { |
564 | QTime _time; | 564 | QTime _time; |
565 | _time = readTime(intstr, true, ok); | 565 | _time = readTime(intstr, true, ok); |
566 | if (_time.isValid()) return _time; | 566 | if (_time.isValid()) return _time; |
567 | return readTime(intstr, false, ok); | 567 | return readTime(intstr, false, ok); |
568 | } | 568 | } |
569 | 569 | ||
570 | QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const | 570 | QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const |
571 | { | 571 | { |
572 | QString str = intstr.simplifyWhiteSpace().lower(); | 572 | QString str = intstr.simplifyWhiteSpace().lower(); |
573 | QString Format = timeFormat().simplifyWhiteSpace(); | 573 | QString Format = timeFormat().simplifyWhiteSpace(); |
574 | if (!seconds) | 574 | if (!seconds) |
575 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); | 575 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); |
576 | 576 | ||
577 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds | 577 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds |
578 | 578 | ||
579 | bool g_12h = false; | 579 | bool g_12h = false; |
580 | bool pm = false; | 580 | bool pm = false; |
581 | uint strpos = 0; | 581 | uint strpos = 0; |
582 | uint Formatpos = 0; | 582 | uint Formatpos = 0; |
583 | 583 | ||
584 | while (Format.length() > Formatpos || str.length() > strpos) | 584 | while (Format.length() > Formatpos || str.length() > strpos) |
585 | { | 585 | { |
586 | if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; | 586 | if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; |
587 | 587 | ||
588 | QChar c = Format.at(Formatpos++); | 588 | QChar c = Format.at(Formatpos++); |
589 | 589 | ||
590 | if (c != '%') | 590 | if (c != '%') |
591 | { | 591 | { |
592 | if (c.isSpace()) | 592 | if (c.isSpace()) |
593 | strpos++; | 593 | strpos++; |
594 | else if (c != str.at(strpos++)) | 594 | else if (c != str.at(strpos++)) |
595 | goto error; | 595 | goto error; |
596 | continue; | 596 | continue; |
597 | } | 597 | } |
598 | 598 | ||
599 | // remove space at the begining | 599 | // remove space at the begining |
600 | if (str.length() > strpos && str.at(strpos).isSpace()) | 600 | if (str.length() > strpos && str.at(strpos).isSpace()) |
601 | strpos++; | 601 | strpos++; |
602 | 602 | ||
603 | c = Format.at(Formatpos++); | 603 | c = Format.at(Formatpos++); |
604 | switch (c) | 604 | switch (c) |
605 | { | 605 | { |
606 | case 'p': | 606 | case 'p': |
607 | { | 607 | { |
608 | QString s; | 608 | QString s; |
609 | s = i18n("pm").lower(); | 609 | s = i18n("pm").lower(); |
610 | int len = s.length(); | 610 | int len = s.length(); |
611 | if (str.mid(strpos, len) == s) | 611 | if (str.mid(strpos, len) == s) |
612 | { | 612 | { |
613 | pm = true; | 613 | pm = true; |
614 | strpos += len; | 614 | strpos += len; |
615 | } | 615 | } |
616 | else | 616 | else |
617 | { | 617 | { |
618 | s = i18n("am").lower(); | 618 | s = i18n("am").lower(); |
619 | len = s.length(); | 619 | len = s.length(); |
620 | if (str.mid(strpos, len) == s) { | 620 | if (str.mid(strpos, len) == s) { |
621 | pm = false; | 621 | pm = false; |
622 | strpos += len; | 622 | strpos += len; |
623 | } | 623 | } |
624 | else | 624 | else |
625 | goto error; | 625 | goto error; |
626 | } | 626 | } |
627 | } | 627 | } |
628 | break; | 628 | break; |
629 | 629 | ||
630 | case 'k': | 630 | case 'k': |
631 | case 'H': | 631 | case 'H': |
632 | g_12h = false; | 632 | g_12h = false; |
633 | hour = readInt(str, strpos); | 633 | hour = readInt(str, strpos); |
634 | if (hour < 0 || hour > 23) | 634 | if (hour < 0 || hour > 23) |
635 | goto error; | 635 | goto error; |
636 | 636 | ||
637 | break; | 637 | break; |
638 | 638 | ||
639 | case 'l': | 639 | case 'l': |
640 | case 'I': | 640 | case 'I': |
641 | g_12h = true; | 641 | g_12h = true; |
642 | hour = readInt(str, strpos); | 642 | hour = readInt(str, strpos); |
643 | if (hour < 1 || hour > 12) | 643 | if (hour < 1 || hour > 12) |
644 | goto error; | 644 | goto error; |
645 | 645 | ||
646 | break; | 646 | break; |
647 | 647 | ||
648 | case 'M': | 648 | case 'M': |
649 | minute = readInt(str, strpos); | 649 | minute = readInt(str, strpos); |
650 | if (minute < 0 || minute > 59) | 650 | if (minute < 0 || minute > 59) |
651 | goto error; | 651 | goto error; |
652 | 652 | ||
653 | break; | 653 | break; |
654 | 654 | ||
655 | case 'S': | 655 | case 'S': |
656 | second = readInt(str, strpos); | 656 | second = readInt(str, strpos); |
657 | if (second < 0 || second > 59) | 657 | if (second < 0 || second > 59) |
658 | goto error; | 658 | goto error; |
659 | 659 | ||
660 | break; | 660 | break; |
661 | } | 661 | } |
662 | } | 662 | } |
663 | if (g_12h) | 663 | if (g_12h) |
664 | { | 664 | { |
665 | hour %= 12; | 665 | hour %= 12; |
666 | if (pm) hour += 12; | 666 | if (pm) hour += 12; |
667 | } | 667 | } |
668 | 668 | ||
669 | if (ok) *ok = true; | 669 | if (ok) *ok = true; |
670 | return QTime(hour, minute, second); | 670 | return QTime(hour, minute, second); |
671 | 671 | ||
672 | error: | 672 | error: |
673 | if (ok) *ok = false; | 673 | if (ok) *ok = false; |
674 | return QTime(-1, -1, -1); // return invalid date if it didn't work | 674 | return QTime(-1, -1, -1); // return invalid date if it didn't work |
675 | // This will be removed in the near future, since it gives a warning on stderr. | 675 | // This will be removed in the near future, since it gives a warning on stderr. |
676 | // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. | 676 | // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. |
677 | } | 677 | } |
678 | 678 | ||
679 | QDateTime KLocale::readDateTime(const QString &intstr, | 679 | QDateTime KLocale::readDateTime(const QString &intstr, |
680 | IntDateFormat intIntDateFormat, | 680 | IntDateFormat intIntDateFormat, |
681 | bool* ok) const | 681 | bool* ok) const |
682 | { | 682 | { |
683 | bool ok1, ok2; | 683 | bool ok1, ok2; |
684 | 684 | ||
685 | // AT the moment we can not read any other format then ISODate | 685 | // AT the moment we can not read any other format then ISODate |
686 | if ( intIntDateFormat != ISODate ) | 686 | if ( intIntDateFormat != ISODate ) |
687 | { | 687 | { |
688 | qDebug("KLocale::readDateTime, only ISODate is supported."); | 688 | qDebug("KLocale::readDateTime, only ISODate is supported."); |
689 | return QDateTime(); | 689 | return QDateTime(); |
690 | } | 690 | } |
691 | 691 | ||
692 | int pos = intstr.find("T"); | 692 | int pos = intstr.find("T"); |
693 | QString date = intstr.left(pos); | 693 | QString date = intstr.left(pos); |
694 | QString time = intstr.mid(pos+1); | 694 | QString time = intstr.mid(pos+1); |
695 | 695 | ||
696 | QString dformat = dateFormat(intIntDateFormat); | 696 | QString dformat = dateFormat(intIntDateFormat); |
697 | QString tformat = timeFormat(intIntDateFormat); | 697 | QString tformat = timeFormat(intIntDateFormat); |
698 | 698 | ||
699 | QDate m_date = readDate(date, dformat, &ok1); | 699 | QDate m_date = readDate(date, dformat, &ok1); |
700 | QTime m_time = readTime(time, tformat, &ok2); | 700 | QTime m_time = readTime(time, tformat, &ok2); |
701 | 701 | ||
702 | QDateTime m_dt; | 702 | QDateTime m_dt; |
703 | 703 | ||
704 | if (ok) | 704 | if (ok) |
705 | { | 705 | { |
706 | if ((ok1 == false) || (ok2 == false)) | 706 | if ((ok1 == false) || (ok2 == false)) |
707 | *ok = false; | 707 | *ok = false; |
708 | else | 708 | else |
709 | *ok = true; | 709 | *ok = true; |
710 | } | 710 | } |
711 | 711 | ||
712 | //only set values if both operations returned true. | 712 | //only set values if both operations returned true. |
713 | if ((ok1 == true) && (ok2 == true)) | 713 | if ((ok1 == true) && (ok2 == true)) |
714 | { | 714 | { |
715 | m_dt.setDate(m_date); | 715 | m_dt.setDate(m_date); |
716 | m_dt.setTime(m_time); | 716 | m_dt.setTime(m_time); |
717 | } | 717 | } |
718 | 718 | ||
719 | //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); | 719 | //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); |
720 | return m_dt; | 720 | return m_dt; |
721 | } | 721 | } |
722 | 722 | ||
723 | QDate KLocale::readDate(const QString &intstr, | 723 | QDate KLocale::readDate(const QString &intstr, |
724 | IntDateFormat intIntDateFormat, | 724 | IntDateFormat intIntDateFormat, |
725 | bool* ok) const | 725 | bool* ok) const |
726 | { | 726 | { |
727 | bool ok1; | 727 | bool ok1; |
728 | 728 | ||
729 | QString dformat = dateFormat(intIntDateFormat); | 729 | QString dformat = dateFormat(intIntDateFormat); |
730 | 730 | ||
731 | QDate m_date = readDate(intstr, dformat, &ok1); | 731 | QDate m_date = readDate(intstr, dformat, &ok1); |
732 | 732 | ||
733 | if (ok) | 733 | if (ok) |
734 | *ok = ok1; | 734 | *ok = ok1; |
735 | 735 | ||
736 | //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); | 736 | //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); |
737 | return m_date; | 737 | return m_date; |
738 | } | 738 | } |
739 | 739 | ||
740 | 740 | ||
741 | bool KLocale::use12Clock() const | 741 | bool KLocale::use12Clock() const |
742 | { | 742 | { |
743 | return !mHourF24Format ;; | 743 | return !mHourF24Format ;; |
744 | } | 744 | } |
745 | 745 | ||
746 | bool KLocale::weekStartsMonday() const | 746 | bool KLocale::weekStartsMonday() const |
747 | { | 747 | { |
748 | return mWeekStartsMonday; | 748 | return mWeekStartsMonday; |
749 | } | 749 | } |
750 | 750 | ||
751 | int KLocale::weekStartDay() const | 751 | int KLocale::weekStartDay() const |
752 | { | 752 | { |
753 | if ( mWeekStartsMonday ) | 753 | if ( mWeekStartsMonday ) |
754 | return 1; | 754 | return 1; |
755 | return 7; | 755 | return 7; |
756 | } | 756 | } |
757 | 757 | ||
758 | QString KLocale::weekDayName(int i,bool shortName) const | 758 | QString KLocale::weekDayName(int i,bool shortName) const |
759 | { | 759 | { |
760 | if ( shortName ) | 760 | if ( shortName ) |
761 | switch ( i ) | 761 | switch ( i ) |
762 | { | 762 | { |
763 | case 1: return i18n("Monday", "Mon"); | 763 | case 1: return i18n("Monday", "Mon"); |
764 | case 2: return i18n("Tuesday", "Tue"); | 764 | case 2: return i18n("Tuesday", "Tue"); |
765 | case 3: return i18n("Wednesday", "Wed"); | 765 | case 3: return i18n("Wednesday", "Wed"); |
766 | case 4: return i18n("Thursday", "Thu"); | 766 | case 4: return i18n("Thursday", "Thu"); |
767 | case 5: return i18n("Friday", "Fri"); | 767 | case 5: return i18n("Friday", "Fri"); |
768 | case 6: return i18n("Saturday", "Sat"); | 768 | case 6: return i18n("Saturday", "Sat"); |
769 | case 7: return i18n("Sunday", "Sun"); | 769 | case 7: return i18n("Sunday", "Sun"); |
770 | } | 770 | } |
771 | else | 771 | else |
772 | switch ( i ) | 772 | switch ( i ) |
773 | { | 773 | { |
774 | case 1: return i18n("Monday"); | 774 | case 1: return i18n("Monday"); |
775 | case 2: return i18n("Tuesday"); | 775 | case 2: return i18n("Tuesday"); |
776 | case 3: return i18n("Wednesday"); | 776 | case 3: return i18n("Wednesday"); |
777 | case 4: return i18n("Thursday"); | 777 | case 4: return i18n("Thursday"); |
778 | case 5: return i18n("Friday"); | 778 | case 5: return i18n("Friday"); |
779 | case 6: return i18n("Saturday"); | 779 | case 6: return i18n("Saturday"); |
780 | case 7: return i18n("Sunday"); | 780 | case 7: return i18n("Sunday"); |
781 | } | 781 | } |
782 | 782 | ||
783 | return QString::null; | 783 | return QString::null; |
784 | } | 784 | } |
785 | 785 | ||
786 | QString KLocale::monthName(int i,bool shortName) const | 786 | QString KLocale::monthName(int i,bool shortName) const |
787 | { | 787 | { |
788 | if ( shortName ) | 788 | if ( shortName ) |
789 | switch ( i ) | 789 | switch ( i ) |
790 | { | 790 | { |
791 | case 1: return i18n("January", "Jan"); | 791 | case 1: return i18n("January", "Jan"); |
792 | case 2: return i18n("February", "Feb"); | 792 | case 2: return i18n("February", "Feb"); |
793 | case 3: return i18n("March", "Mar"); | 793 | case 3: return i18n("March", "Mar"); |
794 | case 4: return i18n("April", "Apr"); | 794 | case 4: return i18n("April", "Apr"); |
795 | case 5: return i18n("May short", "May"); | 795 | case 5: return i18n("May short", "May"); |
796 | case 6: return i18n("June", "Jun"); | 796 | case 6: return i18n("June", "Jun"); |
797 | case 7: return i18n("July", "Jul"); | 797 | case 7: return i18n("July", "Jul"); |
798 | case 8: return i18n("August", "Aug"); | 798 | case 8: return i18n("August", "Aug"); |
799 | case 9: return i18n("September", "Sep"); | 799 | case 9: return i18n("September", "Sep"); |
800 | case 10: return i18n("October", "Oct"); | 800 | case 10: return i18n("October", "Oct"); |
801 | case 11: return i18n("November", "Nov"); | 801 | case 11: return i18n("November", "Nov"); |
802 | case 12: return i18n("December", "Dec"); | 802 | case 12: return i18n("December", "Dec"); |
803 | } | 803 | } |
804 | else | 804 | else |
805 | switch (i) | 805 | switch (i) |
806 | { | 806 | { |
807 | case 1: return i18n("January"); | 807 | case 1: return i18n("January"); |
808 | case 2: return i18n("February"); | 808 | case 2: return i18n("February"); |
809 | case 3: return i18n("March"); | 809 | case 3: return i18n("March"); |
810 | case 4: return i18n("April"); | 810 | case 4: return i18n("April"); |
811 | case 5: return i18n("May long", "May"); | 811 | case 5: return i18n("May long", "May"); |
812 | case 6: return i18n("June"); | 812 | case 6: return i18n("June"); |
813 | case 7: return i18n("July"); | 813 | case 7: return i18n("July"); |
814 | case 8: return i18n("August"); | 814 | case 8: return i18n("August"); |
815 | case 9: return i18n("September"); | 815 | case 9: return i18n("September"); |
816 | case 10: return i18n("October"); | 816 | case 10: return i18n("October"); |
817 | case 11: return i18n("November"); | 817 | case 11: return i18n("November"); |
818 | case 12: return i18n("December"); | 818 | case 12: return i18n("December"); |
819 | } | 819 | } |
820 | 820 | ||
821 | return QString::null; | 821 | return QString::null; |
822 | } | 822 | } |
823 | 823 | ||
824 | QString KLocale::country() const | 824 | QString KLocale::country() const |
825 | { | 825 | { |
826 | return QString::null; | 826 | return QString::null; |
827 | } | 827 | } |
828 | 828 | ||
829 | QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const | 829 | QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const |
830 | { | 830 | { |
831 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; | 831 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; |
832 | 832 | ||
833 | if ( dformat == ISODate ) | 833 | if ( dformat == ISODate ) |
834 | return "%Y-%m-%d"; | 834 | return "%Y-%m-%d"; |
835 | 835 | ||
836 | if ( QApplication::desktop()->width() < 480 ) { | 836 | if ( QApplication::desktop()->width() < 480 ) { |
837 | if ( dformat == Default ) | 837 | if ( dformat == Default ) |
838 | return "%a %d %b %Y"; | 838 | return "%a %d %b %Y"; |
839 | else if ( dformat == Format1 ) | 839 | else if ( dformat == Format1 ) |
840 | return "%a %b %d %Y"; | 840 | return "%a %b %d %Y"; |
841 | } else { | 841 | } else { |
842 | if ( dformat == Default ) | 842 | if ( dformat == Default ) |
843 | return "%A %d %B %Y"; | 843 | return "%A %d %B %Y"; |
844 | else if ( dformat == Format1 ) | 844 | else if ( dformat == Format1 ) |
845 | return "%A %B %d %Y"; | 845 | return "%A %B %d %Y"; |
846 | 846 | ||
847 | } | 847 | } |
848 | return mDateFormat ; | 848 | return mDateFormat ; |
849 | } | 849 | } |
850 | 850 | ||
851 | QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const | 851 | QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const |
852 | { | 852 | { |
853 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; | 853 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; |
854 | 854 | ||
855 | if ( dformat == Default ) | 855 | if ( dformat == Default ) |
856 | return "%d.%m.%Y"; | 856 | return "%d.%m.%Y"; |
857 | else if ( dformat == Format1 ) | 857 | else if ( dformat == Format1 ) |
858 | return "%m.%d.%Y"; | 858 | return "%m.%d.%Y"; |
859 | else if ( dformat == ISODate ) // = Qt::ISODate | 859 | else if ( dformat == ISODate ) // = Qt::ISODate |
860 | return "%Y-%m-%d"; | 860 | return "%Y-%m-%d"; |
861 | return mDateFormatShort ; | 861 | return mDateFormatShort ; |
862 | 862 | ||
863 | } | 863 | } |
864 | 864 | ||
865 | 865 | ||
866 | QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const | 866 | QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const |
867 | { | 867 | { |
868 | const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; | 868 | const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; |
869 | 869 | ||
870 | if ( tformat == Default ) | 870 | if ( tformat == Default ) |
871 | if ( mHourF24Format) | 871 | if ( mHourF24Format) |
872 | return "%H:%M:%S"; | 872 | return "%H:%M:%S"; |
873 | else | 873 | else |
874 | return "%I:%M:%S%p"; | 874 | return "%I:%M:%S%p"; |
875 | 875 | ||
876 | else if ( tformat == Format1 ) | 876 | else if ( tformat == Format1 ) |
877 | if ( mHourF24Format) | 877 | if ( mHourF24Format) |
878 | return "%H:%M:%S"; | 878 | return "%H:%M:%S"; |
879 | else | 879 | else |
880 | return "%I:%M:%S%p"; | 880 | return "%I:%M:%S%p"; |
881 | 881 | ||
882 | else if ( tformat == ISODate ) // = Qt::ISODate | 882 | else if ( tformat == ISODate ) // = Qt::ISODate |
883 | if ( mHourF24Format) | 883 | if ( mHourF24Format) |
884 | return "%H:%M:%S"; | 884 | return "%H:%M:%S"; |
885 | else | 885 | else |
886 | return "%I:%M:%S%p"; | 886 | return "%I:%M:%S%p"; |
887 | 887 | // to satisfy the compiler | |
888 | return "%H:%M:%S"; | ||
888 | } | 889 | } |
889 | 890 | ||
890 | void KLocale::insertCatalogue ( const QString & ) | 891 | void KLocale::insertCatalogue ( const QString & ) |
891 | { | 892 | { |
892 | } | 893 | } |
893 | 894 | ||
894 | KCalendarSystem *KLocale::calendar() | 895 | KCalendarSystem *KLocale::calendar() |
895 | { | 896 | { |
896 | if ( !mCalendarSystem ) { | 897 | if ( !mCalendarSystem ) { |
897 | mCalendarSystem = new KCalendarSystemGregorian; | 898 | mCalendarSystem = new KCalendarSystemGregorian; |
898 | } | 899 | } |
899 | 900 | ||
900 | return mCalendarSystem; | 901 | return mCalendarSystem; |
901 | } | 902 | } |
902 | 903 | ||
903 | int KLocale::timezoneOffset( QString timeZone ) | 904 | int KLocale::timezoneOffset( QString timeZone ) |
904 | { | 905 | { |
905 | int ret = 1001; | 906 | int ret = 1001; |
906 | int index = mTimeZoneList.findIndex( timeZone ); | 907 | int index = mTimeZoneList.findIndex( timeZone ); |
907 | if ( index < 24 ) | 908 | if ( index < 24 ) |
908 | ret = ( index-11 ) * 60 ; | 909 | ret = ( index-11 ) * 60 ; |
909 | return ret; | 910 | return ret; |
910 | } | 911 | } |
911 | 912 | ||
912 | QStringList KLocale::timeZoneList() const | 913 | QStringList KLocale::timeZoneList() const |
913 | { | 914 | { |
914 | return mTimeZoneList; | 915 | return mTimeZoneList; |
915 | } | 916 | } |
916 | void KLocale::setTimezone( const QString &timeZone, bool oddTZ ) | 917 | void KLocale::setTimezone( const QString &timeZone, bool oddTZ ) |
917 | { | 918 | { |
918 | mTimeZoneOffset = timezoneOffset( timeZone ); | 919 | mTimeZoneOffset = timezoneOffset( timeZone ); |
919 | if ( oddTZ ) | 920 | if ( oddTZ ) |
920 | mTimeZoneOffset += 30; | 921 | mTimeZoneOffset += 30; |
921 | } | 922 | } |
922 | 923 | ||
923 | void KLocale::setDaylightSaving( bool b, int start , int end ) | 924 | void KLocale::setDaylightSaving( bool b, int start , int end ) |
924 | { | 925 | { |
925 | daylightEnabled = b; | 926 | daylightEnabled = b; |
926 | daylightStart = start; | 927 | daylightStart = start; |
927 | daylightEnd = end; | 928 | daylightEnd = end; |
928 | mSouthDaylight = (end < start); | 929 | mSouthDaylight = (end < start); |
929 | // qDebug("klocale daylight %d %d %d ", b, start , end ); | 930 | // qDebug("klocale daylight %d %d %d ", b, start , end ); |
930 | } | 931 | } |
931 | 932 | ||
932 | int KLocale::localTimeOffset( const QDateTime &dt ) | 933 | int KLocale::localTimeOffset( const QDateTime &dt ) |
933 | { | 934 | { |
934 | bool addDaylight = false; | 935 | bool addDaylight = false; |
935 | if ( daylightEnabled ) { | 936 | if ( daylightEnabled ) { |
936 | int d_end, d_start; | 937 | int d_end, d_start; |
937 | int dayofyear = dt.date().dayOfYear(); | 938 | int dayofyear = dt.date().dayOfYear(); |
938 | int year = dt.date().year(); | 939 | int year = dt.date().year(); |
939 | int add = 0; | 940 | int add = 0; |
940 | if ( QDate::leapYear(year) ) | 941 | if ( QDate::leapYear(year) ) |
941 | add = 1; | 942 | add = 1; |
942 | QDate date ( year,1,1 ); | 943 | QDate date ( year,1,1 ); |
943 | if ( daylightEnd > 59 ) | 944 | if ( daylightEnd > 59 ) |
944 | d_end = daylightEnd +add; | 945 | d_end = daylightEnd +add; |
945 | else | 946 | else |
946 | d_end = daylightEnd; | 947 | d_end = daylightEnd; |
947 | if ( daylightStart > 59 ) | 948 | if ( daylightStart > 59 ) |
948 | d_start = daylightStart +add; | 949 | d_start = daylightStart +add; |
949 | else | 950 | else |
950 | d_start = daylightStart; | 951 | d_start = daylightStart; |
951 | QDate s_date = date.addDays( d_start -1 ); | 952 | QDate s_date = date.addDays( d_start -1 ); |
952 | QDate e_date = date.addDays( d_end -1 ); | 953 | QDate e_date = date.addDays( d_end -1 ); |
953 | int dof = s_date.dayOfWeek(); | 954 | int dof = s_date.dayOfWeek(); |
954 | if ( dof < 7 ) | 955 | if ( dof < 7 ) |
955 | s_date = s_date.addDays( -dof ); | 956 | s_date = s_date.addDays( -dof ); |
956 | dof = e_date.dayOfWeek(); | 957 | dof = e_date.dayOfWeek(); |
957 | if ( dof < 7 ) | 958 | if ( dof < 7 ) |
958 | e_date = e_date.addDays( -dof ); | 959 | e_date = e_date.addDays( -dof ); |
959 | QTime startTime ( 3,0,0 ); | 960 | QTime startTime ( 3,0,0 ); |
960 | QDateTime startDt( s_date, startTime ); | 961 | QDateTime startDt( s_date, startTime ); |
961 | QDateTime endDt( e_date, startTime ); | 962 | QDateTime endDt( e_date, startTime ); |
962 | //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); | 963 | //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); |
963 | if ( mSouthDaylight ) { | 964 | if ( mSouthDaylight ) { |
964 | if ( ! ( endDt < dt && dt < startDt) ) | 965 | if ( ! ( endDt < dt && dt < startDt) ) |
965 | addDaylight = true; | 966 | addDaylight = true; |
966 | } else { | 967 | } else { |
967 | if ( startDt < dt && dt < endDt ) | 968 | if ( startDt < dt && dt < endDt ) |
968 | addDaylight = true; | 969 | addDaylight = true; |
969 | 970 | ||
970 | 971 | ||
971 | } | 972 | } |
972 | } | 973 | } |
973 | int addMin = 0; | 974 | int addMin = 0; |
974 | if ( addDaylight ) | 975 | if ( addDaylight ) |
975 | addMin = 60; | 976 | addMin = 60; |
976 | return mTimeZoneOffset + addMin; | 977 | return mTimeZoneOffset + addMin; |
977 | } | 978 | } |
978 | // ****************************************************************** | 979 | // ****************************************************************** |
979 | // added LR | 980 | // added LR |
980 | QString KLocale::formatNumber(double num, int precision) const | 981 | QString KLocale::formatNumber(double num, int precision) const |
981 | { | 982 | { |
982 | bool neg = num < 0; | 983 | bool neg = num < 0; |
983 | if (precision == -1) precision = 2; | 984 | if (precision == -1) precision = 2; |
984 | QString res = QString::number(neg?-num:num, 'f', precision); | 985 | QString res = QString::number(neg?-num:num, 'f', precision); |
985 | int pos = res.find('.'); | 986 | int pos = res.find('.'); |
986 | if (pos == -1) pos = res.length(); | 987 | if (pos == -1) pos = res.length(); |
987 | else res.replace(pos, 1, decimalSymbol()); | 988 | else res.replace(pos, 1, decimalSymbol()); |
988 | 989 | ||
989 | while (0 < (pos -= 3)) | 990 | while (0 < (pos -= 3)) |
990 | res.insert(pos, thousandsSeparator()); // thousand sep | 991 | res.insert(pos, thousandsSeparator()); // thousand sep |
991 | 992 | ||
992 | // How can we know where we should put the sign? | 993 | // How can we know where we should put the sign? |
993 | res.prepend(neg?negativeSign():positiveSign()); | 994 | res.prepend(neg?negativeSign():positiveSign()); |
994 | 995 | ||
995 | return res; | 996 | return res; |
996 | } | 997 | } |
997 | QString KLocale::formatNumber(const QString &numStr) const | 998 | QString KLocale::formatNumber(const QString &numStr) const |
998 | { | 999 | { |
999 | return formatNumber(numStr.toDouble()); | 1000 | return formatNumber(numStr.toDouble()); |
1000 | } | 1001 | } |
1001 | double KLocale::readNumber(const QString &_str, bool * ok) const | 1002 | double KLocale::readNumber(const QString &_str, bool * ok) const |
1002 | { | 1003 | { |
1003 | QString str = _str.stripWhiteSpace(); | 1004 | QString str = _str.stripWhiteSpace(); |
1004 | bool neg = str.find(negativeSign()) == 0; | 1005 | bool neg = str.find(negativeSign()) == 0; |
1005 | if (neg) | 1006 | if (neg) |
1006 | str.remove( 0, negativeSign().length() ); | 1007 | str.remove( 0, negativeSign().length() ); |
1007 | 1008 | ||
1008 | /* will hold the scientific notation portion of the number. | 1009 | /* will hold the scientific notation portion of the number. |
1009 | Example, with 2.34E+23, exponentialPart == "E+23" | 1010 | Example, with 2.34E+23, exponentialPart == "E+23" |
1010 | */ | 1011 | */ |
1011 | QString exponentialPart; | 1012 | QString exponentialPart; |
1012 | int EPos; | 1013 | int EPos; |
1013 | 1014 | ||
1014 | EPos = str.find('E', 0, false); | 1015 | EPos = str.find('E', 0, false); |
1015 | 1016 | ||
1016 | if (EPos != -1) | 1017 | if (EPos != -1) |
1017 | { | 1018 | { |
1018 | exponentialPart = str.mid(EPos); | 1019 | exponentialPart = str.mid(EPos); |
1019 | str = str.left(EPos); | 1020 | str = str.left(EPos); |
1020 | } | 1021 | } |
1021 | 1022 | ||
1022 | int pos = str.find(decimalSymbol()); | 1023 | int pos = str.find(decimalSymbol()); |
1023 | QString major; | 1024 | QString major; |
1024 | QString minor; | 1025 | QString minor; |
1025 | if ( pos == -1 ) | 1026 | if ( pos == -1 ) |
1026 | major = str; | 1027 | major = str; |
1027 | else | 1028 | else |
1028 | { | 1029 | { |
1029 | major = str.left(pos); | 1030 | major = str.left(pos); |
1030 | minor = str.mid(pos + decimalSymbol().length()); | 1031 | minor = str.mid(pos + decimalSymbol().length()); |
1031 | } | 1032 | } |
1032 | 1033 | ||
1033 | // Remove thousand separators | 1034 | // Remove thousand separators |
1034 | int thlen = thousandsSeparator().length(); | 1035 | int thlen = thousandsSeparator().length(); |
1035 | int lastpos = 0; | 1036 | int lastpos = 0; |
1036 | while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) | 1037 | while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) |
1037 | { | 1038 | { |
1038 | // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N | 1039 | // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N |
1039 | int fromEnd = major.length() - pos; | 1040 | int fromEnd = major.length() - pos; |
1040 | if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error | 1041 | if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error |
1041 | || pos - lastpos > 3 // More than 3 digits between two separators -> error | 1042 | || pos - lastpos > 3 // More than 3 digits between two separators -> error |
1042 | || pos == 0 // Can't start with a separator | 1043 | || pos == 0 // Can't start with a separator |
1043 | || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators | 1044 | || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators |
1044 | { | 1045 | { |
1045 | if (ok) *ok = false; | 1046 | if (ok) *ok = false; |
1046 | return 0.0; | 1047 | return 0.0; |
1047 | } | 1048 | } |
1048 | 1049 | ||
1049 | lastpos = pos; | 1050 | lastpos = pos; |
1050 | major.remove( pos, thlen ); | 1051 | major.remove( pos, thlen ); |
1051 | } | 1052 | } |
1052 | if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator | 1053 | if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator |
1053 | { | 1054 | { |
1054 | if (ok) *ok = false; | 1055 | if (ok) *ok = false; |
1055 | return 0.0; | 1056 | return 0.0; |
1056 | } | 1057 | } |
1057 | 1058 | ||
1058 | QString tot; | 1059 | QString tot; |
1059 | if (neg) tot = '-'; | 1060 | if (neg) tot = '-'; |
1060 | 1061 | ||
1061 | tot += major + '.' + minor + exponentialPart; | 1062 | tot += major + '.' + minor + exponentialPart; |
1062 | 1063 | ||
1063 | return tot.toDouble(ok); | 1064 | return tot.toDouble(ok); |
1064 | } | 1065 | } |
1065 | QString KLocale::decimalSymbol() const | 1066 | QString KLocale::decimalSymbol() const |
1066 | { | 1067 | { |
1067 | 1068 | ||
1068 | return m_decimalSymbol; | 1069 | return m_decimalSymbol; |
1069 | } | 1070 | } |
1070 | 1071 | ||
1071 | QString KLocale::thousandsSeparator() const | 1072 | QString KLocale::thousandsSeparator() const |
1072 | { | 1073 | { |
1073 | 1074 | ||
1074 | return m_thousandsSeparator; | 1075 | return m_thousandsSeparator; |
1075 | } | 1076 | } |
1076 | QString KLocale::positiveSign() const | 1077 | QString KLocale::positiveSign() const |
1077 | { | 1078 | { |
1078 | return m_positiveSign; | 1079 | return m_positiveSign; |
1079 | } | 1080 | } |
1080 | 1081 | ||
1081 | QString KLocale::negativeSign() const | 1082 | QString KLocale::negativeSign() const |
1082 | { | 1083 | { |
1083 | return m_negativeSign; | 1084 | return m_negativeSign; |
1084 | } | 1085 | } |
diff --git a/microkde/kidmanager.cpp b/microkde/kidmanager.cpp index 8cf486a..e687e5d 100644 --- a/microkde/kidmanager.cpp +++ b/microkde/kidmanager.cpp | |||
@@ -1,136 +1,136 @@ | |||
1 | #include "kidmanager.h" | 1 | #include "kidmanager.h" |
2 | 2 | ||
3 | KIdManager::KIdManager() | 3 | KIdManager::KIdManager() |
4 | { | 4 | { |
5 | 5 | ||
6 | } | 6 | } |
7 | // :profilename;12;id_withLen12;123456: | 7 | // :profilename;12;id_withLen12;123456: |
8 | // 123456 is the csum | 8 | // 123456 is the csum |
9 | QString KIdManager::setId (const QString& idString,const QString& prof,const QString& idvalue ) | 9 | QString KIdManager::setId (const QString& idString,const QString& prof,const QString& idvalue ) |
10 | { | 10 | { |
11 | int startProf; | 11 | int startProf; |
12 | int startIDnum; | 12 | int startIDnum; |
13 | int startIDnumlen; | 13 | int startIDnumlen; |
14 | int startID; | 14 | int startID; |
15 | int lenID; | 15 | int lenID; |
16 | int startCsum; | 16 | int startCsum; |
17 | int lenCsum; | 17 | int lenCsum; |
18 | int endall; | 18 | int endall; |
19 | QString newIDString; | 19 | QString newIDString; |
20 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { | 20 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { |
21 | newIDString = idString.left(startIDnum ) + QString::number( idvalue.length() ) +";"+idvalue+ ";"+idString.mid( startCsum ); | 21 | newIDString = idString.left(startIDnum ) + QString::number( idvalue.length() ) +";"+idvalue+ ";"+idString.mid( startCsum ); |
22 | } else { | 22 | } else { |
23 | newIDString = idString + prof+";"+ QString::number( idvalue.length() ) +";"+idvalue +";0:"; | 23 | newIDString = idString + prof+";"+ QString::number( idvalue.length() ) +";"+idvalue +";0:"; |
24 | } | 24 | } |
25 | //qDebug("setID:profile:%s*retval:%s*idvalue:%s* ", prof.latin1(), newIDString.latin1() ,idvalue.latin1() ); | 25 | //qDebug("setID:profile:%s*retval:%s*idvalue:%s* ", prof.latin1(), newIDString.latin1() ,idvalue.latin1() ); |
26 | return newIDString; | 26 | return newIDString; |
27 | } | 27 | } |
28 | QString KIdManager::getId (const QString& idString,const QString& prof ) | 28 | QString KIdManager::getId (const QString& idString,const QString& prof ) |
29 | { | 29 | { |
30 | int startProf; | 30 | int startProf; |
31 | int startIDnum; | 31 | int startIDnum; |
32 | int startIDnumlen; | 32 | int startIDnumlen; |
33 | int startID; | 33 | int startID; |
34 | int lenID; | 34 | int lenID; |
35 | int startCsum; | 35 | int startCsum; |
36 | int lenCsum; | 36 | int lenCsum; |
37 | int endall; | 37 | int endall; |
38 | QString idval = ""; | 38 | QString idval = ""; |
39 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) | 39 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) |
40 | idval = idString.mid( startID, lenID ); | 40 | idval = idString.mid( startID, lenID ); |
41 | 41 | ||
42 | //qDebug("getID:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); | 42 | //qDebug("getID:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); |
43 | return idval; | 43 | return idval; |
44 | 44 | ||
45 | } | 45 | } |
46 | 46 | ||
47 | QString KIdManager::removeId (const QString& idString,const QString& prof ) | 47 | QString KIdManager::removeId (const QString& idString,const QString& prof ) |
48 | { | 48 | { |
49 | int startProf; | 49 | int startProf; |
50 | int startIDnum; | 50 | int startIDnum; |
51 | int startIDnumlen; | 51 | int startIDnumlen; |
52 | int startID; | 52 | int startID; |
53 | int lenID; | 53 | int lenID; |
54 | int startCsum; | 54 | int startCsum; |
55 | int lenCsum; | 55 | int lenCsum; |
56 | int endall; | 56 | int endall; |
57 | QString newIDString; | 57 | QString newIDString; |
58 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { | 58 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { |
59 | newIDString = idString.left(startProf) + idString.mid( endall+1 ); | 59 | newIDString = idString.left(startProf) + idString.mid( endall+1 ); |
60 | } else { | 60 | } else { |
61 | newIDString = idString; | 61 | newIDString = idString; |
62 | } | 62 | } |
63 | //qDebug("removeID:profile:%s*retval:%s*oldidstring:%s* ", prof.latin1(), newIDString.latin1() ,idString.latin1() ); | 63 | //qDebug("removeID:profile:%s*retval:%s*oldidstring:%s* ", prof.latin1(), newIDString.latin1() ,idString.latin1() ); |
64 | return newIDString; | 64 | return newIDString; |
65 | } | 65 | } |
66 | 66 | ||
67 | QString KIdManager::setCsum (const QString& idString,const QString& prof,const QString& idCsum ) | 67 | QString KIdManager::setCsum (const QString& idString,const QString& prof,const QString& idCsum ) |
68 | { | 68 | { |
69 | int startProf; | 69 | int startProf; |
70 | int startIDnum; | 70 | int startIDnum; |
71 | int startIDnumlen; | 71 | int startIDnumlen; |
72 | int startID; | 72 | int startID; |
73 | int lenID; | 73 | int lenID; |
74 | int startCsum; | 74 | int startCsum; |
75 | int lenCsum; | 75 | int lenCsum; |
76 | int endall; | 76 | int endall; |
77 | QString newIDString; | 77 | QString newIDString; |
78 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { | 78 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { |
79 | newIDString = idString.left(startCsum) + idCsum+ idString.mid( endall +1); | 79 | newIDString = idString.left(startCsum) + idCsum+ idString.mid( endall +1); |
80 | } else { | 80 | } else { |
81 | newIDString = idString + prof + ";3;_u_;"+ idCsum + ":"; | 81 | newIDString = idString + prof + ";3;_u_;"+ idCsum + ":"; |
82 | } | 82 | } |
83 | //qDebug("setCsum:profile:%s*retval:%s*idCsum:%s* ", prof.latin1(), newIDString.latin1() ,idCsum.latin1() ); | 83 | //qDebug("setCsum:profile:%s*retval:%s*idCsum:%s* ", prof.latin1(), newIDString.latin1() ,idCsum.latin1() ); |
84 | return newIDString; | 84 | return newIDString; |
85 | } | 85 | } |
86 | QString KIdManager::getCsum (const QString& idString,const QString& prof ) | 86 | QString KIdManager::getCsum (const QString& idString,const QString& prof ) |
87 | { | 87 | { |
88 | int startProf; | 88 | int startProf; |
89 | int startIDnum; | 89 | int startIDnum; |
90 | int startIDnumlen; | 90 | int startIDnumlen; |
91 | int startID; | 91 | int startID; |
92 | int lenID; | 92 | int lenID; |
93 | int startCsum; | 93 | int startCsum; |
94 | int lenCsum; | 94 | int lenCsum; |
95 | int endall; | 95 | int endall; |
96 | QString idval = ""; | 96 | QString idval = ""; |
97 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) | 97 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) |
98 | idval = idString.mid( startCsum, lenCsum ); | 98 | idval = idString.mid( startCsum, lenCsum ); |
99 | 99 | ||
100 | //qDebug("getCsum:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); | 100 | //qDebug("getCsum:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); |
101 | return idval; | 101 | return idval; |
102 | } | 102 | } |
103 | // :profilename;12;id_withLen12;123456: | 103 | // :profilename;12;id_withLen12;123456: |
104 | bool KIdManager::getNumbers (const QString& idString,const QString& prof, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) | 104 | bool KIdManager::getNumbers (const QString& idString,const QString& prof, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) |
105 | { | 105 | { |
106 | startProf = idString.find( ":"+prof+";" ); | 106 | startProf = idString.find( ":"+prof+";" ); |
107 | if ( startProf >= 0 ) { | 107 | if ( startProf >= 0 ) { |
108 | startIDnum = prof.length()+2+startProf; | 108 | startIDnum = prof.length()+2+startProf; |
109 | startID = idString.find( ";", startIDnum ) +1; | 109 | startID = idString.find( ";", startIDnum ) +1; |
110 | startIDnumlen = startID - startIDnum - 1; | 110 | startIDnumlen = startID - startIDnum - 1; |
111 | if ( startIDnum > 0 ) { | 111 | if ( startIDnum > 0 ) { |
112 | bool ok; | 112 | bool ok; |
113 | lenID = idString.mid ( startIDnum,startIDnumlen).toInt( &ok ); | 113 | lenID = idString.mid ( startIDnum,startIDnumlen).toInt( &ok ); |
114 | if (ok) { | 114 | if (ok) { |
115 | startCsum = startID+lenID+1; | 115 | startCsum = startID+lenID+1; |
116 | endall = idString.find( ":", startCsum )-1; | 116 | endall = idString.find( ":", startCsum )-1; |
117 | if ( endall < 0 ) { | 117 | if ( endall < 0 ) { |
118 | qDebug("Error getNumbers: andall not found "); | 118 | qDebug("Error getNumbers: andall not found "); |
119 | return false; | 119 | return false; |
120 | } | 120 | } |
121 | lenCsum = endall-startCsum+1; | 121 | lenCsum = endall-startCsum+1; |
122 | } | 122 | } |
123 | else { | 123 | else { |
124 | qDebug("Error getNumbers:length is no number:*%s* ", idString.mid ( startIDnum,startIDnumlen).toInt( &ok )); | 124 | qDebug("Error getNumbers:length is no number:*%s* ", idString.mid ( startIDnum,startIDnumlen).latin1()); |
125 | return false; | 125 | return false; |
126 | } | 126 | } |
127 | } else { | 127 | } else { |
128 | qDebug("Error in KIdManager::getNumbers.startIDnum <= 0"); | 128 | qDebug("Error in KIdManager::getNumbers.startIDnum <= 0"); |
129 | return false; | 129 | return false; |
130 | } | 130 | } |
131 | } else { | 131 | } else { |
132 | //qDebug("getnumbers: profile not found *%s* ",prof.latin1() ); | 132 | //qDebug("getnumbers: profile not found *%s* ",prof.latin1() ); |
133 | return false; | 133 | return false; |
134 | } | 134 | } |
135 | return true; | 135 | return true; |
136 | } | 136 | } |
diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp index 5bd9eb7..566b8f4 100644 --- a/microkde/kresources/managerimpl.cpp +++ b/microkde/kresources/managerimpl.cpp | |||
@@ -1,374 +1,374 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkresources. | 2 | This file is part of libkresources. |
3 | 3 | ||
4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> | 5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> |
6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
7 | 7 | ||
8 | This library is free software; you can redistribute it and/or | 8 | This library is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU Library General Public | 9 | modify it under the terms of the GNU Library General Public |
10 | License as published by the Free Software Foundation; either | 10 | License as published by the Free Software Foundation; either |
11 | version 2 of the License, or (at your option) any later version. | 11 | version 2 of the License, or (at your option) any later version. |
12 | 12 | ||
13 | This library is distributed in the hope that it will be useful, | 13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. | 16 | Library General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU Library General Public License | 18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to | 19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. | 21 | Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | 32 | ||
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <kconfig.h> | 35 | #include <kconfig.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | #include <qfile.h> | 37 | #include <qfile.h> |
38 | 38 | ||
39 | #include "resource.h" | 39 | #include "resource.h" |
40 | #include "factory.h" | 40 | #include "factory.h" |
41 | #include "managerimpl.h" | 41 | #include "managerimpl.h" |
42 | 42 | ||
43 | using namespace KRES; | 43 | using namespace KRES; |
44 | 44 | ||
45 | ManagerImpl::ManagerImpl( const QString &family ) | 45 | ManagerImpl::ManagerImpl( const QString &family ) |
46 | : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ), | 46 | : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ), |
47 | mFactory( 0 ) | 47 | mFactory( 0 ) |
48 | 48 | ||
49 | { | 49 | { |
50 | kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl; | 50 | kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl; |
51 | 51 | ||
52 | 52 | ||
53 | } | 53 | } |
54 | 54 | ||
55 | ManagerImpl::~ManagerImpl() | 55 | ManagerImpl::~ManagerImpl() |
56 | { | 56 | { |
57 | kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl; | 57 | kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl; |
58 | 58 | ||
59 | Resource::List::ConstIterator it; | 59 | Resource::List::ConstIterator it; |
60 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { | 60 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { |
61 | delete *it; | 61 | delete *it; |
62 | } | 62 | } |
63 | 63 | ||
64 | delete mStdConfig; | 64 | delete mStdConfig; |
65 | } | 65 | } |
66 | 66 | ||
67 | void ManagerImpl::createStandardConfig() | 67 | void ManagerImpl::createStandardConfig() |
68 | { | 68 | { |
69 | if ( !mStdConfig ) { | 69 | if ( !mStdConfig ) { |
70 | QString file = locateLocal( "data", KGlobal::getAppName() | 70 | QString file = locateLocal( "data", KGlobal::getAppName() |
71 | + "/kresources/" + mFamily + "rc" ); | 71 | + "/kresources/" + mFamily + "rc" ); |
72 | if ( mFamily == "tmpcontact" ) { | 72 | if ( mFamily == "tmpcontact" ) { |
73 | if (QFile::exists ( file ) ){ | 73 | if (QFile::exists ( file ) ){ |
74 | QFile::remove ( file ); | 74 | QFile::remove ( file ); |
75 | qDebug("removed tmp rc file: %s ", file.latin1()); | 75 | qDebug("removed tmp rc file: %s ", file.latin1()); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | mStdConfig = new KConfig( file ); | 78 | mStdConfig = new KConfig( file ); |
79 | } | 79 | } |
80 | 80 | ||
81 | mConfig = mStdConfig; | 81 | mConfig = mStdConfig; |
82 | } | 82 | } |
83 | 83 | ||
84 | void ManagerImpl::readConfig( KConfig *cfg ) | 84 | void ManagerImpl::readConfig( KConfig *cfg ) |
85 | { | 85 | { |
86 | kdDebug(5650) << "ManagerImpl::readConfig()" << endl; | 86 | kdDebug(5650) << "ManagerImpl::readConfig()" << endl; |
87 | 87 | ||
88 | delete mFactory; | 88 | delete mFactory; |
89 | mFactory = Factory::self( mFamily ); | 89 | mFactory = Factory::self( mFamily ); |
90 | 90 | ||
91 | if ( !cfg ) { | 91 | if ( !cfg ) { |
92 | createStandardConfig(); | 92 | createStandardConfig(); |
93 | } else { | 93 | } else { |
94 | mConfig = cfg; | 94 | mConfig = cfg; |
95 | } | 95 | } |
96 | 96 | ||
97 | mStandard = 0; | 97 | mStandard = 0; |
98 | 98 | ||
99 | mConfig->setGroup( "General" ); | 99 | mConfig->setGroup( "General" ); |
100 | 100 | ||
101 | QStringList keys = mConfig->readListEntry( "ResourceKeys" ); | 101 | QStringList keys = mConfig->readListEntry( "ResourceKeys" ); |
102 | keys += mConfig->readListEntry( "PassiveResourceKeys" ); | 102 | keys += mConfig->readListEntry( "PassiveResourceKeys" ); |
103 | 103 | ||
104 | QString standardKey = mConfig->readEntry( "Standard" ); | 104 | QString standardKey = mConfig->readEntry( "Standard" ); |
105 | 105 | ||
106 | for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) { | 106 | for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) { |
107 | readResourceConfig( *it, false ); | 107 | readResourceConfig( *it, false ); |
108 | } | 108 | } |
109 | 109 | ||
110 | } | 110 | } |
111 | 111 | ||
112 | void ManagerImpl::writeConfig( KConfig *cfg ) | 112 | void ManagerImpl::writeConfig( KConfig *cfg ) |
113 | { | 113 | { |
114 | //USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg); | 114 | //USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg); |
115 | 115 | ||
116 | 116 | ||
117 | kdDebug(5650) << "ManagerImpl::writeConfig()" << endl; | 117 | kdDebug(5650) << "ManagerImpl::writeConfig()" << endl; |
118 | 118 | ||
119 | if ( !cfg ) { | 119 | if ( !cfg ) { |
120 | createStandardConfig(); | 120 | createStandardConfig(); |
121 | } else { | 121 | } else { |
122 | mConfig = cfg; | 122 | mConfig = cfg; |
123 | } | 123 | } |
124 | 124 | ||
125 | QStringList activeKeys; | 125 | QStringList activeKeys; |
126 | QStringList passiveKeys; | 126 | QStringList passiveKeys; |
127 | 127 | ||
128 | // First write all keys, collect active and passive keys on the way | 128 | // First write all keys, collect active and passive keys on the way |
129 | Resource::List::Iterator it; | 129 | Resource::List::Iterator it; |
130 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { | 130 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { |
131 | writeResourceConfig( *it, false ); | 131 | writeResourceConfig( *it, false ); |
132 | 132 | ||
133 | QString key = (*it)->identifier(); | 133 | QString key = (*it)->identifier(); |
134 | if( (*it)->isActive() ) | 134 | if( (*it)->isActive() ) |
135 | activeKeys.append( key ); | 135 | activeKeys.append( key ); |
136 | else | 136 | else |
137 | passiveKeys.append( key ); | 137 | passiveKeys.append( key ); |
138 | } | 138 | } |
139 | 139 | ||
140 | // And then the general group | 140 | // And then the general group |
141 | 141 | ||
142 | kdDebug(5650) << "Saving general info" << endl; | 142 | kdDebug(5650) << "Saving general info" << endl; |
143 | mConfig->setGroup( "General" ); | 143 | mConfig->setGroup( "General" ); |
144 | mConfig->writeEntry( "ResourceKeys", activeKeys ); | 144 | mConfig->writeEntry( "ResourceKeys", activeKeys ); |
145 | mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); | 145 | mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); |
146 | if ( mStandard ) | 146 | if ( mStandard ) |
147 | mConfig->writeEntry( "Standard", mStandard->identifier() ); | 147 | mConfig->writeEntry( "Standard", mStandard->identifier() ); |
148 | else | 148 | else |
149 | mConfig->writeEntry( "Standard", "" ); | 149 | mConfig->writeEntry( "Standard", "" ); |
150 | 150 | ||
151 | mConfig->sync(); | 151 | mConfig->sync(); |
152 | kdDebug(5650) << "ManagerImpl::save() finished" << endl; | 152 | kdDebug(5650) << "ManagerImpl::save() finished" << endl; |
153 | 153 | ||
154 | //US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg); | 154 | //US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg); |
155 | 155 | ||
156 | } | 156 | } |
157 | 157 | ||
158 | void ManagerImpl::add( Resource *resource, bool useDCOP ) | 158 | void ManagerImpl::add( Resource *resource, bool useDCOP ) |
159 | { | 159 | { |
160 | qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource); | 160 | //qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource); |
161 | 161 | ||
162 | resource->setActive( true ); | 162 | resource->setActive( true ); |
163 | 163 | ||
164 | if ( mResources.isEmpty() ) { | 164 | if ( mResources.isEmpty() ) { |
165 | mStandard = resource; | 165 | mStandard = resource; |
166 | } | 166 | } |
167 | 167 | ||
168 | mResources.append( resource ); | 168 | mResources.append( resource ); |
169 | 169 | ||
170 | writeResourceConfig( resource, true ); | 170 | writeResourceConfig( resource, true ); |
171 | 171 | ||
172 | qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource); | 172 | //qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource); |
173 | 173 | ||
174 | } | 174 | } |
175 | 175 | ||
176 | void ManagerImpl::remove( Resource *resource, bool useDCOP ) | 176 | void ManagerImpl::remove( Resource *resource, bool useDCOP ) |
177 | { | 177 | { |
178 | if ( mStandard == resource ) mStandard = 0; | 178 | if ( mStandard == resource ) mStandard = 0; |
179 | removeResource( resource ); | 179 | removeResource( resource ); |
180 | 180 | ||
181 | mResources.remove( resource ); | 181 | mResources.remove( resource ); |
182 | 182 | ||
183 | delete resource; | 183 | delete resource; |
184 | 184 | ||
185 | kdDebug(5650) << "Finished ManagerImpl::remove()" << endl; | 185 | kdDebug(5650) << "Finished ManagerImpl::remove()" << endl; |
186 | } | 186 | } |
187 | 187 | ||
188 | void ManagerImpl::setActive( Resource *resource, bool active ) | 188 | void ManagerImpl::setActive( Resource *resource, bool active ) |
189 | { | 189 | { |
190 | if ( resource && resource->isActive() != active ) { | 190 | if ( resource && resource->isActive() != active ) { |
191 | resource->setActive( active ); | 191 | resource->setActive( active ); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | Resource *ManagerImpl::standardResource() | 195 | Resource *ManagerImpl::standardResource() |
196 | { | 196 | { |
197 | return mStandard; | 197 | return mStandard; |
198 | } | 198 | } |
199 | 199 | ||
200 | void ManagerImpl::setStandardResource( Resource *resource ) | 200 | void ManagerImpl::setStandardResource( Resource *resource ) |
201 | { | 201 | { |
202 | mStandard = resource; | 202 | mStandard = resource; |
203 | } | 203 | } |
204 | 204 | ||
205 | void ManagerImpl::resourceChanged( Resource *resource ) | 205 | void ManagerImpl::resourceChanged( Resource *resource ) |
206 | { | 206 | { |
207 | writeResourceConfig( resource, true ); | 207 | writeResourceConfig( resource, true ); |
208 | 208 | ||
209 | 209 | ||
210 | // ManagerIface_stub allManagers( "*", "ManagerIface_" + mFamily.utf8() ); | 210 | // ManagerIface_stub allManagers( "*", "ManagerIface_" + mFamily.utf8() ); |
211 | // allManagers.dcopResourceModified( resource->identifier() ); | 211 | // allManagers.dcopResourceModified( resource->identifier() ); |
212 | } | 212 | } |
213 | 213 | ||
214 | // DCOP asynchronous functions | 214 | // DCOP asynchronous functions |
215 | //US since we work from inside the application, we call the methods directly. | 215 | //US since we work from inside the application, we call the methods directly. |
216 | 216 | ||
217 | QStringList ManagerImpl::resourceNames() | 217 | QStringList ManagerImpl::resourceNames() |
218 | { | 218 | { |
219 | QStringList result; | 219 | QStringList result; |
220 | 220 | ||
221 | Resource::List::ConstIterator it; | 221 | Resource::List::ConstIterator it; |
222 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { | 222 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { |
223 | result.append( (*it)->resourceName() ); | 223 | result.append( (*it)->resourceName() ); |
224 | } | 224 | } |
225 | return result; | 225 | return result; |
226 | } | 226 | } |
227 | 227 | ||
228 | Resource::List *ManagerImpl::resourceList() | 228 | Resource::List *ManagerImpl::resourceList() |
229 | { | 229 | { |
230 | return &mResources; | 230 | return &mResources; |
231 | } | 231 | } |
232 | 232 | ||
233 | QPtrList<Resource> ManagerImpl::resources() | 233 | QPtrList<Resource> ManagerImpl::resources() |
234 | { | 234 | { |
235 | QPtrList<Resource> result; | 235 | QPtrList<Resource> result; |
236 | 236 | ||
237 | Resource::List::ConstIterator it; | 237 | Resource::List::ConstIterator it; |
238 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { | 238 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { |
239 | result.append( *it ); | 239 | result.append( *it ); |
240 | } | 240 | } |
241 | return result; | 241 | return result; |
242 | } | 242 | } |
243 | 243 | ||
244 | QPtrList<Resource> ManagerImpl::resources( bool active ) | 244 | QPtrList<Resource> ManagerImpl::resources( bool active ) |
245 | { | 245 | { |
246 | QPtrList<Resource> result; | 246 | QPtrList<Resource> result; |
247 | 247 | ||
248 | Resource::List::ConstIterator it; | 248 | Resource::List::ConstIterator it; |
249 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { | 249 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { |
250 | if ( (*it)->isActive() == active ) { | 250 | if ( (*it)->isActive() == active ) { |
251 | result.append( *it ); | 251 | result.append( *it ); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | return result; | 254 | return result; |
255 | } | 255 | } |
256 | 256 | ||
257 | void ManagerImpl::setListener( ManagerImplListener *listener ) | 257 | void ManagerImpl::setListener( ManagerImplListener *listener ) |
258 | { | 258 | { |
259 | mListener = listener; | 259 | mListener = listener; |
260 | } | 260 | } |
261 | 261 | ||
262 | Resource* ManagerImpl::readResourceConfig( const QString& identifier, | 262 | Resource* ManagerImpl::readResourceConfig( const QString& identifier, |
263 | bool checkActive ) | 263 | bool checkActive ) |
264 | { | 264 | { |
265 | kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; | 265 | kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; |
266 | 266 | ||
267 | // qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); | 267 | // qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); |
268 | 268 | ||
269 | mConfig->setGroup( "Resource_" + identifier ); | 269 | mConfig->setGroup( "Resource_" + identifier ); |
270 | #ifdef _WIN32_ | 270 | #ifdef _WIN32_ |
271 | // we use plugins on win32. the group is stored in a static variable | 271 | // we use plugins on win32. the group is stored in a static variable |
272 | // such that gourp info not avail on win32 plugins | 272 | // such that gourp info not avail on win32 plugins |
273 | // to fix that, it would be a looooot of work | 273 | // to fix that, it would be a looooot of work |
274 | mConfig->setTempGroup( "Resource_" + identifier ); | 274 | mConfig->setTempGroup( "Resource_" + identifier ); |
275 | #endif | 275 | #endif |
276 | QString type = mConfig->readEntry( "ResourceType" ); | 276 | QString type = mConfig->readEntry( "ResourceType" ); |
277 | QString name = mConfig->readEntry( "ResourceName" ); | 277 | QString name = mConfig->readEntry( "ResourceName" ); |
278 | Resource *resource = mFactory->resource( type, mConfig ); | 278 | Resource *resource = mFactory->resource( type, mConfig ); |
279 | if ( !resource ) { | 279 | if ( !resource ) { |
280 | qDebug("Failed to create resource with id %s ",identifier.latin1() ); | 280 | qDebug("Failed to create resource with id %s ",identifier.latin1() ); |
281 | return 0; | 281 | return 0; |
282 | } | 282 | } |
283 | 283 | ||
284 | if ( resource->identifier().isEmpty() ) | 284 | if ( resource->identifier().isEmpty() ) |
285 | resource->setIdentifier( identifier ); | 285 | resource->setIdentifier( identifier ); |
286 | 286 | ||
287 | mConfig->setGroup( "General" ); | 287 | mConfig->setGroup( "General" ); |
288 | 288 | ||
289 | QString standardKey = mConfig->readEntry( "Standard" ); | 289 | QString standardKey = mConfig->readEntry( "Standard" ); |
290 | if ( standardKey == identifier ) { | 290 | if ( standardKey == identifier ) { |
291 | mStandard = resource; | 291 | mStandard = resource; |
292 | } | 292 | } |
293 | 293 | ||
294 | if ( checkActive ) { | 294 | if ( checkActive ) { |
295 | QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); | 295 | QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); |
296 | resource->setActive( activeKeys.contains( identifier ) ); | 296 | resource->setActive( activeKeys.contains( identifier ) ); |
297 | } | 297 | } |
298 | mResources.append( resource ); | 298 | mResources.append( resource ); |
299 | 299 | ||
300 | return resource; | 300 | return resource; |
301 | } | 301 | } |
302 | 302 | ||
303 | void ManagerImpl::writeResourceConfig( Resource *resource, | 303 | void ManagerImpl::writeResourceConfig( Resource *resource, |
304 | bool checkActive ) | 304 | bool checkActive ) |
305 | { | 305 | { |
306 | QString key = resource->identifier(); | 306 | QString key = resource->identifier(); |
307 | 307 | ||
308 | kdDebug(5650) << "Saving resource " << key << endl; | 308 | kdDebug(5650) << "Saving resource " << key << endl; |
309 | 309 | ||
310 | if ( !mConfig ) createStandardConfig(); | 310 | if ( !mConfig ) createStandardConfig(); |
311 | 311 | ||
312 | mConfig->setGroup( "Resource_" + key ); | 312 | mConfig->setGroup( "Resource_" + key ); |
313 | resource->writeConfig( mConfig ); | 313 | resource->writeConfig( mConfig ); |
314 | 314 | ||
315 | mConfig->setGroup( "General" ); | 315 | mConfig->setGroup( "General" ); |
316 | QString standardKey = mConfig->readEntry( "Standard" ); | 316 | QString standardKey = mConfig->readEntry( "Standard" ); |
317 | 317 | ||
318 | if ( resource == mStandard && standardKey != key ) | 318 | if ( resource == mStandard && standardKey != key ) |
319 | mConfig->writeEntry( "Standard", resource->identifier() ); | 319 | mConfig->writeEntry( "Standard", resource->identifier() ); |
320 | else if ( resource != mStandard && standardKey == key ) | 320 | else if ( resource != mStandard && standardKey == key ) |
321 | mConfig->writeEntry( "Standard", "" ); | 321 | mConfig->writeEntry( "Standard", "" ); |
322 | 322 | ||
323 | if ( checkActive ) { | 323 | if ( checkActive ) { |
324 | QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); | 324 | QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); |
325 | if ( resource->isActive() && !activeKeys.contains( key ) ) { | 325 | if ( resource->isActive() && !activeKeys.contains( key ) ) { |
326 | activeKeys.append( resource->identifier() ); | 326 | activeKeys.append( resource->identifier() ); |
327 | mConfig->writeEntry( "ResourceKeys", activeKeys ); | 327 | mConfig->writeEntry( "ResourceKeys", activeKeys ); |
328 | } else if ( !resource->isActive() && activeKeys.contains( key ) ) { | 328 | } else if ( !resource->isActive() && activeKeys.contains( key ) ) { |
329 | activeKeys.remove( key ); | 329 | activeKeys.remove( key ); |
330 | mConfig->writeEntry( "ResourceKeys", activeKeys ); | 330 | mConfig->writeEntry( "ResourceKeys", activeKeys ); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | mConfig->sync(); | 334 | mConfig->sync(); |
335 | } | 335 | } |
336 | 336 | ||
337 | void ManagerImpl::removeResource( Resource *resource ) | 337 | void ManagerImpl::removeResource( Resource *resource ) |
338 | { | 338 | { |
339 | QString key = resource->identifier(); | 339 | QString key = resource->identifier(); |
340 | 340 | ||
341 | if ( !mConfig ) createStandardConfig(); | 341 | if ( !mConfig ) createStandardConfig(); |
342 | 342 | ||
343 | mConfig->setGroup( "General" ); | 343 | mConfig->setGroup( "General" ); |
344 | QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); | 344 | QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); |
345 | if ( activeKeys.contains( key ) ) { | 345 | if ( activeKeys.contains( key ) ) { |
346 | activeKeys.remove( key ); | 346 | activeKeys.remove( key ); |
347 | mConfig->writeEntry( "ResourceKeys", activeKeys ); | 347 | mConfig->writeEntry( "ResourceKeys", activeKeys ); |
348 | } else { | 348 | } else { |
349 | QStringList passiveKeys = mConfig->readListEntry( "PassiveResourceKeys" ); | 349 | QStringList passiveKeys = mConfig->readListEntry( "PassiveResourceKeys" ); |
350 | passiveKeys.remove( key ); | 350 | passiveKeys.remove( key ); |
351 | mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); | 351 | mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); |
352 | } | 352 | } |
353 | 353 | ||
354 | QString standardKey = mConfig->readEntry( "Standard" ); | 354 | QString standardKey = mConfig->readEntry( "Standard" ); |
355 | if ( standardKey == key ) { | 355 | if ( standardKey == key ) { |
356 | mConfig->writeEntry( "Standard", "" ); | 356 | mConfig->writeEntry( "Standard", "" ); |
357 | } | 357 | } |
358 | 358 | ||
359 | mConfig->deleteGroup( "Resource_" + resource->identifier() ); | 359 | mConfig->deleteGroup( "Resource_" + resource->identifier() ); |
360 | 360 | ||
361 | mConfig->sync(); | 361 | mConfig->sync(); |
362 | } | 362 | } |
363 | 363 | ||
364 | Resource* ManagerImpl::getResource( const QString& identifier ) | 364 | Resource* ManagerImpl::getResource( const QString& identifier ) |
365 | { | 365 | { |
366 | Resource::List::ConstIterator it; | 366 | Resource::List::ConstIterator it; |
367 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { | 367 | for ( it = mResources.begin(); it != mResources.end(); ++it ) { |
368 | if ( (*it)->identifier() == identifier ) | 368 | if ( (*it)->identifier() == identifier ) |
369 | return *it; | 369 | return *it; |
370 | } | 370 | } |
371 | return 0; | 371 | return 0; |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||