summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-07-09 08:02:25 (UTC)
committer ulf69 <ulf69>2004-07-09 08:02:25 (UTC)
commitd91c533ffc42d7bf48fa1326754894b2c30b6831 (patch) (unidiff)
treeba1eada897522030f17ccdf1afd4d4d96a65464e
parent82dabc14cc446fb8c0486cd4c32064e3866d2be9 (diff)
downloadkdepimpi-d91c533ffc42d7bf48fa1326754894b2c30b6831.zip
kdepimpi-d91c533ffc42d7bf48fa1326754894b2c30b6831.tar.gz
kdepimpi-d91c533ffc42d7bf48fa1326754894b2c30b6831.tar.bz2
changed the IntDateFormat from type int to enum, for easier categorization
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditordialog.cpp1
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp6
-rw-r--r--korganizer/calendarview.cpp2
-rw-r--r--korganizer/kowhatsnextview.cpp10
-rw-r--r--microkde/kdecore/klocale.cpp39
-rw-r--r--microkde/kdecore/klocale.h14
6 files changed, 33 insertions, 39 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp
index d8c1aca..5e42640 100644
--- a/kaddressbook/addresseeeditordialog.cpp
+++ b/kaddressbook/addresseeeditordialog.cpp
@@ -1,122 +1,121 @@
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#include <qlayout.h> 24#include <qlayout.h>
25#include <qapplication.h> 25#include <qapplication.h>
26 26
27#include <kdebug.h> 27#include <kdebug.h>
28#include <klocale.h> 28#include <klocale.h>
29#include <kglobal.h> 29#include <kglobal.h>
30 30
31#include "addresseeeditorwidget.h" 31#include "addresseeeditorwidget.h"
32#include "kabcore.h" 32#include "kabcore.h"
33 33
34#include "addresseeeditordialog.h" 34#include "addresseeeditordialog.h"
35 35
36AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, 36AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent,
37 const char *name ) 37 const char *name )
38 : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), 38 : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ),
39 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, 39 KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply,
40 KDialogBase::Ok, parent, name, true ) 40 KDialogBase::Ok, parent, name, true )
41{ 41{
42 42
43 43
44 QWidget *page = plainPage(); 44 QWidget *page = plainPage();
45 45
46 QVBoxLayout *layout = new QVBoxLayout( page ); 46 QVBoxLayout *layout = new QVBoxLayout( page );
47 47
48 mEditorWidget = new AddresseeEditorWidget( core, false, page ); 48 mEditorWidget = new AddresseeEditorWidget( core, false, page );
49 connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), 49 connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ),
50 SLOT( widgetModified() ) ); 50 SLOT( widgetModified() ) );
51 layout->addWidget( mEditorWidget ); 51 layout->addWidget( mEditorWidget );
52 52
53 enableButton( KDialogBase::Apply, false ); 53 enableButton( KDialogBase::Apply, false );
54 if ( QApplication::desktop()->width() < 480 ) { 54 if ( QApplication::desktop()->width() < 480 ) {
55 hideButtons(); 55 hideButtons();
56 } 56 }
57} 57}
58 58
59AddresseeEditorDialog::~AddresseeEditorDialog() 59AddresseeEditorDialog::~AddresseeEditorDialog()
60{ 60{
61 qDebug("AddresseeEditorDialog::~AddresseeEditorDialog()");
62 //emit editorDestroyed( mEditorWidget->addressee().uid() ); 61 //emit editorDestroyed( mEditorWidget->addressee().uid() );
63} 62}
64 63
65void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) 64void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr )
66{ 65{
67 enableButton( KDialogBase::Apply, false ); 66 enableButton( KDialogBase::Apply, false );
68 67
69 mEditorWidget->setAddressee( addr ); 68 mEditorWidget->setAddressee( addr );
70} 69}
71 70
72KABC::Addressee AddresseeEditorDialog::addressee() 71KABC::Addressee AddresseeEditorDialog::addressee()
73{ 72{
74 return mEditorWidget->addressee(); 73 return mEditorWidget->addressee();
75} 74}
76 75
77bool AddresseeEditorDialog::dirty() 76bool AddresseeEditorDialog::dirty()
78{ 77{
79 return mEditorWidget->dirty(); 78 return mEditorWidget->dirty();
80} 79}
81 80
82void AddresseeEditorDialog::slotApply() 81void AddresseeEditorDialog::slotApply()
83{ 82{
84 if ( mEditorWidget->dirty() ) { 83 if ( mEditorWidget->dirty() ) {
85 mEditorWidget->save(); 84 mEditorWidget->save();
86 emit contactModified( mEditorWidget->addressee() ); 85 emit contactModified( mEditorWidget->addressee() );
87 } 86 }
88 87
89 enableButton( KDialogBase::Apply, false ); 88 enableButton( KDialogBase::Apply, false );
90 89
91 KDialogBase::slotApply(); 90 KDialogBase::slotApply();
92} 91}
93 92
94void AddresseeEditorDialog:: accept () 93void AddresseeEditorDialog:: accept ()
95{ 94{
96 slotOk(); 95 slotOk();
97 96
98} 97}
99void AddresseeEditorDialog::slotOk() 98void AddresseeEditorDialog::slotOk()
100{ 99{
101 slotApply(); 100 slotApply();
102 101
103 //KDialogBase::slotOk(); 102 //KDialogBase::slotOk();
104 emit okClicked(); 103 emit okClicked();
105 QDialog::accept(); 104 QDialog::accept();
106} 105}
107 106
108void AddresseeEditorDialog::widgetModified() 107void AddresseeEditorDialog::widgetModified()
109{ 108{
110 enableButton( KDialogBase::Apply, true ); 109 enableButton( KDialogBase::Apply, true );
111} 110}
112 111
113void AddresseeEditorDialog::slotCancel() 112void AddresseeEditorDialog::slotCancel()
114{ 113{
115 KDialogBase::slotCancel(); 114 KDialogBase::slotCancel();
116 115
117 116
118} 117}
119 118
120#ifndef KAB_EMBEDDED 119#ifndef KAB_EMBEDDED
121#include "addresseeeditordialog.moc" 120#include "addresseeeditordialog.moc"
122#endif //KAB_EMBEDDED 121#endif //KAB_EMBEDDED
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index 4365ee5..3cfc1f2 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -1,1284 +1,1280 @@
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#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qhbox.h> 25#include <qhbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlistbox.h> 28#include <qlistbox.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31 31
32#ifndef KAB_EMBEDDED 32#ifndef KAB_EMBEDDED
33#include <qtextedit.h> 33#include <qtextedit.h>
34 34
35#include <kaccelmanager.h> 35#include <kaccelmanager.h>
36#include "keywidget.h" 36#include "keywidget.h"
37#include "soundwidget.h" 37#include "soundwidget.h"
38 38
39#else //KAB_EMBEDDED 39#else //KAB_EMBEDDED
40#include <qmultilineedit.h> 40#include <qmultilineedit.h>
41#endif //KAB_EMBEDDED 41#endif //KAB_EMBEDDED
42 42
43 43
44#include "keywidget.h" 44#include "keywidget.h"
45#include "geowidget.h" 45#include "geowidget.h"
46#include "imagewidget.h" 46#include "imagewidget.h"
47#include "nameeditdialog.h" 47#include "nameeditdialog.h"
48#include "phoneeditwidget.h" 48#include "phoneeditwidget.h"
49#include "secrecywidget.h" 49#include "secrecywidget.h"
50 50
51 51
52#include <qtoolbutton.h> 52#include <qtoolbutton.h>
53#include <qtooltip.h> 53#include <qtooltip.h>
54 54
55#include <kapplication.h> 55#include <kapplication.h>
56#include <kconfig.h> 56#include <kconfig.h>
57#include <kcombobox.h> 57#include <kcombobox.h>
58#include <kdebug.h> 58#include <kdebug.h>
59#include <kdialogbase.h> 59#include <kdialogbase.h>
60#include <kglobal.h> 60#include <kglobal.h>
61#include <kiconloader.h> 61#include <kiconloader.h>
62#include <klineedit.h> 62#include <klineedit.h>
63#include <klocale.h> 63#include <klocale.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kseparator.h> 65#include <kseparator.h>
66#include <ksqueezedtextlabel.h> 66#include <ksqueezedtextlabel.h>
67 67
68#include <libkdepim/categoryeditdialog.h> 68#include <libkdepim/categoryeditdialog.h>
69#include <libkdepim/categoryselectdialog.h> 69#include <libkdepim/categoryselectdialog.h>
70 70
71#include <libkdepim/kdateedit.h> 71#include <libkdepim/kdateedit.h>
72 72
73#include "addresseditwidget.h" 73#include "addresseditwidget.h"
74#include "emaileditwidget.h" 74#include "emaileditwidget.h"
75#include "kabcore.h" 75#include "kabcore.h"
76#include "kabprefs.h" 76#include "kabprefs.h"
77 77
78#include "addresseeeditorwidget.h" 78#include "addresseeeditorwidget.h"
79 79
80 80
81 81
82AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension, 82AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension,
83 QWidget *parent, const char *name ) 83 QWidget *parent, const char *name )
84 : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ), 84 : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ),
85 mBlockSignals( false ) 85 mBlockSignals( false )
86{ 86{
87 87
88 mAConfig = AddresseeConfig::instance(); 88 mAConfig = AddresseeConfig::instance();
89 89
90 kdDebug(5720) << "AddresseeEditorWidget()" << endl; 90 kdDebug(5720) << "AddresseeEditorWidget()" << endl;
91 mFormattedNameType = NameEditDialog::CustomName; 91 mFormattedNameType = NameEditDialog::CustomName;
92 initGUI(); 92 initGUI();
93 mCategoryDialog = 0; 93 mCategoryDialog = 0;
94 mCategoryEditDialog = 0; 94 mCategoryEditDialog = 0;
95 95
96 // Load the empty addressee as defaults 96 // Load the empty addressee as defaults
97 load(); 97 load();
98 98
99 mDirty = false; 99 mDirty = false;
100} 100}
101 101
102AddresseeEditorWidget::~AddresseeEditorWidget() 102AddresseeEditorWidget::~AddresseeEditorWidget()
103{ 103{
104 kdDebug(5720) << "~AddresseeEditorWidget()" << endl; 104 kdDebug(5720) << "~AddresseeEditorWidget()" << endl;
105} 105}
106 106
107void AddresseeEditorWidget::contactsSelectionChanged() 107void AddresseeEditorWidget::contactsSelectionChanged()
108{ 108{
109 KABC::Addressee::List list = selectedContacts(); 109 KABC::Addressee::List list = selectedContacts();
110 110
111 mAddressee = list[ 0 ]; 111 mAddressee = list[ 0 ];
112 load(); 112 load();
113} 113}
114 114
115void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr ) 115void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr )
116{ 116{
117 mAddressee = addr; 117 mAddressee = addr;
118 load(); 118 load();
119} 119}
120 120
121const KABC::Addressee &AddresseeEditorWidget::addressee() 121const KABC::Addressee &AddresseeEditorWidget::addressee()
122{ 122{
123 return mAddressee; 123 return mAddressee;
124} 124}
125 125
126void AddresseeEditorWidget::textChanged( const QString& ) 126void AddresseeEditorWidget::textChanged( const QString& )
127{ 127{
128 emitModified(); 128 emitModified();
129} 129}
130 130
131void AddresseeEditorWidget::initGUI() 131void AddresseeEditorWidget::initGUI()
132{ 132{
133 QVBoxLayout *layout = new QVBoxLayout( this ); 133 QVBoxLayout *layout = new QVBoxLayout( this );
134 134
135 mTabWidget = new QTabWidget( this ); 135 mTabWidget = new QTabWidget( this );
136 layout->addWidget( mTabWidget ); 136 layout->addWidget( mTabWidget );
137 137
138 setupTab1(); 138 setupTab1();
139 setupTab1_1(); 139 setupTab1_1();
140 setupTab2(); 140 setupTab2();
141 setupTab2_1(); 141 setupTab2_1();
142 setupTab3(); 142 setupTab3();
143 setupTab3_1(); 143 setupTab3_1();
144 144
145 mNameEdit->setFocus(); 145 mNameEdit->setFocus();
146 146
147 connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ), 147 connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ),
148 SLOT( pageChanged(QWidget*) ) ); 148 SLOT( pageChanged(QWidget*) ) );
149} 149}
150 150
151void AddresseeEditorWidget::setupTab1() 151void AddresseeEditorWidget::setupTab1()
152{ 152{
153 // This is the General tab 153 // This is the General tab
154 QWidget *tab1 = new QWidget( mTabWidget ); 154 QWidget *tab1 = new QWidget( mTabWidget );
155 155
156//US QGridLayout *layout = new QGridLayout( tab1, 11, 7 ); 156//US QGridLayout *layout = new QGridLayout( tab1, 11, 7 );
157 QGridLayout *layout = new QGridLayout( tab1, 7, 1 ); 157 QGridLayout *layout = new QGridLayout( tab1, 7, 1 );
158 layout->setMargin( KDialogBase::marginHintSmall() ); 158 layout->setMargin( KDialogBase::marginHintSmall() );
159 layout->setSpacing( KDialogBase::spacingHintSmall() ); 159 layout->setSpacing( KDialogBase::spacingHintSmall() );
160 160
161 QLabel *label; 161 QLabel *label;
162 KSeparator* bar; 162 KSeparator* bar;
163 QPushButton *button; 163 QPushButton *button;
164 164
165 ////////////////////////////////// 165 //////////////////////////////////
166 // Upper left group (person info) 166 // Upper left group (person info)
167 167
168 // Person icon 168 // Person icon
169 /* LR 169 /* LR
170 label = new QLabel( tab1 ); 170 label = new QLabel( tab1 );
171//US ambiguous call. Add one more parameter 171//US ambiguous call. Add one more parameter
172//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 172//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
173 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 173 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
174 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 174 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
175 */ 175 */
176 // First name 176 // First name
177 button = new QPushButton( i18n( "Name..." ), tab1 ); 177 button = new QPushButton( i18n( "Name..." ), tab1 );
178//US QToolTip::add( button, i18n( "Edit the contact's name" ) ); 178//US QToolTip::add( button, i18n( "Edit the contact's name" ) );
179 mNameEdit = new KLineEdit( tab1, "mNameEdit" ); 179 mNameEdit = new KLineEdit( tab1, "mNameEdit" );
180 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), 180 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
181 SLOT( nameTextChanged( const QString& ) ) ); 181 SLOT( nameTextChanged( const QString& ) ) );
182 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); 182 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) );
183 183
184 mNameLabel = new KSqueezedTextLabel( tab1 ); 184 mNameLabel = new KSqueezedTextLabel( tab1 );
185 mNameLabel->hide(); 185 mNameLabel->hide();
186 186
187 layout->addWidget( button, 0, 0 ); 187 layout->addWidget( button, 0, 0 );
188 layout->addWidget( mNameEdit, 0, 1 ); 188 layout->addWidget( mNameEdit, 0, 1 );
189 layout->addWidget( mNameLabel, 0, 1 ); 189 layout->addWidget( mNameLabel, 0, 1 );
190 190
191 label = new QLabel( i18n( "Role:" ), tab1 ); 191 label = new QLabel( i18n( "Role:" ), tab1 );
192 mRoleEdit = new KLineEdit( tab1 ); 192 mRoleEdit = new KLineEdit( tab1 );
193 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), 193 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ),
194 SLOT( textChanged( const QString& ) ) ); 194 SLOT( textChanged( const QString& ) ) );
195 label->setBuddy( mRoleEdit ); 195 label->setBuddy( mRoleEdit );
196 layout->addWidget( label, 1, 0 ); 196 layout->addWidget( label, 1, 0 );
197 layout->addWidget( mRoleEdit, 1, 1 ); 197 layout->addWidget( mRoleEdit, 1, 1 );
198 198
199 // Organization 199 // Organization
200 label = new QLabel( i18n( "Organization:" ), tab1 ); 200 label = new QLabel( i18n( "Organization:" ), tab1 );
201 mOrgEdit = new KLineEdit( tab1 ); 201 mOrgEdit = new KLineEdit( tab1 );
202 label->setBuddy( mOrgEdit ); 202 label->setBuddy( mOrgEdit );
203 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), 203 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ),
204 SLOT( textChanged( const QString& ) ) ); 204 SLOT( textChanged( const QString& ) ) );
205 layout->addWidget( label, 2, 0 ); 205 layout->addWidget( label, 2, 0 );
206 layout->addWidget( mOrgEdit, 2, 1 ); 206 layout->addWidget( mOrgEdit, 2, 1 );
207 207
208 // File as (formatted name) 208 // File as (formatted name)
209 label = new QLabel( i18n( "Formatted name:" ), tab1 ); 209 label = new QLabel( i18n( "Formatted name:" ), tab1 );
210 mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); 210 mFormattedNameLabel = new KSqueezedTextLabel( tab1 );
211 layout->addWidget( label, 3, 0 ); 211 layout->addWidget( label, 3, 0 );
212 layout->addWidget( mFormattedNameLabel, 3, 1 ); 212 layout->addWidget( mFormattedNameLabel, 3, 1 );
213 /* LR 213 /* LR
214 // Left hand separator. This separator doesn't go all the way 214 // Left hand separator. This separator doesn't go all the way
215 // across so the dialog still flows from top to bottom 215 // across so the dialog still flows from top to bottom
216 bar = new KSeparator( KSeparator::HLine, tab1 ); 216 bar = new KSeparator( KSeparator::HLine, tab1 );
217 layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); 217 layout->addMultiCellWidget( bar, 4, 4, 0, 2 );
218 */ 218 */
219 ////////////////////////////////////// 219 //////////////////////////////////////
220 220
221 /* LR 221 /* LR
222 // Phone numbers (upper right) 222 // Phone numbers (upper right)
223 label = new QLabel( tab1 ); 223 label = new QLabel( tab1 );
224//US loadIcon call is ambiguous. Add one more parameter 224//US loadIcon call is ambiguous. Add one more parameter
225//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); 225//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) );
226 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 226 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
227//US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); 227//US layout->addMultiCellWidget( label, 0, 1, 3, 3 );
228 layout->addMultiCellWidget( label, 5, 6, 0, 0 ); 228 layout->addMultiCellWidget( label, 5, 6, 0, 0 );
229 */ 229 */
230 mPhoneEditWidget = new PhoneEditWidget( tab1 ); 230 mPhoneEditWidget = new PhoneEditWidget( tab1 );
231 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 231 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
232//US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); 232//US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 );
233 int iii; 233 int iii;
234#ifndef DESKTOP_VERSION 234#ifndef DESKTOP_VERSION
235 iii = 7; 235 iii = 7;
236#else 236#else
237 iii = 8; 237 iii = 8;
238#endif 238#endif
239 layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, 1 ); 239 layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, 1 );
240 ++iii; 240 ++iii;
241 /* LR 241 /* LR
242 bar = new KSeparator( KSeparator::HLine, tab1 ); 242 bar = new KSeparator( KSeparator::HLine, tab1 );
243//US layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); 243//US layout->addMultiCellWidget( bar, 4, 4, 3, 6 );
244 layout->addMultiCellWidget( bar, 9, 9, 0, 2 ); 244 layout->addMultiCellWidget( bar, 9, 9, 0, 2 );
245 */ 245 */
246/*US 246/*US
247 ////////////////////////////////////// 247 //////////////////////////////////////
248 // Addresses (lower left) 248 // Addresses (lower left)
249 label = new QLabel( tab1 ); 249 label = new QLabel( tab1 );
250//US loadIcon call is ambiguous. Add one more parameter 250//US loadIcon call is ambiguous. Add one more parameter
251//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); 251//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) );
252 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); 252 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) );
253 layout->addMultiCellWidget( label, 5, 6, 0, 0 ); 253 layout->addMultiCellWidget( label, 5, 6, 0, 0 );
254 254
255 mAddressEditWidget = new AddressEditWidget( tab1 ); 255 mAddressEditWidget = new AddressEditWidget( tab1 );
256 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 256 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
257 layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); 257 layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 );
258 258
259 ////////////////////////////////////// 259 //////////////////////////////////////
260 // Email / Web (lower right) 260 // Email / Web (lower right)
261 label = new QLabel( tab1 ); 261 label = new QLabel( tab1 );
262//US loadIcon call is ambiguous. Add one more parameter 262//US loadIcon call is ambiguous. Add one more parameter
263//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); 263//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) );
264 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); 264 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) );
265 layout->addMultiCellWidget( label, 5, 6, 3, 3 ); 265 layout->addMultiCellWidget( label, 5, 6, 3, 3 );
266 266
267 mEmailWidget = new EmailEditWidget( tab1 ); 267 mEmailWidget = new EmailEditWidget( tab1 );
268 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 268 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
269 layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); 269 layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 );
270 270
271 // add the separator 271 // add the separator
272 bar = new KSeparator( KSeparator::HLine, tab1 ); 272 bar = new KSeparator( KSeparator::HLine, tab1 );
273 layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); 273 layout->addMultiCellWidget( bar, 7, 7, 3, 6 );
274 274
275 label = new QLabel( tab1 ); 275 label = new QLabel( tab1 );
276//US loadIcon call is ambiguous. Add one more parameter 276//US loadIcon call is ambiguous. Add one more parameter
277//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); 277//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) );
278 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); 278 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) );
279 layout->addMultiCellWidget( label, 8, 9, 3, 3 ); 279 layout->addMultiCellWidget( label, 8, 9, 3, 3 );
280 280
281 label = new QLabel( i18n( "URL:" ), tab1 ); 281 label = new QLabel( i18n( "URL:" ), tab1 );
282 mURLEdit = new KLineEdit( tab1 ); 282 mURLEdit = new KLineEdit( tab1 );
283 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), 283 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ),
284 SLOT( textChanged( const QString& ) ) ); 284 SLOT( textChanged( const QString& ) ) );
285 label->setBuddy( mURLEdit ); 285 label->setBuddy( mURLEdit );
286 layout->addWidget( label, 8, 4 ); 286 layout->addWidget( label, 8, 4 );
287 layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); 287 layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 );
288 288
289 label = new QLabel( i18n( "&IM address:" ), tab1 ); 289 label = new QLabel( i18n( "&IM address:" ), tab1 );
290 mIMAddressEdit = new KLineEdit( tab1 ); 290 mIMAddressEdit = new KLineEdit( tab1 );
291 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), 291 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ),
292 SLOT( textChanged( const QString& ) ) ); 292 SLOT( textChanged( const QString& ) ) );
293 label->setBuddy( mIMAddressEdit ); 293 label->setBuddy( mIMAddressEdit );
294 layout->addWidget( label, 9, 4 ); 294 layout->addWidget( label, 9, 4 );
295 layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); 295 layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 );
296 296
297 layout->addColSpacing( 6, 50 ); 297 layout->addColSpacing( 6, 50 );
298 298
299 bar = new KSeparator( KSeparator::HLine, tab1 ); 299 bar = new KSeparator( KSeparator::HLine, tab1 );
300 layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); 300 layout->addMultiCellWidget( bar, 10, 10, 0, 6 );
301*/ 301*/
302 /////////////////////////////////////// 302 ///////////////////////////////////////
303 QHBox *categoryBox = new QHBox( tab1 ); 303 QHBox *categoryBox = new QHBox( tab1 );
304 categoryBox->setSpacing( KDialogBase::spacingHint() ); 304 categoryBox->setSpacing( KDialogBase::spacingHint() );
305 categoryBox->setMargin( KDialogBase::marginHintSmall() ); 305 categoryBox->setMargin( KDialogBase::marginHintSmall() );
306 306
307 // Categories 307 // Categories
308 button = new QPushButton( i18n( "Categories" ), categoryBox ); 308 button = new QPushButton( i18n( "Categories" ), categoryBox );
309 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); 309 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) );
310 310
311 mCategoryEdit = new KLineEdit( categoryBox ); 311 mCategoryEdit = new KLineEdit( categoryBox );
312 mCategoryEdit->setReadOnly( true ); 312 mCategoryEdit->setReadOnly( true );
313 connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), 313 connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ),
314 SLOT( textChanged( const QString& ) ) ); 314 SLOT( textChanged( const QString& ) ) );
315 315
316 mSecrecyWidget = new SecrecyWidget( categoryBox ); 316 mSecrecyWidget = new SecrecyWidget( categoryBox );
317 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 317 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
318 318
319//US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); 319//US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 );
320 layout->addMultiCellWidget( categoryBox, iii, iii, 0, 1 ); 320 layout->addMultiCellWidget( categoryBox, iii, iii, 0, 1 );
321 321
322 // Build the layout and add to the tab widget 322 // Build the layout and add to the tab widget
323 layout->activate(); // required 323 layout->activate(); // required
324 324
325 mTabWidget->addTab( tab1, i18n( "&General" ) ); 325 mTabWidget->addTab( tab1, i18n( "&General" ) );
326} 326}
327 327
328 328
329void AddresseeEditorWidget::setupTab1_1() 329void AddresseeEditorWidget::setupTab1_1()
330{ 330{
331 // This is the Address tab 331 // This is the Address tab
332 QWidget *tab1_1 = new QWidget( mTabWidget ); 332 QWidget *tab1_1 = new QWidget( mTabWidget );
333 333
334//US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 ); 334//US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 );
335 QGridLayout *layout = new QGridLayout( tab1_1, 7, 2 ); 335 QGridLayout *layout = new QGridLayout( tab1_1, 7, 2 );
336 layout->setMargin( KDialogBase::marginHintSmall() ); 336 layout->setMargin( KDialogBase::marginHintSmall() );
337 layout->setSpacing( KDialogBase::spacingHintSmall() ); 337 layout->setSpacing( KDialogBase::spacingHintSmall() );
338 338
339 QLabel *label; 339 QLabel *label;
340 KSeparator* bar; 340 KSeparator* bar;
341 QPushButton *button; 341 QPushButton *button;
342 342
343/*US 343/*US
344 ////////////////////////////////// 344 //////////////////////////////////
345 // Upper left group (person info) 345 // Upper left group (person info)
346 346
347 // Person icon 347 // Person icon
348 label = new QLabel( tab1 ); 348 label = new QLabel( tab1 );
349//US ambiguous call. Add one more parameter 349//US ambiguous call. Add one more parameter
350//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 350//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
351 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 351 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
352 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 352 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
353 353
354 // First name 354 // First name
355 button = new QPushButton( i18n( "Name..." ), tab1 ); 355 button = new QPushButton( i18n( "Name..." ), tab1 );
356 QToolTip::add( button, i18n( "Edit the contact's name" ) ); 356 QToolTip::add( button, i18n( "Edit the contact's name" ) );
357 mNameEdit = new KLineEdit( tab1, "mNameEdit" ); 357 mNameEdit = new KLineEdit( tab1, "mNameEdit" );
358 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), 358 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
359 SLOT( nameTextChanged( const QString& ) ) ); 359 SLOT( nameTextChanged( const QString& ) ) );
360 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); 360 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) );
361 361
362#ifndef KAB_EMBEDDED 362#ifndef KAB_EMBEDDED
363 mNameLabel = new KSqueezedTextLabel( tab1 ); 363 mNameLabel = new KSqueezedTextLabel( tab1 );
364 mNameLabel->hide(); 364 mNameLabel->hide();
365#else //KAB_EMBEDDED 365#else //KAB_EMBEDDED
366qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 366qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
367#endif //KAB_EMBEDDED 367#endif //KAB_EMBEDDED
368 368
369 layout->addWidget( button, 0, 1 ); 369 layout->addWidget( button, 0, 1 );
370 layout->addWidget( mNameEdit, 0, 2 ); 370 layout->addWidget( mNameEdit, 0, 2 );
371 371
372#ifndef KAB_EMBEDDED 372#ifndef KAB_EMBEDDED
373 layout->addWidget( mNameLabel, 0, 2 ); 373 layout->addWidget( mNameLabel, 0, 2 );
374#else //KAB_EMBEDDED 374#else //KAB_EMBEDDED
375qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 375qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
376#endif //KAB_EMBEDDED 376#endif //KAB_EMBEDDED
377 377
378 label = new QLabel( i18n( "Role:" ), tab1 ); 378 label = new QLabel( i18n( "Role:" ), tab1 );
379 mRoleEdit = new KLineEdit( tab1 ); 379 mRoleEdit = new KLineEdit( tab1 );
380 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), 380 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ),
381 SLOT( textChanged( const QString& ) ) ); 381 SLOT( textChanged( const QString& ) ) );
382 label->setBuddy( mRoleEdit ); 382 label->setBuddy( mRoleEdit );
383 layout->addWidget( label, 1, 1 ); 383 layout->addWidget( label, 1, 1 );
384 layout->addWidget( mRoleEdit, 1, 2 ); 384 layout->addWidget( mRoleEdit, 1, 2 );
385 385
386 // Organization 386 // Organization
387 label = new QLabel( i18n( "Organization:" ), tab1 ); 387 label = new QLabel( i18n( "Organization:" ), tab1 );
388 mOrgEdit = new KLineEdit( tab1 ); 388 mOrgEdit = new KLineEdit( tab1 );
389 label->setBuddy( mOrgEdit ); 389 label->setBuddy( mOrgEdit );
390 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), 390 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ),
391 SLOT( textChanged( const QString& ) ) ); 391 SLOT( textChanged( const QString& ) ) );
392 layout->addWidget( label, 2, 1 ); 392 layout->addWidget( label, 2, 1 );
393 layout->addWidget( mOrgEdit, 2, 2 ); 393 layout->addWidget( mOrgEdit, 2, 2 );
394 394
395 // File as (formatted name) 395 // File as (formatted name)
396 label = new QLabel( i18n( "Formatted name:" ), tab1 ); 396 label = new QLabel( i18n( "Formatted name:" ), tab1 );
397#ifndef KAB_EMBEDDED 397#ifndef KAB_EMBEDDED
398 mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); 398 mFormattedNameLabel = new KSqueezedTextLabel( tab1 );
399#else //KAB_EMBEDDED 399#else //KAB_EMBEDDED
400qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 400qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
401#endif //KAB_EMBEDDED 401#endif //KAB_EMBEDDED
402 layout->addWidget( label, 3, 1 ); 402 layout->addWidget( label, 3, 1 );
403#ifndef KAB_EMBEDDED 403#ifndef KAB_EMBEDDED
404 layout->addWidget( mFormattedNameLabel, 3, 2 ); 404 layout->addWidget( mFormattedNameLabel, 3, 2 );
405#else //KAB_EMBEDDED 405#else //KAB_EMBEDDED
406qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 406qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
407#endif //KAB_EMBEDDED 407#endif //KAB_EMBEDDED
408 408
409 // Left hand separator. This separator doesn't go all the way 409 // Left hand separator. This separator doesn't go all the way
410 // across so the dialog still flows from top to bottom 410 // across so the dialog still flows from top to bottom
411 bar = new KSeparator( KSeparator::HLine, tab1 ); 411 bar = new KSeparator( KSeparator::HLine, tab1 );
412 layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); 412 layout->addMultiCellWidget( bar, 4, 4, 0, 2 );
413 413
414 ////////////////////////////////////// 414 //////////////////////////////////////
415 // Phone numbers (upper right) 415 // Phone numbers (upper right)
416 label = new QLabel( tab1 ); 416 label = new QLabel( tab1 );
417//US loadIcon call is ambiguous. Add one more parameter 417//US loadIcon call is ambiguous. Add one more parameter
418//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); 418//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) );
419 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 419 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
420 layout->addMultiCellWidget( label, 0, 1, 3, 3 ); 420 layout->addMultiCellWidget( label, 0, 1, 3, 3 );
421 421
422 mPhoneEditWidget = new PhoneEditWidget( tab1 ); 422 mPhoneEditWidget = new PhoneEditWidget( tab1 );
423 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 423 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
424 layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); 424 layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 );
425 425
426 bar = new KSeparator( KSeparator::HLine, tab1 ); 426 bar = new KSeparator( KSeparator::HLine, tab1 );
427 layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); 427 layout->addMultiCellWidget( bar, 4, 4, 3, 6 );
428*/ 428*/
429 ////////////////////////////////////// 429 //////////////////////////////////////
430 // Addresses (lower left) 430 // Addresses (lower left)
431 /* LR 431 /* LR
432 label = new QLabel( tab1_1 ); 432 label = new QLabel( tab1_1 );
433//US loadIcon call is ambiguous. Add one more parameter 433//US loadIcon call is ambiguous. Add one more parameter
434//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); 434//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) );
435 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); 435 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) );
436//US layout->addMultiCellWidget( label, 5, 6, 0, 0 ); 436//US layout->addMultiCellWidget( label, 5, 6, 0, 0 );
437 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 437 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
438 */ 438 */
439 439
440 mAddressEditWidget = new AddressEditWidget( tab1_1 ); 440 mAddressEditWidget = new AddressEditWidget( tab1_1 );
441 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 441 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
442//US layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); 442//US layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 );
443 layout->addMultiCellWidget( mAddressEditWidget, 0, 4, 0, 1 ); 443 layout->addMultiCellWidget( mAddressEditWidget, 0, 4, 0, 1 );
444 444
445//US 445//US
446/* LR 446/* LR
447 bar = new KSeparator( KSeparator::HLine, tab1_1 ); 447 bar = new KSeparator( KSeparator::HLine, tab1_1 );
448 layout->addMultiCellWidget( bar, 5, 5, 0, 3 ); 448 layout->addMultiCellWidget( bar, 5, 5, 0, 3 );
449*/ 449*/
450 450
451 ////////////////////////////////////// 451 //////////////////////////////////////
452 // Email / Web (lower right) 452 // Email / Web (lower right)
453 /* LR 453 /* LR
454 label = new QLabel( tab1_1 ); 454 label = new QLabel( tab1_1 );
455//US loadIcon call is ambiguous. Add one more parameter 455//US loadIcon call is ambiguous. Add one more parameter
456//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); 456//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) );
457 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); 457 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) );
458//US layout->addMultiCellWidget( label, 5, 6, 3, 3 ); 458//US layout->addMultiCellWidget( label, 5, 6, 3, 3 );
459 layout->addMultiCellWidget( label, 6, 7, 0, 0 ); 459 layout->addMultiCellWidget( label, 6, 7, 0, 0 );
460 */ 460 */
461 mEmailWidget = new EmailEditWidget( tab1_1 ); 461 mEmailWidget = new EmailEditWidget( tab1_1 );
462 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 462 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
463//US layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); 463//US layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 );
464 layout->addMultiCellWidget( mEmailWidget, 5, 6, 0, 1 ); 464 layout->addMultiCellWidget( mEmailWidget, 5, 6, 0, 1 );
465 465
466 /* LR 466 /* LR
467 // add the separator 467 // add the separator
468 bar = new KSeparator( KSeparator::HLine, tab1_1 ); 468 bar = new KSeparator( KSeparator::HLine, tab1_1 );
469//US layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); 469//US layout->addMultiCellWidget( bar, 7, 7, 3, 6 );
470 layout->addMultiCellWidget( bar, 8, 8, 0, 3 ); 470 layout->addMultiCellWidget( bar, 8, 8, 0, 3 );
471 471
472 label = new QLabel( tab1_1 ); 472 label = new QLabel( tab1_1 );
473//US loadIcon call is ambiguous. Add one more parameter 473//US loadIcon call is ambiguous. Add one more parameter
474//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); 474//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) );
475 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); 475 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) );
476//US layout->addMultiCellWidget( label, 8, 9, 3, 3 ); 476//US layout->addMultiCellWidget( label, 8, 9, 3, 3 );
477 layout->addMultiCellWidget( label, 9, 10, 0, 0 ); 477 layout->addMultiCellWidget( label, 9, 10, 0, 0 );
478 */ 478 */
479 label = new QLabel( i18n( "URL:" ), tab1_1 ); 479 label = new QLabel( i18n( "URL:" ), tab1_1 );
480 mURLEdit = new KLineEdit( tab1_1 ); 480 mURLEdit = new KLineEdit( tab1_1 );
481 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), 481 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ),
482 SLOT( textChanged( const QString& ) ) ); 482 SLOT( textChanged( const QString& ) ) );
483 label->setBuddy( mURLEdit ); 483 label->setBuddy( mURLEdit );
484//US layout->addWidget( label, 8, 4 ); 484//US layout->addWidget( label, 8, 4 );
485 layout->addWidget( label, 7,0 ); 485 layout->addWidget( label, 7,0 );
486//US layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); 486//US layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 );
487 layout->addWidget( mURLEdit, 7, 1); 487 layout->addWidget( mURLEdit, 7, 1);
488 488
489 label = new QLabel( i18n( "&IM address:" ), tab1_1 ); 489 label = new QLabel( i18n( "&IM address:" ), tab1_1 );
490 mIMAddressEdit = new KLineEdit( tab1_1 ); 490 mIMAddressEdit = new KLineEdit( tab1_1 );
491 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), 491 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ),
492 SLOT( textChanged( const QString& ) ) ); 492 SLOT( textChanged( const QString& ) ) );
493 label->setBuddy( mIMAddressEdit ); 493 label->setBuddy( mIMAddressEdit );
494//US layout->addWidget( label, 9, 4 ); 494//US layout->addWidget( label, 9, 4 );
495 layout->addWidget( label, 8, 0 ); 495 layout->addWidget( label, 8, 0 );
496//US layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); 496//US layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 );
497 layout->addWidget( mIMAddressEdit, 8,1 ); 497 layout->addWidget( mIMAddressEdit, 8,1 );
498 498
499//US layout->addColSpacing( 6, 50 ); 499//US layout->addColSpacing( 6, 50 );
500 500
501//US bar = new KSeparator( KSeparator::HLine, tab1_1 ); 501//US bar = new KSeparator( KSeparator::HLine, tab1_1 );
502//US layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); 502//US layout->addMultiCellWidget( bar, 10, 10, 0, 6 );
503 503
504/*US 504/*US
505 /////////////////////////////////////// 505 ///////////////////////////////////////
506 QHBox *categoryBox = new QHBox( tab1 ); 506 QHBox *categoryBox = new QHBox( tab1 );
507 categoryBox->setSpacing( KDialogBase::spacingHintSmall() ); 507 categoryBox->setSpacing( KDialogBase::spacingHintSmall() );
508 508
509 // Categories 509 // Categories
510 button = new QPushButton( i18n( "Categories" ), categoryBox ); 510 button = new QPushButton( i18n( "Categories" ), categoryBox );
511 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); 511 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) );
512 512
513 mCategoryEdit = new KLineEdit( categoryBox ); 513 mCategoryEdit = new KLineEdit( categoryBox );
514 mCategoryEdit->setReadOnly( true ); 514 mCategoryEdit->setReadOnly( true );
515 connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), 515 connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ),
516 SLOT( textChanged( const QString& ) ) ); 516 SLOT( textChanged( const QString& ) ) );
517 517
518 mSecrecyWidget = new SecrecyWidget( categoryBox ); 518 mSecrecyWidget = new SecrecyWidget( categoryBox );
519 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 519 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
520 520
521 layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); 521 layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 );
522*/ 522*/
523 // Build the layout and add to the tab widget 523 // Build the layout and add to the tab widget
524 layout->activate(); // required 524 layout->activate(); // required
525 525
526 mTabWidget->addTab( tab1_1, i18n( "&Address" ) ); 526 mTabWidget->addTab( tab1_1, i18n( "&Address" ) );
527} 527}
528 528
529 529
530 530
531void AddresseeEditorWidget::setupTab2() 531void AddresseeEditorWidget::setupTab2()
532{ 532{
533 // This is the Details tab 533 // This is the Details tab
534 QWidget *tab2 = new QWidget( mTabWidget ); 534 QWidget *tab2 = new QWidget( mTabWidget );
535 535
536 QGridLayout *layout = new QGridLayout( tab2, 8, 3 ); 536 QGridLayout *layout = new QGridLayout( tab2, 8, 3 );
537 layout->setMargin( KDialogBase::marginHintSmall() ); 537 layout->setMargin( KDialogBase::marginHintSmall() );
538 layout->setSpacing( KDialogBase::spacingHintSmall() ); 538 layout->setSpacing( KDialogBase::spacingHintSmall() );
539 539
540 QLabel *label; 540 QLabel *label;
541 KSeparator* bar; 541 KSeparator* bar;
542 542
543 /////////////////////// 543 ///////////////////////
544 // Office info 544 // Office info
545 545
546 // Department 546 // Department
547 label = new QLabel( tab2 ); 547 label = new QLabel( tab2 );
548//US loadIcon call is ambiguous. Add one more parameter 548//US loadIcon call is ambiguous. Add one more parameter
549//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); 549//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) );
550 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); 550 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) );
551 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 551 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
552 552
553 label = new QLabel( i18n( "Department:" ), tab2 ); 553 label = new QLabel( i18n( "Department:" ), tab2 );
554 layout->addWidget( label, 0, 1 ); 554 layout->addWidget( label, 0, 1 );
555 mDepartmentEdit = new KLineEdit( tab2 ); 555 mDepartmentEdit = new KLineEdit( tab2 );
556 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), 556 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ),
557 SLOT( textChanged( const QString& ) ) ); 557 SLOT( textChanged( const QString& ) ) );
558 label->setBuddy( mDepartmentEdit ); 558 label->setBuddy( mDepartmentEdit );
559 layout->addWidget( mDepartmentEdit, 0, 2 ); 559 layout->addWidget( mDepartmentEdit, 0, 2 );
560 560
561 label = new QLabel( i18n( "Office:" ), tab2 ); 561 label = new QLabel( i18n( "Office:" ), tab2 );
562 layout->addWidget( label, 1, 1 ); 562 layout->addWidget( label, 1, 1 );
563 mOfficeEdit = new KLineEdit( tab2 ); 563 mOfficeEdit = new KLineEdit( tab2 );
564 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), 564 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ),
565 SLOT( textChanged( const QString& ) ) ); 565 SLOT( textChanged( const QString& ) ) );
566 label->setBuddy( mOfficeEdit ); 566 label->setBuddy( mOfficeEdit );
567 layout->addWidget( mOfficeEdit, 1, 2 ); 567 layout->addWidget( mOfficeEdit, 1, 2 );
568 568
569 label = new QLabel( i18n( "Profession:" ), tab2 ); 569 label = new QLabel( i18n( "Profession:" ), tab2 );
570 layout->addWidget( label, 2, 1 ); 570 layout->addWidget( label, 2, 1 );
571 mProfessionEdit = new KLineEdit( tab2 ); 571 mProfessionEdit = new KLineEdit( tab2 );
572 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), 572 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ),
573 SLOT( textChanged( const QString& ) ) ); 573 SLOT( textChanged( const QString& ) ) );
574 label->setBuddy( mProfessionEdit ); 574 label->setBuddy( mProfessionEdit );
575 layout->addWidget( mProfessionEdit, 2, 2 ); 575 layout->addWidget( mProfessionEdit, 2, 2 );
576 576
577 label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); 577 label = new QLabel( i18n( "Manager\'s name:" ), tab2 );
578//US layout->addWidget( label, 0, 3 ); 578//US layout->addWidget( label, 0, 3 );
579 layout->addWidget( label, 3, 1 ); 579 layout->addWidget( label, 3, 1 );
580 mManagerEdit = new KLineEdit( tab2 ); 580 mManagerEdit = new KLineEdit( tab2 );
581 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), 581 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ),
582 SLOT( textChanged( const QString& ) ) ); 582 SLOT( textChanged( const QString& ) ) );
583 label->setBuddy( mManagerEdit ); 583 label->setBuddy( mManagerEdit );
584//US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); 584//US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 );
585 layout->addWidget( mManagerEdit, 3, 2 ); 585 layout->addWidget( mManagerEdit, 3, 2 );
586 586
587 label = new QLabel( i18n( "Assistant's name:" ), tab2 ); 587 label = new QLabel( i18n( "Assistant's name:" ), tab2 );
588//US layout->addWidget( label, 1, 3 ); 588//US layout->addWidget( label, 1, 3 );
589 layout->addWidget( label, 4, 1 ); 589 layout->addWidget( label, 4, 1 );
590 mAssistantEdit = new KLineEdit( tab2 ); 590 mAssistantEdit = new KLineEdit( tab2 );
591 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), 591 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ),
592 SLOT( textChanged( const QString& ) ) ); 592 SLOT( textChanged( const QString& ) ) );
593 label->setBuddy( mAssistantEdit ); 593 label->setBuddy( mAssistantEdit );
594//US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); 594//US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 );
595 layout->addWidget( mAssistantEdit, 4, 2 ); 595 layout->addWidget( mAssistantEdit, 4, 2 );
596 596
597 bar = new KSeparator( KSeparator::HLine, tab2 ); 597 bar = new KSeparator( KSeparator::HLine, tab2 );
598//US layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); 598//US layout->addMultiCellWidget( bar, 3, 3, 0, 5 );
599 layout->addMultiCellWidget( bar, 5, 5, 0, 2 ); 599 layout->addMultiCellWidget( bar, 5, 5, 0, 2 );
600 600
601 ///////////////////////////////////////////////// 601 /////////////////////////////////////////////////
602 // Personal info 602 // Personal info
603 603
604 label = new QLabel( tab2 ); 604 label = new QLabel( tab2 );
605//US loadIcon call is ambiguous. Add one more parameter 605//US loadIcon call is ambiguous. Add one more parameter
606//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 606//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
607 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 607 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
608//US layout->addMultiCellWidget( label, 4, 5, 0, 0 ); 608//US layout->addMultiCellWidget( label, 4, 5, 0, 0 );
609 layout->addMultiCellWidget( label, 6, 7, 0, 0 ); 609 layout->addMultiCellWidget( label, 6, 7, 0, 0 );
610 610
611 label = new QLabel( i18n( "Nick name:" ), tab2 ); 611 label = new QLabel( i18n( "Nick name:" ), tab2 );
612//US layout->addWidget( label, 4, 1 ); 612//US layout->addWidget( label, 4, 1 );
613 layout->addWidget( label, 6, 1 ); 613 layout->addWidget( label, 6, 1 );
614 mNicknameEdit = new KLineEdit( tab2 ); 614 mNicknameEdit = new KLineEdit( tab2 );
615 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), 615 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
616 SLOT( textChanged( const QString& ) ) ); 616 SLOT( textChanged( const QString& ) ) );
617 label->setBuddy( mNicknameEdit ); 617 label->setBuddy( mNicknameEdit );
618//US layout->addWidget( mNicknameEdit, 4, 2 ); 618//US layout->addWidget( mNicknameEdit, 4, 2 );
619 layout->addWidget( mNicknameEdit, 6, 2 ); 619 layout->addWidget( mNicknameEdit, 6, 2 );
620 620
621 label = new QLabel( i18n( "Spouse's name:" ), tab2 ); 621 label = new QLabel( i18n( "Spouse's name:" ), tab2 );
622//US layout->addWidget( label, 5, 1 ); 622//US layout->addWidget( label, 5, 1 );
623 layout->addWidget( label, 7, 1 ); 623 layout->addWidget( label, 7, 1 );
624 mSpouseEdit = new KLineEdit( tab2 ); 624 mSpouseEdit = new KLineEdit( tab2 );
625 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), 625 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
626 SLOT( textChanged( const QString& ) ) ); 626 SLOT( textChanged( const QString& ) ) );
627 label->setBuddy( mSpouseEdit ); 627 label->setBuddy( mSpouseEdit );
628//US layout->addWidget( mSpouseEdit, 5, 2 ); 628//US layout->addWidget( mSpouseEdit, 5, 2 );
629 layout->addWidget( mSpouseEdit, 7, 2 ); 629 layout->addWidget( mSpouseEdit, 7, 2 );
630 630
631 label = new QLabel( i18n( "Birthday:" ), tab2 ); 631 label = new QLabel( i18n( "Birthday:" ), tab2 );
632//US layout->addWidget( label, 4, 3 ); 632//US layout->addWidget( label, 4, 3 );
633 layout->addWidget( label, 8, 1 ); 633 layout->addWidget( label, 8, 1 );
634 mBirthdayPicker = new KDateEdit( tab2 ); 634 mBirthdayPicker = new KDateEdit( tab2 );
635 mBirthdayPicker->setHandleInvalid( true ); 635 mBirthdayPicker->setHandleInvalid( true );
636 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), 636 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
637 SLOT( dateChanged( QDate ) ) ); 637 SLOT( dateChanged( QDate ) ) );
638 638
639 639
640#ifndef KAB_EMBEDDED 640#ifndef KAB_EMBEDDED
641 //US invalid dates are handdled by the KDateEdit widget itself 641 //US invalid dates are handdled by the KDateEdit widget itself
642 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), 642 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ),
643 SLOT( invalidDate() ) ); 643 SLOT( invalidDate() ) );
644 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), 644 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ),
645 SLOT( emitModified() ) ); 645 SLOT( emitModified() ) );
646#endif //KAB_EMBEDDED 646#endif //KAB_EMBEDDED
647 647
648 label->setBuddy( mBirthdayPicker ); 648 label->setBuddy( mBirthdayPicker );
649//US layout->addWidget( mBirthdayPicker, 4, 4 ); 649//US layout->addWidget( mBirthdayPicker, 4, 4 );
650 layout->addWidget( mBirthdayPicker, 8, 2 ); 650 layout->addWidget( mBirthdayPicker, 8, 2 );
651 651
652 label = new QLabel( i18n( "Anniversary:" ), tab2 ); 652 label = new QLabel( i18n( "Anniversary:" ), tab2 );
653//US layout->addWidget( label, 5, 3 ); 653//US layout->addWidget( label, 5, 3 );
654 layout->addWidget( label, 9, 1 ); 654 layout->addWidget( label, 9, 1 );
655 mAnniversaryPicker = new KDateEdit( tab2 ); 655 mAnniversaryPicker = new KDateEdit( tab2 );
656 mAnniversaryPicker->setHandleInvalid( true ); 656 mAnniversaryPicker->setHandleInvalid( true );
657 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), 657 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
658 SLOT( dateChanged( QDate ) ) ); 658 SLOT( dateChanged( QDate ) ) );
659#ifndef KAB_EMBEDDED 659#ifndef KAB_EMBEDDED
660 //US invalid dates are handled by the KDateEdit widget itself 660 //US invalid dates are handled by the KDateEdit widget itself
661 connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), 661 connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ),
662 SLOT( invalidDate() ) ); 662 SLOT( invalidDate() ) );
663 connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), 663 connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ),
664 SLOT( emitModified() ) ); 664 SLOT( emitModified() ) );
665#endif //KAB_EMBEDDED 665#endif //KAB_EMBEDDED
666 666
667 label->setBuddy( mAnniversaryPicker ); 667 label->setBuddy( mAnniversaryPicker );
668//US layout->addWidget( mAnniversaryPicker, 5, 4 ); 668//US layout->addWidget( mAnniversaryPicker, 5, 4 );
669 layout->addWidget( mAnniversaryPicker, 9, 2 ); 669 layout->addWidget( mAnniversaryPicker, 9, 2 );
670 670
671/*US 671/*US
672 bar = new KSeparator( KSeparator::HLine, tab2 ); 672 bar = new KSeparator( KSeparator::HLine, tab2 );
673 layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); 673 layout->addMultiCellWidget( bar, 6, 6, 0, 5 );
674 674
675 ////////////////////////////////////// 675 //////////////////////////////////////
676 // Notes 676 // Notes
677 label = new QLabel( i18n( "Note:" ), tab2 ); 677 label = new QLabel( i18n( "Note:" ), tab2 );
678 label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); 678 label->setAlignment( Qt::AlignTop | Qt::AlignLeft );
679 layout->addWidget( label, 7, 0 ); 679 layout->addWidget( label, 7, 0 );
680#ifndef KAB_EMBEDDED 680#ifndef KAB_EMBEDDED
681 mNoteEdit = new QTextEdit( tab2 ); 681 mNoteEdit = new QTextEdit( tab2 );
682 mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); 682 mNoteEdit->setWordWrap( QTextEdit::WidgetWidth );
683 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); 683 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
684#else //KAB_EMBEDDED 684#else //KAB_EMBEDDED
685 mNoteEdit = new QMultiLineEdit( tab2 ); 685 mNoteEdit = new QMultiLineEdit( tab2 );
686//US mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); 686//US mNoteEdit->setWordWrap( QTextEdit::WidgetWidth );
687//US mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); 687//US mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
688qDebug("AddresseeEditorWidget::setupTab2 has to be changed"); 688qDebug("AddresseeEditorWidget::setupTab2 has to be changed");
689#endif //KAB_EMBEDDED 689#endif //KAB_EMBEDDED
690 connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); 690 connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) );
691 label->setBuddy( mNoteEdit ); 691 label->setBuddy( mNoteEdit );
692 layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); 692 layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 );
693*/ 693*/
694 // Build the layout and add to the tab widget 694 // Build the layout and add to the tab widget
695 layout->activate(); // required 695 layout->activate(); // required
696 696
697 mTabWidget->addTab( tab2, i18n( "&Details" ) ); 697 mTabWidget->addTab( tab2, i18n( "&Details" ) );
698} 698}
699 699
700void AddresseeEditorWidget::setupTab2_1() 700void AddresseeEditorWidget::setupTab2_1()
701{ 701{
702 // This is the Details tab 702 // This is the Details tab
703 QWidget *tab2_2 = new QWidget( mTabWidget ); 703 QWidget *tab2_2 = new QWidget( mTabWidget );
704 704
705 QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 ); 705 QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 );
706 layout->setMargin( KDialogBase::marginHintSmall() ); 706 layout->setMargin( KDialogBase::marginHintSmall() );
707 layout->setSpacing( KDialogBase::spacingHintSmall() ); 707 layout->setSpacing( KDialogBase::spacingHintSmall() );
708 708
709 QLabel *label; 709 QLabel *label;
710 KSeparator* bar; 710 KSeparator* bar;
711 711
712/*US 712/*US
713 /////////////////////// 713 ///////////////////////
714 // Office info 714 // Office info
715 715
716 // Department 716 // Department
717 label = new QLabel( tab2 ); 717 label = new QLabel( tab2 );
718//US loadIcon call is ambiguous. Add one more parameter 718//US loadIcon call is ambiguous. Add one more parameter
719//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); 719//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) );
720 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); 720 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) );
721 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 721 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
722 722
723 label = new QLabel( i18n( "Department:" ), tab2 ); 723 label = new QLabel( i18n( "Department:" ), tab2 );
724 layout->addWidget( label, 0, 1 ); 724 layout->addWidget( label, 0, 1 );
725 mDepartmentEdit = new KLineEdit( tab2 ); 725 mDepartmentEdit = new KLineEdit( tab2 );
726 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), 726 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ),
727 SLOT( textChanged( const QString& ) ) ); 727 SLOT( textChanged( const QString& ) ) );
728 label->setBuddy( mDepartmentEdit ); 728 label->setBuddy( mDepartmentEdit );
729 layout->addWidget( mDepartmentEdit, 0, 2 ); 729 layout->addWidget( mDepartmentEdit, 0, 2 );
730 730
731 label = new QLabel( i18n( "Office:" ), tab2 ); 731 label = new QLabel( i18n( "Office:" ), tab2 );
732 layout->addWidget( label, 1, 1 ); 732 layout->addWidget( label, 1, 1 );
733 mOfficeEdit = new KLineEdit( tab2 ); 733 mOfficeEdit = new KLineEdit( tab2 );
734 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), 734 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ),
735 SLOT( textChanged( const QString& ) ) ); 735 SLOT( textChanged( const QString& ) ) );
736 label->setBuddy( mOfficeEdit ); 736 label->setBuddy( mOfficeEdit );
737 layout->addWidget( mOfficeEdit, 1, 2 ); 737 layout->addWidget( mOfficeEdit, 1, 2 );
738 738
739 label = new QLabel( i18n( "Profession:" ), tab2 ); 739 label = new QLabel( i18n( "Profession:" ), tab2 );
740 layout->addWidget( label, 2, 1 ); 740 layout->addWidget( label, 2, 1 );
741 mProfessionEdit = new KLineEdit( tab2 ); 741 mProfessionEdit = new KLineEdit( tab2 );
742 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), 742 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ),
743 SLOT( textChanged( const QString& ) ) ); 743 SLOT( textChanged( const QString& ) ) );
744 label->setBuddy( mProfessionEdit ); 744 label->setBuddy( mProfessionEdit );
745 layout->addWidget( mProfessionEdit, 2, 2 ); 745 layout->addWidget( mProfessionEdit, 2, 2 );
746 746
747 label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); 747 label = new QLabel( i18n( "Manager\'s name:" ), tab2 );
748 layout->addWidget( label, 0, 3 ); 748 layout->addWidget( label, 0, 3 );
749 mManagerEdit = new KLineEdit( tab2 ); 749 mManagerEdit = new KLineEdit( tab2 );
750 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), 750 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ),
751 SLOT( textChanged( const QString& ) ) ); 751 SLOT( textChanged( const QString& ) ) );
752 label->setBuddy( mManagerEdit ); 752 label->setBuddy( mManagerEdit );
753 layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); 753 layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 );
754 754
755 label = new QLabel( i18n( "Assistant's name:" ), tab2 ); 755 label = new QLabel( i18n( "Assistant's name:" ), tab2 );
756 layout->addWidget( label, 1, 3 ); 756 layout->addWidget( label, 1, 3 );
757 mAssistantEdit = new KLineEdit( tab2 ); 757 mAssistantEdit = new KLineEdit( tab2 );
758 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), 758 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ),
759 SLOT( textChanged( const QString& ) ) ); 759 SLOT( textChanged( const QString& ) ) );
760 label->setBuddy( mAssistantEdit ); 760 label->setBuddy( mAssistantEdit );
761 layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); 761 layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 );
762 762
763 bar = new KSeparator( KSeparator::HLine, tab2 ); 763 bar = new KSeparator( KSeparator::HLine, tab2 );
764 layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); 764 layout->addMultiCellWidget( bar, 3, 3, 0, 5 );
765 765
766 ///////////////////////////////////////////////// 766 /////////////////////////////////////////////////
767 // Personal info 767 // Personal info
768 768
769 label = new QLabel( tab2 ); 769 label = new QLabel( tab2 );
770//US loadIcon call is ambiguous. Add one more parameter 770//US loadIcon call is ambiguous. Add one more parameter
771//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 771//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
772 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 772 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
773 layout->addMultiCellWidget( label, 4, 5, 0, 0 ); 773 layout->addMultiCellWidget( label, 4, 5, 0, 0 );
774 774
775 label = new QLabel( i18n( "Nick name:" ), tab2 ); 775 label = new QLabel( i18n( "Nick name:" ), tab2 );
776 layout->addWidget( label, 4, 1 ); 776 layout->addWidget( label, 4, 1 );
777 mNicknameEdit = new KLineEdit( tab2 ); 777 mNicknameEdit = new KLineEdit( tab2 );
778 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), 778 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
779 SLOT( textChanged( const QString& ) ) ); 779 SLOT( textChanged( const QString& ) ) );
780 label->setBuddy( mNicknameEdit ); 780 label->setBuddy( mNicknameEdit );
781 layout->addWidget( mNicknameEdit, 4, 2 ); 781 layout->addWidget( mNicknameEdit, 4, 2 );
782 782
783 label = new QLabel( i18n( "Spouse's name:" ), tab2 ); 783 label = new QLabel( i18n( "Spouse's name:" ), tab2 );
784 layout->addWidget( label, 5, 1 ); 784 layout->addWidget( label, 5, 1 );
785 mSpouseEdit = new KLineEdit( tab2 ); 785 mSpouseEdit = new KLineEdit( tab2 );
786 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), 786 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
787 SLOT( textChanged( const QString& ) ) ); 787 SLOT( textChanged( const QString& ) ) );
788 label->setBuddy( mSpouseEdit ); 788 label->setBuddy( mSpouseEdit );
789 layout->addWidget( mSpouseEdit, 5, 2 ); 789 layout->addWidget( mSpouseEdit, 5, 2 );
790 790
791 label = new QLabel( i18n( "Birthday:" ), tab2 ); 791 label = new QLabel( i18n( "Birthday:" ), tab2 );
792 layout->addWidget( label, 4, 3 ); 792 layout->addWidget( label, 4, 3 );
793 mBirthdayPicker = new KDateEdit( tab2 ); 793 mBirthdayPicker = new KDateEdit( tab2 );
794 mBirthdayPicker->setHandleInvalid( true ); 794 mBirthdayPicker->setHandleInvalid( true );
795 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), 795 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
796 SLOT( dateChanged( QDate ) ) ); 796 SLOT( dateChanged( QDate ) ) );
797 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), 797 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ),
798 SLOT( invalidDate() ) ); 798 SLOT( invalidDate() ) );
799 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), 799 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ),
800 SLOT( emitModified() ) ); 800 SLOT( emitModified() ) );
801 label->setBuddy( mBirthdayPicker ); 801 label->setBuddy( mBirthdayPicker );
802 layout->addWidget( mBirthdayPicker, 4, 4 ); 802 layout->addWidget( mBirthdayPicker, 4, 4 );
803 803
804 label = new QLabel( i18n( "Anniversary:" ), tab2 ); 804 label = new QLabel( i18n( "Anniversary:" ), tab2 );
805 layout->addWidget( label, 5, 3 ); 805 layout->addWidget( label, 5, 3 );
806 mAnniversaryPicker = new KDateEdit( tab2 ); 806 mAnniversaryPicker = new KDateEdit( tab2 );
807 mAnniversaryPicker->setHandleInvalid( true ); 807 mAnniversaryPicker->setHandleInvalid( true );
808 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), 808 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
809 SLOT( dateChanged( QDate ) ) ); 809 SLOT( dateChanged( QDate ) ) );
810 connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), 810 connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ),
811 SLOT( invalidDate() ) ); 811 SLOT( invalidDate() ) );
812 connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), 812 connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ),
813 SLOT( emitModified() ) ); 813 SLOT( emitModified() ) );
814 label->setBuddy( mAnniversaryPicker ); 814 label->setBuddy( mAnniversaryPicker );
815 layout->addWidget( mAnniversaryPicker, 5, 4 ); 815 layout->addWidget( mAnniversaryPicker, 5, 4 );
816 816
817 bar = new KSeparator( KSeparator::HLine, tab2 ); 817 bar = new KSeparator( KSeparator::HLine, tab2 );
818 layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); 818 layout->addMultiCellWidget( bar, 6, 6, 0, 5 );
819*/ 819*/
820 ////////////////////////////////////// 820 //////////////////////////////////////
821 // Notes 821 // Notes
822 label = new QLabel( i18n( "Note:" ), tab2_2 ); 822 label = new QLabel( i18n( "Note:" ), tab2_2 );
823 label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); 823 label->setAlignment( Qt::AlignTop | Qt::AlignLeft );
824//US layout->addWidget( label, 7, 0 ); 824//US layout->addWidget( label, 7, 0 );
825 layout->addWidget( label, 0, 0 ); 825 layout->addWidget( label, 0, 0 );
826#ifndef KAB_EMBEDDED 826#ifndef KAB_EMBEDDED
827 mNoteEdit = new QTextEdit( tab2_2 ); 827 mNoteEdit = new QTextEdit( tab2_2 );
828 mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); 828 mNoteEdit->setWordWrap( QTextEdit::WidgetWidth );
829 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); 829 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
830#else //KAB_EMBEDDED 830#else //KAB_EMBEDDED
831 mNoteEdit = new QMultiLineEdit( tab2_2 ); 831 mNoteEdit = new QMultiLineEdit( tab2_2 );
832 mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth ); 832 mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth );
833 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); 833 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
834#endif //KAB_EMBEDDED 834#endif //KAB_EMBEDDED
835 835
836 connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); 836 connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) );
837 label->setBuddy( mNoteEdit ); 837 label->setBuddy( mNoteEdit );
838//US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); 838//US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 );
839 layout->addWidget( mNoteEdit, 1, 0); 839 layout->addWidget( mNoteEdit, 1, 0);
840 840
841 // Build the layout and add to the tab widget 841 // Build the layout and add to the tab widget
842 layout->activate(); // required 842 layout->activate(); // required
843 843
844 mTabWidget->addTab( tab2_2, i18n( "&Notes" ) ); 844 mTabWidget->addTab( tab2_2, i18n( "&Notes" ) );
845} 845}
846 846
847 847
848 848
849void AddresseeEditorWidget::setupTab3() 849void AddresseeEditorWidget::setupTab3()
850{ 850{
851 // This is the Misc tab 851 // This is the Misc tab
852 QWidget *tab3 = new QWidget( mTabWidget ); 852 QWidget *tab3 = new QWidget( mTabWidget );
853 853
854 QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); 854 QGridLayout *layout = new QGridLayout( tab3, 1, 1 );
855 layout->setMargin( KDialogBase::marginHintSmall() ); 855 layout->setMargin( KDialogBase::marginHintSmall() );
856 layout->setSpacing( KDialogBase::spacingHintSmall() ); 856 layout->setSpacing( KDialogBase::spacingHintSmall() );
857//US layout->setColStretch( 2, 1 ); 857//US layout->setColStretch( 2, 1 );
858 858
859 ////////////////////////////////////// 859 //////////////////////////////////////
860 // Geo 860 // Geo
861 mGeoWidget = new GeoWidget( tab3 ); 861 mGeoWidget = new GeoWidget( tab3 );
862 // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); 862 // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() );
863 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 863 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
864 layout->addWidget( mGeoWidget, 0, 0 ); 864 layout->addWidget( mGeoWidget, 0, 0 );
865/*US 865/*US
866 ////////////////////////////////////// 866 //////////////////////////////////////
867 // Sound 867 // Sound
868#ifndef KAB_EMBEDDED 868#ifndef KAB_EMBEDDED
869 mSoundWidget = new SoundWidget( tab3 ); 869 mSoundWidget = new SoundWidget( tab3 );
870 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); 870 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() );
871 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 871 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
872 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); 872 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop );
873#else //KAB_EMBEDDED 873#else //KAB_EMBEDDED
874qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); 874qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed");
875#endif //KAB_EMBEDDED 875#endif //KAB_EMBEDDED
876 876
877 ////////////////////////////////////// 877 //////////////////////////////////////
878 // Images 878 // Images
879 mImageWidget = new ImageWidget( tab3 ); 879 mImageWidget = new ImageWidget( tab3 );
880 mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); 880 mImageWidget->setMinimumSize( mImageWidget->sizeHint() );
881 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 881 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
882 layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop ); 882 layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop );
883*/ 883*/
884//US 884//US
885/* 885/*
886 KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 ); 886 KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 );
887 layout->addMultiCellWidget( bar, 1, 1, 0, 0 ); 887 layout->addMultiCellWidget( bar, 1, 1, 0, 0 );
888*/ 888*/
889 ////////////////////////////////////// 889 //////////////////////////////////////
890 // Keys 890 // Keys
891 mKeyWidget = new KeyWidget( tab3 ); 891 mKeyWidget = new KeyWidget( tab3 );
892 //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); 892 //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() );
893 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 893 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
894//US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); 894//US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop );
895 layout->addWidget( mKeyWidget, 1, 0 ); 895 layout->addWidget( mKeyWidget, 1, 0 );
896 896
897 mTabWidget->addTab( tab3, i18n( "&Misc" ) ); 897 mTabWidget->addTab( tab3, i18n( "&Misc" ) );
898} 898}
899 899
900void AddresseeEditorWidget::setupTab3_1() 900void AddresseeEditorWidget::setupTab3_1()
901{ 901{
902 // This is the Misc tab 902 // This is the Misc tab
903 QWidget *tab3 = new QWidget( mTabWidget ); 903 QWidget *tab3 = new QWidget( mTabWidget );
904 904
905//US QGridLayout *layout = new QGridLayout( tab3, 2, 3 ); 905//US QGridLayout *layout = new QGridLayout( tab3, 2, 3 );
906 QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); 906 QGridLayout *layout = new QGridLayout( tab3, 1, 1 );
907 layout->setMargin( KDialogBase::marginHint() ); 907 layout->setMargin( KDialogBase::marginHint() );
908 layout->setSpacing( KDialogBase::spacingHint() ); 908 layout->setSpacing( KDialogBase::spacingHint() );
909//US layout->setColStretch( 2, 1 ); 909//US layout->setColStretch( 2, 1 );
910 910
911/*US 911/*US
912 ////////////////////////////////////// 912 //////////////////////////////////////
913 // Geo 913 // Geo
914 mGeoWidget = new GeoWidget( tab3 ); 914 mGeoWidget = new GeoWidget( tab3 );
915 mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); 915 mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() );
916 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 916 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
917 layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop ); 917 layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop );
918*/ 918*/
919 ////////////////////////////////////// 919 //////////////////////////////////////
920 // Sound 920 // Sound
921#ifndef KAB_EMBEDDED 921#ifndef KAB_EMBEDDED
922 mSoundWidget = new SoundWidget( tab3 ); 922 mSoundWidget = new SoundWidget( tab3 );
923 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); 923 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() );
924 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 924 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
925 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); 925 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop );
926#else //KAB_EMBEDDED 926#else //KAB_EMBEDDED
927//US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); 927//US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed");
928#endif //KAB_EMBEDDED 928#endif //KAB_EMBEDDED
929 929
930 ////////////////////////////////////// 930 //////////////////////////////////////
931 // Images 931 // Images
932 mImageWidget = new ImageWidget( tab3 ); 932 mImageWidget = new ImageWidget( tab3 );
933 mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); 933 mImageWidget->setMinimumSize( mImageWidget->sizeHint() );
934 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 934 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
935 layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); 935 layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop );
936/*US 936/*US
937 ////////////////////////////////////// 937 //////////////////////////////////////
938 // Keys 938 // Keys
939 mKeyWidget = new KeyWidget( tab3 ); 939 mKeyWidget = new KeyWidget( tab3 );
940 mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); 940 mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() );
941 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 941 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
942 layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); 942 layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop );
943*/ 943*/
944 mTabWidget->addTab( tab3, i18n( "&Images" ) ); 944 mTabWidget->addTab( tab3, i18n( "&Images" ) );
945} 945}
946 946
947 947
948void AddresseeEditorWidget::load() 948void AddresseeEditorWidget::load()
949{ 949{
950 kdDebug(5720) << "AddresseeEditorWidget::load()" << endl; 950 kdDebug(5720) << "AddresseeEditorWidget::load()" << endl;
951 951
952 // Block signals in case anything tries to emit modified 952 // Block signals in case anything tries to emit modified
953 // CS: This doesn't seem to work. 953 // CS: This doesn't seem to work.
954 bool block = signalsBlocked(); 954 bool block = signalsBlocked();
955 blockSignals( true ); 955 blockSignals( true );
956 mBlockSignals = true; // used for internal signal blocking 956 mBlockSignals = true; // used for internal signal blocking
957 957
958 mNameEdit->setText( mAddressee.assembledName() ); 958 mNameEdit->setText( mAddressee.assembledName() );
959 959
960 if ( mAddressee.formattedName().isEmpty() ) { 960 if ( mAddressee.formattedName().isEmpty() ) {
961//US KConfig config( "kaddressbookrc" ); 961//US KConfig config( "kaddressbookrc" );
962 KConfig config( locateLocal("config", "kaddressbookrc") ); 962 KConfig config( locateLocal("config", "kaddressbookrc") );
963 config.setGroup( "General" ); 963 config.setGroup( "General" );
964 mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); 964 mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 );
965 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 965 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
966 } else { 966 } else {
967 if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) 967 if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) )
968 mFormattedNameType = NameEditDialog::SimpleName; 968 mFormattedNameType = NameEditDialog::SimpleName;
969 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) 969 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) )
970 mFormattedNameType = NameEditDialog::FullName; 970 mFormattedNameType = NameEditDialog::FullName;
971 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) 971 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) )
972 mFormattedNameType = NameEditDialog::ReverseName; 972 mFormattedNameType = NameEditDialog::ReverseName;
973 else 973 else
974 mFormattedNameType = NameEditDialog::CustomName; 974 mFormattedNameType = NameEditDialog::CustomName;
975 } 975 }
976 976
977 mFormattedNameLabel->setText( mAddressee.formattedName() ); 977 mFormattedNameLabel->setText( mAddressee.formattedName() );
978 978
979 mRoleEdit->setText( mAddressee.role() ); 979 mRoleEdit->setText( mAddressee.role() );
980 mOrgEdit->setText( mAddressee.organization() ); 980 mOrgEdit->setText( mAddressee.organization() );
981 981
982//US mURLEdit->setURL( mAddressee.url().url() ); 982//US mURLEdit->setURL( mAddressee.url().url() );
983 mURLEdit->setText( mAddressee.url().prettyURL() ); 983 mURLEdit->setText( mAddressee.url().prettyURL() );
984//US?? mURLEdit->home( false ); 984//US?? mURLEdit->home( false );
985 985
986 // mNoteEdit->setText( mAddressee.note() ); 986 // mNoteEdit->setText( mAddressee.note() );
987 mNoteEdit->setText( mAddressee.note() ); 987 mNoteEdit->setText( mAddressee.note() );
988 mEmailWidget->setEmails( mAddressee.emails() ); 988 mEmailWidget->setEmails( mAddressee.emails() );
989 mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); 989 mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() );
990 mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); 990 mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() );
991 mBirthdayPicker->setDate( mAddressee.birthday().date() ); 991 mBirthdayPicker->setDate( mAddressee.birthday().date() );
992 992
993//US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( 993//US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom(
994//US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); 994//US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) );
995 QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), 995 QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ),
996 "%Y-%m-%d"); // = Qt::ISODate 996 "%Y-%m-%d"); // = Qt::ISODate
997 mAnniversaryPicker->setDate( dt ); 997 mAnniversaryPicker->setDate( dt );
998 998
999 999
1000 mNicknameEdit->setText( mAddressee.nickName() ); 1000 mNicknameEdit->setText( mAddressee.nickName() );
1001 mCategoryEdit->setText( mAddressee.categories().join( "," ) ); 1001 mCategoryEdit->setText( mAddressee.categories().join( "," ) );
1002 1002
1003 mGeoWidget->setGeo( mAddressee.geo() ); 1003 mGeoWidget->setGeo( mAddressee.geo() );
1004 mImageWidget->setPhoto( mAddressee.photo() ); 1004 mImageWidget->setPhoto( mAddressee.photo() );
1005 mImageWidget->setLogo( mAddressee.logo() ); 1005 mImageWidget->setLogo( mAddressee.logo() );
1006 mKeyWidget->setKeys( mAddressee.keys() ); 1006 mKeyWidget->setKeys( mAddressee.keys() );
1007 mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); 1007 mSecrecyWidget->setSecrecy( mAddressee.secrecy() );
1008#ifndef KAB_EMBEDDED 1008#ifndef KAB_EMBEDDED
1009 mSoundWidget->setSound( mAddressee.sound() ); 1009 mSoundWidget->setSound( mAddressee.sound() );
1010#else //KAB_EMBEDDED 1010#else //KAB_EMBEDDED
1011//US qDebug("AddresseeEditorWidget::load has to be changed 2"); 1011//US qDebug("AddresseeEditorWidget::load has to be changed 2");
1012#endif //KAB_EMBEDDED 1012#endif //KAB_EMBEDDED
1013 1013
1014 // Load customs 1014 // Load customs
1015 mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); 1015 mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) );
1016 mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); 1016 mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) );
1017 mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); 1017 mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) );
1018 mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); 1018 mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) );
1019 mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); 1019 mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) );
1020 mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); 1020 mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) );
1021 mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); 1021 mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) );
1022 1022
1023 blockSignals( block ); 1023 blockSignals( block );
1024 mBlockSignals = false; 1024 mBlockSignals = false;
1025 1025
1026 mDirty = false; 1026 mDirty = false;
1027} 1027}
1028 1028
1029void AddresseeEditorWidget::save() 1029void AddresseeEditorWidget::save()
1030{ 1030{
1031 if ( !mDirty ) return; 1031 if ( !mDirty ) return;
1032 1032
1033 mAddressee.setRole( mRoleEdit->text() ); 1033 mAddressee.setRole( mRoleEdit->text() );
1034 mAddressee.setOrganization( mOrgEdit->text() ); 1034 mAddressee.setOrganization( mOrgEdit->text() );
1035 mAddressee.setUrl( KURL( mURLEdit->text() ) ); 1035 mAddressee.setUrl( KURL( mURLEdit->text() ) );
1036 mAddressee.setNote( mNoteEdit->text() ); 1036 mAddressee.setNote( mNoteEdit->text() );
1037 if ( mBirthdayPicker->inputIsValid() ) 1037 if ( mBirthdayPicker->inputIsValid() )
1038 mAddressee.setBirthday( QDateTime( mBirthdayPicker->date() ) ); 1038 mAddressee.setBirthday( QDateTime( mBirthdayPicker->date() ) );
1039 else 1039 else
1040 mAddressee.setBirthday( QDateTime() ); 1040 mAddressee.setBirthday( QDateTime() );
1041 1041
1042 mAddressee.setNickName( mNicknameEdit->text() ); 1042 mAddressee.setNickName( mNicknameEdit->text() );
1043 mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); 1043 mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) );
1044 1044
1045 mAddressee.setGeo( mGeoWidget->geo() ); 1045 mAddressee.setGeo( mGeoWidget->geo() );
1046 mAddressee.setPhoto( mImageWidget->photo() ); 1046 mAddressee.setPhoto( mImageWidget->photo() );
1047 mAddressee.setLogo( mImageWidget->logo() ); 1047 mAddressee.setLogo( mImageWidget->logo() );
1048 mAddressee.setKeys( mKeyWidget->keys() ); 1048 mAddressee.setKeys( mKeyWidget->keys() );
1049#ifndef KAB_EMBEDDED 1049#ifndef KAB_EMBEDDED
1050 mAddressee.setSound( mSoundWidget->sound() ); 1050 mAddressee.setSound( mSoundWidget->sound() );
1051#else //KAB_EMBEDDED 1051#else //KAB_EMBEDDED
1052//US qDebug("AddresseeEditorWidget::save sound not supported"); 1052//US qDebug("AddresseeEditorWidget::save sound not supported");
1053#endif //KAB_EMBEDDED 1053#endif //KAB_EMBEDDED
1054 mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); 1054 mAddressee.setSecrecy( mSecrecyWidget->secrecy() );
1055 1055
1056 // save custom fields 1056 // save custom fields
1057 mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); 1057 mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() );
1058 mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); 1058 mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() );
1059 mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); 1059 mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() );
1060 mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); 1060 mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() );
1061 mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); 1061 mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() );
1062 mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); 1062 mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() );
1063 mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); 1063 mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() );
1064 if ( mAnniversaryPicker->inputIsValid() ) { 1064 if ( mAnniversaryPicker->inputIsValid() ) {
1065 1065
1066//US mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", 1066//US mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary",
1067//US mAnniversaryPicker->date().toString( Qt::ISODate ) ); 1067//US mAnniversaryPicker->date().toString( Qt::ISODate ) );
1068 int orgformat = KGlobal::locale()->getIntDateFormat(); 1068 QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate);
1069 QDate da = mAnniversaryPicker->date();
1070 KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate
1071 QString dt = KGlobal::locale()->formatDate(da, true);
1072 KGlobal::locale()->setIntDateFormat(orgformat );
1073 mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 1069 mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
1074 } 1070 }
1075 else 1071 else
1076 mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); 1072 mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" );
1077 1073
1078 // Save the email addresses 1074 // Save the email addresses
1079 QStringList emails = mAddressee.emails(); 1075 QStringList emails = mAddressee.emails();
1080 QStringList::Iterator iter; 1076 QStringList::Iterator iter;
1081 for ( iter = emails.begin(); iter != emails.end(); ++iter ) 1077 for ( iter = emails.begin(); iter != emails.end(); ++iter )
1082 mAddressee.removeEmail( *iter ); 1078 mAddressee.removeEmail( *iter );
1083 1079
1084 emails = mEmailWidget->emails(); 1080 emails = mEmailWidget->emails();
1085 bool first = true; 1081 bool first = true;
1086 for ( iter = emails.begin(); iter != emails.end(); ++iter ) { 1082 for ( iter = emails.begin(); iter != emails.end(); ++iter ) {
1087 mAddressee.insertEmail( *iter, first ); 1083 mAddressee.insertEmail( *iter, first );
1088 first = false; 1084 first = false;
1089 } 1085 }
1090 1086
1091 // Save the phone numbers 1087 // Save the phone numbers
1092 KABC::PhoneNumber::List phoneNumbers; 1088 KABC::PhoneNumber::List phoneNumbers;
1093 KABC::PhoneNumber::List::Iterator phoneIter; 1089 KABC::PhoneNumber::List::Iterator phoneIter;
1094 phoneNumbers = mAddressee.phoneNumbers(); 1090 phoneNumbers = mAddressee.phoneNumbers();
1095 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 1091 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
1096 ++phoneIter ) 1092 ++phoneIter )
1097 mAddressee.removePhoneNumber( *phoneIter ); 1093 mAddressee.removePhoneNumber( *phoneIter );
1098 1094
1099 phoneNumbers = mPhoneEditWidget->phoneNumbers(); 1095 phoneNumbers = mPhoneEditWidget->phoneNumbers();
1100 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 1096 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
1101 ++phoneIter ) 1097 ++phoneIter )
1102 mAddressee.insertPhoneNumber( *phoneIter ); 1098 mAddressee.insertPhoneNumber( *phoneIter );
1103 1099
1104 // Save the addresses 1100 // Save the addresses
1105 KABC::Address::List addresses; 1101 KABC::Address::List addresses;
1106 KABC::Address::List::Iterator addressIter; 1102 KABC::Address::List::Iterator addressIter;
1107 addresses = mAddressee.addresses(); 1103 addresses = mAddressee.addresses();
1108 for ( addressIter = addresses.begin(); addressIter != addresses.end(); 1104 for ( addressIter = addresses.begin(); addressIter != addresses.end();
1109 ++addressIter ) 1105 ++addressIter )
1110 mAddressee.removeAddress( *addressIter ); 1106 mAddressee.removeAddress( *addressIter );
1111 1107
1112 addresses = mAddressEditWidget->addresses(); 1108 addresses = mAddressEditWidget->addresses();
1113 for ( addressIter = addresses.begin(); addressIter != addresses.end(); 1109 for ( addressIter = addresses.begin(); addressIter != addresses.end();
1114 ++addressIter ) 1110 ++addressIter )
1115 mAddressee.insertAddress( *addressIter ); 1111 mAddressee.insertAddress( *addressIter );
1116 mDirty = false; 1112 mDirty = false;
1117} 1113}
1118 1114
1119bool AddresseeEditorWidget::dirty() 1115bool AddresseeEditorWidget::dirty()
1120{ 1116{
1121 return mDirty; 1117 return mDirty;
1122} 1118}
1123 1119
1124void AddresseeEditorWidget::nameTextChanged( const QString &text ) 1120void AddresseeEditorWidget::nameTextChanged( const QString &text )
1125{ 1121{
1126 // use the addressee class to parse the name for us 1122 // use the addressee class to parse the name for us
1127 mAConfig->setUid( mAddressee.uid() ); 1123 mAConfig->setUid( mAddressee.uid() );
1128 if ( mAConfig->automaticNameParsing() ) { 1124 if ( mAConfig->automaticNameParsing() ) {
1129 if ( !mAddressee.formattedName().isEmpty() ) { 1125 if ( !mAddressee.formattedName().isEmpty() ) {
1130 QString fn = mAddressee.formattedName(); 1126 QString fn = mAddressee.formattedName();
1131 mAddressee.setNameFromString( text ); 1127 mAddressee.setNameFromString( text );
1132 mAddressee.setFormattedName( fn ); 1128 mAddressee.setFormattedName( fn );
1133 } else { 1129 } else {
1134 // use extra addressee to avoid a formatted name assignment 1130 // use extra addressee to avoid a formatted name assignment
1135 Addressee addr; 1131 Addressee addr;
1136 addr.setNameFromString( text ); 1132 addr.setNameFromString( text );
1137 mAddressee.setPrefix( addr.prefix() ); 1133 mAddressee.setPrefix( addr.prefix() );
1138 mAddressee.setGivenName( addr.givenName() ); 1134 mAddressee.setGivenName( addr.givenName() );
1139 mAddressee.setAdditionalName( addr.additionalName() ); 1135 mAddressee.setAdditionalName( addr.additionalName() );
1140 mAddressee.setFamilyName( addr.familyName() ); 1136 mAddressee.setFamilyName( addr.familyName() );
1141 mAddressee.setSuffix( addr.suffix() ); 1137 mAddressee.setSuffix( addr.suffix() );
1142 } 1138 }
1143 } 1139 }
1144 1140
1145 nameBoxChanged(); 1141 nameBoxChanged();
1146 1142
1147 emitModified(); 1143 emitModified();
1148} 1144}
1149 1145
1150void AddresseeEditorWidget::nameBoxChanged() 1146void AddresseeEditorWidget::nameBoxChanged()
1151{ 1147{
1152 KABC::Addressee addr; 1148 KABC::Addressee addr;
1153 mAConfig->setUid( mAddressee.uid() ); 1149 mAConfig->setUid( mAddressee.uid() );
1154 if ( mAConfig->automaticNameParsing() ) { 1150 if ( mAConfig->automaticNameParsing() ) {
1155 addr.setNameFromString( mNameEdit->text() ); 1151 addr.setNameFromString( mNameEdit->text() );
1156 mNameLabel->hide(); 1152 mNameLabel->hide();
1157 mNameEdit->show(); 1153 mNameEdit->show();
1158 } else { 1154 } else {
1159 addr = mAddressee; 1155 addr = mAddressee;
1160 mNameEdit->hide(); 1156 mNameEdit->hide();
1161 mNameLabel->setText( mNameEdit->text() ); 1157 mNameLabel->setText( mNameEdit->text() );
1162 mNameLabel->show(); 1158 mNameLabel->show();
1163 } 1159 }
1164 1160
1165 if ( mFormattedNameType != NameEditDialog::CustomName ) { 1161 if ( mFormattedNameType != NameEditDialog::CustomName ) {
1166 mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 1162 mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
1167 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 1163 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
1168 } 1164 }
1169} 1165}
1170 1166
1171void AddresseeEditorWidget::nameButtonClicked() 1167void AddresseeEditorWidget::nameButtonClicked()
1172{ 1168{
1173 // show the name dialog. 1169 // show the name dialog.
1174 NameEditDialog dialog( mAddressee, mFormattedNameType, this ); 1170 NameEditDialog dialog( mAddressee, mFormattedNameType, this );
1175 1171
1176 if ( dialog.exec() ) { 1172 if ( dialog.exec() ) {
1177 if ( dialog.changed() ) { 1173 if ( dialog.changed() ) {
1178 mAddressee.setFamilyName( dialog.familyName() ); 1174 mAddressee.setFamilyName( dialog.familyName() );
1179 mAddressee.setGivenName( dialog.givenName() ); 1175 mAddressee.setGivenName( dialog.givenName() );
1180 mAddressee.setPrefix( dialog.prefix() ); 1176 mAddressee.setPrefix( dialog.prefix() );
1181 mAddressee.setSuffix( dialog.suffix() ); 1177 mAddressee.setSuffix( dialog.suffix() );
1182 mAddressee.setAdditionalName( dialog.additionalName() ); 1178 mAddressee.setAdditionalName( dialog.additionalName() );
1183 mFormattedNameType = dialog.formattedNameType(); 1179 mFormattedNameType = dialog.formattedNameType();
1184 if ( mFormattedNameType == NameEditDialog::CustomName ) { 1180 if ( mFormattedNameType == NameEditDialog::CustomName ) {
1185 mFormattedNameLabel->setText( dialog.customFormattedName() ); 1181 mFormattedNameLabel->setText( dialog.customFormattedName() );
1186 mAddressee.setFormattedName( dialog.customFormattedName() ); 1182 mAddressee.setFormattedName( dialog.customFormattedName() );
1187 } 1183 }
1188 // Update the name edit. 1184 // Update the name edit.
1189 bool block = mNameEdit->signalsBlocked(); 1185 bool block = mNameEdit->signalsBlocked();
1190 mNameEdit->blockSignals( true ); 1186 mNameEdit->blockSignals( true );
1191 mNameEdit->setText( mAddressee.assembledName() ); 1187 mNameEdit->setText( mAddressee.assembledName() );
1192 mNameEdit->blockSignals( block ); 1188 mNameEdit->blockSignals( block );
1193 1189
1194 // Update the combo box. 1190 // Update the combo box.
1195 nameBoxChanged(); 1191 nameBoxChanged();
1196 1192
1197 emitModified(); 1193 emitModified();
1198 } 1194 }
1199 } 1195 }
1200} 1196}
1201 1197
1202void AddresseeEditorWidget::categoryButtonClicked() 1198void AddresseeEditorWidget::categoryButtonClicked()
1203{ 1199{
1204 // Show the category dialog 1200 // Show the category dialog
1205 if ( mCategoryDialog == 0 ) { 1201 if ( mCategoryDialog == 0 ) {
1206 mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this ); 1202 mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this );
1207 connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ), 1203 connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ),
1208 SLOT(categoriesSelected( const QStringList& ) ) ); 1204 SLOT(categoriesSelected( const QStringList& ) ) );
1209 connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) ); 1205 connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) );
1210 } 1206 }
1211 1207
1212 mCategoryDialog->setCategories(); 1208 mCategoryDialog->setCategories();
1213 mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) ); 1209 mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) );
1214 mCategoryDialog->show(); 1210 mCategoryDialog->show();
1215 mCategoryDialog->raise(); 1211 mCategoryDialog->raise();
1216} 1212}
1217 1213
1218void AddresseeEditorWidget::categoriesSelected( const QStringList &list ) 1214void AddresseeEditorWidget::categoriesSelected( const QStringList &list )
1219{ 1215{
1220 mCategoryEdit->setText( list.join( "," ) ); 1216 mCategoryEdit->setText( list.join( "," ) );
1221} 1217}
1222 1218
1223void AddresseeEditorWidget::editCategories() 1219void AddresseeEditorWidget::editCategories()
1224{ 1220{
1225 if ( mCategoryEditDialog == 0 ) { 1221 if ( mCategoryEditDialog == 0 ) {
1226 mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this ); 1222 mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this );
1227 connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), 1223 connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ),
1228 SLOT( categoryButtonClicked() ) ); 1224 SLOT( categoryButtonClicked() ) );
1229 } 1225 }
1230 1226
1231 mCategoryEditDialog->show(); 1227 mCategoryEditDialog->show();
1232 mCategoryEditDialog->raise(); 1228 mCategoryEditDialog->raise();
1233} 1229}
1234 1230
1235void AddresseeEditorWidget::emitModified() 1231void AddresseeEditorWidget::emitModified()
1236{ 1232{
1237 mDirty = true; 1233 mDirty = true;
1238 1234
1239 KABC::Addressee::List list; 1235 KABC::Addressee::List list;
1240 1236
1241 if ( mIsExtension && !mBlockSignals ) { 1237 if ( mIsExtension && !mBlockSignals ) {
1242 save(); 1238 save();
1243 list.append( mAddressee ); 1239 list.append( mAddressee );
1244 } 1240 }
1245 1241
1246 emit modified( list ); 1242 emit modified( list );
1247} 1243}
1248 1244
1249void AddresseeEditorWidget::dateChanged( QDate ) 1245void AddresseeEditorWidget::dateChanged( QDate )
1250{ 1246{
1251 emitModified(); 1247 emitModified();
1252} 1248}
1253 1249
1254//US invalid dates are handdled by the KDateEdit widget itself 1250//US invalid dates are handdled by the KDateEdit widget itself
1255void AddresseeEditorWidget::invalidDate() 1251void AddresseeEditorWidget::invalidDate()
1256{ 1252{
1257 KMessageBox::sorry( this, i18n( "You must specify a valid date" ) ); 1253 KMessageBox::sorry( this, i18n( "You must specify a valid date" ) );
1258} 1254}
1259 1255
1260 1256
1261void AddresseeEditorWidget::pageChanged( QWidget *wdg ) 1257void AddresseeEditorWidget::pageChanged( QWidget *wdg )
1262{ 1258{
1263#ifndef KAB_EMBEDDED 1259#ifndef KAB_EMBEDDED
1264 if ( wdg ) 1260 if ( wdg )
1265 KAcceleratorManager::manage( wdg ); 1261 KAcceleratorManager::manage( wdg );
1266#else //KAB_EMBEDDED 1262#else //KAB_EMBEDDED
1267//US 1263//US
1268#endif //KAB_EMBEDDED 1264#endif //KAB_EMBEDDED
1269 1265
1270} 1266}
1271 1267
1272QString AddresseeEditorWidget::title() const 1268QString AddresseeEditorWidget::title() const
1273{ 1269{
1274 return i18n( "Contact Editor" ); 1270 return i18n( "Contact Editor" );
1275} 1271}
1276 1272
1277QString AddresseeEditorWidget::identifier() const 1273QString AddresseeEditorWidget::identifier() const
1278{ 1274{
1279 return i18n( "contact_editor" ); 1275 return i18n( "contact_editor" );
1280} 1276}
1281 1277
1282#ifndef KAB_EMBEDDED 1278#ifndef KAB_EMBEDDED
1283#include "addresseeeditorwidget.moc" 1279#include "addresseeeditorwidget.moc"
1284#endif //KAB_EMBEDDED 1280#endif //KAB_EMBEDDED
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index c3c3d47..58b3d70 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3502 +1,3502 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include "kosyncprefsdialog.h" 61#include "kosyncprefsdialog.h"
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#ifndef KORG_NOMAIL 86#ifndef KORG_NOMAIL
87#include "komailclient.h" 87#include "komailclient.h"
88#endif 88#endif
89#ifndef KORG_NOPRINTER 89#ifndef KORG_NOPRINTER
90#include "calprinter.h" 90#include "calprinter.h"
91#endif 91#endif
92#ifndef KORG_NOPLUGINS 92#ifndef KORG_NOPLUGINS
93#include "kocore.h" 93#include "kocore.h"
94#endif 94#endif
95#include "koeventeditor.h" 95#include "koeventeditor.h"
96#include "kotodoeditor.h" 96#include "kotodoeditor.h"
97#include "koprefs.h" 97#include "koprefs.h"
98#include "koeventviewerdialog.h" 98#include "koeventviewerdialog.h"
99#include "publishdialog.h" 99#include "publishdialog.h"
100#include "kofilterview.h" 100#include "kofilterview.h"
101#include "koglobals.h" 101#include "koglobals.h"
102#include "koviewmanager.h" 102#include "koviewmanager.h"
103#include "koagendaview.h" 103#include "koagendaview.h"
104#include "kodialogmanager.h" 104#include "kodialogmanager.h"
105#include "outgoingdialog.h" 105#include "outgoingdialog.h"
106#include "incomingdialog.h" 106#include "incomingdialog.h"
107#include "statusdialog.h" 107#include "statusdialog.h"
108#include "kdatenavigator.h" 108#include "kdatenavigator.h"
109#include "kotodoview.h" 109#include "kotodoview.h"
110#include "datenavigator.h" 110#include "datenavigator.h"
111#include "resourceview.h" 111#include "resourceview.h"
112#include "navigatorbar.h" 112#include "navigatorbar.h"
113#include "searchdialog.h" 113#include "searchdialog.h"
114#include "mainwindow.h" 114#include "mainwindow.h"
115 115
116#include "calendarview.h" 116#include "calendarview.h"
117#ifndef DESKTOP_VERSION 117#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h> 118#include <qtopia/alarmserver.h>
119#endif 119#endif
120#ifndef _WIN32_ 120#ifndef _WIN32_
121#include <stdlib.h> 121#include <stdlib.h>
122#include <stdio.h> 122#include <stdio.h>
123#include <unistd.h> 123#include <unistd.h>
124#else 124#else
125#include <qprocess.h> 125#include <qprocess.h>
126#endif 126#endif
127using namespace KOrg; 127using namespace KOrg;
128using namespace KCal; 128using namespace KCal;
129extern int globalFlagBlockAgenda; 129extern int globalFlagBlockAgenda;
130extern int globalFlagBlockStartup; 130extern int globalFlagBlockStartup;
131 131
132#define SYNC_MODE_NORMAL 0 132#define SYNC_MODE_NORMAL 0
133#define SYNC_MODE_SHARP 1 133#define SYNC_MODE_SHARP 1
134#define SYNC_MODE_QTOPIA 2 134#define SYNC_MODE_QTOPIA 2
135 135
136class KOBeamPrefs : public QDialog 136class KOBeamPrefs : public QDialog
137{ 137{
138 public: 138 public:
139 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 139 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
140 QDialog( parent, name, true ) 140 QDialog( parent, name, true )
141 { 141 {
142 setCaption( i18n("Beam Options") ); 142 setCaption( i18n("Beam Options") );
143 QVBoxLayout* lay = new QVBoxLayout( this ); 143 QVBoxLayout* lay = new QVBoxLayout( this );
144 lay->setSpacing( 3 ); 144 lay->setSpacing( 3 );
145 lay->setMargin( 3 ); 145 lay->setMargin( 3 );
146 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 146 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
147 lay->addWidget( format ); 147 lay->addWidget( format );
148 format->setExclusive ( true ) ; 148 format->setExclusive ( true ) ;
149 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 149 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
150 lay->addWidget( time ); time->setExclusive ( true ) ; 150 lay->addWidget( time ); time->setExclusive ( true ) ;
151 vcal = new QRadioButton(" vCalendar ", format ); 151 vcal = new QRadioButton(" vCalendar ", format );
152 ical = new QRadioButton(" iCalendar ", format ); 152 ical = new QRadioButton(" iCalendar ", format );
153 vcal->setChecked( true ); 153 vcal->setChecked( true );
154 tz = new QRadioButton(i18n(" With timezone "), time ); 154 tz = new QRadioButton(i18n(" With timezone "), time );
155 local = new QRadioButton(i18n(" Local time "), time ); 155 local = new QRadioButton(i18n(" Local time "), time );
156 tz->setChecked( true ); 156 tz->setChecked( true );
157 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 157 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
158 lay->addWidget( ok ); 158 lay->addWidget( ok );
159 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 159 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
160 lay->addWidget( cancel ); 160 lay->addWidget( cancel );
161 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 161 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
162 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 162 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
163 resize( 200, 200 ); 163 resize( 200, 200 );
164 } 164 }
165 165
166 bool beamVcal() { return vcal->isChecked(); } 166 bool beamVcal() { return vcal->isChecked(); }
167 bool beamLocal() { return local->isChecked(); } 167 bool beamLocal() { return local->isChecked(); }
168private: 168private:
169 QRadioButton* vcal, *ical, *local, *tz; 169 QRadioButton* vcal, *ical, *local, *tz;
170}; 170};
171class KOCatPrefs : public QDialog 171class KOCatPrefs : public QDialog
172{ 172{
173 public: 173 public:
174 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 174 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
175 QDialog( parent, name, true ) 175 QDialog( parent, name, true )
176 { 176 {
177 setCaption( i18n("Manage new Categories") ); 177 setCaption( i18n("Manage new Categories") );
178 QVBoxLayout* lay = new QVBoxLayout( this ); 178 QVBoxLayout* lay = new QVBoxLayout( this );
179 lay->setSpacing( 3 ); 179 lay->setSpacing( 3 );
180 lay->setMargin( 3 ); 180 lay->setMargin( 3 );
181 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 181 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
182 lay->addWidget( lab ); 182 lay->addWidget( lab );
183 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 183 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
184 lay->addWidget( format ); 184 lay->addWidget( format );
185 format->setExclusive ( true ) ; 185 format->setExclusive ( true ) ;
186 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 186 addCatBut = new QRadioButton(i18n("Add to category list"), format );
187 new QRadioButton(i18n("Remove from Events/Todos"), format ); 187 new QRadioButton(i18n("Remove from Events/Todos"), format );
188 addCatBut->setChecked( true ); 188 addCatBut->setChecked( true );
189 QPushButton * ok = new QPushButton( i18n("OK"), this ); 189 QPushButton * ok = new QPushButton( i18n("OK"), this );
190 lay->addWidget( ok ); 190 lay->addWidget( ok );
191 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 191 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
192 lay->addWidget( cancel ); 192 lay->addWidget( cancel );
193 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 193 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
194 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 194 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
195 resize( 200, 200 ); 195 resize( 200, 200 );
196 } 196 }
197 197
198 bool addCat() { return addCatBut->isChecked(); } 198 bool addCat() { return addCatBut->isChecked(); }
199private: 199private:
200 QRadioButton* addCatBut; 200 QRadioButton* addCatBut;
201}; 201};
202 202
203 203
204 204
205CalendarView::CalendarView( CalendarResources *calendar, 205CalendarView::CalendarView( CalendarResources *calendar,
206 QWidget *parent, const char *name ) 206 QWidget *parent, const char *name )
207 : CalendarViewBase( parent, name ), 207 : CalendarViewBase( parent, name ),
208 mCalendar( calendar ), 208 mCalendar( calendar ),
209 mResourceManager( calendar->resourceManager() ) 209 mResourceManager( calendar->resourceManager() )
210{ 210{
211 211
212 mEventEditor = 0; 212 mEventEditor = 0;
213 mTodoEditor = 0; 213 mTodoEditor = 0;
214 214
215 init(); 215 init();
216} 216}
217 217
218CalendarView::CalendarView( Calendar *calendar, 218CalendarView::CalendarView( Calendar *calendar,
219 QWidget *parent, const char *name ) 219 QWidget *parent, const char *name )
220 : CalendarViewBase( parent, name ), 220 : CalendarViewBase( parent, name ),
221 mCalendar( calendar ), 221 mCalendar( calendar ),
222 mResourceManager( 0 ) 222 mResourceManager( 0 )
223{ 223{
224 224
225 mEventEditor = 0; 225 mEventEditor = 0;
226 mTodoEditor = 0; 226 mTodoEditor = 0;
227 init();} 227 init();}
228 228
229void CalendarView::init() 229void CalendarView::init()
230{ 230{
231 beamDialog = new KOBeamPrefs(); 231 beamDialog = new KOBeamPrefs();
232 mDatePickerMode = 0; 232 mDatePickerMode = 0;
233 mCurrentSyncDevice = ""; 233 mCurrentSyncDevice = "";
234 writeLocale(); 234 writeLocale();
235 mViewManager = new KOViewManager( this ); 235 mViewManager = new KOViewManager( this );
236 mDialogManager = new KODialogManager( this ); 236 mDialogManager = new KODialogManager( this );
237 mEventViewerDialog = 0; 237 mEventViewerDialog = 0;
238 mModified = false; 238 mModified = false;
239 mReadOnly = false; 239 mReadOnly = false;
240 mSelectedIncidence = 0; 240 mSelectedIncidence = 0;
241 mSyncProfiles.setAutoDelete(true); 241 mSyncProfiles.setAutoDelete(true);
242 mCalPrinter = 0; 242 mCalPrinter = 0;
243 mFilters.setAutoDelete(true); 243 mFilters.setAutoDelete(true);
244 244
245 mCalendar->registerObserver( this ); 245 mCalendar->registerObserver( this );
246 // TODO: Make sure that view is updated, when calendar is changed. 246 // TODO: Make sure that view is updated, when calendar is changed.
247 247
248 mStorage = new FileStorage( mCalendar ); 248 mStorage = new FileStorage( mCalendar );
249 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 249 mNavigator = new DateNavigator( this, "datevav", mViewManager );
250 250
251 QBoxLayout *topLayout = (QBoxLayout*)layout(); 251 QBoxLayout *topLayout = (QBoxLayout*)layout();
252#ifndef KORG_NOSPLITTER 252#ifndef KORG_NOSPLITTER
253 // create the main layout frames. 253 // create the main layout frames.
254 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 254 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
255 topLayout->addWidget(mPanner); 255 topLayout->addWidget(mPanner);
256 256
257 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 257 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
258 "CalendarView::LeftFrame"); 258 "CalendarView::LeftFrame");
259 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 259 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
260 260
261 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 261 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
262 "CalendarView::DateNavigator", QDate::currentDate() ); 262 "CalendarView::DateNavigator", QDate::currentDate() );
263 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 263 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
264 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 264 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
265 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 265 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
266 266
267#ifdef KORG_NORESOURCEVIEW 267#ifdef KORG_NORESOURCEVIEW
268 mResourceView = 0; 268 mResourceView = 0;
269#else 269#else
270 if ( mResourceManager ) { 270 if ( mResourceManager ) {
271 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 271 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
272 mResourceView->updateView(); 272 mResourceView->updateView();
273 connect( mResourceView, SIGNAL( resourcesChanged() ), 273 connect( mResourceView, SIGNAL( resourcesChanged() ),
274 SLOT( updateView() ) ); 274 SLOT( updateView() ) );
275 } else { 275 } else {
276 mResourceView = 0; 276 mResourceView = 0;
277 } 277 }
278#endif 278#endif
279 QWidget *rightBox = new QWidget( mPanner ); 279 QWidget *rightBox = new QWidget( mPanner );
280 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 280 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
281 281
282 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 282 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
283 rightLayout->addWidget( mNavigatorBar ); 283 rightLayout->addWidget( mNavigatorBar );
284 284
285 mRightFrame = new QWidgetStack( rightBox ); 285 mRightFrame = new QWidgetStack( rightBox );
286 rightLayout->addWidget( mRightFrame, 1 ); 286 rightLayout->addWidget( mRightFrame, 1 );
287 287
288 mLeftFrame = mLeftSplitter; 288 mLeftFrame = mLeftSplitter;
289#else 289#else
290 QWidget *mainBox = new QWidget( this ); 290 QWidget *mainBox = new QWidget( this );
291 QWidget *leftFrame = new QWidget( mainBox ); 291 QWidget *leftFrame = new QWidget( mainBox );
292 292
293 QBoxLayout * mainBoxLayout; 293 QBoxLayout * mainBoxLayout;
294 QBoxLayout * leftFrameLayout; 294 QBoxLayout * leftFrameLayout;
295 if ( KOPrefs::instance()->mVerticalScreen ) { 295 if ( KOPrefs::instance()->mVerticalScreen ) {
296 mainBoxLayout = new QVBoxLayout(mainBox); 296 mainBoxLayout = new QVBoxLayout(mainBox);
297 leftFrameLayout = new QHBoxLayout(leftFrame ); 297 leftFrameLayout = new QHBoxLayout(leftFrame );
298 } else { 298 } else {
299 mainBoxLayout = new QHBoxLayout(mainBox); 299 mainBoxLayout = new QHBoxLayout(mainBox);
300 leftFrameLayout = new QVBoxLayout(leftFrame ); 300 leftFrameLayout = new QVBoxLayout(leftFrame );
301 } 301 }
302 topLayout->addWidget( mainBox ); 302 topLayout->addWidget( mainBox );
303 mainBoxLayout->addWidget (leftFrame); 303 mainBoxLayout->addWidget (leftFrame);
304 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 304 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
305 "CalendarView::DateNavigator", QDate::currentDate()); 305 "CalendarView::DateNavigator", QDate::currentDate());
306 // mDateNavigator->blockSignals( true ); 306 // mDateNavigator->blockSignals( true );
307 leftFrameLayout->addWidget( mDateNavigator ); 307 leftFrameLayout->addWidget( mDateNavigator );
308 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 308 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
309 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 309 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
310 310
311 if ( QApplication::desktop()->width() < 480 ) { 311 if ( QApplication::desktop()->width() < 480 ) {
312 leftFrameLayout->addWidget(mFilterView); 312 leftFrameLayout->addWidget(mFilterView);
313 leftFrameLayout->addWidget(mTodoList, 2 ); 313 leftFrameLayout->addWidget(mTodoList, 2 );
314 314
315 } else { 315 } else {
316 leftFrameLayout->addWidget(mTodoList,2 ); 316 leftFrameLayout->addWidget(mTodoList,2 );
317 leftFrameLayout->addWidget(mFilterView ); 317 leftFrameLayout->addWidget(mFilterView );
318 } 318 }
319 mFilterView->hide(); 319 mFilterView->hide();
320 QWidget *rightBox = new QWidget( mainBox ); 320 QWidget *rightBox = new QWidget( mainBox );
321 mainBoxLayout->addWidget ( rightBox, 10 ); 321 mainBoxLayout->addWidget ( rightBox, 10 );
322 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 322 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
323 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 323 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
324 mRightFrame = new QWidgetStack( rightBox ); 324 mRightFrame = new QWidgetStack( rightBox );
325 rightLayout->addWidget( mNavigatorBar ); 325 rightLayout->addWidget( mNavigatorBar );
326 rightLayout->addWidget( mRightFrame, 10 ); 326 rightLayout->addWidget( mRightFrame, 10 );
327 327
328 mLeftFrame = leftFrame; 328 mLeftFrame = leftFrame;
329 if ( KOPrefs::instance()->mVerticalScreen ) { 329 if ( KOPrefs::instance()->mVerticalScreen ) {
330 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 330 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
331 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 331 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
332 } else { 332 } else {
333 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 333 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
334 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 334 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
335 } 335 }
336 336
337 //qDebug("Calendarview Size %d %d ", width(), height()); 337 //qDebug("Calendarview Size %d %d ", width(), height());
338#endif 338#endif
339 339
340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
341 SLOT( showDates( const KCal::DateList & ) ) ); 341 SLOT( showDates( const KCal::DateList & ) ) );
342 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 342 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
343 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 343 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
344 344
345 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 345 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
346 mNavigator, SLOT( selectPreviousYear() ) ); 346 mNavigator, SLOT( selectPreviousYear() ) );
347 connect( mNavigatorBar, SIGNAL( goNextYear() ), 347 connect( mNavigatorBar, SIGNAL( goNextYear() ),
348 mNavigator, SLOT( selectNextYear() ) ); 348 mNavigator, SLOT( selectNextYear() ) );
349 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 349 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
350 mNavigator, SLOT( selectPreviousMonth() ) ); 350 mNavigator, SLOT( selectPreviousMonth() ) );
351 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 351 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
352 mNavigator, SLOT( selectNextMonth() ) ); 352 mNavigator, SLOT( selectNextMonth() ) );
353 353
354 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 354 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
355 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 355 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
356 356
357 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 357 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
358 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 358 mNavigator, SLOT( selectWeek( const QDate & ) ) );
359 359
360 connect( mDateNavigator, SIGNAL( goPrevYear() ), 360 connect( mDateNavigator, SIGNAL( goPrevYear() ),
361 mNavigator, SLOT( selectPreviousYear() ) ); 361 mNavigator, SLOT( selectPreviousYear() ) );
362 connect( mDateNavigator, SIGNAL( goNextYear() ), 362 connect( mDateNavigator, SIGNAL( goNextYear() ),
363 mNavigator, SLOT( selectNextYear() ) ); 363 mNavigator, SLOT( selectNextYear() ) );
364 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 364 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
365 mNavigator, SLOT( selectPreviousMonth() ) ); 365 mNavigator, SLOT( selectPreviousMonth() ) );
366 connect( mDateNavigator, SIGNAL( goNextMonth() ), 366 connect( mDateNavigator, SIGNAL( goNextMonth() ),
367 mNavigator, SLOT( selectNextMonth() ) ); 367 mNavigator, SLOT( selectNextMonth() ) );
368 368
369 connect( mDateNavigator, SIGNAL( goPrevious() ), 369 connect( mDateNavigator, SIGNAL( goPrevious() ),
370 mNavigator, SLOT( selectPrevious() ) ); 370 mNavigator, SLOT( selectPrevious() ) );
371 connect( mDateNavigator, SIGNAL( goNext() ), 371 connect( mDateNavigator, SIGNAL( goNext() ),
372 mNavigator, SLOT( selectNext() ) ); 372 mNavigator, SLOT( selectNext() ) );
373 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 373 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
374 mNavigator, SLOT( slotMonthSelect( int ) ) ); 374 mNavigator, SLOT( slotMonthSelect( int ) ) );
375 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 375 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
376 mNavigator, SLOT( slotMonthSelect( int ) ) ); 376 mNavigator, SLOT( slotMonthSelect( int ) ) );
377 377
378 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 378 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
379 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 379 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
380 380
381 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 381 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
382 SLOT( eventAdded( Event *) ) ); 382 SLOT( eventAdded( Event *) ) );
383 383
384 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 384 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
385 385
386 connect( this, SIGNAL( configChanged() ), 386 connect( this, SIGNAL( configChanged() ),
387 mDateNavigator, SLOT( updateConfig() ) ); 387 mDateNavigator, SLOT( updateConfig() ) );
388 388
389 connect( mTodoList, SIGNAL( newTodoSignal() ), 389 connect( mTodoList, SIGNAL( newTodoSignal() ),
390 SLOT( newTodo() ) ); 390 SLOT( newTodo() ) );
391 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 391 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
392 SLOT( newSubTodo( Todo * ) ) ); 392 SLOT( newSubTodo( Todo * ) ) );
393 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 393 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
394 SLOT( editTodo( Todo * ) ) ); 394 SLOT( editTodo( Todo * ) ) );
395 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 395 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
396 SLOT( showTodo( Todo *) ) ); 396 SLOT( showTodo( Todo *) ) );
397 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 397 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
398 SLOT( deleteTodo( Todo *) ) ); 398 SLOT( deleteTodo( Todo *) ) );
399 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 399 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
400 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 400 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
401 SLOT( purgeCompleted() ) ); 401 SLOT( purgeCompleted() ) );
402 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 402 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
403 SIGNAL( todoModified( Todo *, int ) ) ); 403 SIGNAL( todoModified( Todo *, int ) ) );
404 404
405 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 405 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
406 this, SLOT ( cloneIncidence( Incidence * ) ) ); 406 this, SLOT ( cloneIncidence( Incidence * ) ) );
407 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 407 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
408 this, SLOT (cancelIncidence( Incidence * ) ) ); 408 this, SLOT (cancelIncidence( Incidence * ) ) );
409 409
410 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 410 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
411 this, SLOT ( moveIncidence( Incidence * ) ) ); 411 this, SLOT ( moveIncidence( Incidence * ) ) );
412 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 412 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
413 this, SLOT ( beamIncidence( Incidence * ) ) ); 413 this, SLOT ( beamIncidence( Incidence * ) ) );
414 414
415 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 415 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
416 this, SLOT ( todo_unsub( Todo * ) ) ); 416 this, SLOT ( todo_unsub( Todo * ) ) );
417 417
418 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 418 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
419 SLOT( updateTodo( Todo *, int ) ) ); 419 SLOT( updateTodo( Todo *, int ) ) );
420 connect( this, SIGNAL( todoModified( Todo *, int )), this, 420 connect( this, SIGNAL( todoModified( Todo *, int )), this,
421 SLOT( changeTodoDisplay( Todo *, int ) ) ); 421 SLOT( changeTodoDisplay( Todo *, int ) ) );
422 422
423 423
424 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 424 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
425 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 425 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
426 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 426 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
427 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 427 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
428 428
429 429
430 430
431 431
432 432
433 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 433 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
434 SLOT(checkClipboard())); 434 SLOT(checkClipboard()));
435 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 435 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
436 SLOT( processTodoListSelection( Incidence * ) ) ); 436 SLOT( processTodoListSelection( Incidence * ) ) );
437 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 437 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
438 438
439 // kdDebug() << "CalendarView::CalendarView() done" << endl; 439 // kdDebug() << "CalendarView::CalendarView() done" << endl;
440 440
441 mDateFrame = new QVBox(0,0,WType_Popup); 441 mDateFrame = new QVBox(0,0,WType_Popup);
442 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 442 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
443 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 443 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
444 mDateFrame->setLineWidth(3); 444 mDateFrame->setLineWidth(3);
445 mDateFrame->hide(); 445 mDateFrame->hide();
446 mDateFrame->setCaption( i18n( "Pick a date to display")); 446 mDateFrame->setCaption( i18n( "Pick a date to display"));
447 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 447 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
448 448
449 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 449 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
450 450
451 mEventEditor = mDialogManager->getEventEditor(); 451 mEventEditor = mDialogManager->getEventEditor();
452 mTodoEditor = mDialogManager->getTodoEditor(); 452 mTodoEditor = mDialogManager->getTodoEditor();
453 453
454 mFlagEditDescription = false; 454 mFlagEditDescription = false;
455 455
456 mSuspendTimer = new QTimer( this ); 456 mSuspendTimer = new QTimer( this );
457 mAlarmTimer = new QTimer( this ); 457 mAlarmTimer = new QTimer( this );
458 mRecheckAlarmTimer = new QTimer( this ); 458 mRecheckAlarmTimer = new QTimer( this );
459 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 459 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
460 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 460 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
461 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 461 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
462 mAlarmDialog = new AlarmDialog( this ); 462 mAlarmDialog = new AlarmDialog( this );
463 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 463 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
464 mAlarmDialog->setServerNotification( false ); 464 mAlarmDialog->setServerNotification( false );
465 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 465 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
466} 466}
467 467
468 468
469CalendarView::~CalendarView() 469CalendarView::~CalendarView()
470{ 470{
471 // kdDebug() << "~CalendarView()" << endl; 471 // kdDebug() << "~CalendarView()" << endl;
472 //qDebug("CalendarView::~CalendarView() "); 472 //qDebug("CalendarView::~CalendarView() ");
473 delete mDialogManager; 473 delete mDialogManager;
474 delete mViewManager; 474 delete mViewManager;
475 delete mStorage; 475 delete mStorage;
476 delete mDateFrame ; 476 delete mDateFrame ;
477 delete beamDialog; 477 delete beamDialog;
478 //kdDebug() << "~CalendarView() done" << endl; 478 //kdDebug() << "~CalendarView() done" << endl;
479} 479}
480void CalendarView::timerAlarm() 480void CalendarView::timerAlarm()
481{ 481{
482 //qDebug("CalendarView::timerAlarm() "); 482 //qDebug("CalendarView::timerAlarm() ");
483 computeAlarm(mAlarmNotification ); 483 computeAlarm(mAlarmNotification );
484} 484}
485 485
486void CalendarView::suspendAlarm() 486void CalendarView::suspendAlarm()
487{ 487{
488 //qDebug(" CalendarView::suspendAlarm() "); 488 //qDebug(" CalendarView::suspendAlarm() ");
489 computeAlarm(mSuspendAlarmNotification ); 489 computeAlarm(mSuspendAlarmNotification );
490 490
491} 491}
492 492
493void CalendarView::startAlarm( QString mess , QString filename) 493void CalendarView::startAlarm( QString mess , QString filename)
494{ 494{
495 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 495 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
496 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 496 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
497 497
498} 498}
499 499
500void CalendarView::checkNextTimerAlarm() 500void CalendarView::checkNextTimerAlarm()
501{ 501{
502 mCalendar->checkAlarmForIncidence( 0, true ); 502 mCalendar->checkAlarmForIncidence( 0, true );
503} 503}
504 504
505void CalendarView::computeAlarm( QString msg ) 505void CalendarView::computeAlarm( QString msg )
506{ 506{
507 507
508 QString mess = msg; 508 QString mess = msg;
509 QString mAlarmMessage = mess.mid( 9 ); 509 QString mAlarmMessage = mess.mid( 9 );
510 QString filename = MainWindow::resourcePath(); 510 QString filename = MainWindow::resourcePath();
511 filename += "koalarm.wav"; 511 filename += "koalarm.wav";
512 QString tempfilename; 512 QString tempfilename;
513 if ( mess.left( 13 ) == "suspend_alarm") { 513 if ( mess.left( 13 ) == "suspend_alarm") {
514 bool error = false; 514 bool error = false;
515 int len = mess.mid( 13 ).find("+++"); 515 int len = mess.mid( 13 ).find("+++");
516 if ( len < 2 ) 516 if ( len < 2 )
517 error = true; 517 error = true;
518 else { 518 else {
519 tempfilename = mess.mid( 13, len ); 519 tempfilename = mess.mid( 13, len );
520 if ( !QFile::exists( tempfilename ) ) 520 if ( !QFile::exists( tempfilename ) )
521 error = true; 521 error = true;
522 } 522 }
523 if ( ! error ) { 523 if ( ! error ) {
524 filename = tempfilename; 524 filename = tempfilename;
525 } 525 }
526 mAlarmMessage = mess.mid( 13+len+3 ); 526 mAlarmMessage = mess.mid( 13+len+3 );
527 //qDebug("suspend file %s ",tempfilename.latin1() ); 527 //qDebug("suspend file %s ",tempfilename.latin1() );
528 startAlarm( mAlarmMessage, filename); 528 startAlarm( mAlarmMessage, filename);
529 return; 529 return;
530 } 530 }
531 if ( mess.left( 11 ) == "timer_alarm") { 531 if ( mess.left( 11 ) == "timer_alarm") {
532 //mTimerTime = 0; 532 //mTimerTime = 0;
533 startAlarm( mess.mid( 11 ), filename ); 533 startAlarm( mess.mid( 11 ), filename );
534 return; 534 return;
535 } 535 }
536 if ( mess.left( 10 ) == "proc_alarm") { 536 if ( mess.left( 10 ) == "proc_alarm") {
537 bool error = false; 537 bool error = false;
538 int len = mess.mid( 10 ).find("+++"); 538 int len = mess.mid( 10 ).find("+++");
539 if ( len < 2 ) 539 if ( len < 2 )
540 error = true; 540 error = true;
541 else { 541 else {
542 tempfilename = mess.mid( 10, len ); 542 tempfilename = mess.mid( 10, len );
543 if ( !QFile::exists( tempfilename ) ) 543 if ( !QFile::exists( tempfilename ) )
544 error = true; 544 error = true;
545 } 545 }
546 if ( error ) { 546 if ( error ) {
547 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 547 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
548 mAlarmMessage += mess.mid( 10+len+3+9 ); 548 mAlarmMessage += mess.mid( 10+len+3+9 );
549 } else { 549 } else {
550 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 550 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
551 //qDebug("-----system command %s ",tempfilename.latin1() ); 551 //qDebug("-----system command %s ",tempfilename.latin1() );
552#ifndef _WIN32_ 552#ifndef _WIN32_
553 if ( vfork () == 0 ) { 553 if ( vfork () == 0 ) {
554 execl ( tempfilename.latin1(), 0 ); 554 execl ( tempfilename.latin1(), 0 );
555 return; 555 return;
556 } 556 }
557#else 557#else
558 QProcess* p = new QProcess(); 558 QProcess* p = new QProcess();
559 p->addArgument( tempfilename.latin1() ); 559 p->addArgument( tempfilename.latin1() );
560 p->start(); 560 p->start();
561 return; 561 return;
562#endif 562#endif
563 563
564 return; 564 return;
565 } 565 }
566 566
567 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 567 //qDebug("+++++++system command %s ",tempfilename.latin1() );
568 } 568 }
569 if ( mess.left( 11 ) == "audio_alarm") { 569 if ( mess.left( 11 ) == "audio_alarm") {
570 bool error = false; 570 bool error = false;
571 int len = mess.mid( 11 ).find("+++"); 571 int len = mess.mid( 11 ).find("+++");
572 if ( len < 2 ) 572 if ( len < 2 )
573 error = true; 573 error = true;
574 else { 574 else {
575 tempfilename = mess.mid( 11, len ); 575 tempfilename = mess.mid( 11, len );
576 if ( !QFile::exists( tempfilename ) ) 576 if ( !QFile::exists( tempfilename ) )
577 error = true; 577 error = true;
578 } 578 }
579 if ( ! error ) { 579 if ( ! error ) {
580 filename = tempfilename; 580 filename = tempfilename;
581 } 581 }
582 mAlarmMessage = mess.mid( 11+len+3+9 ); 582 mAlarmMessage = mess.mid( 11+len+3+9 );
583 //qDebug("audio file command %s ",tempfilename.latin1() ); 583 //qDebug("audio file command %s ",tempfilename.latin1() );
584 } 584 }
585 if ( mess.left( 9 ) == "cal_alarm") { 585 if ( mess.left( 9 ) == "cal_alarm") {
586 mAlarmMessage = mess.mid( 9 ) ; 586 mAlarmMessage = mess.mid( 9 ) ;
587 } 587 }
588 588
589 startAlarm( mAlarmMessage, filename ); 589 startAlarm( mAlarmMessage, filename );
590 590
591 591
592} 592}
593 593
594void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 594void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
595{ 595{
596 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 596 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
597 597
598 mSuspendAlarmNotification = noti; 598 mSuspendAlarmNotification = noti;
599 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 599 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
600 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 600 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
601 mSuspendTimer->start( ms , true ); 601 mSuspendTimer->start( ms , true );
602 602
603} 603}
604 604
605void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 605void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
606{ 606{
607 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 607 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
608 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 608 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
609#ifndef DESKTOP_VERSION 609#ifndef DESKTOP_VERSION
610 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 610 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
611#endif 611#endif
612 return; 612 return;
613 } 613 }
614 int maxSec; 614 int maxSec;
615 //maxSec = 5; //testing only 615 //maxSec = 5; //testing only
616 maxSec = 86400+3600; // one day+1hour 616 maxSec = 86400+3600; // one day+1hour
617 mAlarmNotification = noti; 617 mAlarmNotification = noti;
618 int sec = QDateTime::currentDateTime().secsTo( qdt ); 618 int sec = QDateTime::currentDateTime().secsTo( qdt );
619 if ( sec > maxSec ) { 619 if ( sec > maxSec ) {
620 mRecheckAlarmTimer->start( maxSec * 1000 ); 620 mRecheckAlarmTimer->start( maxSec * 1000 );
621 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 621 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
622 return; 622 return;
623 } else { 623 } else {
624 mRecheckAlarmTimer->stop(); 624 mRecheckAlarmTimer->stop();
625 } 625 }
626 //qDebug("Alarm timer started with secs: %d ", sec); 626 //qDebug("Alarm timer started with secs: %d ", sec);
627 mAlarmTimer->start( sec *1000 , true ); 627 mAlarmTimer->start( sec *1000 , true );
628 628
629} 629}
630// called by mRecheckAlarmTimer to get next alarm 630// called by mRecheckAlarmTimer to get next alarm
631// we need this, because a QTimer has only a max range of 25 days 631// we need this, because a QTimer has only a max range of 25 days
632void CalendarView::recheckTimerAlarm() 632void CalendarView::recheckTimerAlarm()
633{ 633{
634 mAlarmTimer->stop(); 634 mAlarmTimer->stop();
635 mRecheckAlarmTimer->stop(); 635 mRecheckAlarmTimer->stop();
636 mCalendar->checkAlarmForIncidence( 0, true ); 636 mCalendar->checkAlarmForIncidence( 0, true );
637} 637}
638void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 638void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
639{ 639{
640 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 640 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
641 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 641 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
642#ifndef DESKTOP_VERSION 642#ifndef DESKTOP_VERSION
643 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 643 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
644#endif 644#endif
645 return; 645 return;
646 } 646 }
647 mAlarmTimer->stop(); 647 mAlarmTimer->stop();
648} 648}
649void CalendarView::selectWeekNum ( int num ) 649void CalendarView::selectWeekNum ( int num )
650{ 650{
651 dateNavigator()->selectWeek( num ); 651 dateNavigator()->selectWeek( num );
652 mViewManager->showWeekView(); 652 mViewManager->showWeekView();
653} 653}
654KOViewManager *CalendarView::viewManager() 654KOViewManager *CalendarView::viewManager()
655{ 655{
656 return mViewManager; 656 return mViewManager;
657} 657}
658 658
659KODialogManager *CalendarView::dialogManager() 659KODialogManager *CalendarView::dialogManager()
660{ 660{
661 return mDialogManager; 661 return mDialogManager;
662} 662}
663 663
664QDate CalendarView::startDate() 664QDate CalendarView::startDate()
665{ 665{
666 DateList dates = mNavigator->selectedDates(); 666 DateList dates = mNavigator->selectedDates();
667 667
668 return dates.first(); 668 return dates.first();
669} 669}
670 670
671QDate CalendarView::endDate() 671QDate CalendarView::endDate()
672{ 672{
673 DateList dates = mNavigator->selectedDates(); 673 DateList dates = mNavigator->selectedDates();
674 674
675 return dates.last(); 675 return dates.last();
676} 676}
677 677
678 678
679void CalendarView::createPrinter() 679void CalendarView::createPrinter()
680{ 680{
681#ifndef KORG_NOPRINTER 681#ifndef KORG_NOPRINTER
682 if (!mCalPrinter) { 682 if (!mCalPrinter) {
683 mCalPrinter = new CalPrinter(this, mCalendar); 683 mCalPrinter = new CalPrinter(this, mCalendar);
684 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 684 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
685 } 685 }
686#endif 686#endif
687} 687}
688 688
689void CalendarView::confSync() 689void CalendarView::confSync()
690{ 690{
691 static KOSyncPrefsDialog* sp = 0; 691 static KOSyncPrefsDialog* sp = 0;
692 if ( ! sp ) { 692 if ( ! sp ) {
693 sp = new KOSyncPrefsDialog( this, "syncprefs", true ); 693 sp = new KOSyncPrefsDialog( this, "syncprefs", true );
694 } 694 }
695 sp->usrReadConfig(); 695 sp->usrReadConfig();
696#ifndef DESKTOP_VERSION 696#ifndef DESKTOP_VERSION
697 sp->showMaximized(); 697 sp->showMaximized();
698#else 698#else
699 sp->show(); 699 sp->show();
700#endif 700#endif
701 sp->exec(); 701 sp->exec();
702 702
703} 703}
704 704
705 705
706//KOPrefs::instance()->mWriteBackFile 706//KOPrefs::instance()->mWriteBackFile
707//KOPrefs::instance()->mWriteBackExistingOnly 707//KOPrefs::instance()->mWriteBackExistingOnly
708 708
709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
715 715
716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
717{ 717{
718 718
719 //void setZaurusId(int id); 719 //void setZaurusId(int id);
720 // int zaurusId() const; 720 // int zaurusId() const;
721 // void setZaurusUid(int id); 721 // void setZaurusUid(int id);
722 // int zaurusUid() const; 722 // int zaurusUid() const;
723 // void setZaurusStat(int id); 723 // void setZaurusStat(int id);
724 // int zaurusStat() const; 724 // int zaurusStat() const;
725 // 0 equal 725 // 0 equal
726 // 1 take local 726 // 1 take local
727 // 2 take remote 727 // 2 take remote
728 // 3 cancel 728 // 3 cancel
729 QDateTime lastSync = mLastCalendarSync; 729 QDateTime lastSync = mLastCalendarSync;
730 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 730 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
731 bool remCh, locCh; 731 bool remCh, locCh;
732 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 732 remCh = ( remote->zaurusUid() != local->zaurusUid() );
733 locCh = ( local->zaurusStat() != local->revision() ); 733 locCh = ( local->zaurusStat() != local->revision() );
734 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 734 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
735 if ( !remCh && ! locCh ) { 735 if ( !remCh && ! locCh ) {
736 //qDebug("both not changed "); 736 //qDebug("both not changed ");
737 lastSync = local->lastModified().addDays(1); 737 lastSync = local->lastModified().addDays(1);
738 } else { 738 } else {
739 if ( locCh ) { 739 if ( locCh ) {
740 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 740 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
741 lastSync = local->lastModified().addDays( -1 ); 741 lastSync = local->lastModified().addDays( -1 );
742 if ( !remCh ) 742 if ( !remCh )
743 remote->setLastModified( lastSync.addDays( -1 ) ); 743 remote->setLastModified( lastSync.addDays( -1 ) );
744 } else { 744 } else {
745 //qDebug(" not loc changed "); 745 //qDebug(" not loc changed ");
746 lastSync = local->lastModified().addDays( 1 ); 746 lastSync = local->lastModified().addDays( 1 );
747 if ( remCh ) 747 if ( remCh )
748 remote->setLastModified( lastSync.addDays( 1 ) ); 748 remote->setLastModified( lastSync.addDays( 1 ) );
749 749
750 } 750 }
751 } 751 }
752 full = true; 752 full = true;
753 if ( mode < 3 ) 753 if ( mode < 3 )
754 mode = 3; 754 mode = 3;
755 } else { 755 } else {
756 if ( local->lastModified() == remote->lastModified() ) 756 if ( local->lastModified() == remote->lastModified() )
757 if ( local->revision() == remote->revision() ) 757 if ( local->revision() == remote->revision() )
758 return 0; 758 return 0;
759 759
760 } 760 }
761 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 761 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
762 762
763 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 763 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
764 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 764 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
765 //full = true; //debug only 765 //full = true; //debug only
766 if ( full ) { 766 if ( full ) {
767 bool equ = false; 767 bool equ = false;
768 if ( local->type() == "Event" ) { 768 if ( local->type() == "Event" ) {
769 equ = (*((Event*) local) == *((Event*) remote)); 769 equ = (*((Event*) local) == *((Event*) remote));
770 } 770 }
771 else if ( local->type() =="Todo" ) 771 else if ( local->type() =="Todo" )
772 equ = (*((Todo*) local) == (*(Todo*) remote)); 772 equ = (*((Todo*) local) == (*(Todo*) remote));
773 else if ( local->type() =="Journal" ) 773 else if ( local->type() =="Journal" )
774 equ = (*((Journal*) local) == *((Journal*) remote)); 774 equ = (*((Journal*) local) == *((Journal*) remote));
775 if ( equ ) { 775 if ( equ ) {
776 //qDebug("equal "); 776 //qDebug("equal ");
777 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 777 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
778 local->setZaurusUid( remote->zaurusUid() ); 778 local->setZaurusUid( remote->zaurusUid() );
779 } 779 }
780 if ( mode < 4 ) 780 if ( mode < 4 )
781 return 0; 781 return 0;
782 782
783 }//else //debug only 783 }//else //debug only
784 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 784 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
785 } 785 }
786 int result; 786 int result;
787 bool localIsNew; 787 bool localIsNew;
788 if ( full && mode < 2 ) 788 if ( full && mode < 2 )
789 mode = 3; 789 mode = 3;
790 790
791 switch( mode ) { 791 switch( mode ) {
792 case 0: 792 case 0:
793 if ( lastSync > remote->lastModified() ) 793 if ( lastSync > remote->lastModified() )
794 return 1; 794 return 1;
795 if ( lastSync > local->lastModified() ) 795 if ( lastSync > local->lastModified() )
796 return 2; 796 return 2;
797 return 1; 797 return 1;
798 break; 798 break;
799 case 1: 799 case 1:
800 if ( lastSync > remote->lastModified() ) 800 if ( lastSync > remote->lastModified() )
801 return 1; 801 return 1;
802 if ( lastSync > local->lastModified() ) 802 if ( lastSync > local->lastModified() )
803 return 2; 803 return 2;
804 return 2; 804 return 2;
805 break; 805 break;
806 case 2: 806 case 2:
807 if ( local->lastModified() > remote->lastModified() ) 807 if ( local->lastModified() > remote->lastModified() )
808 return 1; 808 return 1;
809 else 809 else
810 return 2; 810 return 2;
811 break; 811 break;
812 case 3: 812 case 3:
813 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 813 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
814 if ( lastSync > remote->lastModified() ) 814 if ( lastSync > remote->lastModified() )
815 return 1; 815 return 1;
816 if ( lastSync > local->lastModified() ) 816 if ( lastSync > local->lastModified() )
817 return 2; 817 return 2;
818 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 818 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
819 localIsNew = local->lastModified() > remote->lastModified(); 819 localIsNew = local->lastModified() > remote->lastModified();
820 if ( localIsNew ) 820 if ( localIsNew )
821 getEventViewerDialog()->setColorMode( 1 ); 821 getEventViewerDialog()->setColorMode( 1 );
822 else 822 else
823 getEventViewerDialog()->setColorMode( 2 ); 823 getEventViewerDialog()->setColorMode( 2 );
824 getEventViewerDialog()->setIncidence(local); 824 getEventViewerDialog()->setIncidence(local);
825 if ( localIsNew ) 825 if ( localIsNew )
826 getEventViewerDialog()->setColorMode( 2 ); 826 getEventViewerDialog()->setColorMode( 2 );
827 else 827 else
828 getEventViewerDialog()->setColorMode( 1 ); 828 getEventViewerDialog()->setColorMode( 1 );
829 getEventViewerDialog()->addIncidence(remote); 829 getEventViewerDialog()->addIncidence(remote);
830 getEventViewerDialog()->setColorMode( 0 ); 830 getEventViewerDialog()->setColorMode( 0 );
831 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 831 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
832 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 832 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
833 getEventViewerDialog()->showMe(); 833 getEventViewerDialog()->showMe();
834 result = getEventViewerDialog()->executeS( localIsNew ); 834 result = getEventViewerDialog()->executeS( localIsNew );
835 return result; 835 return result;
836 836
837 break; 837 break;
838 case 4: 838 case 4:
839 return 1; 839 return 1;
840 break; 840 break;
841 case 5: 841 case 5:
842 return 2; 842 return 2;
843 break; 843 break;
844 844
845 default: 845 default:
846 break; 846 break;
847 } 847 }
848 return 0; 848 return 0;
849} 849}
850Event* CalendarView::getLastSyncEvent() 850Event* CalendarView::getLastSyncEvent()
851{ 851{
852 Event* lse; 852 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); 854 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice );
855 if (!lse) { 855 if (!lse) {
856 lse = new Event(); 856 lse = new Event();
857 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); 857 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice );
858 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); 858 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event"));
859 lse->setDtStart( mLastCalendarSync ); 859 lse->setDtStart( mLastCalendarSync );
860 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 860 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
861 lse->setCategories( i18n("SyncEvent") ); 861 lse->setCategories( i18n("SyncEvent") );
862 lse->setReadOnly( true ); 862 lse->setReadOnly( true );
863 mCalendar->addEvent( lse ); 863 mCalendar->addEvent( lse );
864 } 864 }
865 865
866 return lse; 866 return lse;
867 867
868} 868}
869void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) 869void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete )
870{ 870{
871 if ( ! lastSync ) 871 if ( ! lastSync )
872 return; 872 return;
873 if ( toDelete->zaurusId() < 0 ) 873 if ( toDelete->zaurusId() < 0 )
874 return; 874 return;
875 if ( toDelete->type() == "Journal" ) 875 if ( toDelete->type() == "Journal" )
876 return; 876 return;
877 QString des = lastSync->description(); 877 QString des = lastSync->description();
878 QString pref = "e"; 878 QString pref = "e";
879 if ( toDelete->type() == "Todo" ) 879 if ( toDelete->type() == "Todo" )
880 pref = "t"; 880 pref = "t";
881 des += pref+ QString::number ( toDelete->zaurusId() ) + ","; 881 des += pref+ QString::number ( toDelete->zaurusId() ) + ",";
882 lastSync->setReadOnly( false ); 882 lastSync->setReadOnly( false );
883 lastSync->setDescription( des ); 883 lastSync->setDescription( des );
884 lastSync->setReadOnly( true ); 884 lastSync->setReadOnly( true );
885 885
886} 886}
887bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 887bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
888{ 888{
889 bool syncOK = true; 889 bool syncOK = true;
890 int addedEvent = 0; 890 int addedEvent = 0;
891 int addedEventR = 0; 891 int addedEventR = 0;
892 int deletedEventR = 0; 892 int deletedEventR = 0;
893 int deletedEventL = 0; 893 int deletedEventL = 0;
894 int changedLocal = 0; 894 int changedLocal = 0;
895 int changedRemote = 0; 895 int changedRemote = 0;
896 //QPtrList<Event> el = local->rawEvents(); 896 //QPtrList<Event> el = local->rawEvents();
897 Event* eventR; 897 Event* eventR;
898 QString uid; 898 QString uid;
899 int take; 899 int take;
900 Event* eventL; 900 Event* eventL;
901 Event* eventRSync; 901 Event* eventRSync;
902 Event* eventLSync; 902 Event* eventLSync;
903 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); 903 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM");
904 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); 904 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM");
905 bool fullDateRange = false; 905 bool fullDateRange = false;
906 mLastCalendarSync = QDateTime::currentDateTime(); 906 mLastCalendarSync = QDateTime::currentDateTime();
907 QDateTime modifiedCalendar = mLastCalendarSync;; 907 QDateTime modifiedCalendar = mLastCalendarSync;;
908 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); 908 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName );
909 if ( eventR ) { 909 if ( eventR ) {
910 eventRSync = (Event*) eventR->clone(); 910 eventRSync = (Event*) eventR->clone();
911 remote->deleteEvent(eventR ); 911 remote->deleteEvent(eventR );
912 912
913 } else { 913 } else {
914 fullDateRange = true; 914 fullDateRange = true;
915 eventRSync = new Event(); 915 eventRSync = new Event();
916 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 916 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
917 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); 917 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName );
918 eventRSync->setDtStart( mLastCalendarSync ); 918 eventRSync->setDtStart( mLastCalendarSync );
919 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 919 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
920 eventRSync->setCategories( i18n("SyncEvent") ); 920 eventRSync->setCategories( i18n("SyncEvent") );
921 } 921 }
922 eventLSync = getLastSyncEvent(); 922 eventLSync = getLastSyncEvent();
923 if ( eventLSync->dtStart() == mLastCalendarSync ) 923 if ( eventLSync->dtStart() == mLastCalendarSync )
924 fullDateRange = true; 924 fullDateRange = true;
925 925
926 if ( ! fullDateRange ) { 926 if ( ! fullDateRange ) {
927 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 927 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
928 928
929 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 929 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
930 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 930 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
931 fullDateRange = true; 931 fullDateRange = true;
932 } 932 }
933 } 933 }
934 if ( fullDateRange ) 934 if ( fullDateRange )
935 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 935 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
936 else 936 else
937 mLastCalendarSync = eventLSync->dtStart(); 937 mLastCalendarSync = eventLSync->dtStart();
938 // for resyncing if own file has changed 938 // for resyncing if own file has changed
939 if ( mCurrentSyncDevice == "deleteaftersync" ) { 939 if ( mCurrentSyncDevice == "deleteaftersync" ) {
940 mLastCalendarSync = loadedFileVersion; 940 mLastCalendarSync = loadedFileVersion;
941 qDebug("setting mLastCalendarSync "); 941 qDebug("setting mLastCalendarSync ");
942 } 942 }
943 //qDebug("*************************** "); 943 //qDebug("*************************** ");
944 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 944 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
945 QPtrList<Incidence> er = remote->rawIncidences(); 945 QPtrList<Incidence> er = remote->rawIncidences();
946 Incidence* inR = er.first(); 946 Incidence* inR = er.first();
947 Incidence* inL; 947 Incidence* inL;
948 QProgressBar bar( er.count(),0 ); 948 QProgressBar bar( er.count(),0 );
949 bar.setCaption (i18n("Syncing - close to abort!") ); 949 bar.setCaption (i18n("Syncing - close to abort!") );
950 950
951 int w = 300; 951 int w = 300;
952 if ( QApplication::desktop()->width() < 320 ) 952 if ( QApplication::desktop()->width() < 320 )
953 w = 220; 953 w = 220;
954 int h = bar.sizeHint().height() ; 954 int h = bar.sizeHint().height() ;
955 int dw = QApplication::desktop()->width(); 955 int dw = QApplication::desktop()->width();
956 int dh = QApplication::desktop()->height(); 956 int dh = QApplication::desktop()->height();
957 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 957 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
958 bar.show(); 958 bar.show();
959 int modulo = (er.count()/10)+1; 959 int modulo = (er.count()/10)+1;
960 int incCounter = 0; 960 int incCounter = 0;
961 while ( inR ) { 961 while ( inR ) {
962 if ( ! bar.isVisible() ) 962 if ( ! bar.isVisible() )
963 return false; 963 return false;
964 if ( incCounter % modulo == 0 ) 964 if ( incCounter % modulo == 0 )
965 bar.setProgress( incCounter ); 965 bar.setProgress( incCounter );
966 ++incCounter; 966 ++incCounter;
967 uid = inR->uid(); 967 uid = inR->uid();
968 bool skipIncidence = false; 968 bool skipIncidence = false;
969 if ( uid.left(21) == QString("last-syncEvent-device") ) 969 if ( uid.left(21) == QString("last-syncEvent-device") )
970 skipIncidence = true; 970 skipIncidence = true;
971 971
972 qApp->processEvents(); 972 qApp->processEvents();
973 if ( !skipIncidence ) { 973 if ( !skipIncidence ) {
974 inL = local->incidence( uid ); 974 inL = local->incidence( uid );
975 if ( inL ) { // maybe conflict - same uid in both calendars 975 if ( inL ) { // maybe conflict - same uid in both calendars
976 int maxrev = inL->revision(); 976 int maxrev = inL->revision();
977 if ( maxrev < inR->revision() ) 977 if ( maxrev < inR->revision() )
978 maxrev = inR->revision(); 978 maxrev = inR->revision();
979 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 979 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
980 //qDebug("take %d %s ", take, inL->summary().latin1()); 980 //qDebug("take %d %s ", take, inL->summary().latin1());
981 if ( take == 3 ) 981 if ( take == 3 )
982 return false; 982 return false;
983 if ( take == 1 ) {// take local 983 if ( take == 1 ) {// take local
984 inL->setZaurusUid( inR->zaurusUid() ); 984 inL->setZaurusUid( inR->zaurusUid() );
985 remote->deleteIncidence( inR ); 985 remote->deleteIncidence( inR );
986 if ( inL->revision() < maxrev ) 986 if ( inL->revision() < maxrev )
987 inL->setRevision( maxrev ); 987 inL->setRevision( maxrev );
988 remote->addIncidence( inL->clone() ); 988 remote->addIncidence( inL->clone() );
989 ++changedRemote; 989 ++changedRemote;
990 } else { 990 } else {
991 if ( inR->revision() < maxrev ) 991 if ( inR->revision() < maxrev )
992 inR->setRevision( maxrev ); 992 inR->setRevision( maxrev );
993 local->deleteIncidence( inL ); 993 local->deleteIncidence( inL );
994 local->addIncidence( inR->clone() ); 994 local->addIncidence( inR->clone() );
995 ++changedLocal; 995 ++changedLocal;
996 } 996 }
997 } 997 }
998 } else { // no conflict 998 } else { // no conflict
999 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 999 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
1000 QString des = eventLSync->description(); 1000 QString des = eventLSync->description();
1001 QString pref = "e"; 1001 QString pref = "e";
1002 if ( inR->type() == "Todo" ) 1002 if ( inR->type() == "Todo" )
1003 pref = "t"; 1003 pref = "t";
1004 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it 1004 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
1005 inR->setZaurusStat( -3 ); 1005 inR->setZaurusStat( -3 );
1006 //remote->deleteIncidence( inR ); 1006 //remote->deleteIncidence( inR );
1007 ++deletedEventR; 1007 ++deletedEventR;
1008 } else { 1008 } else {
1009 inR->setLastModified( modifiedCalendar ); 1009 inR->setLastModified( modifiedCalendar );
1010 local->addIncidence( inR->clone() ); 1010 local->addIncidence( inR->clone() );
1011 ++addedEvent; 1011 ++addedEvent;
1012 } 1012 }
1013 } else { 1013 } else {
1014 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1014 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1015 inR->setLastModified( modifiedCalendar ); 1015 inR->setLastModified( modifiedCalendar );
1016 local->addIncidence( inR->clone() ); 1016 local->addIncidence( inR->clone() );
1017 ++addedEvent; 1017 ++addedEvent;
1018 } else { 1018 } else {
1019 checkSharpEvent(eventRSyncSharp, inR); 1019 checkSharpEvent(eventRSyncSharp, inR);
1020 remote->deleteIncidence( inR ); 1020 remote->deleteIncidence( inR );
1021 ++deletedEventR; 1021 ++deletedEventR;
1022 } 1022 }
1023 } 1023 }
1024 } 1024 }
1025 } 1025 }
1026 inR = er.next(); 1026 inR = er.next();
1027 } 1027 }
1028 QPtrList<Incidence> el = local->rawIncidences(); 1028 QPtrList<Incidence> el = local->rawIncidences();
1029 inL = el.first(); 1029 inL = el.first();
1030 modulo = (el.count()/10)+1; 1030 modulo = (el.count()/10)+1;
1031 bar.setCaption (i18n("Add / remove events") ); 1031 bar.setCaption (i18n("Add / remove events") );
1032 bar.setTotalSteps ( el.count() ) ; 1032 bar.setTotalSteps ( el.count() ) ;
1033 bar.show(); 1033 bar.show();
1034 incCounter = 0; 1034 incCounter = 0;
1035 1035
1036 while ( inL ) { 1036 while ( inL ) {
1037 1037
1038 qApp->processEvents(); 1038 qApp->processEvents();
1039 if ( ! bar.isVisible() ) 1039 if ( ! bar.isVisible() )
1040 return false; 1040 return false;
1041 if ( incCounter % modulo == 0 ) 1041 if ( incCounter % modulo == 0 )
1042 bar.setProgress( incCounter ); 1042 bar.setProgress( incCounter );
1043 ++incCounter; 1043 ++incCounter;
1044 uid = inL->uid(); 1044 uid = inL->uid();
1045 bool skipIncidence = false; 1045 bool skipIncidence = false;
1046 if ( uid.left(21) == QString("last-syncEvent-device") ) 1046 if ( uid.left(21) == QString("last-syncEvent-device") )
1047 skipIncidence = true; 1047 skipIncidence = true;
1048 if ( mGlobalSyncMode == SYNC_MODE_SHARP && inL->type() == "Journal" ) 1048 if ( mGlobalSyncMode == SYNC_MODE_SHARP && inL->type() == "Journal" )
1049 skipIncidence = true; 1049 skipIncidence = true;
1050 if ( !skipIncidence ) { 1050 if ( !skipIncidence ) {
1051 inR = remote->incidence( uid ); 1051 inR = remote->incidence( uid );
1052 if ( ! inR ) { 1052 if ( ! inR ) {
1053 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 1053 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
1054 if ( inL->zaurusId() >= 0 && mode != 4 ) { 1054 if ( inL->zaurusId() >= 0 && mode != 4 ) {
1055 local->deleteIncidence( inL ); 1055 local->deleteIncidence( inL );
1056 ++deletedEventL; 1056 ++deletedEventL;
1057 } else { 1057 } else {
1058 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1058 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1059 inL->setZaurusId( -1 ); 1059 inL->setZaurusId( -1 );
1060 ++addedEventR; 1060 ++addedEventR;
1061 inL->setLastModified( modifiedCalendar ); 1061 inL->setLastModified( modifiedCalendar );
1062 remote->addIncidence( inL->clone() ); 1062 remote->addIncidence( inL->clone() );
1063 } 1063 }
1064 } 1064 }
1065 } else { 1065 } else {
1066 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1066 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1067 checkSharpEvent(eventLSyncSharp, inL); 1067 checkSharpEvent(eventLSyncSharp, inL);
1068 local->deleteIncidence( inL ); 1068 local->deleteIncidence( inL );
1069 ++deletedEventL; 1069 ++deletedEventL;
1070 } else { 1070 } else {
1071 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1071 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1072 ++addedEventR; 1072 ++addedEventR;
1073 inL->setLastModified( modifiedCalendar ); 1073 inL->setLastModified( modifiedCalendar );
1074 remote->addIncidence( inL->clone() ); 1074 remote->addIncidence( inL->clone() );
1075 } 1075 }
1076 } 1076 }
1077 } 1077 }
1078 } 1078 }
1079 } 1079 }
1080 inL = el.next(); 1080 inL = el.next();
1081 } 1081 }
1082 1082
1083 bar.hide(); 1083 bar.hide();
1084 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1084 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1085 eventLSync->setReadOnly( false ); 1085 eventLSync->setReadOnly( false );
1086 eventLSync->setDtStart( mLastCalendarSync ); 1086 eventLSync->setDtStart( mLastCalendarSync );
1087 eventRSync->setDtStart( mLastCalendarSync ); 1087 eventRSync->setDtStart( mLastCalendarSync );
1088 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1088 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1089 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1089 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1090 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1090 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1091 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1091 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1092 eventLSync->setReadOnly( true ); 1092 eventLSync->setReadOnly( true );
1093 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1093 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1094 remote->addEvent( eventRSync ); 1094 remote->addEvent( eventRSync );
1095 QString mes; 1095 QString mes;
1096 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1096 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1097 if ( KOPrefs::instance()->mShowSyncSummary ) { 1097 if ( KOPrefs::instance()->mShowSyncSummary ) {
1098 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1098 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1099 } 1099 }
1100 qDebug( mes ); 1100 qDebug( mes );
1101 mCalendar->checkAlarmForIncidence( 0, true ); 1101 mCalendar->checkAlarmForIncidence( 0, true );
1102 return syncOK; 1102 return syncOK;
1103} 1103}
1104 1104
1105void CalendarView::setSyncDevice( QString s ) 1105void CalendarView::setSyncDevice( QString s )
1106{ 1106{
1107 mCurrentSyncDevice= s; 1107 mCurrentSyncDevice= s;
1108} 1108}
1109void CalendarView::setSyncName( QString s ) 1109void CalendarView::setSyncName( QString s )
1110{ 1110{
1111 mCurrentSyncName= s; 1111 mCurrentSyncName= s;
1112} 1112}
1113bool CalendarView::syncCalendar(QString filename, int mode) 1113bool CalendarView::syncCalendar(QString filename, int mode)
1114{ 1114{
1115 mGlobalSyncMode = SYNC_MODE_NORMAL; 1115 mGlobalSyncMode = SYNC_MODE_NORMAL;
1116 CalendarLocal* calendar = new CalendarLocal(); 1116 CalendarLocal* calendar = new CalendarLocal();
1117 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1117 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1118 FileStorage* storage = new FileStorage( calendar ); 1118 FileStorage* storage = new FileStorage( calendar );
1119 bool syncOK = false; 1119 bool syncOK = false;
1120 storage->setFileName( filename ); 1120 storage->setFileName( filename );
1121 // qDebug("loading ... "); 1121 // qDebug("loading ... ");
1122 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1122 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1123 getEventViewerDialog()->setSyncMode( true ); 1123 getEventViewerDialog()->setSyncMode( true );
1124 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1124 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1125 getEventViewerDialog()->setSyncMode( false ); 1125 getEventViewerDialog()->setSyncMode( false );
1126 if ( syncOK ) { 1126 if ( syncOK ) {
1127 if ( KOPrefs::instance()->mWriteBackFile ) 1127 if ( KOPrefs::instance()->mWriteBackFile )
1128 { 1128 {
1129 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1129 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1130 storage->save(); 1130 storage->save();
1131 } 1131 }
1132 } 1132 }
1133 setModified( true ); 1133 setModified( true );
1134 } 1134 }
1135 delete storage; 1135 delete storage;
1136 delete calendar; 1136 delete calendar;
1137 if ( syncOK ) 1137 if ( syncOK )
1138 updateView(); 1138 updateView();
1139 return syncOK; 1139 return syncOK;
1140} 1140}
1141void CalendarView::syncSharp() 1141void CalendarView::syncSharp()
1142{ 1142{
1143#ifndef DESKTOP_VERSION 1143#ifndef DESKTOP_VERSION
1144 mGlobalSyncMode = SYNC_MODE_SHARP; 1144 mGlobalSyncMode = SYNC_MODE_SHARP;
1145 //mCurrentSyncDevice = "sharp-DTM"; 1145 //mCurrentSyncDevice = "sharp-DTM";
1146 if ( KOPrefs::instance()->mAskForPreferences ) 1146 if ( KOPrefs::instance()->mAskForPreferences )
1147 edit_sync_options(); 1147 edit_sync_options();
1148 qApp->processEvents(); 1148 qApp->processEvents();
1149 CalendarLocal* calendar = new CalendarLocal(); 1149 CalendarLocal* calendar = new CalendarLocal();
1150 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1150 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1151 bool syncOK = false; 1151 bool syncOK = false;
1152 SharpFormat sharpFormat; 1152 SharpFormat sharpFormat;
1153 if ( sharpFormat.load( calendar, mCalendar ) ) { 1153 if ( sharpFormat.load( calendar, mCalendar ) ) {
1154 getEventViewerDialog()->setSyncMode( true ); 1154 getEventViewerDialog()->setSyncMode( true );
1155 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1155 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1156 getEventViewerDialog()->setSyncMode( false ); 1156 getEventViewerDialog()->setSyncMode( false );
1157 qApp->processEvents(); 1157 qApp->processEvents();
1158 if ( syncOK ) { 1158 if ( syncOK ) {
1159 if ( KOPrefs::instance()->mWriteBackFile ) 1159 if ( KOPrefs::instance()->mWriteBackFile )
1160 { 1160 {
1161 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1161 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1162 Incidence* inc = iL.first(); 1162 Incidence* inc = iL.first();
1163 while ( inc ) { 1163 while ( inc ) {
1164 inc->setZaurusStat( inc->revision () ); 1164 inc->setZaurusStat( inc->revision () );
1165 inc = iL.next(); 1165 inc = iL.next();
1166 } 1166 }
1167 // pending: clean last sync event description 1167 // pending: clean last sync event description
1168 sharpFormat.save(calendar); 1168 sharpFormat.save(calendar);
1169 iL = calendar->rawIncidences(); 1169 iL = calendar->rawIncidences();
1170 inc = iL.first(); 1170 inc = iL.first();
1171 Incidence* loc; 1171 Incidence* loc;
1172 while ( inc ) { 1172 while ( inc ) {
1173 if ( inc->zaurusStat() == -4 ) { 1173 if ( inc->zaurusStat() == -4 ) {
1174 loc = mCalendar->incidence(inc->uid() ); 1174 loc = mCalendar->incidence(inc->uid() );
1175 if ( loc ) { 1175 if ( loc ) {
1176 loc->setZaurusId( inc->zaurusId() ); 1176 loc->setZaurusId( inc->zaurusId() );
1177 loc->setZaurusUid( inc->zaurusUid() ); 1177 loc->setZaurusUid( inc->zaurusUid() );
1178 } 1178 }
1179 } 1179 }
1180 inc = iL.next(); 1180 inc = iL.next();
1181 } 1181 }
1182 Incidence* lse = getLastSyncEvent(); 1182 Incidence* lse = getLastSyncEvent();
1183 if ( lse ) { 1183 if ( lse ) {
1184 lse->setReadOnly( false ); 1184 lse->setReadOnly( false );
1185 lse->setDescription( "" ); 1185 lse->setDescription( "" );
1186 lse->setReadOnly( true ); 1186 lse->setReadOnly( true );
1187 } 1187 }
1188 } 1188 }
1189 } 1189 }
1190 setModified( true ); 1190 setModified( true );
1191 } else { 1191 } else {
1192 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1192 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1193 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1193 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1194 question, i18n("Ok")) ; 1194 question, i18n("Ok")) ;
1195 1195
1196 } 1196 }
1197 delete calendar; 1197 delete calendar;
1198 updateView(); 1198 updateView();
1199 return ;//syncOK; 1199 return ;//syncOK;
1200#endif 1200#endif
1201} 1201}
1202 1202
1203 1203
1204#include <kabc/stdaddressbook.h> 1204#include <kabc/stdaddressbook.h>
1205bool CalendarView::importBday() 1205bool CalendarView::importBday()
1206{ 1206{
1207 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1207 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1208 KABC::AddressBook::Iterator it; 1208 KABC::AddressBook::Iterator it;
1209 int count = 0; 1209 int count = 0;
1210 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1210 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1211 ++count; 1211 ++count;
1212 } 1212 }
1213 QProgressBar bar(count,0 ); 1213 QProgressBar bar(count,0 );
1214 int w = 300; 1214 int w = 300;
1215 if ( QApplication::desktop()->width() < 320 ) 1215 if ( QApplication::desktop()->width() < 320 )
1216 w = 220; 1216 w = 220;
1217 int h = bar.sizeHint().height() ; 1217 int h = bar.sizeHint().height() ;
1218 int dw = QApplication::desktop()->width(); 1218 int dw = QApplication::desktop()->width();
1219 int dh = QApplication::desktop()->height(); 1219 int dh = QApplication::desktop()->height();
1220 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1220 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1221 bar.show(); 1221 bar.show();
1222 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1222 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1223 qApp->processEvents(); 1223 qApp->processEvents();
1224 count = 0; 1224 count = 0;
1225 int addCount = 0; 1225 int addCount = 0;
1226 KCal::Attendee* a = 0; 1226 KCal::Attendee* a = 0;
1227 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1227 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1228 if ( ! bar.isVisible() ) 1228 if ( ! bar.isVisible() )
1229 return false; 1229 return false;
1230 bar.setProgress( count++ ); 1230 bar.setProgress( count++ );
1231 qApp->processEvents(); 1231 qApp->processEvents();
1232 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1232 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1233 if ( (*it).birthday().date().isValid() ){ 1233 if ( (*it).birthday().date().isValid() ){
1234 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1234 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1235 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1235 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1236 ++addCount; 1236 ++addCount;
1237 } 1237 }
1238 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1238 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1239 if ( anni.isValid() ){ 1239 if ( anni.isValid() ){
1240 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1240 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1241 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1241 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1242 ++addCount; 1242 ++addCount;
1243 } 1243 }
1244 } 1244 }
1245 updateView(); 1245 updateView();
1246 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1246 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1247 return true; 1247 return true;
1248} 1248}
1249 1249
1250bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1250bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1251{ 1251{
1252 //qDebug("addAnni "); 1252 //qDebug("addAnni ");
1253 Event * ev = new Event(); 1253 Event * ev = new Event();
1254 if ( a ) { 1254 if ( a ) {
1255 ev->addAttendee( a ); 1255 ev->addAttendee( a );
1256 } 1256 }
1257 QString kind; 1257 QString kind;
1258 if ( birthday ) 1258 if ( birthday )
1259 kind = i18n( "Birthday" ); 1259 kind = i18n( "Birthday" );
1260 else 1260 else
1261 kind = i18n( "Anniversary" ); 1261 kind = i18n( "Anniversary" );
1262 ev->setSummary( name + " - " + kind ); 1262 ev->setSummary( name + " - " + kind );
1263 ev->setOrganizer( "nobody@nowhere" ); 1263 ev->setOrganizer( "nobody@nowhere" );
1264 ev->setCategories( kind ); 1264 ev->setCategories( kind );
1265 ev->setDtStart( QDateTime(date) ); 1265 ev->setDtStart( QDateTime(date) );
1266 ev->setDtEnd( QDateTime(date) ); 1266 ev->setDtEnd( QDateTime(date) );
1267 ev->setFloats( true ); 1267 ev->setFloats( true );
1268 Recurrence * rec = ev->recurrence(); 1268 Recurrence * rec = ev->recurrence();
1269 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1269 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1270 rec->addYearlyNum( date.month() ); 1270 rec->addYearlyNum( date.month() );
1271 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1271 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1272 delete ev; 1272 delete ev;
1273 return false; 1273 return false;
1274 } 1274 }
1275 return true; 1275 return true;
1276 1276
1277} 1277}
1278bool CalendarView::importQtopia( const QString &categories, 1278bool CalendarView::importQtopia( const QString &categories,
1279 const QString &datebook, 1279 const QString &datebook,
1280 const QString &todolist ) 1280 const QString &todolist )
1281{ 1281{
1282 1282
1283 QtopiaFormat qtopiaFormat; 1283 QtopiaFormat qtopiaFormat;
1284 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1284 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1285 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1285 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1286 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1286 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1287 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1287 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1288 1288
1289 updateView(); 1289 updateView();
1290 return true; 1290 return true;
1291 1291
1292#if 0 1292#if 0
1293 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1293 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1294 mCurrentSyncDevice = "qtopia-XML"; 1294 mCurrentSyncDevice = "qtopia-XML";
1295 if ( KOPrefs::instance()->mAskForPreferences ) 1295 if ( KOPrefs::instance()->mAskForPreferences )
1296 edit_sync_options(); 1296 edit_sync_options();
1297 qApp->processEvents(); 1297 qApp->processEvents();
1298 CalendarLocal* calendar = new CalendarLocal(); 1298 CalendarLocal* calendar = new CalendarLocal();
1299 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1299 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1300 bool syncOK = false; 1300 bool syncOK = false;
1301 QtopiaFormat qtopiaFormat; 1301 QtopiaFormat qtopiaFormat;
1302 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1302 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1303 bool loadOk = true; 1303 bool loadOk = true;
1304 if ( !categories.isEmpty() ) 1304 if ( !categories.isEmpty() )
1305 loadOk = qtopiaFormat.load( calendar, categories ); 1305 loadOk = qtopiaFormat.load( calendar, categories );
1306 if ( loadOk && !datebook.isEmpty() ) 1306 if ( loadOk && !datebook.isEmpty() )
1307 loadOk = qtopiaFormat.load( calendar, datebook ); 1307 loadOk = qtopiaFormat.load( calendar, datebook );
1308 if ( loadOk && !todolist.isEmpty() ) 1308 if ( loadOk && !todolist.isEmpty() )
1309 loadOk = qtopiaFormat.load( calendar, todolist ); 1309 loadOk = qtopiaFormat.load( calendar, todolist );
1310 1310
1311 if ( loadOk ) { 1311 if ( loadOk ) {
1312 getEventViewerDialog()->setSyncMode( true ); 1312 getEventViewerDialog()->setSyncMode( true );
1313 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1313 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1314 getEventViewerDialog()->setSyncMode( false ); 1314 getEventViewerDialog()->setSyncMode( false );
1315 qApp->processEvents(); 1315 qApp->processEvents();
1316 if ( syncOK ) { 1316 if ( syncOK ) {
1317 if ( KOPrefs::instance()->mWriteBackFile ) 1317 if ( KOPrefs::instance()->mWriteBackFile )
1318 { 1318 {
1319 // write back XML file 1319 // write back XML file
1320 1320
1321 } 1321 }
1322 setModified( true ); 1322 setModified( true );
1323 } 1323 }
1324 } else { 1324 } else {
1325 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1325 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1326 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1326 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1327 question, i18n("Ok")) ; 1327 question, i18n("Ok")) ;
1328 } 1328 }
1329 delete calendar; 1329 delete calendar;
1330 updateView(); 1330 updateView();
1331 return syncOK; 1331 return syncOK;
1332 1332
1333 1333
1334#endif 1334#endif
1335 1335
1336} 1336}
1337 1337
1338void CalendarView::setSyncEventsReadOnly() 1338void CalendarView::setSyncEventsReadOnly()
1339{ 1339{
1340 Event * ev; 1340 Event * ev;
1341 QPtrList<Event> eL = mCalendar->rawEvents(); 1341 QPtrList<Event> eL = mCalendar->rawEvents();
1342 ev = eL.first(); 1342 ev = eL.first();
1343 while ( ev ) { 1343 while ( ev ) {
1344 if ( ev->uid().left(21) == QString("last-syncEvent-device") ) 1344 if ( ev->uid().left(21) == QString("last-syncEvent-device") )
1345 ev->setReadOnly( true ); 1345 ev->setReadOnly( true );
1346 ev = eL.next(); 1346 ev = eL.next();
1347 } 1347 }
1348} 1348}
1349bool CalendarView::openCalendar(QString filename, bool merge) 1349bool CalendarView::openCalendar(QString filename, bool merge)
1350{ 1350{
1351 1351
1352 if (filename.isEmpty()) { 1352 if (filename.isEmpty()) {
1353 return false; 1353 return false;
1354 } 1354 }
1355 1355
1356 if (!QFile::exists(filename)) { 1356 if (!QFile::exists(filename)) {
1357 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1357 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1358 return false; 1358 return false;
1359 } 1359 }
1360 1360
1361 globalFlagBlockAgenda = 1; 1361 globalFlagBlockAgenda = 1;
1362 if (!merge) mCalendar->close(); 1362 if (!merge) mCalendar->close();
1363 1363
1364 mStorage->setFileName( filename ); 1364 mStorage->setFileName( filename );
1365 1365
1366 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1366 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1367 if ( merge ) ;//setModified( true ); 1367 if ( merge ) ;//setModified( true );
1368 else { 1368 else {
1369 //setModified( true ); 1369 //setModified( true );
1370 mViewManager->setDocumentId( filename ); 1370 mViewManager->setDocumentId( filename );
1371 mDialogManager->setDocumentId( filename ); 1371 mDialogManager->setDocumentId( filename );
1372 mTodoList->setDocumentId( filename ); 1372 mTodoList->setDocumentId( filename );
1373 } 1373 }
1374 globalFlagBlockAgenda = 2; 1374 globalFlagBlockAgenda = 2;
1375 // if ( getLastSyncEvent() ) 1375 // if ( getLastSyncEvent() )
1376 // getLastSyncEvent()->setReadOnly( true ); 1376 // getLastSyncEvent()->setReadOnly( true );
1377 mCalendar->reInitAlarmSettings(); 1377 mCalendar->reInitAlarmSettings();
1378 setSyncEventsReadOnly(); 1378 setSyncEventsReadOnly();
1379 updateUnmanagedViews(); 1379 updateUnmanagedViews();
1380 updateView(); 1380 updateView();
1381 if ( filename != MainWindow::defaultFileName() ) 1381 if ( filename != MainWindow::defaultFileName() )
1382 saveCalendar( MainWindow::defaultFileName() ); 1382 saveCalendar( MainWindow::defaultFileName() );
1383 loadedFileVersion = QDateTime::currentDateTime(); 1383 loadedFileVersion = QDateTime::currentDateTime();
1384 return true; 1384 return true;
1385 } else { 1385 } else {
1386 // while failing to load, the calendar object could 1386 // while failing to load, the calendar object could
1387 // have become partially populated. Clear it out. 1387 // have become partially populated. Clear it out.
1388 if ( !merge ) mCalendar->close(); 1388 if ( !merge ) mCalendar->close();
1389 1389
1390 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1390 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1391 1391
1392 globalFlagBlockAgenda = 2; 1392 globalFlagBlockAgenda = 2;
1393 updateView(); 1393 updateView();
1394 } 1394 }
1395 return false; 1395 return false;
1396} 1396}
1397void CalendarView::setLoadedFileVersion(QDateTime dt) 1397void CalendarView::setLoadedFileVersion(QDateTime dt)
1398{ 1398{
1399 loadedFileVersion = dt; 1399 loadedFileVersion = dt;
1400} 1400}
1401bool CalendarView::checkFileChanged(QString fn) 1401bool CalendarView::checkFileChanged(QString fn)
1402{ 1402{
1403 QFileInfo finf ( fn ); 1403 QFileInfo finf ( fn );
1404 if ( !finf.exists() ) 1404 if ( !finf.exists() )
1405 return true; 1405 return true;
1406 QDateTime dt = finf.lastModified (); 1406 QDateTime dt = finf.lastModified ();
1407 if ( dt <= loadedFileVersion ) 1407 if ( dt <= loadedFileVersion )
1408 return false; 1408 return false;
1409 return true; 1409 return true;
1410 1410
1411} 1411}
1412bool CalendarView::checkFileVersion(QString fn) 1412bool CalendarView::checkFileVersion(QString fn)
1413{ 1413{
1414 QFileInfo finf ( fn ); 1414 QFileInfo finf ( fn );
1415 if ( !finf.exists() ) 1415 if ( !finf.exists() )
1416 return true; 1416 return true;
1417 QDateTime dt = finf.lastModified (); 1417 QDateTime dt = finf.lastModified ();
1418 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1418 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1419 //qDebug("file on disk version %s",dt.toString().latin1()); 1419 //qDebug("file on disk version %s",dt.toString().latin1());
1420 if ( dt <= loadedFileVersion ) 1420 if ( dt <= loadedFileVersion )
1421 return true; 1421 return true;
1422 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , 1422 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) ,
1423 i18n("KO/Pi Warning"),i18n("Overwrite"), 1423 i18n("KO/Pi Warning"),i18n("Overwrite"),
1424 i18n("Sync+save")); 1424 i18n("Sync+save"));
1425 1425
1426 if ( km == KMessageBox::Cancel ) 1426 if ( km == KMessageBox::Cancel )
1427 return false; 1427 return false;
1428 if ( km == KMessageBox::Yes ) 1428 if ( km == KMessageBox::Yes )
1429 return true; 1429 return true;
1430 1430
1431 setSyncDevice("deleteaftersync" ); 1431 setSyncDevice("deleteaftersync" );
1432 KOPrefs::instance()->mAskForPreferences = true; 1432 KOPrefs::instance()->mAskForPreferences = true;
1433 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1433 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1434 KOPrefs::instance()->mWriteBackFile = false; 1434 KOPrefs::instance()->mWriteBackFile = false;
1435 KOPrefs::instance()->mWriteBackExistingOnly = false; 1435 KOPrefs::instance()->mWriteBackExistingOnly = false;
1436 KOPrefs::instance()->mShowSyncSummary = false; 1436 KOPrefs::instance()->mShowSyncSummary = false;
1437 syncCalendar( fn, 3 ); 1437 syncCalendar( fn, 3 );
1438 Event * e = getLastSyncEvent(); 1438 Event * e = getLastSyncEvent();
1439 mCalendar->deleteEvent ( e ); 1439 mCalendar->deleteEvent ( e );
1440 updateView(); 1440 updateView();
1441 return true; 1441 return true;
1442} 1442}
1443 1443
1444bool CalendarView::saveCalendar( QString filename ) 1444bool CalendarView::saveCalendar( QString filename )
1445{ 1445{
1446 1446
1447 // Store back all unsaved data into calendar object 1447 // Store back all unsaved data into calendar object
1448 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1448 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1449 if ( mViewManager->currentView() ) 1449 if ( mViewManager->currentView() )
1450 mViewManager->currentView()->flushView(); 1450 mViewManager->currentView()->flushView();
1451 1451
1452 //mStorage->setFileName( filename ); 1452 //mStorage->setFileName( filename );
1453 1453
1454 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1454 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1455 mStorage->setFileName( filename ); 1455 mStorage->setFileName( filename );
1456 bool success; 1456 bool success;
1457 success = mStorage->save(); 1457 success = mStorage->save();
1458 if ( !success ) { 1458 if ( !success ) {
1459 return false; 1459 return false;
1460 } 1460 }
1461 1461
1462 return true; 1462 return true;
1463} 1463}
1464 1464
1465void CalendarView::closeCalendar() 1465void CalendarView::closeCalendar()
1466{ 1466{
1467 1467
1468 // child windows no longer valid 1468 // child windows no longer valid
1469 emit closingDown(); 1469 emit closingDown();
1470 1470
1471 mCalendar->close(); 1471 mCalendar->close();
1472 setModified(false); 1472 setModified(false);
1473 updateView(); 1473 updateView();
1474} 1474}
1475 1475
1476void CalendarView::archiveCalendar() 1476void CalendarView::archiveCalendar()
1477{ 1477{
1478 mDialogManager->showArchiveDialog(); 1478 mDialogManager->showArchiveDialog();
1479} 1479}
1480 1480
1481 1481
1482void CalendarView::readSettings() 1482void CalendarView::readSettings()
1483{ 1483{
1484 1484
1485 1485
1486 // mViewManager->showAgendaView(); 1486 // mViewManager->showAgendaView();
1487 QString str; 1487 QString str;
1488 //qDebug("CalendarView::readSettings() "); 1488 //qDebug("CalendarView::readSettings() ");
1489 // read settings from the KConfig, supplying reasonable 1489 // read settings from the KConfig, supplying reasonable
1490 // defaults where none are to be found 1490 // defaults where none are to be found
1491 KConfig *config = KOGlobals::config(); 1491 KConfig *config = KOGlobals::config();
1492#ifndef KORG_NOSPLITTER 1492#ifndef KORG_NOSPLITTER
1493 config->setGroup("KOrganizer Geometry"); 1493 config->setGroup("KOrganizer Geometry");
1494 1494
1495 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1495 QValueList<int> sizes = config->readIntListEntry("Separator1");
1496 if (sizes.count() != 2) { 1496 if (sizes.count() != 2) {
1497 sizes << mDateNavigator->minimumSizeHint().width(); 1497 sizes << mDateNavigator->minimumSizeHint().width();
1498 sizes << 300; 1498 sizes << 300;
1499 } 1499 }
1500 mPanner->setSizes(sizes); 1500 mPanner->setSizes(sizes);
1501 1501
1502 sizes = config->readIntListEntry("Separator2"); 1502 sizes = config->readIntListEntry("Separator2");
1503 if ( ( mResourceView && sizes.count() == 4 ) || 1503 if ( ( mResourceView && sizes.count() == 4 ) ||
1504 ( !mResourceView && sizes.count() == 3 ) ) { 1504 ( !mResourceView && sizes.count() == 3 ) ) {
1505 mLeftSplitter->setSizes(sizes); 1505 mLeftSplitter->setSizes(sizes);
1506 } 1506 }
1507#endif 1507#endif
1508 globalFlagBlockAgenda = 1; 1508 globalFlagBlockAgenda = 1;
1509 mViewManager->showAgendaView(); 1509 mViewManager->showAgendaView();
1510 //mViewManager->readSettings( config ); 1510 //mViewManager->readSettings( config );
1511 mTodoList->restoreLayout(config,QString("Todo Layout")); 1511 mTodoList->restoreLayout(config,QString("Todo Layout"));
1512 readFilterSettings(config); 1512 readFilterSettings(config);
1513 config->setGroup( "Views" ); 1513 config->setGroup( "Views" );
1514 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1514 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1515 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1515 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1516 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1516 else if ( dateCount == 7 ) mNavigator->selectWeek();
1517 else mNavigator->selectDates( dateCount ); 1517 else mNavigator->selectDates( dateCount );
1518 // mViewManager->readSettings( config ); 1518 // mViewManager->readSettings( config );
1519 updateConfig(); 1519 updateConfig();
1520 globalFlagBlockAgenda = 2; 1520 globalFlagBlockAgenda = 2;
1521 mViewManager->readSettings( config ); 1521 mViewManager->readSettings( config );
1522#ifdef DESKTOP_VERSION 1522#ifdef DESKTOP_VERSION
1523 config->setGroup("WidgetLayout"); 1523 config->setGroup("WidgetLayout");
1524 QStringList list; 1524 QStringList list;
1525 list = config->readListEntry("MainLayout"); 1525 list = config->readListEntry("MainLayout");
1526 int x,y,w,h; 1526 int x,y,w,h;
1527 if ( ! list.isEmpty() ) { 1527 if ( ! list.isEmpty() ) {
1528 x = list[0].toInt(); 1528 x = list[0].toInt();
1529 y = list[1].toInt(); 1529 y = list[1].toInt();
1530 w = list[2].toInt(); 1530 w = list[2].toInt();
1531 h = list[3].toInt(); 1531 h = list[3].toInt();
1532 topLevelWidget()->setGeometry(x,y,w,h); 1532 topLevelWidget()->setGeometry(x,y,w,h);
1533 1533
1534 } else { 1534 } else {
1535 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1535 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1536 } 1536 }
1537 list = config->readListEntry("EditEventLayout"); 1537 list = config->readListEntry("EditEventLayout");
1538 if ( ! list.isEmpty() ) { 1538 if ( ! list.isEmpty() ) {
1539 x = list[0].toInt(); 1539 x = list[0].toInt();
1540 y = list[1].toInt(); 1540 y = list[1].toInt();
1541 w = list[2].toInt(); 1541 w = list[2].toInt();
1542 h = list[3].toInt(); 1542 h = list[3].toInt();
1543 mEventEditor->setGeometry(x,y,w,h); 1543 mEventEditor->setGeometry(x,y,w,h);
1544 1544
1545 } 1545 }
1546 list = config->readListEntry("EditTodoLayout"); 1546 list = config->readListEntry("EditTodoLayout");
1547 if ( ! list.isEmpty() ) { 1547 if ( ! list.isEmpty() ) {
1548 x = list[0].toInt(); 1548 x = list[0].toInt();
1549 y = list[1].toInt(); 1549 y = list[1].toInt();
1550 w = list[2].toInt(); 1550 w = list[2].toInt();
1551 h = list[3].toInt(); 1551 h = list[3].toInt();
1552 mTodoEditor->setGeometry(x,y,w,h); 1552 mTodoEditor->setGeometry(x,y,w,h);
1553 1553
1554 } 1554 }
1555 list = config->readListEntry("ViewerLayout"); 1555 list = config->readListEntry("ViewerLayout");
1556 if ( ! list.isEmpty() ) { 1556 if ( ! list.isEmpty() ) {
1557 x = list[0].toInt(); 1557 x = list[0].toInt();
1558 y = list[1].toInt(); 1558 y = list[1].toInt();
1559 w = list[2].toInt(); 1559 w = list[2].toInt();
1560 h = list[3].toInt(); 1560 h = list[3].toInt();
1561 getEventViewerDialog()->setGeometry(x,y,w,h); 1561 getEventViewerDialog()->setGeometry(x,y,w,h);
1562 } 1562 }
1563#endif 1563#endif
1564 1564
1565 1565
1566 // pending read sync settings; 1566 // pending read sync settings;
1567 mSyncProfileNames.clear(); 1567 mSyncProfileNames.clear();
1568 mSyncProfileNames << "Profile_1"; 1568 mSyncProfileNames << "Profile_1";
1569 mSyncProfileNames << "Profile_2"; 1569 mSyncProfileNames << "Profile_2";
1570 mSyncProfileNames << "Profile_3"; 1570 mSyncProfileNames << "Profile_3";
1571 mSyncProfileNames << "Profile_4"; 1571 mSyncProfileNames << "Profile_4";
1572 mSyncProfileNames << "Profile_5"; 1572 mSyncProfileNames << "Profile_5";
1573 KSyncProfile* temp = new KSyncProfile (); 1573 KSyncProfile* temp = new KSyncProfile ();
1574 temp->setName("Profile_1" ); 1574 temp->setName("Profile_1" );
1575 mSyncProfiles.append( temp ); 1575 mSyncProfiles.append( temp );
1576 temp = new KSyncProfile (); 1576 temp = new KSyncProfile ();
1577 temp->setName("Profile_2" ); 1577 temp->setName("Profile_2" );
1578 mSyncProfiles.append( temp ); 1578 mSyncProfiles.append( temp );
1579 temp = new KSyncProfile (); 1579 temp = new KSyncProfile ();
1580 temp->setName("Profile_3" ); 1580 temp->setName("Profile_3" );
1581 mSyncProfiles.append( temp ); 1581 mSyncProfiles.append( temp );
1582 temp = new KSyncProfile (); 1582 temp = new KSyncProfile ();
1583 temp->setName("Profile_4" ); 1583 temp->setName("Profile_4" );
1584 mSyncProfiles.append( temp ); 1584 mSyncProfiles.append( temp );
1585 temp = new KSyncProfile (); 1585 temp = new KSyncProfile ();
1586 temp->setName("Profile_5" ); 1586 temp->setName("Profile_5" );
1587 mSyncProfiles.append( temp ); 1587 mSyncProfiles.append( temp );
1588} 1588}
1589 1589
1590 1590
1591void CalendarView::writeSettings() 1591void CalendarView::writeSettings()
1592{ 1592{
1593 // kdDebug() << "CalendarView::writeSettings" << endl; 1593 // kdDebug() << "CalendarView::writeSettings" << endl;
1594 1594
1595 KConfig *config = KOGlobals::config(); 1595 KConfig *config = KOGlobals::config();
1596 1596
1597#ifndef KORG_NOSPLITTER 1597#ifndef KORG_NOSPLITTER
1598 config->setGroup("KOrganizer Geometry"); 1598 config->setGroup("KOrganizer Geometry");
1599 1599
1600 QValueList<int> list = mPanner->sizes(); 1600 QValueList<int> list = mPanner->sizes();
1601 config->writeEntry("Separator1",list); 1601 config->writeEntry("Separator1",list);
1602 1602
1603 list = mLeftSplitter->sizes(); 1603 list = mLeftSplitter->sizes();
1604 config->writeEntry("Separator2",list); 1604 config->writeEntry("Separator2",list);
1605#endif 1605#endif
1606 1606
1607 mViewManager->writeSettings( config ); 1607 mViewManager->writeSettings( config );
1608 mTodoList->saveLayout(config,QString("Todo Layout")); 1608 mTodoList->saveLayout(config,QString("Todo Layout"));
1609 mDialogManager->writeSettings( config ); 1609 mDialogManager->writeSettings( config );
1610 //KOPrefs::instance()->usrWriteConfig(); 1610 //KOPrefs::instance()->usrWriteConfig();
1611 KOPrefs::instance()->writeConfig(); 1611 KOPrefs::instance()->writeConfig();
1612 1612
1613 writeFilterSettings(config); 1613 writeFilterSettings(config);
1614 1614
1615 config->setGroup( "Views" ); 1615 config->setGroup( "Views" );
1616 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1616 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1617 1617
1618#ifdef DESKTOP_VERSION 1618#ifdef DESKTOP_VERSION
1619 config->setGroup("WidgetLayout"); 1619 config->setGroup("WidgetLayout");
1620 QStringList list ;//= config->readListEntry("MainLayout"); 1620 QStringList list ;//= config->readListEntry("MainLayout");
1621 int x,y,w,h; 1621 int x,y,w,h;
1622 QWidget* wid; 1622 QWidget* wid;
1623 wid = topLevelWidget(); 1623 wid = topLevelWidget();
1624 x = wid->geometry().x(); 1624 x = wid->geometry().x();
1625 y = wid->geometry().y(); 1625 y = wid->geometry().y();
1626 w = wid->width(); 1626 w = wid->width();
1627 h = wid->height(); 1627 h = wid->height();
1628 list.clear(); 1628 list.clear();
1629 list << QString::number( x ); 1629 list << QString::number( x );
1630 list << QString::number( y ); 1630 list << QString::number( y );
1631 list << QString::number( w ); 1631 list << QString::number( w );
1632 list << QString::number( h ); 1632 list << QString::number( h );
1633 config->writeEntry("MainLayout",list ); 1633 config->writeEntry("MainLayout",list );
1634 1634
1635 wid = mEventEditor; 1635 wid = mEventEditor;
1636 x = wid->geometry().x(); 1636 x = wid->geometry().x();
1637 y = wid->geometry().y(); 1637 y = wid->geometry().y();
1638 w = wid->width(); 1638 w = wid->width();
1639 h = wid->height(); 1639 h = wid->height();
1640 list.clear(); 1640 list.clear();
1641 list << QString::number( x ); 1641 list << QString::number( x );
1642 list << QString::number( y ); 1642 list << QString::number( y );
1643 list << QString::number( w ); 1643 list << QString::number( w );
1644 list << QString::number( h ); 1644 list << QString::number( h );
1645 config->writeEntry("EditEventLayout",list ); 1645 config->writeEntry("EditEventLayout",list );
1646 1646
1647 wid = mTodoEditor; 1647 wid = mTodoEditor;
1648 x = wid->geometry().x(); 1648 x = wid->geometry().x();
1649 y = wid->geometry().y(); 1649 y = wid->geometry().y();
1650 w = wid->width(); 1650 w = wid->width();
1651 h = wid->height(); 1651 h = wid->height();
1652 list.clear(); 1652 list.clear();
1653 list << QString::number( x ); 1653 list << QString::number( x );
1654 list << QString::number( y ); 1654 list << QString::number( y );
1655 list << QString::number( w ); 1655 list << QString::number( w );
1656 list << QString::number( h ); 1656 list << QString::number( h );
1657 config->writeEntry("EditTodoLayout",list ); 1657 config->writeEntry("EditTodoLayout",list );
1658 wid = getEventViewerDialog(); 1658 wid = getEventViewerDialog();
1659 x = wid->geometry().x(); 1659 x = wid->geometry().x();
1660 y = wid->geometry().y(); 1660 y = wid->geometry().y();
1661 w = wid->width(); 1661 w = wid->width();
1662 h = wid->height(); 1662 h = wid->height();
1663 list.clear(); 1663 list.clear();
1664 list << QString::number( x ); 1664 list << QString::number( x );
1665 list << QString::number( y ); 1665 list << QString::number( y );
1666 list << QString::number( w ); 1666 list << QString::number( w );
1667 list << QString::number( h ); 1667 list << QString::number( h );
1668 config->writeEntry("ViewerLayout",list ); 1668 config->writeEntry("ViewerLayout",list );
1669 wid = mDialogManager->getSearchDialog(); 1669 wid = mDialogManager->getSearchDialog();
1670 if ( wid ) { 1670 if ( wid ) {
1671 x = wid->geometry().x(); 1671 x = wid->geometry().x();
1672 y = wid->geometry().y(); 1672 y = wid->geometry().y();
1673 w = wid->width(); 1673 w = wid->width();
1674 h = wid->height(); 1674 h = wid->height();
1675 list.clear(); 1675 list.clear();
1676 list << QString::number( x ); 1676 list << QString::number( x );
1677 list << QString::number( y ); 1677 list << QString::number( y );
1678 list << QString::number( w ); 1678 list << QString::number( w );
1679 list << QString::number( h ); 1679 list << QString::number( h );
1680 config->writeEntry("SearchLayout",list ); 1680 config->writeEntry("SearchLayout",list );
1681 } 1681 }
1682#endif 1682#endif
1683 1683
1684 1684
1685 config->sync(); 1685 config->sync();
1686} 1686}
1687 1687
1688void CalendarView::readFilterSettings(KConfig *config) 1688void CalendarView::readFilterSettings(KConfig *config)
1689{ 1689{
1690 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1690 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1691 1691
1692 mFilters.clear(); 1692 mFilters.clear();
1693 1693
1694 config->setGroup("General"); 1694 config->setGroup("General");
1695 QStringList filterList = config->readListEntry("CalendarFilters"); 1695 QStringList filterList = config->readListEntry("CalendarFilters");
1696 1696
1697 QStringList::ConstIterator it = filterList.begin(); 1697 QStringList::ConstIterator it = filterList.begin();
1698 QStringList::ConstIterator end = filterList.end(); 1698 QStringList::ConstIterator end = filterList.end();
1699 while(it != end) { 1699 while(it != end) {
1700 // kdDebug() << " filter: " << (*it) << endl; 1700 // kdDebug() << " filter: " << (*it) << endl;
1701 1701
1702 CalFilter *filter; 1702 CalFilter *filter;
1703 filter = new CalFilter(*it); 1703 filter = new CalFilter(*it);
1704 config->setGroup("Filter_" + (*it)); 1704 config->setGroup("Filter_" + (*it));
1705 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1705 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1706 filter->setCriteria(config->readNumEntry("Criteria",0)); 1706 filter->setCriteria(config->readNumEntry("Criteria",0));
1707 filter->setCategoryList(config->readListEntry("CategoryList")); 1707 filter->setCategoryList(config->readListEntry("CategoryList"));
1708 mFilters.append(filter); 1708 mFilters.append(filter);
1709 1709
1710 ++it; 1710 ++it;
1711 } 1711 }
1712 1712
1713 if (mFilters.count() == 0) { 1713 if (mFilters.count() == 0) {
1714 CalFilter *filter = new CalFilter(i18n("Default")); 1714 CalFilter *filter = new CalFilter(i18n("Default"));
1715 mFilters.append(filter); 1715 mFilters.append(filter);
1716 } 1716 }
1717 mFilterView->updateFilters(); 1717 mFilterView->updateFilters();
1718 config->setGroup("FilterView"); 1718 config->setGroup("FilterView");
1719 1719
1720 mFilterView->blockSignals(true); 1720 mFilterView->blockSignals(true);
1721 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1721 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1722 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1722 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1723 mFilterView->blockSignals(false); 1723 mFilterView->blockSignals(false);
1724 // We do it manually to avoid it being done twice by the above calls 1724 // We do it manually to avoid it being done twice by the above calls
1725 updateFilter(); 1725 updateFilter();
1726} 1726}
1727 1727
1728void CalendarView::writeFilterSettings(KConfig *config) 1728void CalendarView::writeFilterSettings(KConfig *config)
1729{ 1729{
1730 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1730 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1731 1731
1732 QStringList filterList; 1732 QStringList filterList;
1733 1733
1734 CalFilter *filter = mFilters.first(); 1734 CalFilter *filter = mFilters.first();
1735 while(filter) { 1735 while(filter) {
1736 // kdDebug() << " fn: " << filter->name() << endl; 1736 // kdDebug() << " fn: " << filter->name() << endl;
1737 filterList << filter->name(); 1737 filterList << filter->name();
1738 config->setGroup("Filter_" + filter->name()); 1738 config->setGroup("Filter_" + filter->name());
1739 config->writeEntry("Criteria",filter->criteria()); 1739 config->writeEntry("Criteria",filter->criteria());
1740 config->writeEntry("CategoryList",filter->categoryList()); 1740 config->writeEntry("CategoryList",filter->categoryList());
1741 filter = mFilters.next(); 1741 filter = mFilters.next();
1742 } 1742 }
1743 config->setGroup("General"); 1743 config->setGroup("General");
1744 config->writeEntry("CalendarFilters",filterList); 1744 config->writeEntry("CalendarFilters",filterList);
1745 1745
1746 config->setGroup("FilterView"); 1746 config->setGroup("FilterView");
1747 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1747 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1748 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1748 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1749} 1749}
1750 1750
1751 1751
1752void CalendarView::goToday() 1752void CalendarView::goToday()
1753{ 1753{
1754 mNavigator->selectToday(); 1754 mNavigator->selectToday();
1755} 1755}
1756 1756
1757void CalendarView::goNext() 1757void CalendarView::goNext()
1758{ 1758{
1759 mNavigator->selectNext(); 1759 mNavigator->selectNext();
1760} 1760}
1761 1761
1762void CalendarView::goPrevious() 1762void CalendarView::goPrevious()
1763{ 1763{
1764 mNavigator->selectPrevious(); 1764 mNavigator->selectPrevious();
1765} 1765}
1766void CalendarView::goNextMonth() 1766void CalendarView::goNextMonth()
1767{ 1767{
1768 mNavigator->selectNextMonth(); 1768 mNavigator->selectNextMonth();
1769} 1769}
1770 1770
1771void CalendarView::goPreviousMonth() 1771void CalendarView::goPreviousMonth()
1772{ 1772{
1773 mNavigator->selectPreviousMonth(); 1773 mNavigator->selectPreviousMonth();
1774} 1774}
1775void CalendarView::writeLocale() 1775void CalendarView::writeLocale()
1776{ 1776{
1777 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1777 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1778 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1778 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1779 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); 1779 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1780 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1780 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1781 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1781 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1782 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1782 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1783 dummy = KOPrefs::instance()->mUserDateFormatShort; 1783 dummy = KOPrefs::instance()->mUserDateFormatShort;
1784 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1784 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1785 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1785 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1786 KOPrefs::instance()->mDaylightsavingStart, 1786 KOPrefs::instance()->mDaylightsavingStart,
1787 KOPrefs::instance()->mDaylightsavingEnd ); 1787 KOPrefs::instance()->mDaylightsavingEnd );
1788 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1788 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1789} 1789}
1790void CalendarView::updateConfig() 1790void CalendarView::updateConfig()
1791{ 1791{
1792 writeLocale(); 1792 writeLocale();
1793 if ( KOPrefs::instance()->mUseAppColors ) 1793 if ( KOPrefs::instance()->mUseAppColors )
1794 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1794 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1795 emit configChanged(); 1795 emit configChanged();
1796 mTodoList->updateConfig(); 1796 mTodoList->updateConfig();
1797 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1797 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1798 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1798 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1799 // To make the "fill window" configurations work 1799 // To make the "fill window" configurations work
1800 //mViewManager->raiseCurrentView(); 1800 //mViewManager->raiseCurrentView();
1801} 1801}
1802 1802
1803 1803
1804void CalendarView::eventChanged(Event *event) 1804void CalendarView::eventChanged(Event *event)
1805{ 1805{
1806 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1806 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1807 //updateUnmanagedViews(); 1807 //updateUnmanagedViews();
1808} 1808}
1809 1809
1810void CalendarView::eventAdded(Event *event) 1810void CalendarView::eventAdded(Event *event)
1811{ 1811{
1812 changeEventDisplay(event,KOGlobals::EVENTADDED); 1812 changeEventDisplay(event,KOGlobals::EVENTADDED);
1813} 1813}
1814 1814
1815void CalendarView::eventToBeDeleted(Event *) 1815void CalendarView::eventToBeDeleted(Event *)
1816{ 1816{
1817 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1817 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1818} 1818}
1819 1819
1820void CalendarView::eventDeleted() 1820void CalendarView::eventDeleted()
1821{ 1821{
1822 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1822 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1823} 1823}
1824void CalendarView::changeTodoDisplay(Todo *which, int action) 1824void CalendarView::changeTodoDisplay(Todo *which, int action)
1825{ 1825{
1826 changeIncidenceDisplay((Incidence *)which, action); 1826 changeIncidenceDisplay((Incidence *)which, action);
1827} 1827}
1828void CalendarView::checkZaurusId( int id, bool todo ) 1828void CalendarView::checkZaurusId( int id, bool todo )
1829{ 1829{
1830 if ( id >= 0 ) { 1830 if ( id >= 0 ) {
1831 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); 1831 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM");
1832 if ( lse ) { 1832 if ( lse ) {
1833 QString des = lse->description(); 1833 QString des = lse->description();
1834 QString pref = "e"; 1834 QString pref = "e";
1835 if ( todo ) 1835 if ( todo )
1836 pref = "t"; 1836 pref = "t";
1837 des += pref+ QString::number ( id ) + ","; 1837 des += pref+ QString::number ( id ) + ",";
1838 lse->setReadOnly( false ); 1838 lse->setReadOnly( false );
1839 lse->setDescription( des ); 1839 lse->setDescription( des );
1840 lse->setReadOnly( true ); 1840 lse->setReadOnly( true );
1841 } 1841 }
1842 } 1842 }
1843} 1843}
1844void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1844void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1845{ 1845{
1846 updateUnmanagedViews(); 1846 updateUnmanagedViews();
1847 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1847 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1848 if ( action == KOGlobals::EVENTDELETED ) { //delete 1848 if ( action == KOGlobals::EVENTDELETED ) { //delete
1849 mCalendar->checkAlarmForIncidence( 0, true ); 1849 mCalendar->checkAlarmForIncidence( 0, true );
1850 if ( mEventViewerDialog ) 1850 if ( mEventViewerDialog )
1851 mEventViewerDialog->hide(); 1851 mEventViewerDialog->hide();
1852 } 1852 }
1853 else 1853 else
1854 mCalendar->checkAlarmForIncidence( which , false ); 1854 mCalendar->checkAlarmForIncidence( which , false );
1855} 1855}
1856 1856
1857// most of the changeEventDisplays() right now just call the view's 1857// most of the changeEventDisplays() right now just call the view's
1858// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1858// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1859void CalendarView::changeEventDisplay(Event *which, int action) 1859void CalendarView::changeEventDisplay(Event *which, int action)
1860{ 1860{
1861 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1861 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1862 changeIncidenceDisplay((Incidence *)which, action); 1862 changeIncidenceDisplay((Incidence *)which, action);
1863 mDateNavigator->updateView(); 1863 mDateNavigator->updateView();
1864 //mDialogManager->updateSearchDialog(); 1864 //mDialogManager->updateSearchDialog();
1865 1865
1866 if (which) { 1866 if (which) {
1867 // If there is an event view visible update the display 1867 // If there is an event view visible update the display
1868 mViewManager->currentView()->changeEventDisplay(which,action); 1868 mViewManager->currentView()->changeEventDisplay(which,action);
1869 // TODO: check, if update needed 1869 // TODO: check, if update needed
1870 // if (which->getTodoStatus()) { 1870 // if (which->getTodoStatus()) {
1871 mTodoList->updateView(); 1871 mTodoList->updateView();
1872 // } 1872 // }
1873 } else { 1873 } else {
1874 mViewManager->currentView()->updateView(); 1874 mViewManager->currentView()->updateView();
1875 } 1875 }
1876} 1876}
1877 1877
1878 1878
1879void CalendarView::updateTodoViews() 1879void CalendarView::updateTodoViews()
1880{ 1880{
1881 1881
1882 mTodoList->updateView(); 1882 mTodoList->updateView();
1883 mViewManager->currentView()->updateView(); 1883 mViewManager->currentView()->updateView();
1884 1884
1885} 1885}
1886 1886
1887 1887
1888void CalendarView::updateView(const QDate &start, const QDate &end) 1888void CalendarView::updateView(const QDate &start, const QDate &end)
1889{ 1889{
1890 mTodoList->updateView(); 1890 mTodoList->updateView();
1891 mViewManager->updateView(start, end); 1891 mViewManager->updateView(start, end);
1892 //mDateNavigator->updateView(); 1892 //mDateNavigator->updateView();
1893} 1893}
1894 1894
1895void CalendarView::updateView() 1895void CalendarView::updateView()
1896{ 1896{
1897 DateList tmpList = mNavigator->selectedDates(); 1897 DateList tmpList = mNavigator->selectedDates();
1898 1898
1899 // We assume that the navigator only selects consecutive days. 1899 // We assume that the navigator only selects consecutive days.
1900 updateView( tmpList.first(), tmpList.last() ); 1900 updateView( tmpList.first(), tmpList.last() );
1901} 1901}
1902 1902
1903void CalendarView::updateUnmanagedViews() 1903void CalendarView::updateUnmanagedViews()
1904{ 1904{
1905 mDateNavigator->updateDayMatrix(); 1905 mDateNavigator->updateDayMatrix();
1906} 1906}
1907 1907
1908int CalendarView::msgItemDelete() 1908int CalendarView::msgItemDelete()
1909{ 1909{
1910 return KMessageBox::warningContinueCancel(this, 1910 return KMessageBox::warningContinueCancel(this,
1911 i18n("This item will be\npermanently deleted."), 1911 i18n("This item will be\npermanently deleted."),
1912 i18n("KO/Pi Confirmation"),i18n("Delete")); 1912 i18n("KO/Pi Confirmation"),i18n("Delete"));
1913} 1913}
1914 1914
1915 1915
1916void CalendarView::edit_cut() 1916void CalendarView::edit_cut()
1917{ 1917{
1918 Event *anEvent=0; 1918 Event *anEvent=0;
1919 1919
1920 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1920 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1921 1921
1922 if (mViewManager->currentView()->isEventView()) { 1922 if (mViewManager->currentView()->isEventView()) {
1923 if ( incidence && incidence->type() == "Event" ) { 1923 if ( incidence && incidence->type() == "Event" ) {
1924 anEvent = static_cast<Event *>(incidence); 1924 anEvent = static_cast<Event *>(incidence);
1925 } 1925 }
1926 } 1926 }
1927 1927
1928 if (!anEvent) { 1928 if (!anEvent) {
1929 KNotifyClient::beep(); 1929 KNotifyClient::beep();
1930 return; 1930 return;
1931 } 1931 }
1932 DndFactory factory( mCalendar ); 1932 DndFactory factory( mCalendar );
1933 factory.cutEvent(anEvent); 1933 factory.cutEvent(anEvent);
1934 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 1934 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
1935} 1935}
1936 1936
1937void CalendarView::edit_copy() 1937void CalendarView::edit_copy()
1938{ 1938{
1939 Event *anEvent=0; 1939 Event *anEvent=0;
1940 1940
1941 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1941 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1942 1942
1943 if (mViewManager->currentView()->isEventView()) { 1943 if (mViewManager->currentView()->isEventView()) {
1944 if ( incidence && incidence->type() == "Event" ) { 1944 if ( incidence && incidence->type() == "Event" ) {
1945 anEvent = static_cast<Event *>(incidence); 1945 anEvent = static_cast<Event *>(incidence);
1946 } 1946 }
1947 } 1947 }
1948 1948
1949 if (!anEvent) { 1949 if (!anEvent) {
1950 KNotifyClient::beep(); 1950 KNotifyClient::beep();
1951 return; 1951 return;
1952 } 1952 }
1953 DndFactory factory( mCalendar ); 1953 DndFactory factory( mCalendar );
1954 factory.copyEvent(anEvent); 1954 factory.copyEvent(anEvent);
1955} 1955}
1956 1956
1957void CalendarView::edit_paste() 1957void CalendarView::edit_paste()
1958{ 1958{
1959 QDate date = mNavigator->selectedDates().first(); 1959 QDate date = mNavigator->selectedDates().first();
1960 1960
1961 DndFactory factory( mCalendar ); 1961 DndFactory factory( mCalendar );
1962 Event *pastedEvent = factory.pasteEvent( date ); 1962 Event *pastedEvent = factory.pasteEvent( date );
1963 1963
1964 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 1964 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
1965} 1965}
1966 1966
1967void CalendarView::edit_options() 1967void CalendarView::edit_options()
1968{ 1968{
1969 mDialogManager->showOptionsDialog(); 1969 mDialogManager->showOptionsDialog();
1970 //writeSettings(); 1970 //writeSettings();
1971} 1971}
1972void CalendarView::edit_sync_options() 1972void CalendarView::edit_sync_options()
1973{ 1973{
1974 //mDialogManager->showSyncOptions(); 1974 //mDialogManager->showSyncOptions();
1975 //KOPrefs::instance()->mSyncAlgoPrefs 1975 //KOPrefs::instance()->mSyncAlgoPrefs
1976 QDialog dia( this, "dia", true ); 1976 QDialog dia( this, "dia", true );
1977 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 1977 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
1978 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 1978 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
1979 QVBoxLayout lay ( &dia ); 1979 QVBoxLayout lay ( &dia );
1980 lay.setSpacing( 2 ); 1980 lay.setSpacing( 2 );
1981 lay.setMargin( 3 ); 1981 lay.setMargin( 3 );
1982 lay.addWidget(&gr); 1982 lay.addWidget(&gr);
1983 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 1983 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
1984 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 1984 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
1985 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 1985 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
1986 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 1986 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
1987 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 1987 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
1988 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 1988 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
1989 //QRadioButton both( i18n("Take both on conflict"), &gr ); 1989 //QRadioButton both( i18n("Take both on conflict"), &gr );
1990 QPushButton pb ( "OK", &dia); 1990 QPushButton pb ( "OK", &dia);
1991 lay.addWidget( &pb ); 1991 lay.addWidget( &pb );
1992 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1992 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1993 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 1993 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
1994 case 0: 1994 case 0:
1995 loc.setChecked( true); 1995 loc.setChecked( true);
1996 break; 1996 break;
1997 case 1: 1997 case 1:
1998 rem.setChecked( true ); 1998 rem.setChecked( true );
1999 break; 1999 break;
2000 case 2: 2000 case 2:
2001 newest.setChecked( true); 2001 newest.setChecked( true);
2002 break; 2002 break;
2003 case 3: 2003 case 3:
2004 ask.setChecked( true); 2004 ask.setChecked( true);
2005 break; 2005 break;
2006 case 4: 2006 case 4:
2007 f_loc.setChecked( true); 2007 f_loc.setChecked( true);
2008 break; 2008 break;
2009 case 5: 2009 case 5:
2010 f_rem.setChecked( true); 2010 f_rem.setChecked( true);
2011 break; 2011 break;
2012 case 6: 2012 case 6:
2013 // both.setChecked( true); 2013 // both.setChecked( true);
2014 break; 2014 break;
2015 default: 2015 default:
2016 break; 2016 break;
2017 } 2017 }
2018 if ( dia.exec() ) { 2018 if ( dia.exec() ) {
2019 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2019 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2020 } 2020 }
2021 2021
2022} 2022}
2023 2023
2024void CalendarView::slotSelectPickerDate( QDate d) 2024void CalendarView::slotSelectPickerDate( QDate d)
2025{ 2025{
2026 mDateFrame->hide(); 2026 mDateFrame->hide();
2027 if ( mDatePickerMode == 1 ) { 2027 if ( mDatePickerMode == 1 ) {
2028 mNavigator->slotDaySelect( d ); 2028 mNavigator->slotDaySelect( d );
2029 } else if ( mDatePickerMode == 2 ) { 2029 } else if ( mDatePickerMode == 2 ) {
2030 if ( mMoveIncidence->type() == "Todo" ) { 2030 if ( mMoveIncidence->type() == "Todo" ) {
2031 Todo * to = (Todo *) mMoveIncidence; 2031 Todo * to = (Todo *) mMoveIncidence;
2032 QTime tim; 2032 QTime tim;
2033 if ( to->hasDueDate() ) 2033 if ( to->hasDueDate() )
2034 tim = to->dtDue().time(); 2034 tim = to->dtDue().time();
2035 else { 2035 else {
2036 tim = QTime ( 0,0,0 ); 2036 tim = QTime ( 0,0,0 );
2037 to->setFloats( true ); 2037 to->setFloats( true );
2038 to->setHasDueDate( true ); 2038 to->setHasDueDate( true );
2039 } 2039 }
2040 QDateTime dt ( d,tim ); 2040 QDateTime dt ( d,tim );
2041 to->setDtDue( dt ); 2041 to->setDtDue( dt );
2042 todoChanged( to ); 2042 todoChanged( to );
2043 } else { 2043 } else {
2044 QTime tim = mMoveIncidence->dtStart().time(); 2044 QTime tim = mMoveIncidence->dtStart().time();
2045 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2045 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2046 QDateTime dt ( d,tim ); 2046 QDateTime dt ( d,tim );
2047 mMoveIncidence->setDtStart( dt ); 2047 mMoveIncidence->setDtStart( dt );
2048 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2048 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2049 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2049 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2050 } 2050 }
2051 2051
2052 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2052 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2053 } 2053 }
2054} 2054}
2055 2055
2056void CalendarView::removeCategories() 2056void CalendarView::removeCategories()
2057{ 2057{
2058 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2058 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2059 QStringList catList = KOPrefs::instance()->mCustomCategories; 2059 QStringList catList = KOPrefs::instance()->mCustomCategories;
2060 QStringList catIncList; 2060 QStringList catIncList;
2061 QStringList newCatList; 2061 QStringList newCatList;
2062 Incidence* inc = incList.first(); 2062 Incidence* inc = incList.first();
2063 int i; 2063 int i;
2064 int count = 0; 2064 int count = 0;
2065 while ( inc ) { 2065 while ( inc ) {
2066 newCatList.clear(); 2066 newCatList.clear();
2067 catIncList = inc->categories() ; 2067 catIncList = inc->categories() ;
2068 for( i = 0; i< catIncList.count(); ++i ) { 2068 for( i = 0; i< catIncList.count(); ++i ) {
2069 if ( catList.contains (catIncList[i])) 2069 if ( catList.contains (catIncList[i]))
2070 newCatList.append( catIncList[i] ); 2070 newCatList.append( catIncList[i] );
2071 } 2071 }
2072 newCatList.sort(); 2072 newCatList.sort();
2073 inc->setCategories( newCatList.join(",") ); 2073 inc->setCategories( newCatList.join(",") );
2074 inc = incList.next(); 2074 inc = incList.next();
2075 } 2075 }
2076} 2076}
2077 2077
2078int CalendarView::addCategories() 2078int CalendarView::addCategories()
2079{ 2079{
2080 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2080 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2081 QStringList catList = KOPrefs::instance()->mCustomCategories; 2081 QStringList catList = KOPrefs::instance()->mCustomCategories;
2082 QStringList catIncList; 2082 QStringList catIncList;
2083 Incidence* inc = incList.first(); 2083 Incidence* inc = incList.first();
2084 int i; 2084 int i;
2085 int count = 0; 2085 int count = 0;
2086 while ( inc ) { 2086 while ( inc ) {
2087 catIncList = inc->categories() ; 2087 catIncList = inc->categories() ;
2088 for( i = 0; i< catIncList.count(); ++i ) { 2088 for( i = 0; i< catIncList.count(); ++i ) {
2089 if ( !catList.contains (catIncList[i])) { 2089 if ( !catList.contains (catIncList[i])) {
2090 catList.append( catIncList[i] ); 2090 catList.append( catIncList[i] );
2091 //qDebug("add cat %s ", catIncList[i].latin1()); 2091 //qDebug("add cat %s ", catIncList[i].latin1());
2092 ++count; 2092 ++count;
2093 } 2093 }
2094 } 2094 }
2095 inc = incList.next(); 2095 inc = incList.next();
2096 } 2096 }
2097 catList.sort(); 2097 catList.sort();
2098 KOPrefs::instance()->mCustomCategories = catList; 2098 KOPrefs::instance()->mCustomCategories = catList;
2099 return count; 2099 return count;
2100} 2100}
2101 2101
2102void CalendarView::manageCategories() 2102void CalendarView::manageCategories()
2103{ 2103{
2104 KOCatPrefs* cp = new KOCatPrefs(); 2104 KOCatPrefs* cp = new KOCatPrefs();
2105 cp->show(); 2105 cp->show();
2106 int w =cp->sizeHint().width() ; 2106 int w =cp->sizeHint().width() ;
2107 int h = cp->sizeHint().height() ; 2107 int h = cp->sizeHint().height() ;
2108 int dw = QApplication::desktop()->width(); 2108 int dw = QApplication::desktop()->width();
2109 int dh = QApplication::desktop()->height(); 2109 int dh = QApplication::desktop()->height();
2110 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2110 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2111 if ( !cp->exec() ) { 2111 if ( !cp->exec() ) {
2112 delete cp; 2112 delete cp;
2113 return; 2113 return;
2114 } 2114 }
2115 int count = 0; 2115 int count = 0;
2116 if ( cp->addCat() ) { 2116 if ( cp->addCat() ) {
2117 count = addCategories(); 2117 count = addCategories();
2118 if ( count ) { 2118 if ( count ) {
2119 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2119 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2120 writeSettings(); 2120 writeSettings();
2121 } 2121 }
2122 } else { 2122 } else {
2123 removeCategories(); 2123 removeCategories();
2124 updateView(); 2124 updateView();
2125 } 2125 }
2126 delete cp; 2126 delete cp;
2127} 2127}
2128 2128
2129void CalendarView::beamIncidence(Incidence * Inc) 2129void CalendarView::beamIncidence(Incidence * Inc)
2130{ 2130{
2131 QPtrList<Incidence> delSel ; 2131 QPtrList<Incidence> delSel ;
2132 delSel.append(Inc); 2132 delSel.append(Inc);
2133 beamIncidenceList( delSel ); 2133 beamIncidenceList( delSel );
2134} 2134}
2135void CalendarView::beamCalendar() 2135void CalendarView::beamCalendar()
2136{ 2136{
2137 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2137 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2138 //qDebug("beamCalendar() "); 2138 //qDebug("beamCalendar() ");
2139 beamIncidenceList( delSel ); 2139 beamIncidenceList( delSel );
2140} 2140}
2141void CalendarView::beamFilteredCalendar() 2141void CalendarView::beamFilteredCalendar()
2142{ 2142{
2143 QPtrList<Incidence> delSel = mCalendar->incidences(); 2143 QPtrList<Incidence> delSel = mCalendar->incidences();
2144 //qDebug("beamFilteredCalendar() "); 2144 //qDebug("beamFilteredCalendar() ");
2145 beamIncidenceList( delSel ); 2145 beamIncidenceList( delSel );
2146} 2146}
2147void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2147void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2148{ 2148{
2149 if ( beamDialog->exec () == QDialog::Rejected ) 2149 if ( beamDialog->exec () == QDialog::Rejected )
2150 return; 2150 return;
2151 2151
2152 QString fn = "/tmp/kopibeamfile"; 2152 QString fn = "/tmp/kopibeamfile";
2153 QString mes; 2153 QString mes;
2154 bool createbup = true; 2154 bool createbup = true;
2155 if ( createbup ) { 2155 if ( createbup ) {
2156 QString description = "\n"; 2156 QString description = "\n";
2157 CalendarLocal* cal = new CalendarLocal(); 2157 CalendarLocal* cal = new CalendarLocal();
2158 if ( beamDialog->beamLocal() ) 2158 if ( beamDialog->beamLocal() )
2159 cal->setLocalTime(); 2159 cal->setLocalTime();
2160 else 2160 else
2161 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2161 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2162 Incidence *incidence = delSel.first(); 2162 Incidence *incidence = delSel.first();
2163 bool addText = false; 2163 bool addText = false;
2164 if ( delSel.count() < 10 ) 2164 if ( delSel.count() < 10 )
2165 addText = true; 2165 addText = true;
2166 else { 2166 else {
2167 description.sprintf(i18n(" %d items?"),delSel.count() ); 2167 description.sprintf(i18n(" %d items?"),delSel.count() );
2168 } 2168 }
2169 while ( incidence ) { 2169 while ( incidence ) {
2170 Incidence *in = incidence->clone(); 2170 Incidence *in = incidence->clone();
2171 if ( addText ) 2171 if ( addText )
2172 description += in->summary() + "\n"; 2172 description += in->summary() + "\n";
2173 cal->addIncidence( in ); 2173 cal->addIncidence( in );
2174 incidence = delSel.next(); 2174 incidence = delSel.next();
2175 } 2175 }
2176 if ( beamDialog->beamVcal() ) { 2176 if ( beamDialog->beamVcal() ) {
2177 fn += ".vcs"; 2177 fn += ".vcs";
2178 FileStorage storage( cal, fn, new VCalFormat ); 2178 FileStorage storage( cal, fn, new VCalFormat );
2179 storage.save(); 2179 storage.save();
2180 } else { 2180 } else {
2181 fn += ".ics"; 2181 fn += ".ics";
2182 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2182 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2183 storage.save(); 2183 storage.save();
2184 } 2184 }
2185 delete cal; 2185 delete cal;
2186 mes = i18n("KO/Pi: Ready for beaming"); 2186 mes = i18n("KO/Pi: Ready for beaming");
2187 setCaption(mes); 2187 setCaption(mes);
2188 2188
2189#ifndef DESKTOP_VERSION 2189#ifndef DESKTOP_VERSION
2190 Ir *ir = new Ir( this ); 2190 Ir *ir = new Ir( this );
2191 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2191 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2192 ir->send( fn, description, "text/x-vCalendar" ); 2192 ir->send( fn, description, "text/x-vCalendar" );
2193#endif 2193#endif
2194 } 2194 }
2195} 2195}
2196void CalendarView::beamDone( Ir *ir ) 2196void CalendarView::beamDone( Ir *ir )
2197{ 2197{
2198#ifndef DESKTOP_VERSION 2198#ifndef DESKTOP_VERSION
2199 delete ir; 2199 delete ir;
2200#endif 2200#endif
2201} 2201}
2202 2202
2203void CalendarView::moveIncidence(Incidence * inc ) 2203void CalendarView::moveIncidence(Incidence * inc )
2204{ 2204{
2205 if ( !inc ) return; 2205 if ( !inc ) return;
2206 // qDebug("showDatePickerForIncidence( ) "); 2206 // qDebug("showDatePickerForIncidence( ) ");
2207 if ( mDateFrame->isVisible() ) 2207 if ( mDateFrame->isVisible() )
2208 mDateFrame->hide(); 2208 mDateFrame->hide();
2209 else { 2209 else {
2210 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2210 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2211 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2211 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2212 int dw = QApplication::desktop()->width(); 2212 int dw = QApplication::desktop()->width();
2213 int dh = QApplication::desktop()->height(); 2213 int dh = QApplication::desktop()->height();
2214 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2214 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2215 mDateFrame->show(); 2215 mDateFrame->show();
2216 } 2216 }
2217 mDatePickerMode = 2; 2217 mDatePickerMode = 2;
2218 mMoveIncidence = inc ; 2218 mMoveIncidence = inc ;
2219 QDate da; 2219 QDate da;
2220 if ( mMoveIncidence->type() == "Todo" ) { 2220 if ( mMoveIncidence->type() == "Todo" ) {
2221 Todo * to = (Todo *) mMoveIncidence; 2221 Todo * to = (Todo *) mMoveIncidence;
2222 if ( to->hasDueDate() ) 2222 if ( to->hasDueDate() )
2223 da = to->dtDue().date(); 2223 da = to->dtDue().date();
2224 else 2224 else
2225 da = QDate::currentDate(); 2225 da = QDate::currentDate();
2226 } else { 2226 } else {
2227 da = mMoveIncidence->dtStart().date(); 2227 da = mMoveIncidence->dtStart().date();
2228 } 2228 }
2229 mDatePicker->setDate( da ); 2229 mDatePicker->setDate( da );
2230} 2230}
2231void CalendarView::showDatePicker( ) 2231void CalendarView::showDatePicker( )
2232{ 2232{
2233 //qDebug("CalendarView::showDatePicker( ) "); 2233 //qDebug("CalendarView::showDatePicker( ) ");
2234 if ( mDateFrame->isVisible() ) 2234 if ( mDateFrame->isVisible() )
2235 mDateFrame->hide(); 2235 mDateFrame->hide();
2236 else { 2236 else {
2237 int w =mDatePicker->sizeHint().width() ; 2237 int w =mDatePicker->sizeHint().width() ;
2238 int h = mDatePicker->sizeHint().height() ; 2238 int h = mDatePicker->sizeHint().height() ;
2239 int dw = QApplication::desktop()->width(); 2239 int dw = QApplication::desktop()->width();
2240 int dh = QApplication::desktop()->height(); 2240 int dh = QApplication::desktop()->height();
2241 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2241 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2242 mDateFrame->show(); 2242 mDateFrame->show();
2243 } 2243 }
2244 mDatePickerMode = 1; 2244 mDatePickerMode = 1;
2245 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2245 mDatePicker->setDate( mNavigator->selectedDates().first() );
2246} 2246}
2247 2247
2248void CalendarView::showEventEditor() 2248void CalendarView::showEventEditor()
2249{ 2249{
2250#ifdef DESKTOP_VERSION 2250#ifdef DESKTOP_VERSION
2251 mEventEditor->show(); 2251 mEventEditor->show();
2252#else 2252#else
2253 mEventEditor->showMaximized(); 2253 mEventEditor->showMaximized();
2254#endif 2254#endif
2255} 2255}
2256void CalendarView::showTodoEditor() 2256void CalendarView::showTodoEditor()
2257{ 2257{
2258#ifdef DESKTOP_VERSION 2258#ifdef DESKTOP_VERSION
2259 mTodoEditor->show(); 2259 mTodoEditor->show();
2260#else 2260#else
2261 mTodoEditor->showMaximized(); 2261 mTodoEditor->showMaximized();
2262#endif 2262#endif
2263} 2263}
2264void CalendarView::cancelIncidence(Incidence * inc ) 2264void CalendarView::cancelIncidence(Incidence * inc )
2265{ 2265{
2266 inc->setCancelled( ! inc->cancelled() ); 2266 inc->setCancelled( ! inc->cancelled() );
2267 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2267 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2268 updateView(); 2268 updateView();
2269} 2269}
2270void CalendarView::cloneIncidence(Incidence * orgInc ) 2270void CalendarView::cloneIncidence(Incidence * orgInc )
2271{ 2271{
2272 Incidence * newInc = orgInc->clone(); 2272 Incidence * newInc = orgInc->clone();
2273 newInc->recreate(); 2273 newInc->recreate();
2274 2274
2275 if ( newInc->type() == "Todo" ) { 2275 if ( newInc->type() == "Todo" ) {
2276 Todo* t = (Todo*) newInc; 2276 Todo* t = (Todo*) newInc;
2277 mTodoEditor->editTodo( t ); 2277 mTodoEditor->editTodo( t );
2278 showTodoEditor(); 2278 showTodoEditor();
2279 if ( mTodoEditor->exec() ) { 2279 if ( mTodoEditor->exec() ) {
2280 mCalendar->addTodo( t ); 2280 mCalendar->addTodo( t );
2281 updateView(); 2281 updateView();
2282 } else { 2282 } else {
2283 delete t; 2283 delete t;
2284 } 2284 }
2285 } 2285 }
2286 else { 2286 else {
2287 Event* e = (Event*) newInc; 2287 Event* e = (Event*) newInc;
2288 mEventEditor->editEvent( e ); 2288 mEventEditor->editEvent( e );
2289 showEventEditor(); 2289 showEventEditor();
2290 if ( mEventEditor->exec() ) { 2290 if ( mEventEditor->exec() ) {
2291 mCalendar->addEvent( e ); 2291 mCalendar->addEvent( e );
2292 updateView(); 2292 updateView();
2293 } else { 2293 } else {
2294 delete e; 2294 delete e;
2295 } 2295 }
2296 } 2296 }
2297} 2297}
2298 2298
2299void CalendarView::newEvent() 2299void CalendarView::newEvent()
2300{ 2300{
2301 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2301 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2302 KOAgendaView *aView = mViewManager->agendaView(); 2302 KOAgendaView *aView = mViewManager->agendaView();
2303 if (aView) { 2303 if (aView) {
2304 if (aView->selectionStart().isValid()) { 2304 if (aView->selectionStart().isValid()) {
2305 if (aView->selectedIsAllDay()) { 2305 if (aView->selectedIsAllDay()) {
2306 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2306 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2307 } else { 2307 } else {
2308 newEvent(aView->selectionStart(),aView->selectionEnd()); 2308 newEvent(aView->selectionStart(),aView->selectionEnd());
2309 } 2309 }
2310 return; 2310 return;
2311 } 2311 }
2312 } 2312 }
2313 2313
2314 QDate date = mNavigator->selectedDates().first(); 2314 QDate date = mNavigator->selectedDates().first();
2315 QDateTime current = QDateTime::currentDateTime(); 2315 QDateTime current = QDateTime::currentDateTime();
2316 if ( date <= current.date() ) { 2316 if ( date <= current.date() ) {
2317 int hour = current.time().hour() +1; 2317 int hour = current.time().hour() +1;
2318 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2318 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2319 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2319 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2320 } else 2320 } else
2321 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2321 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2322 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2322 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2323 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2323 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2324} 2324}
2325 2325
2326void CalendarView::newEvent(QDateTime fh) 2326void CalendarView::newEvent(QDateTime fh)
2327{ 2327{
2328 newEvent(fh, 2328 newEvent(fh,
2329 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2329 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2330} 2330}
2331 2331
2332void CalendarView::newEvent(QDate dt) 2332void CalendarView::newEvent(QDate dt)
2333{ 2333{
2334 newEvent(QDateTime(dt, QTime(0,0,0)), 2334 newEvent(QDateTime(dt, QTime(0,0,0)),
2335 QDateTime(dt, QTime(0,0,0)), true); 2335 QDateTime(dt, QTime(0,0,0)), true);
2336} 2336}
2337 2337
2338void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2338void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2339{ 2339{
2340 2340
2341 mEventEditor->newEvent(fromHint,toHint,allDay); 2341 mEventEditor->newEvent(fromHint,toHint,allDay);
2342 if ( mFilterView->filtersEnabled() ) { 2342 if ( mFilterView->filtersEnabled() ) {
2343 CalFilter *filter = mFilterView->selectedFilter(); 2343 CalFilter *filter = mFilterView->selectedFilter();
2344 if (filter && filter->showCategories()) { 2344 if (filter && filter->showCategories()) {
2345 mEventEditor->setCategories(filter->categoryList().join(",") ); 2345 mEventEditor->setCategories(filter->categoryList().join(",") );
2346 } 2346 }
2347 if ( filter ) 2347 if ( filter )
2348 mEventEditor->setSecrecy( filter->getSecrecy() ); 2348 mEventEditor->setSecrecy( filter->getSecrecy() );
2349 } 2349 }
2350 showEventEditor(); 2350 showEventEditor();
2351} 2351}
2352void CalendarView::todoAdded(Todo * t) 2352void CalendarView::todoAdded(Todo * t)
2353{ 2353{
2354 2354
2355 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2355 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2356 updateTodoViews(); 2356 updateTodoViews();
2357} 2357}
2358void CalendarView::todoChanged(Todo * t) 2358void CalendarView::todoChanged(Todo * t)
2359{ 2359{
2360 emit todoModified( t, 4 ); 2360 emit todoModified( t, 4 );
2361 // updateTodoViews(); 2361 // updateTodoViews();
2362} 2362}
2363void CalendarView::todoToBeDeleted(Todo *) 2363void CalendarView::todoToBeDeleted(Todo *)
2364{ 2364{
2365 //qDebug("todoToBeDeleted(Todo *) "); 2365 //qDebug("todoToBeDeleted(Todo *) ");
2366 updateTodoViews(); 2366 updateTodoViews();
2367} 2367}
2368void CalendarView::todoDeleted() 2368void CalendarView::todoDeleted()
2369{ 2369{
2370 //qDebug(" todoDeleted()"); 2370 //qDebug(" todoDeleted()");
2371 updateTodoViews(); 2371 updateTodoViews();
2372} 2372}
2373 2373
2374 2374
2375 2375
2376void CalendarView::newTodo() 2376void CalendarView::newTodo()
2377{ 2377{
2378 2378
2379 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2379 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2380 if ( mFilterView->filtersEnabled() ) { 2380 if ( mFilterView->filtersEnabled() ) {
2381 CalFilter *filter = mFilterView->selectedFilter(); 2381 CalFilter *filter = mFilterView->selectedFilter();
2382 if (filter && filter->showCategories()) { 2382 if (filter && filter->showCategories()) {
2383 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2383 mTodoEditor->setCategories(filter->categoryList().join(",") );
2384 } 2384 }
2385 if ( filter ) 2385 if ( filter )
2386 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2386 mTodoEditor->setSecrecy( filter->getSecrecy() );
2387 } 2387 }
2388 showTodoEditor(); 2388 showTodoEditor();
2389} 2389}
2390 2390
2391void CalendarView::newSubTodo() 2391void CalendarView::newSubTodo()
2392{ 2392{
2393 Todo *todo = selectedTodo(); 2393 Todo *todo = selectedTodo();
2394 if ( todo ) newSubTodo( todo ); 2394 if ( todo ) newSubTodo( todo );
2395} 2395}
2396 2396
2397void CalendarView::newSubTodo(Todo *parentEvent) 2397void CalendarView::newSubTodo(Todo *parentEvent)
2398{ 2398{
2399 2399
2400 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2400 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2401 showTodoEditor(); 2401 showTodoEditor();
2402} 2402}
2403 2403
2404void CalendarView::newFloatingEvent() 2404void CalendarView::newFloatingEvent()
2405{ 2405{
2406 DateList tmpList = mNavigator->selectedDates(); 2406 DateList tmpList = mNavigator->selectedDates();
2407 QDate date = tmpList.first(); 2407 QDate date = tmpList.first();
2408 2408
2409 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2409 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2410 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2410 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2411} 2411}
2412 2412
2413 2413
2414void CalendarView::editEvent( Event *event ) 2414void CalendarView::editEvent( Event *event )
2415{ 2415{
2416 2416
2417 if ( !event ) return; 2417 if ( !event ) return;
2418 if ( event->isReadOnly() ) { 2418 if ( event->isReadOnly() ) {
2419 showEvent( event ); 2419 showEvent( event );
2420 return; 2420 return;
2421 } 2421 }
2422 mEventEditor->editEvent( event , mFlagEditDescription); 2422 mEventEditor->editEvent( event , mFlagEditDescription);
2423 showEventEditor(); 2423 showEventEditor();
2424} 2424}
2425void CalendarView::editJournal( Journal *jour ) 2425void CalendarView::editJournal( Journal *jour )
2426{ 2426{
2427 if ( !jour ) return; 2427 if ( !jour ) return;
2428 mDialogManager->hideSearchDialog(); 2428 mDialogManager->hideSearchDialog();
2429 mViewManager->showJournalView(); 2429 mViewManager->showJournalView();
2430 mNavigator->slotDaySelect( jour->dtStart().date() ); 2430 mNavigator->slotDaySelect( jour->dtStart().date() );
2431} 2431}
2432void CalendarView::editTodo( Todo *todo ) 2432void CalendarView::editTodo( Todo *todo )
2433{ 2433{
2434 if ( !todo ) return; 2434 if ( !todo ) return;
2435 2435
2436 if ( todo->isReadOnly() ) { 2436 if ( todo->isReadOnly() ) {
2437 showTodo( todo ); 2437 showTodo( todo );
2438 return; 2438 return;
2439 } 2439 }
2440 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2440 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2441 showTodoEditor(); 2441 showTodoEditor();
2442 2442
2443} 2443}
2444 2444
2445KOEventViewerDialog* CalendarView::getEventViewerDialog() 2445KOEventViewerDialog* CalendarView::getEventViewerDialog()
2446{ 2446{
2447 if ( !mEventViewerDialog ) { 2447 if ( !mEventViewerDialog ) {
2448 mEventViewerDialog = new KOEventViewerDialog(this); 2448 mEventViewerDialog = new KOEventViewerDialog(this);
2449 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2449 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2450 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2450 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2451 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2451 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2452 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2452 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2453 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2453 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2454 viewManager(), SLOT( showAgendaView( bool ) ) ); 2454 viewManager(), SLOT( showAgendaView( bool ) ) );
2455 mEventViewerDialog->resize( 640, 480 ); 2455 mEventViewerDialog->resize( 640, 480 );
2456 2456
2457 } 2457 }
2458 return mEventViewerDialog; 2458 return mEventViewerDialog;
2459} 2459}
2460void CalendarView::showEvent(Event *event) 2460void CalendarView::showEvent(Event *event)
2461{ 2461{
2462 getEventViewerDialog()->setEvent(event); 2462 getEventViewerDialog()->setEvent(event);
2463 getEventViewerDialog()->showMe(); 2463 getEventViewerDialog()->showMe();
2464} 2464}
2465 2465
2466void CalendarView::showTodo(Todo *event) 2466void CalendarView::showTodo(Todo *event)
2467{ 2467{
2468 getEventViewerDialog()->setTodo(event); 2468 getEventViewerDialog()->setTodo(event);
2469 getEventViewerDialog()->showMe(); 2469 getEventViewerDialog()->showMe();
2470} 2470}
2471void CalendarView::showJournal( Journal *jour ) 2471void CalendarView::showJournal( Journal *jour )
2472{ 2472{
2473 getEventViewerDialog()->setJournal(jour); 2473 getEventViewerDialog()->setJournal(jour);
2474 getEventViewerDialog()->showMe(); 2474 getEventViewerDialog()->showMe();
2475 2475
2476} 2476}
2477// void CalendarView::todoModified (Todo *event, int changed) 2477// void CalendarView::todoModified (Todo *event, int changed)
2478// { 2478// {
2479// // if (mDialogList.find (event) != mDialogList.end ()) { 2479// // if (mDialogList.find (event) != mDialogList.end ()) {
2480// // kdDebug() << "Todo modified and open" << endl; 2480// // kdDebug() << "Todo modified and open" << endl;
2481// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2481// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2482// // temp->modified (changed); 2482// // temp->modified (changed);
2483 2483
2484// // } 2484// // }
2485 2485
2486// mViewManager->updateView(); 2486// mViewManager->updateView();
2487// } 2487// }
2488 2488
2489void CalendarView::appointment_show() 2489void CalendarView::appointment_show()
2490{ 2490{
2491 Event *anEvent = 0; 2491 Event *anEvent = 0;
2492 2492
2493 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2493 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2494 2494
2495 if (mViewManager->currentView()->isEventView()) { 2495 if (mViewManager->currentView()->isEventView()) {
2496 if ( incidence && incidence->type() == "Event" ) { 2496 if ( incidence && incidence->type() == "Event" ) {
2497 anEvent = static_cast<Event *>(incidence); 2497 anEvent = static_cast<Event *>(incidence);
2498 } 2498 }
2499 } 2499 }
2500 2500
2501 if (!anEvent) { 2501 if (!anEvent) {
2502 KNotifyClient::beep(); 2502 KNotifyClient::beep();
2503 return; 2503 return;
2504 } 2504 }
2505 2505
2506 showEvent(anEvent); 2506 showEvent(anEvent);
2507} 2507}
2508 2508
2509void CalendarView::appointment_edit() 2509void CalendarView::appointment_edit()
2510{ 2510{
2511 Event *anEvent = 0; 2511 Event *anEvent = 0;
2512 2512
2513 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2513 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2514 2514
2515 if (mViewManager->currentView()->isEventView()) { 2515 if (mViewManager->currentView()->isEventView()) {
2516 if ( incidence && incidence->type() == "Event" ) { 2516 if ( incidence && incidence->type() == "Event" ) {
2517 anEvent = static_cast<Event *>(incidence); 2517 anEvent = static_cast<Event *>(incidence);
2518 } 2518 }
2519 } 2519 }
2520 2520
2521 if (!anEvent) { 2521 if (!anEvent) {
2522 KNotifyClient::beep(); 2522 KNotifyClient::beep();
2523 return; 2523 return;
2524 } 2524 }
2525 2525
2526 editEvent(anEvent); 2526 editEvent(anEvent);
2527} 2527}
2528 2528
2529void CalendarView::appointment_delete() 2529void CalendarView::appointment_delete()
2530{ 2530{
2531 Event *anEvent = 0; 2531 Event *anEvent = 0;
2532 2532
2533 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2533 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2534 2534
2535 if (mViewManager->currentView()->isEventView()) { 2535 if (mViewManager->currentView()->isEventView()) {
2536 if ( incidence && incidence->type() == "Event" ) { 2536 if ( incidence && incidence->type() == "Event" ) {
2537 anEvent = static_cast<Event *>(incidence); 2537 anEvent = static_cast<Event *>(incidence);
2538 } 2538 }
2539 } 2539 }
2540 2540
2541 if (!anEvent) { 2541 if (!anEvent) {
2542 KNotifyClient::beep(); 2542 KNotifyClient::beep();
2543 return; 2543 return;
2544 } 2544 }
2545 2545
2546 deleteEvent(anEvent); 2546 deleteEvent(anEvent);
2547} 2547}
2548 2548
2549void CalendarView::todo_unsub(Todo *anTodo ) 2549void CalendarView::todo_unsub(Todo *anTodo )
2550{ 2550{
2551 // Todo *anTodo = selectedTodo(); 2551 // Todo *anTodo = selectedTodo();
2552 if (!anTodo) return; 2552 if (!anTodo) return;
2553 if (!anTodo->relatedTo()) return; 2553 if (!anTodo->relatedTo()) return;
2554 anTodo->relatedTo()->removeRelation(anTodo); 2554 anTodo->relatedTo()->removeRelation(anTodo);
2555 anTodo->setRelatedTo(0); 2555 anTodo->setRelatedTo(0);
2556 anTodo->updated(); 2556 anTodo->updated();
2557 anTodo->setRelatedToUid(""); 2557 anTodo->setRelatedToUid("");
2558 setModified(true); 2558 setModified(true);
2559 updateView(); 2559 updateView();
2560} 2560}
2561 2561
2562void CalendarView::deleteTodo(Todo *todo) 2562void CalendarView::deleteTodo(Todo *todo)
2563{ 2563{
2564 if (!todo) { 2564 if (!todo) {
2565 KNotifyClient::beep(); 2565 KNotifyClient::beep();
2566 return; 2566 return;
2567 } 2567 }
2568 if (KOPrefs::instance()->mConfirm) { 2568 if (KOPrefs::instance()->mConfirm) {
2569 switch (msgItemDelete()) { 2569 switch (msgItemDelete()) {
2570 case KMessageBox::Continue: // OK 2570 case KMessageBox::Continue: // OK
2571 if (!todo->relations().isEmpty()) { 2571 if (!todo->relations().isEmpty()) {
2572 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2572 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2573 i18n("Delete To-Do")); 2573 i18n("Delete To-Do"));
2574 } else { 2574 } else {
2575 checkZaurusId( todo->zaurusId(), true ); 2575 checkZaurusId( todo->zaurusId(), true );
2576 calendar()->deleteTodo(todo); 2576 calendar()->deleteTodo(todo);
2577 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2577 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2578 updateView(); 2578 updateView();
2579 } 2579 }
2580 break; 2580 break;
2581 } // switch 2581 } // switch
2582 } else { 2582 } else {
2583 if (!todo->relations().isEmpty()) { 2583 if (!todo->relations().isEmpty()) {
2584 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2584 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2585 i18n("Delete To-Do")); 2585 i18n("Delete To-Do"));
2586 } else { 2586 } else {
2587 checkZaurusId( todo->zaurusId(), true ); 2587 checkZaurusId( todo->zaurusId(), true );
2588 mCalendar->deleteTodo(todo); 2588 mCalendar->deleteTodo(todo);
2589 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2589 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2590 updateView(); 2590 updateView();
2591 } 2591 }
2592 } 2592 }
2593 emit updateSearchDialog(); 2593 emit updateSearchDialog();
2594} 2594}
2595void CalendarView::deleteJournal(Journal *jour) 2595void CalendarView::deleteJournal(Journal *jour)
2596{ 2596{
2597 if (!jour) { 2597 if (!jour) {
2598 KNotifyClient::beep(); 2598 KNotifyClient::beep();
2599 return; 2599 return;
2600 } 2600 }
2601 if (KOPrefs::instance()->mConfirm) { 2601 if (KOPrefs::instance()->mConfirm) {
2602 switch (msgItemDelete()) { 2602 switch (msgItemDelete()) {
2603 case KMessageBox::Continue: // OK 2603 case KMessageBox::Continue: // OK
2604 calendar()->deleteJournal(jour); 2604 calendar()->deleteJournal(jour);
2605 updateView(); 2605 updateView();
2606 break; 2606 break;
2607 } // switch 2607 } // switch
2608 } else { 2608 } else {
2609 calendar()->deleteJournal(jour);; 2609 calendar()->deleteJournal(jour);;
2610 updateView(); 2610 updateView();
2611 } 2611 }
2612 emit updateSearchDialog(); 2612 emit updateSearchDialog();
2613} 2613}
2614 2614
2615void CalendarView::deleteEvent(Event *anEvent) 2615void CalendarView::deleteEvent(Event *anEvent)
2616{ 2616{
2617 if (!anEvent) { 2617 if (!anEvent) {
2618 KNotifyClient::beep(); 2618 KNotifyClient::beep();
2619 return; 2619 return;
2620 } 2620 }
2621 2621
2622 if (anEvent->recurrence()->doesRecur()) { 2622 if (anEvent->recurrence()->doesRecur()) {
2623 QDate itemDate = mViewManager->currentSelectionDate(); 2623 QDate itemDate = mViewManager->currentSelectionDate();
2624 int km; 2624 int km;
2625 if (!itemDate.isValid()) { 2625 if (!itemDate.isValid()) {
2626 //kdDebug() << "Date Not Valid" << endl; 2626 //kdDebug() << "Date Not Valid" << endl;
2627 if (KOPrefs::instance()->mConfirm) { 2627 if (KOPrefs::instance()->mConfirm) {
2628 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2628 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2629 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2629 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2630 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2630 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2631 if ( km == KMessageBox::Continue ) 2631 if ( km == KMessageBox::Continue )
2632 km = KMessageBox::No; // No = all below 2632 km = KMessageBox::No; // No = all below
2633 } else 2633 } else
2634 km = KMessageBox::No; 2634 km = KMessageBox::No;
2635 } else { 2635 } else {
2636 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2636 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2637 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2637 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2638 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2638 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2639 i18n("KO/Pi Confirmation"),i18n("Current"), 2639 i18n("KO/Pi Confirmation"),i18n("Current"),
2640 i18n("All")); 2640 i18n("All"));
2641 } 2641 }
2642 switch(km) { 2642 switch(km) {
2643 2643
2644 case KMessageBox::No: // Continue // all 2644 case KMessageBox::No: // Continue // all
2645 //qDebug("KMessageBox::No "); 2645 //qDebug("KMessageBox::No ");
2646 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2646 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2647 schedule(Scheduler::Cancel,anEvent); 2647 schedule(Scheduler::Cancel,anEvent);
2648 2648
2649 checkZaurusId( anEvent->zaurusId()); 2649 checkZaurusId( anEvent->zaurusId());
2650 mCalendar->deleteEvent(anEvent); 2650 mCalendar->deleteEvent(anEvent);
2651 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2651 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2652 break; 2652 break;
2653 2653
2654 // Disabled because it does not work 2654 // Disabled because it does not work
2655 //#if 0 2655 //#if 0
2656 case KMessageBox::Yes: // just this one 2656 case KMessageBox::Yes: // just this one
2657 //QDate qd = mNavigator->selectedDates().first(); 2657 //QDate qd = mNavigator->selectedDates().first();
2658 //if (!qd.isValid()) { 2658 //if (!qd.isValid()) {
2659 // kdDebug() << "no date selected, or invalid date" << endl; 2659 // kdDebug() << "no date selected, or invalid date" << endl;
2660 // KNotifyClient::beep(); 2660 // KNotifyClient::beep();
2661 // return; 2661 // return;
2662 //} 2662 //}
2663 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2663 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2664 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2664 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2665 anEvent->addExDate(itemDate); 2665 anEvent->addExDate(itemDate);
2666 int duration = anEvent->recurrence()->duration(); 2666 int duration = anEvent->recurrence()->duration();
2667 if ( duration > 0 ) { 2667 if ( duration > 0 ) {
2668 anEvent->recurrence()->setDuration( duration - 1 ); 2668 anEvent->recurrence()->setDuration( duration - 1 );
2669 } 2669 }
2670 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2670 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2671 } 2671 }
2672 break; 2672 break;
2673 //#endif 2673 //#endif
2674 } // switch 2674 } // switch
2675 } else { 2675 } else {
2676 if (KOPrefs::instance()->mConfirm) { 2676 if (KOPrefs::instance()->mConfirm) {
2677 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2677 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2678 i18n("\nAre you sure you want\nto delete this event?"), 2678 i18n("\nAre you sure you want\nto delete this event?"),
2679 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2679 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2680 case KMessageBox::Continue: // OK 2680 case KMessageBox::Continue: // OK
2681 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2681 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2682 schedule(Scheduler::Cancel,anEvent); 2682 schedule(Scheduler::Cancel,anEvent);
2683 checkZaurusId( anEvent->zaurusId()); 2683 checkZaurusId( anEvent->zaurusId());
2684 mCalendar->deleteEvent(anEvent); 2684 mCalendar->deleteEvent(anEvent);
2685 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2685 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2686 break; 2686 break;
2687 } // switch 2687 } // switch
2688 } else { 2688 } else {
2689 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2689 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2690 schedule(Scheduler::Cancel,anEvent); 2690 schedule(Scheduler::Cancel,anEvent);
2691 checkZaurusId( anEvent->zaurusId()); 2691 checkZaurusId( anEvent->zaurusId());
2692 mCalendar->deleteEvent(anEvent); 2692 mCalendar->deleteEvent(anEvent);
2693 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2693 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2694 } 2694 }
2695 } // if-else 2695 } // if-else
2696 emit updateSearchDialog(); 2696 emit updateSearchDialog();
2697} 2697}
2698 2698
2699bool CalendarView::deleteEvent(const QString &uid) 2699bool CalendarView::deleteEvent(const QString &uid)
2700{ 2700{
2701 Event *ev = mCalendar->event(uid); 2701 Event *ev = mCalendar->event(uid);
2702 if (ev) { 2702 if (ev) {
2703 deleteEvent(ev); 2703 deleteEvent(ev);
2704 return true; 2704 return true;
2705 } else { 2705 } else {
2706 return false; 2706 return false;
2707 } 2707 }
2708} 2708}
2709 2709
2710/*****************************************************************************/ 2710/*****************************************************************************/
2711 2711
2712void CalendarView::action_mail() 2712void CalendarView::action_mail()
2713{ 2713{
2714#ifndef KORG_NOMAIL 2714#ifndef KORG_NOMAIL
2715 KOMailClient mailClient; 2715 KOMailClient mailClient;
2716 2716
2717 Incidence *incidence = currentSelection(); 2717 Incidence *incidence = currentSelection();
2718 2718
2719 if (!incidence) { 2719 if (!incidence) {
2720 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2720 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2721 return; 2721 return;
2722 } 2722 }
2723 if(incidence->attendeeCount() == 0 ) { 2723 if(incidence->attendeeCount() == 0 ) {
2724 KMessageBox::sorry(this, 2724 KMessageBox::sorry(this,
2725 i18n("Can't generate mail:\nNo attendees defined.\n")); 2725 i18n("Can't generate mail:\nNo attendees defined.\n"));
2726 return; 2726 return;
2727 } 2727 }
2728 2728
2729 CalendarLocal cal_tmp; 2729 CalendarLocal cal_tmp;
2730 Event *event = 0; 2730 Event *event = 0;
2731 Event *ev = 0; 2731 Event *ev = 0;
2732 if ( incidence && incidence->type() == "Event" ) { 2732 if ( incidence && incidence->type() == "Event" ) {
2733 event = static_cast<Event *>(incidence); 2733 event = static_cast<Event *>(incidence);
2734 ev = new Event(*event); 2734 ev = new Event(*event);
2735 cal_tmp.addEvent(ev); 2735 cal_tmp.addEvent(ev);
2736 } 2736 }
2737 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2737 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2738 QString attachment = mForm.toString( &cal_tmp ); 2738 QString attachment = mForm.toString( &cal_tmp );
2739 if (ev) delete(ev); 2739 if (ev) delete(ev);
2740 2740
2741 mailClient.mailAttendees(currentSelection(), attachment); 2741 mailClient.mailAttendees(currentSelection(), attachment);
2742 2742
2743#endif 2743#endif
2744 2744
2745#if 0 2745#if 0
2746 Event *anEvent = 0; 2746 Event *anEvent = 0;
2747 if (mViewManager->currentView()->isEventView()) { 2747 if (mViewManager->currentView()->isEventView()) {
2748 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2748 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2749 } 2749 }
2750 2750
2751 if (!anEvent) { 2751 if (!anEvent) {
2752 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2752 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2753 return; 2753 return;
2754 } 2754 }
2755 if(anEvent->attendeeCount() == 0 ) { 2755 if(anEvent->attendeeCount() == 0 ) {
2756 KMessageBox::sorry(this, 2756 KMessageBox::sorry(this,
2757 i18n("Can't generate mail:\nNo attendees defined.\n")); 2757 i18n("Can't generate mail:\nNo attendees defined.\n"));
2758 return; 2758 return;
2759 } 2759 }
2760 2760
2761 mailobject.emailEvent(anEvent); 2761 mailobject.emailEvent(anEvent);
2762#endif 2762#endif
2763} 2763}
2764 2764
2765 2765
2766void CalendarView::schedule_publish(Incidence *incidence) 2766void CalendarView::schedule_publish(Incidence *incidence)
2767{ 2767{
2768 Event *event = 0; 2768 Event *event = 0;
2769 Todo *todo = 0; 2769 Todo *todo = 0;
2770 2770
2771 if (incidence == 0) { 2771 if (incidence == 0) {
2772 incidence = mViewManager->currentView()->selectedIncidences().first(); 2772 incidence = mViewManager->currentView()->selectedIncidences().first();
2773 if (incidence == 0) { 2773 if (incidence == 0) {
2774 incidence = mTodoList->selectedIncidences().first(); 2774 incidence = mTodoList->selectedIncidences().first();
2775 } 2775 }
2776 } 2776 }
2777 if ( incidence && incidence->type() == "Event" ) { 2777 if ( incidence && incidence->type() == "Event" ) {
2778 event = static_cast<Event *>(incidence); 2778 event = static_cast<Event *>(incidence);
2779 } else { 2779 } else {
2780 if ( incidence && incidence->type() == "Todo" ) { 2780 if ( incidence && incidence->type() == "Todo" ) {
2781 todo = static_cast<Todo *>(incidence); 2781 todo = static_cast<Todo *>(incidence);
2782 } 2782 }
2783 } 2783 }
2784 2784
2785 if (!event && !todo) { 2785 if (!event && !todo) {
2786 KMessageBox::sorry(this,i18n("No event selected.")); 2786 KMessageBox::sorry(this,i18n("No event selected."));
2787 return; 2787 return;
2788 } 2788 }
2789 2789
2790 PublishDialog *publishdlg = new PublishDialog(); 2790 PublishDialog *publishdlg = new PublishDialog();
2791 if (incidence->attendeeCount()>0) { 2791 if (incidence->attendeeCount()>0) {
2792 QPtrList<Attendee> attendees = incidence->attendees(); 2792 QPtrList<Attendee> attendees = incidence->attendees();
2793 attendees.first(); 2793 attendees.first();
2794 while ( attendees.current()!=0 ) { 2794 while ( attendees.current()!=0 ) {
2795 publishdlg->addAttendee(attendees.current()); 2795 publishdlg->addAttendee(attendees.current());
2796 attendees.next(); 2796 attendees.next();
2797 } 2797 }
2798 } 2798 }
2799 bool send = true; 2799 bool send = true;
2800 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2800 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2801 if ( publishdlg->exec() != QDialog::Accepted ) 2801 if ( publishdlg->exec() != QDialog::Accepted )
2802 send = false; 2802 send = false;
2803 } 2803 }
2804 if ( send ) { 2804 if ( send ) {
2805 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2805 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2806 if ( event ) { 2806 if ( event ) {
2807 Event *ev = new Event(*event); 2807 Event *ev = new Event(*event);
2808 ev->registerObserver(0); 2808 ev->registerObserver(0);
2809 ev->clearAttendees(); 2809 ev->clearAttendees();
2810 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2810 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2811 delete(ev); 2811 delete(ev);
2812 } 2812 }
2813 } else { 2813 } else {
2814 if ( todo ) { 2814 if ( todo ) {
2815 Todo *ev = new Todo(*todo); 2815 Todo *ev = new Todo(*todo);
2816 ev->registerObserver(0); 2816 ev->registerObserver(0);
2817 ev->clearAttendees(); 2817 ev->clearAttendees();
2818 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2818 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2819 delete(ev); 2819 delete(ev);
2820 } 2820 }
2821 } 2821 }
2822 } 2822 }
2823 } 2823 }
2824 delete publishdlg; 2824 delete publishdlg;
2825} 2825}
2826 2826
2827void CalendarView::schedule_request(Incidence *incidence) 2827void CalendarView::schedule_request(Incidence *incidence)
2828{ 2828{
2829 schedule(Scheduler::Request,incidence); 2829 schedule(Scheduler::Request,incidence);
2830} 2830}
2831 2831
2832void CalendarView::schedule_refresh(Incidence *incidence) 2832void CalendarView::schedule_refresh(Incidence *incidence)
2833{ 2833{
2834 schedule(Scheduler::Refresh,incidence); 2834 schedule(Scheduler::Refresh,incidence);
2835} 2835}
2836 2836
2837void CalendarView::schedule_cancel(Incidence *incidence) 2837void CalendarView::schedule_cancel(Incidence *incidence)
2838{ 2838{
2839 schedule(Scheduler::Cancel,incidence); 2839 schedule(Scheduler::Cancel,incidence);
2840} 2840}
2841 2841
2842void CalendarView::schedule_add(Incidence *incidence) 2842void CalendarView::schedule_add(Incidence *incidence)
2843{ 2843{
2844 schedule(Scheduler::Add,incidence); 2844 schedule(Scheduler::Add,incidence);
2845} 2845}
2846 2846
2847void CalendarView::schedule_reply(Incidence *incidence) 2847void CalendarView::schedule_reply(Incidence *incidence)
2848{ 2848{
2849 schedule(Scheduler::Reply,incidence); 2849 schedule(Scheduler::Reply,incidence);
2850} 2850}
2851 2851
2852void CalendarView::schedule_counter(Incidence *incidence) 2852void CalendarView::schedule_counter(Incidence *incidence)
2853{ 2853{
2854 schedule(Scheduler::Counter,incidence); 2854 schedule(Scheduler::Counter,incidence);
2855} 2855}
2856 2856
2857void CalendarView::schedule_declinecounter(Incidence *incidence) 2857void CalendarView::schedule_declinecounter(Incidence *incidence)
2858{ 2858{
2859 schedule(Scheduler::Declinecounter,incidence); 2859 schedule(Scheduler::Declinecounter,incidence);
2860} 2860}
2861 2861
2862void CalendarView::schedule_publish_freebusy(int daysToPublish) 2862void CalendarView::schedule_publish_freebusy(int daysToPublish)
2863{ 2863{
2864 QDateTime start = QDateTime::currentDateTime(); 2864 QDateTime start = QDateTime::currentDateTime();
2865 QDateTime end = start.addDays(daysToPublish); 2865 QDateTime end = start.addDays(daysToPublish);
2866 2866
2867 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2867 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2868 freebusy->setOrganizer(KOPrefs::instance()->email()); 2868 freebusy->setOrganizer(KOPrefs::instance()->email());
2869 2869
2870 2870
2871 PublishDialog *publishdlg = new PublishDialog(); 2871 PublishDialog *publishdlg = new PublishDialog();
2872 if ( publishdlg->exec() == QDialog::Accepted ) { 2872 if ( publishdlg->exec() == QDialog::Accepted ) {
2873 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2873 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2874 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2874 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2875 delete(freebusy); 2875 delete(freebusy);
2876 } 2876 }
2877 } 2877 }
2878 delete publishdlg; 2878 delete publishdlg;
2879} 2879}
2880 2880
2881void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2881void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2882{ 2882{
2883 Event *event = 0; 2883 Event *event = 0;
2884 Todo *todo = 0; 2884 Todo *todo = 0;
2885 2885
2886 if (incidence == 0) { 2886 if (incidence == 0) {
2887 incidence = mViewManager->currentView()->selectedIncidences().first(); 2887 incidence = mViewManager->currentView()->selectedIncidences().first();
2888 if (incidence == 0) { 2888 if (incidence == 0) {
2889 incidence = mTodoList->selectedIncidences().first(); 2889 incidence = mTodoList->selectedIncidences().first();
2890 } 2890 }
2891 } 2891 }
2892 if ( incidence && incidence->type() == "Event" ) { 2892 if ( incidence && incidence->type() == "Event" ) {
2893 event = static_cast<Event *>(incidence); 2893 event = static_cast<Event *>(incidence);
2894 } 2894 }
2895 if ( incidence && incidence->type() == "Todo" ) { 2895 if ( incidence && incidence->type() == "Todo" ) {
2896 todo = static_cast<Todo *>(incidence); 2896 todo = static_cast<Todo *>(incidence);
2897 } 2897 }
2898 2898
2899 if (!event && !todo) { 2899 if (!event && !todo) {
2900 KMessageBox::sorry(this,i18n("No event selected.")); 2900 KMessageBox::sorry(this,i18n("No event selected."));
2901 return; 2901 return;
2902 } 2902 }
2903 2903
2904 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 2904 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2905 KMessageBox::sorry(this,i18n("The event has no attendees.")); 2905 KMessageBox::sorry(this,i18n("The event has no attendees."));
2906 return; 2906 return;
2907 } 2907 }
2908 2908
2909 Event *ev = 0; 2909 Event *ev = 0;
2910 if (event) ev = new Event(*event); 2910 if (event) ev = new Event(*event);
2911 Todo *to = 0; 2911 Todo *to = 0;
2912 if (todo) to = new Todo(*todo); 2912 if (todo) to = new Todo(*todo);
2913 2913
2914 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 2914 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2915 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 2915 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2916 if (!me) { 2916 if (!me) {
2917 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 2917 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2918 return; 2918 return;
2919 } 2919 }
2920 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 2920 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2921 StatusDialog *statdlg = new StatusDialog(this); 2921 StatusDialog *statdlg = new StatusDialog(this);
2922 if (!statdlg->exec()==QDialog::Accepted) return; 2922 if (!statdlg->exec()==QDialog::Accepted) return;
2923 me->setStatus( statdlg->status() ); 2923 me->setStatus( statdlg->status() );
2924 delete(statdlg); 2924 delete(statdlg);
2925 } 2925 }
2926 Attendee *menew = new Attendee(*me); 2926 Attendee *menew = new Attendee(*me);
2927 if (ev) { 2927 if (ev) {
2928 ev->clearAttendees(); 2928 ev->clearAttendees();
2929 ev->addAttendee(menew,false); 2929 ev->addAttendee(menew,false);
2930 } else { 2930 } else {
2931 if (to) { 2931 if (to) {
2932 todo->clearAttendees(); 2932 todo->clearAttendees();
2933 todo->addAttendee(menew,false); 2933 todo->addAttendee(menew,false);
2934 } 2934 }
2935 } 2935 }
2936 } 2936 }
2937 2937
2938 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2938 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2939 if (ev) { 2939 if (ev) {
2940 if ( !dlg->addMessage(ev,method) ) delete(ev); 2940 if ( !dlg->addMessage(ev,method) ) delete(ev);
2941 } else { 2941 } else {
2942 if (to) { 2942 if (to) {
2943 if ( !dlg->addMessage(to,method) ) delete(to); 2943 if ( !dlg->addMessage(to,method) ) delete(to);
2944 } 2944 }
2945 } 2945 }
2946} 2946}
2947 2947
2948void CalendarView::openAddressbook() 2948void CalendarView::openAddressbook()
2949{ 2949{
2950 KRun::runCommand("kaddressbook"); 2950 KRun::runCommand("kaddressbook");
2951} 2951}
2952 2952
2953void CalendarView::setModified(bool modified) 2953void CalendarView::setModified(bool modified)
2954{ 2954{
2955 if ( modified ) 2955 if ( modified )
2956 emit signalmodified(); 2956 emit signalmodified();
2957 if (mModified != modified) { 2957 if (mModified != modified) {
2958 mModified = modified; 2958 mModified = modified;
2959 emit modifiedChanged(mModified); 2959 emit modifiedChanged(mModified);
2960 } 2960 }
2961} 2961}
2962 2962
2963bool CalendarView::isReadOnly() 2963bool CalendarView::isReadOnly()
2964{ 2964{
2965 return mReadOnly; 2965 return mReadOnly;
2966} 2966}
2967 2967
2968void CalendarView::setReadOnly(bool readOnly) 2968void CalendarView::setReadOnly(bool readOnly)
2969{ 2969{
2970 if (mReadOnly != readOnly) { 2970 if (mReadOnly != readOnly) {
2971 mReadOnly = readOnly; 2971 mReadOnly = readOnly;
2972 emit readOnlyChanged(mReadOnly); 2972 emit readOnlyChanged(mReadOnly);
2973 } 2973 }
2974} 2974}
2975 2975
2976bool CalendarView::isModified() 2976bool CalendarView::isModified()
2977{ 2977{
2978 return mModified; 2978 return mModified;
2979} 2979}
2980 2980
2981void CalendarView::printSetup() 2981void CalendarView::printSetup()
2982{ 2982{
2983#ifndef KORG_NOPRINTER 2983#ifndef KORG_NOPRINTER
2984 createPrinter(); 2984 createPrinter();
2985 2985
2986 mCalPrinter->setupPrinter(); 2986 mCalPrinter->setupPrinter();
2987#endif 2987#endif
2988} 2988}
2989 2989
2990void CalendarView::print() 2990void CalendarView::print()
2991{ 2991{
2992#ifndef KORG_NOPRINTER 2992#ifndef KORG_NOPRINTER
2993 createPrinter(); 2993 createPrinter();
2994 2994
2995 DateList tmpDateList = mNavigator->selectedDates(); 2995 DateList tmpDateList = mNavigator->selectedDates();
2996 mCalPrinter->print(CalPrinter::Month, 2996 mCalPrinter->print(CalPrinter::Month,
2997 tmpDateList.first(), tmpDateList.last()); 2997 tmpDateList.first(), tmpDateList.last());
2998#endif 2998#endif
2999} 2999}
3000 3000
3001void CalendarView::printPreview() 3001void CalendarView::printPreview()
3002{ 3002{
3003#ifndef KORG_NOPRINTER 3003#ifndef KORG_NOPRINTER
3004 kdDebug() << "CalendarView::printPreview()" << endl; 3004 kdDebug() << "CalendarView::printPreview()" << endl;
3005 3005
3006 createPrinter(); 3006 createPrinter();
3007 3007
3008 DateList tmpDateList = mNavigator->selectedDates(); 3008 DateList tmpDateList = mNavigator->selectedDates();
3009 3009
3010 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3010 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3011 tmpDateList.last()); 3011 tmpDateList.last());
3012#endif 3012#endif
3013} 3013}
3014 3014
3015void CalendarView::exportICalendar() 3015void CalendarView::exportICalendar()
3016{ 3016{
3017 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3017 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3018 3018
3019 // Force correct extension 3019 // Force correct extension
3020 if (filename.right(4) != ".ics") filename += ".ics"; 3020 if (filename.right(4) != ".ics") filename += ".ics";
3021 3021
3022 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3022 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3023 storage.save(); 3023 storage.save();
3024} 3024}
3025 3025
3026bool CalendarView::exportVCalendar( QString filename ) 3026bool CalendarView::exportVCalendar( QString filename )
3027{ 3027{
3028 if (mCalendar->journals().count() > 0) { 3028 if (mCalendar->journals().count() > 0) {
3029 int result = KMessageBox::warningContinueCancel(this, 3029 int result = KMessageBox::warningContinueCancel(this,
3030 i18n("The journal entries can not be\nexported to a vCalendar file."), 3030 i18n("The journal entries can not be\nexported to a vCalendar file."),
3031 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3031 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3032 true); 3032 true);
3033 if (result != KMessageBox::Continue) return false; 3033 if (result != KMessageBox::Continue) return false;
3034 } 3034 }
3035 3035
3036 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3036 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3037 3037
3038 // Force correct extension 3038 // Force correct extension
3039 if (filename.right(4) != ".vcs") filename += ".vcs"; 3039 if (filename.right(4) != ".vcs") filename += ".vcs";
3040 3040
3041 FileStorage storage( mCalendar, filename, new VCalFormat ); 3041 FileStorage storage( mCalendar, filename, new VCalFormat );
3042 return storage.save(); 3042 return storage.save();
3043 3043
3044} 3044}
3045 3045
3046void CalendarView::eventUpdated(Incidence *) 3046void CalendarView::eventUpdated(Incidence *)
3047{ 3047{
3048 setModified(); 3048 setModified();
3049 // Don't call updateView here. The code, which has caused the update of the 3049 // Don't call updateView here. The code, which has caused the update of the
3050 // event is responsible for updating the view. 3050 // event is responsible for updating the view.
3051 // updateView(); 3051 // updateView();
3052} 3052}
3053 3053
3054void CalendarView::adaptNavigationUnits() 3054void CalendarView::adaptNavigationUnits()
3055{ 3055{
3056 if (mViewManager->currentView()->isEventView()) { 3056 if (mViewManager->currentView()->isEventView()) {
3057 int days = mViewManager->currentView()->currentDateCount(); 3057 int days = mViewManager->currentView()->currentDateCount();
3058 if (days == 1) { 3058 if (days == 1) {
3059 emit changeNavStringPrev(i18n("&Previous Day")); 3059 emit changeNavStringPrev(i18n("&Previous Day"));
3060 emit changeNavStringNext(i18n("&Next Day")); 3060 emit changeNavStringNext(i18n("&Next Day"));
3061 } else { 3061 } else {
3062 emit changeNavStringPrev(i18n("&Previous Week")); 3062 emit changeNavStringPrev(i18n("&Previous Week"));
3063 emit changeNavStringNext(i18n("&Next Week")); 3063 emit changeNavStringNext(i18n("&Next Week"));
3064 } 3064 }
3065 } 3065 }
3066} 3066}
3067 3067
3068void CalendarView::processMainViewSelection( Incidence *incidence ) 3068void CalendarView::processMainViewSelection( Incidence *incidence )
3069{ 3069{
3070 if ( incidence ) mTodoList->clearSelection(); 3070 if ( incidence ) mTodoList->clearSelection();
3071 processIncidenceSelection( incidence ); 3071 processIncidenceSelection( incidence );
3072} 3072}
3073 3073
3074void CalendarView::processTodoListSelection( Incidence *incidence ) 3074void CalendarView::processTodoListSelection( Incidence *incidence )
3075{ 3075{
3076 if ( incidence && mViewManager->currentView() ) { 3076 if ( incidence && mViewManager->currentView() ) {
3077 mViewManager->currentView()->clearSelection(); 3077 mViewManager->currentView()->clearSelection();
3078 } 3078 }
3079 processIncidenceSelection( incidence ); 3079 processIncidenceSelection( incidence );
3080} 3080}
3081 3081
3082void CalendarView::processIncidenceSelection( Incidence *incidence ) 3082void CalendarView::processIncidenceSelection( Incidence *incidence )
3083{ 3083{
3084 if ( incidence == mSelectedIncidence ) return; 3084 if ( incidence == mSelectedIncidence ) return;
3085 3085
3086 mSelectedIncidence = incidence; 3086 mSelectedIncidence = incidence;
3087 3087
3088 emit incidenceSelected( mSelectedIncidence ); 3088 emit incidenceSelected( mSelectedIncidence );
3089 3089
3090 if ( incidence && incidence->type() == "Event" ) { 3090 if ( incidence && incidence->type() == "Event" ) {
3091 Event *event = static_cast<Event *>( incidence ); 3091 Event *event = static_cast<Event *>( incidence );
3092 if ( event->organizer() == KOPrefs::instance()->email() ) { 3092 if ( event->organizer() == KOPrefs::instance()->email() ) {
3093 emit organizerEventsSelected( true ); 3093 emit organizerEventsSelected( true );
3094 } else { 3094 } else {
3095 emit organizerEventsSelected(false); 3095 emit organizerEventsSelected(false);
3096 } 3096 }
3097 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3097 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3098 KOPrefs::instance()->email() ) ) { 3098 KOPrefs::instance()->email() ) ) {
3099 emit groupEventsSelected( true ); 3099 emit groupEventsSelected( true );
3100 } else { 3100 } else {
3101 emit groupEventsSelected(false); 3101 emit groupEventsSelected(false);
3102 } 3102 }
3103 return; 3103 return;
3104 } else { 3104 } else {
3105 if ( incidence && incidence->type() == "Todo" ) { 3105 if ( incidence && incidence->type() == "Todo" ) {
3106 emit todoSelected( true ); 3106 emit todoSelected( true );
3107 Todo *event = static_cast<Todo *>( incidence ); 3107 Todo *event = static_cast<Todo *>( incidence );
3108 if ( event->organizer() == KOPrefs::instance()->email() ) { 3108 if ( event->organizer() == KOPrefs::instance()->email() ) {
3109 emit organizerEventsSelected( true ); 3109 emit organizerEventsSelected( true );
3110 } else { 3110 } else {
3111 emit organizerEventsSelected(false); 3111 emit organizerEventsSelected(false);
3112 } 3112 }
3113 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3113 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3114 KOPrefs::instance()->email() ) ) { 3114 KOPrefs::instance()->email() ) ) {
3115 emit groupEventsSelected( true ); 3115 emit groupEventsSelected( true );
3116 } else { 3116 } else {
3117 emit groupEventsSelected(false); 3117 emit groupEventsSelected(false);
3118 } 3118 }
3119 return; 3119 return;
3120 } else { 3120 } else {
3121 emit todoSelected( false ); 3121 emit todoSelected( false );
3122 emit organizerEventsSelected(false); 3122 emit organizerEventsSelected(false);
3123 emit groupEventsSelected(false); 3123 emit groupEventsSelected(false);
3124 } 3124 }
3125 return; 3125 return;
3126 } 3126 }
3127 3127
3128 /* if ( incidence && incidence->type() == "Todo" ) { 3128 /* if ( incidence && incidence->type() == "Todo" ) {
3129 emit todoSelected( true ); 3129 emit todoSelected( true );
3130 } else { 3130 } else {
3131 emit todoSelected( false ); 3131 emit todoSelected( false );
3132 }*/ 3132 }*/
3133} 3133}
3134 3134
3135 3135
3136void CalendarView::checkClipboard() 3136void CalendarView::checkClipboard()
3137{ 3137{
3138#ifndef KORG_NODND 3138#ifndef KORG_NODND
3139 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3139 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3140 emit pasteEnabled(true); 3140 emit pasteEnabled(true);
3141 } else { 3141 } else {
3142 emit pasteEnabled(false); 3142 emit pasteEnabled(false);
3143 } 3143 }
3144#endif 3144#endif
3145} 3145}
3146 3146
3147void CalendarView::showDates(const DateList &selectedDates) 3147void CalendarView::showDates(const DateList &selectedDates)
3148{ 3148{
3149 // kdDebug() << "CalendarView::selectDates()" << endl; 3149 // kdDebug() << "CalendarView::selectDates()" << endl;
3150 3150
3151 if ( mViewManager->currentView() ) { 3151 if ( mViewManager->currentView() ) {
3152 updateView( selectedDates.first(), selectedDates.last() ); 3152 updateView( selectedDates.first(), selectedDates.last() );
3153 } else { 3153 } else {
3154 mViewManager->showAgendaView(); 3154 mViewManager->showAgendaView();
3155 } 3155 }
3156 3156
3157 QString selDates; 3157 QString selDates;
3158 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3158 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3159 if (selectedDates.first() < selectedDates.last() ) 3159 if (selectedDates.first() < selectedDates.last() )
3160 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3160 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3161 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3161 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3162 3162
3163} 3163}
3164 3164
3165void CalendarView::editFilters() 3165void CalendarView::editFilters()
3166{ 3166{
3167 // kdDebug() << "CalendarView::editFilters()" << endl; 3167 // kdDebug() << "CalendarView::editFilters()" << endl;
3168 3168
3169 CalFilter *filter = mFilters.first(); 3169 CalFilter *filter = mFilters.first();
3170 while(filter) { 3170 while(filter) {
3171 kdDebug() << " Filter: " << filter->name() << endl; 3171 kdDebug() << " Filter: " << filter->name() << endl;
3172 filter = mFilters.next(); 3172 filter = mFilters.next();
3173 } 3173 }
3174 3174
3175 mDialogManager->showFilterEditDialog(&mFilters); 3175 mDialogManager->showFilterEditDialog(&mFilters);
3176} 3176}
3177void CalendarView::toggleFilter() 3177void CalendarView::toggleFilter()
3178{ 3178{
3179 showFilter(! mFilterView->isVisible()); 3179 showFilter(! mFilterView->isVisible());
3180} 3180}
3181 3181
3182void CalendarView::selectFilter( int fil ) 3182void CalendarView::selectFilter( int fil )
3183{ 3183{
3184 mFilterView->setSelectedFilter( fil ); 3184 mFilterView->setSelectedFilter( fil );
3185} 3185}
3186void CalendarView::showFilter(bool visible) 3186void CalendarView::showFilter(bool visible)
3187{ 3187{
3188 if (visible) mFilterView->show(); 3188 if (visible) mFilterView->show();
3189 else mFilterView->hide(); 3189 else mFilterView->hide();
3190} 3190}
3191void CalendarView::toggleFilerEnabled( ) 3191void CalendarView::toggleFilerEnabled( )
3192{ 3192{
3193 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3193 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3194 if ( !mFilterView->filtersEnabled() ) 3194 if ( !mFilterView->filtersEnabled() )
3195 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3195 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3196 3196
3197} 3197}
3198void CalendarView::updateFilter() 3198void CalendarView::updateFilter()
3199{ 3199{
3200 CalFilter *filter = mFilterView->selectedFilter(); 3200 CalFilter *filter = mFilterView->selectedFilter();
3201 if (filter) { 3201 if (filter) {
3202 if (mFilterView->filtersEnabled()) { 3202 if (mFilterView->filtersEnabled()) {
3203 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3203 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3204 filter->setEnabled(true); 3204 filter->setEnabled(true);
3205 } 3205 }
3206 else filter->setEnabled(false); 3206 else filter->setEnabled(false);
3207 mCalendar->setFilter(filter); 3207 mCalendar->setFilter(filter);
3208 updateView(); 3208 updateView();
3209 } 3209 }
3210} 3210}
3211 3211
3212void CalendarView::filterEdited() 3212void CalendarView::filterEdited()
3213{ 3213{
3214 mFilterView->updateFilters(); 3214 mFilterView->updateFilters();
3215 updateFilter(); 3215 updateFilter();
3216 writeSettings(); 3216 writeSettings();
3217} 3217}
3218 3218
3219 3219
3220void CalendarView::takeOverEvent() 3220void CalendarView::takeOverEvent()
3221{ 3221{
3222 Incidence *incidence = currentSelection(); 3222 Incidence *incidence = currentSelection();
3223 3223
3224 if (!incidence) return; 3224 if (!incidence) return;
3225 3225
3226 incidence->setOrganizer(KOPrefs::instance()->email()); 3226 incidence->setOrganizer(KOPrefs::instance()->email());
3227 incidence->recreate(); 3227 incidence->recreate();
3228 incidence->setReadOnly(false); 3228 incidence->setReadOnly(false);
3229 3229
3230 updateView(); 3230 updateView();
3231} 3231}
3232 3232
3233void CalendarView::takeOverCalendar() 3233void CalendarView::takeOverCalendar()
3234{ 3234{
3235 // TODO: Create Calendar::allIncidences() function and use it here 3235 // TODO: Create Calendar::allIncidences() function and use it here
3236 3236
3237 QPtrList<Event> events = mCalendar->events(); 3237 QPtrList<Event> events = mCalendar->events();
3238 for(uint i=0; i<events.count(); ++i) { 3238 for(uint i=0; i<events.count(); ++i) {
3239 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3239 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3240 events.at(i)->recreate(); 3240 events.at(i)->recreate();
3241 events.at(i)->setReadOnly(false); 3241 events.at(i)->setReadOnly(false);
3242 } 3242 }
3243 3243
3244 QPtrList<Todo> todos = mCalendar->todos(); 3244 QPtrList<Todo> todos = mCalendar->todos();
3245 for(uint i=0; i<todos.count(); ++i) { 3245 for(uint i=0; i<todos.count(); ++i) {
3246 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3246 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3247 todos.at(i)->recreate(); 3247 todos.at(i)->recreate();
3248 todos.at(i)->setReadOnly(false); 3248 todos.at(i)->setReadOnly(false);
3249 } 3249 }
3250 3250
3251 QPtrList<Journal> journals = mCalendar->journals(); 3251 QPtrList<Journal> journals = mCalendar->journals();
3252 for(uint i=0; i<journals.count(); ++i) { 3252 for(uint i=0; i<journals.count(); ++i) {
3253 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3253 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3254 journals.at(i)->recreate(); 3254 journals.at(i)->recreate();
3255 journals.at(i)->setReadOnly(false); 3255 journals.at(i)->setReadOnly(false);
3256 } 3256 }
3257 3257
3258 updateView(); 3258 updateView();
3259} 3259}
3260 3260
3261void CalendarView::showIntro() 3261void CalendarView::showIntro()
3262{ 3262{
3263 kdDebug() << "To be implemented." << endl; 3263 kdDebug() << "To be implemented." << endl;
3264} 3264}
3265 3265
3266QWidgetStack *CalendarView::viewStack() 3266QWidgetStack *CalendarView::viewStack()
3267{ 3267{
3268 return mRightFrame; 3268 return mRightFrame;
3269} 3269}
3270 3270
3271QWidget *CalendarView::leftFrame() 3271QWidget *CalendarView::leftFrame()
3272{ 3272{
3273 return mLeftFrame; 3273 return mLeftFrame;
3274} 3274}
3275 3275
3276DateNavigator *CalendarView::dateNavigator() 3276DateNavigator *CalendarView::dateNavigator()
3277{ 3277{
3278 return mNavigator; 3278 return mNavigator;
3279} 3279}
3280 3280
3281KDateNavigator* CalendarView::dateNavigatorWidget() 3281KDateNavigator* CalendarView::dateNavigatorWidget()
3282{ 3282{
3283 return mDateNavigator; 3283 return mDateNavigator;
3284} 3284}
3285void CalendarView::toggleDateNavigatorWidget() 3285void CalendarView::toggleDateNavigatorWidget()
3286{ 3286{
3287 if (mDateNavigator->isVisible()) 3287 if (mDateNavigator->isVisible())
3288 mDateNavigator->hide(); 3288 mDateNavigator->hide();
3289 else 3289 else
3290 mDateNavigator->show(); 3290 mDateNavigator->show();
3291} 3291}
3292void CalendarView::addView(KOrg::BaseView *view) 3292void CalendarView::addView(KOrg::BaseView *view)
3293{ 3293{
3294 mViewManager->addView(view); 3294 mViewManager->addView(view);
3295} 3295}
3296 3296
3297void CalendarView::showView(KOrg::BaseView *view) 3297void CalendarView::showView(KOrg::BaseView *view)
3298{ 3298{
3299 mViewManager->showView(view, mLeftFrame->isVisible()); 3299 mViewManager->showView(view, mLeftFrame->isVisible());
3300} 3300}
3301 3301
3302Incidence *CalendarView::currentSelection() 3302Incidence *CalendarView::currentSelection()
3303{ 3303{
3304 return mViewManager->currentSelection(); 3304 return mViewManager->currentSelection();
3305} 3305}
3306void CalendarView::toggleAllDaySize() 3306void CalendarView::toggleAllDaySize()
3307{ 3307{
3308 /* 3308 /*
3309 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3309 if ( KOPrefs::instance()->mAllDaySize > 47 )
3310 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3310 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3311 else 3311 else
3312 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3312 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3313 */ 3313 */
3314 viewManager()->agendaView()->toggleAllDay(); 3314 viewManager()->agendaView()->toggleAllDay();
3315} 3315}
3316void CalendarView::toggleExpand() 3316void CalendarView::toggleExpand()
3317{ 3317{
3318 // if ( mLeftFrame->isHidden() ) { 3318 // if ( mLeftFrame->isHidden() ) {
3319 // mLeftFrame->show(); 3319 // mLeftFrame->show();
3320 // emit calendarViewExpanded( false ); 3320 // emit calendarViewExpanded( false );
3321 // } else { 3321 // } else {
3322 // mLeftFrame->hide(); 3322 // mLeftFrame->hide();
3323 // emit calendarViewExpanded( true ); 3323 // emit calendarViewExpanded( true );
3324 // } 3324 // }
3325 3325
3326 globalFlagBlockAgenda = 1; 3326 globalFlagBlockAgenda = 1;
3327 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3327 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3328 globalFlagBlockAgenda = 5; 3328 globalFlagBlockAgenda = 5;
3329 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3329 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3330 //mViewManager->showView( 0, true ); 3330 //mViewManager->showView( 0, true );
3331} 3331}
3332 3332
3333void CalendarView::calendarModified( bool modified, Calendar * ) 3333void CalendarView::calendarModified( bool modified, Calendar * )
3334{ 3334{
3335 setModified( modified ); 3335 setModified( modified );
3336} 3336}
3337 3337
3338Todo *CalendarView::selectedTodo() 3338Todo *CalendarView::selectedTodo()
3339{ 3339{
3340 Incidence *incidence = currentSelection(); 3340 Incidence *incidence = currentSelection();
3341 if ( incidence && incidence->type() == "Todo" ) { 3341 if ( incidence && incidence->type() == "Todo" ) {
3342 return static_cast<Todo *>( incidence ); 3342 return static_cast<Todo *>( incidence );
3343 } 3343 }
3344 3344
3345 incidence = mTodoList->selectedIncidences().first(); 3345 incidence = mTodoList->selectedIncidences().first();
3346 if ( incidence && incidence->type() == "Todo" ) { 3346 if ( incidence && incidence->type() == "Todo" ) {
3347 return static_cast<Todo *>( incidence ); 3347 return static_cast<Todo *>( incidence );
3348 } 3348 }
3349 3349
3350 return 0; 3350 return 0;
3351} 3351}
3352 3352
3353void CalendarView::dialogClosing(Incidence *in) 3353void CalendarView::dialogClosing(Incidence *in)
3354{ 3354{
3355 // mDialogList.remove(in); 3355 // mDialogList.remove(in);
3356} 3356}
3357 3357
3358void CalendarView::showIncidence() 3358void CalendarView::showIncidence()
3359{ 3359{
3360 Incidence *incidence = currentSelection(); 3360 Incidence *incidence = currentSelection();
3361 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3361 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3362 if ( incidence ) { 3362 if ( incidence ) {
3363 ShowIncidenceVisitor v; 3363 ShowIncidenceVisitor v;
3364 v.act( incidence, this ); 3364 v.act( incidence, this );
3365 } 3365 }
3366} 3366}
3367void CalendarView::editIncidenceDescription() 3367void CalendarView::editIncidenceDescription()
3368{ 3368{
3369 mFlagEditDescription = true; 3369 mFlagEditDescription = true;
3370 editIncidence(); 3370 editIncidence();
3371 mFlagEditDescription = false; 3371 mFlagEditDescription = false;
3372} 3372}
3373void CalendarView::editIncidence() 3373void CalendarView::editIncidence()
3374{ 3374{
3375 // qDebug("editIncidence() "); 3375 // qDebug("editIncidence() ");
3376 Incidence *incidence = currentSelection(); 3376 Incidence *incidence = currentSelection();
3377 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3377 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3378 if ( incidence ) { 3378 if ( incidence ) {
3379 EditIncidenceVisitor v; 3379 EditIncidenceVisitor v;
3380 v.act( incidence, this ); 3380 v.act( incidence, this );
3381 } 3381 }
3382} 3382}
3383 3383
3384void CalendarView::deleteIncidence() 3384void CalendarView::deleteIncidence()
3385{ 3385{
3386 Incidence *incidence = currentSelection(); 3386 Incidence *incidence = currentSelection();
3387 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3387 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3388 if ( incidence ) { 3388 if ( incidence ) {
3389 deleteIncidence(incidence); 3389 deleteIncidence(incidence);
3390 } 3390 }
3391} 3391}
3392 3392
3393void CalendarView::showIncidence(Incidence *incidence) 3393void CalendarView::showIncidence(Incidence *incidence)
3394{ 3394{
3395 if ( incidence ) { 3395 if ( incidence ) {
3396 ShowIncidenceVisitor v; 3396 ShowIncidenceVisitor v;
3397 v.act( incidence, this ); 3397 v.act( incidence, this );
3398 } 3398 }
3399} 3399}
3400 3400
3401void CalendarView::editIncidence(Incidence *incidence) 3401void CalendarView::editIncidence(Incidence *incidence)
3402{ 3402{
3403 if ( incidence ) { 3403 if ( incidence ) {
3404 3404
3405 EditIncidenceVisitor v; 3405 EditIncidenceVisitor v;
3406 v.act( incidence, this ); 3406 v.act( incidence, this );
3407 3407
3408 } 3408 }
3409} 3409}
3410 3410
3411void CalendarView::deleteIncidence(Incidence *incidence) 3411void CalendarView::deleteIncidence(Incidence *incidence)
3412{ 3412{
3413 //qDebug(" CalendarView::deleteIncidence "); 3413 //qDebug(" CalendarView::deleteIncidence ");
3414 if ( incidence ) { 3414 if ( incidence ) {
3415 DeleteIncidenceVisitor v; 3415 DeleteIncidenceVisitor v;
3416 v.act( incidence, this ); 3416 v.act( incidence, this );
3417 } 3417 }
3418} 3418}
3419 3419
3420 3420
3421void CalendarView::lookForOutgoingMessages() 3421void CalendarView::lookForOutgoingMessages()
3422{ 3422{
3423 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3423 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3424 ogd->loadMessages(); 3424 ogd->loadMessages();
3425} 3425}
3426 3426
3427void CalendarView::lookForIncomingMessages() 3427void CalendarView::lookForIncomingMessages()
3428{ 3428{
3429 IncomingDialog *icd = mDialogManager->incomingDialog(); 3429 IncomingDialog *icd = mDialogManager->incomingDialog();
3430 icd->retrieve(); 3430 icd->retrieve();
3431} 3431}
3432 3432
3433bool CalendarView::removeCompletedSubTodos( Todo* t ) 3433bool CalendarView::removeCompletedSubTodos( Todo* t )
3434{ 3434{
3435 bool deleteTodo = true; 3435 bool deleteTodo = true;
3436 QPtrList<Incidence> subTodos; 3436 QPtrList<Incidence> subTodos;
3437 Incidence *aTodo; 3437 Incidence *aTodo;
3438 subTodos = t->relations(); 3438 subTodos = t->relations();
3439 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3439 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3440 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3440 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3441 deleteTodo = false; 3441 deleteTodo = false;
3442 } 3442 }
3443 if ( deleteTodo ) { 3443 if ( deleteTodo ) {
3444 if ( t->isCompleted() ) { 3444 if ( t->isCompleted() ) {
3445 checkZaurusId( t->zaurusId(), true ); 3445 checkZaurusId( t->zaurusId(), true );
3446 mCalendar->deleteTodo( t ); 3446 mCalendar->deleteTodo( t );
3447 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3447 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3448 } 3448 }
3449 else 3449 else
3450 deleteTodo = false; 3450 deleteTodo = false;
3451 } 3451 }
3452 return deleteTodo; 3452 return deleteTodo;
3453 3453
3454} 3454}
3455void CalendarView::purgeCompleted() 3455void CalendarView::purgeCompleted()
3456{ 3456{
3457 int result = KMessageBox::warningContinueCancel(this, 3457 int result = KMessageBox::warningContinueCancel(this,
3458 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3458 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3459 3459
3460 if (result == KMessageBox::Continue) { 3460 if (result == KMessageBox::Continue) {
3461 3461
3462 QPtrList<Todo> todoCal; 3462 QPtrList<Todo> todoCal;
3463 QPtrList<Todo> rootTodos; 3463 QPtrList<Todo> rootTodos;
3464 //QPtrList<Incidence> rel; 3464 //QPtrList<Incidence> rel;
3465 Todo *aTodo;//, *rTodo; 3465 Todo *aTodo;//, *rTodo;
3466 Incidence *rIncidence; 3466 Incidence *rIncidence;
3467 bool childDelete = false; 3467 bool childDelete = false;
3468 bool deletedOne = true; 3468 bool deletedOne = true;
3469 todoCal = calendar()->todos(); 3469 todoCal = calendar()->todos();
3470 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3470 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3471 if ( !aTodo->relatedTo() ) 3471 if ( !aTodo->relatedTo() )
3472 rootTodos.append( aTodo ); 3472 rootTodos.append( aTodo );
3473 } 3473 }
3474 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3474 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3475 removeCompletedSubTodos( aTodo ); 3475 removeCompletedSubTodos( aTodo );
3476 } 3476 }
3477 3477
3478 updateView(); 3478 updateView();
3479 } 3479 }
3480} 3480}
3481 3481
3482void CalendarView::slotCalendarChanged() 3482void CalendarView::slotCalendarChanged()
3483{ 3483{
3484 ; 3484 ;
3485} 3485}
3486 3486
3487NavigatorBar *CalendarView::navigatorBar() 3487NavigatorBar *CalendarView::navigatorBar()
3488{ 3488{
3489 return mNavigatorBar; 3489 return mNavigatorBar;
3490} 3490}
3491 3491
3492 3492
3493 3493
3494void CalendarView::keyPressEvent ( QKeyEvent *e) 3494void CalendarView::keyPressEvent ( QKeyEvent *e)
3495{ 3495{
3496 //qDebug(" alendarView::keyPressEvent "); 3496 //qDebug(" alendarView::keyPressEvent ");
3497 e->ignore(); 3497 e->ignore();
3498} 3498}
3499 3499
3500//#include "calendarview.moc" 3500//#include "calendarview.moc"
3501 3501
3502//#include "calendarviewbase.moc" 3502//#include "calendarviewbase.moc"
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 0547a2e..b2001ec 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -1,649 +1,643 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtextbrowser.h> 21#include <qtextbrowser.h>
22#include <qtextcodec.h> 22#include <qtextcodec.h>
23#include <qfileinfo.h> 23#include <qfileinfo.h>
24#include <qlabel.h> 24#include <qlabel.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27 27
28#include <kglobal.h> 28#include <kglobal.h>
29#include <klocale.h> 29#include <klocale.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kiconloader.h> 31#include <kiconloader.h>
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35 35
36#ifndef KORG_NOPRINTER 36#ifndef KORG_NOPRINTER
37#include "calprinter.h" 37#include "calprinter.h"
38#endif 38#endif
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "koeventviewerdialog.h" 41#include "koeventviewerdialog.h"
42 42
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44using namespace KOrg; 44using namespace KOrg;
45 45
46void WhatsNextTextBrowser::setSource(const QString& n) 46void WhatsNextTextBrowser::setSource(const QString& n)
47{ 47{
48 48
49 if (n.startsWith("event:")) { 49 if (n.startsWith("event:")) {
50 emit showIncidence(n); 50 emit showIncidence(n);
51 return; 51 return;
52 } else if (n.startsWith("todo:")) { 52 } else if (n.startsWith("todo:")) {
53 emit showIncidence(n); 53 emit showIncidence(n);
54 return; 54 return;
55 } else { 55 } else {
56 QTextBrowser::setSource(n); 56 QTextBrowser::setSource(n);
57 } 57 }
58} 58}
59 59
60KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, 60KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
61 const char *name) 61 const char *name)
62 : KOrg::BaseView(calendar, parent, name) 62 : KOrg::BaseView(calendar, parent, name)
63{ 63{
64 // mDateLabel = 64 // mDateLabel =
65 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); 65 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
66 // mDateLabel->setMargin(2); 66 // mDateLabel->setMargin(2);
67 // mDateLabel->setAlignment(AlignCenter); 67 // mDateLabel->setAlignment(AlignCenter);
68 setFont( KOPrefs::instance()->mWhatsNextFont ); 68 setFont( KOPrefs::instance()->mWhatsNextFont );
69 mView = new WhatsNextTextBrowser(this); 69 mView = new WhatsNextTextBrowser(this);
70 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); 70 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
71 71
72 mEventViewer = 0; 72 mEventViewer = 0;
73 73
74 QBoxLayout *topLayout = new QVBoxLayout(this); 74 QBoxLayout *topLayout = new QVBoxLayout(this);
75 // topLayout->addWidget(mDateLabel); 75 // topLayout->addWidget(mDateLabel);
76 topLayout->addWidget(mView); 76 topLayout->addWidget(mView);
77} 77}
78 78
79KOWhatsNextView::~KOWhatsNextView() 79KOWhatsNextView::~KOWhatsNextView()
80{ 80{
81} 81}
82 82
83int KOWhatsNextView::maxDatesHint() 83int KOWhatsNextView::maxDatesHint()
84{ 84{
85 return 0; 85 return 0;
86} 86}
87 87
88int KOWhatsNextView::currentDateCount() 88int KOWhatsNextView::currentDateCount()
89{ 89{
90 return 0; 90 return 0;
91} 91}
92 92
93QPtrList<Incidence> KOWhatsNextView::selectedIncidences() 93QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
94{ 94{
95 QPtrList<Incidence> eventList; 95 QPtrList<Incidence> eventList;
96 96
97 return eventList; 97 return eventList;
98} 98}
99 99
100 100
101void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, 101void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
102 const QDate &td) 102 const QDate &td)
103{ 103{
104#ifndef KORG_NOPRINTER 104#ifndef KORG_NOPRINTER
105 calPrinter->preview(CalPrinter::Day, fd, td); 105 calPrinter->preview(CalPrinter::Day, fd, td);
106#endif 106#endif
107} 107}
108void KOWhatsNextView::updateConfig() 108void KOWhatsNextView::updateConfig()
109{ 109{
110 setFont( KOPrefs::instance()->mWhatsNextFont ); 110 setFont( KOPrefs::instance()->mWhatsNextFont );
111 updateView(); 111 updateView();
112 112
113} 113}
114void KOWhatsNextView::updateView() 114void KOWhatsNextView::updateView()
115{ 115{
116 116
117 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); 117 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
118 KIconLoader kil("korganizer"); 118 KIconLoader kil("korganizer");
119 QString ipath;// = new QString(); 119 QString ipath;// = new QString();
120 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); 120 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
121 //<big><big><strong>" + date + "</strong></big></big>\n"; 121 //<big><big><strong>" + date + "</strong></big></big>\n";
122 mText = "<table width=\"100%\">\n"; 122 mText = "<table width=\"100%\">\n";
123 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 123 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
124#ifdef DESKTOP_VERSION 124#ifdef DESKTOP_VERSION
125 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; 125 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
126#else 126#else
127 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 127 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
128#endif 128#endif
129 // mText += "<img src=\""; 129 // mText += "<img src=\"";
130 // mText += ipath; 130 // mText += ipath;
131 // mText += "\">"; 131 // mText += "\">";
132 mEventDate = QDate::currentDate(); 132 mEventDate = QDate::currentDate();
133#ifdef DESKTOP_VERSION 133#ifdef DESKTOP_VERSION
134 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; 134 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
135#else 135#else
136 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; 136 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
137#endif 137#endif
138 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 138 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
139 int iii; 139 int iii;
140 mTodos.clear(); 140 mTodos.clear();
141 QPtrList<Event> events; 141 QPtrList<Event> events;
142 QPtrList<Todo> todos = calendar()->todos(); 142 QPtrList<Todo> todos = calendar()->todos();
143 Todo * todo; 143 Todo * todo;
144 //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; 144 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
145 int daysToShow = KOPrefs::instance()->mWhatsNextDays ; 145 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
146 bool itemAdded = false; 146 bool itemAdded = false;
147 for ( iii = 0; iii < daysToShow; ++iii ) { 147 for ( iii = 0; iii < daysToShow; ++iii ) {
148 QString date; 148 QString date;
149 itemAdded = false; 149 itemAdded = false;
150 events = calendar()->events( mEventDate, true ); 150 events = calendar()->events( mEventDate, true );
151 151
152 if ( iii == 0 ) { // today !!! 152 if ( iii == 0 ) { // today !!!
153 todo = todos.first(); 153 todo = todos.first();
154 while(todo) { 154 while(todo) {
155 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { 155 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) {
156 if ( ! itemAdded ) { 156 if ( ! itemAdded ) {
157 appendDay ( iii, mEventDate ); 157 appendDay ( iii, mEventDate );
158 itemAdded = true; 158 itemAdded = true;
159 159
160 } 160 }
161 appendEvent(todo); 161 appendEvent(todo);
162 } 162 }
163 todo = todos.next(); 163 todo = todos.next();
164 } 164 }
165 } 165 }
166 166
167 167
168 if (events.count() > 0) { 168 if (events.count() > 0) {
169 // mText += "<p></p>"; 169 // mText += "<p></p>";
170 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 170 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
171 // mText += "<h2>"; 171 // mText += "<h2>";
172 //mText += " <img src=\""; 172 //mText += " <img src=\"";
173 //mText += ipath; 173 //mText += ipath;
174 //mText += "\">"; 174 //mText += "\">";
175 if ( ! itemAdded ) { 175 if ( ! itemAdded ) {
176 appendDay ( iii, mEventDate ); 176 appendDay ( iii, mEventDate );
177 itemAdded = true; 177 itemAdded = true;
178 178
179 } 179 }
180 Event *ev = events.first(); 180 Event *ev = events.first();
181 while(ev) { 181 while(ev) {
182 //qDebug("+++++event append %s", ev->summary().latin1()); 182 //qDebug("+++++event append %s", ev->summary().latin1());
183 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { 183 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) {
184 appendEvent(ev, false , iii!= 0 ); 184 appendEvent(ev, false , iii!= 0 );
185 } 185 }
186 ev = events.next(); 186 ev = events.next();
187 } 187 }
188 188
189 //mText += "</table>\n"; 189 //mText += "</table>\n";
190 } 190 }
191 191
192 todo = todos.first(); 192 todo = todos.first();
193 while(todo) { 193 while(todo) {
194 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { 194 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) {
195 if ( ! itemAdded ) { 195 if ( ! itemAdded ) {
196 appendDay ( iii, mEventDate ); 196 appendDay ( iii, mEventDate );
197 itemAdded = true; 197 itemAdded = true;
198 } 198 }
199 appendEvent(todo); 199 appendEvent(todo);
200 } 200 }
201 todo = todos.next(); 201 todo = todos.next();
202 } 202 }
203 if ( !itemAdded && iii == 0 ) { 203 if ( !itemAdded && iii == 0 ) {
204 // appendDay ( iii, mEventDate ); 204 // appendDay ( iii, mEventDate );
205 //mText += "<table>"; 205 //mText += "<table>";
206 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; 206 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n";
207 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n"; 207 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n";
208 //mText +="</table>"; 208 //mText +="</table>";
209 } 209 }
210 if ( itemAdded ) 210 if ( itemAdded )
211 mText += "</table>\n"; 211 mText += "</table>\n";
212 mEventDate = mEventDate.addDays( 1 ); 212 mEventDate = mEventDate.addDays( 1 );
213 } 213 }
214 214
215 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; 215 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios;
216 if (todos.count() > 0 && topmostPrios > 0 ) { 216 if (todos.count() > 0 && topmostPrios > 0 ) {
217 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 217 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
218 // mText += "<h2>"; 218 // mText += "<h2>";
219 //<img src=\""; 219 //<img src=\"";
220 // mText += ipath; 220 // mText += ipath;
221 // mText += "\">"; 221 // mText += "\">";
222 // mText += i18n("Overdue To-Do:") + "</h2>\n"; 222 // mText += i18n("Overdue To-Do:") + "</h2>\n";
223 223
224 //mText += "<ul>\n"; 224 //mText += "<ul>\n";
225 bool gotone = false; 225 bool gotone = false;
226 int priority = 1; 226 int priority = 1;
227 int priosFound = 0; 227 int priosFound = 0;
228#ifdef DESKTOP_VERSION 228#ifdef DESKTOP_VERSION
229 mText +="<p></p>"; 229 mText +="<p></p>";
230#endif 230#endif
231 231
232 mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></strong></big></big>\n"; 232 mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></strong></big></big>\n";
233 mText += "<ul>\n"; 233 mText += "<ul>\n";
234 while (!gotone && priority<6) { 234 while (!gotone && priority<6) {
235 todo = todos.first(); 235 todo = todos.first();
236 while(todo) { 236 while(todo) {
237 if (!todo->isCompleted() && (todo->priority() == priority) ) { 237 if (!todo->isCompleted() && (todo->priority() == priority) ) {
238 if ( appendTodo(todo) ) 238 if ( appendTodo(todo) )
239 gotone = true; 239 gotone = true;
240 } 240 }
241 todo = todos.next(); 241 todo = todos.next();
242 } 242 }
243 if ( gotone ) { 243 if ( gotone ) {
244 gotone = false; 244 gotone = false;
245 ++priosFound; 245 ++priosFound;
246 if ( priosFound == topmostPrios ) 246 if ( priosFound == topmostPrios )
247 break; 247 break;
248 } 248 }
249 priority++; 249 priority++;
250 // kdDebug() << "adding the todos..." << endl; 250 // kdDebug() << "adding the todos..." << endl;
251 } 251 }
252 mText += "</ul>\n"; 252 mText += "</ul>\n";
253 } 253 }
254 254
255 int replys = 0; 255 int replys = 0;
256 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); 256 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6));
257 if (events.count() > 0) { 257 if (events.count() > 0) {
258 Event *ev = events.first(); 258 Event *ev = events.first();
259 while(ev) { 259 while(ev) {
260 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 260 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
261 if (me!=0) { 261 if (me!=0) {
262 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 262 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
263 if (replys == 0) { 263 if (replys == 0) {
264 mText += "<p></p>"; 264 mText += "<p></p>";
265 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 265 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
266 mText += "<h2>"; 266 mText += "<h2>";
267 //<img src=\""; 267 //<img src=\"";
268 // mText += ipath; 268 // mText += ipath;
269 // mText += "\">"; 269 // mText += "\">";
270 mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; 270 mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
271 mText += "<table>\n"; 271 mText += "<table>\n";
272 } 272 }
273 replys++; 273 replys++;
274 appendEvent(ev,true); 274 appendEvent(ev,true);
275 } 275 }
276 } 276 }
277 ev = events.next(); 277 ev = events.next();
278 } 278 }
279 } 279 }
280 todos = calendar()->todos(); 280 todos = calendar()->todos();
281 if (todos.count() > 0) { 281 if (todos.count() > 0) {
282 Todo *to = todos.first(); 282 Todo *to = todos.first();
283 while(to) { 283 while(to) {
284 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 284 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
285 if (me!=0) { 285 if (me!=0) {
286 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 286 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
287 if (replys == 0) { 287 if (replys == 0) {
288 mText += "<p></p>"; 288 mText += "<p></p>";
289 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 289 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
290 mText += "<h2>"; 290 mText += "<h2>";
291 //<img src=\""; 291 //<img src=\"";
292 // mText += ipath; 292 // mText += ipath;
293 // mText += "\">"; 293 // mText += "\">";
294 mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; 294 mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
295 mText += "<table>\n"; 295 mText += "<table>\n";
296 } 296 }
297 replys++; 297 replys++;
298 appendEvent(to); 298 appendEvent(to);
299 } 299 }
300 } 300 }
301 kdDebug () << "check for todo-replys..." << endl; 301 kdDebug () << "check for todo-replys..." << endl;
302 to = todos.next(); 302 to = todos.next();
303 } 303 }
304 } 304 }
305 if (replys > 0 ) mText += "</table>\n"; 305 if (replys > 0 ) mText += "</table>\n";
306 306
307 307
308 mText += "</td></tr>\n</table>\n"; 308 mText += "</td></tr>\n</table>\n";
309 309
310 kdDebug() << "KOWhatsNextView::updateView: text: " << mText << endl; 310 kdDebug() << "KOWhatsNextView::updateView: text: " << mText << endl;
311 mView->setText(mText); 311 mView->setText(mText);
312 mView->setFocus(); 312 mView->setFocus();
313 313
314 // QPixmap bPix = SmallIcon( "back" ); 314 // QPixmap bPix = SmallIcon( "back" );
315 // qDebug("xxxxxxxxxxxxxxxxxxxxx "); 315 // qDebug("xxxxxxxxxxxxxxxxxxxxx ");
316 // QWidget* test = new QWidget(); 316 // QWidget* test = new QWidget();
317 // test->setBackgroundMode(FixedPixmap ); 317 // test->setBackgroundMode(FixedPixmap );
318 // test->setBackgroundPixmap ( bPix ); 318 // test->setBackgroundPixmap ( bPix );
319 // test->resize( 300, 400 ); 319 // test->resize( 300, 400 );
320 // test->show(); 320 // test->show();
321 // mView->setBackgroundMode(FixedPixmap ); 321 // mView->setBackgroundMode(FixedPixmap );
322 // mView->setBackgroundPixmap ( bPix ); 322 // mView->setBackgroundPixmap ( bPix );
323} 323}
324 324
325void KOWhatsNextView::appendDay( int i, QDate eventDate ) 325void KOWhatsNextView::appendDay( int i, QDate eventDate )
326{ 326{
327 QString date; 327 QString date;
328 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); 328 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer);
329 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { 329 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) {
330 if ( i == 0 ) { 330 if ( i == 0 ) {
331 mText += "<table>\n"; 331 mText += "<table>\n";
332 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; 332 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>";
333 } 333 }
334 else if ( i == 1 ) 334 else if ( i == 1 )
335 date = "<em><font color=\"#000080\">" + day + "</font></em>" ; 335 date = "<em><font color=\"#000080\">" + day + "</font></em>" ;
336 else date = "<em><font color=\"#000080\">" + day + "</font></em>"; 336 else date = "<em><font color=\"#000080\">" + day + "</font></em>";
337 //mText += "<h2>" + date + "</h2>\n"; 337 //mText += "<h2>" + date + "</h2>\n";
338 mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 338 mText += "<big><big><strong>" + date + "</strong></big></big>\n";
339 mText += "<table>\n"; 339 mText += "<table>\n";
340 340
341 341
342 342
343 } else { 343 } else {
344 if ( i == 0 ) { 344 if ( i == 0 ) {
345 mText += "<table>\n"; 345 mText += "<table>\n";
346 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; 346 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>";
347 } 347 }
348 348
349#ifdef DESKTOP_VERSION 349#ifdef DESKTOP_VERSION
350 else if ( i == 1 ) { 350 else if ( i == 1 ) {
351 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; 351 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
352 } 352 }
353 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; 353 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
354#else 354#else
355 else if ( i == 1 ) { 355 else if ( i == 1 ) {
356 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; 356 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
357 } 357 }
358 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; 358 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
359 359
360#endif 360#endif
361 //mText += "<h2>" + date + "</h2>\n"; 361 //mText += "<h2>" + date + "</h2>\n";
362 mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 362 mText += "<big><big><strong>" + date + "</strong></big></big>\n";
363 mText += "<table>\n"; 363 mText += "<table>\n";
364 } 364 }
365} 365}
366 366
367 367
368void KOWhatsNextView::showDates(const QDate &, const QDate &) 368void KOWhatsNextView::showDates(const QDate &, const QDate &)
369{ 369{
370 updateView(); 370 updateView();
371} 371}
372 372
373void KOWhatsNextView::showEvents(QPtrList<Event>) 373void KOWhatsNextView::showEvents(QPtrList<Event>)
374{ 374{
375} 375}
376 376
377void KOWhatsNextView::changeEventDisplay(Event *, int action) 377void KOWhatsNextView::changeEventDisplay(Event *, int action)
378{ 378{
379 switch(action) { 379 switch(action) {
380 case KOGlobals::EVENTADDED: 380 case KOGlobals::EVENTADDED:
381 updateView(); 381 updateView();
382 break; 382 break;
383 case KOGlobals::EVENTEDITED: 383 case KOGlobals::EVENTEDITED:
384 updateView(); 384 updateView();
385 break; 385 break;
386 case KOGlobals::EVENTDELETED: 386 case KOGlobals::EVENTDELETED:
387 updateView(); 387 updateView();
388 break; 388 break;
389 default: 389 default:
390 updateView(); 390 updateView();
391 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; 391 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
392 } 392 }
393} 393}
394 394
395void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed ) 395void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed )
396{ 396{
397 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(21) == QString("last-syncEvent-device") ) 397 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(21) == QString("last-syncEvent-device") )
398 return; 398 return;
399 QDateTime cdt = QDateTime::currentDateTime(); 399 QDateTime cdt = QDateTime::currentDateTime();
400 mText += "<tr><td><b>"; 400 mText += "<tr><td><b>";
401 if (ev->type()=="Event") { 401 if (ev->type()=="Event") {
402 402
403 if (!ev->doesFloat()) { 403 if (!ev->doesFloat()) {
404 Event *event = static_cast<Event *>(ev); 404 Event *event = static_cast<Event *>(ev);
405 QDateTime st,end; 405 QDateTime st,end;
406 if ( event->recurrence()->doesRecur() ) { 406 if ( event->recurrence()->doesRecur() ) {
407 QDate recDate= mEventDate; 407 QDate recDate= mEventDate;
408 int days = event->dtStart().date().daysTo (event->dtEnd().date() ); 408 int days = event->dtStart().date().daysTo (event->dtEnd().date() );
409 while ( ! event->recursOn( recDate ) ) { 409 while ( ! event->recursOn( recDate ) ) {
410 recDate = recDate.addDays( -1 ); 410 recDate = recDate.addDays( -1 );
411 411
412 } 412 }
413 st = QDateTime ( recDate, event->dtStart().time() ); 413 st = QDateTime ( recDate, event->dtStart().time() );
414 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); 414 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() );
415 } 415 }
416 else { 416 else {
417 st = event->dtStart(); 417 st = event->dtStart();
418 end = event->dtEnd(); 418 end = event->dtEnd();
419 } 419 }
420 420
421 if (reply) mText += "on " + event->dtStartDateStr() + ": "; 421 if (reply) mText += "on " + event->dtStartDateStr() + ": ";
422 QString dateText; 422 QString dateText;
423 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); 423 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() );
424 if ( st.date() < mEventDate ) 424 if ( st.date() < mEventDate )
425 dateText = "++:++-"; 425 dateText = "++:++-";
426 else 426 else
427 dateText = event->dtStartTimeStr() + "-"; 427 dateText = event->dtStartTimeStr() + "-";
428 if ( end.date() > mEventDate ) 428 if ( end.date() > mEventDate )
429 dateText += "++:++"; 429 dateText += "++:++";
430 else 430 else
431 dateText += event->dtEndTimeStr(); 431 dateText += event->dtEndTimeStr();
432 if ( notRed ) 432 if ( notRed )
433 mText += dateText; 433 mText += dateText;
434 else { 434 else {
435 if ( end < cdt ) 435 if ( end < cdt )
436 mText += "<font color=\"#F00000\">" + dateText + "</font>"; 436 mText += "<font color=\"#F00000\">" + dateText + "</font>";
437 else if ( st < cdt ) 437 else if ( st < cdt )
438 mText += "<font color=\"#008000\">" + dateText + "</font>"; 438 mText += "<font color=\"#008000\">" + dateText + "</font>";
439 else 439 else
440 mText += dateText; 440 mText += dateText;
441 } 441 }
442 442
443 } else { 443 } else {
444 mText += i18n("Allday:"); 444 mText += i18n("Allday:");
445 445
446 } 446 }
447 } else { 447 } else {
448 mTodos.append( ev ); 448 mTodos.append( ev );
449 mText += i18n("ToDo:"); 449 mText += i18n("ToDo:");
450 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { 450 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) {
451 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 451 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
452 QString dfs = KGlobal::locale()->dateFormatShort(); 452 QString dfs = KGlobal::locale()->dateFormatShort();
453 KGlobal::locale()->setIntDateFormat( 3 );
454 KGlobal::locale()->setDateFormatShort("%d.%b"); 453 KGlobal::locale()->setDateFormatShort("%d.%b");
455 mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "</font>"; 454 mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>";
456
457 KGlobal::locale()->setDateFormatShort(dfs); 455 KGlobal::locale()->setDateFormatShort(dfs);
458 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate );
459 } else { 456 } else {
460 if (!ev->doesFloat() ) 457 if (!ev->doesFloat() )
461 if( ( (Todo*)ev)->dtDue() < cdt ) { 458 if( ( (Todo*)ev)->dtDue() < cdt ) {
462 mText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; 459 mText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
463 460
464 461
465 } else 462 } else
466 mText +=((Todo*)ev)->dtDueTimeStr(); 463 mText +=((Todo*)ev)->dtDueTimeStr();
467 mTodos.append( ev ); 464 mTodos.append( ev );
468 } 465 }
469 } 466 }
470 mText += "</b></td><td>"; 467 mText += "</b></td><td>";
471 bool needClose = false; 468 bool needClose = false;
472 if ( ev->cancelled() ) { 469 if ( ev->cancelled() ) {
473 mText += "<font color=\"#F00000\">[c"; 470 mText += "<font color=\"#F00000\">[c";
474 needClose =true; 471 needClose =true;
475 472
476 } 473 }
477 if ( ev->isAlarmEnabled() ) { 474 if ( ev->isAlarmEnabled() ) {
478 if ( !needClose) 475 if ( !needClose)
479 mText +="["; 476 mText +="[";
480 mText += "a"; 477 mText += "a";
481 needClose =true; 478 needClose =true;
482 479
483 } 480 }
484 if ( ev->description().length() > 0 ) { 481 if ( ev->description().length() > 0 ) {
485 if ( !needClose) 482 if ( !needClose)
486 mText +="["; 483 mText +="[";
487 mText += "i"; 484 mText += "i";
488 needClose =true; 485 needClose =true;
489 } 486 }
490 if ( ev->recurrence()->doesRecur() ) { 487 if ( ev->recurrence()->doesRecur() ) {
491 if ( !needClose) 488 if ( !needClose)
492 mText +="["; 489 mText +="[";
493 mText += "r"; 490 mText += "r";
494 needClose =true; 491 needClose =true;
495 } 492 }
496 if ( needClose ) { 493 if ( needClose ) {
497 mText += "] "; 494 mText += "] ";
498 } 495 }
499 if ( ev->cancelled() ) 496 if ( ev->cancelled() )
500 mText += "</font>"; 497 mText += "</font>";
501 mText += "<a "; 498 mText += "<a ";
502 if (ev->type()=="Event") mText += "href=\"event:"; 499 if (ev->type()=="Event") mText += "href=\"event:";
503 if (ev->type()=="Todo") mText += "href=\"todo:"; 500 if (ev->type()=="Todo") mText += "href=\"todo:";
504 mText += ev->uid() + "\">"; 501 mText += ev->uid() + "\">";
505 if ( ev->summary().length() > 0 ) 502 if ( ev->summary().length() > 0 )
506 mText += ev->summary(); 503 mText += ev->summary();
507 else 504 else
508 mText += i18n("-no summary-"); 505 mText += i18n("-no summary-");
509 mText += "</a>"; 506 mText += "</a>";
510 if ( KOPrefs::instance()->mWNViewShowLocation ) 507 if ( KOPrefs::instance()->mWNViewShowLocation )
511 if ( !ev->location().isEmpty() ) 508 if ( !ev->location().isEmpty() )
512 mText += " ("+ev->location() +")"; 509 mText += " ("+ev->location() +")";
513 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) 510 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents)
514 mText += " ["+ev->relatedTo()->summary() +"]"; 511 mText += " ["+ev->relatedTo()->summary() +"]";
515 mText += "</td></tr>\n"; 512 mText += "</td></tr>\n";
516} 513}
517 514
518bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) 515bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
519{ 516{
520 if ( mTodos.find( ev ) != mTodos.end() ) return false; 517 if ( mTodos.find( ev ) != mTodos.end() ) return false;
521 518
522 mTodos.append( ev ); 519 mTodos.append( ev );
523 if ( !isSub ) 520 if ( !isSub )
524 mText += "<p>"; 521 mText += "<p>";
525 else 522 else
526 mText += "<li>"; 523 mText += "<li>";
527 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; 524 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] ";
528 525
529 526
530 mText += ind; 527 mText += ind;
531 bool needClose = false; 528 bool needClose = false;
532 if ( ev->cancelled() ) { 529 if ( ev->cancelled() ) {
533 mText += "<font color=\"#F00000\">[c"; 530 mText += "<font color=\"#F00000\">[c";
534 needClose =true; 531 needClose =true;
535 532
536 } 533 }
537 if ( ev->isAlarmEnabled() ) { 534 if ( ev->isAlarmEnabled() ) {
538 if ( !needClose) 535 if ( !needClose)
539 mText +="["; 536 mText +="[";
540 mText += "a"; 537 mText += "a";
541 needClose =true; 538 needClose =true;
542 539
543 } 540 }
544 541
545 if ( ev->description().length() > 0 ) { 542 if ( ev->description().length() > 0 ) {
546 if ( !needClose) 543 if ( !needClose)
547 mText +="["; 544 mText +="[";
548 mText += "i"; 545 mText += "i";
549 needClose =true; 546 needClose =true;
550 } 547 }
551 // if ( ev->recurrence()->doesRecur() ) { 548 // if ( ev->recurrence()->doesRecur() ) {
552 // if ( !needClose) 549 // if ( !needClose)
553 // mText +="("; 550 // mText +="(";
554 // mText += "r"; 551 // mText += "r";
555 // needClose =true; 552 // needClose =true;
556 // } 553 // }
557 if ( needClose ) 554 if ( needClose )
558 mText += "] "; 555 mText += "] ";
559 if ( ev->cancelled() ) 556 if ( ev->cancelled() )
560 mText += "</font>"; 557 mText += "</font>";
561 mText += "<a href=\"todo:" + ev->uid() + "\">"; 558 mText += "<a href=\"todo:" + ev->uid() + "\">";
562 mText += ev->summary(); 559 mText += ev->summary();
563 mText += "</a>"; 560 mText += "</a>";
564 if ( ((Todo*)ev)->hasDueDate () ) { 561 if ( ((Todo*)ev)->hasDueDate () ) {
565 QString year = ""; 562 QString year = "";
566 int ye = ((Todo*)ev)->dtDue().date().year(); 563 int ye = ((Todo*)ev)->dtDue().date().year();
567 if ( QDateTime::currentDateTime().date().year() != ye ) 564 if ( QDateTime::currentDateTime().date().year() != ye )
568 year = QString::number( ye ); 565 year = QString::number( ye );
569 QString dfs = KGlobal::locale()->dateFormatShort(); 566 QString dfs = KGlobal::locale()->dateFormatShort();
570 KGlobal::locale()->setIntDateFormat( 3 );
571 KGlobal::locale()->setDateFormatShort("%d.%b"); 567 KGlobal::locale()->setDateFormatShort("%d.%b");
572 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "."+ year +"]</font>"; 568 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>";
573
574 KGlobal::locale()->setDateFormatShort(dfs); 569 KGlobal::locale()->setDateFormatShort(dfs);
575 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate );
576 } 570 }
577 if ( KOPrefs::instance()->mWNViewShowLocation ) 571 if ( KOPrefs::instance()->mWNViewShowLocation )
578 if ( !ev->location().isEmpty() ) 572 if ( !ev->location().isEmpty() )
579 mText += " ("+ev->location() +")"; 573 mText += " ("+ev->location() +")";
580 if ( !isSub ) { 574 if ( !isSub ) {
581 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) 575 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
582 mText += " ["+ev->relatedTo()->summary() +"]"; 576 mText += " ["+ev->relatedTo()->summary() +"]";
583 mText += "</p>\n"; 577 mText += "</p>\n";
584 } 578 }
585 else { 579 else {
586 ind += "-"; 580 ind += "-";
587 mText += "</li>\n"; 581 mText += "</li>\n";
588 } 582 }
589 QPtrList<Incidence> Relations = ev->relations(); 583 QPtrList<Incidence> Relations = ev->relations();
590 Incidence *to; 584 Incidence *to;
591 for (to=Relations.first();to;to=Relations.next()) { 585 for (to=Relations.first();to;to=Relations.next()) {
592 if (!((Todo*)to)->isCompleted()) 586 if (!((Todo*)to)->isCompleted())
593 appendTodo( to, ind , true ); 587 appendTodo( to, ind , true );
594 } 588 }
595 589
596 return true; 590 return true;
597} 591}
598 592
599/* 593/*
600 void KOWhatsNextView::createEventViewer() 594 void KOWhatsNextView::createEventViewer()
601 { 595 {
602 if (!mEventViewer) { 596 if (!mEventViewer) {
603 597
604 mEventViewer = new KOEventViewerDialog(this); 598 mEventViewer = new KOEventViewerDialog(this);
605 } 599 }
606 } 600 }
607*/ 601*/
608void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) 602void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
609{ 603{
610 if ( mEventViewer ) 604 if ( mEventViewer )
611 delete mEventViewer; 605 delete mEventViewer;
612 mEventViewer = v; 606 mEventViewer = v;
613} 607}
614 608
615// TODO: Create this function in CalendarView and remove it from here 609// TODO: Create this function in CalendarView and remove it from here
616void KOWhatsNextView::showIncidence(const QString &uid) 610void KOWhatsNextView::showIncidence(const QString &uid)
617{ 611{
618 if ( !mEventViewer ) { 612 if ( !mEventViewer ) {
619 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); 613 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
620 return; 614 return;
621 } 615 }
622 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; 616 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
623 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); 617 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
624 if (uid.startsWith("event:")) { 618 if (uid.startsWith("event:")) {
625#ifdef DESKTOP_VERSION 619#ifdef DESKTOP_VERSION
626 Event *event = calendar()->event(uid.mid(8)); 620 Event *event = calendar()->event(uid.mid(8));
627#else 621#else
628 Event *event = calendar()->event(uid.mid(6)); 622 Event *event = calendar()->event(uid.mid(6));
629#endif 623#endif
630 //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); 624 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
631 if (!event) return; 625 if (!event) return;
632 //createEventViewer(); 626 //createEventViewer();
633 mEventViewer->setEvent(event); 627 mEventViewer->setEvent(event);
634 } else if (uid.startsWith("todo:")) { 628 } else if (uid.startsWith("todo:")) {
635#ifdef DESKTOP_VERSION 629#ifdef DESKTOP_VERSION
636 Todo *todo = calendar()->todo(uid.mid(7)); 630 Todo *todo = calendar()->todo(uid.mid(7));
637#else 631#else
638 Todo *todo = calendar()->todo(uid.mid(5)); 632 Todo *todo = calendar()->todo(uid.mid(5));
639#endif 633#endif
640 if (!todo) return; 634 if (!todo) return;
641 //createEventViewer(); 635 //createEventViewer();
642 mEventViewer->setTodo(todo); 636 mEventViewer->setTodo(todo);
643 } else { 637 } else {
644 return; 638 return;
645 639
646 } 640 }
647 mEventViewer->showMe(); 641 mEventViewer->showMe();
648 mEventViewer->raise(); 642 mEventViewer->raise();
649} 643}
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index d77e251..9d7e60b 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -1,881 +1,884 @@
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 9
10QDict<QString> *mLocaleDict = 0; 10QDict<QString> *mLocaleDict = 0;
11void setLocaleDict( QDict<QString> * dict ) 11void setLocaleDict( QDict<QString> * dict )
12{ 12{
13 mLocaleDict = dict; 13 mLocaleDict = dict;
14 14
15} 15}
16QString i18n(const char *text) 16QString i18n(const char *text)
17{ 17{
18 if ( ! mLocaleDict ) 18 if ( ! mLocaleDict )
19 return QString( text ); 19 return QString( text );
20 else { 20 else {
21 QString* ret = mLocaleDict->find(QString(text)) ; 21 QString* ret = mLocaleDict->find(QString(text)) ;
22 if ( ret == 0 ) { 22 if ( ret == 0 ) {
23 return QString( text ); 23 return QString( text );
24 } 24 }
25 else { 25 else {
26 if ( (*ret).isEmpty() ) 26 if ( (*ret).isEmpty() )
27 return QString( text ); 27 return QString( text );
28 else 28 else
29 return (*ret); 29 return (*ret);
30 } 30 }
31 } 31 }
32 32
33} 33}
34 34
35QString i18n(const char *,const char *text) 35QString i18n(const char *,const char *text)
36{ 36{
37 return i18n( text ); 37 return i18n( text );
38} 38}
39 39
40QString i18n(const char *text1, const char *textn, int num) 40QString i18n(const char *text1, const char *textn, int num)
41{ 41{
42 if ( num == 1 ) return i18n( text1 ); 42 if ( num == 1 ) return i18n( text1 );
43 else { 43 else {
44 QString text = i18n( textn ); 44 QString text = i18n( textn );
45 int pos = text.find( "%n" ); 45 int pos = text.find( "%n" );
46 if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); 46 if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) );
47 return text; 47 return text;
48 } 48 }
49} 49}
50 50
51inline void put_it_in( QChar *buffer, uint& index, const QString &s ) 51inline void put_it_in( QChar *buffer, uint& index, const QString &s )
52{ 52{
53 for ( uint l = 0; l < s.length(); l++ ) 53 for ( uint l = 0; l < s.length(); l++ )
54 buffer[index++] = s.at( l ); 54 buffer[index++] = s.at( l );
55} 55}
56 56
57inline void put_it_in( QChar *buffer, uint& index, int number ) 57inline void put_it_in( QChar *buffer, uint& index, int number )
58{ 58{
59 buffer[index++] = number / 10 + '0'; 59 buffer[index++] = number / 10 + '0';
60 buffer[index++] = number % 10 + '0'; 60 buffer[index++] = number % 10 + '0';
61} 61}
62 62
63static int readInt(const QString &str, uint &pos) 63static int readInt(const QString &str, uint &pos)
64{ 64{
65 if (!str.at(pos).isDigit()) return -1; 65 if (!str.at(pos).isDigit()) return -1;
66 int result = 0; 66 int result = 0;
67 for (; str.length() > pos && str.at(pos).isDigit(); pos++) 67 for (; str.length() > pos && str.at(pos).isDigit(); pos++)
68 { 68 {
69 result *= 10; 69 result *= 10;
70 result += str.at(pos).digitValue(); 70 result += str.at(pos).digitValue();
71 } 71 }
72 72
73 return result; 73 return result;
74} 74}
75 75
76KLocale::KLocale() : mCalendarSystem( 0 ) 76KLocale::KLocale() : mCalendarSystem( 0 )
77{ 77{
78 78
79 m_decimalSymbol = "."; 79 m_decimalSymbol = ".";
80 m_positiveSign = ""; 80 m_positiveSign = "";
81 m_negativeSign = "-"; 81 m_negativeSign = "-";
82 m_thousandsSeparator = ","; 82 m_thousandsSeparator = ",";
83 83
84 84
85 85
86 86
87 mWeekStartsMonday = true; 87 mWeekStartsMonday = true;
88 mHourF24Format = true; 88 mHourF24Format = true;
89 mIntDateFormat = 0; 89 mIntDateFormat = Default;
90 mLanguage = 0; 90 mLanguage = 0;
91 mDateFormat = "%a %Y %b %d"; 91 mDateFormat = "%a %Y %b %d";
92 mDateFormatShort = "%Y-%m-%d"; 92 mDateFormatShort = "%Y-%m-%d";
93 mTimeZoneList << i18n ("-11:00 US/Samoa") 93 mTimeZoneList << i18n ("-11:00 US/Samoa")
94 << i18n ("-10:00 US/Hawaii") 94 << i18n ("-10:00 US/Hawaii")
95 << i18n ("-09:00 US/Alaska") 95 << i18n ("-09:00 US/Alaska")
96 << i18n ("-08:00 US/Pacific") 96 << i18n ("-08:00 US/Pacific")
97 << i18n ("-07:00 US/Mountain") 97 << i18n ("-07:00 US/Mountain")
98 << i18n ("-06:00 US/Central") 98 << i18n ("-06:00 US/Central")
99 << i18n ("-05:00 US/Eastern") 99 << i18n ("-05:00 US/Eastern")
100 << i18n ("-04:00 Brazil/West") 100 << i18n ("-04:00 Brazil/West")
101 << i18n ("-03:00 Brazil/East") 101 << i18n ("-03:00 Brazil/East")
102 << i18n ("-02:00 Brazil/DeNoronha") 102 << i18n ("-02:00 Brazil/DeNoronha")
103 << i18n ("-01:00 Atlantic/Azores") 103 << i18n ("-01:00 Atlantic/Azores")
104 << i18n (" 00:00 Europe/London(UTC)") 104 << i18n (" 00:00 Europe/London(UTC)")
105 << i18n ("+01:00 Europe/Oslo(CET)") 105 << i18n ("+01:00 Europe/Oslo(CET)")
106 << i18n ("+02:00 Europe/Helsinki") 106 << i18n ("+02:00 Europe/Helsinki")
107 << i18n ("+03:00 Europe/Moscow") 107 << i18n ("+03:00 Europe/Moscow")
108 << i18n ("+04:00 Indian/Mauritius") 108 << i18n ("+04:00 Indian/Mauritius")
109 << i18n ("+05:00 Indian/Maldives") 109 << i18n ("+05:00 Indian/Maldives")
110 << i18n ("+06:00 Indian/Chagos") 110 << i18n ("+06:00 Indian/Chagos")
111 << i18n ("+07:00 Asia/Bangkok") 111 << i18n ("+07:00 Asia/Bangkok")
112 << i18n ("+08:00 Asia/Hongkong") 112 << i18n ("+08:00 Asia/Hongkong")
113 << i18n ("+09:00 Asia/Tokyo") 113 << i18n ("+09:00 Asia/Tokyo")
114 << i18n ("+10:00 Asia/Vladivostok") 114 << i18n ("+10:00 Asia/Vladivostok")
115 << i18n ("+11:00 Asia/Magadan") 115 << i18n ("+11:00 Asia/Magadan")
116 << i18n ("+12:00 Asia/Kamchatka") 116 << i18n ("+12:00 Asia/Kamchatka")
117 // << i18n (" xx:xx User defined offset") 117 // << i18n (" xx:xx User defined offset")
118 << i18n (" Local Time"); 118 << i18n (" Local Time");
119 mSouthDaylight = false; 119 mSouthDaylight = false;
120 mTimeZoneOffset = 0; 120 mTimeZoneOffset = 0;
121 daylightEnabled = false; 121 daylightEnabled = false;
122} 122}
123 123
124void KLocale::setDateFormat( QString s ) 124void KLocale::setDateFormat( QString s )
125{ 125{
126 mDateFormat = s; 126 mDateFormat = s;
127} 127}
128 128
129void KLocale::setDateFormatShort( QString s ) 129void KLocale::setDateFormatShort( QString s )
130{ 130{
131 mDateFormatShort = s; 131 mDateFormatShort = s;
132} 132}
133 133
134void KLocale::setHore24Format ( bool b ) 134void KLocale::setHore24Format ( bool b )
135{ 135{
136 mHourF24Format = b; 136 mHourF24Format = b;
137} 137}
138void KLocale::setWeekStartMonday( bool b ) 138void KLocale::setWeekStartMonday( bool b )
139{ 139{
140 mWeekStartsMonday = b; 140 mWeekStartsMonday = b;
141} 141}
142int KLocale::getIntDateFormat( ) 142KLocale::IntDateFormat KLocale::getIntDateFormat( )
143{ 143{
144 return mIntDateFormat ; 144 return mIntDateFormat;
145 145
146} 146}
147void KLocale::setIntDateFormat( int i ) 147void KLocale::setIntDateFormat( KLocale::IntDateFormat i )
148{ 148{
149 mIntDateFormat = i; 149 mIntDateFormat = i;
150} 150}
151void KLocale::setLanguage( int i ) 151void KLocale::setLanguage( int i )
152{ 152{
153 mLanguage = i; 153 mLanguage = i;
154} 154}
155QString KLocale::translate( const char *index ) const 155QString KLocale::translate( const char *index ) const
156{ 156{
157 return i18n( index ); 157 return i18n( index );
158} 158}
159 159
160QString KLocale::translate( const char *, const char *fallback) const 160QString KLocale::translate( const char *, const char *fallback) const
161{ 161{
162 return i18n( fallback ); 162 return i18n( fallback );
163} 163}
164 164
165QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const 165QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const
166{ 166{
167 const QString rst = timeFormat(); 167 const QString rst = timeFormat();
168 168
169 // only "pm/am" here can grow, the rest shrinks, but 169 // only "pm/am" here can grow, the rest shrinks, but
170 // I'm rather safe than sorry 170 // I'm rather safe than sorry
171 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; 171 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30];
172 172
173 uint index = 0; 173 uint index = 0;
174 bool escape = false; 174 bool escape = false;
175 int number = 0; 175 int number = 0;
176 176
177 for ( uint format_index = 0; format_index < rst.length(); format_index++ ) 177 for ( uint format_index = 0; format_index < rst.length(); format_index++ )
178 { 178 {
179 if ( !escape ) 179 if ( !escape )
180 { 180 {
181 if ( rst.at( format_index ).unicode() == '%' ) 181 if ( rst.at( format_index ).unicode() == '%' )
182 escape = true; 182 escape = true;
183 else 183 else
184 buffer[index++] = rst.at( format_index ); 184 buffer[index++] = rst.at( format_index );
185 } 185 }
186 else 186 else
187 { 187 {
188 switch ( rst.at( format_index ).unicode() ) 188 switch ( rst.at( format_index ).unicode() )
189 { 189 {
190 case '%': 190 case '%':
191 buffer[index++] = '%'; 191 buffer[index++] = '%';
192 break; 192 break;
193 case 'H': 193 case 'H':
194 put_it_in( buffer, index, pTime.hour() ); 194 put_it_in( buffer, index, pTime.hour() );
195 break; 195 break;
196 case 'I': 196 case 'I':
197 put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); 197 put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 );
198 break; 198 break;
199 case 'M': 199 case 'M':
200 put_it_in( buffer, index, pTime.minute() ); 200 put_it_in( buffer, index, pTime.minute() );
201 break; 201 break;
202 case 'S': 202 case 'S':
203 if (includeSecs) 203 if (includeSecs)
204 put_it_in( buffer, index, pTime.second() ); 204 put_it_in( buffer, index, pTime.second() );
205 else 205 else
206 { 206 {
207 // we remove the seperator sign before the seconds and 207 // we remove the seperator sign before the seconds and
208 // assume that works everywhere 208 // assume that works everywhere
209 --index; 209 --index;
210 break; 210 break;
211 } 211 }
212 break; 212 break;
213 case 'k': 213 case 'k':
214 number = pTime.hour(); 214 number = pTime.hour();
215 case 'l': 215 case 'l':
216 // to share the code 216 // to share the code
217 if ( rst.at( format_index ).unicode() == 'l' ) 217 if ( rst.at( format_index ).unicode() == 'l' )
218 number = (pTime.hour() + 11) % 12 + 1; 218 number = (pTime.hour() + 11) % 12 + 1;
219 if ( number / 10 ) 219 if ( number / 10 )
220 buffer[index++] = number / 10 + '0'; 220 buffer[index++] = number / 10 + '0';
221 buffer[index++] = number % 10 + '0'; 221 buffer[index++] = number % 10 + '0';
222 break; 222 break;
223 case 'p': 223 case 'p':
224 { 224 {
225 QString s; 225 QString s;
226 if ( pTime.hour() >= 12 ) 226 if ( pTime.hour() >= 12 )
227 put_it_in( buffer, index, i18n("pm") ); 227 put_it_in( buffer, index, i18n("pm") );
228 else 228 else
229 put_it_in( buffer, index, i18n("am") ); 229 put_it_in( buffer, index, i18n("am") );
230 break; 230 break;
231 } 231 }
232 default: 232 default:
233 buffer[index++] = rst.at( format_index ); 233 buffer[index++] = rst.at( format_index );
234 break; 234 break;
235 } 235 }
236 escape = false; 236 escape = false;
237 } 237 }
238 } 238 }
239 QString ret( buffer, index ); 239 QString ret( buffer, index );
240 delete [] buffer; 240 delete [] buffer;
241 return ret; 241 return ret;
242} 242}
243 243
244QString KLocale::formatDate(const QDate &pDate, bool shortFormat) const 244QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const
245{ 245{
246 const QString rst = shortFormat?dateFormatShort():dateFormat(); 246 const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat);
247 247
248 // I'm rather safe than sorry 248 // I'm rather safe than sorry
249 QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; 249 QChar *buffer = new QChar[rst.length() * 3 / 2 + 50];
250 250
251 unsigned int index = 0; 251 unsigned int index = 0;
252 bool escape = false; 252 bool escape = false;
253 int number = 0; 253 int number = 0;
254 254
255 for ( uint format_index = 0; format_index < rst.length(); ++format_index ) 255 for ( uint format_index = 0; format_index < rst.length(); ++format_index )
256 { 256 {
257 if ( !escape ) 257 if ( !escape )
258 { 258 {
259 if ( rst.at( format_index ).unicode() == '%' ) 259 if ( rst.at( format_index ).unicode() == '%' )
260 escape = true; 260 escape = true;
261 else 261 else
262 buffer[index++] = rst.at( format_index ); 262 buffer[index++] = rst.at( format_index );
263 } 263 }
264 else 264 else
265 { 265 {
266 switch ( rst.at( format_index ).unicode() ) 266 switch ( rst.at( format_index ).unicode() )
267 { 267 {
268 case '%': 268 case '%':
269 buffer[index++] = '%'; 269 buffer[index++] = '%';
270 break; 270 break;
271 case 'Y': 271 case 'Y':
272 put_it_in( buffer, index, pDate.year() / 100 ); 272 put_it_in( buffer, index, pDate.year() / 100 );
273 case 'y': 273 case 'y':
274 put_it_in( buffer, index, pDate.year() % 100 ); 274 put_it_in( buffer, index, pDate.year() % 100 );
275 break; 275 break;
276 case 'n': 276 case 'n':
277 number = pDate.month(); 277 number = pDate.month();
278 case 'e': 278 case 'e':
279 // to share the code 279 // to share the code
280 if ( rst.at( format_index ).unicode() == 'e' ) 280 if ( rst.at( format_index ).unicode() == 'e' )
281 number = pDate.day(); 281 number = pDate.day();
282 if ( number / 10 ) 282 if ( number / 10 )
283 buffer[index++] = number / 10 + '0'; 283 buffer[index++] = number / 10 + '0';
284 buffer[index++] = number % 10 + '0'; 284 buffer[index++] = number % 10 + '0';
285 break; 285 break;
286 case 'm': 286 case 'm':
287 put_it_in( buffer, index, pDate.month() ); 287 put_it_in( buffer, index, pDate.month() );
288 break; 288 break;
289 case 'b': 289 case 'b':
290 put_it_in( buffer, index, monthName(pDate.month(), true) ); 290 put_it_in( buffer, index, monthName(pDate.month(), true) );
291 break; 291 break;
292 case 'B': 292 case 'B':
293 put_it_in( buffer, index, monthName(pDate.month(), false) ); 293 put_it_in( buffer, index, monthName(pDate.month(), false) );
294 break; 294 break;
295 case 'd': 295 case 'd':
296 put_it_in( buffer, index, pDate.day() ); 296 put_it_in( buffer, index, pDate.day() );
297 break; 297 break;
298 case 'a': 298 case 'a':
299 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); 299 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) );
300 break; 300 break;
301 case 'A': 301 case 'A':
302 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); 302 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) );
303 break; 303 break;
304 default: 304 default:
305 buffer[index++] = rst.at( format_index ); 305 buffer[index++] = rst.at( format_index );
306 break; 306 break;
307 } 307 }
308 escape = false; 308 escape = false;
309 } 309 }
310 } 310 }
311 QString ret( buffer, index ); 311 QString ret( buffer, index );
312 delete [] buffer; 312 delete [] buffer;
313 return ret; 313 return ret;
314} 314}
315 315
316QString KLocale::formatDateTime(const QDateTime &pDateTime, 316QString KLocale::formatDateTime(const QDateTime &pDateTime,
317 bool shortFormat, 317 bool shortFormat,
318 bool includeSeconds) const 318 bool includeSeconds) const
319{ 319{
320 return QString( "%1 %2") 320 return QString( "%1 %2")
321 .arg( formatDate( pDateTime.date(), shortFormat ) ) 321 .arg( formatDate( pDateTime.date(), shortFormat ) )
322 .arg( formatTime( pDateTime.time(), includeSeconds ) ); 322 .arg( formatTime( pDateTime.time(), includeSeconds ) );
323} 323}
324 324
325QString KLocale::formatDateTime(const QDateTime &pDateTime) const 325QString KLocale::formatDateTime(const QDateTime &pDateTime) const
326{ 326{
327 return formatDateTime(pDateTime, true); 327 return formatDateTime(pDateTime, true);
328} 328}
329 329
330QDate KLocale::readDate(const QString &intstr, bool* ok) const 330QDate KLocale::readDate(const QString &intstr, bool* ok) const
331{ 331{
332 QDate date; 332 QDate date;
333 date = readDate(intstr, true, ok); 333 date = readDate(intstr, true, ok);
334 if (date.isValid()) return date; 334 if (date.isValid()) return date;
335 return readDate(intstr, false, ok); 335 return readDate(intstr, false, ok);
336} 336}
337 337
338QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const 338QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const
339{ 339{
340 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); 340 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace();
341 return readDate( intstr, fmt, ok ); 341 return readDate( intstr, fmt, ok );
342} 342}
343 343
344QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const 344QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const
345{ 345{
346 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; 346 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl;
347 QString str = intstr.simplifyWhiteSpace().lower(); 347 QString str = intstr.simplifyWhiteSpace().lower();
348 int day = -1, month = -1; 348 int day = -1, month = -1;
349 // allow the year to be omitted if not in the format 349 // allow the year to be omitted if not in the format
350 int year = QDate::currentDate().year(); 350 int year = QDate::currentDate().year();
351 uint strpos = 0; 351 uint strpos = 0;
352 uint fmtpos = 0; 352 uint fmtpos = 0;
353 353
354 while (fmt.length() > fmtpos || str.length() > strpos) 354 while (fmt.length() > fmtpos || str.length() > strpos)
355 { 355 {
356 if ( !(fmt.length() > fmtpos && str.length() > strpos) ) 356 if ( !(fmt.length() > fmtpos && str.length() > strpos) )
357 goto error; 357 goto error;
358 358
359 QChar c = fmt.at(fmtpos++); 359 QChar c = fmt.at(fmtpos++);
360 360
361 if (c != '%') { 361 if (c != '%') {
362 if (c.isSpace()) 362 if (c.isSpace())
363 strpos++; 363 strpos++;
364 else if (c != str.at(strpos++)) 364 else if (c != str.at(strpos++))
365 goto error; 365 goto error;
366 continue; 366 continue;
367 } 367 }
368 368
369 // remove space at the begining 369 // remove space at the begining
370 if (str.length() > strpos && str.at(strpos).isSpace()) 370 if (str.length() > strpos && str.at(strpos).isSpace())
371 strpos++; 371 strpos++;
372 372
373 c = fmt.at(fmtpos++); 373 c = fmt.at(fmtpos++);
374 switch (c) 374 switch (c)
375 { 375 {
376 case 'a': 376 case 'a':
377 case 'A': 377 case 'A':
378 // this will just be ignored 378 // this will just be ignored
379 { // Cristian Tache: porting to Win: Block added because of "j" redefinition 379 { // Cristian Tache: porting to Win: Block added because of "j" redefinition
380 for (int j = 1; j < 8; j++) { 380 for (int j = 1; j < 8; j++) {
381 QString s = weekDayName(j, c == 'a').lower(); 381 QString s = weekDayName(j, c == 'a').lower();
382 int len = s.length(); 382 int len = s.length();
383 if (str.mid(strpos, len) == s) 383 if (str.mid(strpos, len) == s)
384 strpos += len; 384 strpos += len;
385 } 385 }
386 break; 386 break;
387 } 387 }
388 case 'b': 388 case 'b':
389 case 'B': 389 case 'B':
390 { // Cristian Tache: porting to Win: Block added because of "j" redefinition 390 { // Cristian Tache: porting to Win: Block added because of "j" redefinition
391 for (int j = 1; j < 13; j++) { 391 for (int j = 1; j < 13; j++) {
392 QString s = monthName(j, c == 'b').lower(); 392 QString s = monthName(j, c == 'b').lower();
393 int len = s.length(); 393 int len = s.length();
394 if (str.mid(strpos, len) == s) { 394 if (str.mid(strpos, len) == s) {
395 month = j; 395 month = j;
396 strpos += len; 396 strpos += len;
397 } 397 }
398 } 398 }
399 break; 399 break;
400 } 400 }
401 case 'd': 401 case 'd':
402 case 'e': 402 case 'e':
403 day = readInt(str, strpos); 403 day = readInt(str, strpos);
404 if (day < 1 || day > 31) 404 if (day < 1 || day > 31)
405 goto error; 405 goto error;
406 406
407 break; 407 break;
408 408
409 case 'n': 409 case 'n':
410 case 'm': 410 case 'm':
411 month = readInt(str, strpos); 411 month = readInt(str, strpos);
412 if (month < 1 || month > 12) 412 if (month < 1 || month > 12)
413 goto error; 413 goto error;
414 414
415 break; 415 break;
416 416
417 case 'Y': 417 case 'Y':
418 case 'y': 418 case 'y':
419 year = readInt(str, strpos); 419 year = readInt(str, strpos);
420 if (year < 0) 420 if (year < 0)
421 goto error; 421 goto error;
422 // Qt treats a year in the range 0-100 as 1900-1999. 422 // Qt treats a year in the range 0-100 as 1900-1999.
423 // It is nicer for the user if we treat 0-68 as 2000-2068 423 // It is nicer for the user if we treat 0-68 as 2000-2068
424 if (year < 69) 424 if (year < 69)
425 year += 2000; 425 year += 2000;
426 else if (c == 'y') 426 else if (c == 'y')
427 year += 1900; 427 year += 1900;
428 428
429 break; 429 break;
430 } 430 }
431 } 431 }
432 //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; 432 //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl;
433 if ( year != -1 && month != -1 && day != -1 ) 433 if ( year != -1 && month != -1 && day != -1 )
434 { 434 {
435 if (ok) *ok = true; 435 if (ok) *ok = true;
436 return QDate(year, month, day); 436 return QDate(year, month, day);
437 } 437 }
438 error: 438 error:
439 if (ok) *ok = false; 439 if (ok) *ok = false;
440 return QDate(); // invalid date 440 return QDate(); // invalid date
441} 441}
442 442
443QTime KLocale::readTime(const QString &intstr, bool *ok) const 443QTime KLocale::readTime(const QString &intstr, bool *ok) const
444{ 444{
445 QTime _time; 445 QTime _time;
446 _time = readTime(intstr, true, ok); 446 _time = readTime(intstr, true, ok);
447 if (_time.isValid()) return _time; 447 if (_time.isValid()) return _time;
448 return readTime(intstr, false, ok); 448 return readTime(intstr, false, ok);
449} 449}
450 450
451QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const 451QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
452{ 452{
453 QString str = intstr.simplifyWhiteSpace().lower(); 453 QString str = intstr.simplifyWhiteSpace().lower();
454 QString Format = timeFormat().simplifyWhiteSpace(); 454 QString Format = timeFormat().simplifyWhiteSpace();
455 if (!seconds) 455 if (!seconds)
456 Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); 456 Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null);
457 457
458 int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds 458 int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds
459 bool g_12h = false; 459 bool g_12h = false;
460 bool pm = false; 460 bool pm = false;
461 uint strpos = 0; 461 uint strpos = 0;
462 uint Formatpos = 0; 462 uint Formatpos = 0;
463 463
464 while (Format.length() > Formatpos || str.length() > strpos) 464 while (Format.length() > Formatpos || str.length() > strpos)
465 { 465 {
466 if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; 466 if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error;
467 467
468 QChar c = Format.at(Formatpos++); 468 QChar c = Format.at(Formatpos++);
469 469
470 if (c != '%') 470 if (c != '%')
471 { 471 {
472 if (c.isSpace()) 472 if (c.isSpace())
473 strpos++; 473 strpos++;
474 else if (c != str.at(strpos++)) 474 else if (c != str.at(strpos++))
475 goto error; 475 goto error;
476 continue; 476 continue;
477 } 477 }
478 478
479 // remove space at the begining 479 // remove space at the begining
480 if (str.length() > strpos && str.at(strpos).isSpace()) 480 if (str.length() > strpos && str.at(strpos).isSpace())
481 strpos++; 481 strpos++;
482 482
483 c = Format.at(Formatpos++); 483 c = Format.at(Formatpos++);
484 switch (c) 484 switch (c)
485 { 485 {
486 case 'p': 486 case 'p':
487 { 487 {
488 QString s; 488 QString s;
489 s = i18n("pm").lower(); 489 s = i18n("pm").lower();
490 int len = s.length(); 490 int len = s.length();
491 if (str.mid(strpos, len) == s) 491 if (str.mid(strpos, len) == s)
492 { 492 {
493 pm = true; 493 pm = true;
494 strpos += len; 494 strpos += len;
495 } 495 }
496 else 496 else
497 { 497 {
498 s = i18n("am").lower(); 498 s = i18n("am").lower();
499 len = s.length(); 499 len = s.length();
500 if (str.mid(strpos, len) == s) { 500 if (str.mid(strpos, len) == s) {
501 pm = false; 501 pm = false;
502 strpos += len; 502 strpos += len;
503 } 503 }
504 else 504 else
505 goto error; 505 goto error;
506 } 506 }
507 } 507 }
508 break; 508 break;
509 509
510 case 'k': 510 case 'k':
511 case 'H': 511 case 'H':
512 g_12h = false; 512 g_12h = false;
513 hour = readInt(str, strpos); 513 hour = readInt(str, strpos);
514 if (hour < 0 || hour > 23) 514 if (hour < 0 || hour > 23)
515 goto error; 515 goto error;
516 516
517 break; 517 break;
518 518
519 case 'l': 519 case 'l':
520 case 'I': 520 case 'I':
521 g_12h = true; 521 g_12h = true;
522 hour = readInt(str, strpos); 522 hour = readInt(str, strpos);
523 if (hour < 1 || hour > 12) 523 if (hour < 1 || hour > 12)
524 goto error; 524 goto error;
525 525
526 break; 526 break;
527 527
528 case 'M': 528 case 'M':
529 minute = readInt(str, strpos); 529 minute = readInt(str, strpos);
530 if (minute < 0 || minute > 59) 530 if (minute < 0 || minute > 59)
531 goto error; 531 goto error;
532 532
533 break; 533 break;
534 534
535 case 'S': 535 case 'S':
536 second = readInt(str, strpos); 536 second = readInt(str, strpos);
537 if (second < 0 || second > 59) 537 if (second < 0 || second > 59)
538 goto error; 538 goto error;
539 539
540 break; 540 break;
541 } 541 }
542 } 542 }
543 if (g_12h) 543 if (g_12h)
544 { 544 {
545 hour %= 12; 545 hour %= 12;
546 if (pm) hour += 12; 546 if (pm) hour += 12;
547 } 547 }
548 548
549 if (ok) *ok = true; 549 if (ok) *ok = true;
550 return QTime(hour, minute, second); 550 return QTime(hour, minute, second);
551 551
552 error: 552 error:
553 if (ok) *ok = false; 553 if (ok) *ok = false;
554 return QTime(-1, -1, -1); // return invalid date if it didn't work 554 return QTime(-1, -1, -1); // return invalid date if it didn't work
555 // This will be removed in the near future, since it gives a warning on stderr. 555 // This will be removed in the near future, since it gives a warning on stderr.
556 // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. 556 // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime.
557} 557}
558 558
559bool KLocale::use12Clock() const 559bool KLocale::use12Clock() const
560{ 560{
561 return !mHourF24Format ;; 561 return !mHourF24Format ;;
562} 562}
563 563
564bool KLocale::weekStartsMonday() const 564bool KLocale::weekStartsMonday() const
565{ 565{
566 return mWeekStartsMonday; 566 return mWeekStartsMonday;
567} 567}
568 568
569int KLocale::weekStartDay() const 569int KLocale::weekStartDay() const
570{ 570{
571 if ( mWeekStartsMonday ) 571 if ( mWeekStartsMonday )
572 return 1; 572 return 1;
573 return 7; 573 return 7;
574} 574}
575 575
576QString KLocale::weekDayName(int i,bool shortName) const 576QString KLocale::weekDayName(int i,bool shortName) const
577{ 577{
578 if ( shortName ) 578 if ( shortName )
579 switch ( i ) 579 switch ( i )
580 { 580 {
581 case 1: return i18n("Monday", "Mon"); 581 case 1: return i18n("Monday", "Mon");
582 case 2: return i18n("Tuesday", "Tue"); 582 case 2: return i18n("Tuesday", "Tue");
583 case 3: return i18n("Wednesday", "Wed"); 583 case 3: return i18n("Wednesday", "Wed");
584 case 4: return i18n("Thursday", "Thu"); 584 case 4: return i18n("Thursday", "Thu");
585 case 5: return i18n("Friday", "Fri"); 585 case 5: return i18n("Friday", "Fri");
586 case 6: return i18n("Saturday", "Sat"); 586 case 6: return i18n("Saturday", "Sat");
587 case 7: return i18n("Sunday", "Sun"); 587 case 7: return i18n("Sunday", "Sun");
588 } 588 }
589 else 589 else
590 switch ( i ) 590 switch ( i )
591 { 591 {
592 case 1: return i18n("Monday"); 592 case 1: return i18n("Monday");
593 case 2: return i18n("Tuesday"); 593 case 2: return i18n("Tuesday");
594 case 3: return i18n("Wednesday"); 594 case 3: return i18n("Wednesday");
595 case 4: return i18n("Thursday"); 595 case 4: return i18n("Thursday");
596 case 5: return i18n("Friday"); 596 case 5: return i18n("Friday");
597 case 6: return i18n("Saturday"); 597 case 6: return i18n("Saturday");
598 case 7: return i18n("Sunday"); 598 case 7: return i18n("Sunday");
599 } 599 }
600 600
601 return QString::null; 601 return QString::null;
602} 602}
603 603
604QString KLocale::monthName(int i,bool shortName) const 604QString KLocale::monthName(int i,bool shortName) const
605{ 605{
606 if ( shortName ) 606 if ( shortName )
607 switch ( i ) 607 switch ( i )
608 { 608 {
609 case 1: return i18n("January", "Jan"); 609 case 1: return i18n("January", "Jan");
610 case 2: return i18n("February", "Feb"); 610 case 2: return i18n("February", "Feb");
611 case 3: return i18n("March", "Mar"); 611 case 3: return i18n("March", "Mar");
612 case 4: return i18n("April", "Apr"); 612 case 4: return i18n("April", "Apr");
613 case 5: return i18n("May short", "May"); 613 case 5: return i18n("May short", "May");
614 case 6: return i18n("June", "Jun"); 614 case 6: return i18n("June", "Jun");
615 case 7: return i18n("July", "Jul"); 615 case 7: return i18n("July", "Jul");
616 case 8: return i18n("August", "Aug"); 616 case 8: return i18n("August", "Aug");
617 case 9: return i18n("September", "Sep"); 617 case 9: return i18n("September", "Sep");
618 case 10: return i18n("October", "Oct"); 618 case 10: return i18n("October", "Oct");
619 case 11: return i18n("November", "Nov"); 619 case 11: return i18n("November", "Nov");
620 case 12: return i18n("December", "Dec"); 620 case 12: return i18n("December", "Dec");
621 } 621 }
622 else 622 else
623 switch (i) 623 switch (i)
624 { 624 {
625 case 1: return i18n("January"); 625 case 1: return i18n("January");
626 case 2: return i18n("February"); 626 case 2: return i18n("February");
627 case 3: return i18n("March"); 627 case 3: return i18n("March");
628 case 4: return i18n("April"); 628 case 4: return i18n("April");
629 case 5: return i18n("May long", "May"); 629 case 5: return i18n("May long", "May");
630 case 6: return i18n("June"); 630 case 6: return i18n("June");
631 case 7: return i18n("July"); 631 case 7: return i18n("July");
632 case 8: return i18n("August"); 632 case 8: return i18n("August");
633 case 9: return i18n("September"); 633 case 9: return i18n("September");
634 case 10: return i18n("October"); 634 case 10: return i18n("October");
635 case 11: return i18n("November"); 635 case 11: return i18n("November");
636 case 12: return i18n("December"); 636 case 12: return i18n("December");
637 } 637 }
638 638
639 return QString::null; 639 return QString::null;
640} 640}
641 641
642QString KLocale::country() const 642QString KLocale::country() const
643{ 643{
644 return QString::null; 644 return QString::null;
645} 645}
646 646
647QString KLocale::dateFormat() const 647QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
648{ 648{
649 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
650
649 if ( QApplication::desktop()->width() < 480 ) { 651 if ( QApplication::desktop()->width() < 480 ) {
650 if ( mIntDateFormat == 0 ) 652 if ( dformat == Default )
651 return "%a %d %b %Y"; 653 return "%a %d %b %Y";
652 else if ( mIntDateFormat == 1 ) 654 else if ( dformat == Format1 )
653 return "%a %b %d %Y"; 655 return "%a %b %d %Y";
654 else if ( mIntDateFormat == 2 ) 656 else if ( dformat == ISODate )
655 return "%a %Y %b %d"; 657 return "%a %Y %b %d";
656 } else { 658 } else {
657 659
658 if ( mIntDateFormat == 0 ) 660 if ( dformat == Default )
659 return "%A %d %B %Y"; 661 return "%A %d %B %Y";
660 else if ( mIntDateFormat == 1 ) 662 else if ( dformat == Format1 )
661 return "%A %B %d %Y"; 663 return "%A %B %d %Y";
662 else if ( mIntDateFormat == 2 ) 664 else if ( dformat == ISODate )
663 return "%A %Y %B %d"; 665 return "%A %Y %B %d";
664 } 666 }
665 return mDateFormat ; 667 return mDateFormat ;
666} 668}
667 669
668QString KLocale::dateFormatShort() const 670QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const
669{ 671{
672 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
670 673
671 if ( mIntDateFormat == 0 ) 674 if ( dformat == Default )
672 return "%d.%m.%Y"; 675 return "%d.%m.%Y";
673 else if ( mIntDateFormat == 1 ) 676 else if ( dformat == Format1 )
674 return "%m.%d.%Y"; 677 return "%m.%d.%Y";
675 else if ( mIntDateFormat == 2 ) 678 else if ( dformat == ISODate ) // = Qt::ISODate
676 return "%Y-%m-%d"; 679 return "%Y-%m-%d";
677 return mDateFormatShort ; 680 return mDateFormatShort ;
678 681
679} 682}
680 683
681 684
682QString KLocale::timeFormat() const 685QString KLocale::timeFormat() const
683{ 686{
684 if ( mHourF24Format) 687 if ( mHourF24Format)
685 return "%H:%M:%S"; 688 return "%H:%M:%S";
686 return "%I:%M:%S%p"; 689 return "%I:%M:%S%p";
687} 690}
688 691
689void KLocale::insertCatalogue ( const QString & ) 692void KLocale::insertCatalogue ( const QString & )
690{ 693{
691} 694}
692 695
693KCalendarSystem *KLocale::calendar() 696KCalendarSystem *KLocale::calendar()
694{ 697{
695 if ( !mCalendarSystem ) { 698 if ( !mCalendarSystem ) {
696 mCalendarSystem = new KCalendarSystemGregorian; 699 mCalendarSystem = new KCalendarSystemGregorian;
697 } 700 }
698 701
699 return mCalendarSystem; 702 return mCalendarSystem;
700} 703}
701 704
702int KLocale::timezoneOffset( QString timeZone ) 705int KLocale::timezoneOffset( QString timeZone )
703{ 706{
704 int ret = 1001; 707 int ret = 1001;
705 int index = mTimeZoneList.findIndex( timeZone ); 708 int index = mTimeZoneList.findIndex( timeZone );
706 if ( index < 24 ) 709 if ( index < 24 )
707 ret = ( index-11 ) * 60 ; 710 ret = ( index-11 ) * 60 ;
708 return ret; 711 return ret;
709} 712}
710 713
711QStringList KLocale::timeZoneList() const 714QStringList KLocale::timeZoneList() const
712{ 715{
713 return mTimeZoneList; 716 return mTimeZoneList;
714} 717}
715void KLocale::setTimezone( const QString &timeZone ) 718void KLocale::setTimezone( const QString &timeZone )
716{ 719{
717 mTimeZoneOffset = timezoneOffset( timeZone ); 720 mTimeZoneOffset = timezoneOffset( timeZone );
718} 721}
719 722
720void KLocale::setDaylightSaving( bool b, int start , int end ) 723void KLocale::setDaylightSaving( bool b, int start , int end )
721{ 724{
722 daylightEnabled = b; 725 daylightEnabled = b;
723 daylightStart = start; 726 daylightStart = start;
724 daylightEnd = end; 727 daylightEnd = end;
725 mSouthDaylight = (end < start); 728 mSouthDaylight = (end < start);
726 // qDebug("klocale daylight %d %d %d ", b, start , end ); 729 // qDebug("klocale daylight %d %d %d ", b, start , end );
727} 730}
728 731
729int KLocale::localTimeOffset( const QDateTime &dt ) 732int KLocale::localTimeOffset( const QDateTime &dt )
730{ 733{
731 bool addDaylight = false; 734 bool addDaylight = false;
732 if ( daylightEnabled ) { 735 if ( daylightEnabled ) {
733 int d_end, d_start; 736 int d_end, d_start;
734 int dayofyear = dt.date().dayOfYear(); 737 int dayofyear = dt.date().dayOfYear();
735 int year = dt.date().year(); 738 int year = dt.date().year();
736 int add = 0; 739 int add = 0;
737 if ( QDate::leapYear(year) ) 740 if ( QDate::leapYear(year) )
738 add = 1; 741 add = 1;
739 QDate date ( year,1,1 ); 742 QDate date ( year,1,1 );
740 if ( daylightEnd > 59 ) 743 if ( daylightEnd > 59 )
741 d_end = daylightEnd +add; 744 d_end = daylightEnd +add;
742 else 745 else
743 d_end = daylightEnd; 746 d_end = daylightEnd;
744 if ( daylightStart > 59 ) 747 if ( daylightStart > 59 )
745 d_start = daylightStart +add; 748 d_start = daylightStart +add;
746 else 749 else
747 d_start = daylightStart; 750 d_start = daylightStart;
748 QDate s_date = date.addDays( d_start -1 ); 751 QDate s_date = date.addDays( d_start -1 );
749 QDate e_date = date.addDays( d_end -1 ); 752 QDate e_date = date.addDays( d_end -1 );
750 int dof = s_date.dayOfWeek(); 753 int dof = s_date.dayOfWeek();
751 if ( dof < 7 ) 754 if ( dof < 7 )
752 s_date = s_date.addDays( -dof ); 755 s_date = s_date.addDays( -dof );
753 dof = e_date.dayOfWeek(); 756 dof = e_date.dayOfWeek();
754 if ( dof < 7 ) 757 if ( dof < 7 )
755 e_date = e_date.addDays( -dof ); 758 e_date = e_date.addDays( -dof );
756 QTime startTime ( 3,0,0 ); 759 QTime startTime ( 3,0,0 );
757 QDateTime startDt( s_date, startTime ); 760 QDateTime startDt( s_date, startTime );
758 QDateTime endDt( e_date, startTime ); 761 QDateTime endDt( e_date, startTime );
759 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); 762 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( ));
760 if ( mSouthDaylight ) { 763 if ( mSouthDaylight ) {
761 if ( ! ( endDt < dt && dt < startDt) ) 764 if ( ! ( endDt < dt && dt < startDt) )
762 addDaylight = true; 765 addDaylight = true;
763 } else { 766 } else {
764 if ( startDt < dt && dt < endDt ) 767 if ( startDt < dt && dt < endDt )
765 addDaylight = true; 768 addDaylight = true;
766 769
767 770
768 } 771 }
769 } 772 }
770 int addMin = 0; 773 int addMin = 0;
771 if ( addDaylight ) 774 if ( addDaylight )
772 addMin = 60; 775 addMin = 60;
773 return mTimeZoneOffset + addMin; 776 return mTimeZoneOffset + addMin;
774} 777}
775// ****************************************************************** 778// ******************************************************************
776// added LR 779// added LR
777QString KLocale::formatNumber(double num, int precision) const 780QString KLocale::formatNumber(double num, int precision) const
778{ 781{
779 bool neg = num < 0; 782 bool neg = num < 0;
780 if (precision == -1) precision = 2; 783 if (precision == -1) precision = 2;
781 QString res = QString::number(neg?-num:num, 'f', precision); 784 QString res = QString::number(neg?-num:num, 'f', precision);
782 int pos = res.find('.'); 785 int pos = res.find('.');
783 if (pos == -1) pos = res.length(); 786 if (pos == -1) pos = res.length();
784 else res.replace(pos, 1, decimalSymbol()); 787 else res.replace(pos, 1, decimalSymbol());
785 788
786 while (0 < (pos -= 3)) 789 while (0 < (pos -= 3))
787 res.insert(pos, thousandsSeparator()); // thousand sep 790 res.insert(pos, thousandsSeparator()); // thousand sep
788 791
789 // How can we know where we should put the sign? 792 // How can we know where we should put the sign?
790 res.prepend(neg?negativeSign():positiveSign()); 793 res.prepend(neg?negativeSign():positiveSign());
791 794
792 return res; 795 return res;
793} 796}
794QString KLocale::formatNumber(const QString &numStr) const 797QString KLocale::formatNumber(const QString &numStr) const
795{ 798{
796 return formatNumber(numStr.toDouble()); 799 return formatNumber(numStr.toDouble());
797} 800}
798double KLocale::readNumber(const QString &_str, bool * ok) const 801double KLocale::readNumber(const QString &_str, bool * ok) const
799{ 802{
800 QString str = _str.stripWhiteSpace(); 803 QString str = _str.stripWhiteSpace();
801 bool neg = str.find(negativeSign()) == 0; 804 bool neg = str.find(negativeSign()) == 0;
802 if (neg) 805 if (neg)
803 str.remove( 0, negativeSign().length() ); 806 str.remove( 0, negativeSign().length() );
804 807
805 /* will hold the scientific notation portion of the number. 808 /* will hold the scientific notation portion of the number.
806 Example, with 2.34E+23, exponentialPart == "E+23" 809 Example, with 2.34E+23, exponentialPart == "E+23"
807 */ 810 */
808 QString exponentialPart; 811 QString exponentialPart;
809 int EPos; 812 int EPos;
810 813
811 EPos = str.find('E', 0, false); 814 EPos = str.find('E', 0, false);
812 815
813 if (EPos != -1) 816 if (EPos != -1)
814 { 817 {
815 exponentialPart = str.mid(EPos); 818 exponentialPart = str.mid(EPos);
816 str = str.left(EPos); 819 str = str.left(EPos);
817 } 820 }
818 821
819 int pos = str.find(decimalSymbol()); 822 int pos = str.find(decimalSymbol());
820 QString major; 823 QString major;
821 QString minor; 824 QString minor;
822 if ( pos == -1 ) 825 if ( pos == -1 )
823 major = str; 826 major = str;
824 else 827 else
825 { 828 {
826 major = str.left(pos); 829 major = str.left(pos);
827 minor = str.mid(pos + decimalSymbol().length()); 830 minor = str.mid(pos + decimalSymbol().length());
828 } 831 }
829 832
830 // Remove thousand separators 833 // Remove thousand separators
831 int thlen = thousandsSeparator().length(); 834 int thlen = thousandsSeparator().length();
832 int lastpos = 0; 835 int lastpos = 0;
833 while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) 836 while ( ( pos = major.find( thousandsSeparator() ) ) > 0 )
834 { 837 {
835 // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N 838 // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N
836 int fromEnd = major.length() - pos; 839 int fromEnd = major.length() - pos;
837 if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error 840 if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error
838 || pos - lastpos > 3 // More than 3 digits between two separators -> error 841 || pos - lastpos > 3 // More than 3 digits between two separators -> error
839 || pos == 0 // Can't start with a separator 842 || pos == 0 // Can't start with a separator
840 || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators 843 || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators
841 { 844 {
842 if (ok) *ok = false; 845 if (ok) *ok = false;
843 return 0.0; 846 return 0.0;
844 } 847 }
845 848
846 lastpos = pos; 849 lastpos = pos;
847 major.remove( pos, thlen ); 850 major.remove( pos, thlen );
848 } 851 }
849 if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator 852 if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator
850 { 853 {
851 if (ok) *ok = false; 854 if (ok) *ok = false;
852 return 0.0; 855 return 0.0;
853 } 856 }
854 857
855 QString tot; 858 QString tot;
856 if (neg) tot = '-'; 859 if (neg) tot = '-';
857 860
858 tot += major + '.' + minor + exponentialPart; 861 tot += major + '.' + minor + exponentialPart;
859 862
860 return tot.toDouble(ok); 863 return tot.toDouble(ok);
861} 864}
862QString KLocale::decimalSymbol() const 865QString KLocale::decimalSymbol() const
863{ 866{
864 867
865 return m_decimalSymbol; 868 return m_decimalSymbol;
866} 869}
867 870
868QString KLocale::thousandsSeparator() const 871QString KLocale::thousandsSeparator() const
869{ 872{
870 873
871 return m_thousandsSeparator; 874 return m_thousandsSeparator;
872} 875}
873QString KLocale::positiveSign() const 876QString KLocale::positiveSign() const
874{ 877{
875 return m_positiveSign; 878 return m_positiveSign;
876} 879}
877 880
878QString KLocale::negativeSign() const 881QString KLocale::negativeSign() const
879{ 882{
880 return m_negativeSign; 883 return m_negativeSign;
881} 884}
diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h
index 7470cd2..f6c0253 100644
--- a/microkde/kdecore/klocale.h
+++ b/microkde/kdecore/klocale.h
@@ -1,110 +1,112 @@
1#ifndef MINIKDE_KLOCALE_H 1#ifndef MINIKDE_KLOCALE_H
2#define MINIKDE_KLOCALE_H 2#define MINIKDE_KLOCALE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6#include <qdatetime.h> 6#include <qdatetime.h>
7#include <qdict.h> 7#include <qdict.h>
8 8
9#ifndef I18N_NOOP 9#ifndef I18N_NOOP
10#define I18N_NOOP(x) (x) 10#define I18N_NOOP(x) (x)
11#endif 11#endif
12 12
13class KCalendarSystem; 13class KCalendarSystem;
14void setLocaleDict( QDict<QString> * dict ); 14void setLocaleDict( QDict<QString> * dict );
15QString i18n(const char *text); 15QString i18n(const char *text);
16QString i18n(const char *hint, const char *text); 16QString i18n(const char *hint, const char *text);
17QString i18n(const char *text1, const char *textn, int num); 17QString i18n(const char *text1, const char *textn, int num);
18 18
19// Qt3's uic generates i18n( "msg", "comment" ) calls which conflict 19// Qt3's uic generates i18n( "msg", "comment" ) calls which conflict
20// with our i18n method. we use uic -tr tr2i18n to redirect 20// with our i18n method. we use uic -tr tr2i18n to redirect
21// to the right i18n() function 21// to the right i18n() function
22inline QString tr2i18n(const char* message, const char* =0) { 22inline QString tr2i18n(const char* message, const char* =0) {
23 return i18n( message); 23 return i18n( message);
24} 24}
25 25
26class KLocale 26class KLocale
27{ 27{
28 public: 28 public:
29 KLocale(); 29 KLocale();
30 30
31 QString formatNumber(double num, int precision = -1) const; 31 QString formatNumber(double num, int precision = -1) const;
32 QString formatNumber(const QString &numStr) const; 32 QString formatNumber(const QString &numStr) const;
33 double readNumber(const QString &numStr, bool * ok = 0) const; 33 double readNumber(const QString &numStr, bool * ok = 0) const;
34 34
35 QString decimalSymbol() const; 35 QString decimalSymbol() const;
36 QString thousandsSeparator() const; 36 QString thousandsSeparator() const;
37 QString positiveSign() const; 37 QString positiveSign() const;
38 QString negativeSign() const; 38 QString negativeSign() const;
39 39
40 40
41 QString translate( const char *index ) const; 41 QString translate( const char *index ) const;
42 QString translate( const char *index, const char *fallback) const; 42 QString translate( const char *index, const char *fallback) const;
43 43
44 QString formatDate(const QDate &pDate, bool shortFormat = false) const; 44 enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 };
45
46 QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const;
45 QString formatTime(const QTime &pTime, bool includeSecs = false) const; 47 QString formatTime(const QTime &pTime, bool includeSecs = false) const;
46 QString formatDateTime(const QDateTime &pDateTime) const; 48 QString formatDateTime(const QDateTime &pDateTime) const;
47 QString formatDateTime(const QDateTime &pDateTime, 49 QString formatDateTime(const QDateTime &pDateTime,
48 bool shortFormat, 50 bool shortFormat,
49 bool includeSecs = false) const; 51 bool includeSecs = false) const;
50 52
51 QDate readDate(const QString &str, bool* ok = 0) const; 53 QDate readDate(const QString &str, bool* ok = 0) const;
52 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; 54 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
53 QTime readTime(const QString &str, bool* ok = 0) const; 55 QTime readTime(const QString &str, bool* ok = 0) const;
54 56
55 bool use12Clock() const; 57 bool use12Clock() const;
56 bool weekStartsMonday() const; 58 bool weekStartsMonday() const;
57 int weekStartDay() const; 59 int weekStartDay() const;
58 60
59 QString weekDayName(int,bool=false) const; 61 QString weekDayName(int,bool=false) const;
60 QString monthName(int,bool=false) const; 62 QString monthName(int,bool=false) const;
61 63
62 QString country() const; 64 QString country() const;
63 65
64 QString dateFormat() const; 66 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const;
65 QString dateFormatShort() const; 67 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const;
66 QString timeFormat() const; 68 QString timeFormat() const;
67 69
68 void insertCatalogue ( const QString & ); 70 void insertCatalogue ( const QString & );
69 71
70 KCalendarSystem *calendar(); 72 KCalendarSystem *calendar();
71 void setHore24Format ( bool ); 73 void setHore24Format ( bool );
72 void setWeekStartMonday( bool ); 74 void setWeekStartMonday( bool );
73 void setIntDateFormat( int ); 75 void setIntDateFormat( IntDateFormat );
74 int getIntDateFormat( ); 76 IntDateFormat getIntDateFormat( );
75 void setLanguage( int ); 77 void setLanguage( int );
76 void setDateFormat( QString ); 78 void setDateFormat( QString );
77 void setDateFormatShort( QString ); 79 void setDateFormatShort( QString );
78 80
79 QString m_decimalSymbol; 81 QString m_decimalSymbol;
80 QString m_thousandsSeparator; 82 QString m_thousandsSeparator;
81 QString m_currencySymbol; 83 QString m_currencySymbol;
82 QString m_monetaryDecimalSymbol; 84 QString m_monetaryDecimalSymbol;
83 QString m_monetaryThousandsSeparator; 85 QString m_monetaryThousandsSeparator;
84 QString m_positiveSign; 86 QString m_positiveSign;
85 QString m_negativeSign; 87 QString m_negativeSign;
86 88
87 int timezoneOffset( QString ); 89 int timezoneOffset( QString );
88 QStringList timeZoneList() const; 90 QStringList timeZoneList() const;
89 void setDaylightSaving( bool, int , int ); 91 void setDaylightSaving( bool, int , int );
90 int localTimeOffset(const QDateTime &); 92 int localTimeOffset(const QDateTime &);
91 void setTimezone( const QString &timeZone ); 93 void setTimezone( const QString &timeZone );
92 private: 94 private:
93 QTime readTime(const QString &str, bool seconds, bool *ok) const; 95 QTime readTime(const QString &str, bool seconds, bool *ok) const;
94 QDate readDate(const QString &str, bool shortFormat, bool *ok) const; 96 QDate readDate(const QString &str, bool shortFormat, bool *ok) const;
95 KCalendarSystem *mCalendarSystem; 97 KCalendarSystem *mCalendarSystem;
96 bool mWeekStartsMonday; 98 bool mWeekStartsMonday;
97 bool mHourF24Format; 99 bool mHourF24Format;
98 int mIntDateFormat; 100 IntDateFormat mIntDateFormat;
99 int mLanguage; 101 int mLanguage;
100 QString mDateFormat; 102 QString mDateFormat;
101 QString mDateFormatShort; 103 QString mDateFormatShort;
102 QStringList mTimeZoneList; 104 QStringList mTimeZoneList;
103 bool daylightEnabled; 105 bool daylightEnabled;
104 int mDaylightTZoffset; 106 int mDaylightTZoffset;
105 int mNondaylightTZoffset; 107 int mNondaylightTZoffset;
106 bool mSouthDaylight; 108 bool mSouthDaylight;
107 int daylightStart, daylightEnd, mTimeZoneOffset; 109 int daylightStart, daylightEnd, mTimeZoneOffset;
108}; 110};
109 111
110#endif 112#endif