summaryrefslogtreecommitdiffabout
path: root/libkdepim
Unidiff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/categoryeditdialog.cpp19
-rw-r--r--libkdepim/categoryeditdialog.h18
-rw-r--r--libkdepim/categoryeditdialog_base.cpp20
-rw-r--r--libkdepim/categoryeditdialog_base.h26
-rw-r--r--libkdepim/categoryselectdialog.cpp43
-rw-r--r--libkdepim/categoryselectdialog.h10
-rw-r--r--libkdepim/categoryselectdialog_base.cpp19
-rw-r--r--libkdepim/categoryselectdialog_base.h26
-rw-r--r--libkdepim/externalapphandler.cpp30
-rw-r--r--libkdepim/externalapphandler.h15
-rw-r--r--libkdepim/kcmconfigs/kcmkdepimconfig.cpp4
-rw-r--r--libkdepim/kcmconfigs/kdepimconfigwidget.cpp53
-rw-r--r--libkdepim/kcmconfigs/kdepimconfigwidget.h6
-rw-r--r--libkdepim/kdateedit.cpp40
-rw-r--r--libkdepim/kdateedit.h11
-rw-r--r--libkdepim/kdatepicker.cpp8
-rw-r--r--libkdepim/kdatepicker.h7
-rw-r--r--libkdepim/kpimglobalprefs.cpp10
-rw-r--r--libkdepim/kpimglobalprefs.h4
-rw-r--r--libkdepim/kprefsdialog.cpp19
-rw-r--r--libkdepim/kprefsdialog.h12
-rw-r--r--libkdepim/kprefswidget.cpp19
-rw-r--r--libkdepim/kprefswidget.h12
-rw-r--r--libkdepim/ksyncmanager.cpp97
-rw-r--r--libkdepim/ksyncmanager.h26
-rw-r--r--libkdepim/ksyncprefsdialog.cpp130
-rw-r--r--libkdepim/ksyncprefsdialog.h30
-rw-r--r--libkdepim/ksyncprofile.h2
-rw-r--r--libkdepim/libkdepim.pro4
-rw-r--r--libkdepim/libkdepimE.pro6
-rwxr-xr-xlibkdepim/ol_access.cpp52
-rwxr-xr-xlibkdepim/ol_access.h4
-rw-r--r--libkdepim/phoneaccess.cpp15
33 files changed, 432 insertions, 365 deletions
diff --git a/libkdepim/categoryeditdialog.cpp b/libkdepim/categoryeditdialog.cpp
index e2325d2..92a1737 100644
--- a/libkdepim/categoryeditdialog.cpp
+++ b/libkdepim/categoryeditdialog.cpp
@@ -1,141 +1,142 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qstringlist.h> 24#include <qstringlist.h>
25#include <qlineedit.h> 25#include <qlineedit.h>
26#include <qlistview.h> 26#include <q3listview.h>
27#include <qheader.h> 27#include <q3header.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qapplication.h> 29#include <qapplication.h>
30#include <QDesktopWidget>
30 31
31#include "kpimprefs.h" 32#include "kpimprefs.h"
32 33
33#include "categoryeditdialog.h" 34#include "categoryeditdialog.h"
34 35
35using namespace KPIM; 36using namespace KPIM;
36 37
37CategoryEditDialog::CategoryEditDialog( KPimPrefs *prefs, QWidget* parent, 38CategoryEditDialog::CategoryEditDialog( KPimPrefs *prefs, QWidget* parent,
38 const char* name, bool modal, 39 const char* name, bool modal,
39 WFlags fl ) 40 Qt::WFlags fl )
40 : CategoryEditDialog_base( parent, name, modal, fl ), 41 : CategoryEditDialog_base( parent, name, modal, fl ),
41 mPrefs( prefs ) 42 mPrefs( prefs )
42{ 43{
43 mCategories->header()->hide(); 44 mCategories->header()->hide();
44 45
45 QStringList::Iterator it; 46 QStringList::Iterator it;
46 bool categoriesExist=false; 47 bool categoriesExist=false;
47 for (it = mPrefs->mCustomCategories.begin(); 48 for (it = mPrefs->mCustomCategories.begin();
48 it != mPrefs->mCustomCategories.end(); ++it ) { 49 it != mPrefs->mCustomCategories.end(); ++it ) {
49 new QListViewItem(mCategories,*it); 50 new Q3ListViewItem(mCategories,*it);
50 categoriesExist=true; 51 categoriesExist=true;
51 } 52 }
52 53
53 connect(mCategories,SIGNAL(selectionChanged(QListViewItem *)), 54 connect(mCategories,SIGNAL(selectionChanged(Q3ListViewItem *)),
54 SLOT(editItem(QListViewItem *))); 55 SLOT(editItem(Q3ListViewItem *)));
55 connect(mEdit,SIGNAL(textChanged ( const QString & )),this,SLOT(slotTextChanged(const QString &))); 56 connect(mEdit,SIGNAL(textChanged ( const QString & )),this,SLOT(slotTextChanged(const QString &)));
56 mButtonRemove->setEnabled(categoriesExist); 57 mButtonRemove->setEnabled(categoriesExist);
57 mButtonModify->setEnabled(categoriesExist); 58 mButtonModify->setEnabled(categoriesExist);
58#ifndef DESKTOP_VERSION 59#ifndef DESKTOP_VERSION
59 mButtonOk->hide(); 60 mButtonOk->hide();
60 mButtonCancel->hide(); 61 mButtonCancel->hide();
61#endif 62#endif
62 mButtonAdd->setEnabled(!mEdit->text().isEmpty()); 63 mButtonAdd->setEnabled(!mEdit->text().isEmpty());
63 if ( QApplication::desktop()->width() > 460 ) 64 if ( QApplication::desktop()->width() > 460 )
64 resize( 300, 360 ); 65 resize( 300, 360 );
65 else 66 else
66 showMaximized(); 67 showMaximized();
67} 68}
68 69
69/* 70/*
70 * Destroys the object and frees any allocated resources 71 * Destroys the object and frees any allocated resources
71 */ 72 */
72CategoryEditDialog::~CategoryEditDialog() 73CategoryEditDialog::~CategoryEditDialog()
73{ 74{
74 // no need to delete child widgets, Qt does it all for us 75 // no need to delete child widgets, Qt does it all for us
75} 76}
76 77
77void CategoryEditDialog::slotTextChanged(const QString &text) 78void CategoryEditDialog::slotTextChanged(const QString &text)
78{ 79{
79 mButtonAdd->setEnabled(!text.isEmpty()); 80 mButtonAdd->setEnabled(!text.isEmpty());
80} 81}
81 82
82void CategoryEditDialog::add() 83void CategoryEditDialog::add()
83{ 84{
84 if (!mEdit->text().isEmpty()) { 85 if (!mEdit->text().isEmpty()) {
85 new QListViewItem(mCategories,mEdit->text()); 86 new Q3ListViewItem(mCategories,mEdit->text());
86 mEdit->setText(""); 87 mEdit->setText("");
87 mButtonRemove->setEnabled(mCategories->childCount()>0); 88 mButtonRemove->setEnabled(mCategories->childCount()>0);
88 mButtonModify->setEnabled(mCategories->childCount()>0); 89 mButtonModify->setEnabled(mCategories->childCount()>0);
89 } 90 }
90} 91}
91 92
92void CategoryEditDialog::remove() 93void CategoryEditDialog::remove()
93{ 94{
94 if (mCategories->currentItem()) { 95 if (mCategories->currentItem()) {
95 delete mCategories->currentItem(); 96 delete mCategories->currentItem();
96 mButtonRemove->setEnabled(mCategories->childCount()>0); 97 mButtonRemove->setEnabled(mCategories->childCount()>0);
97 mButtonModify->setEnabled(mCategories->childCount()>0); 98 mButtonModify->setEnabled(mCategories->childCount()>0);
98 } 99 }
99} 100}
100 101
101void CategoryEditDialog::modify() 102void CategoryEditDialog::modify()
102{ 103{
103 if (!mEdit->text().isEmpty()) { 104 if (!mEdit->text().isEmpty()) {
104 if (mCategories->currentItem()) { 105 if (mCategories->currentItem()) {
105 mCategories->currentItem()->setText(0,mEdit->text()); 106 mCategories->currentItem()->setText(0,mEdit->text());
106 } 107 }
107 } 108 }
108} 109}
109void CategoryEditDialog::accept() 110void CategoryEditDialog::accept()
110{ 111{
111 slotOk(); 112 slotOk();
112} 113}
113 114
114void CategoryEditDialog::slotOk() 115void CategoryEditDialog::slotOk()
115{ 116{
116 slotApply(); 117 slotApply();
117 QDialog::accept(); 118 QDialog::accept();
118} 119}
119 120
120void CategoryEditDialog::slotApply() 121void CategoryEditDialog::slotApply()
121{ 122{
122 mPrefs->mCustomCategories.clear(); 123 mPrefs->mCustomCategories.clear();
123 124
124 QListViewItem *item = mCategories->firstChild(); 125 Q3ListViewItem *item = mCategories->firstChild();
125 while(item) { 126 while(item) {
126 mPrefs->mCustomCategories.append(item->text(0)); 127 mPrefs->mCustomCategories.append(item->text(0));
127 item = item->nextSibling(); 128 item = item->nextSibling();
128 } 129 }
129 mPrefs->writeConfig(); 130 mPrefs->writeConfig();
130 131
131 emit categoryConfigChanged(); 132 emit categoryConfigChanged();
132} 133}
133 134
134void CategoryEditDialog::editItem(QListViewItem *item) 135void CategoryEditDialog::editItem(Q3ListViewItem *item)
135{ 136{
136 mEdit->setText(item->text(0)); 137 mEdit->setText(item->text(0));
137 mButtonRemove->setEnabled(true); 138 mButtonRemove->setEnabled(true);
138 mButtonModify->setEnabled(true); 139 mButtonModify->setEnabled(true);
139} 140}
140 141
141//US #include "categoryeditdialog.moc" 142//US #include "categoryeditdialog.moc"
diff --git a/libkdepim/categoryeditdialog.h b/libkdepim/categoryeditdialog.h
index 9bb3201..828894f 100644
--- a/libkdepim/categoryeditdialog.h
+++ b/libkdepim/categoryeditdialog.h
@@ -1,86 +1,86 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KPIM_CATEGORYEDITDIALOG_H 23#ifndef KPIM_CATEGORYEDITDIALOG_H
24#define KPIM_CATEGORYEDITDIALOG_H 24#define KPIM_CATEGORYEDITDIALOG_H
25 25
26#include <categoryeditdialog_base.h> 26#include <categoryeditdialog_base.h>
27#include <qlistview.h> 27#include <q3listview.h>
28 28
29class KPimPrefs; 29class KPimPrefs;
30 30
31namespace KPIM { 31namespace KPIM {
32 32
33 class CategorySelectItem :public QObject, public QCheckListItem 33 class CategorySelectItem :public QObject, public Q3CheckListItem
34{ 34{
35 35
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 38
39 CategorySelectItem(QListView * parent, const QString & text, Type tt) : QObject( parent ), 39 CategorySelectItem(Q3ListView * parent, const QString & text, Type tt) : QObject( parent ),
40 QCheckListItem (parent, text, tt ) 40 Q3CheckListItem (parent, text, tt )
41 {;} 41 {;}
42 42
43 signals: 43 signals:
44 void stateChanged( QListViewItem*); 44 void stateChanged( Q3ListViewItem*);
45 45
46 protected: 46 protected:
47 47
48 virtual void stateChange(bool b) 48 virtual void stateChange(bool b)
49 { 49 {
50 QCheckListItem::stateChange(b); 50 Q3CheckListItem::stateChange(b);
51 emit stateChanged( this ); 51 emit stateChanged( this );
52 } 52 }
53}; 53};
54 54
55 55
56class CategoryEditDialog : public CategoryEditDialog_base 56class CategoryEditDialog : public CategoryEditDialog_base
57{ 57{
58 Q_OBJECT 58 Q_OBJECT
59 public: 59 public:
60 CategoryEditDialog( KPimPrefs *prefs, QWidget* parent = 0, 60 CategoryEditDialog( KPimPrefs *prefs, QWidget* parent = 0,
61 const char* name = 0, 61 const char* name = 0,
62 bool modal = FALSE, WFlags fl = 0 ); 62 bool modal = FALSE, Qt::WFlags fl = 0 );
63 ~CategoryEditDialog(); 63 ~CategoryEditDialog();
64 64
65 public slots: 65 public slots:
66 void add(); 66 void add();
67 void remove(); 67 void remove();
68 void modify(); 68 void modify();
69 void accept(); 69 void accept();
70 70
71 void slotOk(); 71 void slotOk();
72 void slotApply(); 72 void slotApply();
73 73
74 signals: 74 signals:
75 void categoryConfigChanged(); 75 void categoryConfigChanged();
76 76
77 private slots: 77 private slots:
78 void editItem(QListViewItem *item); 78 void editItem(Q3ListViewItem *item);
79 void slotTextChanged(const QString &text); 79 void slotTextChanged(const QString &text);
80 80 private:
81 KPimPrefs *mPrefs; 81 KPimPrefs *mPrefs;
82}; 82};
83 83
84} 84}
85 85
86#endif 86#endif
diff --git a/libkdepim/categoryeditdialog_base.cpp b/libkdepim/categoryeditdialog_base.cpp
index 1908576..c85f6e5 100644
--- a/libkdepim/categoryeditdialog_base.cpp
+++ b/libkdepim/categoryeditdialog_base.cpp
@@ -1,155 +1,159 @@
1#include <klocale.h> 1#include <klocale.h>
2/**************************************************************************** 2/****************************************************************************
3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryeditdialog_base.ui' 3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryeditdialog_base.ui'
4** 4**
5** Created: Sat Mar 29 21:46:09 2003 5** Created: Sat Mar 29 21:46:09 2003
6** by: The User Interface Compiler () 6** by: The User Interface Compiler ()
7** 7**
8** WARNING! All changes made in this file will be lost! 8** WARNING! All changes made in this file will be lost!
9****************************************************************************/ 9****************************************************************************/
10 10
11#include "categoryeditdialog_base.h" 11#include "categoryeditdialog_base.h"
12 12
13#include <qvariant.h> 13#include <qvariant.h>
14#include <qheader.h> 14#include <q3header.h>
15#include <qlineedit.h> 15#include <qlineedit.h>
16#include <qlistview.h> 16#include <q3listview.h>
17#include <qpushbutton.h> 17#include <qpushbutton.h>
18#include <qlayout.h> 18#include <qlayout.h>
19#include <qtooltip.h> 19#include <qtooltip.h>
20#include <qwhatsthis.h> 20#include <q3whatsthis.h>
21//Added by qt3to4:
22#include <Q3GridLayout>
23#include <Q3HBoxLayout>
24#include <Q3VBoxLayout>
21 25
22/* 26/*
23 * Constructs a CategoryEditDialog_base as a child of 'parent', with the 27 * Constructs a CategoryEditDialog_base as a child of 'parent', with the
24 * name 'name' and widget flags set to 'f'. 28 * name 'name' and widget flags set to 'f'.
25 * 29 *
26 * The dialog will by default be modeless, unless you set 'modal' to 30 * The dialog will by default be modeless, unless you set 'modal' to
27 * TRUE to construct a modal dialog. 31 * TRUE to construct a modal dialog.
28 */ 32 */
29CategoryEditDialog_base::CategoryEditDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl ) 33CategoryEditDialog_base::CategoryEditDialog_base( QWidget* parent, const char* name, bool modal, Qt::WFlags fl )
30 : QDialog( parent, name, true, fl ) 34 : QDialog( parent, name, true, fl )
31 35
32{ 36{
33 if ( !name ) 37 if ( !name )
34 setName( "CategoryEditDialog_base" ); 38 setName( "CategoryEditDialog_base" );
35 CategoryEditDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "CategoryEditDialog_baseLayout"); 39 CategoryEditDialog_baseLayout = new Q3GridLayout( this, 1, 1, 11, 6, "CategoryEditDialog_baseLayout");
36 40
37 mEdit = new QLineEdit( this, "mEdit" ); 41 mEdit = new QLineEdit( this, "mEdit" );
38 42
39 CategoryEditDialog_baseLayout->addMultiCellWidget( mEdit, 1, 1, 0, 0 ); 43 CategoryEditDialog_baseLayout->addMultiCellWidget( mEdit, 1, 1, 0, 0 );
40 44
41 Layout13 = new QHBoxLayout( 0, 0, 6, "Layout13"); 45 Layout13 = new Q3HBoxLayout( 0, 0, 6, "Layout13");
42 46
43 // mButtonHelp = new QPushButton( this, "mButtonHelp" ); 47 // mButtonHelp = new QPushButton( this, "mButtonHelp" );
44 //mButtonHelp->setAutoDefault( TRUE ); 48 //mButtonHelp->setAutoDefault( TRUE );
45 //Layout13->addWidget( mButtonHelp ); 49 //Layout13->addWidget( mButtonHelp );
46 //QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); 50 //QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
47 //Layout13->addItem( spacer ); 51 //Layout13->addItem( spacer );
48 52
49 //mApply = new QPushButton( this, "mApply" ); 53 //mApply = new QPushButton( this, "mApply" );
50 // Layout13->addWidget( mApply ); 54 // Layout13->addWidget( mApply );
51 55
52 mButtonOk = new QPushButton( this, "mButtonOk" ); 56 mButtonOk = new QPushButton( this, "mButtonOk" );
53 mButtonOk->setAutoDefault( TRUE ); 57 mButtonOk->setAutoDefault( TRUE );
54 mButtonOk->setDefault( TRUE ); 58 mButtonOk->setDefault( TRUE );
55 Layout13->addWidget( mButtonOk ); 59 Layout13->addWidget( mButtonOk );
56 60
57 mButtonCancel = new QPushButton( this, "mButtonCancel" ); 61 mButtonCancel = new QPushButton( this, "mButtonCancel" );
58 mButtonCancel->setAutoDefault( TRUE ); 62 mButtonCancel->setAutoDefault( TRUE );
59 Layout13->addWidget( mButtonCancel ); 63 Layout13->addWidget( mButtonCancel );
60 64
61 CategoryEditDialog_baseLayout->addMultiCellLayout( Layout13, 2, 2, 0, 1 ); 65 CategoryEditDialog_baseLayout->addMultiCellLayout( Layout13, 2, 2, 0, 1 );
62 66
63 mCategories = new QListView( this, "mCategories" ); 67 mCategories = new Q3ListView( this, "mCategories" );
64 mCategories->addColumn( tr2i18n( "Category" ) ); 68 mCategories->addColumn( tr2i18n( "Category" ) );
65 69
66 CategoryEditDialog_baseLayout->addWidget( mCategories, 0, 0 ); 70 CategoryEditDialog_baseLayout->addWidget( mCategories, 0, 0 );
67 71
68 layout103 = new QVBoxLayout( 0, 0, 6, "layout103"); 72 layout103 = new Q3VBoxLayout( 0, 0, 6, "layout103");
69 73
70 mButtonAdd = new QPushButton( this, "mButtonAdd" ); 74 mButtonAdd = new QPushButton( this, "mButtonAdd" );
71 CategoryEditDialog_baseLayout->addMultiCellWidget(mButtonAdd , 1, 1, 1, 1 ); 75 CategoryEditDialog_baseLayout->addMultiCellWidget(mButtonAdd , 1, 1, 1, 1 );
72 //layout103->addWidget( mButtonAdd ); 76 //layout103->addWidget( mButtonAdd );
73 77
74 mButtonModify = new QPushButton( this, "mButtonModify" ); 78 mButtonModify = new QPushButton( this, "mButtonModify" );
75 layout103->addWidget( mButtonModify ); 79 layout103->addWidget( mButtonModify );
76 80
77 mButtonRemove = new QPushButton( this, "mButtonRemove" ); 81 mButtonRemove = new QPushButton( this, "mButtonRemove" );
78 layout103->addWidget( mButtonRemove ); 82 layout103->addWidget( mButtonRemove );
79 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 83 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
80 layout103->addItem( spacer_2 ); 84 layout103->addItem( spacer_2 );
81 85
82 CategoryEditDialog_baseLayout->addLayout( layout103, 0, 1 ); 86 CategoryEditDialog_baseLayout->addLayout( layout103, 0, 1 );
83 languageChange(); 87 languageChange();
84 resize( sizeHint() ); 88 resize( sizeHint() );
85 89
86 // signals and slots connections 90 // signals and slots connections
87 connect( mButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); 91 connect( mButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
88 connect( mButtonAdd, SIGNAL( clicked() ), this, SLOT( add() ) ); 92 connect( mButtonAdd, SIGNAL( clicked() ), this, SLOT( add() ) );
89 connect( mButtonModify, SIGNAL( clicked() ), this, SLOT( modify() ) ); 93 connect( mButtonModify, SIGNAL( clicked() ), this, SLOT( modify() ) );
90 connect( mButtonRemove, SIGNAL( clicked() ), this, SLOT( remove() ) ); 94 connect( mButtonRemove, SIGNAL( clicked() ), this, SLOT( remove() ) );
91 connect( mButtonOk, SIGNAL( clicked() ), this, SLOT( slotOk() ) ); 95 connect( mButtonOk, SIGNAL( clicked() ), this, SLOT( slotOk() ) );
92 //connect( mApply, SIGNAL( clicked() ), this, SLOT( slotApply() ) ); 96 //connect( mApply, SIGNAL( clicked() ), this, SLOT( slotApply() ) );
93 97
94 // tab order 98 // tab order
95 // setTabOrder( mCategories, mEdit ); 99 // setTabOrder( mCategories, mEdit );
96// setTabOrder( mEdit, mButtonAdd ); 100// setTabOrder( mEdit, mButtonAdd );
97// setTabOrder( mButtonAdd, mButtonModify ); 101// setTabOrder( mButtonAdd, mButtonModify );
98// setTabOrder( mButtonModify, mButtonRemove ); 102// setTabOrder( mButtonModify, mButtonRemove );
99// setTabOrder( mButtonRemove, mButtonHelp ); 103// setTabOrder( mButtonRemove, mButtonHelp );
100// setTabOrder( mButtonHelp, mApply ); 104// setTabOrder( mButtonHelp, mApply );
101// setTabOrder( mApply, mButtonOk ); 105// setTabOrder( mApply, mButtonOk );
102// setTabOrder( mButtonOk, mButtonCancel ); 106// setTabOrder( mButtonOk, mButtonCancel );
103} 107}
104 108
105/* 109/*
106 * Destroys the object and frees any allocated resources 110 * Destroys the object and frees any allocated resources
107 */ 111 */
108CategoryEditDialog_base::~CategoryEditDialog_base() 112CategoryEditDialog_base::~CategoryEditDialog_base()
109{ 113{
110 // no need to delete child widgets, Qt does it all for us 114 // no need to delete child widgets, Qt does it all for us
111} 115}
112 116
113/* 117/*
114 * Sets the strings of the subwidgets using the current 118 * Sets the strings of the subwidgets using the current
115 * language. 119 * language.
116 */ 120 */
117void CategoryEditDialog_base::languageChange() 121void CategoryEditDialog_base::languageChange()
118{ 122{
119 setCaption( tr2i18n( "Edit Categories" ) ); 123 setCaption( tr2i18n( "Edit Categories" ) );
120 // mButtonHelp->setText( tr2i18n( "&Help" ) ); 124 // mButtonHelp->setText( tr2i18n( "&Help" ) );
121 // mApply->setText( tr2i18n( "&Apply" ) ); 125 // mApply->setText( tr2i18n( "&Apply" ) );
122 mButtonOk->setText( tr2i18n( "&OK" ) ); 126 mButtonOk->setText( tr2i18n( "&OK" ) );
123 mButtonCancel->setText( tr2i18n( "&Cancel" ) ); 127 mButtonCancel->setText( tr2i18n( "&Cancel" ) );
124 mCategories->header()->setLabel( 0, tr2i18n( "Category" ) ); 128 mCategories->header()->setLabel( 0, tr2i18n( "Category" ) );
125 mButtonAdd->setText( tr2i18n( "A&dd" ) ); 129 mButtonAdd->setText( tr2i18n( "A&dd" ) );
126 mButtonModify->setText( tr2i18n( "&Modify" ) ); 130 mButtonModify->setText( tr2i18n( "&Modify" ) );
127 mButtonRemove->setText( tr2i18n( "&Remove" ) ); 131 mButtonRemove->setText( tr2i18n( "&Remove" ) );
128} 132}
129 133
130void CategoryEditDialog_base::add() 134void CategoryEditDialog_base::add()
131{ 135{
132 qWarning( "CategoryEditDialog_base::add(): Not implemented yet" ); 136 qWarning( "CategoryEditDialog_base::add(): Not implemented yet" );
133} 137}
134 138
135void CategoryEditDialog_base::modify() 139void CategoryEditDialog_base::modify()
136{ 140{
137 qWarning( "CategoryEditDialog_base::modify(): Not implemented yet" ); 141 qWarning( "CategoryEditDialog_base::modify(): Not implemented yet" );
138} 142}
139 143
140void CategoryEditDialog_base::slotApply() 144void CategoryEditDialog_base::slotApply()
141{ 145{
142 qWarning( "CategoryEditDialog_base::slotApply(): Not implemented yet" ); 146 qWarning( "CategoryEditDialog_base::slotApply(): Not implemented yet" );
143} 147}
144 148
145void CategoryEditDialog_base::remove() 149void CategoryEditDialog_base::remove()
146{ 150{
147 qWarning( "CategoryEditDialog_base::remove(): Not implemented yet" ); 151 qWarning( "CategoryEditDialog_base::remove(): Not implemented yet" );
148} 152}
149 153
150void CategoryEditDialog_base::slotOk() 154void CategoryEditDialog_base::slotOk()
151{ 155{
152 qWarning( "CategoryEditDialog_base::slotOk(): Not implemented yet" ); 156 qWarning( "CategoryEditDialog_base::slotOk(): Not implemented yet" );
153} 157}
154 158
155//US #include "categoryeditdialog_base.moc" 159//US #include "categoryeditdialog_base.moc"
diff --git a/libkdepim/categoryeditdialog_base.h b/libkdepim/categoryeditdialog_base.h
index 5557ad0..cd577b0 100644
--- a/libkdepim/categoryeditdialog_base.h
+++ b/libkdepim/categoryeditdialog_base.h
@@ -1,58 +1,62 @@
1/**************************************************************************** 1/****************************************************************************
2** Form interface generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryeditdialog_base.ui' 2** Form interface generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryeditdialog_base.ui'
3** 3**
4** Created: Sat Mar 29 21:45:20 2003 4** Created: Sat Mar 29 21:45:20 2003
5** by: The User Interface Compiler () 5** by: The User Interface Compiler ()
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9 9
10#ifndef CATEGORYEDITDIALOG_BASE_H 10#ifndef CATEGORYEDITDIALOG_BASE_H
11#define CATEGORYEDITDIALOG_BASE_H 11#define CATEGORYEDITDIALOG_BASE_H
12 12
13#include <qvariant.h> 13#include <qvariant.h>
14#include <qdialog.h> 14#include <qdialog.h>
15 15//Added by qt3to4:
16class QVBoxLayout; 16#include <Q3VBoxLayout>
17class QHBoxLayout; 17#include <Q3GridLayout>
18class QGridLayout; 18#include <Q3HBoxLayout>
19
20class Q3VBoxLayout;
21class Q3HBoxLayout;
22class Q3GridLayout;
19class QLineEdit; 23class QLineEdit;
20class QListView; 24class Q3ListView;
21class QListViewItem; 25class Q3ListViewItem;
22class QPushButton; 26class QPushButton;
23 27
24class CategoryEditDialog_base : public QDialog 28class CategoryEditDialog_base : public QDialog
25{ 29{
26 Q_OBJECT 30 Q_OBJECT
27 31
28public: 32public:
29 CategoryEditDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 33 CategoryEditDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, Qt::WFlags fl = 0 );
30 ~CategoryEditDialog_base(); 34 ~CategoryEditDialog_base();
31 35
32 QLineEdit* mEdit; 36 QLineEdit* mEdit;
33 QPushButton* mButtonHelp; 37 QPushButton* mButtonHelp;
34 QPushButton* mApply; 38 QPushButton* mApply;
35 QPushButton* mButtonOk; 39 QPushButton* mButtonOk;
36 QPushButton* mButtonCancel; 40 QPushButton* mButtonCancel;
37 QListView* mCategories; 41 Q3ListView* mCategories;
38 QPushButton* mButtonAdd; 42 QPushButton* mButtonAdd;
39 QPushButton* mButtonModify; 43 QPushButton* mButtonModify;
40 QPushButton* mButtonRemove; 44 QPushButton* mButtonRemove;
41 45
42public slots: 46public slots:
43 virtual void add(); 47 virtual void add();
44 virtual void modify(); 48 virtual void modify();
45 virtual void slotApply(); 49 virtual void slotApply();
46 virtual void remove(); 50 virtual void remove();
47 virtual void slotOk(); 51 virtual void slotOk();
48 52
49protected: 53protected:
50 QGridLayout* CategoryEditDialog_baseLayout; 54 Q3GridLayout* CategoryEditDialog_baseLayout;
51 QHBoxLayout* Layout13; 55 Q3HBoxLayout* Layout13;
52 QVBoxLayout* layout103; 56 Q3VBoxLayout* layout103;
53 57
54protected slots: 58protected slots:
55 virtual void languageChange(); 59 virtual void languageChange();
56}; 60};
57 61
58#endif // CATEGORYEDITDIALOG_BASE_H 62#endif // CATEGORYEDITDIALOG_BASE_H
diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp
index 2a9b43e..4f72880 100644
--- a/libkdepim/categoryselectdialog.cpp
+++ b/libkdepim/categoryselectdialog.cpp
@@ -1,246 +1,249 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlistview.h> 24#include <q3listview.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qheader.h> 26#include <q3header.h>
27#include <qapp.h> 27#include <qapplication.h>
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29//Added by qt3to4:
30#include <QPixmap>
31#include <QDesktopWidget>
29#include <kmessagebox.h> 32#include <kmessagebox.h>
30 33
31 34
32#include "categoryeditdialog.h" 35#include "categoryeditdialog.h"
33#include "categoryselectdialog.h" 36#include "categoryselectdialog.h"
34 37
35#include "kpimprefs.h" 38#include "kpimprefs.h"
36 39
37using namespace KPIM; 40using namespace KPIM;
38 41
39CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, 42CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent,
40 const char* name, 43 const char* name,
41 bool modal, WFlags fl ) 44 bool modal, Qt::WFlags fl )
42 : CategorySelectDialog_base( parent, name, true, fl ), 45 : CategorySelectDialog_base( parent, name, true, fl ),
43 mPrefs( prefs ) 46 mPrefs( prefs )
44{ 47{
45 Q_UNUSED( modal ); 48 Q_UNUSED( modal );
46 mColorItem = 0; 49 mColorItem = 0;
47 mColorEnabled = false; 50 mColorEnabled = false;
48 mCategories->header()->hide(); 51 mCategories->header()->hide();
49 52
50 setCategories(); 53 setCategories();
51 54
52 connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog())); 55 connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog()));
53 if ( QApplication::desktop()->width() > 460 ) 56 if ( QApplication::desktop()->width() > 460 )
54 resize( 300, 360 ); 57 resize( 300, 360 );
55 else 58 else
56 showMaximized(); 59 showMaximized();
57 connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) ); 60 connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) );
58 // connect( mCategories, SIGNAL( clicked(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); 61 // connect( mCategories, SIGNAL( clicked(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) );
59#ifndef DESKTOP_VERSION 62#ifndef DESKTOP_VERSION
60 mButtonOk->hide(); 63 mButtonOk->hide();
61 mButtonCancel->hide(); 64 mButtonCancel->hide();
62#endif 65#endif
63} 66}
64void CategorySelectDialog::editCategoriesDialog() 67void CategorySelectDialog::editCategoriesDialog()
65{ 68{
66 KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this ); 69 KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this );
67 70
68 ced->exec(); 71 ced->exec();
69 delete ced; 72 delete ced;
70 slotApply(); 73 slotApply();
71 QStringList temp = mCategoryList; 74 QStringList temp = mCategoryList;
72 setCategories(); 75 setCategories();
73 setSelected( temp ); 76 setSelected( temp );
74} 77}
75void CategorySelectDialog::setCategories() 78void CategorySelectDialog::setCategories()
76{ 79{
77 mColorItem = 0; 80 mColorItem = 0;
78 mCategories->clear(); 81 mCategories->clear();
79 mCategoryList.clear(); 82 mCategoryList.clear();
80 83
81 QStringList::Iterator it; 84 QStringList::Iterator it;
82 for (it = mPrefs->mCustomCategories.begin(); 85 for (it = mPrefs->mCustomCategories.begin();
83 it != mPrefs->mCustomCategories.end(); ++it ) { 86 it != mPrefs->mCustomCategories.end(); ++it ) {
84 CategorySelectItem * item = new CategorySelectItem(mCategories,*it,QCheckListItem::CheckBox); 87 CategorySelectItem * item = new CategorySelectItem(mCategories,*it,Q3CheckListItem::CheckBox);
85 QObject::connect( item, SIGNAL( stateChanged(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); 88 QObject::connect( item, SIGNAL( stateChanged(Q3ListViewItem *) ), this, SLOT( clicked(Q3ListViewItem *) ) );
86 89
87 } 90 }
88} 91}
89 92
90CategorySelectDialog::~CategorySelectDialog() 93CategorySelectDialog::~CategorySelectDialog()
91{ 94{
92} 95}
93 96
94void CategorySelectDialog::setSelected(const QStringList &selList) 97void CategorySelectDialog::setSelected(const QStringList &selList)
95{ 98{
96 clear(); 99 clear();
97 100
98 QStringList::ConstIterator it; 101 QStringList::ConstIterator it;
99 QStringList notFound; 102 QStringList notFound;
100 bool found = false; 103 bool found = false;
101 for (it=selList.begin();it!=selList.end();++it) { 104 for (it=selList.begin();it!=selList.end();++it) {
102 //qDebug(" CategorySelectDialog::setSelected("); 105 //qDebug(" CategorySelectDialog::setSelected(");
103 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 106 Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild();
104 while (item) { 107 while (item) {
105 if (item->text() == *it) { 108 if (item->text() == *it) {
106 item->setOn(true); 109 item->setOn(true);
107 if ( ! found ) 110 if ( ! found )
108 setColorItem( item ); 111 setColorItem( item );
109 found = true; 112 found = true;
110 break; 113 break;
111 } 114 }
112 item = (QCheckListItem *)item->nextSibling(); 115 item = (Q3CheckListItem *)item->nextSibling();
113 } 116 }
114// if ( ! found ) { 117// if ( ! found ) {
115 118
116//emit updateCategoriesGlobal(); 119//emit updateCategoriesGlobal();
117// QMessageBox::information( this, "KO/E: Information!", 120// QMessageBox::information( this, "KO/E: Information!",
118// "Categories found, which were not\n" 121// "Categories found, which were not\n"
119// "in list of categories!\n" 122// "in list of categories!\n"
120// "message", 123// "message",
121// "OK", "", 0, 124// "OK", "", 0,
122// 0, 1 ); 125// 0, 1 );
123// setSelected(selList); 126// setSelected(selList);
124// return; 127// return;
125// } 128// }
126 } 129 }
127} 130}
128 131
129QStringList CategorySelectDialog::selectedCategories() const 132QStringList CategorySelectDialog::selectedCategories() const
130{ 133{
131 return mCategoryList; 134 return mCategoryList;
132} 135}
133void CategorySelectDialog::setColorEnabled() 136void CategorySelectDialog::setColorEnabled()
134{ 137{
135 mColorEnabled = true; 138 mColorEnabled = true;
136 mSetColorCat->show(); 139 mSetColorCat->show();
137} 140}
138void CategorySelectDialog::setColorCat() 141void CategorySelectDialog::setColorCat()
139{ 142{
140 QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem (); 143 Q3CheckListItem * newColorItem = (Q3CheckListItem * )mCategories->currentItem ();
141 if ( !newColorItem ) { 144 if ( !newColorItem ) {
142 KMessageBox::error(this,i18n("There is no current item.")); 145 KMessageBox::error(this,i18n("There is no current item."));
143 return; 146 return;
144 } 147 }
145 if ( !newColorItem->isOn() ) 148 if ( !newColorItem->isOn() )
146 newColorItem->setOn( true ); 149 newColorItem->setOn( true );
147 setColorItem( newColorItem ); 150 setColorItem( newColorItem );
148 151
149} 152}
150void CategorySelectDialog::clicked ( QListViewItem * it ) 153void CategorySelectDialog::clicked ( Q3ListViewItem * it )
151{ 154{
152 if ( ! it ) 155 if ( ! it )
153 return; 156 return;
154 QCheckListItem *i = (QCheckListItem *) it; 157 Q3CheckListItem *i = (Q3CheckListItem *) it;
155 if ( !i->isOn() && i==mColorItem) { 158 if ( !i->isOn() && i==mColorItem) {
156 setColorItem( 0); 159 setColorItem( 0);
157 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 160 Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild();
158 while (item) { 161 while (item) {
159 if (item->isOn()) { 162 if (item->isOn()) {
160 setColorItem( item ); 163 setColorItem( item );
161 break; 164 break;
162 } 165 }
163 item = (QCheckListItem *)item->nextSibling(); 166 item = (Q3CheckListItem *)item->nextSibling();
164 } 167 }
165 } else if ( i->isOn() && !mColorItem) { 168 } else if ( i->isOn() && !mColorItem) {
166 setColorItem( i); 169 setColorItem( i);
167 } 170 }
168} 171}
169void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem ) 172void CategorySelectDialog::setColorItem( Q3CheckListItem * newColorItem )
170{ 173{
171 if ( !mColorEnabled ) 174 if ( !mColorEnabled )
172 return; 175 return;
173 if ( mColorItem == newColorItem) 176 if ( mColorItem == newColorItem)
174 return; 177 return;
175 if ( mColorItem ) { 178 if ( mColorItem ) {
176 mColorItem->setPixmap ( 0, QPixmap() ); 179 mColorItem->setPixmap ( 0, QPixmap() );
177 mColorItem = 0; 180 mColorItem = 0;
178 } 181 }
179 if ( newColorItem ) { 182 if ( newColorItem ) {
180 QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 ); 183 QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 );
181 pix.fill(Qt::red ); 184 pix.fill(Qt::red );
182 newColorItem->setPixmap ( 0, pix ); 185 newColorItem->setPixmap ( 0, pix );
183 mColorItem = newColorItem; 186 mColorItem = newColorItem;
184 } 187 }
185} 188}
186void CategorySelectDialog::slotApply() 189void CategorySelectDialog::slotApply()
187{ 190{
188 QStringList categories; 191 QStringList categories;
189 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 192 Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild();
190 QString colcat; 193 QString colcat;
191 while (item) { 194 while (item) {
192 if (item->isOn()) { 195 if (item->isOn()) {
193 if ( item == mColorItem) 196 if ( item == mColorItem)
194 colcat = item->text(); 197 colcat = item->text();
195 else 198 else
196 categories.append(item->text()); 199 categories.append(item->text());
197 } 200 }
198 item = (QCheckListItem *)item->nextSibling(); 201 item = (Q3CheckListItem *)item->nextSibling();
199 } 202 }
200 categories.sort(); 203 categories.sort();
201 if ( ! colcat.isEmpty() ) 204 if ( ! colcat.isEmpty() )
202 categories.prepend( colcat ); 205 categories.prepend( colcat );
203 // QString categoriesStr = categories.join(","); 206 // QString categoriesStr = categories.join(",");
204 207
205 mCategoryList = categories; 208 mCategoryList = categories;
206 209
207} 210}
208void CategorySelectDialog::accept() 211void CategorySelectDialog::accept()
209{ 212{
210 slotOk(); 213 slotOk();
211} 214}
212 215
213void CategorySelectDialog::slotOk() 216void CategorySelectDialog::slotOk()
214{ 217{
215 slotApply(); 218 slotApply();
216 emit categoriesSelected(mCategoryList); 219 emit categoriesSelected(mCategoryList);
217 emit categoriesSelected(mCategoryList.join(",")); 220 emit categoriesSelected(mCategoryList.join(","));
218 QDialog::accept(); 221 QDialog::accept();
219} 222}
220 223
221void CategorySelectDialog::clear() 224void CategorySelectDialog::clear()
222{ 225{
223 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 226 Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild();
224 while (item) { 227 while (item) {
225 item->setOn(false); 228 item->setOn(false);
226 item = (QCheckListItem *)item->nextSibling(); 229 item = (Q3CheckListItem *)item->nextSibling();
227 } 230 }
228} 231}
229 232
230void CategorySelectDialog::updateCategoryConfig() 233void CategorySelectDialog::updateCategoryConfig()
231{ 234{
232 QStringList selected; 235 QStringList selected;
233 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 236 Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild();
234 while (item) { 237 while (item) {
235 if (item->isOn()) { 238 if (item->isOn()) {
236 selected.append(item->text()); 239 selected.append(item->text());
237 } 240 }
238 item = (QCheckListItem *)item->nextSibling(); 241 item = (Q3CheckListItem *)item->nextSibling();
239 } 242 }
240 243
241 setCategories(); 244 setCategories();
242 245
243 setSelected(selected); 246 setSelected(selected);
244} 247}
245 248
246//#include "categoryselectdialog.moc" 249//#include "categoryselectdialog.moc"
diff --git a/libkdepim/categoryselectdialog.h b/libkdepim/categoryselectdialog.h
index 680a093..ff7ac58 100644
--- a/libkdepim/categoryselectdialog.h
+++ b/libkdepim/categoryselectdialog.h
@@ -1,75 +1,75 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KPIM_CATEGORYSELECTDIALOG_H 23#ifndef KPIM_CATEGORYSELECTDIALOG_H
24#define KPIM_CATEGORYSELECTDIALOG_H 24#define KPIM_CATEGORYSELECTDIALOG_H
25 25
26#include <categoryselectdialog_base.h> 26#include <categoryselectdialog_base.h>
27 27
28class KPimPrefs; 28class KPimPrefs;
29class QCheckListItem; 29class Q3CheckListItem;
30 30
31namespace KPIM { 31namespace KPIM {
32 32
33class CategorySelectDialog : public CategorySelectDialog_base 33class CategorySelectDialog : public CategorySelectDialog_base
34{ 34{
35 Q_OBJECT 35 Q_OBJECT
36 public: 36 public:
37 CategorySelectDialog( KPimPrefs *prefs, QWidget* parent = 0, 37 CategorySelectDialog( KPimPrefs *prefs, QWidget* parent = 0,
38 const char* name = 0, 38 const char* name = 0,
39 bool modal = FALSE, WFlags fl = 0 ); 39 bool modal = FALSE, Qt::WFlags fl = 0 );
40 ~CategorySelectDialog(); 40 ~CategorySelectDialog();
41 41
42 void setCategories(); 42 void setCategories();
43 void setColorEnabled(); 43 void setColorEnabled();
44 void setSelected(const QStringList &selList); 44 void setSelected(const QStringList &selList);
45 45
46 QStringList selectedCategories() const; 46 QStringList selectedCategories() const;
47 47
48 public slots: 48 public slots:
49 void slotOk(); 49 void slotOk();
50 void slotApply(); 50 void slotApply();
51 void clear(); 51 void clear();
52 void accept(); 52 void accept();
53 void editCategoriesDialog(); 53 void editCategoriesDialog();
54 void updateCategoryConfig(); 54 void updateCategoryConfig();
55 void setColorCat(); 55 void setColorCat();
56 void clicked ( QListViewItem * ); 56 void clicked ( Q3ListViewItem * );
57 signals: 57 signals:
58 void categoriesSelected(const QString &); 58 void categoriesSelected(const QString &);
59 void categoriesSelected(const QStringList &); 59 void categoriesSelected(const QStringList &);
60 void editCategories(); 60 void editCategories();
61 61
62 private: 62 private:
63 bool mColorEnabled; 63 bool mColorEnabled;
64 KPimPrefs *mPrefs; 64 KPimPrefs *mPrefs;
65 QStringList mCategoryList; 65 QStringList mCategoryList;
66 QCheckListItem *mColorItem; 66 Q3CheckListItem *mColorItem;
67 void setColorItem( QCheckListItem * ); 67 void setColorItem( Q3CheckListItem * );
68 68
69 class CategorySelectDialogPrivate; 69 class CategorySelectDialogPrivate;
70 CategorySelectDialogPrivate *d; 70 CategorySelectDialogPrivate *d;
71}; 71};
72 72
73} 73}
74 74
75#endif 75#endif
diff --git a/libkdepim/categoryselectdialog_base.cpp b/libkdepim/categoryselectdialog_base.cpp
index 4793fd7..5d53ac4 100644
--- a/libkdepim/categoryselectdialog_base.cpp
+++ b/libkdepim/categoryselectdialog_base.cpp
@@ -1,131 +1,134 @@
1#include <klocale.h> 1#include <klocale.h>
2/**************************************************************************** 2/****************************************************************************
3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryselectdialog_base.ui' 3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryselectdialog_base.ui'
4** 4**
5** Created: Sat Mar 29 21:46:05 2003 5** Created: Sat Mar 29 21:46:05 2003
6** by: The User Interface Compiler () 6** by: The User Interface Compiler ()
7** 7**
8** WARNING! All changes made in this file will be lost! 8** WARNING! All changes made in this file will be lost!
9****************************************************************************/ 9****************************************************************************/
10 10
11#include "categoryselectdialog_base.h" 11#include "categoryselectdialog_base.h"
12 12
13#include <qvariant.h> 13#include <qvariant.h>
14#include <qheader.h> 14#include <q3header.h>
15#include <qlistview.h> 15#include <q3listview.h>
16#include <qpushbutton.h> 16#include <qpushbutton.h>
17#include <qlayout.h> 17#include <qlayout.h>
18#include <qtooltip.h> 18#include <qtooltip.h>
19#include <qwhatsthis.h> 19#include <q3whatsthis.h>
20//Added by qt3to4:
21#include <Q3VBoxLayout>
22#include <Q3HBoxLayout>
20 23
21/* 24/*
22 * Constructs a CategorySelectDialog_base as a child of 'parent', with the 25 * Constructs a CategorySelectDialog_base as a child of 'parent', with the
23 * name 'name' and widget flags set to 'f'. 26 * name 'name' and widget flags set to 'f'.
24 * 27 *
25 * The dialog will by default be modeless, unless you set 'modal' to 28 * The dialog will by default be modeless, unless you set 'modal' to
26 * TRUE to construct a modal dialog. 29 * TRUE to construct a modal dialog.
27 */ 30 */
28CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl ) 31CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const char* name, bool modal, Qt::WFlags fl )
29 : QDialog( parent, name, modal, fl ) 32 : QDialog( parent, name, modal, fl )
30 33
31{ 34{
32 if ( !name ) 35 if ( !name )
33 setName( "CategorySelectDialog_base" ); 36 setName( "CategorySelectDialog_base" );
34 CategorySelectDialog_baseLayout = new QVBoxLayout( this, 11, 6, "CategorySelectDialog_baseLayout"); 37 CategorySelectDialog_baseLayout = new Q3VBoxLayout( this, 11, 6, "CategorySelectDialog_baseLayout");
35 38
36 mCategories = new QListView( this, "mCategories" ); 39 mCategories = new Q3ListView( this, "mCategories" );
37 mCategories->addColumn( i18n( "Category" ) ); 40 mCategories->addColumn( i18n( "Category" ) );
38 CategorySelectDialog_baseLayout->addWidget( mCategories ); 41 CategorySelectDialog_baseLayout->addWidget( mCategories );
39 mSetColorCat = new QPushButton( this, "msetColor" ); 42 mSetColorCat = new QPushButton( this, "msetColor" );
40 CategorySelectDialog_baseLayout->addWidget( mSetColorCat ); 43 CategorySelectDialog_baseLayout->addWidget( mSetColorCat );
41 Layout12 = new QHBoxLayout( 0, 0, 4, "Layout12"); 44 Layout12 = new Q3HBoxLayout( 0, 0, 4, "Layout12");
42 45
43 mClear = new QPushButton( this, "mClear" ); 46 mClear = new QPushButton( this, "mClear" );
44 Layout12->addWidget( mClear ); 47 Layout12->addWidget( mClear );
45 // QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); 48 // QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
46 //Layout12->addItem( spacer ); 49 //Layout12->addItem( spacer );
47 50
48 mButtonEdit = new QPushButton( this, "mButtonEdit" ); 51 mButtonEdit = new QPushButton( this, "mButtonEdit" );
49 Layout12->addWidget( mButtonEdit ); 52 Layout12->addWidget( mButtonEdit );
50 CategorySelectDialog_baseLayout->addLayout( Layout12 ); 53 CategorySelectDialog_baseLayout->addLayout( Layout12 );
51 54
52 Layout11 = new QHBoxLayout( 0, 0, 4, "Layout11"); 55 Layout11 = new Q3HBoxLayout( 0, 0, 4, "Layout11");
53 56
54 //mButtonHelp = new QPushButton( this, "mButtonHelp" ); 57 //mButtonHelp = new QPushButton( this, "mButtonHelp" );
55 //Layout11->addWidget( mButtonHelp ); 58 //Layout11->addWidget( mButtonHelp );
56 //QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); 59 //QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
57 // Layout11->addItem( spacer_2 ); 60 // Layout11->addItem( spacer_2 );
58 61
59 //mApply = new QPushButton( this, "mApply" ); 62 //mApply = new QPushButton( this, "mApply" );
60 // Layout11->addWidget( mApply ); 63 // Layout11->addWidget( mApply );
61 64
62 mButtonOk = new QPushButton( this, "mButtonOk" ); 65 mButtonOk = new QPushButton( this, "mButtonOk" );
63 mButtonOk->setOn( FALSE ); 66 mButtonOk->setOn( FALSE );
64 mButtonOk->setDefault( TRUE ); 67 mButtonOk->setDefault( TRUE );
65 Layout11->addWidget( mButtonOk ); 68 Layout11->addWidget( mButtonOk );
66 69
67 mButtonCancel = new QPushButton( this, "mButtonCancel" ); 70 mButtonCancel = new QPushButton( this, "mButtonCancel" );
68 Layout11->addWidget( mButtonCancel ); 71 Layout11->addWidget( mButtonCancel );
69 CategorySelectDialog_baseLayout->addLayout( Layout11 ); 72 CategorySelectDialog_baseLayout->addLayout( Layout11 );
70 languageChange(); 73 languageChange();
71 // resize( sizeHint() ); 74 // resize( sizeHint() );
72 75
73 // signals and slots connections 76 // signals and slots connections
74 connect( mButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); 77 connect( mButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
75 connect( mButtonOk, SIGNAL( clicked() ), this, SLOT( slotOk() ) ); 78 connect( mButtonOk, SIGNAL( clicked() ), this, SLOT( slotOk() ) );
76 connect( mClear, SIGNAL( clicked() ), this, SLOT( clear() ) ); 79 connect( mClear, SIGNAL( clicked() ), this, SLOT( clear() ) );
77 //connect( mApply, SIGNAL( clicked() ), this, SLOT( slotApply() ) ); 80 //connect( mApply, SIGNAL( clicked() ), this, SLOT( slotApply() ) );
78 81
79 // tab order 82 // tab order
80 setTabOrder( mCategories, mClear ); 83 setTabOrder( mCategories, mClear );
81 setTabOrder( mClear, mButtonEdit ); 84 setTabOrder( mClear, mButtonEdit );
82 setTabOrder( mButtonEdit, mButtonOk );//mButtonHelp ); 85 setTabOrder( mButtonEdit, mButtonOk );//mButtonHelp );
83 // setTabOrder( mButtonHelp, mApply ); 86 // setTabOrder( mButtonHelp, mApply );
84 // setTabOrder( mApply, mButtonOk ); 87 // setTabOrder( mApply, mButtonOk );
85 setTabOrder( mButtonOk, mButtonCancel ); 88 setTabOrder( mButtonOk, mButtonCancel );
86 // showMaximized(); 89 // showMaximized();
87 //raise(); 90 //raise();
88 mSetColorCat->hide(); 91 mSetColorCat->hide();
89} 92}
90 93
91/* 94/*
92 * Destroys the object and frees any allocated resources 95 * Destroys the object and frees any allocated resources
93 */ 96 */
94CategorySelectDialog_base::~CategorySelectDialog_base() 97CategorySelectDialog_base::~CategorySelectDialog_base()
95{ 98{
96 // no need to delete child widgets, Qt does it all for us 99 // no need to delete child widgets, Qt does it all for us
97} 100}
98 101
99/* 102/*
100 * Sets the strings of the subwidgets using the current 103 * Sets the strings of the subwidgets using the current
101 * language. 104 * language.
102 */ 105 */
103void CategorySelectDialog_base::languageChange() 106void CategorySelectDialog_base::languageChange()
104{ 107{
105 setCaption( i18n( "Select Categories" ) ); 108 setCaption( i18n( "Select Categories" ) );
106 mCategories->header()->setLabel( 0, tr2i18n( "Category" ) ); 109 mCategories->header()->setLabel( 0, tr2i18n( "Category" ) );
107 mClear->setText( i18n( " &Deselect All " ) ); 110 mClear->setText( i18n( " &Deselect All " ) );
108 mButtonEdit->setText( i18n( " &Edit Categories " ) ); 111 mButtonEdit->setText( i18n( " &Edit Categories " ) );
109 // mButtonHelp->setText( tr2i18n( "&Help" ) ); 112 // mButtonHelp->setText( tr2i18n( "&Help" ) );
110 //mApply->setText( i18n( "&Apply" ) ); 113 //mApply->setText( i18n( "&Apply" ) );
111 mButtonOk->setText( i18n( "&OK" ) ); 114 mButtonOk->setText( i18n( "&OK" ) );
112 mSetColorCat->setText( i18n( "Set current as color category" ) ); 115 mSetColorCat->setText( i18n( "Set current as color category" ) );
113 mButtonCancel->setText( i18n( "&Cancel" ) ); 116 mButtonCancel->setText( i18n( "&Cancel" ) );
114} 117}
115 118
116void CategorySelectDialog_base::clear() 119void CategorySelectDialog_base::clear()
117{ 120{
118 qWarning( "CategorySelectDialog_base::clear(): Not implemented yet" ); 121 qWarning( "CategorySelectDialog_base::clear(): Not implemented yet" );
119} 122}
120 123
121void CategorySelectDialog_base::slotApply() 124void CategorySelectDialog_base::slotApply()
122{ 125{
123 qWarning( "CategorySelectDialog_base::slotApply(): Not implemented yet" ); 126 qWarning( "CategorySelectDialog_base::slotApply(): Not implemented yet" );
124} 127}
125 128
126void CategorySelectDialog_base::slotOk() 129void CategorySelectDialog_base::slotOk()
127{ 130{
128 qWarning( "CategorySelectDialog_base::slotOk(): Not implemented yet" ); 131 qWarning( "CategorySelectDialog_base::slotOk(): Not implemented yet" );
129} 132}
130 133
131//US#include "categoryselectdialog_base.moc" 134//US#include "categoryselectdialog_base.moc"
diff --git a/libkdepim/categoryselectdialog_base.h b/libkdepim/categoryselectdialog_base.h
index 59ffa22..71d4ce9 100644
--- a/libkdepim/categoryselectdialog_base.h
+++ b/libkdepim/categoryselectdialog_base.h
@@ -1,54 +1,58 @@
1/**************************************************************************** 1/****************************************************************************
2** Form interface generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryselectdialog_base.ui' 2** Form interface generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryselectdialog_base.ui'
3** 3**
4** Created: Sat Mar 29 21:45:20 2003 4** Created: Sat Mar 29 21:45:20 2003
5** by: The User Interface Compiler () 5** by: The User Interface Compiler ()
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9 9
10#ifndef CATEGORYSELECTDIALOG_BASE_H 10#ifndef CATEGORYSELECTDIALOG_BASE_H
11#define CATEGORYSELECTDIALOG_BASE_H 11#define CATEGORYSELECTDIALOG_BASE_H
12 12
13#include <qvariant.h> 13#include <qvariant.h>
14#include <qdialog.h> 14#include <qdialog.h>
15 15//Added by qt3to4:
16class QVBoxLayout; 16#include <Q3VBoxLayout>
17class QHBoxLayout; 17#include <Q3GridLayout>
18class QGridLayout; 18#include <Q3HBoxLayout>
19class QListView; 19
20class QListViewItem; 20class Q3VBoxLayout;
21class Q3HBoxLayout;
22class Q3GridLayout;
23class Q3ListView;
24class Q3ListViewItem;
21class QPushButton; 25class QPushButton;
22 26
23class CategorySelectDialog_base : public QDialog 27class CategorySelectDialog_base : public QDialog
24{ 28{
25 Q_OBJECT 29 Q_OBJECT
26 30
27public: 31public:
28 CategorySelectDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 32 CategorySelectDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, Qt::WFlags fl = 0 );
29 ~CategorySelectDialog_base(); 33 ~CategorySelectDialog_base();
30 34
31 QListView* mCategories; 35 Q3ListView* mCategories;
32 QPushButton* mClear; 36 QPushButton* mClear;
33 QPushButton* mButtonEdit; 37 QPushButton* mButtonEdit;
34 QPushButton* mButtonHelp; 38 QPushButton* mButtonHelp;
35 QPushButton* mApply; 39 QPushButton* mApply;
36 QPushButton* mButtonOk; 40 QPushButton* mButtonOk;
37 QPushButton* mButtonCancel; 41 QPushButton* mButtonCancel;
38 QPushButton* mSetColorCat; 42 QPushButton* mSetColorCat;
39 43
40public slots: 44public slots:
41 virtual void clear(); 45 virtual void clear();
42 virtual void slotApply(); 46 virtual void slotApply();
43 virtual void slotOk(); 47 virtual void slotOk();
44 48
45protected: 49protected:
46 QVBoxLayout* CategorySelectDialog_baseLayout; 50 Q3VBoxLayout* CategorySelectDialog_baseLayout;
47 QHBoxLayout* Layout12; 51 Q3HBoxLayout* Layout12;
48 QHBoxLayout* Layout11; 52 Q3HBoxLayout* Layout11;
49 53
50protected slots: 54protected slots:
51 virtual void languageChange(); 55 virtual void languageChange();
52}; 56};
53 57
54#endif // CATEGORYSELECTDIALOG_BASE_H 58#endif // CATEGORYSELECTDIALOG_BASE_H
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index f376e6c..3fc548a 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,1321 +1,1323 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30#include <stdlib.h> 30#include <stdlib.h>
31 31
32#include <qfile.h> 32#include <qfile.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qregexp.h> 35#include <qregexp.h>
36 36
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qtopia/qcopenvelope_qws.h> 39#include <qtopia/qcopenvelope_qws.h>
40#else 40#else
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qprocess.h> 42#include <q3process.h>
43//Added by qt3to4:
44#include <Q3CString>
43#endif 45#endif
44 46
45#include <kstaticdeleter.h> 47#include <kstaticdeleter.h>
46#include <kmessagebox.h> 48#include <kmessagebox.h>
47 49
48 50
49#include "externalapphandler.h" 51#include "externalapphandler.h"
50 52
51#include "kpimglobalprefs.h" 53#include "kpimglobalprefs.h"
52 54
53//uncomment line to get debug output 55//uncomment line to get debug output
54//#define DEBUG_EXT_APP_HANDLER 56//#define DEBUG_EXT_APP_HANDLER
55 57
56/********************************************************************************* 58/*********************************************************************************
57 * 59 *
58 ********************************************************************************/ 60 ********************************************************************************/
59 61
60 62
61QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 63QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
62 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) 64 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
63{ 65{
64 //sourceMessage passes later three parameters: sourceChannel, uid, param1 66 //sourceMessage passes later three parameters: sourceChannel, uid, param1
65 if (_usedSourceParameters == 0) 67 if (_usedSourceParameters == 0)
66 _sourceMessageParameters = "QString,QString)"; 68 _sourceMessageParameters = "QString,QString)";
67 else if (_usedSourceParameters == 1) 69 else if (_usedSourceParameters == 1)
68 _sourceMessageParameters = "(QString,QString,QString)"; 70 _sourceMessageParameters = "(QString,QString,QString)";
69 else if (_usedSourceParameters == 2) 71 else if (_usedSourceParameters == 2)
70 _sourceMessageParameters = "(QString,QString,QString,QString)"; 72 _sourceMessageParameters = "(QString,QString,QString,QString)";
71 else if (_usedSourceParameters == 3) 73 else if (_usedSourceParameters == 3)
72 _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; 74 _sourceMessageParameters = "(QString,QString,QString,QString,QString)";
73} 75}
74 76
75/*********************************************************************************/ 77/*********************************************************************************/
76 78
77QCopTransferItem::QCopTransferItem() 79QCopTransferItem::QCopTransferItem()
78{ 80{
79} 81}
80 82
81/*********************************************************************************/ 83/*********************************************************************************/
82bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) 84bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3)
83{ 85{
84 86
85#ifndef DESKTOP_VERSION 87#ifndef DESKTOP_VERSION
86 //sourceMessage passes two parameters: sourceChannel, uid 88 //sourceMessage passes two parameters: sourceChannel, uid
87 QString sourceMessage = _sourceMessage + _sourceMessageParameters; 89 QString sourceMessage = _sourceMessage + _sourceMessageParameters;
88#ifdef DEBUG_EXT_APP_HANDLER 90#ifdef DEBUG_EXT_APP_HANDLER
89 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); 91 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1());
90 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); 92 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1());
91#endif 93#endif
92 94
93 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); 95 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
94 96
95 e << _sourceChannel << uid; 97 e << _sourceChannel << uid;
96 98
97 if (_usedSourceParameters == 1) 99 if (_usedSourceParameters == 1)
98 e << param1; 100 e << param1;
99 else if (_usedSourceParameters == 2) 101 else if (_usedSourceParameters == 2)
100 e << param1 << param2; 102 e << param1 << param2;
101 else if (_usedSourceParameters == 3) 103 else if (_usedSourceParameters == 3)
102 e << param1 << param2 << param3; 104 e << param1 << param2 << param3;
103 105
104 qApp->processEvents(); 106 qApp->processEvents();
105 107
106 return true; 108 return true;
107 109
108#else 110#else
109 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 111 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
110 return false; 112 return false;
111#endif 113#endif
112 114
113} 115}
114 116
115 117
116/*********************************************************************************/ 118/*********************************************************************************/
117void QCopTransferItem::setSourceChannel(const QString& sourceChannel) 119void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
118{ 120{
119 121
120 if ( !sourceChannel.isEmpty()) 122 if ( !sourceChannel.isEmpty())
121 _sourceChannel = sourceChannel; 123 _sourceChannel = sourceChannel;
122} 124}
123 125
124 126
125/*********************************************************************************/ 127/*********************************************************************************/
126bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 128bool QCopTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
127{ 129{
128 130
129 // copied from old mail2 131 // copied from old mail2
130/* 132/*
131 static int ii = 0; 133 static int ii = 0;
132 134
133 // block second call 135 // block second call
134 if ( ii < 2 ) { 136 if ( ii < 2 ) {
135 ++ii; 137 ++ii;
136 if ( ii > 1 ) { 138 if ( ii > 1 ) {
137 qDebug("qcop call blocked "); 139 qDebug("qcop call blocked ");
138 return true; 140 return true;
139 } 141 }
140 } 142 }
141*/ 143*/
142 144
143// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); 145// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
144 146
145 //we are in the target and get a request from the source 147 //we are in the target and get a request from the source
146 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) 148 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
147 { 149 {
148 150
149 QDataStream stream( data, IO_ReadOnly ); 151 QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly );
150 152
151 153
152 QString sourceChannel; 154 QString sourceChannel;
153 QString uid; 155 QString uid;
154 QString param1; 156 QString param1;
155 QString param2; 157 QString param2;
156 QString param3; 158 QString param3;
157 159
158 stream >> sourceChannel >> uid; 160 stream >> sourceChannel >> uid;
159 161
160 if (_usedSourceParameters == 0) 162 if (_usedSourceParameters == 0)
161 { 163 {
162 emit receivedMessageFromSource(sourceChannel, uid); 164 emit receivedMessageFromSource(sourceChannel, uid);
163 } 165 }
164 else if (_usedSourceParameters == 1) 166 else if (_usedSourceParameters == 1)
165 { 167 {
166 stream >> param1; 168 stream >> param1;
167 emit receivedMessageFromSource(sourceChannel, uid, param1); 169 emit receivedMessageFromSource(sourceChannel, uid, param1);
168 } 170 }
169 else if (_usedSourceParameters == 2) 171 else if (_usedSourceParameters == 2)
170 { 172 {
171 stream >> param1 >> param2; 173 stream >> param1 >> param2;
172 emit receivedMessageFromSource(sourceChannel, uid, param1, param2); 174 emit receivedMessageFromSource(sourceChannel, uid, param1, param2);
173 } 175 }
174 else if (_usedSourceParameters == 3) 176 else if (_usedSourceParameters == 3)
175 { 177 {
176 stream >> param1 >> param2 >> param3; 178 stream >> param1 >> param2 >> param3;
177 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); 179 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3);
178 } 180 }
179 181
180 return true; 182 return true;
181 } 183 }
182 184
183 return false; 185 return false;
184} 186}
185 187
186 188
187/********************************************************************************* 189/*********************************************************************************
188 * 190 *
189 ********************************************************************************/ 191 ********************************************************************************/
190 192
191 193
192QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 194QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
193 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 195 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
194{ 196{
195 //targetMessage returns later two parameters: uid, and map<qstring,qstring> 197 //targetMessage returns later two parameters: uid, and map<qstring,qstring>
196 _targetMessageParameters = "(QString,QMAP<QString,QString>)"; 198 _targetMessageParameters = "(QString,QMAP<QString,QString>)";
197} 199}
198 200
199/*********************************************************************************/ 201/*********************************************************************************/
200bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) 202bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
201{ 203{
202#ifndef DESKTOP_VERSION 204#ifndef DESKTOP_VERSION
203 //targetMessage passes two parameters: uid, map 205 //targetMessage passes two parameters: uid, map
204 QString targetMessage = _targetMessage + _targetMessageParameters; 206 QString targetMessage = _targetMessage + _targetMessageParameters;
205 207
206#ifdef DEBUG_EXT_APP_HANDLER 208#ifdef DEBUG_EXT_APP_HANDLER
207 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 209 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
208 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); 210 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
209#endif 211#endif
210 212
211 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 213 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
212 //US we need no names in the To field. The emailadresses are enough 214 //US we need no names in the To field. The emailadresses are enough
213 215
214 e << uid << nameEmailMap; 216 e << uid << nameEmailMap;
215 217
216 qApp->processEvents(); 218 qApp->processEvents();
217 219
218 return true; 220 return true;
219 221
220#else 222#else
221 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 223 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
222 return false; 224 return false;
223#endif 225#endif
224 226
225} 227}
226 228
227 229
228/*********************************************************************************/ 230/*********************************************************************************/
229bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 231bool QCopMapTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
230{ 232{
231 bool res = QCopTransferItem::appMessage( cmsg, data ); 233 bool res = QCopTransferItem::appMessage( cmsg, data );
232 234
233 if (res == false) 235 if (res == false)
234 { 236 {
235 QDataStream stream( data, IO_ReadOnly ); 237 QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly );
236 238
237// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); 239// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() );
238 240
239 //we are in the source and get an answer from the target 241 //we are in the source and get an answer from the target
240 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 242 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
241 { 243 {
242 QMap<QString,QString> adrMap; 244 QMap<QString,QString> adrMap;
243 QString uid; 245 QString uid;
244 246
245 stream >> uid >> adrMap; 247 stream >> uid >> adrMap;
246 248
247 emit receivedMessageFromTarget(uid, adrMap); 249 emit receivedMessageFromTarget(uid, adrMap);
248 250
249 251
250 return true; 252 return true;
251 } 253 }
252 } 254 }
253 255
254 return false; 256 return false;
255} 257}
256 258
257 259
258/********************************************************************************* 260/*********************************************************************************
259 * 261 *
260 ********************************************************************************/ 262 ********************************************************************************/
261 263
262QCopListTransferItem::~QCopListTransferItem() 264QCopListTransferItem::~QCopListTransferItem()
263{ 265{
264 266
265} 267}
266 268
267QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 269QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
268 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 270 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
269{ 271{
270 //targetMessage returns later two parameters: uid, and three lists 272 //targetMessage returns later two parameters: uid, and three lists
271 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; 273 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)";
272} 274}
273 275
274/*********************************************************************************/ 276/*********************************************************************************/
275bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 277bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6)
276{ 278{
277#ifndef DESKTOP_VERSION 279#ifndef DESKTOP_VERSION
278 //targetMessage passes two parameters: uid, map 280 //targetMessage passes two parameters: uid, map
279 QString targetMessage = _targetMessage + _targetMessageParameters; 281 QString targetMessage = _targetMessage + _targetMessageParameters;
280 282
281#ifdef DEBUG_EXT_APP_HANDLER 283#ifdef DEBUG_EXT_APP_HANDLER
282 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 284 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
283 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); 285 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1());
284 286
285 287
286 for ( int i = 0; i < list3.count(); i++) 288 for ( int i = 0; i < list3.count(); i++)
287 qDebug("listentry list3: %s",list3[i].latin1()); 289 qDebug("listentry list3: %s",list3[i].latin1());
288#endif 290#endif
289 291
290 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 292 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
291 //US we need no names in the To field. The emailadresses are enough 293 //US we need no names in the To field. The emailadresses are enough
292 294
293 e << uid << list1 << list2 << list3 << list4 << list5 << list6; 295 e << uid << list1 << list2 << list3 << list4 << list5 << list6;
294 296
295 qApp->processEvents(); 297 qApp->processEvents();
296 298
297 return true; 299 return true;
298 300
299#else 301#else
300 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 302 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
301 return false; 303 return false;
302#endif 304#endif
303 305
304} 306}
305 307
306 308
307/*********************************************************************************/ 309/*********************************************************************************/
308bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 310bool QCopListTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
309{ 311{
310 bool res = QCopTransferItem::appMessage( cmsg, data ); 312 bool res = QCopTransferItem::appMessage( cmsg, data );
311#ifdef DEBUG_EXT_APP_HANDLER 313#ifdef DEBUG_EXT_APP_HANDLER
312 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 314 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
313#endif 315#endif
314 316
315 if (res == false) 317 if (res == false)
316 { 318 {
317 QDataStream stream( data, IO_ReadOnly ); 319 QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly );
318 320
319#ifdef DEBUG_EXT_APP_HANDLER 321#ifdef DEBUG_EXT_APP_HANDLER
320 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 322 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
321#endif 323#endif
322 324
323 //we are in the source and get an answer from the target 325 //we are in the source and get an answer from the target
324 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 326 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
325 { 327 {
326 QStringList list1; 328 QStringList list1;
327 QStringList list2; 329 QStringList list2;
328 QStringList list3; 330 QStringList list3;
329 QStringList list4; 331 QStringList list4;
330 QStringList list5; 332 QStringList list5;
331 QStringList list6; 333 QStringList list6;
332 QString uid; 334 QString uid;
333 335
334#ifdef DEBUG_EXT_APP_HANDLER 336#ifdef DEBUG_EXT_APP_HANDLER
335 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 337 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
336#endif 338#endif
337 339
338 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; 340 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6;
339 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); 341 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6);
340 342
341 343
342 return true; 344 return true;
343 } 345 }
344 } 346 }
345 347
346 return false; 348 return false;
347} 349}
348 350
349 351
350 352
351/********************************************************************************* 353/*********************************************************************************
352 * 354 *
353 ********************************************************************************/ 355 ********************************************************************************/
354 356
355 357
356ExternalAppHandler *ExternalAppHandler::sInstance = 0; 358ExternalAppHandler *ExternalAppHandler::sInstance = 0;
357static KStaticDeleter<ExternalAppHandler> staticDeleter; 359static KStaticDeleter<ExternalAppHandler> staticDeleter;
358 360
359ExternalAppHandler::ExternalAppHandler() 361ExternalAppHandler::ExternalAppHandler()
360{ 362{
361 mDefaultItems.setAutoDelete(true); 363 mDefaultItems.setAutoDelete(true);
362 364
363 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 365 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
364 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); 366 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&)));
365 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 367 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
366 368
367//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 369//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
368//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); 370//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
369//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 371//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
370 372
371 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 373 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
372 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 374 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
373 375
374 376
375 377
376 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); 378 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList");
377 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); 379 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&)));
378 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 380 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
379 381
380 382
381} 383}
382 384
383ExternalAppHandler::~ExternalAppHandler() 385ExternalAppHandler::~ExternalAppHandler()
384{ 386{
385 delete mNameEmailUidListFromKAPITransfer; 387 delete mNameEmailUidListFromKAPITransfer;
386 //delete mFindByEmailFromKAPITransfer; 388 //delete mFindByEmailFromKAPITransfer;
387 delete mDisplayDetails; 389 delete mDisplayDetails;
388 delete mBirthdayListFromKAPITransfer; 390 delete mBirthdayListFromKAPITransfer;
389} 391}
390 392
391void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, 393void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid,
392 const QStringList& nameList, 394 const QStringList& nameList,
393 const QStringList& emailList, 395 const QStringList& emailList,
394 const QStringList& uidList, 396 const QStringList& uidList,
395 const QStringList&, 397 const QStringList&,
396 const QStringList&, 398 const QStringList&,
397 const QStringList& ) 399 const QStringList& )
398{ 400{
399 // this method is a conevnient way to reduce the number of parameters I have to pass 401 // this method is a conevnient way to reduce the number of parameters I have to pass
400 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); 402 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList);
401} 403}
402 404
403 405
404void ExternalAppHandler::loadConfig() 406void ExternalAppHandler::loadConfig()
405{ 407{
406 408
407 mDefaultItems.clear(); 409 mDefaultItems.clear();
408 mEmailAppAvailable = UNDEFINED; 410 mEmailAppAvailable = UNDEFINED;
409 mPhoneAppAvailable = UNDEFINED; 411 mPhoneAppAvailable = UNDEFINED;
410 mFaxAppAvailable = UNDEFINED; 412 mFaxAppAvailable = UNDEFINED;
411 mSMSAppAvailable = UNDEFINED; 413 mSMSAppAvailable = UNDEFINED;
412 mPagerAppAvailable = UNDEFINED; 414 mPagerAppAvailable = UNDEFINED;
413 mSIPAppAvailable = UNDEFINED; 415 mSIPAppAvailable = UNDEFINED;
414 416
415 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 417 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
416 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 418 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
417 QString qtpath = QString::fromLatin1( getenv("QTDIR") ); 419 QString qtpath = QString::fromLatin1( getenv("QTDIR") );
418 420
419 //if qtopiapath is not set, fallback to qt 421 //if qtopiapath is not set, fallback to qt
420 if (qtopiapath.isEmpty()) 422 if (qtopiapath.isEmpty())
421 qtopiapath = qtpath; 423 qtopiapath = qtpath;
422 424
423 //if opiepath is not set, fallback to qtopia 425 //if opiepath is not set, fallback to qtopia
424 if (opiepath.isEmpty()) 426 if (opiepath.isEmpty())
425 opiepath = qtopiapath; 427 opiepath = qtopiapath;
426 428
427 429
428 430
429 //mailclients 431 //mailclients
430 QString mailmsg1 = "writeMail(QString,QString)"; 432 QString mailmsg1 = "writeMail(QString,QString)";
431 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 433 QString mailmsg2 = "writeMail(QMap(QString,QString))";
432 434
433 QString undefined = ""; 435 QString undefined = "";
434 436
435 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 437 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
436 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 438 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
437 439
438#ifdef DESKTOP_VERSION 440#ifdef DESKTOP_VERSION
439 QString appPath; 441 QString appPath;
440#ifdef _WIN32_ 442#ifdef _WIN32_
441 appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe"; 443 appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe";
442#else 444#else
443 appPath = "/usr/bin/thunderbird"; 445 appPath = "/usr/bin/thunderbird";
444#endif 446#endif
445 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1"); 447 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1");
446 448
447#ifdef _WIN32_ 449#ifdef _WIN32_
448 appPath = "C:\\Programme\\Mozilla\\mozilla.exe"; 450 appPath = "C:\\Programme\\Mozilla\\mozilla.exe";
449#else 451#else
450 appPath = "/usr/bin/mozilla"; 452 appPath = "/usr/bin/mozilla";
451#endif 453#endif
452 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1"); 454 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1");
453 455
454 456
455 457
456#else 458#else
457 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 459 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
458 ( QFile::exists( opiepath + "/bin/ompi" )) || 460 ( QFile::exists( opiepath + "/bin/ompi" )) ||
459 ( QFile::exists( qtpath + "/bin/ompi" ))) 461 ( QFile::exists( qtpath + "/bin/ompi" )))
460 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 462 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
461 463
462 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || 464 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) ||
463 ( QFile::exists( qtpath + "/bin/qtmail" ))) 465 ( QFile::exists( qtpath + "/bin/qtmail" )))
464 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 466 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
465 467
466 if ( QFile::exists( opiepath + "/bin/opiemail" )) 468 if ( QFile::exists( opiepath + "/bin/opiemail" ))
467 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 469 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
468 470
469 if ( QFile::exists( opiepath + "/bin/mailit" )) 471 if ( QFile::exists( opiepath + "/bin/mailit" ))
470 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 472 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
471#endif 473#endif
472 474
473 475
474 //phoneclients 476 //phoneclients
475 477
476 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 478 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
477 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 479 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
478 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 480 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
479 ( QFile::exists( opiepath + "/bin/kppi" ))) 481 ( QFile::exists( opiepath + "/bin/kppi" )))
480 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 482 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
481 483
482 //faxclients 484 //faxclients
483 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 485 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
484 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 486 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
485 487
486 //smsclients 488 //smsclients
487 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 489 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
488 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 490 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
489 491
490 //pagerclients 492 //pagerclients
491 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 493 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
492 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 494 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
493 495
494 //sipclients 496 //sipclients
495 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); 497 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined);
496 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); 498 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined);
497 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 499 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
498 ( QFile::exists( opiepath + "/bin/kppi" ))) 500 ( QFile::exists( opiepath + "/bin/kppi" )))
499 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 501 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
500 502
501} 503}
502 504
503ExternalAppHandler *ExternalAppHandler::instance() 505ExternalAppHandler *ExternalAppHandler::instance()
504{ 506{
505 if ( !sInstance ) { 507 if ( !sInstance ) {
506 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 508 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
507 sInstance->loadConfig(); 509 sInstance->loadConfig();
508 } 510 }
509 511
510 return sInstance; 512 return sInstance;
511} 513}
512 514
513void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 515void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
514{ 516{
515 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 517 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
516 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); 518 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
517 mDefaultItems.append(dai); 519 mDefaultItems.append(dai);
518} 520}
519 521
520 522
521QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 523Q3PtrList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
522{ 524{
523 QList<DefaultAppItem> list; 525 Q3PtrList<DefaultAppItem> list;
524 526
525 DefaultAppItem* dai; 527 DefaultAppItem* dai;
526 528
527 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 529 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
528 { 530 {
529 if (dai->_type == type) 531 if (dai->_type == type)
530 list.append(dai); 532 list.append(dai);
531 } 533 }
532 534
533 return list; 535 return list;
534} 536}
535 537
536DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 538DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
537{ 539{
538 DefaultAppItem* dai; 540 DefaultAppItem* dai;
539 541
540 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 542 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
541 { 543 {
542 if (dai->_type == type && dai->_id == clientid) 544 if (dai->_type == type && dai->_id == clientid)
543 return dai; 545 return dai;
544 } 546 }
545 547
546 return 0; 548 return 0;
547} 549}
548 550
549bool ExternalAppHandler::isEmailAppAvailable() 551bool ExternalAppHandler::isEmailAppAvailable()
550{ 552{
551 553
552 if (mEmailAppAvailable == UNDEFINED) 554 if (mEmailAppAvailable == UNDEFINED)
553 { 555 {
554 int client = KPimGlobalPrefs::instance()->mEmailClient; 556 int client = KPimGlobalPrefs::instance()->mEmailClient;
555 if (client == KPimGlobalPrefs::NONE_EMC) 557 if (client == KPimGlobalPrefs::NONE_EMC)
556 mEmailAppAvailable = UNAVAILABLE; 558 mEmailAppAvailable = UNAVAILABLE;
557 else 559 else
558 mEmailAppAvailable = AVAILABLE; 560 mEmailAppAvailable = AVAILABLE;
559 } 561 }
560 return (mEmailAppAvailable == AVAILABLE); 562 return (mEmailAppAvailable == AVAILABLE);
561 563
562} 564}
563 565
564bool ExternalAppHandler::isSMSAppAvailable() 566bool ExternalAppHandler::isSMSAppAvailable()
565{ 567{
566#ifndef DESKTOP_VERSION 568#ifndef DESKTOP_VERSION
567 if (mSMSAppAvailable == UNDEFINED) 569 if (mSMSAppAvailable == UNDEFINED)
568 { 570 {
569 int client = KPimGlobalPrefs::instance()->mSMSClient; 571 int client = KPimGlobalPrefs::instance()->mSMSClient;
570 if (client == KPimGlobalPrefs::NONE_SMC) 572 if (client == KPimGlobalPrefs::NONE_SMC)
571 mSMSAppAvailable = UNAVAILABLE; 573 mSMSAppAvailable = UNAVAILABLE;
572 else 574 else
573 mSMSAppAvailable = AVAILABLE; 575 mSMSAppAvailable = AVAILABLE;
574 } 576 }
575 577
576 return (mSMSAppAvailable == AVAILABLE); 578 return (mSMSAppAvailable == AVAILABLE);
577#else //DESKTOP_VERSION 579#else //DESKTOP_VERSION
578 return false; 580 return false;
579#endif //DESKTOP_VERSION 581#endif //DESKTOP_VERSION
580} 582}
581 583
582bool ExternalAppHandler::isPhoneAppAvailable() 584bool ExternalAppHandler::isPhoneAppAvailable()
583{ 585{
584#ifndef DESKTOP_VERSION 586#ifndef DESKTOP_VERSION
585 if (mPhoneAppAvailable == UNDEFINED) 587 if (mPhoneAppAvailable == UNDEFINED)
586 { 588 {
587 int client = KPimGlobalPrefs::instance()->mPhoneClient; 589 int client = KPimGlobalPrefs::instance()->mPhoneClient;
588 if (client == KPimGlobalPrefs::NONE_PHC) 590 if (client == KPimGlobalPrefs::NONE_PHC)
589 mPhoneAppAvailable = UNAVAILABLE; 591 mPhoneAppAvailable = UNAVAILABLE;
590 else 592 else
591 mPhoneAppAvailable = AVAILABLE; 593 mPhoneAppAvailable = AVAILABLE;
592 } 594 }
593 595
594 return (mPhoneAppAvailable == AVAILABLE); 596 return (mPhoneAppAvailable == AVAILABLE);
595#else //DESKTOP_VERSION 597#else //DESKTOP_VERSION
596 return false; 598 return false;
597#endif //DESKTOP_VERSION 599#endif //DESKTOP_VERSION
598} 600}
599 601
600bool ExternalAppHandler::isFaxAppAvailable() 602bool ExternalAppHandler::isFaxAppAvailable()
601{ 603{
602#ifndef DESKTOP_VERSION 604#ifndef DESKTOP_VERSION
603 if (mFaxAppAvailable == UNDEFINED) 605 if (mFaxAppAvailable == UNDEFINED)
604 { 606 {
605 int client = KPimGlobalPrefs::instance()->mFaxClient; 607 int client = KPimGlobalPrefs::instance()->mFaxClient;
606 if (client == KPimGlobalPrefs::NONE_FAC) 608 if (client == KPimGlobalPrefs::NONE_FAC)
607 mFaxAppAvailable = UNAVAILABLE; 609 mFaxAppAvailable = UNAVAILABLE;
608 else 610 else
609 mFaxAppAvailable = AVAILABLE; 611 mFaxAppAvailable = AVAILABLE;
610 } 612 }
611 613
612 return (mFaxAppAvailable == AVAILABLE); 614 return (mFaxAppAvailable == AVAILABLE);
613#else //DESKTOP_VERSION 615#else //DESKTOP_VERSION
614 return false; 616 return false;
615#endif //DESKTOP_VERSION 617#endif //DESKTOP_VERSION
616} 618}
617 619
618bool ExternalAppHandler::isPagerAppAvailable() 620bool ExternalAppHandler::isPagerAppAvailable()
619{ 621{
620#ifndef DESKTOP_VERSION 622#ifndef DESKTOP_VERSION
621 if (mPagerAppAvailable == UNDEFINED) 623 if (mPagerAppAvailable == UNDEFINED)
622 { 624 {
623 int client = KPimGlobalPrefs::instance()->mPagerClient; 625 int client = KPimGlobalPrefs::instance()->mPagerClient;
624 if (client == KPimGlobalPrefs::NONE_PAC) 626 if (client == KPimGlobalPrefs::NONE_PAC)
625 mPagerAppAvailable = UNAVAILABLE; 627 mPagerAppAvailable = UNAVAILABLE;
626 else 628 else
627 mPagerAppAvailable = AVAILABLE; 629 mPagerAppAvailable = AVAILABLE;
628 } 630 }
629 631
630 return (mPagerAppAvailable == AVAILABLE); 632 return (mPagerAppAvailable == AVAILABLE);
631#else //DESKTOP_VERSION 633#else //DESKTOP_VERSION
632 return false; 634 return false;
633#endif //DESKTOP_VERSION 635#endif //DESKTOP_VERSION
634} 636}
635 637
636 638
637bool ExternalAppHandler::isSIPAppAvailable() 639bool ExternalAppHandler::isSIPAppAvailable()
638{ 640{
639#ifndef DESKTOP_VERSION 641#ifndef DESKTOP_VERSION
640 if (mSIPAppAvailable == UNDEFINED) 642 if (mSIPAppAvailable == UNDEFINED)
641 { 643 {
642 int client = KPimGlobalPrefs::instance()->mSipClient; 644 int client = KPimGlobalPrefs::instance()->mSipClient;
643 if (client == KPimGlobalPrefs::NONE_SIC) 645 if (client == KPimGlobalPrefs::NONE_SIC)
644 mSIPAppAvailable = UNAVAILABLE; 646 mSIPAppAvailable = UNAVAILABLE;
645 else 647 else
646 mSIPAppAvailable = AVAILABLE; 648 mSIPAppAvailable = AVAILABLE;
647 } 649 }
648 650
649 return (mSIPAppAvailable == AVAILABLE); 651 return (mSIPAppAvailable == AVAILABLE);
650#else //DESKTOP_VERSION 652#else //DESKTOP_VERSION
651 return false; 653 return false;
652#endif //DESKTOP_VERSION 654#endif //DESKTOP_VERSION
653} 655}
654 656
655/************************************************************************** 657/**************************************************************************
656 * 658 *
657 **************************************************************************/ 659 **************************************************************************/
658 660
659 661
660//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 662//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
661bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 663bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
662{ 664{
663 665
664#ifndef DESKTOP_VERSION 666#ifndef DESKTOP_VERSION
665 QString channel; 667 QString channel;
666 QString message2; 668 QString message2;
667 QString parameters2; 669 QString parameters2;
668 670
669 671
670 int client = KPimGlobalPrefs::instance()->mEmailClient; 672 int client = KPimGlobalPrefs::instance()->mEmailClient;
671 if (client == KPimGlobalPrefs::OTHER_EMC) 673 if (client == KPimGlobalPrefs::OTHER_EMC)
672 { 674 {
673 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 675 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
674 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 676 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
675 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 677 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
676 } 678 }
677 else 679 else
678 { 680 {
679 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 681 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
680 if (!dai) 682 if (!dai)
681 { 683 {
682 qDebug("could not find configured email application."); 684 qDebug("could not find configured email application.");
683 return false; 685 return false;
684 } 686 }
685 channel = dai->_channel; 687 channel = dai->_channel;
686 message2 = dai->_message2; 688 message2 = dai->_message2;
687 parameters2 = dai->_parameters2; 689 parameters2 = dai->_parameters2;
688 } 690 }
689 691
690 //first check if one of the mailers need the emails right in the message. 692 //first check if one of the mailers need the emails right in the message.
691 message2 = translateMessage(message2, emails, urls); 693 message2 = translateMessage(message2, emails, urls);
692 694
693 695
694#ifdef DEBUG_EXT_APP_HANDLER 696#ifdef DEBUG_EXT_APP_HANDLER
695 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 697 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
696 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 698 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
697#endif 699#endif
698 700
699 701
700 QCopEnvelope e(channel.latin1(), message2.latin1()); 702 QCopEnvelope e(channel.latin1(), message2.latin1());
701 //US we need no names in the To field. The emailadresses are enough 703 //US we need no names in the To field. The emailadresses are enough
702 704
703 passParameters(&e, parameters2, emails, urls); 705 passParameters(&e, parameters2, emails, urls);
704 706
705 707
706 708
707#else 709#else
708 //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); 710 //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1());
709 711
710 QString channel; 712 QString channel;
711 QString message2; 713 QString message2;
712 QString parameters2; 714 QString parameters2;
713 QString message; 715 QString message;
714 QString parameters; 716 QString parameters;
715 717
716 718
717 int client = KPimGlobalPrefs::instance()->mEmailClient; 719 int client = KPimGlobalPrefs::instance()->mEmailClient;
718 if (client == KPimGlobalPrefs::OTHER_EMC) 720 if (client == KPimGlobalPrefs::OTHER_EMC)
719 { 721 {
720 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 722 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
721 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 723 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
722 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2; 724 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2;
723 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 725 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
724 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2; 726 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2;
725 } 727 }
726 else 728 else
727 { 729 {
728 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 730 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
729 if (!dai) 731 if (!dai)
730 { 732 {
731 qDebug("could not find configured email application."); 733 qDebug("could not find configured email application.");
732 return false; 734 return false;
733 } 735 }
734 channel = dai->_channel; 736 channel = dai->_channel;
735 message2 = dai->_message2; 737 message2 = dai->_message2;
736 parameters2 = dai->_parameters2; 738 parameters2 = dai->_parameters2;
737 message = dai->_message; 739 message = dai->_message;
738 parameters = dai->_parameters; 740 parameters = dai->_parameters;
739 } 741 }
740 742
741 //first check if one of the mailers need the emails right in the message. 743 //first check if one of the mailers need the emails right in the message.
742 message2 = translateMessage(message2, emails, urls); 744 message2 = translateMessage(message2, emails, urls);
743#ifdef DEBUG_EXT_APP_HANDLER 745#ifdef DEBUG_EXT_APP_HANDLER
744 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 746 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
745 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 747 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
746#endif 748#endif
747 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); 749 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() );
748 //KMessageBox::sorry( 0, message2 ); 750 //KMessageBox::sorry( 0, message2 );
749 QProcess * proc = new QProcess( this ); 751 Q3Process * proc = new Q3Process( this );
750 int i = 0; 752 int i = 0;
751 proc->addArgument( channel ); 753 proc->addArgument( channel );
752 754
753 if ( message.find (" " ) > 0 ) { 755 if ( message.find (" " ) > 0 ) {
754 QStringList list = QStringList::split( " ", message ); 756 QStringList list = QStringList::split( " ", message );
755 int i = 0; 757 int i = 0;
756 while ( i < list.count ( ) ) { 758 while ( i < list.count ( ) ) {
757 //qDebug("add%sdd ",list[i].latin1() ); 759 //qDebug("add%sdd ",list[i].latin1() );
758 proc->addArgument( list[i] ); 760 proc->addArgument( list[i] );
759 //KMessageBox::sorry( 0,list[i]); 761 //KMessageBox::sorry( 0,list[i]);
760 ++i; 762 ++i;
761 } 763 }
762 } else { 764 } else {
763 proc->addArgument(message ); 765 proc->addArgument(message );
764 //KMessageBox::sorry( 0, message ); 766 //KMessageBox::sorry( 0, message );
765 767
766 } 768 }
767 769
768 parameters2 = translateMessage(parameters2, urls, "" ); 770 parameters2 = translateMessage(parameters2, urls, "" );
769 QString arg = "to='%1'"; 771 QString arg = "to='%1'";
770 arg = arg.arg( emails ) + ","+parameters2;; 772 arg = arg.arg( emails ) + ","+parameters2;;
771 773
772 //KMessageBox::sorry( 0,arg ); 774 //KMessageBox::sorry( 0,arg );
773 //qDebug("2add%sdd ",arg.latin1() ); 775 //qDebug("2add%sdd ",arg.latin1() );
774 proc->addArgument( arg); 776 proc->addArgument( arg);
775 proc->launch(""); 777 proc->launch(QString());
776#endif 778#endif
777 779
778 return true; 780 return true;
779} 781}
780 782
781/************************************************************************** 783/**************************************************************************
782 * 784 *
783 **************************************************************************/ 785 **************************************************************************/
784 786
785 787
786//calls the emailapplication and creates a mail with parameter emails as recipients 788//calls the emailapplication and creates a mail with parameter emails as recipients
787bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 789bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
788{ 790{
789 791
790 QString channel; 792 QString channel;
791 QString message; 793 QString message;
792 QString parameters; 794 QString parameters;
793 795
794 796
795 int client = KPimGlobalPrefs::instance()->mEmailClient; 797 int client = KPimGlobalPrefs::instance()->mEmailClient;
796 if (client == KPimGlobalPrefs::OTHER_EMC) 798 if (client == KPimGlobalPrefs::OTHER_EMC)
797 { 799 {
798 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 800 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
799 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 801 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
800 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 802 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
801 } 803 }
802 else 804 else
803 { 805 {
804 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 806 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
805 if (!dai) 807 if (!dai)
806 { 808 {
807 qDebug("could not find configured email application."); 809 qDebug("could not find configured email application.");
808 return false; 810 return false;
809 } 811 }
810 channel = dai->_channel; 812 channel = dai->_channel;
811 message = dai->_message; 813 message = dai->_message;
812 parameters = dai->_parameters; 814 parameters = dai->_parameters;
813 } 815 }
814 816
815#ifdef DESKTOP_VERSION 817#ifdef DESKTOP_VERSION
816 //message = channel + " " +message + " \""+ parameters + "\""; 818 //message = channel + " " +message + " \""+ parameters + "\"";
817#endif 819#endif
818 //first check if one of the mailers need the emails right in the message. 820 //first check if one of the mailers need the emails right in the message.
819 message = translateMessage(message, name, emailadress); 821 message = translateMessage(message, name, emailadress);
820 822
821#ifdef DEBUG_EXT_APP_HANDLER 823#ifdef DEBUG_EXT_APP_HANDLER
822 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 824 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
823 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 825 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
824#endif 826#endif
825 827
826#ifndef DESKTOP_VERSION 828#ifndef DESKTOP_VERSION
827 QCopEnvelope e(channel.latin1(), message.latin1()); 829 QCopEnvelope e(channel.latin1(), message.latin1());
828 //US we need no names in the To field. The emailadresses are enough 830 //US we need no names in the To field. The emailadresses are enough
829 831
830 passParameters(&e, parameters, name, emailadress); 832 passParameters(&e, parameters, name, emailadress);
831#else // DESKTOP_VERSION 833#else // DESKTOP_VERSION
832 834
833 //KMessageBox::sorry( 0,channel ); 835 //KMessageBox::sorry( 0,channel );
834 QProcess * proc = new QProcess( this ); 836 Q3Process * proc = new Q3Process( this );
835 proc->addArgument( channel ); 837 proc->addArgument( channel );
836 if ( message.find (" " ) > 0 ) { 838 if ( message.find (" " ) > 0 ) {
837 QStringList list = QStringList::split( " ", message ); 839 QStringList list = QStringList::split( " ", message );
838 int i = 0; 840 int i = 0;
839 while ( i < list.count ( ) ) { 841 while ( i < list.count ( ) ) {
840 //qDebug("add%sdd ",list[i].latin1() ); 842 //qDebug("add%sdd ",list[i].latin1() );
841 proc->addArgument( list[i] ); 843 proc->addArgument( list[i] );
842 //KMessageBox::sorry( 0,list[i]); 844 //KMessageBox::sorry( 0,list[i]);
843 ++i; 845 ++i;
844 } 846 }
845 } else { 847 } else {
846 proc->addArgument(message ); 848 proc->addArgument(message );
847 849
848 } 850 }
849 parameters = translateMessage(parameters, name, emailadress); 851 parameters = translateMessage(parameters, name, emailadress);
850 852
851 //KMessageBox::information(0,parameters); 853 //KMessageBox::information(0,parameters);
852 proc->addArgument( parameters ); 854 proc->addArgument( parameters );
853 proc->launch(""); 855 proc->launch(QString());
854#endif 856#endif
855 857
856 return true; 858 return true;
857} 859}
858 860
859/************************************************************************** 861/**************************************************************************
860 * 862 *
861 **************************************************************************/ 863 **************************************************************************/
862 864
863//calls the emailapplication and creates a mail with parameter as recipients 865//calls the emailapplication and creates a mail with parameter as recipients
864// parameters format is 866// parameters format is
865// NAME <EMAIL>:SUBJECT 867// NAME <EMAIL>:SUBJECT
866bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 868bool ExternalAppHandler::mailToOneContact( const QString& adressline )
867{ 869{
868 QString line = adressline; 870 QString line = adressline;
869 871
870 int first = line.find( "<"); 872 int first = line.find( "<");
871 int last = line.find( ">"); 873 int last = line.find( ">");
872 QString name = line.left(first); 874 QString name = line.left(first);
873 QString emailadress = line.mid(first+1, last-first-1); 875 QString emailadress = line.mid(first+1, last-first-1);
874 876
875 //Subject can not be handled right now. 877 //Subject can not be handled right now.
876 return mailToOneContact( name, emailadress ); 878 return mailToOneContact( name, emailadress );
877 879
878} 880}
879 881
880 882
881/************************************************************************** 883/**************************************************************************
882 * 884 *
883 **************************************************************************/ 885 **************************************************************************/
884 886
885//calls the phoneapplication with the number 887//calls the phoneapplication with the number
886bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 888bool ExternalAppHandler::callByPhone( const QString& phonenumber )
887{ 889{
888#ifndef DESKTOP_VERSION 890#ifndef DESKTOP_VERSION
889 QString channel; 891 QString channel;
890 QString message; 892 QString message;
891 QString parameters; 893 QString parameters;
892 894
893 895
894 int client = KPimGlobalPrefs::instance()->mPhoneClient; 896 int client = KPimGlobalPrefs::instance()->mPhoneClient;
895 if (client == KPimGlobalPrefs::OTHER_PHC) 897 if (client == KPimGlobalPrefs::OTHER_PHC)
896 { 898 {
897 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 899 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
898 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 900 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
899 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 901 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
900 } 902 }
901 else 903 else
902 { 904 {
903 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 905 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
904 if (!dai) 906 if (!dai)
905 { 907 {
906 qDebug("could not find configured phone application."); 908 qDebug("could not find configured phone application.");
907 return false; 909 return false;
908 } 910 }
909 channel = dai->_channel; 911 channel = dai->_channel;
910 message = dai->_message; 912 message = dai->_message;
911 parameters = dai->_parameters; 913 parameters = dai->_parameters;
912 } 914 }
913 915
914 916
915 //first check if one of the mailers need the emails right in the message. 917 //first check if one of the mailers need the emails right in the message.
916 message = translateMessage(message, phonenumber, ""); 918 message = translateMessage(message, phonenumber, "");
917 919
918 920
919#ifdef DEBUG_EXT_APP_HANDLER 921#ifdef DEBUG_EXT_APP_HANDLER
920 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 922 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
921 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 923 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
922#endif 924#endif
923 925
924 QCopEnvelope e(channel.latin1(), message.latin1()); 926 QCopEnvelope e(channel.latin1(), message.latin1());
925 //US we need no names in the To field. The emailadresses are enough 927 //US we need no names in the To field. The emailadresses are enough
926 928
927 passParameters(&e, parameters, phonenumber, ""); 929 passParameters(&e, parameters, phonenumber, "");
928 930
929 931
930#else 932#else
931 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 933 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
932#endif 934#endif
933 935
934 936
935 return true; 937 return true;
936} 938}
937 939
938/************************************************************************** 940/**************************************************************************
939 * 941 *
940 **************************************************************************/ 942 **************************************************************************/
941 943
942//calls the smsapplication with the number 944//calls the smsapplication with the number
943bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 945bool ExternalAppHandler::callBySMS( const QString& phonenumber )
944{ 946{
945#ifndef DESKTOP_VERSION 947#ifndef DESKTOP_VERSION
946 QString channel; 948 QString channel;
947 QString message; 949 QString message;
948 QString parameters; 950 QString parameters;
949 951
950 952
951 int client = KPimGlobalPrefs::instance()->mSMSClient; 953 int client = KPimGlobalPrefs::instance()->mSMSClient;
952 if (client == KPimGlobalPrefs::OTHER_SMC) 954 if (client == KPimGlobalPrefs::OTHER_SMC)
953 { 955 {
954 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 956 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
955 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 957 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
956 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 958 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
957 } 959 }
958 else 960 else
959 { 961 {
960 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 962 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
961 if (!dai) 963 if (!dai)
962 { 964 {
963 qDebug("could not find configured sms application."); 965 qDebug("could not find configured sms application.");
964 return false; 966 return false;
965 } 967 }
966 channel = dai->_channel; 968 channel = dai->_channel;
967 message = dai->_message; 969 message = dai->_message;
968 parameters = dai->_parameters; 970 parameters = dai->_parameters;
969 } 971 }
970 972
971 973
972 //first check if one of the mailers need the emails right in the message. 974 //first check if one of the mailers need the emails right in the message.
973 message = translateMessage(message, phonenumber, ""); 975 message = translateMessage(message, phonenumber, "");
974 976
975 977
976#ifdef DEBUG_EXT_APP_HANDLER 978#ifdef DEBUG_EXT_APP_HANDLER
977 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 979 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
978 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 980 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
979#endif 981#endif
980 982
981 QCopEnvelope e(channel.latin1(), message.latin1()); 983 QCopEnvelope e(channel.latin1(), message.latin1());
982 //US we need no names in the To field. The emailadresses are enough 984 //US we need no names in the To field. The emailadresses are enough
983 985
984 passParameters(&e, parameters, phonenumber, ""); 986 passParameters(&e, parameters, phonenumber, "");
985 987
986 988
987#else 989#else
988 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 990 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
989#endif 991#endif
990 992
991 993
992 return true; 994 return true;
993} 995}
994 996
995/************************************************************************** 997/**************************************************************************
996 * 998 *
997 **************************************************************************/ 999 **************************************************************************/
998 1000
999//calls the pagerapplication with the number 1001//calls the pagerapplication with the number
1000bool ExternalAppHandler::callByPager( const QString& pagernumber ) 1002bool ExternalAppHandler::callByPager( const QString& pagernumber )
1001{ 1003{
1002#ifndef DESKTOP_VERSION 1004#ifndef DESKTOP_VERSION
1003 QString channel; 1005 QString channel;
1004 QString message; 1006 QString message;
1005 QString parameters; 1007 QString parameters;
1006 1008
1007 1009
1008 int client = KPimGlobalPrefs::instance()->mPagerClient; 1010 int client = KPimGlobalPrefs::instance()->mPagerClient;
1009 if (client == KPimGlobalPrefs::OTHER_PAC) 1011 if (client == KPimGlobalPrefs::OTHER_PAC)
1010 { 1012 {
1011 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 1013 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
1012 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 1014 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
1013 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 1015 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
1014 } 1016 }
1015 else 1017 else
1016 { 1018 {
1017 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 1019 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
1018 if (!dai) 1020 if (!dai)
1019 { 1021 {
1020 qDebug("could not find configured pager application."); 1022 qDebug("could not find configured pager application.");
1021 return false; 1023 return false;
1022 } 1024 }
1023 channel = dai->_channel; 1025 channel = dai->_channel;
1024 message = dai->_message; 1026 message = dai->_message;
1025 parameters = dai->_parameters; 1027 parameters = dai->_parameters;
1026 } 1028 }
1027 1029
1028 1030
1029 //first check if one of the mailers need the emails right in the message. 1031 //first check if one of the mailers need the emails right in the message.
1030 message = translateMessage(message, pagernumber, ""); 1032 message = translateMessage(message, pagernumber, "");
1031 1033
1032 1034
1033#ifdef DEBUG_EXT_APP_HANDLER 1035#ifdef DEBUG_EXT_APP_HANDLER
1034 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1036 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1035 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 1037 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
1036#endif 1038#endif
1037 1039
1038 QCopEnvelope e(channel.latin1(), message.latin1()); 1040 QCopEnvelope e(channel.latin1(), message.latin1());
1039 //US we need no names in the To field. The emailadresses are enough 1041 //US we need no names in the To field. The emailadresses are enough
1040 1042
1041 passParameters(&e, parameters, pagernumber, ""); 1043 passParameters(&e, parameters, pagernumber, "");
1042 1044
1043 1045
1044#else 1046#else
1045 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 1047 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
1046#endif 1048#endif
1047 1049
1048 1050
1049 return true; 1051 return true;
1050} 1052}
1051 1053
1052/************************************************************************** 1054/**************************************************************************
1053 * 1055 *
1054 **************************************************************************/ 1056 **************************************************************************/
1055 1057
1056//calls the faxapplication with the number 1058//calls the faxapplication with the number
1057bool ExternalAppHandler::callByFax( const QString& faxnumber ) 1059bool ExternalAppHandler::callByFax( const QString& faxnumber )
1058{ 1060{
1059#ifndef DESKTOP_VERSION 1061#ifndef DESKTOP_VERSION
1060 QString channel; 1062 QString channel;
1061 QString message; 1063 QString message;
1062 QString parameters; 1064 QString parameters;
1063 1065
1064 1066
1065 int client = KPimGlobalPrefs::instance()->mFaxClient; 1067 int client = KPimGlobalPrefs::instance()->mFaxClient;
1066 if (client == KPimGlobalPrefs::OTHER_FAC) 1068 if (client == KPimGlobalPrefs::OTHER_FAC)
1067 { 1069 {
1068 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 1070 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
1069 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 1071 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
1070 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 1072 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
1071 } 1073 }
1072 else 1074 else
1073 { 1075 {
1074 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 1076 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
1075 if (!dai) 1077 if (!dai)
1076 { 1078 {
1077 qDebug("could not find configured fax application."); 1079 qDebug("could not find configured fax application.");
1078 return false; 1080 return false;
1079 } 1081 }
1080 channel = dai->_channel; 1082 channel = dai->_channel;
1081 message = dai->_message; 1083 message = dai->_message;
1082 parameters = dai->_parameters; 1084 parameters = dai->_parameters;
1083 } 1085 }
1084 1086
1085 1087
1086 //first check if one of the mailers need the emails right in the message. 1088 //first check if one of the mailers need the emails right in the message.
1087 message = translateMessage(message, faxnumber, ""); 1089 message = translateMessage(message, faxnumber, "");
1088 1090
1089 1091
1090#ifdef DEBUG_EXT_APP_HANDLER 1092#ifdef DEBUG_EXT_APP_HANDLER
1091 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1093 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1092 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 1094 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
1093#endif 1095#endif
1094 1096
1095 QCopEnvelope e(channel.latin1(), message.latin1()); 1097 QCopEnvelope e(channel.latin1(), message.latin1());
1096 //US we need no names in the To field. The emailadresses are enough 1098 //US we need no names in the To field. The emailadresses are enough
1097 1099
1098 passParameters(&e, parameters, faxnumber, ""); 1100 passParameters(&e, parameters, faxnumber, "");
1099 1101
1100 1102
1101#else 1103#else
1102 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 1104 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
1103#endif 1105#endif
1104 1106
1105 1107
1106 return true; 1108 return true;
1107} 1109}
1108 1110
1109/************************************************************************** 1111/**************************************************************************
1110 * 1112 *
1111 **************************************************************************/ 1113 **************************************************************************/
1112 1114
1113//calls the sipapplication with the number 1115//calls the sipapplication with the number
1114bool ExternalAppHandler::callBySIP( const QString& sipnumber ) 1116bool ExternalAppHandler::callBySIP( const QString& sipnumber )
1115{ 1117{
1116#ifndef DESKTOP_VERSION 1118#ifndef DESKTOP_VERSION
1117 QString channel; 1119 QString channel;
1118 QString message; 1120 QString message;
1119 QString parameters; 1121 QString parameters;
1120 1122
1121 1123
1122 int client = KPimGlobalPrefs::instance()->mSipClient; 1124 int client = KPimGlobalPrefs::instance()->mSipClient;
1123 if (client == KPimGlobalPrefs::OTHER_SIC) 1125 if (client == KPimGlobalPrefs::OTHER_SIC)
1124 { 1126 {
1125 channel = KPimGlobalPrefs::instance()->mSipOtherChannel; 1127 channel = KPimGlobalPrefs::instance()->mSipOtherChannel;
1126 message = KPimGlobalPrefs::instance()->mSipOtherMessage; 1128 message = KPimGlobalPrefs::instance()->mSipOtherMessage;
1127 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; 1129 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters;
1128 } 1130 }
1129 else 1131 else
1130 { 1132 {
1131 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); 1133 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client);
1132 if (!dai) 1134 if (!dai)
1133 { 1135 {
1134 qDebug("could not find configured sip application."); 1136 qDebug("could not find configured sip application.");
1135 return false; 1137 return false;
1136 } 1138 }
1137 channel = dai->_channel; 1139 channel = dai->_channel;
1138 message = dai->_message; 1140 message = dai->_message;
1139 parameters = dai->_parameters; 1141 parameters = dai->_parameters;
1140 } 1142 }
1141 1143
1142 1144
1143 //first check if one of the sip apps need the emails right in the message. 1145 //first check if one of the sip apps need the emails right in the message.
1144 message = translateMessage(message, sipnumber, ""); 1146 message = translateMessage(message, sipnumber, "");
1145 1147
1146 1148
1147#ifdef DEBUG_EXT_APP_HANDLER 1149#ifdef DEBUG_EXT_APP_HANDLER
1148 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1150 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1149 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); 1151 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1());
1150#endif 1152#endif
1151 1153
1152 QCopEnvelope e(channel.latin1(), message.latin1()); 1154 QCopEnvelope e(channel.latin1(), message.latin1());
1153 //US we need no names in the To field. The emailadresses are enough 1155 //US we need no names in the To field. The emailadresses are enough
1154 1156
1155 passParameters(&e, parameters, sipnumber, ""); 1157 passParameters(&e, parameters, sipnumber, "");
1156 1158
1157 1159
1158#else 1160#else
1159 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); 1161 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) );
1160#endif 1162#endif
1161 1163
1162 1164
1163 return true; 1165 return true;
1164} 1166}
1165 1167
1166 1168
1167/************************************************************************** 1169/**************************************************************************
1168 * 1170 *
1169 **************************************************************************/ 1171 **************************************************************************/
1170 1172
1171 1173
1172QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 1174QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
1173{ 1175{
1174 message = message.replace( QRegExp("%1"), param1 ); 1176 message = message.replace( QRegExp("%1"), param1 );
1175 return message.replace( QRegExp("%2"), param2 ); 1177 return message.replace( QRegExp("%2"), param2 );
1176} 1178}
1177 1179
1178/************************************************************************** 1180/**************************************************************************
1179 * 1181 *
1180 **************************************************************************/ 1182 **************************************************************************/
1181 1183
1182void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 1184void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
1183{ 1185{
1184#ifndef DESKTOP_VERSION 1186#ifndef DESKTOP_VERSION
1185 QMap<QString, QString> valmap; 1187 QMap<QString, QString> valmap;
1186 bool useValMap = false; 1188 bool useValMap = false;
1187 1189
1188 // first extract all parts of the parameters. 1190 // first extract all parts of the parameters.
1189 QStringList paramlist = QStringList::split(";", parameters); 1191 QStringList paramlist = QStringList::split(";", parameters);
1190 1192
1191 //Now check how many parts we have. 1193 //Now check how many parts we have.
1192 //=0 :no params to pass 1194 //=0 :no params to pass
1193 //>0 :parameters to pass 1195 //>0 :parameters to pass
1194 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 1196 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
1195 { 1197 {
1196 QString param = (*it); 1198 QString param = (*it);
1197 QStringList keyvallist = QStringList::split("=", param); 1199 QStringList keyvallist = QStringList::split("=", param);
1198 1200
1199 //if we have keyvalue pairs, we assume that we pass a map to the envelope 1201 //if we have keyvalue pairs, we assume that we pass a map to the envelope
1200 QStringList::Iterator it2 = keyvallist.begin(); 1202 QStringList::Iterator it2 = keyvallist.begin();
1201 QString key = (*it2); 1203 QString key = (*it2);
1202 key = key.replace( QRegExp("%1"), param1 ); 1204 key = key.replace( QRegExp("%1"), param1 );
1203 key = key.replace( QRegExp("%2"), param2 ); 1205 key = key.replace( QRegExp("%2"), param2 );
1204 ++it2; 1206 ++it2;
1205 1207
1206 if(it2 != keyvallist.end()) 1208 if(it2 != keyvallist.end())
1207 { 1209 {
1208 QString value = (*it2); 1210 QString value = (*it2);
1209 value = value.replace( QRegExp("%1"), param1 ); 1211 value = value.replace( QRegExp("%1"), param1 );
1210 value = value.replace( QRegExp("%2"), param2 ); 1212 value = value.replace( QRegExp("%2"), param2 );
1211 1213
1212 valmap.insert(key, value); 1214 valmap.insert(key, value);
1213 useValMap = true; 1215 useValMap = true;
1214 } 1216 }
1215 else 1217 else
1216 { 1218 {
1217 // qDebug("pass parameter << %s", key.latin1()); 1219 // qDebug("pass parameter << %s", key.latin1());
1218 (*e) << key; 1220 (*e) << key;
1219 } 1221 }
1220 } 1222 }
1221 1223
1222 if (useValMap == true) 1224 if (useValMap == true)
1223 (*e) << valmap; 1225 (*e) << valmap;
1224 1226
1225#endif 1227#endif
1226 1228
1227} 1229}
1228 1230
1229 1231
1230 1232
1231/************************************************************************** 1233/**************************************************************************
1232 * 1234 *
1233 **************************************************************************/ 1235 **************************************************************************/
1234 1236
1235void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) 1237void ExternalAppHandler::appMessage( const Q3CString& cmsg, const QByteArray& data )
1236{ 1238{
1237 qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this); 1239 qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this);
1238 if ( cmsg == "nextView()" ) { 1240 if ( cmsg == "nextView()" ) {
1239 qDebug("nextView()"); 1241 qDebug("nextView()");
1240 QTimer::singleShot( 0, this, SIGNAL ( nextView() )); 1242 QTimer::singleShot( 0, this, SIGNAL ( nextView() ));
1241 return; 1243 return;
1242 } 1244 }
1243 if ( cmsg == "callContactdialog()" ) { 1245 if ( cmsg == "callContactdialog()" ) {
1244 qDebug("callContactdialog()"); 1246 qDebug("callContactdialog()");
1245 QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() )); 1247 QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() ));
1246 return; 1248 return;
1247 } 1249 }
1248 if ( cmsg == "doRingSync" ) { 1250 if ( cmsg == "doRingSync" ) {
1249 qDebug("doRingSync"); 1251 qDebug("doRingSync");
1250 QTimer::singleShot( 0, this, SIGNAL ( doRingSync() )); 1252 QTimer::singleShot( 0, this, SIGNAL ( doRingSync() ));
1251 return; 1253 return;
1252 } 1254 }
1253 1255
1254 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1256 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1255 if (!res) 1257 if (!res)
1256 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); 1258 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data );
1257 1259
1258 if (!res) 1260 if (!res)
1259 res = mDisplayDetails->appMessage( cmsg, data ); 1261 res = mDisplayDetails->appMessage( cmsg, data );
1260 1262
1261// if (!res) 1263// if (!res)
1262// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1264// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1263} 1265}
1264 1266
1265 1267
1266 1268
1267bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1269bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1268{ 1270{
1269 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1271 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1270 // maybe we are sending to KA/Pi fom a different worldd... 1272 // maybe we are sending to KA/Pi fom a different worldd...
1271 // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application 1273 // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application
1272 // for that reason we send the current QApplication::desktop()->width() to KA/Pi 1274 // for that reason we send the current QApplication::desktop()->width() to KA/Pi
1273 //qDebug("UID %s ", sessionuid.latin1()); 1275 //qDebug("UID %s ", sessionuid.latin1());
1274 //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() )); 1276 //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() ));
1275 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); 1277 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid);
1276} 1278}
1277 1279
1278bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1280bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1279{ 1281{
1280 QStringList list4, list5, list6; 1282 QStringList list4, list5, list6;
1281 1283
1282 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1284 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1283 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1285 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1284} 1286}
1285 1287
1286bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) 1288bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email)
1287{ 1289{
1288 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1290 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1289 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); 1291 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email);
1290} 1292}
1291 1293
1292bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1294bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1293{ 1295{
1294 QStringList list4, list5, list6; 1296 QStringList list4, list5, list6;
1295 1297
1296 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1298 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1297 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1299 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1298} 1300}
1299 1301
1300bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) 1302bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid)
1301{ 1303{
1302 mDisplayDetails->setSourceChannel(""); 1304 mDisplayDetails->setSourceChannel("");
1303 return mDisplayDetails->sendMessageToTarget("", name, email, uid); 1305 return mDisplayDetails->sendMessageToTarget("", name, email, uid);
1304} 1306}
1305 1307
1306bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1308bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1307{ 1309{
1308 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1310 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1309 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); 1311 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid);
1310} 1312}
1311 1313
1312bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 1314bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6)
1313{ 1315{
1314 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1316 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1315 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1317 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1316} 1318}
1317 1319
1318 1320
1319 1321
1320 1322
1321 1323
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h
index b899ad7..3247fe4 100644
--- a/libkdepim/externalapphandler.h
+++ b/libkdepim/externalapphandler.h
@@ -1,294 +1,297 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef EXTERNALAPPHANDLER_H 31#ifndef EXTERNALAPPHANDLER_H
32#define EXTERNALAPPHANDLER_H 32#define EXTERNALAPPHANDLER_H
33 33
34#include <qobject.h> 34#include <qobject.h>
35#include <qlist.h> 35#include <qlist.h>
36#include <qmap.h> 36#include <qmap.h>
37#include <Q3PtrList>
38//Added by qt3to4:
39#include <Q3CString>
37 40
38class QCopEnvelope; 41class QCopEnvelope;
39 42
40 43
41class ExternalAppHandler; 44class ExternalAppHandler;
42class QCopTransferItem : public QObject 45class QCopTransferItem : public QObject
43{ 46{
44 Q_OBJECT 47 Q_OBJECT
45 public: 48 public:
46 QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); 49 QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
47 QCopTransferItem(); 50 QCopTransferItem();
48 51
49 bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null); 52 bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null);
50 53
51 void setSourceChannel(const QString& sourceChannel); 54 void setSourceChannel(const QString& sourceChannel);
52 55
53 virtual bool appMessage( const QCString& msg, const QByteArray& data ); 56 virtual bool appMessage( const Q3CString& msg, const QByteArray& data );
54 57
55 58
56 signals: 59 signals:
57 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid); 60 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid);
58 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1); 61 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1);
59 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2); 62 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2);
60 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3); 63 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3);
61 64
62 public: 65 public:
63 int _usedSourceParameters; 66 int _usedSourceParameters;
64 QString _sourceChannel; 67 QString _sourceChannel;
65 QString _sourceMessage; 68 QString _sourceMessage;
66 QString _sourceMessageParameters; 69 QString _sourceMessageParameters;
67 QString _targetChannel; 70 QString _targetChannel;
68 QString _targetMessage; 71 QString _targetMessage;
69 QString _targetMessageParameters; 72 QString _targetMessageParameters;
70 73
71}; 74};
72 75
73/********************************************************************************* 76/*********************************************************************************
74 * 77 *
75 ********************************************************************************/ 78 ********************************************************************************/
76 79
77class QCopMapTransferItem : public QCopTransferItem 80class QCopMapTransferItem : public QCopTransferItem
78{ 81{
79 Q_OBJECT 82 Q_OBJECT
80 public: 83 public:
81 QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); 84 QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
82 85
83 bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap); 86 bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap);
84 87
85 88
86 virtual bool appMessage( const QCString& msg, const QByteArray& data ); 89 virtual bool appMessage( const Q3CString& msg, const QByteArray& data );
87 90
88 91
89 signals: 92 signals:
90 void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); 93 void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap);
91 94
92}; 95};
93 96
94/********************************************************************************* 97/*********************************************************************************
95 * 98 *
96 ********************************************************************************/ 99 ********************************************************************************/
97 100
98class QCopListTransferItem : public QCopTransferItem 101class QCopListTransferItem : public QCopTransferItem
99{ 102{
100 Q_OBJECT 103 Q_OBJECT
101 public: 104 public:
102 QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); 105 QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
103 ~QCopListTransferItem(); 106 ~QCopListTransferItem();
104 bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6); 107 bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6);
105 108
106 109
107 virtual bool appMessage( const QCString& msg, const QByteArray& data ); 110 virtual bool appMessage( const Q3CString& msg, const QByteArray& data );
108 111
109 112
110 signals: 113 signals:
111 void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4 , const QStringList& list5, const QStringList& list6); 114 void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4 , const QStringList& list5, const QStringList& list6);
112 115
113}; 116};
114 117
115/********************************************************************************* 118/*********************************************************************************
116 * 119 *
117 ********************************************************************************/ 120 ********************************************************************************/
118 121
119 122
120class DefaultAppItem 123class DefaultAppItem
121{ 124{
122 public: 125 public:
123 DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) 126 DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2)
124 : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) 127 : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2)
125 {} 128 {}
126 129
127 DefaultAppItem() 130 DefaultAppItem()
128 { } 131 { }
129 132
130 public: 133 public:
131 int _type; 134 int _type;
132 int _id; 135 int _id;
133 QString _label; 136 QString _label;
134 QString _channel; 137 QString _channel;
135 QString _message; 138 QString _message;
136 QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; 139 QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ;
137 QString _message2; 140 QString _message2;
138 QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; 141 QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ;
139 142
140}; 143};
141 144
142/********************************************************************************* 145/*********************************************************************************
143 * 146 *
144 ********************************************************************************/ 147 ********************************************************************************/
145 148
146class ExternalAppHandler : public QObject 149class ExternalAppHandler : public QObject
147{ 150{
148 Q_OBJECT 151 Q_OBJECT
149 public: 152 public:
150 virtual ~ExternalAppHandler(); 153 virtual ~ExternalAppHandler();
151 154
152 static ExternalAppHandler *instance(); 155 static ExternalAppHandler *instance();
153 156
154 enum Types { 157 enum Types {
155 EMAIL = 0, 158 EMAIL = 0,
156 PHONE = 1, 159 PHONE = 1,
157 SMS = 2, 160 SMS = 2,
158 FAX = 3, 161 FAX = 3,
159 PAGER = 4, 162 PAGER = 4,
160 SIP = 5 163 SIP = 5
161 }; 164 };
162 165
163 enum Availability { 166 enum Availability {
164 UNDEFINED = -1, 167 UNDEFINED = -1,
165 UNAVAILABLE = 0, 168 UNAVAILABLE = 0,
166 AVAILABLE = 1 169 AVAILABLE = 1
167 }; 170 };
168 171
169 //calls the emailapplication with a number of attachments that need to be send. 172 //calls the emailapplication with a number of attachments that need to be send.
170 //either parameter can be left empty. 173 //either parameter can be left empty.
171 bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); 174 bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls );
172 175
173 //calls the emailapplication and creates a mail with parameter emailadress as recipients 176 //calls the emailapplication and creates a mail with parameter emailadress as recipients
174 bool mailToOneContact( const QString& name, const QString& emailadress ); 177 bool mailToOneContact( const QString& name, const QString& emailadress );
175 178
176 //calls the emailapplication and creates a mail with parameter as recipients 179 //calls the emailapplication and creates a mail with parameter as recipients
177 // parameters format is 180 // parameters format is
178 // NAME <EMAIL>:SUBJECT 181 // NAME <EMAIL>:SUBJECT
179 bool mailToOneContact( const QString& adressline ); 182 bool mailToOneContact( const QString& adressline );
180 183
181 //calls the phoneapplication with the number 184 //calls the phoneapplication with the number
182 bool callByPhone( const QString& phonenumber ); 185 bool callByPhone( const QString& phonenumber );
183 186
184 //calls the smsapplication with the number 187 //calls the smsapplication with the number
185 bool callBySMS( const QString& phonenumber ); 188 bool callBySMS( const QString& phonenumber );
186 189
187 //calls the pagerapplication with the number 190 //calls the pagerapplication with the number
188 bool callByPager( const QString& pagernumber ); 191 bool callByPager( const QString& pagernumber );
189 192
190 //calls the faxapplication with the number 193 //calls the faxapplication with the number
191 bool callByFax( const QString& faxnumber ); 194 bool callByFax( const QString& faxnumber );
192 195
193 //calls the sipapplication with the number 196 //calls the sipapplication with the number
194 bool callBySIP( const QString& sipnumber ); 197 bool callBySIP( const QString& sipnumber );
195 198
196 bool isEmailAppAvailable(); 199 bool isEmailAppAvailable();
197 bool isSMSAppAvailable(); 200 bool isSMSAppAvailable();
198 bool isPhoneAppAvailable(); 201 bool isPhoneAppAvailable();
199 bool isFaxAppAvailable(); 202 bool isFaxAppAvailable();
200 bool isPagerAppAvailable(); 203 bool isPagerAppAvailable();
201 bool isSIPAppAvailable(); 204 bool isSIPAppAvailable();
202 205
203 206
204 //Call this method on the source when you want to select names from the addressbook by using QCop 207 //Call this method on the source when you want to select names from the addressbook by using QCop
205 bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid); 208 bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid);
206 //Call this method on the target when you want to return the name/email map to the source (client). 209 //Call this method on the target when you want to return the name/email map to the source (client).
207 bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); 210 bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid);
208 211
209 212
210 213
211 bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email); 214 bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email);
212 bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); 215 bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid);
213 216
214 bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid); 217 bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid);
215 218
216 219
217 220
218 bool requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid); 221 bool requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid);
219 bool returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, 222 bool returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid,
220 const QStringList& birthdayList, const QStringList& anniversaryList, 223 const QStringList& birthdayList, const QStringList& anniversaryList,
221 const QStringList& realNameList, const QStringList& emailList, 224 const QStringList& realNameList, const QStringList& emailList,
222 const QStringList& assembledNameList, const QStringList& uidList); 225 const QStringList& assembledNameList, const QStringList& uidList);
223 226
224 227
225 //loadConfig clears the cache and checks again if the applications are available or not 228 //loadConfig clears the cache and checks again if the applications are available or not
226 void loadConfig(); 229 void loadConfig();
227 230
228 QList<DefaultAppItem> getAvailableDefaultItems(Types); 231 Q3PtrList<DefaultAppItem> getAvailableDefaultItems(Types);
229 DefaultAppItem* getDefaultItem(Types, int); 232 DefaultAppItem* getDefaultItem(Types, int);
230 233
231 public slots: 234 public slots:
232 void appMessage( const QCString& msg, const QByteArray& data ); 235 void appMessage( const Q3CString& msg, const QByteArray& data );
233 236
234 237
235 signals: 238 signals:
236 void callContactdialog(); 239 void callContactdialog();
237 void nextView(); 240 void nextView();
238 void doRingSync(); 241 void doRingSync();
239 // Emmitted when the target app receives a request from the source app 242 // Emmitted when the target app receives a request from the source app
240 void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid); 243 void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid);
241 244
242 // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi 245 // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi
243 // The first parameter is a uniqueid. It can be used to identify the event 246 // The first parameter is a uniqueid. It can be used to identify the event
244 void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); 247 void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList);
245 248
246 void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email); 249 void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email);
247 void receivedFindByEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); 250 void receivedFindByEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList);
248 251
249 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 252 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
250 253
251 254
252 // Emmitted when the target app receives a request from the source app 255 // Emmitted when the target app receives a request from the source app
253 void requestForBirthdayList(const QString& sourceChannel, const QString& uid); 256 void requestForBirthdayList(const QString& sourceChannel, const QString& uid);
254 257
255 // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi 258 // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi
256 // The first parameter is a uniqueid. It can be used to identify the event 259 // The first parameter is a uniqueid. It can be used to identify the event
257 void receivedBirthdayListEvent(const QString& uid, const QStringList& birthdayList, 260 void receivedBirthdayListEvent(const QString& uid, const QStringList& birthdayList,
258 const QStringList& anniversaryList, const QStringList& realNameList, 261 const QStringList& anniversaryList, const QStringList& realNameList,
259 const QStringList& emailList, const QStringList& assembledNameList, 262 const QStringList& emailList, const QStringList& assembledNameList,
260 const QStringList& uidList); 263 const QStringList& uidList);
261 264
262 265
263 private: 266 private:
264 ExternalAppHandler(); 267 ExternalAppHandler();
265 QList<DefaultAppItem> mDefaultItems; 268 Q3PtrList<DefaultAppItem> mDefaultItems;
266 269
267 Availability mEmailAppAvailable; 270 Availability mEmailAppAvailable;
268 Availability mPhoneAppAvailable; 271 Availability mPhoneAppAvailable;
269 Availability mFaxAppAvailable; 272 Availability mFaxAppAvailable;
270 Availability mSMSAppAvailable; 273 Availability mSMSAppAvailable;
271 Availability mPagerAppAvailable; 274 Availability mPagerAppAvailable;
272 Availability mSIPAppAvailable; 275 Availability mSIPAppAvailable;
273 276
274 QCopListTransferItem* mNameEmailUidListFromKAPITransfer; 277 QCopListTransferItem* mNameEmailUidListFromKAPITransfer;
275 QCopListTransferItem* mFindByEmailFromKAPITransfer; 278 QCopListTransferItem* mFindByEmailFromKAPITransfer;
276 QCopTransferItem* mDisplayDetails; 279 QCopTransferItem* mDisplayDetails;
277 QCopListTransferItem* mBirthdayListFromKAPITransfer; 280 QCopListTransferItem* mBirthdayListFromKAPITransfer;
278 281
279 282
280 void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); 283 void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2);
281 284
282 QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; 285 QString& translateMessage(QString& message, const QString& param1, const QString& param2) const;
283 void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; 286 void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const;
284 287
285 288
286 static ExternalAppHandler *sInstance; 289 static ExternalAppHandler *sInstance;
287 290
288 private slots: 291 private slots:
289 void receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& ); 292 void receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& );
290 293
291}; 294};
292 295
293 296
294#endif 297#endif
diff --git a/libkdepim/kcmconfigs/kcmkdepimconfig.cpp b/libkdepim/kcmconfigs/kcmkdepimconfig.cpp
index 5094830..9f47766 100644
--- a/libkdepim/kcmconfigs/kcmkdepimconfig.cpp
+++ b/libkdepim/kcmconfigs/kcmkdepimconfig.cpp
@@ -1,80 +1,82 @@
1/* 1/*
2 This file is part of KDEPim/Pi. 2 This file is part of KDEPim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31 31
32#include <qlayout.h> 32#include <qlayout.h>
33//Added by qt3to4:
34#include <Q3VBoxLayout>
33 35
34#include <kdebug.h> 36#include <kdebug.h>
35//#include <klocale.h> 37//#include <klocale.h>
36//#include <stdlib.h> 38//#include <stdlib.h>
37 39
38#include "kdepimconfigwidget.h" 40#include "kdepimconfigwidget.h"
39 41
40#include "kcmkdepimconfig.h" 42#include "kcmkdepimconfig.h"
41#include "kprefs.h" 43#include "kprefs.h"
42#include "kpimglobalprefs.h" 44#include "kpimglobalprefs.h"
43 45
44#ifndef _WIN32_ 46#ifndef _WIN32_
45extern "C" 47extern "C"
46{ 48{
47 KCModule *create_kdepimconfig(QWidget *parent, const char * ) { 49 KCModule *create_kdepimconfig(QWidget *parent, const char * ) {
48 return new KCMKdePimConfig(parent, "kcmkdepimconfig" ); 50 return new KCMKdePimConfig(parent, "kcmkdepimconfig" );
49 } 51 }
50} 52}
51#endif 53#endif
52 54
53KCMKdePimConfig::KCMKdePimConfig(QWidget *parent, const char *name ) 55KCMKdePimConfig::KCMKdePimConfig(QWidget *parent, const char *name )
54 : KCModule( KPimGlobalPrefs::instance(), parent, name ) 56 : KCModule( KPimGlobalPrefs::instance(), parent, name )
55{ 57{
56 //abort(); 58 //abort();
57 QVBoxLayout *layout = new QVBoxLayout( this ); 59 Q3VBoxLayout *layout = new Q3VBoxLayout( this );
58 mConfigWidget = new KDEPIMConfigWidget( (KPimGlobalPrefs*)getPreferences(), this, "KDEPIMConfigWidget" ); 60 mConfigWidget = new KDEPIMConfigWidget( (KPimGlobalPrefs*)getPreferences(), this, "KDEPIMConfigWidget" );
59 layout->addWidget( mConfigWidget ); 61 layout->addWidget( mConfigWidget );
60 layout->setSpacing( 0 ); 62 layout->setSpacing( 0 );
61 layout->setMargin( 0 ); 63 layout->setMargin( 0 );
62 64
63 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); 65 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) );
64} 66}
65 67
66void KCMKdePimConfig::load() 68void KCMKdePimConfig::load()
67{ 69{
68 mConfigWidget->readConfig(); 70 mConfigWidget->readConfig();
69} 71}
70 72
71void KCMKdePimConfig::save() 73void KCMKdePimConfig::save()
72{ 74{
73 mConfigWidget->writeConfig(); 75 mConfigWidget->writeConfig();
74} 76}
75 77
76void KCMKdePimConfig::defaults() 78void KCMKdePimConfig::defaults()
77{ 79{
78 qDebug("KCMKdePimConfig::defaults()"); 80 qDebug("KCMKdePimConfig::defaults()");
79 mConfigWidget->setDefaults(); 81 mConfigWidget->setDefaults();
80} 82}
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
index 292951b..11a2b45 100644
--- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
+++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
@@ -1,1011 +1,1016 @@
1/* 1/*
2 This file is part of KdePim/Pi. 2 This file is part of KdePim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qgroupbox.h> 34#include <q3groupbox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qbuttongroup.h> 37#include <q3buttongroup.h>
38#include <qcheckbox.h> 38#include <qcheckbox.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qvbox.h> 40#include <q3vbox.h>
41#include <qdir.h> 41#include <qdir.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qspinbox.h> 43#include <qspinbox.h>
44#include <QDesktopWidget>
45//Added by qt3to4:
46#include <Q3HBoxLayout>
47#include <Q3GridLayout>
48#include <Q3VBoxLayout>
44 49
45#include <kdialog.h> 50#include <kdialog.h>
46#include <kprefsdialog.h> 51#include <kprefsdialog.h>
47#include <klocale.h> 52#include <klocale.h>
48#include <kglobalsettings.h> 53#include <kglobalsettings.h>
49#include <kdateedit.h> 54#include <kdateedit.h>
50#include <kglobal.h> 55#include <kglobal.h>
51#include <stdlib.h> 56#include <stdlib.h>
52 57
53/*US 58/*US
54#include <qcheckbox.h> 59#include <qcheckbox.h>
55#include <qframe.h> 60#include <qframe.h>
56#include <qpushbutton.h> 61#include <qpushbutton.h>
57#include <qcombobox.h> 62#include <qcombobox.h>
58#include <qlineedit.h> 63#include <qlineedit.h>
59#include <qlabel.h> 64#include <qlabel.h>
60#include <qfile.h> 65#include <qfile.h>
61 66
62#include <kconfig.h> 67#include <kconfig.h>
63#include <kdebug.h> 68#include <kdebug.h>
64#include <kdialog.h> 69#include <kdialog.h>
65#include <klistview.h> 70#include <klistview.h>
66#include <klocale.h> 71#include <klocale.h>
67#include <kglobal.h> 72#include <kglobal.h>
68#include <kmessagebox.h> 73#include <kmessagebox.h>
69#include <kstandarddirs.h> 74#include <kstandarddirs.h>
70 75
71#ifndef KAB_EMBEDDED 76#ifndef KAB_EMBEDDED
72#include <ktrader.h> 77#include <ktrader.h>
73#else // KAB_EMBEDDED 78#else // KAB_EMBEDDED
74#include <mergewidget.h> 79#include <mergewidget.h>
75#include <distributionlistwidget.h> 80#include <distributionlistwidget.h>
76#endif // KAB_EMBEDDED 81#endif // KAB_EMBEDDED
77 82
78#include "addresseewidget.h" 83#include "addresseewidget.h"
79#include "extensionconfigdialog.h" 84#include "extensionconfigdialog.h"
80#include "extensionwidget.h" 85#include "extensionwidget.h"
81*/ 86*/
82 87
83#include "qapplication.h" 88#include "qapplication.h"
84 89
85#include "kpimglobalprefs.h" 90#include "kpimglobalprefs.h"
86 91
87#include "kdepimconfigwidget.h" 92#include "kdepimconfigwidget.h"
88#include <kprefs.h> 93#include <kprefs.h>
89#include <kmessagebox.h> 94#include <kmessagebox.h>
90 95
91 96
92 97
93KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name ) 98KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name )
94 : KPrefsWidget(prefs, parent, name ) 99 : KPrefsWidget(prefs, parent, name )
95{ 100{
96 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email")); 101 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email"));
97 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone")); 102 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone"));
98 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS")); 103 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS"));
99 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax")); 104 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax"));
100 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager")); 105 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager"));
101 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP")); 106 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP"));
102 107
103 108
104 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 109 Q3VBoxLayout *topLayout = new Q3VBoxLayout( this, 0,
105 KDialog::spacingHint() ); 110 KDialog::spacingHint() );
106 111
107 tabWidget = new QTabWidget( this ); 112 tabWidget = new QTabWidget( this );
108 topLayout->addWidget( tabWidget ); 113 topLayout->addWidget( tabWidget );
109 114
110 115
111 setupLocaleTab(); 116 setupLocaleTab();
112 setupLocaleDateTab(); 117 setupLocaleDateTab();
113 setupTimeZoneTab(); 118 setupTimeZoneTab();
114 setupExternalAppTab(); 119 setupExternalAppTab();
115 setupStoreTab(); 120 setupStoreTab();
116 setupBackupTab(); 121 setupBackupTab();
117} 122}
118void KDEPIMConfigWidget::showTimeZoneTab() 123void KDEPIMConfigWidget::showTimeZoneTab()
119{ 124{
120 tabWidget->setCurrentPage ( 3 ) ; 125 tabWidget->setCurrentPage ( 3 ) ;
121} 126}
122void KDEPIMConfigWidget::setupBackupTab() 127void KDEPIMConfigWidget::setupBackupTab()
123{ 128{
124 QVBox *colorPage = new QVBox( this ); 129 Q3VBox *colorPage = new Q3VBox( this );
125 tabWidget->addTab( colorPage, i18n( "Backup" ) ); 130 tabWidget->addTab( colorPage, i18n( "Backup" ) );
126 QWidget* topFrame = new QWidget( colorPage ); 131 QWidget* topFrame = new QWidget( colorPage );
127 QVBoxLayout *topLayout = new QVBoxLayout(topFrame); 132 Q3VBoxLayout *topLayout = new Q3VBoxLayout(topFrame);
128 KPrefsWidBool *sb = addWidBool(i18n("Backup enabled"), 133 KPrefsWidBool *sb = addWidBool(i18n("Backup enabled"),
129 &(KPimGlobalPrefs::instance()->mBackupEnabled),topFrame); 134 &(KPimGlobalPrefs::instance()->mBackupEnabled),topFrame);
130 topLayout->addWidget((QWidget*)sb->checkBox()); 135 topLayout->addWidget((QWidget*)sb->checkBox());
131 QWidget* bupFrame = new QWidget( topFrame ); 136 QWidget* bupFrame = new QWidget( topFrame );
132 topLayout->addWidget((bupFrame)); 137 topLayout->addWidget((bupFrame));
133 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) ); 138 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) );
134 QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame); 139 Q3VBoxLayout *bupLayout = new Q3VBoxLayout(bupFrame);
135 sb = addWidBool(i18n("Use standard backup dir"), 140 sb = addWidBool(i18n("Use standard backup dir"),
136 &(KPimGlobalPrefs::instance()->mBackupUseDefaultDir),bupFrame); 141 &(KPimGlobalPrefs::instance()->mBackupUseDefaultDir),bupFrame);
137 bupLayout->addWidget((QWidget*)sb->checkBox()); 142 bupLayout->addWidget((QWidget*)sb->checkBox());
138 mBackupUrl = new KURLRequester( bupFrame ); 143 mBackupUrl = new KURLRequester( bupFrame );
139 mBackupUrl->setPathIsDir(); 144 mBackupUrl->setPathIsDir();
140 mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); 145 mBackupUrl->setURL( KGlobalSettings::backupDataDir() );
141 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) ); 146 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) );
142 bupLayout->addWidget( mBackupUrl ); 147 bupLayout->addWidget( mBackupUrl );
143 148
144 mBackupUrl->setEnabled( !KPimGlobalPrefs::instance()->mBackupUseDefaultDir ); 149 mBackupUrl->setEnabled( !KPimGlobalPrefs::instance()->mBackupUseDefaultDir );
145 bupFrame->setEnabled( KPimGlobalPrefs::instance()->mBackupEnabled ); 150 bupFrame->setEnabled( KPimGlobalPrefs::instance()->mBackupEnabled );
146 QHBox *dummy = new QHBox(bupFrame); 151 Q3HBox *dummy = new Q3HBox(bupFrame);
147 new QLabel(i18n("Number of Backups:"),dummy); 152 new QLabel(i18n("Number of Backups:"),dummy);
148 mBackupNumbersSpin = new QSpinBox(1,21,1,dummy); 153 mBackupNumbersSpin = new QSpinBox(1,21,1,dummy);
149 new QLabel(i18n(" "),dummy); 154 new QLabel(i18n(" "),dummy);
150 bupLayout->addWidget( dummy ); 155 bupLayout->addWidget( dummy );
151 156
152 dummy = new QHBox(bupFrame); 157 dummy = new Q3HBox(bupFrame);
153 new QLabel(i18n("Make backup every "),dummy); 158 new QLabel(i18n("Make backup every "),dummy);
154 mBackupDayCountSpin = new QSpinBox(1,28,1,dummy); 159 mBackupDayCountSpin = new QSpinBox(1,28,1,dummy);
155 new QLabel(i18n(" days"),dummy); 160 new QLabel(i18n(" days"),dummy);
156 new QLabel(i18n(" "),dummy); 161 new QLabel(i18n(" "),dummy);
157 bupLayout->addWidget( dummy ); 162 bupLayout->addWidget( dummy );
158 QString localKdeDir; 163 QString localKdeDir;
159 localKdeDir = readEnvPath("LOCALMICROKDEHOME"); 164 localKdeDir = readEnvPath("LOCALMICROKDEHOME");
160 if ( ! localKdeDir.isEmpty() ) { 165 if ( ! localKdeDir.isEmpty() ) {
161 sb->checkBox()->setEnabled( false ); 166 sb->checkBox()->setEnabled( false );
162 sb->checkBox()->setChecked( true ); 167 sb->checkBox()->setChecked( true );
163 mBackupUrl->setEnabled( false ); 168 mBackupUrl->setEnabled( false );
164 KPimGlobalPrefs::instance()->mBackupUseDefaultDir = true; 169 KPimGlobalPrefs::instance()->mBackupUseDefaultDir = true;
165 } 170 }
166 171
167} 172}
168void KDEPIMConfigWidget::setupStoreTab() 173void KDEPIMConfigWidget::setupStoreTab()
169{ 174{
170 QVBox *colorPage = new QVBox( this ); 175 Q3VBox *colorPage = new Q3VBox( this );
171 tabWidget->addTab( colorPage, i18n( "Colors" ) ); 176 tabWidget->addTab( colorPage, i18n( "Colors" ) );
172 QWidget* cw = new QWidget( colorPage ); 177 QWidget* cw = new QWidget( colorPage );
173 KPrefsWidColor *holidayColor = 178 KPrefsWidColor *holidayColor =
174 addWidColor(i18n("Alternating background of list views"), 179 addWidColor(i18n("Alternating background of list views"),
175 &(KPimGlobalPrefs::instance()->mAlternateColor),cw); 180 &(KPimGlobalPrefs::instance()->mAlternateColor),cw);
176 QHBoxLayout *topLayout = new QHBoxLayout(cw); 181 Q3HBoxLayout *topLayout = new Q3HBoxLayout(cw);
177 topLayout->addWidget(holidayColor->label()); 182 topLayout->addWidget(holidayColor->label());
178 topLayout->addWidget( (QWidget* )holidayColor->button()); 183 topLayout->addWidget( (QWidget* )holidayColor->button());
179 184
180 185
181 QVBox *storePage = new QVBox( this ); 186 Q3VBox *storePage = new Q3VBox( this );
182 if ( QApplication::desktop()->height() > 240 ) 187 if ( QApplication::desktop()->height() > 240 )
183 new QLabel( i18n("Your current storage dir is:\n%1\nYour mail is stored in:\n(storagedir)/apps/kopiemail/localmail").arg(KGlobal::dirs()->localkdedir()), storePage ); 188 new QLabel( i18n("Your current storage dir is:\n%1\nYour mail is stored in:\n(storagedir)/apps/kopiemail/localmail").arg(KGlobal::dirs()->localkdedir()), storePage );
184 new QLabel( i18n("<b>New data storage dir:</b>"), storePage ); 189 new QLabel( i18n("<b>New data storage dir:</b>"), storePage );
185 mStoreUrl = new KURLRequester( storePage ); 190 mStoreUrl = new KURLRequester( storePage );
186 mStoreUrl->setPathIsDir(); 191 mStoreUrl->setPathIsDir();
187 mStoreUrl->setURL( KGlobal::dirs()->localkdedir() ); 192 mStoreUrl->setURL( KGlobal::dirs()->localkdedir() );
188#ifdef DESKTOP_VERSION 193#ifdef DESKTOP_VERSION
189 QString confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; 194 QString confFile = qApp->applicationDirPath ()+ "/.microkdehome" ;
190 QFileInfo fi ( confFile ); 195 QFileInfo fi ( confFile );
191 if ( fi.exists() ) { 196 if ( fi.exists() ) {
192 KConfig cfg ( confFile ); 197 KConfig cfg ( confFile );
193 cfg.setGroup("Global"); 198 cfg.setGroup("Global");
194 QString localKdeDir = cfg.readEntry( "MICROKDEHOME", "x_x_x" ); 199 QString localKdeDir = cfg.readEntry( "MICROKDEHOME", "x_x_x" );
195 if ( localKdeDir != "x_x_x" ) { 200 if ( localKdeDir != "x_x_x" ) {
196 mStoreUrl->setURL( localKdeDir ); 201 mStoreUrl->setURL( localKdeDir );
197 qDebug("Reading config from %s ", confFile.latin1()); 202 qDebug("Reading config from %s ", confFile.latin1());
198 } 203 }
199 } 204 }
200 205
201#endif 206#endif
202 new QLabel( i18n("New dirs are created automatically"), storePage ); 207 new QLabel( i18n("New dirs are created automatically"), storePage );
203 QHBox *bb = new QHBox( storePage ); 208 Q3HBox *bb = new Q3HBox( storePage );
204 QPushButton * pb; 209 QPushButton * pb;
205 if ( QApplication::desktop()->width() < 640 ) 210 if ( QApplication::desktop()->width() < 640 )
206 pb = new QPushButton ( i18n("Save"), bb ); 211 pb = new QPushButton ( i18n("Save"), bb );
207 else 212 else
208 pb = new QPushButton ( i18n("Save settings"), bb ); 213 pb = new QPushButton ( i18n("Save settings"), bb );
209 connect(pb, SIGNAL( clicked() ), this, SLOT ( saveStoreSettings() ) ); 214 connect(pb, SIGNAL( clicked() ), this, SLOT ( saveStoreSettings() ) );
210 pb = new QPushButton ( i18n("Save standard"), bb ); 215 pb = new QPushButton ( i18n("Save standard"), bb );
211 connect(pb, SIGNAL( clicked() ), this, SLOT ( setStandardStore() ) ); 216 connect(pb, SIGNAL( clicked() ), this, SLOT ( setStandardStore() ) );
212#ifdef DESKTOP_VERSION 217#ifdef DESKTOP_VERSION
213 pb = new QPushButton ( i18n("Save using LOCAL storage"), bb ); 218 pb = new QPushButton ( i18n("Save using LOCAL storage"), bb );
214 connect(pb, SIGNAL( clicked() ), this, SLOT ( setLocalStore() ) ); 219 connect(pb, SIGNAL( clicked() ), this, SLOT ( setLocalStore() ) );
215#endif 220#endif
216 new QLabel( i18n("<b>New settings are used\nafter a restart</b>"), storePage ); 221 new QLabel( i18n("<b>New settings are used\nafter a restart</b>"), storePage );
217 mDataStoragePath = new QLabel( i18n("Settings are stored in\n%1").arg(QDir::homeDirPath() + "/.microkdehome" ), storePage ); 222 mDataStoragePath = new QLabel( i18n("Settings are stored in\n%1").arg(QDir::homeDirPath() + "/.microkdehome" ), storePage );
218 tabWidget->addTab( storePage, i18n( "Data storage path" ) ); 223 tabWidget->addTab( storePage, i18n( "Data storage path" ) );
219 224
220#ifdef DESKTOP_VERSION 225#ifdef DESKTOP_VERSION
221 if ( mStoreUrl->url().startsWith( "LOCAL:" ) ) { 226 if ( mStoreUrl->url().startsWith( "LOCAL:" ) ) {
222 mDataStoragePath->setText( i18n("Settings are stored in\n%1").arg( qApp->applicationDirPath ()+"/.microkdehome" )); 227 mDataStoragePath->setText( i18n("Settings are stored in\n%1").arg( qApp->applicationDirPath ()+"/.microkdehome" ));
223 } 228 }
224#endif 229#endif
225} 230}
226void KDEPIMConfigWidget::setLocalStore() 231void KDEPIMConfigWidget::setLocalStore()
227{ 232{
228 mStoreUrl->setURL( "LOCAL:kdepimpi" ); 233 mStoreUrl->setURL( "LOCAL:kdepimpi" );
229 saveStoreSettings(); 234 saveStoreSettings();
230 QString message = i18n("'LOCAL' mode makes is possible to run\nKA/Pi and KO/Pi from a USB memory stick.\nIn LOCAL mode the data is stored\nin a path relative to the executable.\nNote, that in LOCAL mode only addressbook\nresource files in\n <path of the executable>/<dirname after LOCAL:>/apps/kabc/*.vcf\n are supported.\nIf you use the standard addressbook settings\nyou do not have to reconfigure any path,\njust restart the application and import\nyour addressbook and calendar data."); 235 QString message = i18n("'LOCAL' mode makes is possible to run\nKA/Pi and KO/Pi from a USB memory stick.\nIn LOCAL mode the data is stored\nin a path relative to the executable.\nNote, that in LOCAL mode only addressbook\nresource files in\n <path of the executable>/<dirname after LOCAL:>/apps/kabc/*.vcf\n are supported.\nIf you use the standard addressbook settings\nyou do not have to reconfigure any path,\njust restart the application and import\nyour addressbook and calendar data.");
231 KMessageBox::information( this, message); 236 KMessageBox::information( this, message);
232} 237}
233void KDEPIMConfigWidget::setStandardStore() 238void KDEPIMConfigWidget::setStandardStore()
234{ 239{
235 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" ); 240 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" );
236 saveStoreSettings(); 241 saveStoreSettings();
237} 242}
238void KDEPIMConfigWidget::saveStoreSettings() 243void KDEPIMConfigWidget::saveStoreSettings()
239{ 244{
240#ifdef DESKTOP_VERSION 245#ifdef DESKTOP_VERSION
241 if ( !mStoreUrl->url().startsWith( "LOCAL:" ) ) { 246 if ( !mStoreUrl->url().startsWith( "LOCAL:" ) ) {
242 QString file = qApp->applicationDirPath ()+"/.microkdehome"; 247 QString file = qApp->applicationDirPath ()+"/.microkdehome";
243 QFileInfo fi ( file ); 248 QFileInfo fi ( file );
244 if ( fi.exists() ) { 249 if ( fi.exists() ) {
245 bool res = QFile::remove( file ); 250 bool res = QFile::remove( file );
246 if ( ! res ) 251 if ( ! res )
247 KMessageBox::information( this, i18n("ERROR: Cannot remove file\n%1\nPlease remove it manually.").arg( file )); 252 KMessageBox::information( this, i18n("ERROR: Cannot remove file\n%1\nPlease remove it manually.").arg( file ));
248 } 253 }
249 } 254 }
250#endif 255#endif
251 if ( !mStoreUrl->url().isEmpty() ) { 256 if ( !mStoreUrl->url().isEmpty() ) {
252 QString path = QDir::homeDirPath(); 257 QString path = QDir::homeDirPath();
253 QString url = mStoreUrl->url(); 258 QString url = mStoreUrl->url();
254#ifdef DESKTOP_VERSION 259#ifdef DESKTOP_VERSION
255 if ( url.startsWith( "LOCAL:" ) ) { 260 if ( url.startsWith( "LOCAL:" ) ) {
256 path = qApp->applicationDirPath () ; 261 path = qApp->applicationDirPath () ;
257 } 262 }
258#endif 263#endif
259 KConfig cfg ( path + "/.microkdehome" ); 264 KConfig cfg ( path + "/.microkdehome" );
260 cfg.setGroup("Global"); 265 cfg.setGroup("Global");
261 cfg.writeEntry( "MICROKDEHOME", url ); 266 cfg.writeEntry( "MICROKDEHOME", url );
262 qDebug("cfg.writeEntry( MICROKDEHOME, %s ", url.latin1()); 267 qDebug("cfg.writeEntry( MICROKDEHOME, %s ", url.latin1());
263 cfg.sync(); 268 cfg.sync();
264 mDataStoragePath->setText( i18n("Settings are stored in\n%1").arg( path+"/.microkdehome" )); 269 mDataStoragePath->setText( i18n("Settings are stored in\n%1").arg( path+"/.microkdehome" ));
265 } else { 270 } else {
266 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" ); 271 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" );
267 saveStoreSettings(); 272 saveStoreSettings();
268 } 273 }
269} 274}
270void KDEPIMConfigWidget::setupExternalAppTab() 275void KDEPIMConfigWidget::setupExternalAppTab()
271{ 276{
272 QWidget *externalAppsPage = new QWidget( this ); 277 QWidget *externalAppsPage = new QWidget( this );
273 QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(), 278 Q3VBoxLayout* layout = new Q3VBoxLayout( externalAppsPage, KDialog::marginHintSmall(),
274 KDialog::spacingHintSmall() ); 279 KDialog::spacingHintSmall() );
275 280
276 mExternalApps = new QComboBox( externalAppsPage ); 281 mExternalApps = new QComboBox( externalAppsPage );
277 282
278 QMap<ExternalAppHandler::Types, QString>::Iterator it; 283 QMap<ExternalAppHandler::Types, QString>::Iterator it;
279 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it ) 284 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it )
280 mExternalApps->insertItem( it.data(), it.key() ); 285 mExternalApps->insertItem( it.data(), it.key() );
281 286
282 layout->addWidget( mExternalApps ); 287 layout->addWidget( mExternalApps );
283 288
284 connect( mExternalApps, SIGNAL( activated( int ) ), 289 connect( mExternalApps, SIGNAL( activated( int ) ),
285 this, SLOT (externalapp_changed( int ) ) ); 290 this, SLOT (externalapp_changed( int ) ) );
286 291
287 292
288 mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage ); 293 mExternalAppGroupBox = new Q3GroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage );
289 QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" ); 294 Q3GridLayout *boxLayout = new Q3GridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" );
290 mExternalAppGroupBox->layout()->setMargin(4); 295 mExternalAppGroupBox->layout()->setMargin(4);
291 296
292 mClient = new QComboBox( mExternalAppGroupBox ); 297 mClient = new QComboBox( mExternalAppGroupBox );
293 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 ); 298 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 );
294 299
295 connect( mClient, SIGNAL( activated( int ) ), 300 connect( mClient, SIGNAL( activated( int ) ),
296 this, SLOT (client_changed( int ) ) ); 301 this, SLOT (client_changed( int ) ) );
297 302
298 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox); 303 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox);
299 boxLayout->addWidget( lab, 1, 0 ); 304 boxLayout->addWidget( lab, 1, 0 );
300 mChannel = new QLineEdit(mExternalAppGroupBox); 305 mChannel = new QLineEdit(mExternalAppGroupBox);
301 mChannel->setReadOnly(true); 306 mChannel->setReadOnly(true);
302 boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 ); 307 boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 );
303 308
304 lab = new QLabel( i18n("Message:"), mExternalAppGroupBox); 309 lab = new QLabel( i18n("Message:"), mExternalAppGroupBox);
305 boxLayout->addWidget( lab, 3, 0 ); 310 boxLayout->addWidget( lab, 3, 0 );
306 mMessage = new QLineEdit(mExternalAppGroupBox); 311 mMessage = new QLineEdit(mExternalAppGroupBox);
307 mMessage->setReadOnly(true); 312 mMessage->setReadOnly(true);
308 boxLayout->addWidget( mMessage , 4, 0); 313 boxLayout->addWidget( mMessage , 4, 0);
309 314
310 lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox); 315 lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox);
311 boxLayout->addWidget( lab, 3, 1 ); 316 boxLayout->addWidget( lab, 3, 1 );
312 mParameters = new QLineEdit(mExternalAppGroupBox); 317 mParameters = new QLineEdit(mExternalAppGroupBox);
313 mParameters->setReadOnly(true); 318 mParameters->setReadOnly(true);
314 boxLayout->addWidget( mParameters, 4, 1 ); 319 boxLayout->addWidget( mParameters, 4, 1 );
315 lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox); 320 lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox);
316 boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 ); 321 boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 );
317 322
318 323
319 if ( QApplication::desktop()->height() > 240 ) { 324 if ( QApplication::desktop()->height() > 240 ) {
320 lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox); 325 lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox);
321 boxLayout->addWidget( lab, 6, 0 ); 326 boxLayout->addWidget( lab, 6, 0 );
322 mMessage2 = new QLineEdit(mExternalAppGroupBox); 327 mMessage2 = new QLineEdit(mExternalAppGroupBox);
323 mMessage2->setReadOnly(true); 328 mMessage2->setReadOnly(true);
324 boxLayout->addWidget( mMessage2 , 7, 0); 329 boxLayout->addWidget( mMessage2 , 7, 0);
325 330
326 lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox); 331 lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox);
327 boxLayout->addWidget( lab, 6, 1 ); 332 boxLayout->addWidget( lab, 6, 1 );
328 mParameters2 = new QLineEdit(mExternalAppGroupBox); 333 mParameters2 = new QLineEdit(mExternalAppGroupBox);
329 mParameters2->setReadOnly(true); 334 mParameters2->setReadOnly(true);
330 boxLayout->addWidget( mParameters2, 7, 1 ); 335 boxLayout->addWidget( mParameters2, 7, 1 );
331 336
332 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox); 337 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox);
333 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 ); 338 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 );
334 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 339 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
335 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 340 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
336 } else { 341 } else {
337 mMessage2 = 0; 342 mMessage2 = 0;
338 mParameters2 = 0; 343 mParameters2 = 0;
339 } 344 }
340 345
341 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 346 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
342 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 347 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
343 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 348 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
344 349
345 350
346 layout->addWidget( mExternalAppGroupBox ); 351 layout->addWidget( mExternalAppGroupBox );
347 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) ); 352 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) );
348 353
349} 354}
350 355
351 356
352void KDEPIMConfigWidget::setupLocaleDateTab() 357void KDEPIMConfigWidget::setupLocaleDateTab()
353{ 358{
354 QWidget *topFrame = new QWidget( this ); 359 QWidget *topFrame = new QWidget( this );
355 QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2); 360 Q3GridLayout *topLayout = new Q3GridLayout( topFrame, 3, 2);
356 361
357 topLayout->setSpacing(KDialog::spacingHintSmall()); 362 topLayout->setSpacing(KDialog::spacingHintSmall());
358 topLayout->setMargin(KDialog::marginHintSmall()); 363 topLayout->setMargin(KDialog::marginHintSmall());
359 int iii = 0; 364 int iii = 0;
360 365
361 366
362 KPrefsWidRadios *syncPrefsGroup = 367 KPrefsWidRadios *syncPrefsGroup =
363 addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame); 368 addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame);
364 QString format; 369 QString format;
365 if ( QApplication::desktop()->width() < 480 ) 370 if ( QApplication::desktop()->width() < 480 )
366 format = "(%d.%m.%Y)"; 371 format = "(%d.%m.%Y)";
367 else 372 else
368 format = "(%d.%m.%Y|%A %d %B %Y)"; 373 format = "(%d.%m.%Y|%A %d %B %Y)";
369 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); 374 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
370 if ( QApplication::desktop()->width() < 480 ) 375 if ( QApplication::desktop()->width() < 480 )
371 format = "(%m.%d.%Y)"; 376 format = "(%m.%d.%Y)";
372 else 377 else
373 format = "(%m.%d.%Y|%A %B %d %Y)"; 378 format = "(%m.%d.%Y|%A %B %d %Y)";
374 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); 379 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format));
375 if ( QApplication::desktop()->width() < 480 ) 380 if ( QApplication::desktop()->width() < 480 )
376 format = "(%Y-%m-%d)"; 381 format = "(%Y-%m-%d)";
377 else 382 else
378 format = "(%Y-%m-%d|%A %Y %B %d)"; 383 format = "(%Y-%m-%d|%A %Y %B %d)";
379 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); 384 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format));
380 syncPrefsGroup->addRadio(i18n("User defined")); 385 syncPrefsGroup->addRadio(i18n("User defined"));
381 if ( QApplication::desktop()->width() < 480 ) { 386 if ( QApplication::desktop()->width() < 480 ) {
382 syncPrefsGroup->groupBox()->layout()->setMargin( 5 ); 387 syncPrefsGroup->groupBox()->layout()->setMargin( 5 );
383 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 ); 388 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 );
384 } 389 }
385 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); 390 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
386 ++iii; 391 ++iii;
387 ++iii; 392 ++iii;
388 QLabel * lab; 393 QLabel * lab;
389 mUserDateFormatLong = new QLineEdit(topFrame); 394 mUserDateFormatLong = new QLineEdit(topFrame);
390 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); 395 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame);
391 topLayout->addWidget(lab ,iii,0); 396 topLayout->addWidget(lab ,iii,0);
392 topLayout->addWidget(mUserDateFormatLong,iii,1); 397 topLayout->addWidget(mUserDateFormatLong,iii,1);
393 ++iii; 398 ++iii;
394 mUserDateFormatShort = new QLineEdit(topFrame); 399 mUserDateFormatShort = new QLineEdit(topFrame);
395 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); 400 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame);
396 topLayout->addWidget(lab ,iii,0); 401 topLayout->addWidget(lab ,iii,0);
397 topLayout->addWidget(mUserDateFormatShort,iii,1); 402 topLayout->addWidget(mUserDateFormatShort,iii,1);
398 ++iii; 403 ++iii;
399 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); 404 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame);
400 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 405 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
401 ++iii; 406 ++iii;
402 //qDebug(" QApplication::desktop()->height()xx %d ", QApplication::desktop()->height() ); 407 //qDebug(" QApplication::desktop()->height()xx %d ", QApplication::desktop()->height() );
403 if ( QApplication::desktop()->height() > 240 ) { 408 if ( QApplication::desktop()->height() > 240 ) {
404 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); 409 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame);
405 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 410 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
406 ++iii; 411 ++iii;
407 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); 412 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame);
408 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 413 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
409 ++iii; 414 ++iii;
410 } 415 }
411 416
412 connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 417 connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
413 connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 418 connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
414 419
415 420
416 tabWidget->addTab( topFrame, i18n( "Date Format" ) ); 421 tabWidget->addTab( topFrame, i18n( "Date Format" ) );
417} 422}
418 423
419void KDEPIMConfigWidget::setupLocaleTab() 424void KDEPIMConfigWidget::setupLocaleTab()
420{ 425{
421 426
422 QWidget *topFrame = new QWidget( this ); 427 QWidget *topFrame = new QWidget( this );
423 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 428 Q3GridLayout *topLayout = new Q3GridLayout(topFrame,4,2);
424 429
425 topLayout->setSpacing(KDialog::spacingHint()); 430 topLayout->setSpacing(KDialog::spacingHint());
426 topLayout->setMargin(KDialog::marginHint()); 431 topLayout->setMargin(KDialog::marginHint());
427 int iii = 0; 432 int iii = 0;
428 KPrefsWidRadios *syncPrefsGroup = 433 KPrefsWidRadios *syncPrefsGroup =
429 addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame); 434 addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame);
430 syncPrefsGroup->addRadio(i18n("English")); 435 syncPrefsGroup->addRadio(i18n("English"));
431 syncPrefsGroup->addRadio(i18n("German")); 436 syncPrefsGroup->addRadio(i18n("German"));
432 syncPrefsGroup->addRadio(i18n("French")); 437 syncPrefsGroup->addRadio(i18n("French"));
433 syncPrefsGroup->addRadio(i18n("Italian")); 438 syncPrefsGroup->addRadio(i18n("Italian"));
434 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); 439 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)"));
435 if ( QApplication::desktop()->width() < 300 ) { 440 if ( QApplication::desktop()->width() < 300 ) {
436 syncPrefsGroup->groupBox()->layout()->setMargin( 5 ); 441 syncPrefsGroup->groupBox()->layout()->setMargin( 5 );
437 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 ); 442 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 );
438 } 443 }
439 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); 444 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
440 ++iii; 445 ++iii;
441 446
442 447
443 tabWidget->addTab( topFrame, i18n( "Language" ) ); 448 tabWidget->addTab( topFrame, i18n( "Language" ) );
444 topFrame = new QWidget( this ); 449 topFrame = new QWidget( this );
445 topLayout = new QGridLayout(topFrame,4,2); 450 topLayout = new Q3GridLayout(topFrame,4,2);
446 451
447 topLayout->setSpacing(KDialog::spacingHint()); 452 topLayout->setSpacing(KDialog::spacingHint());
448 topLayout->setMargin(KDialog::marginHint()); 453 topLayout->setMargin(KDialog::marginHint());
449 iii = 0; 454 iii = 0;
450 syncPrefsGroup = 455 syncPrefsGroup =
451 addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame); 456 addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame);
452 if ( QApplication::desktop()->width() > 300 ) 457 if ( QApplication::desktop()->width() > 300 )
453 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); 458 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
454 syncPrefsGroup->addRadio(i18n("24:00")); 459 syncPrefsGroup->addRadio(i18n("24:00"));
455 syncPrefsGroup->addRadio(i18n("12:00am")); 460 syncPrefsGroup->addRadio(i18n("12:00am"));
456 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); 461 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
457 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 462 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
458 ++iii; 463 ++iii;
459 464
460 KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"), 465 KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"),
461 &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame); 466 &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame);
462 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 467 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
463 ++iii; 468 ++iii;
464 469
465 470
466 tabWidget->addTab( topFrame, i18n( "Time Format" ) ); 471 tabWidget->addTab( topFrame, i18n( "Time Format" ) );
467 472
468} 473}
469 474
470 475
471void KDEPIMConfigWidget::setupTimeZoneTab() 476void KDEPIMConfigWidget::setupTimeZoneTab()
472{ 477{
473 QWidget *topFrame; 478 QWidget *topFrame;
474 QGridLayout *topLayout ; 479 Q3GridLayout *topLayout ;
475 480
476 481
477 482
478 483
479 484
480 485
481 topFrame = new QWidget( this ); 486 topFrame = new QWidget( this );
482 topLayout = new QGridLayout( topFrame, 5, 2); 487 topLayout = new Q3GridLayout( topFrame, 5, 2);
483 topLayout->setSpacing(KDialog::spacingHintSmall()); 488 topLayout->setSpacing(KDialog::spacingHintSmall());
484 topLayout->setMargin(KDialog::marginHintSmall()); 489 topLayout->setMargin(KDialog::marginHintSmall());
485 490
486 QHBox *timeZoneBox = new QHBox( topFrame ); 491 Q3HBox *timeZoneBox = new Q3HBox( topFrame );
487 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); 492 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
488 493
489 new QLabel( i18n("Timezone:"), timeZoneBox ); 494 new QLabel( i18n("Timezone:"), timeZoneBox );
490 mTimeZoneCombo = new QComboBox( timeZoneBox ); 495 mTimeZoneCombo = new QComboBox( timeZoneBox );
491 if ( QApplication::desktop()->width() < 300 ) { 496 if ( QApplication::desktop()->width() < 300 ) {
492 mTimeZoneCombo->setMaximumWidth(150); 497 mTimeZoneCombo->setMaximumWidth(150);
493 } 498 }
494 499
495 QStringList list; 500 QStringList list;
496 list = KGlobal::locale()->timeZoneList(); 501 list = KGlobal::locale()->timeZoneList();
497 mTimeZoneCombo->insertStringList(list); 502 mTimeZoneCombo->insertStringList(list);
498 503
499 // find the currently set time zone and select it 504 // find the currently set time zone and select it
500 QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId; 505 QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId;
501 int nCurrentlySet = 11; 506 int nCurrentlySet = 11;
502 for (int i = 0; i < mTimeZoneCombo->count(); i++) 507 for (int i = 0; i < mTimeZoneCombo->count(); i++)
503 { 508 {
504 if (mTimeZoneCombo->text(i) == sCurrentlySet) 509 if (mTimeZoneCombo->text(i) == sCurrentlySet)
505 { 510 {
506 nCurrentlySet = i; 511 nCurrentlySet = i;
507 break; 512 break;
508 } 513 }
509 } 514 }
510 mTimeZoneCombo->setCurrentItem(nCurrentlySet); 515 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
511 int iii = 1; 516 int iii = 1;
512 KPrefsWidBool *sb = 517 KPrefsWidBool *sb =
513 addWidBool(i18n("Add 30 min to selected Timezone"), 518 addWidBool(i18n("Add 30 min to selected Timezone"),
514 &(KPimGlobalPrefs::instance()->mTimeZoneAdd30min),topFrame); 519 &(KPimGlobalPrefs::instance()->mTimeZoneAdd30min),topFrame);
515 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 520 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
516 ++iii; 521 ++iii;
517 sb = 522 sb =
518 addWidBool(i18n("Timezone has daylight saving"), 523 addWidBool(i18n("Timezone has daylight saving"),
519 &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame); 524 &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame);
520 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 525 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
521 ++iii; 526 ++iii;
522 QLabel* lab; 527 QLabel* lab;
523 528
524 lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame ); 529 lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame );
525 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 530 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
526 ++iii; 531 ++iii;
527 532
528 lab = new QLabel( i18n("The year in the date is ignored."), topFrame ); 533 lab = new QLabel( i18n("The year in the date is ignored."), topFrame );
529 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 534 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
530 ++iii; 535 ++iii;
531 lab = new QLabel( i18n("Daylight start:"), topFrame ); 536 lab = new QLabel( i18n("Daylight start:"), topFrame );
532 topLayout->addWidget(lab, iii,0); 537 topLayout->addWidget(lab, iii,0);
533 mStartDateSavingEdit = new KDateEdit(topFrame); 538 mStartDateSavingEdit = new KDateEdit(topFrame);
534 topLayout->addWidget(mStartDateSavingEdit, iii,1); 539 topLayout->addWidget(mStartDateSavingEdit, iii,1);
535 ++iii; 540 ++iii;
536 541
537 lab = new QLabel( i18n("Daylight end:"), topFrame ); 542 lab = new QLabel( i18n("Daylight end:"), topFrame );
538 topLayout->addWidget(lab, iii,0); 543 topLayout->addWidget(lab, iii,0);
539 mEndDateSavingEdit = new KDateEdit(topFrame); 544 mEndDateSavingEdit = new KDateEdit(topFrame);
540 topLayout->addWidget(mEndDateSavingEdit, iii,1); 545 topLayout->addWidget(mEndDateSavingEdit, iii,1);
541 ++iii; 546 ++iii;
542 QDate current ( 2001, 1,1); 547 QDate current ( 2001, 1,1);
543 mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1)); 548 mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1));
544 mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1)); 549 mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1));
545 550
546 connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); 551 connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
547 connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); 552 connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
548 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) ); 553 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) );
549 tabWidget->addTab( topFrame, i18n( "Time Zone" ) ); 554 tabWidget->addTab( topFrame, i18n( "Time Zone" ) );
550 555
551 556
552 topFrame = new QWidget( this ); 557 topFrame = new QWidget( this );
553 topLayout = new QGridLayout( topFrame, 3, 2); 558 topLayout = new Q3GridLayout( topFrame, 3, 2);
554 topLayout->setSpacing(KDialog::spacingHintSmall()); 559 topLayout->setSpacing(KDialog::spacingHintSmall());
555 topLayout->setMargin(KDialog::marginHintSmall()); 560 topLayout->setMargin(KDialog::marginHintSmall());
556 tabWidget->addTab( topFrame, i18n( "Fonts" ) ); 561 tabWidget->addTab( topFrame, i18n( "Fonts" ) );
557 562
558 QLabel* labb = new QLabel( i18n("Global application font for all apps:"), topFrame ); 563 QLabel* labb = new QLabel( i18n("Global application font for all apps:"), topFrame );
559 topLayout->addMultiCellWidget(labb,0,0,0,2); 564 topLayout->addMultiCellWidget(labb,0,0,0,2);
560 int i = 1; 565 int i = 1;
561 KPrefsWidFont *timeLabelsFont = 566 KPrefsWidFont *timeLabelsFont =
562 addWidFont(i18n("Kx/Pi"),i18n("Application Font"), 567 addWidFont(i18n("Kx/Pi"),i18n("Application Font"),
563 &(KPimGlobalPrefs::instance()->mApplicationFont),topFrame); 568 &(KPimGlobalPrefs::instance()->mApplicationFont),topFrame);
564 topLayout->addWidget(timeLabelsFont->label(),i,0); 569 topLayout->addWidget(timeLabelsFont->label(),i,0);
565 topLayout->addWidget(timeLabelsFont->preview(),i,1); 570 topLayout->addWidget(timeLabelsFont->preview(),i,1);
566 topLayout->addWidget(timeLabelsFont->button(),i,2); 571 topLayout->addWidget(timeLabelsFont->button(),i,2);
567} 572}
568 573
569void KDEPIMConfigWidget::externalapp_changed( int newApp ) 574void KDEPIMConfigWidget::externalapp_changed( int newApp )
570{ 575{
571 // first store the current data 576 // first store the current data
572 saveEditFieldSettings(); 577 saveEditFieldSettings();
573 578
574 // set mCurrentApp 579 // set mCurrentApp
575 mCurrentApp = (ExternalAppHandler::Types)newApp; 580 mCurrentApp = (ExternalAppHandler::Types)newApp;
576 581
577 // set mCurrentClient 582 // set mCurrentClient
578 switch(mCurrentApp) 583 switch(mCurrentApp)
579 { 584 {
580 case(ExternalAppHandler::EMAIL): 585 case(ExternalAppHandler::EMAIL):
581 mCurrentClient = mEmailClient; 586 mCurrentClient = mEmailClient;
582 break; 587 break;
583 case(ExternalAppHandler::PHONE): 588 case(ExternalAppHandler::PHONE):
584 mCurrentClient = mPhoneClient; 589 mCurrentClient = mPhoneClient;
585 break; 590 break;
586 case(ExternalAppHandler::SMS): 591 case(ExternalAppHandler::SMS):
587 mCurrentClient = mSMSClient; 592 mCurrentClient = mSMSClient;
588 break; 593 break;
589 case(ExternalAppHandler::FAX): 594 case(ExternalAppHandler::FAX):
590 mCurrentClient = mFaxClient; 595 mCurrentClient = mFaxClient;
591 break; 596 break;
592 case(ExternalAppHandler::PAGER): 597 case(ExternalAppHandler::PAGER):
593 mCurrentClient = mPagerClient; 598 mCurrentClient = mPagerClient;
594 break; 599 break;
595 case(ExternalAppHandler::SIP): 600 case(ExternalAppHandler::SIP):
596 mCurrentClient = mSipClient; 601 mCurrentClient = mSipClient;
597 break; 602 break;
598 default: 603 default:
599 return; 604 return;
600 } 605 }
601 606
602 // and at last update the widgets 607 // and at last update the widgets
603 updateClientWidgets(); 608 updateClientWidgets();
604} 609}
605 610
606 611
607 612
608void KDEPIMConfigWidget::client_changed( int newClient ) 613void KDEPIMConfigWidget::client_changed( int newClient )
609{ 614{
610 if (newClient == mCurrentClient) 615 if (newClient == mCurrentClient)
611 return; 616 return;
612 617
613 // first store the current data 618 // first store the current data
614 saveEditFieldSettings(); 619 saveEditFieldSettings();
615 620
616 621
617 //then reset the clientvariable 622 //then reset the clientvariable
618 mCurrentClient = newClient; 623 mCurrentClient = newClient;
619 624
620 // and at last update the widgets 625 // and at last update the widgets
621 updateClientWidgets(); 626 updateClientWidgets();
622 627
623 KPrefsWidget::modified(); 628 KPrefsWidget::modified();
624} 629}
625 630
626void KDEPIMConfigWidget::saveEditFieldSettings() 631void KDEPIMConfigWidget::saveEditFieldSettings()
627{ 632{
628 633
629 switch(mCurrentApp) 634 switch(mCurrentApp)
630 { 635 {
631 case(ExternalAppHandler::EMAIL): 636 case(ExternalAppHandler::EMAIL):
632 mEmailClient = mClient->currentItem(); 637 mEmailClient = mClient->currentItem();
633 break; 638 break;
634 case(ExternalAppHandler::PHONE): 639 case(ExternalAppHandler::PHONE):
635 mPhoneClient= mClient->currentItem(); 640 mPhoneClient= mClient->currentItem();
636 break; 641 break;
637 case(ExternalAppHandler::SMS): 642 case(ExternalAppHandler::SMS):
638 mSMSClient = mClient->currentItem(); 643 mSMSClient = mClient->currentItem();
639 break; 644 break;
640 case(ExternalAppHandler::FAX): 645 case(ExternalAppHandler::FAX):
641 mFaxClient = mClient->currentItem(); 646 mFaxClient = mClient->currentItem();
642 break; 647 break;
643 case(ExternalAppHandler::PAGER): 648 case(ExternalAppHandler::PAGER):
644 mPagerClient = mClient->currentItem(); 649 mPagerClient = mClient->currentItem();
645 break; 650 break;
646 case(ExternalAppHandler::SIP): 651 case(ExternalAppHandler::SIP):
647 mSipClient = mClient->currentItem(); 652 mSipClient = mClient->currentItem();
648 break; 653 break;
649 default: 654 default:
650 return; 655 return;
651 } 656 }
652 657
653 //store the current data back to the apropriate membervariables if we had set it to "other" 658 //store the current data back to the apropriate membervariables if we had set it to "other"
654 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 659 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
655 { 660 {
656 mEmailOtherChannel = mChannel->text(); 661 mEmailOtherChannel = mChannel->text();
657 mEmailOtherMessage = mMessage->text(); 662 mEmailOtherMessage = mMessage->text();
658 mEmailOtherMessageParameters = mParameters->text(); 663 mEmailOtherMessageParameters = mParameters->text();
659 if ( mMessage2 ) 664 if ( mMessage2 )
660 mEmailOtherMessage2 = mMessage2->text(); 665 mEmailOtherMessage2 = mMessage2->text();
661 if ( mParameters2 ) 666 if ( mParameters2 )
662 mEmailOtherMessageParameters2 = mParameters2->text(); 667 mEmailOtherMessageParameters2 = mParameters2->text();
663 } 668 }
664 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 669 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
665 { 670 {
666 mPhoneOtherChannel = mChannel->text(); 671 mPhoneOtherChannel = mChannel->text();
667 mPhoneOtherMessage = mMessage->text(); 672 mPhoneOtherMessage = mMessage->text();
668 mPhoneOtherMessageParameters = mParameters->text(); 673 mPhoneOtherMessageParameters = mParameters->text();
669 } 674 }
670 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 675 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
671 { 676 {
672 mSMSOtherChannel = mChannel->text(); 677 mSMSOtherChannel = mChannel->text();
673 mSMSOtherMessage = mMessage->text(); 678 mSMSOtherMessage = mMessage->text();
674 mSMSOtherMessageParameters = mParameters->text(); 679 mSMSOtherMessageParameters = mParameters->text();
675 } 680 }
676 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 681 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
677 { 682 {
678 mFaxOtherChannel = mChannel->text(); 683 mFaxOtherChannel = mChannel->text();
679 mFaxOtherMessage = mMessage->text(); 684 mFaxOtherMessage = mMessage->text();
680 mFaxOtherMessageParameters = mParameters->text(); 685 mFaxOtherMessageParameters = mParameters->text();
681 } 686 }
682 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 687 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
683 { 688 {
684 mPagerOtherChannel = mChannel->text(); 689 mPagerOtherChannel = mChannel->text();
685 mPagerOtherMessage = mMessage->text(); 690 mPagerOtherMessage = mMessage->text();
686 mPagerOtherMessageParameters = mParameters->text(); 691 mPagerOtherMessageParameters = mParameters->text();
687 } 692 }
688 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) 693 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))
689 { 694 {
690 mSipOtherChannel = mChannel->text(); 695 mSipOtherChannel = mChannel->text();
691 mSipOtherMessage = mMessage->text(); 696 mSipOtherMessage = mMessage->text();
692 mSipOtherMessageParameters = mParameters->text(); 697 mSipOtherMessageParameters = mParameters->text();
693 } 698 }
694 699
695 700
696} 701}
697 702
698void KDEPIMConfigWidget::updateClientWidgets() 703void KDEPIMConfigWidget::updateClientWidgets()
699{ 704{
700 bool blocked = signalsBlocked(); 705 bool blocked = signalsBlocked();
701 blockSignals( true ); 706 blockSignals( true );
702 707
703 // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display 708 // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display
704 QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp ); 709 QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp );
705 if (it == mExternalAppsMap.end()) 710 if (it == mExternalAppsMap.end())
706 return; 711 return;
707 712
708 // update group box 713 // update group box
709 mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data())); 714 mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data()));
710 715
711 //update the entries in the client combobox 716 //update the entries in the client combobox
712 mClient->clear(); 717 mClient->clear();
713 718
714 QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp); 719 Q3PtrList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp);
715 DefaultAppItem* dai; 720 DefaultAppItem* dai;
716 for ( dai=items.first(); dai != 0; dai=items.next() ) 721 for ( dai=items.first(); dai != 0; dai=items.next() )
717 { 722 {
718 mClient->insertItem( i18n(dai->_label), dai->_id ); 723 mClient->insertItem( i18n(dai->_label), dai->_id );
719 724
720 if (dai->_id == mCurrentClient) 725 if (dai->_id == mCurrentClient)
721 { 726 {
722 //restore the edit fields with the data of the local membervariables if we had set it to "other". 727 //restore the edit fields with the data of the local membervariables if we had set it to "other".
723 //Otherwise take the default data from externalapphandler. 728 //Otherwise take the default data from externalapphandler.
724 mChannel->setText(dai->_channel); 729 mChannel->setText(dai->_channel);
725 mMessage->setText(dai->_message); 730 mMessage->setText(dai->_message);
726 mParameters->setText(dai->_parameters); 731 mParameters->setText(dai->_parameters);
727 if ( mMessage2 ) 732 if ( mMessage2 )
728 mMessage2->setText(dai->_message2); 733 mMessage2->setText(dai->_message2);
729 if ( mParameters2 ) 734 if ( mParameters2 )
730 mParameters2->setText(dai->_parameters2); 735 mParameters2->setText(dai->_parameters2);
731 736
732 737
733 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 738 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
734 { 739 {
735 mChannel->setText(mEmailOtherChannel); 740 mChannel->setText(mEmailOtherChannel);
736 mMessage->setText(mEmailOtherMessage); 741 mMessage->setText(mEmailOtherMessage);
737 mParameters->setText(mEmailOtherMessageParameters); 742 mParameters->setText(mEmailOtherMessageParameters);
738 if ( mMessage2 ) 743 if ( mMessage2 )
739 mMessage2->setText(mEmailOtherMessage2); 744 mMessage2->setText(mEmailOtherMessage2);
740 if ( mParameters2 ) 745 if ( mParameters2 )
741 mParameters2->setText(mEmailOtherMessageParameters2); 746 mParameters2->setText(mEmailOtherMessageParameters2);
742 } 747 }
743 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 748 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
744 { 749 {
745 mChannel->setText(mPhoneOtherChannel); 750 mChannel->setText(mPhoneOtherChannel);
746 mMessage->setText(mPhoneOtherMessage); 751 mMessage->setText(mPhoneOtherMessage);
747 mParameters->setText(mPhoneOtherMessageParameters); 752 mParameters->setText(mPhoneOtherMessageParameters);
748 } 753 }
749 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 754 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
750 { 755 {
751 mChannel->setText(mSMSOtherChannel); 756 mChannel->setText(mSMSOtherChannel);
752 mMessage->setText(mSMSOtherMessage); 757 mMessage->setText(mSMSOtherMessage);
753 mParameters->setText(mSMSOtherMessageParameters); 758 mParameters->setText(mSMSOtherMessageParameters);
754 } 759 }
755 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 760 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
756 { 761 {
757 mChannel->setText(mFaxOtherChannel); 762 mChannel->setText(mFaxOtherChannel);
758 mMessage->setText(mFaxOtherMessage); 763 mMessage->setText(mFaxOtherMessage);
759 mParameters->setText(mFaxOtherMessageParameters); 764 mParameters->setText(mFaxOtherMessageParameters);
760 } 765 }
761 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 766 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
762 { 767 {
763 mChannel->setText(mPagerOtherChannel); 768 mChannel->setText(mPagerOtherChannel);
764 mMessage->setText(mPagerOtherMessage); 769 mMessage->setText(mPagerOtherMessage);
765 mParameters->setText(mPagerOtherMessageParameters); 770 mParameters->setText(mPagerOtherMessageParameters);
766 } 771 }
767 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) 772 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))
768 { 773 {
769 mChannel->setText(mSipOtherChannel); 774 mChannel->setText(mSipOtherChannel);
770 mMessage->setText(mSipOtherMessage); 775 mMessage->setText(mSipOtherMessage);
771 mParameters->setText(mSipOtherMessageParameters); 776 mParameters->setText(mSipOtherMessageParameters);
772 } 777 }
773 } 778 }
774 779
775 } 780 }
776 781
777 bool readonly; 782 bool readonly;
778 bool enabled; 783 bool enabled;
779 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 784 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
780 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 785 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
781 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 786 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
782 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 787 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
783 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 788 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
784 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))) 789 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)))
785 { 790 {
786 readonly = false; 791 readonly = false;
787 } 792 }
788 else 793 else
789 { 794 {
790 readonly = true; 795 readonly = true;
791 } 796 }
792 797
793 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC)) 798 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC))
794 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC)) 799 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC))
795 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC)) 800 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC))
796 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC)) 801 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC))
797 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC)) 802 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC))
798 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC))) 803 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC)))
799 { 804 {
800 enabled = false; 805 enabled = false;
801 } 806 }
802 else 807 else
803 { 808 {
804 enabled = true; 809 enabled = true;
805 } 810 }
806 811
807 812
808 mChannel->setReadOnly(readonly); 813 mChannel->setReadOnly(readonly);
809 mMessage->setReadOnly(readonly); 814 mMessage->setReadOnly(readonly);
810 mParameters->setReadOnly(readonly); 815 mParameters->setReadOnly(readonly);
811 if ( mMessage2 ) 816 if ( mMessage2 )
812 mMessage2->setReadOnly(readonly); 817 mMessage2->setReadOnly(readonly);
813 if ( mParameters2 ) 818 if ( mParameters2 )
814 mParameters2->setReadOnly(readonly); 819 mParameters2->setReadOnly(readonly);
815 820
816 mChannel->setEnabled(enabled); 821 mChannel->setEnabled(enabled);
817 mMessage->setEnabled(enabled); 822 mMessage->setEnabled(enabled);
818 mParameters->setEnabled(enabled); 823 mParameters->setEnabled(enabled);
819 if ( mMessage2 ) 824 if ( mMessage2 )
820 mMessage2->setEnabled(enabled); 825 mMessage2->setEnabled(enabled);
821 if ( mParameters2 ) 826 if ( mParameters2 )
822 mParameters2->setEnabled(enabled); 827 mParameters2->setEnabled(enabled);
823 828
824 829
825 830
826 mClient->setCurrentItem(mCurrentClient); 831 mClient->setCurrentItem(mCurrentClient);
827 832
828 833
829 // enable/disable the extra message/parameter field 834 // enable/disable the extra message/parameter field
830 if (mCurrentApp == ExternalAppHandler::EMAIL) 835 if (mCurrentApp == ExternalAppHandler::EMAIL)
831 { 836 {
832 } 837 }
833 else 838 else
834 { 839 {
835 if ( mMessage2 ) 840 if ( mMessage2 )
836 mMessage2->setText( "" ); 841 mMessage2->setText( "" );
837 if ( mParameters2 ) 842 if ( mParameters2 )
838 mParameters2->setText( "" ); 843 mParameters2->setText( "" );
839 } 844 }
840 845
841 if (enabled == true) { 846 if (enabled == true) {
842 if ( mMessage2 ) 847 if ( mMessage2 )
843 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 848 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
844 if ( mParameters2 ) 849 if ( mParameters2 )
845 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 850 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
846 } 851 }
847 852
848 853
849 blockSignals( blocked ); 854 blockSignals( blocked );
850 855
851} 856}
852 857
853void KDEPIMConfigWidget::usrReadConfig() 858void KDEPIMConfigWidget::usrReadConfig()
854{ 859{
855 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 860 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
856 861
857 bool blocked = signalsBlocked(); 862 bool blocked = signalsBlocked();
858 blockSignals( true ); 863 blockSignals( true );
859 864
860 if (KPimGlobalPrefs::instance()->mBackupUseDefaultDir ) 865 if (KPimGlobalPrefs::instance()->mBackupUseDefaultDir )
861 mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); 866 mBackupUrl->setURL( KGlobalSettings::backupDataDir() );
862 else { 867 else {
863 mBackupUrl->setURL(prefs->mBackupDatadir); 868 mBackupUrl->setURL(prefs->mBackupDatadir);
864 869
865 } 870 }
866 mBackupNumbersSpin->setValue( prefs->mBackupNumbers ); 871 mBackupNumbersSpin->setValue( prefs->mBackupNumbers );
867 mBackupDayCountSpin->setValue( prefs->mBackupDayCount); 872 mBackupDayCountSpin->setValue( prefs->mBackupDayCount);
868 873
869 QString dummy = prefs->mUserDateFormatLong; 874 QString dummy = prefs->mUserDateFormatLong;
870 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); 875 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") ));
871 dummy = prefs->mUserDateFormatShort; 876 dummy = prefs->mUserDateFormatShort;
872 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); 877 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") ));
873 878
874 QDate current ( 2001, 1,1); 879 QDate current ( 2001, 1,1);
875 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1)); 880 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1));
876 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1)); 881 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1));
877 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId)); 882 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId));
878 883
879 mEmailClient = prefs->mEmailClient; 884 mEmailClient = prefs->mEmailClient;
880 mEmailOtherChannel = prefs->mEmailOtherChannel; 885 mEmailOtherChannel = prefs->mEmailOtherChannel;
881 mEmailOtherMessage = prefs->mEmailOtherMessage; 886 mEmailOtherMessage = prefs->mEmailOtherMessage;
882 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters; 887 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters;
883 mEmailOtherMessage2 = prefs->mEmailOtherMessage2; 888 mEmailOtherMessage2 = prefs->mEmailOtherMessage2;
884 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2; 889 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2;
885 890
886 mPhoneClient = prefs->mPhoneClient; 891 mPhoneClient = prefs->mPhoneClient;
887 mPhoneOtherChannel = prefs->mPhoneOtherChannel; 892 mPhoneOtherChannel = prefs->mPhoneOtherChannel;
888 mPhoneOtherMessage = prefs->mPhoneOtherMessage; 893 mPhoneOtherMessage = prefs->mPhoneOtherMessage;
889 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters; 894 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters;
890 895
891 mFaxClient = prefs->mFaxClient; 896 mFaxClient = prefs->mFaxClient;
892 mFaxOtherChannel = prefs->mFaxOtherChannel; 897 mFaxOtherChannel = prefs->mFaxOtherChannel;
893 mFaxOtherMessage = prefs->mFaxOtherMessage; 898 mFaxOtherMessage = prefs->mFaxOtherMessage;
894 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters; 899 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters;
895 900
896 mSMSClient = prefs->mSMSClient; 901 mSMSClient = prefs->mSMSClient;
897 mSMSOtherChannel = prefs->mSMSOtherChannel; 902 mSMSOtherChannel = prefs->mSMSOtherChannel;
898 mSMSOtherMessage = prefs->mSMSOtherMessage; 903 mSMSOtherMessage = prefs->mSMSOtherMessage;
899 mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters; 904 mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters;
900 905
901 mPagerClient = prefs->mPagerClient; 906 mPagerClient = prefs->mPagerClient;
902 mPagerOtherChannel = prefs->mPagerOtherChannel; 907 mPagerOtherChannel = prefs->mPagerOtherChannel;
903 mPagerOtherMessage = prefs->mPagerOtherMessage; 908 mPagerOtherMessage = prefs->mPagerOtherMessage;
904 mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters; 909 mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters;
905 910
906 mSipClient = prefs->mSipClient; 911 mSipClient = prefs->mSipClient;
907 mSipOtherChannel = prefs->mSipOtherChannel; 912 mSipOtherChannel = prefs->mSipOtherChannel;
908 mSipOtherMessage = prefs->mSipOtherMessage; 913 mSipOtherMessage = prefs->mSipOtherMessage;
909 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters; 914 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters;
910 915
911 mCurrentApp = ExternalAppHandler::EMAIL; 916 mCurrentApp = ExternalAppHandler::EMAIL;
912 mCurrentClient = mEmailClient; 917 mCurrentClient = mEmailClient;
913 918
914 updateClientWidgets(); 919 updateClientWidgets();
915 920
916 blockSignals( blocked ); 921 blockSignals( blocked );
917 922
918} 923}
919 924
920void KDEPIMConfigWidget::usrWriteConfig() 925void KDEPIMConfigWidget::usrWriteConfig()
921{ 926{
922 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 927 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
923 928
924 saveEditFieldSettings(); 929 saveEditFieldSettings();
925 930
926 prefs->mBackupNumbers = mBackupNumbersSpin->value(); 931 prefs->mBackupNumbers = mBackupNumbersSpin->value();
927 prefs->mBackupDayCount = mBackupDayCountSpin->value(); 932 prefs->mBackupDayCount = mBackupDayCountSpin->value();
928 QString bup_url = mBackupUrl->url(); 933 QString bup_url = mBackupUrl->url();
929 if ( bup_url.right(1) != "/" && bup_url.right(1) != "\\" ) 934 if ( bup_url.right(1) != "/" && bup_url.right(1) != "\\" )
930 bup_url += "/"; 935 bup_url += "/";
931 936
932 prefs->mBackupDatadir = bup_url; 937 prefs->mBackupDatadir = bup_url;
933 938
934 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); 939 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") );
935 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); 940 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") );
936 941
937 prefs->mTimeZoneId = mTimeZoneCombo->currentText(); 942 prefs->mTimeZoneId = mTimeZoneCombo->currentText();
938 QDate date; 943 QDate date;
939 date = mStartDateSavingEdit->date(); 944 date = mStartDateSavingEdit->date();
940 int sub = 0; 945 int sub = 0;
941 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 946 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
942 sub = 1; 947 sub = 1;
943 prefs->mDaylightsavingStart = date.dayOfYear()-sub; 948 prefs->mDaylightsavingStart = date.dayOfYear()-sub;
944 date = mEndDateSavingEdit->date(); 949 date = mEndDateSavingEdit->date();
945 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 950 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
946 sub = 1; 951 sub = 1;
947 else 952 else
948 sub = 0; 953 sub = 0;
949 prefs->mDaylightsavingEnd = date.dayOfYear()-sub; 954 prefs->mDaylightsavingEnd = date.dayOfYear()-sub;
950 955
951 956
952 prefs->mEmailClient = mEmailClient; 957 prefs->mEmailClient = mEmailClient;
953 prefs->mEmailOtherChannel = mEmailOtherChannel; 958 prefs->mEmailOtherChannel = mEmailOtherChannel;
954 prefs->mEmailOtherMessage = mEmailOtherMessage; 959 prefs->mEmailOtherMessage = mEmailOtherMessage;
955 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters; 960 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters;
956 prefs->mEmailOtherMessage2 = mEmailOtherMessage2; 961 prefs->mEmailOtherMessage2 = mEmailOtherMessage2;
957 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2; 962 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2;
958 963
959 prefs->mPhoneClient = mPhoneClient; 964 prefs->mPhoneClient = mPhoneClient;
960 prefs->mPhoneOtherChannel = mPhoneOtherChannel; 965 prefs->mPhoneOtherChannel = mPhoneOtherChannel;
961 prefs->mPhoneOtherMessage = mPhoneOtherMessage; 966 prefs->mPhoneOtherMessage = mPhoneOtherMessage;
962 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters; 967 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters;
963 968
964 prefs->mFaxClient = mFaxClient; 969 prefs->mFaxClient = mFaxClient;
965 prefs->mFaxOtherChannel = mFaxOtherChannel; 970 prefs->mFaxOtherChannel = mFaxOtherChannel;
966 prefs->mFaxOtherMessage = mFaxOtherMessage; 971 prefs->mFaxOtherMessage = mFaxOtherMessage;
967 prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters; 972 prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters;
968 973
969 prefs->mSMSClient = mSMSClient; 974 prefs->mSMSClient = mSMSClient;
970 prefs->mSMSOtherChannel = mSMSOtherChannel; 975 prefs->mSMSOtherChannel = mSMSOtherChannel;
971 prefs->mSMSOtherMessage = mSMSOtherMessage; 976 prefs->mSMSOtherMessage = mSMSOtherMessage;
972 prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters; 977 prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters;
973 978
974 prefs->mPagerClient = mPagerClient; 979 prefs->mPagerClient = mPagerClient;
975 prefs->mPagerOtherChannel = mPagerOtherChannel; 980 prefs->mPagerOtherChannel = mPagerOtherChannel;
976 prefs->mPagerOtherMessage = mPagerOtherMessage; 981 prefs->mPagerOtherMessage = mPagerOtherMessage;
977 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters; 982 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters;
978 983
979 984
980 prefs->mSipClient = mSipClient; 985 prefs->mSipClient = mSipClient;
981 prefs->mSipOtherChannel = mSipOtherChannel; 986 prefs->mSipOtherChannel = mSipOtherChannel;
982 prefs->mSipOtherMessage = mSipOtherMessage; 987 prefs->mSipOtherMessage = mSipOtherMessage;
983 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters; 988 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters;
984 989
985 //release the cache that other views can access the changed values instantanious 990 //release the cache that other views can access the changed values instantanious
986 ExternalAppHandler::instance()->loadConfig(); 991 ExternalAppHandler::instance()->loadConfig();
987 KPimGlobalPrefs::instance()->setGlobalConfig(); 992 KPimGlobalPrefs::instance()->setGlobalConfig();
988} 993}
989 994
990 995
991void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text, 996void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text,
992 const QStringList *tags) 997 const QStringList *tags)
993{ 998{
994 if (tags) { 999 if (tags) {
995 int i = tags->findIndex(text); 1000 int i = tags->findIndex(text);
996 if (i > 0) combo->setCurrentItem(i); 1001 if (i > 0) combo->setCurrentItem(i);
997 } else { 1002 } else {
998 for(int i=0;i<combo->count();++i) { 1003 for(int i=0;i<combo->count();++i) {
999 if (combo->text(i) == text) { 1004 if (combo->text(i) == text) {
1000 combo->setCurrentItem(i); 1005 combo->setCurrentItem(i);
1001 break; 1006 break;
1002 } 1007 }
1003 } 1008 }
1004 } 1009 }
1005} 1010}
1006 1011
1007 1012
1008void KDEPIMConfigWidget::textChanged( const QString& text ) 1013void KDEPIMConfigWidget::textChanged( const QString& text )
1009{ 1014{
1010 emit changed( true ); 1015 emit changed( true );
1011} 1016}
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.h b/libkdepim/kcmconfigs/kdepimconfigwidget.h
index 824ef79..d693015 100644
--- a/libkdepim/kcmconfigs/kdepimconfigwidget.h
+++ b/libkdepim/kcmconfigs/kdepimconfigwidget.h
@@ -1,163 +1,165 @@
1/* 1/*
2 This file is part of KDEPim/Pi. 2 This file is part of KDEPim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef KDEPIMCONFIGWIDGET_H 31#ifndef KDEPIMCONFIGWIDGET_H
32#define KDEPIMCONFIGWIDGET_H 32#define KDEPIMCONFIGWIDGET_H
33 33
34#include <kprefswidget.h> 34#include <kprefswidget.h>
35#include <kio/kfile/kurlrequester.h> 35#include <kio/kfile/kurlrequester.h>
36#include <qmap.h> 36#include <qmap.h>
37//Added by qt3to4:
38#include <QLabel>
37 39
38#include "externalapphandler.h" 40#include "externalapphandler.h"
39 41
40 42
41class QComboBox; 43class QComboBox;
42class QLineEdit; 44class QLineEdit;
43class KPimGlobalPrefs; 45class KPimGlobalPrefs;
44class QGroupBox; 46class Q3GroupBox;
45class QTabWidget; 47class QTabWidget;
46class KDateEdit; 48class KDateEdit;
47 49
48class KDEPIMConfigWidget : public KPrefsWidget 50class KDEPIMConfigWidget : public KPrefsWidget
49{ 51{
50 Q_OBJECT 52 Q_OBJECT
51 53
52 public: 54 public:
53 KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name = 0 ); 55 KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name = 0 );
54 56
55 public slots: 57 public slots:
56 void textChanged( const QString& text ); 58 void textChanged( const QString& text );
57 void showTimeZoneTab(); 59 void showTimeZoneTab();
58 60
59 protected: 61 protected:
60 /** Implement this to read custom configuration widgets. */ 62 /** Implement this to read custom configuration widgets. */
61 virtual void usrReadConfig(); 63 virtual void usrReadConfig();
62 /** Implement this to write custom configuration widgets. */ 64 /** Implement this to write custom configuration widgets. */
63 virtual void usrWriteConfig(); 65 virtual void usrWriteConfig();
64 66
65 67
66 private slots: 68 private slots:
67// void configureExtension(); 69// void configureExtension();
68// void selectionChanged( QListViewItem* ); 70// void selectionChanged( QListViewItem* );
69// void itemClicked( QListViewItem* ); 71// void itemClicked( QListViewItem* );
70 void client_changed( int newClient ); 72 void client_changed( int newClient );
71 void externalapp_changed( int newApp ); 73 void externalapp_changed( int newApp );
72 void saveStoreSettings(); 74 void saveStoreSettings();
73 void setStandardStore(); 75 void setStandardStore();
74 void setLocalStore(); 76 void setLocalStore();
75 77
76 private: 78 private:
77 void setupExternalAppTab(); 79 void setupExternalAppTab();
78 void setupLocaleDateTab(); 80 void setupLocaleDateTab();
79 void setupLocaleTab(); 81 void setupLocaleTab();
80 void setupTimeZoneTab(); 82 void setupTimeZoneTab();
81 void setupStoreTab(); 83 void setupStoreTab();
82 void setupBackupTab(); 84 void setupBackupTab();
83 KURLRequester* mStoreUrl; 85 KURLRequester* mStoreUrl;
84 86
85 void setCombo(QComboBox *combo,const QString & text, const QStringList *tags = 0); 87 void setCombo(QComboBox *combo,const QString & text, const QStringList *tags = 0);
86 88
87 89
88 void saveEditFieldSettings(); 90 void saveEditFieldSettings();
89 void updateClientWidgets(); 91 void updateClientWidgets();
90 92
91 QTabWidget *tabWidget; 93 QTabWidget *tabWidget;
92 94
93 95
94 QLineEdit* mUserDateFormatShort; 96 QLineEdit* mUserDateFormatShort;
95 QLineEdit* mUserDateFormatLong; 97 QLineEdit* mUserDateFormatLong;
96 QComboBox* mTimeZoneCombo; 98 QComboBox* mTimeZoneCombo;
97 KDateEdit* mStartDateSavingEdit; 99 KDateEdit* mStartDateSavingEdit;
98 KDateEdit* mEndDateSavingEdit; 100 KDateEdit* mEndDateSavingEdit;
99 101
100// void restoreExtensionSettings(); 102// void restoreExtensionSettings();
101// void saveExtensionSettings(); 103// void saveExtensionSettings();
102 104
103// KListView *mExtensionView; 105// KListView *mExtensionView;
104 106
105// QCheckBox *mNameParsing; 107// QCheckBox *mNameParsing;
106// QCheckBox *mViewsSingleClickBox; 108// QCheckBox *mViewsSingleClickBox;
107// QPushButton *mConfigureButton; 109// QPushButton *mConfigureButton;
108 QComboBox* mExternalApps; 110 QComboBox* mExternalApps;
109 QGroupBox* mExternalAppGroupBox; 111 Q3GroupBox* mExternalAppGroupBox;
110 112
111 113
112 QComboBox* mClient; 114 QComboBox* mClient;
113 QLineEdit* mChannel; 115 QLineEdit* mChannel;
114 QLineEdit* mMessage; 116 QLineEdit* mMessage;
115 QLineEdit* mParameters; 117 QLineEdit* mParameters;
116 QLineEdit* mMessage2; 118 QLineEdit* mMessage2;
117 QLineEdit* mParameters2; 119 QLineEdit* mParameters2;
118 120
119 ExternalAppHandler::Types mCurrentApp; 121 ExternalAppHandler::Types mCurrentApp;
120 int mCurrentClient; 122 int mCurrentClient;
121 123
122 124
123 int mEmailClient; 125 int mEmailClient;
124 QString mEmailOtherChannel; 126 QString mEmailOtherChannel;
125 QString mEmailOtherMessage; 127 QString mEmailOtherMessage;
126 QString mEmailOtherMessageParameters; 128 QString mEmailOtherMessageParameters;
127 QString mEmailOtherMessage2; 129 QString mEmailOtherMessage2;
128 QString mEmailOtherMessageParameters2; 130 QString mEmailOtherMessageParameters2;
129 131
130 int mPhoneClient; 132 int mPhoneClient;
131 QString mPhoneOtherChannel; 133 QString mPhoneOtherChannel;
132 QString mPhoneOtherMessage; 134 QString mPhoneOtherMessage;
133 QString mPhoneOtherMessageParameters; 135 QString mPhoneOtherMessageParameters;
134 136
135 int mFaxClient; 137 int mFaxClient;
136 QString mFaxOtherChannel; 138 QString mFaxOtherChannel;
137 QString mFaxOtherMessage; 139 QString mFaxOtherMessage;
138 QString mFaxOtherMessageParameters; 140 QString mFaxOtherMessageParameters;
139 141
140 int mSMSClient; 142 int mSMSClient;
141 QString mSMSOtherChannel; 143 QString mSMSOtherChannel;
142 QString mSMSOtherMessage; 144 QString mSMSOtherMessage;
143 QString mSMSOtherMessageParameters; 145 QString mSMSOtherMessageParameters;
144 146
145 int mPagerClient; 147 int mPagerClient;
146 QString mPagerOtherChannel; 148 QString mPagerOtherChannel;
147 QString mPagerOtherMessage; 149 QString mPagerOtherMessage;
148 QString mPagerOtherMessageParameters; 150 QString mPagerOtherMessageParameters;
149 151
150 int mSipClient; 152 int mSipClient;
151 QString mSipOtherChannel; 153 QString mSipOtherChannel;
152 QString mSipOtherMessage; 154 QString mSipOtherMessage;
153 QString mSipOtherMessageParameters; 155 QString mSipOtherMessageParameters;
154 156
155 QLabel* mDataStoragePath; 157 QLabel* mDataStoragePath;
156 KURLRequester* mBackupUrl; 158 KURLRequester* mBackupUrl;
157 QSpinBox* mBackupDayCountSpin, *mBackupNumbersSpin ; 159 QSpinBox* mBackupDayCountSpin, *mBackupNumbersSpin ;
158 QMap<ExternalAppHandler::Types, QString> mExternalAppsMap; 160 QMap<ExternalAppHandler::Types, QString> mExternalAppsMap;
159 161
160// AddresseeWidget *mAddresseeWidget; 162// AddresseeWidget *mAddresseeWidget;
161}; 163};
162 164
163#endif 165#endif
diff --git a/libkdepim/kdateedit.cpp b/libkdepim/kdateedit.cpp
index bf38479..28c88d4 100644
--- a/libkdepim/kdateedit.cpp
+++ b/libkdepim/kdateedit.cpp
@@ -1,510 +1,514 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 3
4 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qapplication.h> 25#include <qapplication.h>
26#include <qevent.h> 26#include <qevent.h>
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qpixmap.h> 28#include <qpixmap.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30//Added by qt3to4:
31#include <Q3Frame>
32#include <QKeyEvent>
30 33
31#include <kdatepicker.h> 34#include <kdatepicker.h>
32#include <kdebug.h> 35#include <kdebug.h>
33#include <kglobal.h> 36#include <kglobal.h>
34#include <kiconloader.h> 37#include <kiconloader.h>
35#include <klocale.h> 38#include <klocale.h>
36#include <kmessagebox.h> 39#include <kmessagebox.h>
37#include <knotifyclient.h> 40#include <knotifyclient.h>
38#include <qpalette.h> 41#include <qpalette.h>
42#include <QDesktopWidget>
39 43
40#include "kdateedit.h" 44#include "kdateedit.h"
41//#include "kdateedit.moc" 45//#include "kdateedit.moc"
42 46
43KDateEdit::KDateEdit(QWidget *parent, const char *name, bool withoutDP ) 47KDateEdit::KDateEdit(QWidget *parent, const char *name, bool withoutDP )
44 : QHBox(parent, name) 48 : Q3HBox(parent, name)
45{ 49{
46 dateFormShort = true; 50 dateFormShort = true;
47 withoutDp = withoutDP; 51 withoutDp = withoutDP;
48 mDateEdit = new QLineEdit(this); 52 mDateEdit = new QLineEdit(this);
49 mDateEdit->setText(KGlobal::locale()->formatDate(QDate::currentDate(),dateFormShort)); 53 mDateEdit->setText(KGlobal::locale()->formatDate(QDate::currentDate(),dateFormShort));
50 setFocusProxy(mDateEdit); 54 setFocusProxy(mDateEdit);
51 mDateEdit->installEventFilter(this); 55 mDateEdit->installEventFilter(this);
52 56
53 // Highlight Background and Textcolor 57 // Highlight Background and Textcolor
54 QPalette palette = QWidget::palette(); 58 QPalette palette = QWidget::palette();
55 unsigned char red, green, blue; 59 unsigned char red, green, blue;
56 red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; 60 red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10;
57 green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; 61 green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10;
58 blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; 62 blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10;
59 palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); 63 palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) );
60 palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); 64 palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) );
61 mDateEdit->setPalette( palette ); 65 mDateEdit->setPalette( palette );
62 66
63 if ( withoutDP ) { 67 if ( withoutDP ) {
64 mDateFrame = 0; 68 mDateFrame = 0;
65 mDateButton = 0; 69 mDateButton = 0;
66 mDatePicker = 0; 70 mDatePicker = 0;
67 } else { 71 } else {
68 QPixmap pixmap = SmallIcon("smallcal"); 72 QPixmap pixmap = SmallIcon("smallcal");
69 mDateButton = new QPushButton(this); 73 mDateButton = new QPushButton(this);
70 mDateButton->setPixmap(pixmap); 74 mDateButton->setPixmap(pixmap);
71 QPixmap pixmap2 = SmallIcon("today_small"); 75 QPixmap pixmap2 = SmallIcon("today_small");
72 QPushButton* nowButton = new QPushButton(this); 76 QPushButton* nowButton = new QPushButton(this);
73 nowButton->setPixmap(pixmap2); 77 nowButton->setPixmap(pixmap2);
74 78
75 mDateFrame = new QVBox(0,0,WType_Popup); 79 mDateFrame = new Q3VBox(0,0,Qt::WType_Popup);
76 // mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 80 // mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
77 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 81 mDateFrame->setFrameStyle( Q3Frame::WinPanel |Q3Frame::Raised );
78 mDateFrame->setLineWidth(3); 82 mDateFrame->setLineWidth(3);
79 mDateFrame->hide(); 83 mDateFrame->hide();
80 84
81 mDatePicker = new KDatePicker(mDateFrame,QDate::currentDate()); 85 mDatePicker = new KDatePicker(mDateFrame,QDate::currentDate());
82 connect(mDatePicker,SIGNAL(dateEntered(QDate)),SLOT(setDate(QDate))); 86 connect(mDatePicker,SIGNAL(dateEntered(QDate)),SLOT(setDate(QDate)));
83 connect(mDatePicker,SIGNAL(dateEntered(QDate)),SIGNAL(dateChanged(QDate))); 87 connect(mDatePicker,SIGNAL(dateEntered(QDate)),SIGNAL(dateChanged(QDate)));
84 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(setDate(QDate))); 88 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(setDate(QDate)));
85 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SIGNAL(dateChanged(QDate))); 89 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SIGNAL(dateChanged(QDate)));
86 connect(mDatePicker,SIGNAL(dateSelected(QDate)),mDateFrame,SLOT(hide())); 90 connect(mDatePicker,SIGNAL(dateSelected(QDate)),mDateFrame,SLOT(hide()));
87 connect(mDateButton,SIGNAL(clicked()),SLOT(toggleDatePicker())); 91 connect(mDateButton,SIGNAL(clicked()),SLOT(toggleDatePicker()));
88 connect(nowButton,SIGNAL(clicked()),SLOT(goToNow())); 92 connect(nowButton,SIGNAL(clicked()),SLOT(goToNow()));
89 mDateButton->setFocusPolicy( QWidget::NoFocus ); 93 mDateButton->setFocusPolicy( Qt::NoFocus );
90 mDateButton->setAutoDefault( false ); 94 mDateButton->setAutoDefault( false );
91 //mDateFrame->resize( 400, 300 ); 95 //mDateFrame->resize( 400, 300 );
92 96
93 } 97 }
94 connect(mDateEdit,SIGNAL(returnPressed()),SLOT(lineEnterPressed())); 98 connect(mDateEdit,SIGNAL(returnPressed()),SLOT(lineEnterPressed()));
95 connect(mDateEdit,SIGNAL(textChanged(const QString &)), 99 connect(mDateEdit,SIGNAL(textChanged(const QString &)),
96 SLOT(textChanged(const QString &))); 100 SLOT(textChanged(const QString &)));
97 101
98 // Create the keyword list. This will be used to match against when the user 102 // Create the keyword list. This will be used to match against when the user
99 // enters information. 103 // enters information.
100 mKeywordMap[i18n("tomorrow")] = 1; 104 mKeywordMap[i18n("tomorrow")] = 1;
101 mKeywordMap[i18n("today")] = 0; 105 mKeywordMap[i18n("today")] = 0;
102 mKeywordMap[i18n("yesterday")] = -1; 106 mKeywordMap[i18n("yesterday")] = -1;
103 107
104 /* 108 /*
105 * This loop uses some math tricks to figure out the offset in days 109 * This loop uses some math tricks to figure out the offset in days
106 * to the next date the given day of the week occurs. There 110 * to the next date the given day of the week occurs. There
107 * are two cases, that the new day is >= the current day, which means 111 * are two cases, that the new day is >= the current day, which means
108 * the new day has not occured yet or that the new day < the current day, 112 * the new day has not occured yet or that the new day < the current day,
109 * which means the new day is already passed (so we need to find the 113 * which means the new day is already passed (so we need to find the
110 * day in the next week). 114 * day in the next week).
111 */ 115 */
112 QString dayName; 116 QString dayName;
113 int currentDay = QDate::currentDate().dayOfWeek(); 117 int currentDay = QDate::currentDate().dayOfWeek();
114 for (int i = 1; i <= 7; ++i) 118 for (int i = 1; i <= 7; ++i)
115 { 119 {
116 dayName = KGlobal::locale()->weekDayName(i).lower(); 120 dayName = KGlobal::locale()->weekDayName(i).lower();
117 if (i >= currentDay) 121 if (i >= currentDay)
118 mKeywordMap[dayName] = i - currentDay; 122 mKeywordMap[dayName] = i - currentDay;
119 else 123 else
120 mKeywordMap[dayName] = 7 - currentDay + i; 124 mKeywordMap[dayName] = 7 - currentDay + i;
121 } 125 }
122 126
123 mTextChanged = false; 127 mTextChanged = false;
124 mHandleInvalid = false; 128 mHandleInvalid = false;
125 // QWidget::setTabOrder( mDateEdit, mDateButton ); 129 // QWidget::setTabOrder( mDateEdit, mDateButton );
126} 130}
127 131
128KDateEdit::~KDateEdit() 132KDateEdit::~KDateEdit()
129{ 133{
130 delete mDateFrame; 134 delete mDateFrame;
131} 135}
132void KDateEdit::clear() 136void KDateEdit::clear()
133{ 137{
134 bool b = mDateEdit->signalsBlocked(); 138 bool b = mDateEdit->signalsBlocked();
135 mDateEdit->blockSignals(true); 139 mDateEdit->blockSignals(true);
136 mDateEdit->setText(""); 140 mDateEdit->setText("");
137 mDateEdit->blockSignals(b); 141 mDateEdit->blockSignals(b);
138} 142}
139void KDateEdit::goToNow() 143void KDateEdit::goToNow()
140{ 144{
141 setDate(QDate::currentDate() ); 145 setDate(QDate::currentDate() );
142 emit setTimeTo( QTime::currentTime() ); 146 emit setTimeTo( QTime::currentTime() );
143} 147}
144void KDateEdit::setDate(QDate newDate) 148void KDateEdit::setDate(QDate newDate)
145{ 149{
146 if (!newDate.isValid() && !mHandleInvalid) 150 if (!newDate.isValid() && !mHandleInvalid)
147 return; 151 return;
148 if ( readDate() == newDate ) 152 if ( readDate() == newDate )
149 return; 153 return;
150 QString dateString = ""; 154 QString dateString = "";
151 if(newDate.isValid()) 155 if(newDate.isValid())
152 dateString = KGlobal::locale()->formatDate( newDate, dateFormShort ); 156 dateString = KGlobal::locale()->formatDate( newDate, dateFormShort );
153 157
154 mTextChanged = false; 158 mTextChanged = false;
155 159
156 // We do not want to generate a signal here, since we explicity setting 160 // We do not want to generate a signal here, since we explicity setting
157 // the date 161 // the date
158 bool b = mDateEdit->signalsBlocked(); 162 bool b = mDateEdit->signalsBlocked();
159 mDateEdit->blockSignals(true); 163 mDateEdit->blockSignals(true);
160 mDateEdit->setText(dateString); 164 mDateEdit->setText(dateString);
161 mDateEdit->blockSignals(b); 165 mDateEdit->blockSignals(b);
162} 166}
163 167
164void KDateEdit::setDate( QDate date,int *cpos,const int key ,const bool dateFormShort) 168void KDateEdit::setDate( QDate date,int *cpos,const int key ,const bool dateFormShort)
165{ 169{
166 QString dateForm = dateFormShort ? 170 QString dateForm = dateFormShort ?
167 KGlobal::locale()->dateFormatShort() : 171 KGlobal::locale()->dateFormatShort() :
168 KGlobal::locale()->dateFormat(); 172 KGlobal::locale()->dateFormat();
169 173
170 int begin = dateForm.find("%"); 174 int begin = dateForm.find("%");
171 int space = 0; 175 int space = 0;
172 int allStrLength = 0; 176 int allStrLength = 0;
173 int strLength = 0; 177 int strLength = 0;
174 int repeat = 0; 178 int repeat = 0;
175 179
176 // witch? Day, Month or Year switch? 180 // witch? Day, Month or Year switch?
177 while(1){ 181 while(1){
178 switch ( dateForm.at(begin + 1).latin1() ) 182 switch ( dateForm.at(begin + 1).latin1() )
179 { 183 {
180 case 'd':// 16 (month day) 184 case 'd':// 16 (month day)
181 strLength = 2; //Ok 185 strLength = 2; //Ok
182 break; 186 break;
183 case 'm':// 01 (month) 187 case 'm':// 01 (month)
184 strLength = 2; //Ok 188 strLength = 2; //Ok
185 break; 189 break;
186 case 'a':// Mon (Weekday) 190 case 'a':// Mon (Weekday)
187 strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length(); 191 strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length();
188 break; 192 break;
189 case 'A':// Monday (Weekday) 193 case 'A':// Monday (Weekday)
190 strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length(); 194 strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length();
191 break; 195 break;
192 case 'b':// Jan (monthName) 196 case 'b':// Jan (monthName)
193 strLength = KGlobal::locale()->monthName(date.month(), true).length(); 197 strLength = KGlobal::locale()->monthName(date.month(), true).length();
194 break; 198 break;
195 case 'B':// January (monthName) 199 case 'B':// January (monthName)
196 strLength = KGlobal::locale()->monthName(date.month(), false).length(); 200 strLength = KGlobal::locale()->monthName(date.month(), false).length();
197 break; 201 break;
198 case 'y':// 04 (year short) 202 case 'y':// 04 (year short)
199 strLength = 2; //Ok 203 strLength = 2; //Ok
200 break; 204 break;
201 case 'Y':// 2004 (year) 205 case 'Y':// 2004 (year)
202 strLength = 4; //Ok 206 strLength = 4; //Ok
203 break; 207 break;
204 default: 208 default:
205 break; 209 break;
206 } 210 }
207 space = begin - (repeat++ * 2); 211 space = begin - (repeat++ * 2);
208 // all select? then dayswitch 212 // all select? then dayswitch
209 if( (mDateEdit->text().length() == mDateEdit->markedText().length() ) && 213 if( (mDateEdit->text().length() == mDateEdit->markedText().length() ) &&
210 ( (dateForm.at(begin + 1).latin1() == 'd') || 214 ( (dateForm.at(begin + 1).latin1() == 'd') ||
211 (dateForm.at(begin + 1).latin1() == 'a') || 215 (dateForm.at(begin + 1).latin1() == 'a') ||
212 (dateForm.at(begin + 1).latin1() == 'A') ) ) { 216 (dateForm.at(begin + 1).latin1() == 'A') ) ) {
213 break; 217 break;
214 } 218 }
215 // mDateEdit-StringPos == CursorPosition(cpos) then break and set date 219 // mDateEdit-StringPos == CursorPosition(cpos) then break and set date
216 if( ( (space + allStrLength) <= *cpos && *cpos <= (space + allStrLength + strLength) ) || *cpos < begin ) { 220 if( ( (space + allStrLength) <= *cpos && *cpos <= (space + allStrLength + strLength) ) || *cpos < begin ) {
217 break; 221 break;
218 } 222 }
219 allStrLength += strLength; 223 allStrLength += strLength;
220 begin = dateForm.find("%", begin +1); 224 begin = dateForm.find("%", begin +1);
221 } 225 }
222 226
223 // set date 227 // set date
224 switch ( dateForm.at(begin + 1).latin1() ) { 228 switch ( dateForm.at(begin + 1).latin1() ) {
225 case 'd': 229 case 'd':
226 case 'a': 230 case 'a':
227 case 'A': 231 case 'A':
228 if(key == Key_Up) { 232 if(key == Qt::Key_Up) {
229 setDate( date.addDays( 1 ) ); 233 setDate( date.addDays( 1 ) );
230 } 234 }
231 else if(key == Key_Down) { 235 else if(key == Qt::Key_Down) {
232 setDate( date.addDays( -1 ) ); 236 setDate( date.addDays( -1 ) );
233 } 237 }
234 maxDay = readDate().day(); 238 maxDay = readDate().day();
235 break; 239 break;
236 case 'm': 240 case 'm':
237 case 'b': 241 case 'b':
238 case 'B': 242 case 'B':
239 if(key == Key_Up) { 243 if(key == Qt::Key_Up) {
240 int year = ((date.month()+1)>12)?date.year()+1:date.year(); 244 int year = ((date.month()+1)>12)?date.year()+1:date.year();
241 int month = ((date.month()+1)>12)?1:date.month()+1; 245 int month = ((date.month()+1)>12)?1:date.month()+1;
242 int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay; 246 int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay;
243 setDate( QDate( year, month, day ) ); 247 setDate( QDate( year, month, day ) );
244 } else if(key == Key_Down) { 248 } else if(key == Qt::Key_Down) {
245 int year = ((date.month()-1)<1)?date.year()-1:date.year(); 249 int year = ((date.month()-1)<1)?date.year()-1:date.year();
246 int month = ((date.month()-1)<1)?12:date.month()-1; 250 int month = ((date.month()-1)<1)?12:date.month()-1;
247 int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay; 251 int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay;
248 setDate( QDate( year, month, day ) ); 252 setDate( QDate( year, month, day ) );
249 } 253 }
250 break; 254 break;
251 case 'y': 255 case 'y':
252 case 'Y': 256 case 'Y':
253 if(key == Key_Up) { 257 if(key == Qt::Key_Up) {
254 setDate( QDate( date.year() + 1, date.month() , date.day()) ); 258 setDate( QDate( date.year() + 1, date.month() , date.day()) );
255 } 259 }
256 else if(key == Key_Down) { 260 else if(key == Qt::Key_Down) {
257 setDate( QDate( date.year() - 1, date.month() , date.day()) ); 261 setDate( QDate( date.year() - 1, date.month() , date.day()) );
258 } 262 }
259 break; 263 break;
260/* default: 264/* default:
261 if(key == Key_Up) { 265 if(key == Key_Up) {
262 setDate( date.addDays( 1 ) ); 266 setDate( date.addDays( 1 ) );
263 } else if(key == Key_Down) { 267 } else if(key == Key_Down) {
264 setDate( date.addDays( -1 ) ); 268 setDate( date.addDays( -1 ) );
265 } 269 }
266 break;*/ 270 break;*/
267 } 271 }
268 272
269 date = readDate(); 273 date = readDate();
270 begin = dateForm.find("%"); 274 begin = dateForm.find("%");
271 int allSelectStrLength = 0; 275 int allSelectStrLength = 0;
272 int selectStrLength = 0; 276 int selectStrLength = 0;
273 277
274 // set selection do new date an set cursor at end of selection 278 // set selection do new date an set cursor at end of selection
275 for(int i = 0; i < repeat; i++){ 279 for(int i = 0; i < repeat; i++){
276 switch ( dateForm.at(begin + 1).latin1() ) 280 switch ( dateForm.at(begin + 1).latin1() )
277 { 281 {
278 case 'd':// 16 (month day) 282 case 'd':// 16 (month day)
279 selectStrLength = 2; //Ok 283 selectStrLength = 2; //Ok
280 break; 284 break;
281 case 'm':// 01 (month) 285 case 'm':// 01 (month)
282 selectStrLength = 2; //Ok 286 selectStrLength = 2; //Ok
283 break; 287 break;
284 case 'a':// Mon (Weekday short) 288 case 'a':// Mon (Weekday short)
285 selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length(); 289 selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length();
286 break; 290 break;
287 case 'A':// Monday (Weekday) 291 case 'A':// Monday (Weekday)
288 selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length(); 292 selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length();
289 break; 293 break;
290 case 'b':// Jan (monthName short) 294 case 'b':// Jan (monthName short)
291 selectStrLength = KGlobal::locale()->monthName(date.month(), true).length(); 295 selectStrLength = KGlobal::locale()->monthName(date.month(), true).length();
292 break; 296 break;
293 case 'B':// January (monthName) 297 case 'B':// January (monthName)
294 selectStrLength = KGlobal::locale()->monthName(date.month(), false).length(); 298 selectStrLength = KGlobal::locale()->monthName(date.month(), false).length();
295 break; 299 break;
296 case 'y':// 04 (year short) 300 case 'y':// 04 (year short)
297 selectStrLength = 2; //Ok 301 selectStrLength = 2; //Ok
298 break; 302 break;
299 case 'Y':// 2004 (year) 303 case 'Y':// 2004 (year)
300 selectStrLength = 4; //Ok 304 selectStrLength = 4; //Ok
301 break; 305 break;
302 default: 306 default:
303 break; 307 break;
304 } 308 }
305 space = begin - (i * 2); 309 space = begin - (i * 2);
306 allSelectStrLength += selectStrLength; 310 allSelectStrLength += selectStrLength;
307 begin = dateForm.find("%", begin +1); 311 begin = dateForm.find("%", begin +1);
308 } 312 }
309 // set selection from begin of date 313 // set selection from begin of date
310 setSelect( space + allSelectStrLength - selectStrLength , selectStrLength); 314 setSelect( space + allSelectStrLength - selectStrLength , selectStrLength);
311 *cpos = space + allSelectStrLength; 315 *cpos = space + allSelectStrLength;
312 emit(dateChanged(date)); 316 emit(dateChanged(date));
313 317
314 return; 318 return;
315} 319}
316 320
317void KDateEdit::setHandleInvalid(bool handleInvalid) 321void KDateEdit::setHandleInvalid(bool handleInvalid)
318{ 322{
319 mHandleInvalid = handleInvalid; 323 mHandleInvalid = handleInvalid;
320} 324}
321 325
322void KDateEdit::setEnabled(bool on) 326void KDateEdit::setEnabled(bool on)
323{ 327{
324 mDateEdit->setEnabled(on); 328 mDateEdit->setEnabled(on);
325 mDateButton->setEnabled(on); 329 mDateButton->setEnabled(on);
326} 330}
327 331
328QDate KDateEdit::date() const 332QDate KDateEdit::date() const
329{ 333{
330 QDate date = readDate(); 334 QDate date = readDate();
331 335
332 if (date.isValid() || mHandleInvalid) { 336 if (date.isValid() || mHandleInvalid) {
333 return date; 337 return date;
334 } else { 338 } else {
335 KNotifyClient::beep(); 339 KNotifyClient::beep();
336 return QDate::currentDate(); 340 return QDate::currentDate();
337 } 341 }
338} 342}
339 343
340void KDateEdit::keyPressEvent(QKeyEvent *e) 344void KDateEdit::keyPressEvent(QKeyEvent *e)
341{ 345{
342 QDate date = readDate(); 346 QDate date = readDate();
343 int cpos = mDateEdit->cursorPosition(); 347 int cpos = mDateEdit->cursorPosition();
344 348
345 switch(e->key()) 349 switch(e->key())
346 { 350 {
347 case Key_Escape: 351 case Qt::Key_Escape:
348 mDateEdit->deselect(); 352 mDateEdit->deselect();
349 case Key_Tab: 353 case Qt::Key_Tab:
350 QHBox::keyPressEvent(e); 354 Q3HBox::keyPressEvent(e);
351 break; 355 break;
352 case Key_Up: 356 case Qt::Key_Up:
353 // when date invalid then set to currend and return 357 // when date invalid then set to currend and return
354 if(!date.isValid()) { 358 if(!date.isValid()) {
355 date = QDate::currentDate(); 359 date = QDate::currentDate();
356 setDate(date); 360 setDate(date);
357 mDateEdit->setCursorPosition(cpos); 361 mDateEdit->setCursorPosition(cpos);
358 emit(dateChanged(date)); 362 emit(dateChanged(date));
359 QString text = i18n( "You entered an invalid date!\n Date changed to current date." ); 363 QString text = i18n( "You entered an invalid date!\n Date changed to current date." );
360 KMessageBox::information( 0, text ); 364 KMessageBox::information( 0, text );
361 return; 365 return;
362 } 366 }
363 setDate(date, &cpos, Key_Up, dateFormShort); 367 setDate(date, &cpos, Qt::Key_Up, dateFormShort);
364 break; 368 break;
365 case Key_Down: 369 case Qt::Key_Down:
366 // when date invalid then set to current and return 370 // when date invalid then set to current and return
367 if(!date.isValid()) { 371 if(!date.isValid()) {
368 date = QDate::currentDate(); 372 date = QDate::currentDate();
369 setDate(date); 373 setDate(date);
370 mDateEdit->setCursorPosition(cpos); 374 mDateEdit->setCursorPosition(cpos);
371 emit(dateChanged(date)); 375 emit(dateChanged(date));
372 QString text = i18n( "You entered an invalid date!\n Date changed to current date." ); 376 QString text = i18n( "You entered an invalid date!\n Date changed to current date." );
373 KMessageBox::information( 0, text ); 377 KMessageBox::information( 0, text );
374 return; 378 return;
375 } 379 }
376 setDate(date, &cpos, Key_Down, dateFormShort); 380 setDate(date, &cpos, Qt::Key_Down, dateFormShort);
377 break; 381 break;
378 default: 382 default:
379 QHBox::keyPressEvent(e); 383 Q3HBox::keyPressEvent(e);
380 break; 384 break;
381 } // switch 385 } // switch
382 mDateEdit->setCursorPosition(cpos); 386 mDateEdit->setCursorPosition(cpos);
383} 387}
384 388
385void KDateEdit::setSelect( int from, int to ) 389void KDateEdit::setSelect( int from, int to )
386{ 390{
387// return; 391// return;
388 mDateEdit->setSelection( from , to ); 392 mDateEdit->setSelection( from , to );
389} 393}
390 394
391void KDateEdit::toggleDatePicker() 395void KDateEdit::toggleDatePicker()
392{ 396{
393 if( mDateFrame->isVisible() ) { 397 if( mDateFrame->isVisible() ) {
394 mDateFrame->hide(); 398 mDateFrame->hide();
395 } else { 399 } else {
396 QPoint tmpPoint = mapToGlobal(mDateButton->geometry().bottomRight()); 400 QPoint tmpPoint = mapToGlobal(mDateButton->geometry().bottomRight());
397 QSize datepickersize = mDatePicker->sizeHint(); 401 QSize datepickersize = mDatePicker->sizeHint();
398 402
399 if ( tmpPoint.x() < 7+datepickersize.width() ) tmpPoint.setX( 7+datepickersize.width() ); 403 if ( tmpPoint.x() < 7+datepickersize.width() ) tmpPoint.setX( 7+datepickersize.width() );
400 404
401 int h = QApplication::desktop()->height(); 405 int h = QApplication::desktop()->height();
402 406
403 if ( tmpPoint.y() + datepickersize.height() > h ) tmpPoint.setY( h - datepickersize.height() ); 407 if ( tmpPoint.y() + datepickersize.height() > h ) tmpPoint.setY( h - datepickersize.height() );
404 408
405 mDateFrame->setGeometry(tmpPoint.x()-datepickersize.width()-7, tmpPoint.y(), 409 mDateFrame->setGeometry(tmpPoint.x()-datepickersize.width()-7, tmpPoint.y(),
406 datepickersize.width()+2*mDateFrame->lineWidth(), datepickersize.height()+2*mDateFrame->lineWidth()); 410 datepickersize.width()+2*mDateFrame->lineWidth(), datepickersize.height()+2*mDateFrame->lineWidth());
407 411
408 QDate date = readDate(); 412 QDate date = readDate();
409 if(date.isValid()) { 413 if(date.isValid()) {
410 mDatePicker->setDate(date); 414 mDatePicker->setDate(date);
411 } else { 415 } else {
412 mDatePicker->setDate(QDate::currentDate()); 416 mDatePicker->setDate(QDate::currentDate());
413 } 417 }
414 mDateFrame->show(); 418 mDateFrame->show();
415 } 419 }
416} 420}
417 421
418 422
419void KDateEdit::lineEnterPressed() 423void KDateEdit::lineEnterPressed()
420{ 424{
421 QDate date = readDate(); 425 QDate date = readDate();
422 426
423 if(date.isValid()) 427 if(date.isValid())
424 { 428 {
425 // Update the edit. This is needed if the user has entered a 429 // Update the edit. This is needed if the user has entered a
426 // word rather than the actual date. 430 // word rather than the actual date.
427 setDate(date); 431 setDate(date);
428 emit(dateChanged(date)); 432 emit(dateChanged(date));
429 emit returnPressed(); 433 emit returnPressed();
430 } 434 }
431 else 435 else
432 { 436 {
433 if ( withoutDp ) { 437 if ( withoutDp ) {
434 KNotifyClient::beep(); 438 KNotifyClient::beep();
435 } else { 439 } else {
436 if ( !mDateEdit->text().isEmpty() ) { 440 if ( !mDateEdit->text().isEmpty() ) {
437 mTextChanged = false; 441 mTextChanged = false;
438 QString text = i18n( "You entered an invalid date!\n Will use current date instead." ); 442 QString text = i18n( "You entered an invalid date!\n Will use current date instead." );
439 if ( isVisible() ) 443 if ( isVisible() )
440 if ( KMessageBox::warningContinueCancel( 0, text ) == KMessageBox::Continue ) { 444 if ( KMessageBox::warningContinueCancel( 0, text ) == KMessageBox::Continue ) {
441 setDate( QDate::currentDate() ); 445 setDate( QDate::currentDate() );
442 emit dateChanged( QDate::currentDate() ); 446 emit dateChanged( QDate::currentDate() );
443 } 447 }
444 } 448 }
445 } 449 }
446 } 450 }
447} 451}
448 452
449bool KDateEdit::inputIsValid() 453bool KDateEdit::inputIsValid()
450{ 454{
451 return readDate().isValid(); 455 return readDate().isValid();
452} 456}
453 457
454QDate KDateEdit::readDate() const 458QDate KDateEdit::readDate() const
455{ 459{
456 QString text = mDateEdit->text(); 460 QString text = mDateEdit->text();
457 QDate date; 461 QDate date;
458 462
459 if (mKeywordMap.contains(text.lower())) 463 if (mKeywordMap.contains(text.lower()))
460 { 464 {
461 date = QDate::currentDate().addDays(mKeywordMap[text.lower()]); 465 date = QDate::currentDate().addDays(mKeywordMap[text.lower()]);
462 } 466 }
463 else 467 else
464 { 468 {
465 date = KGlobal::locale()->readDate(text); 469 date = KGlobal::locale()->readDate(text);
466 } 470 }
467 471
468 return date; 472 return date;
469} 473}
470 474
471bool KDateEdit::eventFilter(QObject *, QEvent *e) 475bool KDateEdit::eventFilter(QObject *, QEvent *e)
472{ 476{
473 // We only process the focus out event if the text has changed 477 // We only process the focus out event if the text has changed
474 // since we got focus 478 // since we got focus
475 if ((e->type() == QEvent::FocusOut) ) 479 if ((e->type() == QEvent::FocusOut) )
476 { 480 {
477 if ( mTextChanged ) { 481 if ( mTextChanged ) {
478 lineEnterPressed(); 482 lineEnterPressed();
479 mTextChanged = false; 483 mTextChanged = false;
480 } 484 }
481 } 485 }
482 // switch dateFormShort by double klick with mouse 486 // switch dateFormShort by double klick with mouse
483 else if (e->type() == QEvent::MouseButtonDblClick) 487 else if (e->type() == QEvent::MouseButtonDblClick)
484 { 488 {
485 toggleDateFormat(); 489 toggleDateFormat();
486 } 490 }
487 else if (e->type() == QEvent::FocusIn) 491 else if (e->type() == QEvent::FocusIn)
488 { 492 {
489 maxDay = readDate().day(); 493 maxDay = readDate().day();
490 } 494 }
491 495
492 return false; 496 return false;
493} 497}
494void KDateEdit::toggleDateFormat() 498void KDateEdit::toggleDateFormat()
495{ 499{
496 dateFormShort = ! dateFormShort; 500 dateFormShort = ! dateFormShort;
497 mDateEdit->setText(KGlobal::locale()->formatDate(readDate(),dateFormShort)); 501 mDateEdit->setText(KGlobal::locale()->formatDate(readDate(),dateFormShort));
498 502
499} 503}
500 504
501void KDateEdit::textChanged(const QString &) 505void KDateEdit::textChanged(const QString &)
502{ 506{
503 if(mHandleInvalid && mDateEdit->text().stripWhiteSpace().isEmpty()) { 507 if(mHandleInvalid && mDateEdit->text().stripWhiteSpace().isEmpty()) {
504 QDate date; //invalid date 508 QDate date; //invalid date
505 emit(dateChanged(date)); 509 emit(dateChanged(date));
506 } else { 510 } else {
507 mTextChanged = true; 511 mTextChanged = true;
508 } 512 }
509 maxDay = readDate().day(); 513 maxDay = readDate().day();
510} 514}
diff --git a/libkdepim/kdateedit.h b/libkdepim/kdateedit.h
index 2d8c452..38eacde 100644
--- a/libkdepim/kdateedit.h
+++ b/libkdepim/kdateedit.h
@@ -1,143 +1,146 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 3
4 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef KDATEEDIT_H 24#ifndef KDATEEDIT_H
25#define KDATEEDIT_H 25#define KDATEEDIT_H
26 26
27#include <qhbox.h> 27#include <q3hbox.h>
28#include <qvbox.h> 28#include <q3vbox.h>
29#include <qdatetime.h> 29#include <qdatetime.h>
30#include <qmap.h> 30#include <qmap.h>
31//Added by qt3to4:
32#include <QKeyEvent>
33#include <QEvent>
31 34
32class QLineEdit; 35class QLineEdit;
33class QPushButton; 36class QPushButton;
34class QObject; 37class QObject;
35class QEvent; 38class QEvent;
36class KDatePicker; 39class KDatePicker;
37class KDateValidator; 40class KDateValidator;
38 41
39/** 42/**
40* A date editing widget that consists of a line edit followed by 43* A date editing widget that consists of a line edit followed by
41* a small push button. The line edit contains the date in text form, 44* a small push button. The line edit contains the date in text form,
42* and the push button will display a 'popup' style date picker. 45* and the push button will display a 'popup' style date picker.
43* 46*
44* This widget also supports advanced features like allowing the user 47* This widget also supports advanced features like allowing the user
45* to type in the day name to get the date. The following keywords 48* to type in the day name to get the date. The following keywords
46* are supported (in the native language): tomorrow, yesturday, today, 49* are supported (in the native language): tomorrow, yesturday, today,
47* monday, tuesday, wednesday, thursday, friday, saturday, sunday. 50* monday, tuesday, wednesday, thursday, friday, saturday, sunday.
48* 51*
49* @author Cornelius Schumacher <schumacher@kde.org> 52* @author Cornelius Schumacher <schumacher@kde.org>
50* @author Mike Pilone <mpilone@slac.com> 53* @author Mike Pilone <mpilone@slac.com>
51*/ 54*/
52class KDateEdit : public QHBox 55class KDateEdit : public Q3HBox
53{ 56{
54 Q_OBJECT 57 Q_OBJECT
55 public: 58 public:
56 KDateEdit(QWidget *parent=0, const char *name=0, bool withoutDP = false ); 59 KDateEdit(QWidget *parent=0, const char *name=0, bool withoutDP = false );
57 virtual ~KDateEdit(); 60 virtual ~KDateEdit();
58 61
59 /** @return True if the date in the text edit is valid, 62 /** @return True if the date in the text edit is valid,
60 * false otherwise. This will not modify the display of the date, 63 * false otherwise. This will not modify the display of the date,
61 * but only check for validity. 64 * but only check for validity.
62 */ 65 */
63 bool inputIsValid(); 66 bool inputIsValid();
64 67
65 /** @return The date entered. This will not 68 /** @return The date entered. This will not
66 * modify the display of the date, but only return it. 69 * modify the display of the date, but only return it.
67 */ 70 */
68 QDate date() const; 71 QDate date() const;
69 72
70 /** @param handleInvalid If true the date edit accepts invalid dates 73 /** @param handleInvalid If true the date edit accepts invalid dates
71 * and displays them as the empty ("") string. It also returns an invalid date. 74 * and displays them as the empty ("") string. It also returns an invalid date.
72 * If false (default) invalid dates are not accepted and instead the date 75 * If false (default) invalid dates are not accepted and instead the date
73 * of today will be returned. 76 * of today will be returned.
74 */ 77 */
75 void setHandleInvalid(bool handleInvalid); 78 void setHandleInvalid(bool handleInvalid);
76 79
77 /** Checks for a focus out event. The display of the date is updated 80 /** Checks for a focus out event. The display of the date is updated
78 * to display the proper date when the focus leaves. 81 * to display the proper date when the focus leaves.
79 */ 82 */
80 virtual bool eventFilter(QObject *o, QEvent *e); 83 virtual bool eventFilter(QObject *o, QEvent *e);
81 void toggleDateFormat(); 84 void toggleDateFormat();
82 void clear(); 85 void clear();
83 signals: 86 signals:
84 /** This signal is emitted whenever the user modifies the date. This 87 /** This signal is emitted whenever the user modifies the date. This
85 * may not get emitted until the user presses enter in the line edit or 88 * may not get emitted until the user presses enter in the line edit or
86 * focus leaves the widget (ie: the user confirms their selection). 89 * focus leaves the widget (ie: the user confirms their selection).
87 */ 90 */
88 void dateChanged(QDate); 91 void dateChanged(QDate);
89 void returnPressed(); 92 void returnPressed();
90 void setTimeTo( QTime ); 93 void setTimeTo( QTime );
91 public slots: 94 public slots:
92 /** Sets the date. 95 /** Sets the date.
93 * 96 *
94 * @param date The new date to display. This date must be valid or 97 * @param date The new date to display. This date must be valid or
95 * it will not be displayed. 98 * it will not be displayed.
96 */ 99 */
97 void setDate(QDate date); 100 void setDate(QDate date);
98 // set Date with key_up key_down to relation of cursor Position 101 // set Date with key_up key_down to relation of cursor Position
99 // and set selection from begin to end of single date 102 // and set selection from begin to end of single date
100 void setDate(QDate, int *cpos, const int, const bool); 103 void setDate(QDate, int *cpos, const int, const bool);
101 104
102 /** Sets the date edit to be enabled or disabled (grayed out) 105 /** Sets the date edit to be enabled or disabled (grayed out)
103 * 106 *
104 * @param on Enabled if true, disabled if false 107 * @param on Enabled if true, disabled if false
105 */ 108 */
106 void setEnabled(bool on); 109 void setEnabled(bool on);
107 110
108 protected slots: 111 protected slots:
109 void toggleDatePicker(); 112 void toggleDatePicker();
110 void lineEnterPressed(); 113 void lineEnterPressed();
111 void textChanged(const QString &); 114 void textChanged(const QString &);
112 void goToNow(); 115 void goToNow();
113 116
114 private: 117 private:
115 /** Reads the text from the line edit. If the text is a keyword, the 118 /** Reads the text from the line edit. If the text is a keyword, the
116 * word will be translated to a date. If the text is not a keyword, the 119 * word will be translated to a date. If the text is not a keyword, the
117 * text will be interpreted as a date. 120 * text will be interpreted as a date.
118 */ 121 */
119 QDate readDate() const; 122 QDate readDate() const;
120 123
121 /** Maps the text that the user can enter to the offset in days from 124 /** Maps the text that the user can enter to the offset in days from
122 * today. For example, the text 'tomorrow' is mapped to +1. 125 * today. For example, the text 'tomorrow' is mapped to +1.
123 */ 126 */
124 QMap<QString, int> mKeywordMap; 127 QMap<QString, int> mKeywordMap;
125 bool mTextChanged; 128 bool mTextChanged;
126 bool mHandleInvalid; 129 bool mHandleInvalid;
127 130
128 QPushButton *mDateButton; 131 QPushButton *mDateButton;
129 QLineEdit *mDateEdit; 132 QLineEdit *mDateEdit;
130 KDatePicker *mDatePicker; 133 KDatePicker *mDatePicker;
131 QVBox *mDateFrame; 134 Q3VBox *mDateFrame;
132 int maxDay; 135 int maxDay;
133 bool withoutDp; 136 bool withoutDp;
134 137
135 protected: 138 protected:
136 virtual void keyPressEvent(QKeyEvent *qke); 139 virtual void keyPressEvent(QKeyEvent *qke);
137 void setSelect ( int, int ); 140 void setSelect ( int, int );
138 bool dateFormShort; 141 bool dateFormShort;
139 char lengthMonthName; 142 char lengthMonthName;
140 143
141}; 144};
142 145
143#endif 146#endif
diff --git a/libkdepim/kdatepicker.cpp b/libkdepim/kdatepicker.cpp
index 68ef943..28b65cf 100644
--- a/libkdepim/kdatepicker.cpp
+++ b/libkdepim/kdatepicker.cpp
@@ -1,498 +1,502 @@
1/* -*- C++ -*- 1/* -*- C++ -*-
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) 3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
4 (C) 1998-2001 Mirko Boehm (mirko@kde.org) 4 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include "kdatepicker.h" 21#include "kdatepicker.h"
22#include <kglobal.h> 22#include <kglobal.h>
23#include <kapplication.h> 23#include <kapplication.h>
24#include <klocale.h> 24#include <klocale.h>
25#include <kiconloader.h> 25#include <kiconloader.h>
26#include <qframe.h> 26#include <q3frame.h>
27#include <qpainter.h> 27#include <qpainter.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qtoolbutton.h> 29#include <qtoolbutton.h>
30#include <qfont.h> 30#include <qfont.h>
31#include <qapplication.h> 31#include <qapplication.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qvalidator.h> 33#include <qvalidator.h>
34//Added by qt3to4:
35#include <QResizeEvent>
36#include <QKeyEvent>
37#include <QDesktopWidget>
34#include <kdebug.h> 38#include <kdebug.h>
35#include <knotifyclient.h> 39#include <knotifyclient.h>
36#include <kglobalsettings.h> 40#include <kglobalsettings.h>
37#include "kdatetbl.h" 41#include "kdatetbl.h"
38#include "kdateedit.h" 42#include "kdateedit.h"
39//#include "kdatepicker.moc" 43//#include "kdatepicker.moc"
40 44
41 45
42KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) 46KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name)
43 : QFrame(parent,name), 47 : Q3Frame(parent,name),
44 yearForward(new QToolButton(this)), 48 yearForward(new QToolButton(this)),
45 yearBackward(new QToolButton(this)), 49 yearBackward(new QToolButton(this)),
46 monthForward(new QToolButton(this)), 50 monthForward(new QToolButton(this)),
47 monthBackward(new QToolButton(this)), 51 monthBackward(new QToolButton(this)),
48 selectMonth(new QToolButton(this)), 52 selectMonth(new QToolButton(this)),
49 selectYear(new QToolButton(this)), 53 selectYear(new QToolButton(this)),
50 todayBut(new QToolButton(this)), 54 todayBut(new QToolButton(this)),
51 //line(new QLineEdit(this)), 55 //line(new QLineEdit(this)),
52 val(new KDateValidator(this)) 56 val(new KDateValidator(this))
53 //table(new KDateTable(this)), 57 //table(new KDateTable(this)),
54 //fontsize(1) 58 //fontsize(1)
55{ 59{
56 QFont fo = KGlobalSettings::generalFont(); 60 QFont fo = KGlobalSettings::generalFont();
57 int add = 2; 61 int add = 2;
58 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 62 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
59 add += 4; 63 add += 4;
60 fo.setPointSize(fo.pointSize()+add ); 64 fo.setPointSize(fo.pointSize()+add );
61 setFont( fo ); 65 setFont( fo );
62 table = new KDateTable(this); 66 table = new KDateTable(this);
63 setFontSize(font().pointSize()); 67 setFontSize(font().pointSize());
64 //line->setValidator(val); 68 //line->setValidator(val);
65 lineDate = new KDateEdit( this, "dateediipicker", true ); 69 lineDate = new KDateEdit( this, "dateediipicker", true );
66 yearForward->setPixmap(SmallIcon("3rightarrowB")); 70 yearForward->setPixmap(SmallIcon("3rightarrowB"));
67 yearBackward->setPixmap(SmallIcon("3leftarrowB")); 71 yearBackward->setPixmap(SmallIcon("3leftarrowB"));
68 monthForward->setPixmap(SmallIcon("2rightarrowB")); 72 monthForward->setPixmap(SmallIcon("2rightarrowB"));
69 monthBackward->setPixmap(SmallIcon("2leftarrowB")); 73 monthBackward->setPixmap(SmallIcon("2leftarrowB"));
70 todayBut->setPixmap(SmallIcon("today")); 74 todayBut->setPixmap(SmallIcon("today"));
71 setDate(dt); // set button texts 75 setDate(dt); // set button texts
72 connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); 76 connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate)));
73 connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); 77 connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot()));
74 connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); 78 connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked()));
75 connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); 79 connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked()));
76 connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); 80 connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked()));
77 connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); 81 connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked()));
78 connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); 82 connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked()));
79 connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); 83 connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked()));
80 connect(todayBut, SIGNAL(clicked()), SLOT(goToday())); 84 connect(todayBut, SIGNAL(clicked()), SLOT(goToday()));
81 //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); 85 //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
82 connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate))); 86 connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate)));
83 connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); 87 connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
84 table->setFocus(); 88 table->setFocus();
85 89
86} 90}
87 91
88KDatePicker::~KDatePicker() 92KDatePicker::~KDatePicker()
89{ 93{
90} 94}
91 95
92void 96void
93KDatePicker::resizeEvent(QResizeEvent*) 97KDatePicker::resizeEvent(QResizeEvent*)
94{ 98{
95 QWidget *buttons[] = { 99 QWidget *buttons[] = {
96 yearBackward, 100 yearBackward,
97 monthBackward, 101 monthBackward,
98 selectMonth, 102 selectMonth,
99 selectYear, 103 selectYear,
100 monthForward, 104 monthForward,
101 yearForward }; 105 yearForward };
102 const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); 106 const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]);
103 QSize sizes[NoOfButtons]; 107 QSize sizes[NoOfButtons];
104 int buttonHeight=0; 108 int buttonHeight=0;
105 int count; 109 int count;
106 int w; 110 int w;
107 int x=0; 111 int x=0;
108 // ----- calculate button row height: 112 // ----- calculate button row height:
109 for(count=0; count<NoOfButtons; ++count) { 113 for(count=0; count<NoOfButtons; ++count) {
110 int xS = buttons[count]->sizeHint().width(); 114 int xS = buttons[count]->sizeHint().width();
111 int yS = buttons[count]->sizeHint().height(); 115 int yS = buttons[count]->sizeHint().height();
112 if ( QApplication::desktop()->width() < 320 ) 116 if ( QApplication::desktop()->width() < 320 )
113 sizes[count]=QSize ( xS+4, yS ); 117 sizes[count]=QSize ( xS+4, yS );
114 else 118 else
115 sizes[count]=QSize ( xS+10, yS ); 119 sizes[count]=QSize ( xS+10, yS );
116 120
117 buttonHeight=QMAX(buttonHeight, sizes[count].height()); 121 buttonHeight=QMAX(buttonHeight, sizes[count].height());
118 } 122 }
119 buttonHeight += 10; 123 buttonHeight += 10;
120 // ----- calculate size of the month button: 124 // ----- calculate size of the month button:
121 w=0; 125 w=0;
122 for(count=0; count<NoOfButtons; ++count) { 126 for(count=0; count<NoOfButtons; ++count) {
123 if(buttons[count]!=selectMonth) 127 if(buttons[count]!=selectMonth)
124 { 128 {
125 w+=sizes[count].width(); 129 w+=sizes[count].width();
126 } else { 130 } else {
127 x=count; 131 x=count;
128 } 132 }
129 } 133 }
130 sizes[x].setWidth(width()-w); // stretch the month button 134 sizes[x].setWidth(width()-w); // stretch the month button
131 // ----- place the buttons: 135 // ----- place the buttons:
132 x=0; 136 x=0;
133 for(count=0; count<NoOfButtons; ++count) 137 for(count=0; count<NoOfButtons; ++count)
134 { 138 {
135 w=sizes[count].width(); 139 w=sizes[count].width();
136 buttons[count]->setGeometry(x, 0, w, buttonHeight); 140 buttons[count]->setGeometry(x, 0, w, buttonHeight);
137 x+=w; 141 x+=w;
138 } 142 }
139 // ----- place the line edit for direct input: 143 // ----- place the line edit for direct input:
140 sizes[0]=lineDate->sizeHint(); 144 sizes[0]=lineDate->sizeHint();
141 //line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); 145 //line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height());
142 int todaywid = todayBut->sizeHint().width(); 146 int todaywid = todayBut->sizeHint().width();
143todayBut->setGeometry(0, height()-sizes[0].height(),todaywid, sizes[0].height()); 147todayBut->setGeometry(0, height()-sizes[0].height(),todaywid, sizes[0].height());
144 lineDate->setGeometry(0+todaywid, height()-sizes[0].height(), width()-todaywid, sizes[0].height()); 148 lineDate->setGeometry(0+todaywid, height()-sizes[0].height(), width()-todaywid, sizes[0].height());
145 // ----- adjust the table: 149 // ----- adjust the table:
146 table->setGeometry(0, buttonHeight, width(), 150 table->setGeometry(0, buttonHeight, width(),
147 height()-buttonHeight-sizes[0].height()); 151 height()-buttonHeight-sizes[0].height());
148} 152}
149 153
150void 154void
151KDatePicker::dateChangedSlot(QDate date) 155KDatePicker::dateChangedSlot(QDate date)
152{ 156{
153 lineDate->setDate( date );//(KGlobal::locale()->formatDate(date, true)); 157 lineDate->setDate( date );//(KGlobal::locale()->formatDate(date, true));
154 //line->setText(KGlobal::locale()->formatDate(date, true)); 158 //line->setText(KGlobal::locale()->formatDate(date, true));
155 QString temp; 159 QString temp;
156 selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); 160 selectMonth->setText(KGlobal::locale()->monthName(date.month(), false));
157 temp.setNum(date.year()); 161 temp.setNum(date.year());
158 selectYear->setText(temp); 162 selectYear->setText(temp);
159 emit(dateChanged(date)); 163 emit(dateChanged(date));
160} 164}
161 165
162void 166void
163KDatePicker::tableClickedSlot() 167KDatePicker::tableClickedSlot()
164{ 168{
165 169
166 emit(dateSelected(table->getDate())); 170 emit(dateSelected(table->getDate()));
167 emit(tableClicked()); 171 emit(tableClicked());
168} 172}
169 173
170const QDate& 174const QDate&
171KDatePicker::getDate() const 175KDatePicker::getDate() const
172{ 176{
173 return table->getDate(); 177 return table->getDate();
174} 178}
175 179
176const QDate & 180const QDate &
177KDatePicker::date() const 181KDatePicker::date() const
178{ 182{
179 return table->getDate(); 183 return table->getDate();
180} 184}
181 185
182void KDatePicker::goToday() 186void KDatePicker::goToday()
183{ 187{
184 slotSetDate( QDate::currentDate() ); 188 slotSetDate( QDate::currentDate() );
185 189
186} 190}
187void KDatePicker::slotSetDate( QDate date ) 191void KDatePicker::slotSetDate( QDate date )
188{ 192{
189 193
190 if(date.isValid()) { 194 if(date.isValid()) {
191 QString temp; 195 QString temp;
192 // ----- 196 // -----
193 table->setDate(date); 197 table->setDate(date);
194 selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); 198 selectMonth->setText(KGlobal::locale()->monthName(date.month(), false));
195 temp.setNum(date.year()); 199 temp.setNum(date.year());
196 selectYear->setText(temp); 200 selectYear->setText(temp);
197 //line->setText(KGlobal::locale()->formatDate(date, true)); 201 //line->setText(KGlobal::locale()->formatDate(date, true));
198 lineDate->setDate( date ); 202 lineDate->setDate( date );
199 } 203 }
200 204
201} 205}
202bool 206bool
203KDatePicker::setDate(const QDate& date) 207KDatePicker::setDate(const QDate& date)
204{ 208{
205 table->setFocus(); 209 table->setFocus();
206 if(date.isValid()) { 210 if(date.isValid()) {
207 QString temp; 211 QString temp;
208 // ----- 212 // -----
209 table->setDate(date); 213 table->setDate(date);
210 selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); 214 selectMonth->setText(KGlobal::locale()->monthName(date.month(), false));
211 temp.setNum(date.year()); 215 temp.setNum(date.year());
212 selectYear->setText(temp); 216 selectYear->setText(temp);
213 //line->setText(KGlobal::locale()->formatDate(date, true)); 217 //line->setText(KGlobal::locale()->formatDate(date, true));
214 lineDate->setDate( date ); 218 lineDate->setDate( date );
215 return true; 219 return true;
216 } else { 220 } else {
217 221
218 return false; 222 return false;
219 } 223 }
220 224
221 225
222} 226}
223 227
224void 228void
225KDatePicker::monthForwardClicked() 229KDatePicker::monthForwardClicked()
226{ 230{
227 QDate temp=table->getDate(); 231 QDate temp=table->getDate();
228 int day=temp.day(); 232 int day=temp.day();
229 // ----- 233 // -----
230 if(temp.month()==12) { 234 if(temp.month()==12) {
231 temp.setYMD(temp.year()+1, 1, 1); 235 temp.setYMD(temp.year()+1, 1, 1);
232 } else { 236 } else {
233 temp.setYMD(temp.year(), temp.month()+1, 1); 237 temp.setYMD(temp.year(), temp.month()+1, 1);
234 } 238 }
235 if(temp.daysInMonth()<day) { 239 if(temp.daysInMonth()<day) {
236 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); 240 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth());
237 } else { 241 } else {
238 temp.setYMD(temp.year(), temp.month(), day); 242 temp.setYMD(temp.year(), temp.month(), day);
239 } 243 }
240 // assert(temp.isValid()); 244 // assert(temp.isValid());
241 setDate(temp); 245 setDate(temp);
242} 246}
243 247
244void 248void
245KDatePicker::monthBackwardClicked() 249KDatePicker::monthBackwardClicked()
246{ 250{
247 QDate temp=table->getDate(); 251 QDate temp=table->getDate();
248 int day=temp.day(); 252 int day=temp.day();
249 // ----- 253 // -----
250 if(temp.month()==1) 254 if(temp.month()==1)
251 { 255 {
252 temp.setYMD(temp.year()-1, 12, 1); 256 temp.setYMD(temp.year()-1, 12, 1);
253 } else { 257 } else {
254 temp.setYMD(temp.year(), temp.month()-1, 1); 258 temp.setYMD(temp.year(), temp.month()-1, 1);
255 } 259 }
256 if(temp.daysInMonth()<day) 260 if(temp.daysInMonth()<day)
257 { 261 {
258 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); 262 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth());
259 } else { 263 } else {
260 temp.setYMD(temp.year(), temp.month(), day); 264 temp.setYMD(temp.year(), temp.month(), day);
261 } 265 }
262 // assert(temp.isValid()); 266 // assert(temp.isValid());
263 setDate(temp); 267 setDate(temp);
264} 268}
265 269
266void 270void
267KDatePicker::yearForwardClicked() 271KDatePicker::yearForwardClicked()
268{ 272{
269 QDate temp=table->getDate(); 273 QDate temp=table->getDate();
270 int day=temp.day(); 274 int day=temp.day();
271 // ----- 275 // -----
272 temp.setYMD(temp.year()+1, temp.month(), 1); 276 temp.setYMD(temp.year()+1, temp.month(), 1);
273 if(temp.daysInMonth()<day) 277 if(temp.daysInMonth()<day)
274 { 278 {
275 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); 279 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth());
276 } else { 280 } else {
277 temp.setYMD(temp.year(), temp.month(), day); 281 temp.setYMD(temp.year(), temp.month(), day);
278 } 282 }
279 // assert(temp.isValid()); 283 // assert(temp.isValid());
280 setDate(temp); 284 setDate(temp);
281} 285}
282 286
283void 287void
284KDatePicker::yearBackwardClicked() 288KDatePicker::yearBackwardClicked()
285{ 289{
286 QDate temp=table->getDate(); 290 QDate temp=table->getDate();
287 int day=temp.day(); 291 int day=temp.day();
288 // ----- 292 // -----
289 temp.setYMD(temp.year()-1, temp.month(), 1); 293 temp.setYMD(temp.year()-1, temp.month(), 1);
290 if(temp.daysInMonth()<day) 294 if(temp.daysInMonth()<day)
291 { 295 {
292 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); 296 temp.setYMD(temp.year(), temp.month(), temp.daysInMonth());
293 } else { 297 } else {
294 temp.setYMD(temp.year(), temp.month(), day); 298 temp.setYMD(temp.year(), temp.month(), day);
295 } 299 }
296 // assert(temp.isValid()); 300 // assert(temp.isValid());
297 setDate(temp); 301 setDate(temp);
298} 302}
299 303
300void 304void
301KDatePicker::selectMonthClicked() 305KDatePicker::selectMonthClicked()
302{ 306{
303 int month; 307 int month;
304 KPopupFrame* popup = new KPopupFrame(this); 308 KPopupFrame* popup = new KPopupFrame(this);
305 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); 309 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup);
306 // ----- 310 // -----
307 picker->resize(picker->sizeHint()); 311 picker->resize(picker->sizeHint());
308 popup->setMainWidget(picker); 312 popup->setMainWidget(picker);
309 picker->setFocus(); 313 picker->setFocus();
310 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 314 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
311 if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) 315 if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height()))))
312 { 316 {
313 QDate date; 317 QDate date;
314 int day; 318 int day;
315 // ----- 319 // -----
316 month=picker->getResult(); 320 month=picker->getResult();
317 date=table->getDate(); 321 date=table->getDate();
318 day=date.day(); 322 day=date.day();
319 // ----- construct a valid date in this month: 323 // ----- construct a valid date in this month:
320 date.setYMD(date.year(), month, 1); 324 date.setYMD(date.year(), month, 1);
321 date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); 325 date.setYMD(date.year(), month, QMIN(day, date.daysInMonth()));
322 // ----- set this month 326 // ----- set this month
323 setDate(date); 327 setDate(date);
324 } else { 328 } else {
325 KNotifyClient::beep(); 329 KNotifyClient::beep();
326 } 330 }
327 delete popup; 331 delete popup;
328} 332}
329 333
330void 334void
331KDatePicker::selectYearClicked() 335KDatePicker::selectYearClicked()
332{ 336{
333 int year; 337 int year;
334 KPopupFrame* popup = new KPopupFrame(this); 338 KPopupFrame* popup = new KPopupFrame(this);
335 KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup); 339 KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup);
336 // ----- 340 // -----
337 picker->resize(picker->sizeHint()); 341 picker->resize(picker->sizeHint());
338 popup->setMainWidget(picker); 342 popup->setMainWidget(picker);
339 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 343 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
340 picker->setFocus(); 344 picker->setFocus();
341 if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height())))) 345 if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height()))))
342 { 346 {
343 QDate date; 347 QDate date;
344 int day; 348 int day;
345 // ----- 349 // -----
346 year=picker->getYear(); 350 year=picker->getYear();
347 date=table->getDate(); 351 date=table->getDate();
348 day=date.day(); 352 day=date.day();
349 // ----- construct a valid date in this month: 353 // ----- construct a valid date in this month:
350 date.setYMD(year, date.month(), 1); 354 date.setYMD(year, date.month(), 1);
351 date.setYMD(year, date.month(), QMIN(day, date.daysInMonth())); 355 date.setYMD(year, date.month(), QMIN(day, date.daysInMonth()));
352 // ----- set this month 356 // ----- set this month
353 setDate(date); 357 setDate(date);
354 } else { 358 } else {
355 KNotifyClient::beep(); 359 KNotifyClient::beep();
356 } 360 }
357 delete popup; 361 delete popup;
358} 362}
359 363
360void 364void
361KDatePicker::setEnabled(bool enable) 365KDatePicker::setEnabled(bool enable)
362{ 366{
363 QWidget *widgets[]= { 367 QWidget *widgets[]= {
364 yearForward, yearBackward, monthForward, monthBackward, 368 yearForward, yearBackward, monthForward, monthBackward,
365 selectMonth, selectYear, 369 selectMonth, selectYear,
366 lineDate, table }; 370 lineDate, table };
367 const int Size=sizeof(widgets)/sizeof(widgets[0]); 371 const int Size=sizeof(widgets)/sizeof(widgets[0]);
368 int count; 372 int count;
369 // ----- 373 // -----
370 for(count=0; count<Size; ++count) 374 for(count=0; count<Size; ++count)
371 { 375 {
372 widgets[count]->setEnabled(enable); 376 widgets[count]->setEnabled(enable);
373 } 377 }
374} 378}
375 379
376void 380void
377KDatePicker::lineEnterPressed() 381KDatePicker::lineEnterPressed()
378{ 382{
379 QDate temp; 383 QDate temp;
380 // ----- 384 // -----
381 temp = lineDate->date(); 385 temp = lineDate->date();
382 //if(val->date(line->text(), temp)==QValidator::Acceptable) 386 //if(val->date(line->text(), temp)==QValidator::Acceptable)
383 //{ 387 //{
384 emit(dateEntered(temp)); 388 emit(dateEntered(temp));
385 setDate(temp); 389 setDate(temp);
386 // } else { 390 // } else {
387// KNotifyClient::beep(); 391// KNotifyClient::beep();
388// } 392// }
389} 393}
390 394
391QSize 395QSize
392KDatePicker::sizeHint() const 396KDatePicker::sizeHint() const
393{ 397{
394 QSize tableSize=table->sizeHint(); 398 QSize tableSize=table->sizeHint();
395 QWidget *buttons[]={ 399 QWidget *buttons[]={
396 yearBackward, 400 yearBackward,
397 monthBackward, 401 monthBackward,
398 selectMonth, 402 selectMonth,
399 selectYear, 403 selectYear,
400 monthForward, 404 monthForward,
401 yearForward }; 405 yearForward };
402 const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); 406 const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]);
403 QSize sizes[NoOfButtons]; 407 QSize sizes[NoOfButtons];
404 int cx=0, cy=0, count; 408 int cx=0, cy=0, count;
405 // ----- store the size hints: 409 // ----- store the size hints:
406 for(count=0; count<NoOfButtons; ++count) 410 for(count=0; count<NoOfButtons; ++count)
407 { 411 {
408 sizes[count]=buttons[count]->sizeHint(); 412 sizes[count]=buttons[count]->sizeHint();
409 if(buttons[count]==selectMonth) 413 if(buttons[count]==selectMonth)
410 { 414 {
411 cx+=maxMonthRect.width()+15; 415 cx+=maxMonthRect.width()+15;
412 } else { 416 } else {
413 cx+=sizes[count].width()+15; 417 cx+=sizes[count].width()+15;
414 } 418 }
415 cy=QMAX(sizes[count].height(), cy); 419 cy=QMAX(sizes[count].height(), cy);
416 } 420 }
417 // ----- calculate width hint: 421 // ----- calculate width hint:
418 cx=QMAX(cx, tableSize.width()); // line edit ignored 422 cx=QMAX(cx, tableSize.width()); // line edit ignored
419 if ( cx > QApplication::desktop()->width() -5 ) 423 if ( cx > QApplication::desktop()->width() -5 )
420 cx = QApplication::desktop()->width() -5; 424 cx = QApplication::desktop()->width() -5;
421 // ----- calculate height hint: 425 // ----- calculate height hint:
422 cy+=tableSize.height()+lineDate->sizeHint().height(); 426 cy+=tableSize.height()+lineDate->sizeHint().height();
423 427
424 return QSize(cx, cy); 428 return QSize(cx, cy);
425} 429}
426 430
427void 431void
428KDatePicker::setFontSize(int s) 432KDatePicker::setFontSize(int s)
429{ 433{
430 QWidget *buttons[]= { 434 QWidget *buttons[]= {
431 // yearBackward, 435 // yearBackward,
432 // monthBackward, 436 // monthBackward,
433 selectMonth, 437 selectMonth,
434 selectYear, 438 selectYear,
435 // monthForward, 439 // monthForward,
436 // yearForward 440 // yearForward
437 }; 441 };
438 const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); 442 const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]);
439 int count; 443 int count;
440 QFont font; 444 QFont font;
441 QRect r; 445 QRect r;
442 // ----- 446 // -----
443 fontsize=s; 447 fontsize=s;
444 for(count=0; count<NoOfButtons; ++count) 448 for(count=0; count<NoOfButtons; ++count)
445 { 449 {
446 font=buttons[count]->font(); 450 font=buttons[count]->font();
447 font.setPointSize(s); 451 font.setPointSize(s);
448 buttons[count]->setFont(font); 452 buttons[count]->setFont(font);
449 } 453 }
450 QFontMetrics metrics(selectMonth->fontMetrics()); 454 QFontMetrics metrics(selectMonth->fontMetrics());
451 for(int i=1; i <= 12; ++i) 455 for(int i=1; i <= 12; ++i)
452 { // maxMonthRect is used by sizeHint() 456 { // maxMonthRect is used by sizeHint()
453 r=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); 457 r=metrics.boundingRect(KGlobal::locale()->monthName(i, false));
454 maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width())); 458 maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width()));
455 maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height())); 459 maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height()));
456 } 460 }
457 table->setFontSize(s); 461 table->setFontSize(s);
458} 462}
459 463
460void KDatePicker::virtual_hook( int id, void* data ) 464void KDatePicker::virtual_hook( int id, void* data )
461{ /*BASE::virtual_hook( id, data );*/ } 465{ /*BASE::virtual_hook( id, data );*/ }
462 466
463void KDatePicker::keyPressEvent ( QKeyEvent * e ) 467void KDatePicker::keyPressEvent ( QKeyEvent * e )
464{ 468{
465 switch ( e->key() ) { 469 switch ( e->key() ) {
466 case Qt::Key_Right: 470 case Qt::Key_Right:
467 monthForwardClicked(); 471 monthForwardClicked();
468 break; 472 break;
469 case Qt::Key_Left: 473 case Qt::Key_Left:
470 monthBackwardClicked(); 474 monthBackwardClicked();
471 break; 475 break;
472 476
473 case Qt::Key_Down: 477 case Qt::Key_Down:
474 yearForwardClicked(); 478 yearForwardClicked();
475 479
476 break; 480 break;
477 481
478 case Qt::Key_Up: 482 case Qt::Key_Up:
479 yearBackwardClicked(); 483 yearBackwardClicked();
480 break; 484 break;
481 485
482 case Qt::Key_T: 486 case Qt::Key_T:
483 goToday(); 487 goToday();
484 break; 488 break;
485 489
486 case Qt::Key_Return: 490 case Qt::Key_Return:
487 case Qt::Key_Enter: 491 case Qt::Key_Enter:
488 case Qt::Key_Space: 492 case Qt::Key_Space:
489 tableClickedSlot(); 493 tableClickedSlot();
490 break; 494 break;
491 case Qt::Key_Escape: 495 case Qt::Key_Escape:
492 e->ignore(); 496 e->ignore();
493 break; 497 break;
494 default: 498 default:
495 break; 499 break;
496 } 500 }
497 501
498} 502}
diff --git a/libkdepim/kdatepicker.h b/libkdepim/kdatepicker.h
index 3db9a89..4d904da 100644
--- a/libkdepim/kdatepicker.h
+++ b/libkdepim/kdatepicker.h
@@ -1,183 +1,186 @@
1/* -*- C++ -*- 1/* -*- C++ -*-
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) 3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
4 (C) 1998-2001 Mirko Boehm (mirko@kde.org) 4 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef MICROKDE_KDATEPICKER_H 20#ifndef MICROKDE_KDATEPICKER_H
21#define MICROKDE_KDATEPICKER_H 21#define MICROKDE_KDATEPICKER_H
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qframe.h> 23#include <q3frame.h>
24#include <qevent.h> 24#include <qevent.h>
25//Added by qt3to4:
26#include <QResizeEvent>
27#include <QKeyEvent>
25 28
26class QLineEdit; 29class QLineEdit;
27class QToolButton; 30class QToolButton;
28class KDateValidator; 31class KDateValidator;
29class KDateTable; 32class KDateTable;
30class KDateEdit; 33class KDateEdit;
31 34
32/** 35/**
33 * Provides a widget for calendar date input. 36 * Provides a widget for calendar date input.
34 * 37 *
35 * Different from the 38 * Different from the
36 * previous versions, it now emits two types of signals, either 39 * previous versions, it now emits two types of signals, either
37 * @ref dateSelected() or @ref dateEntered() (see documentation for both 40 * @ref dateSelected() or @ref dateEntered() (see documentation for both
38 * signals). 41 * signals).
39 * 42 *
40 * A line edit has been added in the newer versions to allow the user 43 * A line edit has been added in the newer versions to allow the user
41 * to select a date directly by entering numbers like 19990101 44 * to select a date directly by entering numbers like 19990101
42 * or 990101. 45 * or 990101.
43 * 46 *
44 * @image kdatepicker.png KDatePicker 47 * @image kdatepicker.png KDatePicker
45 * 48 *
46 * @version $Id$ 49 * @version $Id$
47 * @author Tim Gilman, Mirko Boehm 50 * @author Tim Gilman, Mirko Boehm
48 * 51 *
49 * @short A date selection widget. 52 * @short A date selection widget.
50 **/ 53 **/
51class KDatePicker: public QFrame 54class KDatePicker: public Q3Frame
52{ 55{
53 Q_OBJECT 56 Q_OBJECT
54public: 57public:
55 /** The usual constructor. The given date will be displayed 58 /** The usual constructor. The given date will be displayed
56 * initially. 59 * initially.
57 **/ 60 **/
58 KDatePicker(QWidget *parent=0, 61 KDatePicker(QWidget *parent=0,
59 QDate=QDate::currentDate(), 62 QDate=QDate::currentDate(),
60 const char *name=0); 63 const char *name=0);
61 /** 64 /**
62 * The destructor. 65 * The destructor.
63 **/ 66 **/
64 virtual ~KDatePicker(); 67 virtual ~KDatePicker();
65 68
66 /** The size hint for date pickers. The size hint recommends the 69 /** The size hint for date pickers. The size hint recommends the
67 * minimum size of the widget so that all elements may be placed 70 * minimum size of the widget so that all elements may be placed
68 * without clipping. This sometimes looks ugly, so when using the 71 * without clipping. This sometimes looks ugly, so when using the
69 * size hint, try adding 28 to each of the reported numbers of 72 * size hint, try adding 28 to each of the reported numbers of
70 * pixels. 73 * pixels.
71 **/ 74 **/
72 QSize sizeHint() const; 75 QSize sizeHint() const;
73 76
74 /** 77 /**
75 * Sets the date. 78 * Sets the date.
76 * 79 *
77 * @returns @p false and does not change anything 80 * @returns @p false and does not change anything
78 * if the date given is invalid. 81 * if the date given is invalid.
79 **/ 82 **/
80 bool setDate(const QDate&); 83 bool setDate(const QDate&);
81 84
82 /** 85 /**
83 * Returns the selected date. 86 * Returns the selected date.
84 * @deprecated 87 * @deprecated
85 **/ 88 **/
86 const QDate& getDate() const; 89 const QDate& getDate() const;
87 90
88 /** 91 /**
89 * @returns the selected date. 92 * @returns the selected date.
90 */ 93 */
91 const QDate &date() const; 94 const QDate &date() const;
92 95
93 /** 96 /**
94 * Enables or disables the widget. 97 * Enables or disables the widget.
95 **/ 98 **/
96 void setEnabled(bool); 99 void setEnabled(bool);
97 100
98 /** 101 /**
99 * Sets the font size of the widgets elements. 102 * Sets the font size of the widgets elements.
100 **/ 103 **/
101 void setFontSize(int); 104 void setFontSize(int);
102 /** 105 /**
103 * Returns the font size of the widget elements. 106 * Returns the font size of the widget elements.
104 */ 107 */
105 int fontSize() const 108 int fontSize() const
106 { return fontsize; } 109 { return fontsize; }
107protected: 110protected:
108 /// the resize event 111 /// the resize event
109 void resizeEvent(QResizeEvent*); 112 void resizeEvent(QResizeEvent*);
110 QToolButton *todayBut; 113 QToolButton *todayBut;
111 /// the year forward button 114 /// the year forward button
112 QToolButton *yearForward; 115 QToolButton *yearForward;
113 /// the year backward button 116 /// the year backward button
114 QToolButton *yearBackward; 117 QToolButton *yearBackward;
115 /// the month forward button 118 /// the month forward button
116 QToolButton *monthForward; 119 QToolButton *monthForward;
117 /// the month backward button 120 /// the month backward button
118 QToolButton *monthBackward; 121 QToolButton *monthBackward;
119 /// the button for selecting the month directly 122 /// the button for selecting the month directly
120 QToolButton *selectMonth; 123 QToolButton *selectMonth;
121 /// the button for selecting the year directly 124 /// the button for selecting the year directly
122 QToolButton *selectYear; 125 QToolButton *selectYear;
123 /// the line edit to enter the date directly 126 /// the line edit to enter the date directly
124 //QLineEdit *line; 127 //QLineEdit *line;
125 KDateEdit *lineDate; 128 KDateEdit *lineDate;
126 /// the validator for the line edit: 129 /// the validator for the line edit:
127 KDateValidator *val; 130 KDateValidator *val;
128 /// the date table 131 /// the date table
129 KDateTable *table; 132 KDateTable *table;
130 /// the size calculated during resize events 133 /// the size calculated during resize events
131 // QSize sizehint; 134 // QSize sizehint;
132 /// the widest month string in pixels: 135 /// the widest month string in pixels:
133 QSize maxMonthRect; 136 QSize maxMonthRect;
134protected slots: 137protected slots:
135 void dateChangedSlot(QDate); 138 void dateChangedSlot(QDate);
136 void tableClickedSlot(); 139 void tableClickedSlot();
137 void monthForwardClicked(); 140 void monthForwardClicked();
138 void monthBackwardClicked(); 141 void monthBackwardClicked();
139 void yearForwardClicked(); 142 void yearForwardClicked();
140 void yearBackwardClicked(); 143 void yearBackwardClicked();
141 void selectMonthClicked(); 144 void selectMonthClicked();
142 void selectYearClicked(); 145 void selectYearClicked();
143 void lineEnterPressed(); 146 void lineEnterPressed();
144 void slotSetDate(QDate); 147 void slotSetDate(QDate);
145 void goToday(); 148 void goToday();
146signals: 149signals:
147 /** This signal is emitted each time the selected date is changed. 150 /** This signal is emitted each time the selected date is changed.
148 * Usually, this does not mean that the date has been entered, 151 * Usually, this does not mean that the date has been entered,
149 * since the date also changes, for example, when another month is 152 * since the date also changes, for example, when another month is
150 * selected. 153 * selected.
151 * @see dateSelected 154 * @see dateSelected
152 */ 155 */
153 void dateChanged(QDate); 156 void dateChanged(QDate);
154 /** This signal is emitted each time a day has been selected by 157 /** This signal is emitted each time a day has been selected by
155 * clicking on the table (hitting a day in the current month). It 158 * clicking on the table (hitting a day in the current month). It
156 * has the same meaning as dateSelected() in older versions of 159 * has the same meaning as dateSelected() in older versions of
157 * KDatePicker. 160 * KDatePicker.
158 */ 161 */
159 void dateSelected(QDate); 162 void dateSelected(QDate);
160 /** This signal is emitted when enter is pressed and a VALID date 163 /** This signal is emitted when enter is pressed and a VALID date
161 * has been entered before into the line edit. Connect to both 164 * has been entered before into the line edit. Connect to both
162 * dateEntered() and dateSelected() to receive all events where the 165 * dateEntered() and dateSelected() to receive all events where the
163 * user really enters a date. 166 * user really enters a date.
164 */ 167 */
165 void dateEntered(QDate); 168 void dateEntered(QDate);
166 /** This signal is emitted when the day has been selected by 169 /** This signal is emitted when the day has been selected by
167 * clicking on it in the table. 170 * clicking on it in the table.
168 */ 171 */
169 void tableClicked(); 172 void tableClicked();
170 173
171private: 174private:
172 /// the font size for the widget 175 /// the font size for the widget
173 int fontsize; 176 int fontsize;
174 177
175protected: 178protected:
176 virtual void virtual_hook( int id, void* data ); 179 virtual void virtual_hook( int id, void* data );
177private: 180private:
178 class KDatePickerPrivate; 181 class KDatePickerPrivate;
179 KDatePickerPrivate *d; 182 KDatePickerPrivate *d;
180 void keyPressEvent ( QKeyEvent * ) ; 183 void keyPressEvent ( QKeyEvent * ) ;
181}; 184};
182 185
183#endif // KDATEPICKER_H 186#endif // KDATEPICKER_H
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index 9c28425..3677e87 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -1,229 +1,229 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kconfig.h> 32#include <kconfig.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kdebug.h> 34#include <kdebug.h>
35#include <kglobalsettings.h> 35#include <kglobalsettings.h>
36#include <kstaticdeleter.h> 36#include <kstaticdeleter.h>
37 37
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <stdlib.h> 40#include <stdlib.h>
41#include <qtextstream.h> 41#include <q3textstream.h>
42#include <qapplication.h> 42#include <qapplication.h>
43#include "kpimglobalprefs.h" 43#include "kpimglobalprefs.h"
44 44
45KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; 45KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0;
46static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP; 46static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP;
47 47
48 48
49KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) 49KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
50 : KPrefs("microkdeglobalrc") 50 : KPrefs("microkdeglobalrc")
51{ 51{
52 mLocaleDict = 0; 52 mLocaleDict = 0;
53 KPrefs::setCurrentGroup("Fonts"); 53 KPrefs::setCurrentGroup("Fonts");
54 addItemFont("ApplicationFont",&mApplicationFont,KGlobalSettings::generalFont() ); 54 addItemFont("ApplicationFont",&mApplicationFont,KGlobalSettings::generalFont() );
55 KPrefs::setCurrentGroup("Locale"); 55 KPrefs::setCurrentGroup("Locale");
56 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 56 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
57 addItemInt("PreferredTime",&mPreferredTime,0); 57 addItemInt("PreferredTime",&mPreferredTime,0);
58 addItemInt("PreferredDate",&mPreferredDate,0); 58 addItemInt("PreferredDate",&mPreferredDate,0);
59 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); 59 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
60 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%AK %d. %b %y"); 60 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%AK %d. %b %y");
61 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); 61 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
62 62
63 KPrefs::setCurrentGroup("Colors"); 63 KPrefs::setCurrentGroup("Colors");
64 addItemColor("AlternateBGcolor",&mAlternateColor,KGlobalSettings::alternateBackgroundColor()); 64 addItemColor("AlternateBGcolor",&mAlternateColor,KGlobalSettings::alternateBackgroundColor());
65 65
66 66
67 KPrefs::setCurrentGroup("Time & Date"); 67 KPrefs::setCurrentGroup("Time & Date");
68 68
69 addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") ); 69 addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") );
70 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); 70 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
71 addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); 71 addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false);
72 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); 72 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
73 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 73 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
74 74
75 KPrefs::setCurrentGroup( "ExternalApplications" ); 75 KPrefs::setCurrentGroup( "ExternalApplications" );
76 76
77 addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); 77 addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC );
78 addItemString( "EmailChannel", &mEmailOtherChannel, "" ); 78 addItemString( "EmailChannel", &mEmailOtherChannel, "" );
79 addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); 79 addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" );
80 addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); 80 addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" );
81 addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); 81 addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" );
82 addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); 82 addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" );
83 83
84 addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); 84 addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC );
85 addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); 85 addItemString( "PhoneChannel", &mPhoneOtherChannel, "" );
86 addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); 86 addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" );
87 addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); 87 addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" );
88 88
89 addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); 89 addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC );
90 addItemString( "FaxChannel", &mFaxOtherChannel, "" ); 90 addItemString( "FaxChannel", &mFaxOtherChannel, "" );
91 addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); 91 addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" );
92 addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); 92 addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" );
93 93
94 addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); 94 addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC );
95 addItemString( "SMSChannel", &mSMSOtherChannel, "" ); 95 addItemString( "SMSChannel", &mSMSOtherChannel, "" );
96 addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); 96 addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" );
97 addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); 97 addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" );
98 98
99 addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); 99 addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC );
100 addItemString( "PagerChannel", &mPagerOtherChannel, "" ); 100 addItemString( "PagerChannel", &mPagerOtherChannel, "" );
101 addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); 101 addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" );
102 addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); 102 addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" );
103 103
104 addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); 104 addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC );
105 addItemString( "SIPChannel", &mSipOtherChannel, "" ); 105 addItemString( "SIPChannel", &mSipOtherChannel, "" );
106 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); 106 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" );
107 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); 107 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" );
108 108
109 KPrefs::setCurrentGroup( "PhoneAccess" ); 109 KPrefs::setCurrentGroup( "PhoneAccess" );
110 addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); 110 addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm");
111 addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); 111 addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda");
112 addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); 112 addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i");
113 113
114 KPrefs::setCurrentGroup( "BackupSettings" ); 114 KPrefs::setCurrentGroup( "BackupSettings" );
115 addItemString("BackupDatadir",&mBackupDatadir,KGlobalSettings::backupDataDir()); 115 addItemString("BackupDatadir",&mBackupDatadir,KGlobalSettings::backupDataDir());
116 addItemInt( "BackupNumbers", &mBackupNumbers, 3 ); 116 addItemInt( "BackupNumbers", &mBackupNumbers, 3 );
117 addItemInt( "BackupDayCount", &mBackupDayCount, 2 ); 117 addItemInt( "BackupDayCount", &mBackupDayCount, 2 );
118 addItemBool( "BackupUseDefaultDir",&mBackupUseDefaultDir, true ); 118 addItemBool( "BackupUseDefaultDir",&mBackupUseDefaultDir, true );
119 addItemBool( "BackupEnabled",&mBackupEnabled, false ); 119 addItemBool( "BackupEnabled",&mBackupEnabled, false );
120 120
121} 121}
122 122
123void KPimGlobalPrefs::setGlobalConfig() 123void KPimGlobalPrefs::setGlobalConfig()
124{ 124{
125 if ( mLocaleDict == 0 ) { 125 if ( mLocaleDict == 0 ) {
126 QString fileName ; 126 QString fileName ;
127 QString name = KGlobal::getAppName() +"/"; 127 QString name = KGlobal::getAppName() +"/";
128#ifndef DESKTOP_VERSION 128#ifndef DESKTOP_VERSION
129 fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name; 129 fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name;
130#else 130#else
131 fileName = qApp->applicationDirPath () + "/kdepim/"+ name; 131 fileName = qApp->applicationDirPath () + "/kdepim/"+ name;
132#endif 132#endif
133 mLocaleDict = 0; 133 mLocaleDict = 0;
134 if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { 134 if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) {
135 135
136 if ( mPreferredLanguage == 1 ) 136 if ( mPreferredLanguage == 1 )
137 fileName = fileName+"germantranslation.txt"; 137 fileName = fileName+"germantranslation.txt";
138 else if ( mPreferredLanguage == 4 ) 138 else if ( mPreferredLanguage == 4 )
139 fileName = fileName+"usertranslation.txt"; 139 fileName = fileName+"usertranslation.txt";
140 else if ( mPreferredLanguage == 2 ) 140 else if ( mPreferredLanguage == 2 )
141 fileName = fileName+"frenchtranslation.txt"; 141 fileName = fileName+"frenchtranslation.txt";
142 else if ( mPreferredLanguage == 3 ) 142 else if ( mPreferredLanguage == 3 )
143 fileName = fileName+"italiantranslation.txt"; 143 fileName = fileName+"italiantranslation.txt";
144 QFile file( fileName ); 144 QFile file( fileName );
145 if (file.open( IO_ReadOnly ) ) { 145 if (file.open( QIODevice::ReadOnly ) ) {
146 QTextStream ts( &file ); 146 Q3TextStream ts( &file );
147 ts.setEncoding( QTextStream::Latin1 ); 147 ts.setEncoding( Q3TextStream::Latin1 );
148 //ts.setCodec( QTextCodec::latin1 ); 148 //ts.setCodec( QTextCodec::latin1 );
149 QString text = ts.read(); 149 QString text = ts.read();
150 file.close(); 150 file.close();
151 text.replace( QRegExp("\\\\n"), "\n" ); 151 text.replace( QRegExp("\\\\n"), "\n" );
152 QString line; 152 QString line;
153 QString we; 153 QString we;
154 QString wt; 154 QString wt;
155 int br = 0; 155 int br = 0;
156 int nbr; 156 int nbr;
157 nbr = text.find ( "},", br ); 157 nbr = text.find ( "},", br );
158 line = text.mid( br, nbr - br ); 158 line = text.mid( br, nbr - br );
159 br = nbr+1; 159 br = nbr+1;
160 int se, ee, st, et; 160 int se, ee, st, et;
161 mLocaleDict = new QDict<QString>; 161 mLocaleDict = new Q3Dict<QString>;
162 mLocaleDict->setAutoDelete( true ); 162 mLocaleDict->setAutoDelete( true );
163 QString end = "{ \"\",\"\" }"; 163 QString end = "{ \"\",\"\" }";
164 while ( (line != end) && (br > 1) ) { 164 while ( (line != end) && (br > 1) ) {
165 //qDebug("%d *%s* ", br, line.latin1()); 165 //qDebug("%d *%s* ", br, line.latin1());
166 se = line.find("\"")+1; 166 se = line.find("\"")+1;
167 et = line.findRev("\"",-1); 167 et = line.findRev("\"",-1);
168 ee = line.find("\",\""); 168 ee = line.find("\",\"");
169 st = ee+3; 169 st = ee+3;
170 we = line.mid( se, ee-se ); 170 we = line.mid( se, ee-se );
171 if ( mPreferredLanguage == 4 ) 171 if ( mPreferredLanguage == 4 )
172 wt = QString::fromUtf8(line.mid( st, et-st ).latin1()); 172 wt = QString::fromUtf8(line.mid( st, et-st ).latin1());
173 else 173 else
174 wt = line.mid( st, et-st ); 174 wt = line.mid( st, et-st );
175 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); 175 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
176 mLocaleDict->insert( we, new QString (wt) ); 176 mLocaleDict->insert( we, new QString (wt) );
177 nbr = text.find ( "}", br ); 177 nbr = text.find ( "}", br );
178 line = text.mid( br, nbr - br ); 178 line = text.mid( br, nbr - br );
179 br = nbr+1; 179 br = nbr+1;
180 } 180 }
181 //qDebug("end *%s* ", end.latin1()); 181 //qDebug("end *%s* ", end.latin1());
182 182
183 setLocaleDict( mLocaleDict ); 183 setLocaleDict( mLocaleDict );
184 } else { 184 } else {
185 qDebug("KO: Cannot find translation file %s",fileName.latin1() ); 185 qDebug("KO: Cannot find translation file %s",fileName.latin1() );
186 } 186 }
187 } 187 }
188 } 188 }
189 189
190 KGlobal::locale()->setHore24Format( !mPreferredTime ); 190 KGlobal::locale()->setHore24Format( !mPreferredTime );
191 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); 191 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday );
192 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); 192 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate );
193 KGlobal::locale()->setLanguage( mPreferredLanguage ); 193 KGlobal::locale()->setLanguage( mPreferredLanguage );
194 QString dummy = mUserDateFormatLong; 194 QString dummy = mUserDateFormatLong;
195 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 195 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
196 dummy = mUserDateFormatShort; 196 dummy = mUserDateFormatShort;
197 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 197 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
198 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, 198 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving,
199 mDaylightsavingStart, 199 mDaylightsavingStart,
200 mDaylightsavingEnd ); 200 mDaylightsavingEnd );
201 KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); 201 KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min );
202 KGlobalSettings::setAlternateBackgroundColor(mAlternateColor); 202 KGlobalSettings::setAlternateBackgroundColor(mAlternateColor);
203 QString localKdeDir; 203 QString localKdeDir;
204 localKdeDir = readEnvPath("LOCALMICROKDEHOME"); 204 localKdeDir = readEnvPath("LOCALMICROKDEHOME");
205 if ( ! localKdeDir.isEmpty() ) { 205 if ( ! localKdeDir.isEmpty() ) {
206 mBackupUseDefaultDir = true; 206 mBackupUseDefaultDir = true;
207 mBackupDatadir = KGlobalSettings::backupDataDir(); 207 mBackupDatadir = KGlobalSettings::backupDataDir();
208 } 208 }
209 209
210} 210}
211KPimGlobalPrefs::~KPimGlobalPrefs() 211KPimGlobalPrefs::~KPimGlobalPrefs()
212{ 212{
213 if (sInstance == this) 213 if (sInstance == this)
214 sInstance = staticDeleterGP.setObject(0); 214 sInstance = staticDeleterGP.setObject(0);
215 else 215 else
216 qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); 216 qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?");
217 if ( mLocaleDict ) 217 if ( mLocaleDict )
218 delete mLocaleDict; 218 delete mLocaleDict;
219} 219}
220 220
221KPimGlobalPrefs *KPimGlobalPrefs::instance() 221KPimGlobalPrefs *KPimGlobalPrefs::instance()
222{ 222{
223 if ( !sInstance ) { 223 if ( !sInstance ) {
224 sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); 224 sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() );
225 sInstance->readConfig(); 225 sInstance->readConfig();
226 } 226 }
227 227
228 return sInstance; 228 return sInstance;
229} 229}
diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h
index 94ac8ae..01f5ab0 100644
--- a/libkdepim/kpimglobalprefs.h
+++ b/libkdepim/kpimglobalprefs.h
@@ -1,151 +1,151 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef KPIMGLOBALPREFS_H 31#ifndef KPIMGLOBALPREFS_H
32#define KPIMGLOBALPREFS_H 32#define KPIMGLOBALPREFS_H
33 33
34#include "kprefs.h" 34#include "kprefs.h"
35#include <qdict.h> 35#include <q3dict.h>
36 36
37class KPimGlobalPrefs : public KPrefs 37class KPimGlobalPrefs : public KPrefs
38{ 38{
39 public: 39 public:
40 40
41 void setGlobalConfig(); 41 void setGlobalConfig();
42 static KPimGlobalPrefs *instance(); 42 static KPimGlobalPrefs *instance();
43 43
44 44
45 virtual ~KPimGlobalPrefs(); 45 virtual ~KPimGlobalPrefs();
46 46
47 47
48 enum EMailClients { 48 enum EMailClients {
49 NONE_EMC = 0, 49 NONE_EMC = 0,
50 OTHER_EMC = 1, 50 OTHER_EMC = 1,
51 OMPI_EMC = 2, 51 OMPI_EMC = 2,
52 QTOPIA_EMC = 3, 52 QTOPIA_EMC = 3,
53 OPIE_EMC = 4, 53 OPIE_EMC = 4,
54 OPIE_MAILIT_EMC = 5 54 OPIE_MAILIT_EMC = 5
55 }; 55 };
56 56
57 enum PhoneClients { 57 enum PhoneClients {
58 NONE_PHC = 0, 58 NONE_PHC = 0,
59 OTHER_PHC = 1, 59 OTHER_PHC = 1,
60 KPPI_PHC = 2 60 KPPI_PHC = 2
61 }; 61 };
62 62
63 enum FaxClients { 63 enum FaxClients {
64 NONE_FAC = 0, 64 NONE_FAC = 0,
65 OTHER_FAC = 1 65 OTHER_FAC = 1
66 }; 66 };
67 67
68 enum SMSClients { 68 enum SMSClients {
69 NONE_SMC = 0, 69 NONE_SMC = 0,
70 OTHER_SMC = 1 70 OTHER_SMC = 1
71 }; 71 };
72 72
73 enum PagerClients { 73 enum PagerClients {
74 NONE_PAC = 0, 74 NONE_PAC = 0,
75 OTHER_PAC = 1 75 OTHER_PAC = 1
76 }; 76 };
77 77
78 enum SIPClients { 78 enum SIPClients {
79 NONE_SIC = 0, 79 NONE_SIC = 0,
80 OTHER_SIC = 1, 80 OTHER_SIC = 1,
81 KPPI_SIC = 2 81 KPPI_SIC = 2
82 }; 82 };
83 83
84 private: 84 private:
85 KPimGlobalPrefs( const QString &name = QString::null ); 85 KPimGlobalPrefs( const QString &name = QString::null );
86 86
87 static KPimGlobalPrefs *sInstance; 87 static KPimGlobalPrefs *sInstance;
88 QDict<QString> *mLocaleDict; 88 Q3Dict<QString> *mLocaleDict;
89 89
90 90
91 public: 91 public:
92 //US I copied the following "locale" settings from KOPrefs 92 //US I copied the following "locale" settings from KOPrefs
93 int mPreferredDate; 93 int mPreferredDate;
94 QString mUserDateFormatLong; 94 QString mUserDateFormatLong;
95 QString mUserDateFormatShort; 95 QString mUserDateFormatShort;
96 int mPreferredLanguage; 96 int mPreferredLanguage;
97 int mPreferredTime; 97 int mPreferredTime;
98 bool mWeekStartsOnSunday; 98 bool mWeekStartsOnSunday;
99 QString mTimeZoneId; 99 QString mTimeZoneId;
100 bool mUseDaylightsaving; 100 bool mUseDaylightsaving;
101 int mDaylightsavingStart; 101 int mDaylightsavingStart;
102 int mDaylightsavingEnd; 102 int mDaylightsavingEnd;
103 bool mTimeZoneAdd30min; 103 bool mTimeZoneAdd30min;
104 QFont mApplicationFont; 104 QFont mApplicationFont;
105 QColor mAlternateColor; 105 QColor mAlternateColor;
106 106
107 int mEmailClient; 107 int mEmailClient;
108 QString mEmailOtherChannel; 108 QString mEmailOtherChannel;
109 QString mEmailOtherMessage; 109 QString mEmailOtherMessage;
110 QString mEmailOtherMessageParameters; 110 QString mEmailOtherMessageParameters;
111 QString mEmailOtherMessage2; 111 QString mEmailOtherMessage2;
112 QString mEmailOtherMessageParameters2; 112 QString mEmailOtherMessageParameters2;
113 113
114 int mPhoneClient; 114 int mPhoneClient;
115 QString mPhoneOtherChannel; 115 QString mPhoneOtherChannel;
116 QString mPhoneOtherMessage; 116 QString mPhoneOtherMessage;
117 QString mPhoneOtherMessageParameters; 117 QString mPhoneOtherMessageParameters;
118 118
119 int mFaxClient; 119 int mFaxClient;
120 QString mFaxOtherChannel; 120 QString mFaxOtherChannel;
121 QString mFaxOtherMessage; 121 QString mFaxOtherMessage;
122 QString mFaxOtherMessageParameters; 122 QString mFaxOtherMessageParameters;
123 123
124 int mSMSClient; 124 int mSMSClient;
125 QString mSMSOtherChannel; 125 QString mSMSOtherChannel;
126 QString mSMSOtherMessage; 126 QString mSMSOtherMessage;
127 QString mSMSOtherMessageParameters; 127 QString mSMSOtherMessageParameters;
128 128
129 int mPagerClient; 129 int mPagerClient;
130 QString mPagerOtherChannel; 130 QString mPagerOtherChannel;
131 QString mPagerOtherMessage; 131 QString mPagerOtherMessage;
132 QString mPagerOtherMessageParameters; 132 QString mPagerOtherMessageParameters;
133 133
134 int mSipClient; 134 int mSipClient;
135 QString mSipOtherChannel; 135 QString mSipOtherChannel;
136 QString mSipOtherMessage; 136 QString mSipOtherMessage;
137 QString mSipOtherMessageParameters; 137 QString mSipOtherMessageParameters;
138 138
139 QString mEx2PhoneDevice; 139 QString mEx2PhoneDevice;
140 QString mEx2PhoneConnection; 140 QString mEx2PhoneConnection;
141 QString mEx2PhoneModel; 141 QString mEx2PhoneModel;
142 142
143 143
144 bool mBackupEnabled; 144 bool mBackupEnabled;
145 QString mBackupDatadir; 145 QString mBackupDatadir;
146 bool mBackupUseDefaultDir; 146 bool mBackupUseDefaultDir;
147 int mBackupNumbers; 147 int mBackupNumbers;
148 int mBackupDayCount; 148 int mBackupDayCount;
149}; 149};
150 150
151#endif 151#endif
diff --git a/libkdepim/kprefsdialog.cpp b/libkdepim/kprefsdialog.cpp
index 6dc741d..358acbd 100644
--- a/libkdepim/kprefsdialog.cpp
+++ b/libkdepim/kprefsdialog.cpp
@@ -1,440 +1,441 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24// $Id$ 24// $Id$
25 25
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qgroupbox.h> 28#include <q3groupbox.h>
29#include <qbuttongroup.h> 29#include <q3buttongroup.h>
30#include <qlineedit.h> 30#include <qlineedit.h>
31#include <qfont.h> 31#include <qfont.h>
32#include <qslider.h> 32#include <qslider.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qtextstream.h> 34#include <q3textstream.h>
35#include <qvbox.h> 35#include <q3vbox.h>
36#include <qhbox.h> 36#include <q3hbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qframe.h> 39#include <q3frame.h>
40#include <qcombobox.h> 40#include <qcombobox.h>
41#include <qcheckbox.h> 41#include <qcheckbox.h>
42#include <qradiobutton.h> 42#include <qradiobutton.h>
43#include <qpushbutton.h> 43#include <qpushbutton.h>
44#include <qapplication.h> 44#include <qapplication.h>
45#include <QDesktopWidget>
45 46
46#include <kcolorbutton.h> 47#include <kcolorbutton.h>
47#include <kdebug.h> 48#include <kdebug.h>
48#include <klocale.h> 49#include <klocale.h>
49#include <kglobal.h> 50#include <kglobal.h>
50#include <kglobalsettings.h> 51#include <kglobalsettings.h>
51#include <kfontdialog.h> 52#include <kfontdialog.h>
52#include <kmessagebox.h> 53#include <kmessagebox.h>
53#include <kcolordialog.h> 54#include <kcolordialog.h>
54#include <kiconloader.h> 55#include <kiconloader.h>
55 56
56#include "kprefs.h" 57#include "kprefs.h"
57#include "kpimglobalprefs.h" 58#include "kpimglobalprefs.h"
58 59
59#include "kprefsdialog.h" 60#include "kprefsdialog.h"
60//#include "kprefsdialog.moc" 61//#include "kprefsdialog.moc"
61 62
62KPrefsDialogWidBool::KPrefsDialogWidBool(const QString &text,bool *reference, 63KPrefsDialogWidBool::KPrefsDialogWidBool(const QString &text,bool *reference,
63 QWidget *parent) 64 QWidget *parent)
64{ 65{
65 mReference = reference; 66 mReference = reference;
66 67
67 mCheck = new QCheckBox(text,parent); 68 mCheck = new QCheckBox(text,parent);
68} 69}
69 70
70void KPrefsDialogWidBool::readConfig() 71void KPrefsDialogWidBool::readConfig()
71{ 72{
72 mCheck->setChecked(*mReference); 73 mCheck->setChecked(*mReference);
73} 74}
74 75
75void KPrefsDialogWidBool::writeConfig() 76void KPrefsDialogWidBool::writeConfig()
76{ 77{
77 *mReference = mCheck->isChecked(); 78 *mReference = mCheck->isChecked();
78} 79}
79 80
80QCheckBox *KPrefsDialogWidBool::checkBox() 81QCheckBox *KPrefsDialogWidBool::checkBox()
81{ 82{
82 return mCheck; 83 return mCheck;
83} 84}
84 85
85 86
86KPrefsDialogWidColor::KPrefsDialogWidColor(const QString &text,QColor *reference, 87KPrefsDialogWidColor::KPrefsDialogWidColor(const QString &text,QColor *reference,
87 QWidget *parent) 88 QWidget *parent)
88{ 89{
89 mReference = reference; 90 mReference = reference;
90 91
91 mButton = new KColorButton(parent); 92 mButton = new KColorButton(parent);
92 mLabel = new QLabel(mButton, text, parent); 93 mLabel = new QLabel(mButton, text, parent);
93 mButton->setColor( *mReference ); 94 mButton->setColor( *mReference );
94 mButton->setColor( Qt::red ); 95 mButton->setColor( Qt::red );
95 96
96} 97}
97 98
98KPrefsDialogWidColor::~KPrefsDialogWidColor() 99KPrefsDialogWidColor::~KPrefsDialogWidColor()
99{ 100{
100// kdDebug(5300) << "KPrefsDialogWidColor::~KPrefsDialogWidColor()" << endl; 101// kdDebug(5300) << "KPrefsDialogWidColor::~KPrefsDialogWidColor()" << endl;
101} 102}
102 103
103void KPrefsDialogWidColor::readConfig() 104void KPrefsDialogWidColor::readConfig()
104{ 105{
105 mButton->setColor(*mReference); 106 mButton->setColor(*mReference);
106} 107}
107 108
108void KPrefsDialogWidColor::writeConfig() 109void KPrefsDialogWidColor::writeConfig()
109{ 110{
110 *mReference = mButton->color(); 111 *mReference = mButton->color();
111} 112}
112 113
113QLabel *KPrefsDialogWidColor::label() 114QLabel *KPrefsDialogWidColor::label()
114{ 115{
115 return mLabel; 116 return mLabel;
116} 117}
117 118
118KColorButton *KPrefsDialogWidColor::button() 119KColorButton *KPrefsDialogWidColor::button()
119{ 120{
120 return mButton; 121 return mButton;
121} 122}
122 123
123KPrefsDialogWidFont::KPrefsDialogWidFont(const QString &sampleText,const QString &labelText, 124KPrefsDialogWidFont::KPrefsDialogWidFont(const QString &sampleText,const QString &labelText,
124 QFont *reference,QWidget *parent) 125 QFont *reference,QWidget *parent)
125{ 126{
126 mReference = reference; 127 mReference = reference;
127 128
128 mLabel = new QLabel(labelText, parent); 129 mLabel = new QLabel(labelText, parent);
129 130
130 mPreview = new QLabel(sampleText,parent); 131 mPreview = new QLabel(sampleText,parent);
131 mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken); 132 mPreview->setFrameStyle(Q3Frame::Panel|Q3Frame::Sunken);
132 133
133 mButton = new QPushButton(i18n("Choose..."), parent); 134 mButton = new QPushButton(i18n("Choose..."), parent);
134 connect(mButton,SIGNAL(clicked()),SLOT(selectFont())); 135 connect(mButton,SIGNAL(clicked()),SLOT(selectFont()));
135 mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 ); 136 mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 );
136 mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 ); 137 mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 );
137} 138}
138 139
139KPrefsDialogWidFont::~KPrefsDialogWidFont() 140KPrefsDialogWidFont::~KPrefsDialogWidFont()
140{ 141{
141} 142}
142 143
143void KPrefsDialogWidFont::readConfig() 144void KPrefsDialogWidFont::readConfig()
144{ 145{
145 mPreview->setFont(*mReference); 146 mPreview->setFont(*mReference);
146} 147}
147 148
148void KPrefsDialogWidFont::writeConfig() 149void KPrefsDialogWidFont::writeConfig()
149{ 150{
150 *mReference = mPreview->font(); 151 *mReference = mPreview->font();
151} 152}
152 153
153QLabel *KPrefsDialogWidFont::label() 154QLabel *KPrefsDialogWidFont::label()
154{ 155{
155 return mLabel; 156 return mLabel;
156} 157}
157 158
158QLabel *KPrefsDialogWidFont::preview() 159QLabel *KPrefsDialogWidFont::preview()
159{ 160{
160 return mPreview; 161 return mPreview;
161} 162}
162 163
163QPushButton *KPrefsDialogWidFont::button() 164QPushButton *KPrefsDialogWidFont::button()
164{ 165{
165 return mButton; 166 return mButton;
166} 167}
167 168
168void KPrefsDialogWidFont::selectFont() 169void KPrefsDialogWidFont::selectFont()
169{ 170{
170 QFont myFont(mPreview->font()); 171 QFont myFont(mPreview->font());
171 bool ok; 172 bool ok;
172 myFont = KFontDialog::getFont(myFont, ok); 173 myFont = KFontDialog::getFont(myFont, ok);
173 if ( ok ) { 174 if ( ok ) {
174 mPreview->setFont(myFont); 175 mPreview->setFont(myFont);
175 } 176 }
176} 177}
177 178
178 179
179KPrefsDialogWidTime::KPrefsDialogWidTime(const QString &text,int *reference, 180KPrefsDialogWidTime::KPrefsDialogWidTime(const QString &text,int *reference,
180 QWidget *parent) 181 QWidget *parent)
181{ 182{
182 mReference = reference; 183 mReference = reference;
183 184
184 mLabel = new QLabel(text,parent); 185 mLabel = new QLabel(text,parent);
185 mSpin = new QSpinBox(0,23,1,parent); 186 mSpin = new QSpinBox(0,23,1,parent);
186 mSpin->setSuffix(":00"); 187 mSpin->setSuffix(":00");
187} 188}
188 189
189void KPrefsDialogWidTime::readConfig() 190void KPrefsDialogWidTime::readConfig()
190{ 191{
191 mSpin->setValue(*mReference); 192 mSpin->setValue(*mReference);
192} 193}
193 194
194void KPrefsDialogWidTime::writeConfig() 195void KPrefsDialogWidTime::writeConfig()
195{ 196{
196 *mReference = mSpin->value(); 197 *mReference = mSpin->value();
197} 198}
198 199
199QLabel *KPrefsDialogWidTime::label() 200QLabel *KPrefsDialogWidTime::label()
200{ 201{
201 return mLabel; 202 return mLabel;
202} 203}
203 204
204QSpinBox *KPrefsDialogWidTime::spinBox() 205QSpinBox *KPrefsDialogWidTime::spinBox()
205{ 206{
206 return mSpin; 207 return mSpin;
207} 208}
208 209
209 210
210KPrefsDialogWidRadios::KPrefsDialogWidRadios(const QString &text,int *reference, 211KPrefsDialogWidRadios::KPrefsDialogWidRadios(const QString &text,int *reference,
211 QWidget *parent) 212 QWidget *parent)
212{ 213{
213 mReference = reference; 214 mReference = reference;
214 215
215 mBox = new QButtonGroup(1,Qt::Horizontal,text,parent); 216 mBox = new Q3ButtonGroup(1,Qt::Horizontal,text,parent);
216} 217}
217 218
218KPrefsDialogWidRadios::~KPrefsDialogWidRadios() 219KPrefsDialogWidRadios::~KPrefsDialogWidRadios()
219{ 220{
220} 221}
221 222
222void KPrefsDialogWidRadios::addRadio(const QString &text) 223void KPrefsDialogWidRadios::addRadio(const QString &text)
223{ 224{
224 new QRadioButton(text,mBox); 225 new QRadioButton(text,mBox);
225} 226}
226 227
227QButtonGroup *KPrefsDialogWidRadios::groupBox() 228Q3ButtonGroup *KPrefsDialogWidRadios::groupBox()
228{ 229{
229 return mBox; 230 return mBox;
230} 231}
231 232
232void KPrefsDialogWidRadios::readConfig() 233void KPrefsDialogWidRadios::readConfig()
233{ 234{
234 mBox->setButton(*mReference); 235 mBox->setButton(*mReference);
235} 236}
236 237
237void KPrefsDialogWidRadios::writeConfig() 238void KPrefsDialogWidRadios::writeConfig()
238{ 239{
239 *mReference = mBox->id(mBox->selected()); 240 *mReference = mBox->id(mBox->selected());
240} 241}
241 242
242 243
243KPrefsDialogWidString::KPrefsDialogWidString(const QString &text,QString *reference, 244KPrefsDialogWidString::KPrefsDialogWidString(const QString &text,QString *reference,
244 QWidget *parent, QLineEdit::EchoMode echomode) 245 QWidget *parent, QLineEdit::EchoMode echomode)
245{ 246{
246 mReference = reference; 247 mReference = reference;
247 248
248 mLabel = new QLabel(text,parent); 249 mLabel = new QLabel(text,parent);
249 mEdit = new QLineEdit(parent); 250 mEdit = new QLineEdit(parent);
250 mEdit->setEchoMode( echomode ); 251 mEdit->setEchoMode( echomode );
251} 252}
252 253
253KPrefsDialogWidString::~KPrefsDialogWidString() 254KPrefsDialogWidString::~KPrefsDialogWidString()
254{ 255{
255} 256}
256 257
257void KPrefsDialogWidString::readConfig() 258void KPrefsDialogWidString::readConfig()
258{ 259{
259 mEdit->setText(*mReference); 260 mEdit->setText(*mReference);
260} 261}
261 262
262void KPrefsDialogWidString::writeConfig() 263void KPrefsDialogWidString::writeConfig()
263{ 264{
264 *mReference = mEdit->text(); 265 *mReference = mEdit->text();
265} 266}
266 267
267QLabel *KPrefsDialogWidString::label() 268QLabel *KPrefsDialogWidString::label()
268{ 269{
269 return mLabel; 270 return mLabel;
270} 271}
271 272
272QLineEdit *KPrefsDialogWidString::lineEdit() 273QLineEdit *KPrefsDialogWidString::lineEdit()
273{ 274{
274 return mEdit; 275 return mEdit;
275} 276}
276 277
277 278
278KPrefsDialog::KPrefsDialog(KPrefs *prefs,QWidget *parent,char *name,bool modal) : 279KPrefsDialog::KPrefsDialog(KPrefs *prefs,QWidget *parent,char *name,bool modal) :
279 KDialogBase(IconList,i18n("Preferences"),Ok|Cancel|Default,Ok,parent, 280 KDialogBase(IconList,i18n("Preferences"),Ok|Cancel|Default,Ok,parent,
280 name,modal,true) 281 name,modal,true)
281{ 282{
282 mPrefs = prefs; 283 mPrefs = prefs;
283 284
284// This seems to cause a crash on exit. Investigate later. 285// This seems to cause a crash on exit. Investigate later.
285 mPrefsWids.setAutoDelete(true); 286 mPrefsWids.setAutoDelete(true);
286 287
287 connect(this,SIGNAL(defaultClicked()),SLOT(slotDefault())); 288 connect(this,SIGNAL(defaultClicked()),SLOT(slotDefault()));
288 //connect(this,SIGNAL(cancelClicked()),SLOT(slotDefault())); 289 //connect(this,SIGNAL(cancelClicked()),SLOT(slotDefault()));
289 //connect(this,SIGNAL(cancelClicked()),SLOT(reject())); 290 //connect(this,SIGNAL(cancelClicked()),SLOT(reject()));
290} 291}
291 292
292KPrefsDialog::~KPrefsDialog() 293KPrefsDialog::~KPrefsDialog()
293{ 294{
294} 295}
295 296
296void KPrefsDialog::addWid(KPrefsDialogWid *wid) 297void KPrefsDialog::addWid(KPrefsDialogWid *wid)
297{ 298{
298 mPrefsWids.append(wid); 299 mPrefsWids.append(wid);
299} 300}
300 301
301KPrefsDialogWidBool *KPrefsDialog::addWidBool(const QString &text,bool *reference,QWidget *parent) 302KPrefsDialogWidBool *KPrefsDialog::addWidBool(const QString &text,bool *reference,QWidget *parent)
302{ 303{
303 KPrefsDialogWidBool *w = new KPrefsDialogWidBool(text,reference,parent); 304 KPrefsDialogWidBool *w = new KPrefsDialogWidBool(text,reference,parent);
304 addWid(w); 305 addWid(w);
305 return w; 306 return w;
306} 307}
307 308
308KPrefsDialogWidTime *KPrefsDialog::addWidTime(const QString &text,int *reference,QWidget *parent) 309KPrefsDialogWidTime *KPrefsDialog::addWidTime(const QString &text,int *reference,QWidget *parent)
309{ 310{
310 KPrefsDialogWidTime *w = new KPrefsDialogWidTime(text,reference,parent); 311 KPrefsDialogWidTime *w = new KPrefsDialogWidTime(text,reference,parent);
311 addWid(w); 312 addWid(w);
312 return w; 313 return w;
313} 314}
314 315
315KPrefsDialogWidColor *KPrefsDialog::addWidColor(const QString &text,QColor *reference,QWidget *parent) 316KPrefsDialogWidColor *KPrefsDialog::addWidColor(const QString &text,QColor *reference,QWidget *parent)
316{ 317{
317 KPrefsDialogWidColor *w = new KPrefsDialogWidColor(text,reference,parent); 318 KPrefsDialogWidColor *w = new KPrefsDialogWidColor(text,reference,parent);
318 addWid(w); 319 addWid(w);
319 return w; 320 return w;
320} 321}
321 322
322KPrefsDialogWidRadios *KPrefsDialog::addWidRadios(const QString &text,int *reference,QWidget *parent) 323KPrefsDialogWidRadios *KPrefsDialog::addWidRadios(const QString &text,int *reference,QWidget *parent)
323{ 324{
324 KPrefsDialogWidRadios *w = new KPrefsDialogWidRadios(text,reference,parent); 325 KPrefsDialogWidRadios *w = new KPrefsDialogWidRadios(text,reference,parent);
325 addWid(w); 326 addWid(w);
326 return w; 327 return w;
327} 328}
328 329
329KPrefsDialogWidString *KPrefsDialog::addWidString(const QString &text,QString *reference,QWidget *parent) 330KPrefsDialogWidString *KPrefsDialog::addWidString(const QString &text,QString *reference,QWidget *parent)
330{ 331{
331 KPrefsDialogWidString *w = new KPrefsDialogWidString(text,reference,parent); 332 KPrefsDialogWidString *w = new KPrefsDialogWidString(text,reference,parent);
332 addWid(w); 333 addWid(w);
333 return w; 334 return w;
334} 335}
335 336
336KPrefsDialogWidString *KPrefsDialog::addWidPassword(const QString &text,QString *reference,QWidget *parent) 337KPrefsDialogWidString *KPrefsDialog::addWidPassword(const QString &text,QString *reference,QWidget *parent)
337{ 338{
338 KPrefsDialogWidString *w = new KPrefsDialogWidString(text,reference,parent,QLineEdit::Password); 339 KPrefsDialogWidString *w = new KPrefsDialogWidString(text,reference,parent,QLineEdit::Password);
339 addWid(w); 340 addWid(w);
340 return w; 341 return w;
341} 342}
342 343
343KPrefsDialogWidFont *KPrefsDialog::addWidFont(const QString &sampleText,const QString &buttonText, 344KPrefsDialogWidFont *KPrefsDialog::addWidFont(const QString &sampleText,const QString &buttonText,
344 QFont *reference,QWidget *parent) 345 QFont *reference,QWidget *parent)
345{ 346{
346 KPrefsDialogWidFont *w = new KPrefsDialogWidFont(sampleText,buttonText,reference,parent); 347 KPrefsDialogWidFont *w = new KPrefsDialogWidFont(sampleText,buttonText,reference,parent);
347 addWid(w); 348 addWid(w);
348 return w; 349 return w;
349} 350}
350 351
351void KPrefsDialog::setDefaults() 352void KPrefsDialog::setDefaults()
352{ 353{
353 mPrefs->setDefaults(); 354 mPrefs->setDefaults();
354 355
355 readConfig(); 356 readConfig();
356} 357}
357 358
358void KPrefsDialog::readConfig() 359void KPrefsDialog::readConfig()
359{ 360{
360// kdDebug(5300) << "KPrefsDialog::readConfig()" << endl; 361// kdDebug(5300) << "KPrefsDialog::readConfig()" << endl;
361 362
362 KPrefsDialogWid *wid; 363 KPrefsDialogWid *wid;
363 for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { 364 for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) {
364 wid->readConfig(); 365 wid->readConfig();
365 } 366 }
366 367
367 usrReadConfig(); 368 usrReadConfig();
368} 369}
369 370
370void KPrefsDialog::writeConfig() 371void KPrefsDialog::writeConfig()
371{ 372{
372// kdDebug(5300) << "KPrefsDialog::writeConfig()" << endl; 373// kdDebug(5300) << "KPrefsDialog::writeConfig()" << endl;
373 374
374 KPrefsDialogWid *wid; 375 KPrefsDialogWid *wid;
375 for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { 376 for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) {
376 wid->writeConfig(); 377 wid->writeConfig();
377 } 378 }
378 379
379 usrWriteConfig(); 380 usrWriteConfig();
380 381
381// kdDebug(5300) << "KPrefsDialog::writeConfig() now writing..." << endl; 382// kdDebug(5300) << "KPrefsDialog::writeConfig() now writing..." << endl;
382 383
383 mPrefs->writeConfig(); 384 mPrefs->writeConfig();
384 385
385// kdDebug(5300) << "KPrefsDialog::writeConfig() done" << endl; 386// kdDebug(5300) << "KPrefsDialog::writeConfig() done" << endl;
386} 387}
387 388
388 389
389void KPrefsDialog::slotApply() 390void KPrefsDialog::slotApply()
390{ 391{
391 writeConfig(); 392 writeConfig();
392 emit configChanged(); 393 emit configChanged();
393} 394}
394 395
395void KPrefsDialog::slotOk() 396void KPrefsDialog::slotOk()
396{ 397{
397 slotApply(); 398 slotApply();
398 QDialog::accept(); 399 QDialog::accept();
399} 400}
400void KPrefsDialog::accept() 401void KPrefsDialog::accept()
401{ 402{
402 slotOk(); 403 slotOk();
403} 404}
404 405
405void KPrefsDialog::slotDefault() 406void KPrefsDialog::slotDefault()
406{ 407{
407 if (KMessageBox::warningContinueCancel(this, 408 if (KMessageBox::warningContinueCancel(this,
408 i18n("You are about to set all\npreferences to default values.\nAll " 409 i18n("You are about to set all\npreferences to default values.\nAll "
409 "custom modifications will be lost."),i18n("Setting Default Preferences"), 410 "custom modifications will be lost."),i18n("Setting Default Preferences"),
410 i18n("Continue")) 411 i18n("Continue"))
411 == KMessageBox::Continue) setDefaults(); 412 == KMessageBox::Continue) setDefaults();
412} 413}
413 414
414KPimPrefsGlobalDialog::KPimPrefsGlobalDialog(QWidget *parent,char *name,bool modal): KPrefsDialog( KPimGlobalPrefs::instance() ,parent, name, modal ) 415KPimPrefsGlobalDialog::KPimPrefsGlobalDialog(QWidget *parent,char *name,bool modal): KPrefsDialog( KPimGlobalPrefs::instance() ,parent, name, modal )
415{ 416{
416 setFont( KGlobalSettings::generalMaxFont() ); 417 setFont( KGlobalSettings::generalMaxFont() );
417 kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), this, "KPrefsGlobalDialog" ); 418 kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), this, "KPrefsGlobalDialog" );
418 setMainWidget( kdelibcfg ); 419 setMainWidget( kdelibcfg );
419 setCaption( i18n("KDE-Pim Global Settings")); 420 setCaption( i18n("KDE-Pim Global Settings"));
420 kdelibcfg->readConfig(); 421 kdelibcfg->readConfig();
421#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
422 if ( QApplication::desktop()->height() <= 480 ) 423 if ( QApplication::desktop()->height() <= 480 )
423 hideButtons(); 424 hideButtons();
424 showMaximized(); 425 showMaximized();
425#endif 426#endif
426} 427}
427void KPimPrefsGlobalDialog::showTZconfig() 428void KPimPrefsGlobalDialog::showTZconfig()
428{ 429{
429 kdelibcfg->showTimeZoneTab() ; 430 kdelibcfg->showTimeZoneTab() ;
430} 431}
431void KPimPrefsGlobalDialog::usrReadConfig() 432void KPimPrefsGlobalDialog::usrReadConfig()
432{ 433{
433 kdelibcfg->readConfig(); 434 kdelibcfg->readConfig();
434} 435}
435 436
436void KPimPrefsGlobalDialog::usrWriteConfig() 437void KPimPrefsGlobalDialog::usrWriteConfig()
437{ 438{
438 kdelibcfg->writeConfig(); 439 kdelibcfg->writeConfig();
439} 440}
440 441
diff --git a/libkdepim/kprefsdialog.h b/libkdepim/kprefsdialog.h
index 52ec809..cc95dd4 100644
--- a/libkdepim/kprefsdialog.h
+++ b/libkdepim/kprefsdialog.h
@@ -1,471 +1,473 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef _KPREFSDIALOG_H 23#ifndef _KPREFSDIALOG_H
24#define _KPREFSDIALOG_H 24#define _KPREFSDIALOG_H
25// $Id$ 25// $Id$
26 26
27#include <qptrlist.h> 27#include <q3ptrlist.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29//Added by qt3to4:
30#include <QLabel>
29 31
30#include <kdialogbase.h> 32#include <kdialogbase.h>
31 33
32class KPrefs; 34class KPrefs;
33class KPrefsDialog; 35class KPrefsDialog;
34 36
35class KColorButton; 37class KColorButton;
36class QCheckBox; 38class QCheckBox;
37class QLabel; 39class QLabel;
38class QSpinBox; 40class QSpinBox;
39class QButtonGroup; 41class Q3ButtonGroup;
40 42
41/** 43/**
42 @short Base class for widgets used by @ref KPrefsDialog. 44 @short Base class for widgets used by @ref KPrefsDialog.
43 @author Cornelius Schumacher 45 @author Cornelius Schumacher
44 @see KPrefsDialog 46 @see KPrefsDialog
45 47
46 This class provides the interface for the preferences widgets used by 48 This class provides the interface for the preferences widgets used by
47 KPrefsDialog. 49 KPrefsDialog.
48*/ 50*/
49class KPrefsDialogWid : public QObject 51class KPrefsDialogWid : public QObject
50{ 52{
51 public: 53 public:
52 /** 54 /**
53 This function is called to read value of the setting from the 55 This function is called to read value of the setting from the
54 stored configuration and display it in the widget. 56 stored configuration and display it in the widget.
55 */ 57 */
56 virtual void readConfig() = 0; 58 virtual void readConfig() = 0;
57 /** 59 /**
58 This function is called to write the current setting of the widget to the 60 This function is called to write the current setting of the widget to the
59 stored configuration. 61 stored configuration.
60 */ 62 */
61 virtual void writeConfig() = 0; 63 virtual void writeConfig() = 0;
62}; 64};
63 65
64/** 66/**
65 @short Widget for bool settings in @ref KPrefsDialog. 67 @short Widget for bool settings in @ref KPrefsDialog.
66 68
67 This class provides a widget for configuring bool values. It is meant to be 69 This class provides a widget for configuring bool values. It is meant to be
68 used by KPrefsDialog. The user is responsible for the layout management. 70 used by KPrefsDialog. The user is responsible for the layout management.
69*/ 71*/
70class KPrefsDialogWidBool : public KPrefsDialogWid 72class KPrefsDialogWidBool : public KPrefsDialogWid
71{ 73{
72 public: 74 public:
73 /** 75 /**
74 Create a bool widget consisting of a QCheckbox. 76 Create a bool widget consisting of a QCheckbox.
75 77
76 @param text Text of QCheckBox. 78 @param text Text of QCheckBox.
77 @param reference Pointer to variable read and written by this widget. 79 @param reference Pointer to variable read and written by this widget.
78 @param parent Parent widget. 80 @param parent Parent widget.
79 */ 81 */
80 KPrefsDialogWidBool(const QString &text,bool *reference,QWidget *parent); 82 KPrefsDialogWidBool(const QString &text,bool *reference,QWidget *parent);
81 83
82 /** 84 /**
83 Return the QCheckbox used by this widget. 85 Return the QCheckbox used by this widget.
84 */ 86 */
85 QCheckBox *checkBox(); 87 QCheckBox *checkBox();
86 88
87 void readConfig(); 89 void readConfig();
88 void writeConfig(); 90 void writeConfig();
89 91
90 private: 92 private:
91 bool *mReference; 93 bool *mReference;
92 94
93 QCheckBox *mCheck; 95 QCheckBox *mCheck;
94}; 96};
95 97
96/** 98/**
97 @short Widget for time settings in @ref KPrefsDialog. 99 @short Widget for time settings in @ref KPrefsDialog.
98 100
99 This class provides a widget for configuring time values. It is meant to be 101 This class provides a widget for configuring time values. It is meant to be
100 used by KPrefsDialog. The user is responsible for the layout management. 102 used by KPrefsDialog. The user is responsible for the layout management.
101*/ 103*/
102class KPrefsDialogWidTime : public KPrefsDialogWid 104class KPrefsDialogWidTime : public KPrefsDialogWid
103{ 105{
104 public: 106 public:
105 /** 107 /**
106 Create a time widget consisting of a label and a spinbox. 108 Create a time widget consisting of a label and a spinbox.
107 109
108 @param text Text of Label. 110 @param text Text of Label.
109 @param reference Pointer to variable read and written by this widget. 111 @param reference Pointer to variable read and written by this widget.
110 @param parent Parent widget. 112 @param parent Parent widget.
111 */ 113 */
112 KPrefsDialogWidTime(const QString &text,int *reference,QWidget *parent); 114 KPrefsDialogWidTime(const QString &text,int *reference,QWidget *parent);
113 115
114 /** 116 /**
115 Return QLabel used by this widget. 117 Return QLabel used by this widget.
116 */ 118 */
117 QLabel *label(); 119 QLabel *label();
118 /** 120 /**
119 Return QSpinBox used by this widget. 121 Return QSpinBox used by this widget.
120 */ 122 */
121 QSpinBox *spinBox(); 123 QSpinBox *spinBox();
122 124
123 void readConfig(); 125 void readConfig();
124 void writeConfig(); 126 void writeConfig();
125 127
126 private: 128 private:
127 int *mReference; 129 int *mReference;
128 130
129 QLabel *mLabel; 131 QLabel *mLabel;
130 QSpinBox *mSpin; 132 QSpinBox *mSpin;
131}; 133};
132 134
133/** 135/**
134 @short Widget for color settings in @ref KPrefsDialog. 136 @short Widget for color settings in @ref KPrefsDialog.
135 137
136 This class provides a widget for configuring color values. It is meant to be 138 This class provides a widget for configuring color values. It is meant to be
137 used by KPrefsDialog. The user is responsible for the layout management. 139 used by KPrefsDialog. The user is responsible for the layout management.
138*/ 140*/
139class KPrefsDialogWidColor : public KPrefsDialogWid 141class KPrefsDialogWidColor : public KPrefsDialogWid
140{ 142{
141 public: 143 public:
142 /** 144 /**
143 Create a color widget consisting of a test field and a button for opening 145 Create a color widget consisting of a test field and a button for opening
144 a color dialog. 146 a color dialog.
145 147
146 @param text Text of button. 148 @param text Text of button.
147 @param reference Pointer to variable read and written by this widget. 149 @param reference Pointer to variable read and written by this widget.
148 @param parent Parent widget. 150 @param parent Parent widget.
149 */ 151 */
150 KPrefsDialogWidColor(const QString &text,QColor *reference,QWidget *parent); 152 KPrefsDialogWidColor(const QString &text,QColor *reference,QWidget *parent);
151 /** 153 /**
152 Destruct color setting widget. 154 Destruct color setting widget.
153 */ 155 */
154 ~KPrefsDialogWidColor(); 156 ~KPrefsDialogWidColor();
155 157
156 /** 158 /**
157 Return QLabel for the button 159 Return QLabel for the button
158 */ 160 */
159 QLabel *label(); 161 QLabel *label();
160 /** 162 /**
161 Return button opening the color dialog. 163 Return button opening the color dialog.
162 */ 164 */
163 KColorButton *button(); 165 KColorButton *button();
164 166
165 void readConfig(); 167 void readConfig();
166 void writeConfig(); 168 void writeConfig();
167 169
168 private: 170 private:
169 QColor *mReference; 171 QColor *mReference;
170 172
171 QLabel *mLabel; 173 QLabel *mLabel;
172 KColorButton *mButton; 174 KColorButton *mButton;
173}; 175};
174 176
175/** 177/**
176 @short Widget for font settings in @ref KPrefsDialog. 178 @short Widget for font settings in @ref KPrefsDialog.
177 179
178 This class provides a widget for configuring font values. It is meant to be 180 This class provides a widget for configuring font values. It is meant to be
179 used by KPrefsDialog. The user is responsible for the layout management. 181 used by KPrefsDialog. The user is responsible for the layout management.
180*/ 182*/
181class KPrefsDialogWidFont : public KPrefsDialogWid 183class KPrefsDialogWidFont : public KPrefsDialogWid
182{ 184{
183 Q_OBJECT 185 Q_OBJECT
184 public: 186 public:
185 /** 187 /**
186 Create a font widget consisting of a test field and a button for opening 188 Create a font widget consisting of a test field and a button for opening
187 a font dialog. 189 a font dialog.
188 190
189 @param label Text of label. 191 @param label Text of label.
190 @param reference Pointer to variable read and written by this widget. 192 @param reference Pointer to variable read and written by this widget.
191 @param parent Parent widget. 193 @param parent Parent widget.
192 */ 194 */
193 KPrefsDialogWidFont(const QString &sampleText,const QString &labelText, 195 KPrefsDialogWidFont(const QString &sampleText,const QString &labelText,
194 QFont *reference,QWidget *parent); 196 QFont *reference,QWidget *parent);
195 /** 197 /**
196 Destruct font setting widget. 198 Destruct font setting widget.
197 */ 199 */
198 ~KPrefsDialogWidFont(); 200 ~KPrefsDialogWidFont();
199 201
200 /** 202 /**
201 Return label. 203 Return label.
202 */ 204 */
203 QLabel *label(); 205 QLabel *label();
204 /** 206 /**
205 Return QFrame used as preview field. 207 Return QFrame used as preview field.
206 */ 208 */
207 QLabel *preview(); 209 QLabel *preview();
208 /** 210 /**
209 Return button opening the font dialog. 211 Return button opening the font dialog.
210 */ 212 */
211 QPushButton *button(); 213 QPushButton *button();
212 214
213 void readConfig(); 215 void readConfig();
214 void writeConfig(); 216 void writeConfig();
215 217
216 protected slots: 218 protected slots:
217 void selectFont(); 219 void selectFont();
218 220
219 private: 221 private:
220 QFont *mReference; 222 QFont *mReference;
221 223
222 QLabel *mLabel; 224 QLabel *mLabel;
223 QLabel *mPreview; 225 QLabel *mPreview;
224 QPushButton *mButton; 226 QPushButton *mButton;
225}; 227};
226 228
227/** 229/**
228 @short Widget for settings represented by a group of radio buttons in 230 @short Widget for settings represented by a group of radio buttons in
229 @ref KPrefsDialog. 231 @ref KPrefsDialog.
230 232
231 This class provides a widget for configuring selections. It is meant to be 233 This class provides a widget for configuring selections. It is meant to be
232 used by KPrefsDialog. The user is responsible for the layout management. The 234 used by KPrefsDialog. The user is responsible for the layout management. The
233 setting is interpreted as an int value, corresponding to the position of the 235 setting is interpreted as an int value, corresponding to the position of the
234 radio button. The position of the button is defined by the sequence of @ref 236 radio button. The position of the button is defined by the sequence of @ref
235 addRadio() calls, starting with 0. 237 addRadio() calls, starting with 0.
236*/ 238*/
237class KPrefsDialogWidRadios : public KPrefsDialogWid 239class KPrefsDialogWidRadios : public KPrefsDialogWid
238{ 240{
239 public: 241 public:
240 /** 242 /**
241 Create a widget for selection of an option. It consists of a box with 243 Create a widget for selection of an option. It consists of a box with
242 several radio buttons. 244 several radio buttons.
243 245
244 @param text Text of main box. 246 @param text Text of main box.
245 @param reference Pointer to variable read and written by this widget. 247 @param reference Pointer to variable read and written by this widget.
246 @param parent Parent widget. 248 @param parent Parent widget.
247 */ 249 */
248 KPrefsDialogWidRadios(const QString &text,int *reference,QWidget *parent); 250 KPrefsDialogWidRadios(const QString &text,int *reference,QWidget *parent);
249 virtual ~KPrefsDialogWidRadios(); 251 virtual ~KPrefsDialogWidRadios();
250 252
251 /** 253 /**
252 Add a radio button. 254 Add a radio button.
253 255
254 @param text Text of the button. 256 @param text Text of the button.
255 */ 257 */
256 void addRadio(const QString &text); 258 void addRadio(const QString &text);
257 259
258 /** 260 /**
259 Return the box widget used by this widget. 261 Return the box widget used by this widget.
260 */ 262 */
261 QButtonGroup *groupBox(); 263 Q3ButtonGroup *groupBox();
262 264
263 void readConfig(); 265 void readConfig();
264 void writeConfig(); 266 void writeConfig();
265 267
266 private: 268 private:
267 int *mReference; 269 int *mReference;
268 270
269 QButtonGroup *mBox; 271 Q3ButtonGroup *mBox;
270}; 272};
271 273
272 274
273/** 275/**
274 @short Widget for string settings in @ref KPrefsDialog. 276 @short Widget for string settings in @ref KPrefsDialog.
275 277
276 This class provides a widget for configuring string values. It is meant to be 278 This class provides a widget for configuring string values. It is meant to be
277 used by KPrefsDialog. The user is responsible for the layout management. 279 used by KPrefsDialog. The user is responsible for the layout management.
278*/ 280*/
279class KPrefsDialogWidString : public KPrefsDialogWid 281class KPrefsDialogWidString : public KPrefsDialogWid
280{ 282{
281 public: 283 public:
282 /** 284 /**
283 Create a string widget consisting of a test label and a line edit. 285 Create a string widget consisting of a test label and a line edit.
284 286
285 @param text Text of label. 287 @param text Text of label.
286 @param reference Pointer to variable read and written by this widget. 288 @param reference Pointer to variable read and written by this widget.
287 @param parent Parent widget. 289 @param parent Parent widget.
288 */ 290 */
289 KPrefsDialogWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal); 291 KPrefsDialogWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal);
290 /** 292 /**
291 Destructor. 293 Destructor.
292 */ 294 */
293 virtual ~KPrefsDialogWidString(); 295 virtual ~KPrefsDialogWidString();
294 296
295 /** 297 /**
296 Return label used by this widget. 298 Return label used by this widget.
297 */ 299 */
298 QLabel *label(); 300 QLabel *label();
299 /** 301 /**
300 Return QLineEdit used by this widget. 302 Return QLineEdit used by this widget.
301 */ 303 */
302 QLineEdit *lineEdit(); 304 QLineEdit *lineEdit();
303 305
304 void readConfig(); 306 void readConfig();
305 void writeConfig(); 307 void writeConfig();
306 308
307 private: 309 private:
308 QString *mReference; 310 QString *mReference;
309 311
310 QLabel *mLabel; 312 QLabel *mLabel;
311 QLineEdit *mEdit; 313 QLineEdit *mEdit;
312}; 314};
313 315
314 316
315/** 317/**
316 @short Base class for a preferences dialog. 318 @short Base class for a preferences dialog.
317 319
318 This class provides the framework for a preferences dialog. You have to 320 This class provides the framework for a preferences dialog. You have to
319 subclass it and add the code to create the actual configuration widgets and 321 subclass it and add the code to create the actual configuration widgets and
320 do the layout management. 322 do the layout management.
321 323
322 KPrefsDialog provides functions to add subclasses of @ref KPrefsDialogWid. For 324 KPrefsDialog provides functions to add subclasses of @ref KPrefsDialogWid. For
323 these widgets the reading, writing and setting to default values is handled 325 these widgets the reading, writing and setting to default values is handled
324 automatically. Custom widgets have to be handled in the functions @ref 326 automatically. Custom widgets have to be handled in the functions @ref
325 usrReadConfig() and @ref usrWriteConfig(). 327 usrReadConfig() and @ref usrWriteConfig().
326*/ 328*/
327class KPrefsDialog : public KDialogBase 329class KPrefsDialog : public KDialogBase
328{ 330{
329 Q_OBJECT 331 Q_OBJECT
330 public: 332 public:
331 /** 333 /**
332 Create a KPrefsDialog for a KPrefs object. 334 Create a KPrefsDialog for a KPrefs object.
333 335
334 @param prefs KPrefs object used to access te configuration. 336 @param prefs KPrefs object used to access te configuration.
335 @param parent Parent widget. 337 @param parent Parent widget.
336 @param name Widget name. 338 @param name Widget name.
337 @param modal true, if dialog has to be modal, false for non-modal. 339 @param modal true, if dialog has to be modal, false for non-modal.
338 */ 340 */
339 KPrefsDialog(KPrefs *prefs,QWidget *parent=0,char *name=0,bool modal=false); 341 KPrefsDialog(KPrefs *prefs,QWidget *parent=0,char *name=0,bool modal=false);
340 /** 342 /**
341 Destructor. 343 Destructor.
342 */ 344 */
343 virtual ~KPrefsDialog(); 345 virtual ~KPrefsDialog();
344 346
345 /** 347 /**
346 Register a custom KPrefsDialogWid object. 348 Register a custom KPrefsDialogWid object.
347 */ 349 */
348 void addWid(KPrefsDialogWid *); 350 void addWid(KPrefsDialogWid *);
349 /** 351 /**
350 Register a @ref KPrefsDialogWidBool object. 352 Register a @ref KPrefsDialogWidBool object.
351 353
352 @param text Text of bool widget. 354 @param text Text of bool widget.
353 @param reference Reference to variable storing the setting. 355 @param reference Reference to variable storing the setting.
354 @param parent Parent widget. 356 @param parent Parent widget.
355 */ 357 */
356 KPrefsDialogWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent); 358 KPrefsDialogWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent);
357 /** 359 /**
358 Register a @ref KPrefsDialogWidTime object. 360 Register a @ref KPrefsDialogWidTime object.
359 361
360 @param text Text of time widget. 362 @param text Text of time widget.
361 @param reference Reference to variable storing the setting. 363 @param reference Reference to variable storing the setting.
362 @param parent Parent widget. 364 @param parent Parent widget.
363 */ 365 */
364 KPrefsDialogWidTime *addWidTime(const QString &text,int *reference,QWidget *parent); 366 KPrefsDialogWidTime *addWidTime(const QString &text,int *reference,QWidget *parent);
365 /** 367 /**
366 Register a @ref KPrefsDialogWidColor object. 368 Register a @ref KPrefsDialogWidColor object.
367 369
368 @param text Text of color widget. 370 @param text Text of color widget.
369 @param reference Reference to variable storing the setting. 371 @param reference Reference to variable storing the setting.
370 @param parent Parent widget. 372 @param parent Parent widget.
371 */ 373 */
372 KPrefsDialogWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent); 374 KPrefsDialogWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent);
373 /** 375 /**
374 Register a @ref KPrefsDialogWidRadios object. 376 Register a @ref KPrefsDialogWidRadios object.
375 377
376 @param text Text of radio button box widget. 378 @param text Text of radio button box widget.
377 @param reference Reference to variable storing the setting. 379 @param reference Reference to variable storing the setting.
378 @param parent Parent widget. 380 @param parent Parent widget.
379 */ 381 */
380 KPrefsDialogWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent); 382 KPrefsDialogWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent);
381 /** 383 /**
382 Register a @ref KPrefsDialogWidString object. 384 Register a @ref KPrefsDialogWidString object.
383 385
384 @param text Text of string widget. 386 @param text Text of string widget.
385 @param reference Reference to variable storing the setting. 387 @param reference Reference to variable storing the setting.
386 @param parent Parent widget. 388 @param parent Parent widget.
387 */ 389 */
388 KPrefsDialogWidString *addWidString(const QString &text,QString *reference,QWidget *parent); 390 KPrefsDialogWidString *addWidString(const QString &text,QString *reference,QWidget *parent);
389 /** 391 /**
390 Register a password @ref KPrefsDialogWidString object, with echomode set to QLineEdit::Password. 392 Register a password @ref KPrefsDialogWidString object, with echomode set to QLineEdit::Password.
391 393
392 @param text Text of string widget. 394 @param text Text of string widget.
393 @param reference Reference to variable storing the setting. 395 @param reference Reference to variable storing the setting.
394 @param parent Parent widget. 396 @param parent Parent widget.
395 */ 397 */
396 KPrefsDialogWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent); 398 KPrefsDialogWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent);
397 /** 399 /**
398 Register a @ref KPrefsDialogWidFont object. 400 Register a @ref KPrefsDialogWidFont object.
399 401
400 @param sampleText Sample text of font widget. 402 @param sampleText Sample text of font widget.
401 @param buttonText Button text of font widget. 403 @param buttonText Button text of font widget.
402 @param reference Reference to variable storing the setting. 404 @param reference Reference to variable storing the setting.
403 @param parent Parent widget. 405 @param parent Parent widget.
404 */ 406 */
405 KPrefsDialogWidFont *addWidFont(const QString &sampleText,const QString &buttonText, 407 KPrefsDialogWidFont *addWidFont(const QString &sampleText,const QString &buttonText,
406 QFont *reference,QWidget *parent); 408 QFont *reference,QWidget *parent);
407 409
408 public slots: 410 public slots:
409 /** Set all widgets to default values. */ 411 /** Set all widgets to default values. */
410 void setDefaults(); 412 void setDefaults();
411 413
412 /** Read preferences from config file. */ 414 /** Read preferences from config file. */
413 void readConfig(); 415 void readConfig();
414 416
415 /** Write preferences to config file. */ 417 /** Write preferences to config file. */
416 void writeConfig(); 418 void writeConfig();
417 419
418 signals: 420 signals:
419 /** Emitted when the a changed configuration has been stored. */ 421 /** Emitted when the a changed configuration has been stored. */
420 void configChanged(); 422 void configChanged();
421 423
422 protected slots: 424 protected slots:
423 /** Apply changes to preferences */ 425 /** Apply changes to preferences */
424 void slotApply(); 426 void slotApply();
425 427
426 void accept(); 428 void accept();
427 /** Accept changes to preferences and close dialog */ 429 /** Accept changes to preferences and close dialog */
428 void slotOk(); 430 void slotOk();
429 431
430 /** Set preferences to default values */ 432 /** Set preferences to default values */
431 void slotDefault(); 433 void slotDefault();
432 434
433 protected: 435 protected:
434 /** Implement this to read custom configuration widgets. */ 436 /** Implement this to read custom configuration widgets. */
435 virtual void usrReadConfig() {} 437 virtual void usrReadConfig() {}
436 /** Implement this to write custom configuration widgets. */ 438 /** Implement this to write custom configuration widgets. */
437 virtual void usrWriteConfig() {} 439 virtual void usrWriteConfig() {}
438 440
439 private: 441 private:
440 KPrefs *mPrefs; 442 KPrefs *mPrefs;
441 443
442 QPtrList<KPrefsDialogWid> mPrefsWids; 444 Q3PtrList<KPrefsDialogWid> mPrefsWids;
443}; 445};
444 446
445 447
446#include "kcmconfigs/kdepimconfigwidget.h" 448#include "kcmconfigs/kdepimconfigwidget.h"
447class KPimPrefsGlobalDialog : public KPrefsDialog 449class KPimPrefsGlobalDialog : public KPrefsDialog
448{ 450{
449 Q_OBJECT 451 Q_OBJECT
450 public: 452 public:
451 KPimPrefsGlobalDialog(QWidget *parent=0,char *name=0,bool modal=true); 453 KPimPrefsGlobalDialog(QWidget *parent=0,char *name=0,bool modal=true);
452 /** 454 /**
453 Destructor. 455 Destructor.
454 */ 456 */
455 void showTZconfig(); 457 void showTZconfig();
456 458
457 public slots: 459 public slots:
458 460
459 signals: 461 signals:
460 protected slots: 462 protected slots:
461 463
462 protected: 464 protected:
463 void usrReadConfig(); 465 void usrReadConfig();
464 virtual void usrWriteConfig() ; 466 virtual void usrWriteConfig() ;
465 467
466 private: 468 private:
467 KDEPIMConfigWidget* kdelibcfg; 469 KDEPIMConfigWidget* kdelibcfg;
468 470
469}; 471};
470 472
471#endif 473#endif
diff --git a/libkdepim/kprefswidget.cpp b/libkdepim/kprefswidget.cpp
index f6a0b38..51431e2 100644
--- a/libkdepim/kprefswidget.cpp
+++ b/libkdepim/kprefswidget.cpp
@@ -1,428 +1,429 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24// $Id$ 24// $Id$
25 25
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qgroupbox.h> 28#include <q3groupbox.h>
29#include <qbuttongroup.h> 29#include <q3buttongroup.h>
30#include <qlineedit.h> 30#include <qlineedit.h>
31#include <qfont.h> 31#include <qfont.h>
32#include <qslider.h> 32#include <qslider.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qtextstream.h> 34#include <q3textstream.h>
35#include <qvbox.h> 35#include <q3vbox.h>
36#include <qhbox.h> 36#include <q3hbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qframe.h> 39#include <q3frame.h>
40#include <qcombobox.h> 40#include <qcombobox.h>
41#include <qcheckbox.h> 41#include <qcheckbox.h>
42#include <qradiobutton.h> 42#include <qradiobutton.h>
43#include <qpushbutton.h> 43#include <qpushbutton.h>
44#include <qapplication.h> 44#include <qapplication.h>
45#include <QDesktopWidget>
45 46
46#include <kcolorbutton.h> 47#include <kcolorbutton.h>
47#include <kdebug.h> 48#include <kdebug.h>
48#include <klocale.h> 49#include <klocale.h>
49#include <kglobal.h> 50#include <kglobal.h>
50#include <kfontdialog.h> 51#include <kfontdialog.h>
51#include <kmessagebox.h> 52#include <kmessagebox.h>
52#include <kcolordialog.h> 53#include <kcolordialog.h>
53#include <kiconloader.h> 54#include <kiconloader.h>
54 55
55#include "kprefs.h" 56#include "kprefs.h"
56 57
57#include "kprefswidget.h" 58#include "kprefswidget.h"
58//#include "kprefsdialog.moc" 59//#include "kprefsdialog.moc"
59 60
60KPrefsWidBool::KPrefsWidBool(const QString &text,bool *reference, 61KPrefsWidBool::KPrefsWidBool(const QString &text,bool *reference,
61 QWidget *parent) 62 QWidget *parent)
62{ 63{
63 mReference = reference; 64 mReference = reference;
64 65
65 mCheck = new QCheckBox(text,parent); 66 mCheck = new QCheckBox(text,parent);
66 67
67 connect( mCheck, SIGNAL( toggled( bool ) ), SIGNAL( modified() ) ); 68 connect( mCheck, SIGNAL( toggled( bool ) ), SIGNAL( modified() ) );
68 69
69} 70}
70 71
71void KPrefsWidBool::readConfig() 72void KPrefsWidBool::readConfig()
72{ 73{
73 mCheck->setChecked(*mReference); 74 mCheck->setChecked(*mReference);
74} 75}
75 76
76void KPrefsWidBool::writeConfig() 77void KPrefsWidBool::writeConfig()
77{ 78{
78 *mReference = mCheck->isChecked(); 79 *mReference = mCheck->isChecked();
79} 80}
80 81
81QCheckBox *KPrefsWidBool::checkBox() 82QCheckBox *KPrefsWidBool::checkBox()
82{ 83{
83 return mCheck; 84 return mCheck;
84} 85}
85 86
86 87
87KPrefsWidColor::KPrefsWidColor(const QString &text,QColor *reference, 88KPrefsWidColor::KPrefsWidColor(const QString &text,QColor *reference,
88 QWidget *parent) 89 QWidget *parent)
89{ 90{
90 mReference = reference; 91 mReference = reference;
91 92
92 mButton = new KColorButton(parent); 93 mButton = new KColorButton(parent);
93 mLabel = new QLabel(mButton, text, parent); 94 mLabel = new QLabel(mButton, text, parent);
94 mButton->setColor( *mReference ); 95 mButton->setColor( *mReference );
95 mButton->setColor( Qt::red ); 96 mButton->setColor( Qt::red );
96 97
97 connect( mButton, SIGNAL( changed(const QColor &)), SIGNAL( modified() ) ); 98 connect( mButton, SIGNAL( changed(const QColor &)), SIGNAL( modified() ) );
98 99
99} 100}
100 101
101KPrefsWidColor::~KPrefsWidColor() 102KPrefsWidColor::~KPrefsWidColor()
102{ 103{
103// kdDebug(5300) << "KPrefsWidColor::~KPrefsWidColor()" << endl; 104// kdDebug(5300) << "KPrefsWidColor::~KPrefsWidColor()" << endl;
104} 105}
105 106
106void KPrefsWidColor::readConfig() 107void KPrefsWidColor::readConfig()
107{ 108{
108 mButton->setColor(*mReference); 109 mButton->setColor(*mReference);
109} 110}
110 111
111void KPrefsWidColor::writeConfig() 112void KPrefsWidColor::writeConfig()
112{ 113{
113 *mReference = mButton->color(); 114 *mReference = mButton->color();
114} 115}
115 116
116QLabel *KPrefsWidColor::label() 117QLabel *KPrefsWidColor::label()
117{ 118{
118 return mLabel; 119 return mLabel;
119} 120}
120 121
121KColorButton *KPrefsWidColor::button() 122KColorButton *KPrefsWidColor::button()
122{ 123{
123 return mButton; 124 return mButton;
124} 125}
125 126
126KPrefsWidFont::KPrefsWidFont(const QString &sampleText,const QString &labelText, 127KPrefsWidFont::KPrefsWidFont(const QString &sampleText,const QString &labelText,
127 QFont *reference,QWidget *parent) 128 QFont *reference,QWidget *parent)
128{ 129{
129 mReference = reference; 130 mReference = reference;
130 131
131 mLabel = new QLabel(labelText, parent); 132 mLabel = new QLabel(labelText, parent);
132 133
133 mPreview = new QLabel(sampleText,parent); 134 mPreview = new QLabel(sampleText,parent);
134 mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken); 135 mPreview->setFrameStyle(Q3Frame::Panel|Q3Frame::Sunken);
135 136
136 mButton = new QPushButton(i18n("Choose..."), parent); 137 mButton = new QPushButton(i18n("Choose..."), parent);
137 connect(mButton,SIGNAL(clicked()),SLOT(selectFont())); 138 connect(mButton,SIGNAL(clicked()),SLOT(selectFont()));
138 mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 ); 139 mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 );
139 mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 ); 140 mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 );
140} 141}
141 142
142KPrefsWidFont::~KPrefsWidFont() 143KPrefsWidFont::~KPrefsWidFont()
143{ 144{
144} 145}
145 146
146void KPrefsWidFont::readConfig() 147void KPrefsWidFont::readConfig()
147{ 148{
148 mPreview->setFont(*mReference); 149 mPreview->setFont(*mReference);
149} 150}
150 151
151void KPrefsWidFont::writeConfig() 152void KPrefsWidFont::writeConfig()
152{ 153{
153 *mReference = mPreview->font(); 154 *mReference = mPreview->font();
154} 155}
155 156
156QLabel *KPrefsWidFont::label() 157QLabel *KPrefsWidFont::label()
157{ 158{
158 return mLabel; 159 return mLabel;
159} 160}
160 161
161QLabel *KPrefsWidFont::preview() 162QLabel *KPrefsWidFont::preview()
162{ 163{
163 return mPreview; 164 return mPreview;
164} 165}
165 166
166QPushButton *KPrefsWidFont::button() 167QPushButton *KPrefsWidFont::button()
167{ 168{
168 return mButton; 169 return mButton;
169} 170}
170 171
171void KPrefsWidFont::selectFont() 172void KPrefsWidFont::selectFont()
172{ 173{
173 QFont myFont(mPreview->font()); 174 QFont myFont(mPreview->font());
174 bool ok; 175 bool ok;
175 myFont = KFontDialog::getFont(myFont, ok); 176 myFont = KFontDialog::getFont(myFont, ok);
176 if ( ok ) { 177 if ( ok ) {
177 mPreview->setFont(myFont); 178 mPreview->setFont(myFont);
178 emit modified(); 179 emit modified();
179 } 180 }
180} 181}
181 182
182 183
183KPrefsWidTime::KPrefsWidTime(const QString &text,int *reference, 184KPrefsWidTime::KPrefsWidTime(const QString &text,int *reference,
184 QWidget *parent) 185 QWidget *parent)
185{ 186{
186 mReference = reference; 187 mReference = reference;
187 188
188 mLabel = new QLabel(text,parent); 189 mLabel = new QLabel(text,parent);
189 mSpin = new QSpinBox(0,23,1,parent); 190 mSpin = new QSpinBox(0,23,1,parent);
190 mSpin->setSuffix(":00"); 191 mSpin->setSuffix(":00");
191 connect( mSpin, SIGNAL( valueChanged(int)), SIGNAL( modified() ) ); 192 connect( mSpin, SIGNAL( valueChanged(int)), SIGNAL( modified() ) );
192 193
193} 194}
194 195
195void KPrefsWidTime::readConfig() 196void KPrefsWidTime::readConfig()
196{ 197{
197 mSpin->setValue(*mReference); 198 mSpin->setValue(*mReference);
198} 199}
199 200
200void KPrefsWidTime::writeConfig() 201void KPrefsWidTime::writeConfig()
201{ 202{
202 *mReference = mSpin->value(); 203 *mReference = mSpin->value();
203} 204}
204 205
205QLabel *KPrefsWidTime::label() 206QLabel *KPrefsWidTime::label()
206{ 207{
207 return mLabel; 208 return mLabel;
208} 209}
209 210
210QSpinBox *KPrefsWidTime::spinBox() 211QSpinBox *KPrefsWidTime::spinBox()
211{ 212{
212 return mSpin; 213 return mSpin;
213} 214}
214 215
215 216
216KPrefsWidRadios::KPrefsWidRadios(const QString &text,int *reference, 217KPrefsWidRadios::KPrefsWidRadios(const QString &text,int *reference,
217 QWidget *parent) 218 QWidget *parent)
218{ 219{
219 mReference = reference; 220 mReference = reference;
220 221
221 mBox = new QButtonGroup(1,Qt::Horizontal,text,parent); 222 mBox = new Q3ButtonGroup(1,Qt::Horizontal,text,parent);
222 connect( mBox, SIGNAL( clicked(int)), SIGNAL( modified() ) ); 223 connect( mBox, SIGNAL( clicked(int)), SIGNAL( modified() ) );
223} 224}
224 225
225KPrefsWidRadios::~KPrefsWidRadios() 226KPrefsWidRadios::~KPrefsWidRadios()
226{ 227{
227} 228}
228 229
229void KPrefsWidRadios::addRadio(const QString &text) 230void KPrefsWidRadios::addRadio(const QString &text)
230{ 231{
231 new QRadioButton(text,mBox); 232 new QRadioButton(text,mBox);
232} 233}
233 234
234QButtonGroup *KPrefsWidRadios::groupBox() 235Q3ButtonGroup *KPrefsWidRadios::groupBox()
235{ 236{
236 return mBox; 237 return mBox;
237} 238}
238 239
239void KPrefsWidRadios::readConfig() 240void KPrefsWidRadios::readConfig()
240{ 241{
241 mBox->setButton(*mReference); 242 mBox->setButton(*mReference);
242} 243}
243 244
244void KPrefsWidRadios::writeConfig() 245void KPrefsWidRadios::writeConfig()
245{ 246{
246 *mReference = mBox->id(mBox->selected()); 247 *mReference = mBox->id(mBox->selected());
247} 248}
248 249
249 250
250KPrefsWidString::KPrefsWidString(const QString &text,QString *reference, 251KPrefsWidString::KPrefsWidString(const QString &text,QString *reference,
251 QWidget *parent, QLineEdit::EchoMode echomode) 252 QWidget *parent, QLineEdit::EchoMode echomode)
252{ 253{
253 mReference = reference; 254 mReference = reference;
254 255
255 mLabel = new QLabel(text,parent); 256 mLabel = new QLabel(text,parent);
256 mEdit = new QLineEdit(parent); 257 mEdit = new QLineEdit(parent);
257 mEdit->setEchoMode( echomode ); 258 mEdit->setEchoMode( echomode );
258 connect( mEdit, SIGNAL( textChanged(const QString&) ), SIGNAL( modified() ) ); 259 connect( mEdit, SIGNAL( textChanged(const QString&) ), SIGNAL( modified() ) );
259 260
260} 261}
261 262
262KPrefsWidString::~KPrefsWidString() 263KPrefsWidString::~KPrefsWidString()
263{ 264{
264} 265}
265 266
266void KPrefsWidString::readConfig() 267void KPrefsWidString::readConfig()
267{ 268{
268 mEdit->setText(*mReference); 269 mEdit->setText(*mReference);
269} 270}
270 271
271void KPrefsWidString::writeConfig() 272void KPrefsWidString::writeConfig()
272{ 273{
273 *mReference = mEdit->text(); 274 *mReference = mEdit->text();
274} 275}
275 276
276QLabel *KPrefsWidString::label() 277QLabel *KPrefsWidString::label()
277{ 278{
278 return mLabel; 279 return mLabel;
279} 280}
280 281
281QLineEdit *KPrefsWidString::lineEdit() 282QLineEdit *KPrefsWidString::lineEdit()
282{ 283{
283 return mEdit; 284 return mEdit;
284} 285}
285 286
286 287
287KPrefsWidget::KPrefsWidget(KPrefs *prefs,QWidget *parent,const char *name) : 288KPrefsWidget::KPrefsWidget(KPrefs *prefs,QWidget *parent,const char *name) :
288 QWidget(parent, name ) 289 QWidget(parent, name )
289{ 290{
290 mPrefs = prefs; 291 mPrefs = prefs;
291 mPrefsWids.setAutoDelete( true ); 292 mPrefsWids.setAutoDelete( true );
292} 293}
293 294
294KPrefsWidget::~KPrefsWidget() 295KPrefsWidget::~KPrefsWidget()
295{ 296{
296} 297}
297 298
298void KPrefsWidget::addWid(KPrefsWid *wid) 299void KPrefsWidget::addWid(KPrefsWid *wid)
299{ 300{
300 mPrefsWids.append(wid); 301 mPrefsWids.append(wid);
301 connect( wid, SIGNAL( modified() ), this, SLOT( modified() ) ); 302 connect( wid, SIGNAL( modified() ), this, SLOT( modified() ) );
302 303
303} 304}
304 305
305KPrefsWidBool *KPrefsWidget::addWidBool(const QString &text,bool *reference,QWidget *parent) 306KPrefsWidBool *KPrefsWidget::addWidBool(const QString &text,bool *reference,QWidget *parent)
306{ 307{
307 KPrefsWidBool *w = new KPrefsWidBool(text,reference,parent); 308 KPrefsWidBool *w = new KPrefsWidBool(text,reference,parent);
308 addWid(w); 309 addWid(w);
309 return w; 310 return w;
310} 311}
311 312
312KPrefsWidTime *KPrefsWidget::addWidTime(const QString &text,int *reference,QWidget *parent) 313KPrefsWidTime *KPrefsWidget::addWidTime(const QString &text,int *reference,QWidget *parent)
313{ 314{
314 KPrefsWidTime *w = new KPrefsWidTime(text,reference,parent); 315 KPrefsWidTime *w = new KPrefsWidTime(text,reference,parent);
315 addWid(w); 316 addWid(w);
316 return w; 317 return w;
317} 318}
318 319
319KPrefsWidColor *KPrefsWidget::addWidColor(const QString &text,QColor *reference,QWidget *parent) 320KPrefsWidColor *KPrefsWidget::addWidColor(const QString &text,QColor *reference,QWidget *parent)
320{ 321{
321 KPrefsWidColor *w = new KPrefsWidColor(text,reference,parent); 322 KPrefsWidColor *w = new KPrefsWidColor(text,reference,parent);
322 addWid(w); 323 addWid(w);
323 return w; 324 return w;
324} 325}
325 326
326KPrefsWidRadios *KPrefsWidget::addWidRadios(const QString &text,int *reference,QWidget *parent) 327KPrefsWidRadios *KPrefsWidget::addWidRadios(const QString &text,int *reference,QWidget *parent)
327{ 328{
328 KPrefsWidRadios *w = new KPrefsWidRadios(text,reference,parent); 329 KPrefsWidRadios *w = new KPrefsWidRadios(text,reference,parent);
329 addWid(w); 330 addWid(w);
330 return w; 331 return w;
331} 332}
332 333
333KPrefsWidString *KPrefsWidget::addWidString(const QString &text,QString *reference,QWidget *parent) 334KPrefsWidString *KPrefsWidget::addWidString(const QString &text,QString *reference,QWidget *parent)
334{ 335{
335 KPrefsWidString *w = new KPrefsWidString(text,reference,parent); 336 KPrefsWidString *w = new KPrefsWidString(text,reference,parent);
336 addWid(w); 337 addWid(w);
337 return w; 338 return w;
338} 339}
339 340
340KPrefsWidString *KPrefsWidget::addWidPassword(const QString &text,QString *reference,QWidget *parent) 341KPrefsWidString *KPrefsWidget::addWidPassword(const QString &text,QString *reference,QWidget *parent)
341{ 342{
342 KPrefsWidString *w = new KPrefsWidString(text,reference,parent,QLineEdit::Password); 343 KPrefsWidString *w = new KPrefsWidString(text,reference,parent,QLineEdit::Password);
343 addWid(w); 344 addWid(w);
344 return w; 345 return w;
345} 346}
346 347
347KPrefsWidFont *KPrefsWidget::addWidFont(const QString &sampleText,const QString &buttonText, 348KPrefsWidFont *KPrefsWidget::addWidFont(const QString &sampleText,const QString &buttonText,
348 QFont *reference,QWidget *parent) 349 QFont *reference,QWidget *parent)
349{ 350{
350 KPrefsWidFont *w = new KPrefsWidFont(sampleText,buttonText,reference,parent); 351 KPrefsWidFont *w = new KPrefsWidFont(sampleText,buttonText,reference,parent);
351 addWid(w); 352 addWid(w);
352 return w; 353 return w;
353} 354}
354 355
355void KPrefsWidget::setDefaults() 356void KPrefsWidget::setDefaults()
356{ 357{
357 mPrefs->setDefaults(); 358 mPrefs->setDefaults();
358 359
359 readConfig(); 360 readConfig();
360} 361}
361 362
362void KPrefsWidget::readConfig() 363void KPrefsWidget::readConfig()
363{ 364{
364// kdDebug(5300) << "KPrefsDialog::readConfig()" << endl; 365// kdDebug(5300) << "KPrefsDialog::readConfig()" << endl;
365 366
366 KPrefsWid *wid; 367 KPrefsWid *wid;
367 for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { 368 for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) {
368 wid->readConfig(); 369 wid->readConfig();
369 } 370 }
370 371
371 usrReadConfig(); 372 usrReadConfig();
372 373
373 emit changed( false ); 374 emit changed( false );
374 375
375} 376}
376 377
377void KPrefsWidget::writeConfig() 378void KPrefsWidget::writeConfig()
378{ 379{
379// kdDebug(5300) << "KPrefsDialog::writeConfig()" << endl; 380// kdDebug(5300) << "KPrefsDialog::writeConfig()" << endl;
380 381
381 KPrefsWid *wid; 382 KPrefsWid *wid;
382 for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) { 383 for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) {
383 wid->writeConfig(); 384 wid->writeConfig();
384 } 385 }
385 386
386 usrWriteConfig(); 387 usrWriteConfig();
387 388
388// kdDebug(5300) << "KPrefsDialog::writeConfig() now writing..." << endl; 389// kdDebug(5300) << "KPrefsDialog::writeConfig() now writing..." << endl;
389 390
390 mPrefs->writeConfig(); 391 mPrefs->writeConfig();
391 392
392 emit changed( false ); 393 emit changed( false );
393 394
394// kdDebug(5300) << "KPrefsDialog::writeConfig() done" << endl; 395// kdDebug(5300) << "KPrefsDialog::writeConfig() done" << endl;
395} 396}
396 397
397/*US 398/*US
398void KPrefsWidget::slotApply() 399void KPrefsWidget::slotApply()
399{ 400{
400 writeConfig(); 401 writeConfig();
401 emit configChanged(); 402 emit configChanged();
402} 403}
403 404
404void KPrefsDialog::slotOk() 405void KPrefsDialog::slotOk()
405{ 406{
406 slotApply(); 407 slotApply();
407 QDialog::accept(); 408 QDialog::accept();
408} 409}
409void KPrefsDialog::accept() 410void KPrefsDialog::accept()
410{ 411{
411 slotOk(); 412 slotOk();
412} 413}
413 414
414void KPrefsDialog::slotDefault() 415void KPrefsDialog::slotDefault()
415{ 416{
416 if (KMessageBox::warningContinueCancel(this, 417 if (KMessageBox::warningContinueCancel(this,
417 i18n("You are about to set all\npreferences to default values.\nAll " 418 i18n("You are about to set all\npreferences to default values.\nAll "
418 "custom modifications will be lost."),i18n("Setting Default Preferences"), 419 "custom modifications will be lost."),i18n("Setting Default Preferences"),
419 i18n("Continue")) 420 i18n("Continue"))
420 == KMessageBox::Continue) setDefaults(); 421 == KMessageBox::Continue) setDefaults();
421} 422}
422*/ 423*/
423 424
424void KPrefsWidget::modified() 425void KPrefsWidget::modified()
425{ 426{
426 emit changed( true ); 427 emit changed( true );
427} 428}
428 429
diff --git a/libkdepim/kprefswidget.h b/libkdepim/kprefswidget.h
index 8543a39..9de1be5 100644
--- a/libkdepim/kprefswidget.h
+++ b/libkdepim/kprefswidget.h
@@ -1,455 +1,457 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23// $Id$ 23// $Id$
24 24
25#ifndef _KPREFSWIDGET_H 25#ifndef _KPREFSWIDGET_H
26#define _KPREFSWIDGET_H 26#define _KPREFSWIDGET_H
27 27
28#include <qptrlist.h> 28#include <q3ptrlist.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31 31
32#include <qwidget.h> 32#include <qwidget.h>
33//Added by qt3to4:
34#include <QLabel>
33 35
34class KPrefs; 36class KPrefs;
35 37
36class KColorButton; 38class KColorButton;
37class QCheckBox; 39class QCheckBox;
38class QLabel; 40class QLabel;
39class QSpinBox; 41class QSpinBox;
40class QButtonGroup; 42class Q3ButtonGroup;
41 43
42/** 44/**
43 @short Base class for widgets used by @ref KPrefsDialog. 45 @short Base class for widgets used by @ref KPrefsDialog.
44 @author Cornelius Schumacher 46 @author Cornelius Schumacher
45 @see KPrefsDialog 47 @see KPrefsDialog
46 48
47 This class provides the interface for the preferences widgets used by 49 This class provides the interface for the preferences widgets used by
48 KPrefsDialog. 50 KPrefsDialog.
49*/ 51*/
50class KPrefsWid : public QObject 52class KPrefsWid : public QObject
51{ 53{
52 Q_OBJECT 54 Q_OBJECT
53 public: 55 public:
54 /** 56 /**
55 This function is called to read value of the setting from the 57 This function is called to read value of the setting from the
56 stored configuration and display it in the widget. 58 stored configuration and display it in the widget.
57 */ 59 */
58 virtual void readConfig() = 0; 60 virtual void readConfig() = 0;
59 /** 61 /**
60 This function is called to write the current setting of the widget to the 62 This function is called to write the current setting of the widget to the
61 stored configuration. 63 stored configuration.
62 */ 64 */
63 virtual void writeConfig() = 0; 65 virtual void writeConfig() = 0;
64 66
65 //connect to this signal if you want to be notified of changes 67 //connect to this signal if you want to be notified of changes
66 signals: 68 signals:
67 void modified(); 69 void modified();
68 70
69}; 71};
70 72
71/** 73/**
72 @short Widget for bool settings in @ref KPrefsDialog. 74 @short Widget for bool settings in @ref KPrefsDialog.
73 75
74 This class provides a widget for configuring bool values. It is meant to be 76 This class provides a widget for configuring bool values. It is meant to be
75 used by KPrefsDialog. The user is responsible for the layout management. 77 used by KPrefsDialog. The user is responsible for the layout management.
76*/ 78*/
77class KPrefsWidBool : public KPrefsWid 79class KPrefsWidBool : public KPrefsWid
78{ 80{
79 public: 81 public:
80 /** 82 /**
81 Create a bool widget consisting of a QCheckbox. 83 Create a bool widget consisting of a QCheckbox.
82 84
83 @param text Text of QCheckBox. 85 @param text Text of QCheckBox.
84 @param reference Pointer to variable read and written by this widget. 86 @param reference Pointer to variable read and written by this widget.
85 @param parent Parent widget. 87 @param parent Parent widget.
86 */ 88 */
87 KPrefsWidBool(const QString &text,bool *reference,QWidget *parent); 89 KPrefsWidBool(const QString &text,bool *reference,QWidget *parent);
88 90
89 /** 91 /**
90 Return the QCheckbox used by this widget. 92 Return the QCheckbox used by this widget.
91 */ 93 */
92 QCheckBox *checkBox(); 94 QCheckBox *checkBox();
93 95
94 void readConfig(); 96 void readConfig();
95 void writeConfig(); 97 void writeConfig();
96 98
97 private: 99 private:
98 bool *mReference; 100 bool *mReference;
99 101
100 QCheckBox *mCheck; 102 QCheckBox *mCheck;
101}; 103};
102 104
103/** 105/**
104 @short Widget for time settings in @ref KPrefsDialog. 106 @short Widget for time settings in @ref KPrefsDialog.
105 107
106 This class provides a widget for configuring time values. It is meant to be 108 This class provides a widget for configuring time values. It is meant to be
107 used by KPrefsDialog. The user is responsible for the layout management. 109 used by KPrefsDialog. The user is responsible for the layout management.
108*/ 110*/
109class KPrefsWidTime : public KPrefsWid 111class KPrefsWidTime : public KPrefsWid
110{ 112{
111 public: 113 public:
112 /** 114 /**
113 Create a time widget consisting of a label and a spinbox. 115 Create a time widget consisting of a label and a spinbox.
114 116
115 @param text Text of Label. 117 @param text Text of Label.
116 @param reference Pointer to variable read and written by this widget. 118 @param reference Pointer to variable read and written by this widget.
117 @param parent Parent widget. 119 @param parent Parent widget.
118 */ 120 */
119 KPrefsWidTime(const QString &text,int *reference,QWidget *parent); 121 KPrefsWidTime(const QString &text,int *reference,QWidget *parent);
120 122
121 /** 123 /**
122 Return QLabel used by this widget. 124 Return QLabel used by this widget.
123 */ 125 */
124 QLabel *label(); 126 QLabel *label();
125 /** 127 /**
126 Return QSpinBox used by this widget. 128 Return QSpinBox used by this widget.
127 */ 129 */
128 QSpinBox *spinBox(); 130 QSpinBox *spinBox();
129 131
130 void readConfig(); 132 void readConfig();
131 void writeConfig(); 133 void writeConfig();
132 134
133 private: 135 private:
134 int *mReference; 136 int *mReference;
135 137
136 QLabel *mLabel; 138 QLabel *mLabel;
137 QSpinBox *mSpin; 139 QSpinBox *mSpin;
138}; 140};
139 141
140/** 142/**
141 @short Widget for color settings in @ref KPrefsDialog. 143 @short Widget for color settings in @ref KPrefsDialog.
142 144
143 This class provides a widget for configuring color values. It is meant to be 145 This class provides a widget for configuring color values. It is meant to be
144 used by KPrefsDialog. The user is responsible for the layout management. 146 used by KPrefsDialog. The user is responsible for the layout management.
145*/ 147*/
146class KPrefsWidColor : public KPrefsWid 148class KPrefsWidColor : public KPrefsWid
147{ 149{
148 public: 150 public:
149 /** 151 /**
150 Create a color widget consisting of a test field and a button for opening 152 Create a color widget consisting of a test field and a button for opening
151 a color dialog. 153 a color dialog.
152 154
153 @param text Text of button. 155 @param text Text of button.
154 @param reference Pointer to variable read and written by this widget. 156 @param reference Pointer to variable read and written by this widget.
155 @param parent Parent widget. 157 @param parent Parent widget.
156 */ 158 */
157 KPrefsWidColor(const QString &text,QColor *reference,QWidget *parent); 159 KPrefsWidColor(const QString &text,QColor *reference,QWidget *parent);
158 /** 160 /**
159 Destruct color setting widget. 161 Destruct color setting widget.
160 */ 162 */
161 ~KPrefsWidColor(); 163 ~KPrefsWidColor();
162 164
163 /** 165 /**
164 Return QLabel for the button 166 Return QLabel for the button
165 */ 167 */
166 QLabel *label(); 168 QLabel *label();
167 /** 169 /**
168 Return button opening the color dialog. 170 Return button opening the color dialog.
169 */ 171 */
170 KColorButton *button(); 172 KColorButton *button();
171 173
172 void readConfig(); 174 void readConfig();
173 void writeConfig(); 175 void writeConfig();
174 176
175 private: 177 private:
176 QColor *mReference; 178 QColor *mReference;
177 179
178 QLabel *mLabel; 180 QLabel *mLabel;
179 KColorButton *mButton; 181 KColorButton *mButton;
180}; 182};
181 183
182/** 184/**
183 @short Widget for font settings in @ref KPrefsDialog. 185 @short Widget for font settings in @ref KPrefsDialog.
184 186
185 This class provides a widget for configuring font values. It is meant to be 187 This class provides a widget for configuring font values. It is meant to be
186 used by KPrefsDialog. The user is responsible for the layout management. 188 used by KPrefsDialog. The user is responsible for the layout management.
187*/ 189*/
188class KPrefsWidFont : public KPrefsWid 190class KPrefsWidFont : public KPrefsWid
189{ 191{
190 Q_OBJECT 192 Q_OBJECT
191 public: 193 public:
192 /** 194 /**
193 Create a font widget consisting of a test field and a button for opening 195 Create a font widget consisting of a test field and a button for opening
194 a font dialog. 196 a font dialog.
195 197
196 @param label Text of label. 198 @param label Text of label.
197 @param reference Pointer to variable read and written by this widget. 199 @param reference Pointer to variable read and written by this widget.
198 @param parent Parent widget. 200 @param parent Parent widget.
199 */ 201 */
200 KPrefsWidFont(const QString &sampleText,const QString &labelText, 202 KPrefsWidFont(const QString &sampleText,const QString &labelText,
201 QFont *reference,QWidget *parent); 203 QFont *reference,QWidget *parent);
202 /** 204 /**
203 Destruct font setting widget. 205 Destruct font setting widget.
204 */ 206 */
205 ~KPrefsWidFont(); 207 ~KPrefsWidFont();
206 208
207 /** 209 /**
208 Return label. 210 Return label.
209 */ 211 */
210 QLabel *label(); 212 QLabel *label();
211 /** 213 /**
212 Return QFrame used as preview field. 214 Return QFrame used as preview field.
213 */ 215 */
214 QLabel *preview(); 216 QLabel *preview();
215 /** 217 /**
216 Return button opening the font dialog. 218 Return button opening the font dialog.
217 */ 219 */
218 QPushButton *button(); 220 QPushButton *button();
219 221
220 void readConfig(); 222 void readConfig();
221 void writeConfig(); 223 void writeConfig();
222 224
223 protected slots: 225 protected slots:
224 void selectFont(); 226 void selectFont();
225 227
226 private: 228 private:
227 QFont *mReference; 229 QFont *mReference;
228 230
229 QLabel *mLabel; 231 QLabel *mLabel;
230 QLabel *mPreview; 232 QLabel *mPreview;
231 QPushButton *mButton; 233 QPushButton *mButton;
232}; 234};
233 235
234/** 236/**
235 @short Widget for settings represented by a group of radio buttons in 237 @short Widget for settings represented by a group of radio buttons in
236 @ref KPrefsDialog. 238 @ref KPrefsDialog.
237 239
238 This class provides a widget for configuring selections. It is meant to be 240 This class provides a widget for configuring selections. It is meant to be
239 used by KPrefsDialog. The user is responsible for the layout management. The 241 used by KPrefsDialog. The user is responsible for the layout management. The
240 setting is interpreted as an int value, corresponding to the position of the 242 setting is interpreted as an int value, corresponding to the position of the
241 radio button. The position of the button is defined by the sequence of @ref 243 radio button. The position of the button is defined by the sequence of @ref
242 addRadio() calls, starting with 0. 244 addRadio() calls, starting with 0.
243*/ 245*/
244class KPrefsWidRadios : public KPrefsWid 246class KPrefsWidRadios : public KPrefsWid
245{ 247{
246 public: 248 public:
247 /** 249 /**
248 Create a widget for selection of an option. It consists of a box with 250 Create a widget for selection of an option. It consists of a box with
249 several radio buttons. 251 several radio buttons.
250 252
251 @param text Text of main box. 253 @param text Text of main box.
252 @param reference Pointer to variable read and written by this widget. 254 @param reference Pointer to variable read and written by this widget.
253 @param parent Parent widget. 255 @param parent Parent widget.
254 */ 256 */
255 KPrefsWidRadios(const QString &text,int *reference,QWidget *parent); 257 KPrefsWidRadios(const QString &text,int *reference,QWidget *parent);
256 virtual ~KPrefsWidRadios(); 258 virtual ~KPrefsWidRadios();
257 259
258 /** 260 /**
259 Add a radio button. 261 Add a radio button.
260 262
261 @param text Text of the button. 263 @param text Text of the button.
262 */ 264 */
263 void addRadio(const QString &text); 265 void addRadio(const QString &text);
264 266
265 /** 267 /**
266 Return the box widget used by this widget. 268 Return the box widget used by this widget.
267 */ 269 */
268 QButtonGroup *groupBox(); 270 Q3ButtonGroup *groupBox();
269 271
270 void readConfig(); 272 void readConfig();
271 void writeConfig(); 273 void writeConfig();
272 274
273 private: 275 private:
274 int *mReference; 276 int *mReference;
275 277
276 QButtonGroup *mBox; 278 Q3ButtonGroup *mBox;
277}; 279};
278 280
279 281
280/** 282/**
281 @short Widget for string settings in @ref KPrefsDialog. 283 @short Widget for string settings in @ref KPrefsDialog.
282 284
283 This class provides a widget for configuring string values. It is meant to be 285 This class provides a widget for configuring string values. It is meant to be
284 used by KPrefsDialog. The user is responsible for the layout management. 286 used by KPrefsDialog. The user is responsible for the layout management.
285*/ 287*/
286class KPrefsWidString : public KPrefsWid 288class KPrefsWidString : public KPrefsWid
287{ 289{
288 public: 290 public:
289 /** 291 /**
290 Create a string widget consisting of a test label and a line edit. 292 Create a string widget consisting of a test label and a line edit.
291 293
292 @param text Text of label. 294 @param text Text of label.
293 @param reference Pointer to variable read and written by this widget. 295 @param reference Pointer to variable read and written by this widget.
294 @param parent Parent widget. 296 @param parent Parent widget.
295 */ 297 */
296 KPrefsWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal); 298 KPrefsWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal);
297 /** 299 /**
298 Destructor. 300 Destructor.
299 */ 301 */
300 virtual ~KPrefsWidString(); 302 virtual ~KPrefsWidString();
301 303
302 /** 304 /**
303 Return label used by this widget. 305 Return label used by this widget.
304 */ 306 */
305 QLabel *label(); 307 QLabel *label();
306 /** 308 /**
307 Return QLineEdit used by this widget. 309 Return QLineEdit used by this widget.
308 */ 310 */
309 QLineEdit *lineEdit(); 311 QLineEdit *lineEdit();
310 312
311 void readConfig(); 313 void readConfig();
312 void writeConfig(); 314 void writeConfig();
313 315
314 private: 316 private:
315 QString *mReference; 317 QString *mReference;
316 318
317 QLabel *mLabel; 319 QLabel *mLabel;
318 QLineEdit *mEdit; 320 QLineEdit *mEdit;
319}; 321};
320 322
321 323
322/** 324/**
323 @short Base class for a preferences widget. 325 @short Base class for a preferences widget.
324 326
325 This class provides the framework for a preferences widget. You have to 327 This class provides the framework for a preferences widget. You have to
326 subclass it and add the code to create the actual configuration widgets and 328 subclass it and add the code to create the actual configuration widgets and
327 do the layout management. 329 do the layout management.
328 330
329 KPrefsWidget provides functions to add subclasses of @ref KPrefsWid. For 331 KPrefsWidget provides functions to add subclasses of @ref KPrefsWid. For
330 these widgets the reading, writing and setting to default values is handled 332 these widgets the reading, writing and setting to default values is handled
331 automatically. Custom widgets have to be handled in the functions @ref 333 automatically. Custom widgets have to be handled in the functions @ref
332 usrReadConfig() and @ref usrWriteConfig(). 334 usrReadConfig() and @ref usrWriteConfig().
333*/ 335*/
334class KPrefsWidget : public QWidget 336class KPrefsWidget : public QWidget
335{ 337{
336 Q_OBJECT 338 Q_OBJECT
337 public: 339 public:
338 /** 340 /**
339 Create a KPrefsDialog for a KPrefs object. 341 Create a KPrefsDialog for a KPrefs object.
340 342
341 @param prefs KPrefs object used to access te configuration. 343 @param prefs KPrefs object used to access te configuration.
342 @param parent Parent widget. 344 @param parent Parent widget.
343 @param name Widget name. 345 @param name Widget name.
344 */ 346 */
345 KPrefsWidget(KPrefs *prefs,QWidget *parent=0,const char *name=0); 347 KPrefsWidget(KPrefs *prefs,QWidget *parent=0,const char *name=0);
346 /** 348 /**
347 Destructor. 349 Destructor.
348 */ 350 */
349 virtual ~KPrefsWidget(); 351 virtual ~KPrefsWidget();
350 352
351 /** 353 /**
352 Register a custom KPrefsWid object. 354 Register a custom KPrefsWid object.
353 */ 355 */
354 void addWid(KPrefsWid *); 356 void addWid(KPrefsWid *);
355 /** 357 /**
356 Register a @ref KPrefsWidBool object. 358 Register a @ref KPrefsWidBool object.
357 359
358 @param text Text of bool widget. 360 @param text Text of bool widget.
359 @param reference Reference to variable storing the setting. 361 @param reference Reference to variable storing the setting.
360 @param parent Parent widget. 362 @param parent Parent widget.
361 */ 363 */
362 KPrefsWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent); 364 KPrefsWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent);
363 /** 365 /**
364 Register a @ref KPrefsWidTime object. 366 Register a @ref KPrefsWidTime object.
365 367
366 @param text Text of time widget. 368 @param text Text of time widget.
367 @param reference Reference to variable storing the setting. 369 @param reference Reference to variable storing the setting.
368 @param parent Parent widget. 370 @param parent Parent widget.
369 */ 371 */
370 KPrefsWidTime *addWidTime(const QString &text,int *reference,QWidget *parent); 372 KPrefsWidTime *addWidTime(const QString &text,int *reference,QWidget *parent);
371 /** 373 /**
372 Register a @ref KPrefsWidColor object. 374 Register a @ref KPrefsWidColor object.
373 375
374 @param text Text of color widget. 376 @param text Text of color widget.
375 @param reference Reference to variable storing the setting. 377 @param reference Reference to variable storing the setting.
376 @param parent Parent widget. 378 @param parent Parent widget.
377 */ 379 */
378 KPrefsWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent); 380 KPrefsWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent);
379 /** 381 /**
380 Register a @ref KPrefsWidRadios object. 382 Register a @ref KPrefsWidRadios object.
381 383
382 @param text Text of radio button box widget. 384 @param text Text of radio button box widget.
383 @param reference Reference to variable storing the setting. 385 @param reference Reference to variable storing the setting.
384 @param parent Parent widget. 386 @param parent Parent widget.
385 */ 387 */
386 KPrefsWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent); 388 KPrefsWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent);
387 /** 389 /**
388 Register a @ref KPrefsWidString object. 390 Register a @ref KPrefsWidString object.
389 391
390 @param text Text of string widget. 392 @param text Text of string widget.
391 @param reference Reference to variable storing the setting. 393 @param reference Reference to variable storing the setting.
392 @param parent Parent widget. 394 @param parent Parent widget.
393 */ 395 */
394 KPrefsWidString *addWidString(const QString &text,QString *reference,QWidget *parent); 396 KPrefsWidString *addWidString(const QString &text,QString *reference,QWidget *parent);
395 /** 397 /**
396 Register a password @ref KPrefsWidString object, with echomode set to QLineEdit::Password. 398 Register a password @ref KPrefsWidString object, with echomode set to QLineEdit::Password.
397 399
398 @param text Text of string widget. 400 @param text Text of string widget.
399 @param reference Reference to variable storing the setting. 401 @param reference Reference to variable storing the setting.
400 @param parent Parent widget. 402 @param parent Parent widget.
401 */ 403 */
402 KPrefsWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent); 404 KPrefsWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent);
403 /** 405 /**
404 Register a @ref KPrefsWidFont object. 406 Register a @ref KPrefsWidFont object.
405 407
406 @param sampleText Sample text of font widget. 408 @param sampleText Sample text of font widget.
407 @param buttonText Button text of font widget. 409 @param buttonText Button text of font widget.
408 @param reference Reference to variable storing the setting. 410 @param reference Reference to variable storing the setting.
409 @param parent Parent widget. 411 @param parent Parent widget.
410 */ 412 */
411 KPrefsWidFont *addWidFont(const QString &sampleText,const QString &buttonText, 413 KPrefsWidFont *addWidFont(const QString &sampleText,const QString &buttonText,
412 QFont *reference,QWidget *parent); 414 QFont *reference,QWidget *parent);
413 415
414 public slots: 416 public slots:
415 /** Set all widgets to default values. */ 417 /** Set all widgets to default values. */
416 void setDefaults(); 418 void setDefaults();
417 419
418 /** Read preferences from config file. */ 420 /** Read preferences from config file. */
419 void readConfig(); 421 void readConfig();
420 422
421 /** Write preferences to config file. */ 423 /** Write preferences to config file. */
422 void writeConfig(); 424 void writeConfig();
423 425
424 /** connect this slot to all UI elements */ 426 /** connect this slot to all UI elements */
425 void modified(); 427 void modified();
426 428
427 signals: 429 signals:
428 /** Emitted when the a changed configuration has been stored. */ 430 /** Emitted when the a changed configuration has been stored. */
429 //US void configChanged(); 431 //US void configChanged();
430 void changed( bool ); 432 void changed( bool );
431 433
432 protected slots: 434 protected slots:
433 /** Apply changes to preferences */ 435 /** Apply changes to preferences */
434 //US void slotApply(); 436 //US void slotApply();
435 437
436 //US void accept(); 438 //US void accept();
437 /** Accept changes to preferences and close dialog */ 439 /** Accept changes to preferences and close dialog */
438 //US void slotOk(); 440 //US void slotOk();
439 441
440 /** Set preferences to default values */ 442 /** Set preferences to default values */
441 //US void slotDefault(); 443 //US void slotDefault();
442 444
443 protected: 445 protected:
444 /** Implement this to read custom configuration widgets. */ 446 /** Implement this to read custom configuration widgets. */
445 virtual void usrReadConfig() {} 447 virtual void usrReadConfig() {}
446 /** Implement this to write custom configuration widgets. */ 448 /** Implement this to write custom configuration widgets. */
447 virtual void usrWriteConfig() {} 449 virtual void usrWriteConfig() {}
448 450
449 private: 451 private:
450 KPrefs *mPrefs; 452 KPrefs *mPrefs;
451 453
452 QPtrList<KPrefsWid> mPrefsWids; 454 Q3PtrList<KPrefsWid> mPrefsWids;
453}; 455};
454 456
455#endif 457#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 5708dfc..c844627 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1883 +1,1886 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <q3progressbar.h>
39#include <qpopupmenu.h> 39#include <q3popupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <q3buttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52#include <qapplication.h> 52#include <qapplication.h>
53#include <QDesktopWidget>
54//Added by qt3to4:
55#include <Q3VBoxLayout>
53 56
54#include <klocale.h> 57#include <klocale.h>
55#include <kglobal.h> 58#include <kglobal.h>
56#include <kconfig.h> 59#include <kconfig.h>
57#include <kfiledialog.h> 60#include <kfiledialog.h>
58 61
59QDateTime KSyncManager::mRequestedSyncEvent; 62QDateTime KSyncManager::mRequestedSyncEvent;
60 63
61 64
62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 65KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, Q3PopupMenu* syncmenu)
63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) 66 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu)
64{ 67{
65 mServerSocket = 0; 68 mServerSocket = 0;
66 bar = new QProgressBar ( 1, 0 ); 69 bar = new Q3ProgressBar ( 1, 0 );
67 bar->setCaption (""); 70 bar->setCaption ("");
68 mWriteBackInPast = 2; 71 mWriteBackInPast = 2;
69 72
70 73
71} 74}
72 75
73KSyncManager::~KSyncManager() 76KSyncManager::~KSyncManager()
74{ 77{
75 delete bar; 78 delete bar;
76} 79}
77 80
78void KSyncManager::setDefaultFileName( QString s) 81void KSyncManager::setDefaultFileName( QString s)
79{ 82{
80 mDefFileName = s ; 83 mDefFileName = s ;
81 if ( mPrefs->mPassiveSyncAutoStart ) 84 if ( mPrefs->mPassiveSyncAutoStart )
82 enableQuick( false ); 85 enableQuick( false );
83} 86}
84 87
85void KSyncManager::fillSyncMenu() 88void KSyncManager::fillSyncMenu()
86{ 89{
87 if ( mSyncMenu->count() ) 90 if ( mSyncMenu->count() )
88 mSyncMenu->clear(); 91 mSyncMenu->clear();
89 92
90 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 93 mSyncMenu->insertItem( i18n("Configure..."), 0 );
91 mSyncMenu->insertSeparator(); 94 mSyncMenu->insertSeparator();
92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 95 Q3PopupMenu *clearMenu = new Q3PopupMenu ( mSyncMenu );
93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 96 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
94 clearMenu->insertItem( i18n("For all profiles"), 1 ); 97 clearMenu->insertItem( i18n("For all profiles"), 1 );
95 clearMenu->insertSeparator(); 98 clearMenu->insertSeparator();
96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 99 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
97 mSyncMenu->insertSeparator(); 100 mSyncMenu->insertSeparator();
98 if ( mServerSocket == 0 ) { 101 if ( mServerSocket == 0 ) {
99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 102 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
100 } else { 103 } else {
101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 104 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
102 } 105 }
103 mSyncMenu->insertSeparator(); 106 mSyncMenu->insertSeparator();
104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 107 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
105 mSyncMenu->insertSeparator(); 108 mSyncMenu->insertSeparator();
106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 109 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
107 config.setGroup("General"); 110 config.setGroup("General");
108 QStringList prof = config.readListEntry("SyncProfileNames"); 111 QStringList prof = config.readListEntry("SyncProfileNames");
109 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 112 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
110 if ( prof.count() < 2 ) { 113 if ( prof.count() < 2 ) {
111 prof.clear(); 114 prof.clear();
112 QString externalName; 115 QString externalName;
113#ifdef DESKTOP_VERSION 116#ifdef DESKTOP_VERSION
114#ifdef _WIN32_ 117#ifdef _WIN32_
115 externalName = "OutLook"; 118 externalName = "OutLook";
116#else 119#else
117 externalName = "KDE_Desktop"; 120 externalName = "KDE_Desktop";
118#endif 121#endif
119#else 122#else
120 externalName = "Sharp_DTM"; 123 externalName = "Sharp_DTM";
121#endif 124#endif
122 prof << externalName; 125 prof << externalName;
123 prof << i18n("Local_file"); 126 prof << i18n("Local_file");
124 prof << i18n("Last_file"); 127 prof << i18n("Last_file");
125 KSyncProfile* temp = new KSyncProfile (); 128 KSyncProfile* temp = new KSyncProfile ();
126 temp->setName( prof[0] ); 129 temp->setName( prof[0] );
127 temp->writeConfig(&config); 130 temp->writeConfig(&config);
128 temp->setName( prof[1] ); 131 temp->setName( prof[1] );
129 temp->writeConfig(&config); 132 temp->writeConfig(&config);
130 temp->setName( prof[2] ); 133 temp->setName( prof[2] );
131 temp->writeConfig(&config); 134 temp->writeConfig(&config);
132 config.setGroup("General"); 135 config.setGroup("General");
133 config.writeEntry("SyncProfileNames",prof); 136 config.writeEntry("SyncProfileNames",prof);
134 config.writeEntry("ExternSyncProfiles",externalName); 137 config.writeEntry("ExternSyncProfiles",externalName);
135 config.sync(); 138 config.sync();
136 delete temp; 139 delete temp;
137 } 140 }
138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 141 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
139 mSyncProfileNames = prof; 142 mSyncProfileNames = prof;
140 unsigned int i; 143 unsigned int i;
141 for ( i = 0; i < prof.count(); ++i ) { 144 for ( i = 0; i < prof.count(); ++i ) {
142 QString insertText = prof[i]; 145 QString insertText = prof[i];
143 if ( i == 0 ) { 146 if ( i == 0 ) {
144#ifdef DESKTOP_VERSION 147#ifdef DESKTOP_VERSION
145#ifdef _WIN32_ 148#ifdef _WIN32_
146 insertText = "OutLook"; 149 insertText = "OutLook";
147#else 150#else
148 insertText = "KDE_Desktop"; 151 insertText = "KDE_Desktop";
149#endif 152#endif
150#else 153#else
151 insertText = "Sharp_DTM"; 154 insertText = "Sharp_DTM";
152#endif 155#endif
153 } 156 }
154 mSyncMenu->insertItem( insertText, 1000+i ); 157 mSyncMenu->insertItem( insertText, 1000+i );
155 clearMenu->insertItem( insertText, 1000+i ); 158 clearMenu->insertItem( insertText, 1000+i );
156 if ( i == 2 ) 159 if ( i == 2 )
157 mSyncMenu->insertSeparator(); 160 mSyncMenu->insertSeparator();
158 } 161 }
159 QDir app_dir; 162 QDir app_dir;
160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 163 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
161 if ( mTargetApp == PWMPI) { 164 if ( mTargetApp == PWMPI) {
162 mSyncMenu->removeItem( 1000 ); 165 mSyncMenu->removeItem( 1000 );
163 clearMenu->removeItem( 1000 ); 166 clearMenu->removeItem( 1000 );
164 } 167 }
165#ifndef DESKTOP_VERSION 168#ifndef DESKTOP_VERSION
166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 169 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
167 mSyncMenu->removeItem( 1000 ); 170 mSyncMenu->removeItem( 1000 );
168 clearMenu->removeItem( 1000 ); 171 clearMenu->removeItem( 1000 );
169 } 172 }
170#endif 173#endif
171 mSyncMenu->removeItem( 1002 ); 174 mSyncMenu->removeItem( 1002 );
172 clearMenu->removeItem( 1002 ); 175 clearMenu->removeItem( 1002 );
173} 176}
174void KSyncManager::slotClearMenu( int action ) 177void KSyncManager::slotClearMenu( int action )
175{ 178{
176 QString syncDevice; 179 QString syncDevice;
177 if ( action > 999 ) { 180 if ( action > 999 ) {
178 syncDevice = mSyncProfileNames[action - 1000] ; 181 syncDevice = mSyncProfileNames[action - 1000] ;
179 } 182 }
180 183
181 184
182 185
183 int result = 0; 186 int result = 0;
184 QString sd; 187 QString sd;
185 if ( syncDevice.isEmpty() ) 188 if ( syncDevice.isEmpty() )
186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 189 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
187 else 190 else
188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 191 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
189 192
190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 193 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
191 0, 1 ); 194 0, 1 );
192 if ( result ) 195 if ( result )
193 return; 196 return;
194 mImplementation->removeSyncInfo( syncDevice ); 197 mImplementation->removeSyncInfo( syncDevice );
195} 198}
196void KSyncManager::slotSyncMenu( int action ) 199void KSyncManager::slotSyncMenu( int action )
197{ 200{
198 qDebug("KSM::syncaction %d ", action); 201 qDebug("KSM::syncaction %d ", action);
199 mCurrentResourceLocal = ""; 202 mCurrentResourceLocal = "";
200 emit multiResourceSyncStart( false ); 203 emit multiResourceSyncStart( false );
201 if ( action == 5000 ) 204 if ( action == 5000 )
202 return; 205 return;
203 mSyncWithDesktop = false; 206 mSyncWithDesktop = false;
204 if ( action == 0 ) { 207 if ( action == 0 ) {
205 208
206 // seems to be a Qt2 event handling bug 209 // seems to be a Qt2 event handling bug
207 // syncmenu.clear causes a segfault at first time 210 // syncmenu.clear causes a segfault at first time
208 // when we call it after the main event loop, it is ok 211 // when we call it after the main event loop, it is ok
209 // same behaviour when calling OM/Pi via QCOP for the first time 212 // same behaviour when calling OM/Pi via QCOP for the first time
210 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 213 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
211 //confSync(); 214 //confSync();
212 215
213 return; 216 return;
214 } 217 }
215 if ( action == 1 ) { 218 if ( action == 1 ) {
216 multiSync( true ); 219 multiSync( true );
217 return; 220 return;
218 } 221 }
219 if ( action == 2 ) { 222 if ( action == 2 ) {
220 enableQuick(); 223 enableQuick();
221 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 224 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
222 return; 225 return;
223 } 226 }
224 if ( action == 3 ) { 227 if ( action == 3 ) {
225 delete mServerSocket; 228 delete mServerSocket;
226 mServerSocket = 0; 229 mServerSocket = 0;
227 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 230 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
228 return; 231 return;
229 } 232 }
230 233
231 if (blockSave()) 234 if (blockSave())
232 return; 235 return;
233 236
234 setBlockSave(true); 237 setBlockSave(true);
235 bool silent = false; 238 bool silent = false;
236 if ( action == 999 ) { 239 if ( action == 999 ) {
237 //special mode for silent syncing 240 //special mode for silent syncing
238 action = 1000; 241 action = 1000;
239 silent = true; 242 silent = true;
240 } 243 }
241 244
242 mCurrentSyncProfile = action - 1000 ; 245 mCurrentSyncProfile = action - 1000 ;
243 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 246 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
244 mCurrentSyncName = mLocalMachineName ; 247 mCurrentSyncName = mLocalMachineName ;
245 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 248 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
246 KSyncProfile* temp = new KSyncProfile (); 249 KSyncProfile* temp = new KSyncProfile ();
247 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 250 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
248 temp->readConfig(&config); 251 temp->readConfig(&config);
249 if (silent) { 252 if (silent) {
250 mAskForPreferences = false; 253 mAskForPreferences = false;
251 mShowSyncSummary = false; 254 mShowSyncSummary = false;
252 mWriteBackFile = true; 255 mWriteBackFile = true;
253 mSyncAlgoPrefs = 2;// take newest 256 mSyncAlgoPrefs = 2;// take newest
254 } 257 }
255 else { 258 else {
256 mAskForPreferences = temp->getAskForPreferences(); 259 mAskForPreferences = temp->getAskForPreferences();
257 mShowSyncSummary = temp->getShowSummaryAfterSync(); 260 mShowSyncSummary = temp->getShowSummaryAfterSync();
258 mWriteBackFile = temp->getWriteBackFile(); 261 mWriteBackFile = temp->getWriteBackFile();
259 mSyncAlgoPrefs = temp->getSyncPrefs(); 262 mSyncAlgoPrefs = temp->getSyncPrefs();
260 } 263 }
261 mWriteBackExistingOnly = temp->getWriteBackExisting(); 264 mWriteBackExistingOnly = temp->getWriteBackExisting();
262 mIsKapiFile = temp->getIsKapiFile(); 265 mIsKapiFile = temp->getIsKapiFile();
263 mWriteBackInFuture = 0; 266 mWriteBackInFuture = 0;
264 if ( temp->getWriteBackFuture() ) { 267 if ( temp->getWriteBackFuture() ) {
265 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 268 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
266 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 269 mWriteBackInPast = temp->getWriteBackPastWeeks( );
267 } 270 }
268 mFilterInCal = temp->getFilterInCal(); 271 mFilterInCal = temp->getFilterInCal();
269 mFilterOutCal = temp->getFilterOutCal(); 272 mFilterOutCal = temp->getFilterOutCal();
270 mFilterInAB = temp->getFilterInAB(); 273 mFilterInAB = temp->getFilterInAB();
271 mFilterOutAB = temp->getFilterOutAB(); 274 mFilterOutAB = temp->getFilterOutAB();
272 275
273 if ( action == 1000 ) { 276 if ( action == 1000 ) {
274 mIsKapiFile = false; 277 mIsKapiFile = false;
275#ifdef DESKTOP_VERSION 278#ifdef DESKTOP_VERSION
276 syncKDE(); 279 syncKDE();
277#else 280#else
278 syncSharp(); 281 syncSharp();
279#endif 282#endif
280 283
281 } else if ( action == 1001 ) { 284 } else if ( action == 1001 ) {
282 syncLocalFile(); 285 syncLocalFile();
283 286
284 } else if ( action == 1002 ) { 287 } else if ( action == 1002 ) {
285 mWriteBackFile = false; 288 mWriteBackFile = false;
286 mAskForPreferences = false; 289 mAskForPreferences = false;
287 mShowSyncSummary = false; 290 mShowSyncSummary = false;
288 mSyncAlgoPrefs = 3; 291 mSyncAlgoPrefs = 3;
289 quickSyncLocalFile(); 292 quickSyncLocalFile();
290 293
291 } else if ( action >= 1003 ) { 294 } else if ( action >= 1003 ) {
292 if ( temp->getIsLocalFileSync() ) { 295 if ( temp->getIsLocalFileSync() ) {
293 switch(mTargetApp) 296 switch(mTargetApp)
294 { 297 {
295 case (KAPI): 298 case (KAPI):
296 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 299 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
297 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 300 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
298 break; 301 break;
299 case (KOPI): 302 case (KOPI):
300 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 303 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
301 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 304 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
302 break; 305 break;
303 case (PWMPI): 306 case (PWMPI):
304 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 307 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
305 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 308 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
306 break; 309 break;
307 default: 310 default:
308 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 311 qDebug("KSM::slotSyncMenu: invalid apptype selected");
309 break; 312 break;
310 313
311 } 314 }
312 } else { 315 } else {
313 if ( temp->getIsPhoneSync() ) { 316 if ( temp->getIsPhoneSync() ) {
314 mPhoneDevice = temp->getPhoneDevice( ) ; 317 mPhoneDevice = temp->getPhoneDevice( ) ;
315 mPhoneConnection = temp->getPhoneConnection( ); 318 mPhoneConnection = temp->getPhoneConnection( );
316 mPhoneModel = temp->getPhoneModel( ); 319 mPhoneModel = temp->getPhoneModel( );
317 syncPhone(); 320 syncPhone();
318 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { 321 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
319 mSpecificResources.clear(); 322 mSpecificResources.clear();
320 if ( mTargetApp == KAPI ) { 323 if ( mTargetApp == KAPI ) {
321 if ( temp->getIsPiSyncSpec() ) 324 if ( temp->getIsPiSyncSpec() )
322 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); 325 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true );
323 mPassWordPiSync = temp->getRemotePwAB(); 326 mPassWordPiSync = temp->getRemotePwAB();
324 mActiveSyncPort = temp->getRemotePortAB(); 327 mActiveSyncPort = temp->getRemotePortAB();
325 mActiveSyncIP = temp->getRemoteIPAB(); 328 mActiveSyncIP = temp->getRemoteIPAB();
326 } else if ( mTargetApp == KOPI ) { 329 } else if ( mTargetApp == KOPI ) {
327 if ( temp->getIsPiSyncSpec() ) 330 if ( temp->getIsPiSyncSpec() )
328 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); 331 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true );
329 mPassWordPiSync = temp->getRemotePw(); 332 mPassWordPiSync = temp->getRemotePw();
330 mActiveSyncPort = temp->getRemotePort(); 333 mActiveSyncPort = temp->getRemotePort();
331 mActiveSyncIP = temp->getRemoteIP(); 334 mActiveSyncIP = temp->getRemoteIP();
332 } else { 335 } else {
333 mPassWordPiSync = temp->getRemotePwPWM(); 336 mPassWordPiSync = temp->getRemotePwPWM();
334 mActiveSyncPort = temp->getRemotePortPWM(); 337 mActiveSyncPort = temp->getRemotePortPWM();
335 mActiveSyncIP = temp->getRemoteIPPWM(); 338 mActiveSyncIP = temp->getRemoteIPPWM();
336 } 339 }
337 syncPi(); 340 syncPi();
338 while ( !mPisyncFinished ) { 341 while ( !mPisyncFinished ) {
339 //qDebug("waiting "); 342 //qDebug("waiting ");
340 qApp->processEvents(); 343 qApp->processEvents();
341 } 344 }
342 } else 345 } else
343 syncRemote( temp ); 346 syncRemote( temp );
344 347
345 } 348 }
346 } 349 }
347 delete temp; 350 delete temp;
348 setBlockSave(false); 351 setBlockSave(false);
349} 352}
350 353
351void KSyncManager::enableQuick( bool ask ) 354void KSyncManager::enableQuick( bool ask )
352{ 355{
353 bool autoStart; 356 bool autoStart;
354 bool changed = false; 357 bool changed = false;
355 if ( ask ) { 358 if ( ask ) {
356 QDialog dia ( 0, "input-dialog", true ); 359 QDialog dia ( 0, "input-dialog", true );
357 QLineEdit lab ( &dia ); 360 QLineEdit lab ( &dia );
358 QVBoxLayout lay( &dia ); 361 Q3VBoxLayout lay( &dia );
359 lab.setText( mPrefs->mPassiveSyncPort ); 362 lab.setText( mPrefs->mPassiveSyncPort );
360 lay.setMargin(7); 363 lay.setMargin(7);
361 lay.setSpacing(7); 364 lay.setSpacing(7);
362 int po = 9197+mTargetApp; 365 int po = 9197+mTargetApp;
363 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); 366 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia );
364 lay.addWidget( &label); 367 lay.addWidget( &label);
365 lay.addWidget( &lab); 368 lay.addWidget( &lab);
366 369
367 QLineEdit lepw ( &dia ); 370 QLineEdit lepw ( &dia );
368 lepw.setText( mPrefs->mPassiveSyncPw ); 371 lepw.setText( mPrefs->mPassiveSyncPw );
369 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 372 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
370 lay.addWidget( &label2); 373 lay.addWidget( &label2);
371 lay.addWidget( &lepw); 374 lay.addWidget( &lepw);
372 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 375 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
373 lay.addWidget( &autostart); 376 lay.addWidget( &autostart);
374 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 377 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
375#ifdef DESKTOP_VERSION 378#ifdef DESKTOP_VERSION
376#ifdef _WIN32_ 379#ifdef _WIN32_
377 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 380 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
378 syncdesktop.hide();// not implemented! 381 syncdesktop.hide();// not implemented!
379#else 382#else
380 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 383 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
381#endif 384#endif
382 lay.addWidget( &syncdesktop); 385 lay.addWidget( &syncdesktop);
383#else 386#else
384 mPrefs->mPassiveSyncWithDesktop = false; 387 mPrefs->mPassiveSyncWithDesktop = false;
385 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 388 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
386 syncdesktop.hide(); 389 syncdesktop.hide();
387#endif 390#endif
388 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 391 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
389 392
390 QPushButton pb ( "OK", &dia); 393 QPushButton pb ( "OK", &dia);
391 lay.addWidget( &pb ); 394 lay.addWidget( &pb );
392 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 395 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
393 dia.resize( 230,120 ); 396 dia.resize( 230,120 );
394 dia.setCaption( i18n("Enter port for Pi-Sync") ); 397 dia.setCaption( i18n("Enter port for Pi-Sync") );
395 dia.show(); 398 dia.show();
396#ifndef DESKTOP_VERSION 399#ifndef DESKTOP_VERSION
397 int dw = QApplication::desktop()->width(); 400 int dw = QApplication::desktop()->width();
398 int dh = QApplication::desktop()->height(); 401 int dh = QApplication::desktop()->height();
399 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); 402 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
400#endif 403#endif
401 if ( ! dia.exec() ) 404 if ( ! dia.exec() )
402 return; 405 return;
403 dia.hide(); 406 dia.hide();
404 qApp->processEvents(); 407 qApp->processEvents();
405 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 408 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
406 changed = true; 409 changed = true;
407 mPrefs->mPassiveSyncPw = lepw.text(); 410 mPrefs->mPassiveSyncPw = lepw.text();
408 } 411 }
409 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 412 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
410 mPrefs->mPassiveSyncPort = lab.text(); 413 mPrefs->mPassiveSyncPort = lab.text();
411 changed = true; 414 changed = true;
412 } 415 }
413 autoStart = autostart.isChecked(); 416 autoStart = autostart.isChecked();
414 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 417 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
415 changed = true; 418 changed = true;
416 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 419 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
417 } 420 }
418 } 421 }
419 else 422 else
420 autoStart = mPrefs->mPassiveSyncAutoStart; 423 autoStart = mPrefs->mPassiveSyncAutoStart;
421 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 424 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
422 changed = true; 425 changed = true;
423 bool ok; 426 bool ok;
424 mPrefs->mPassiveSyncAutoStart = false; 427 mPrefs->mPassiveSyncAutoStart = false;
425 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); 428 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok);
426 if ( ! ok || port_t > 65535 ) { 429 if ( ! ok || port_t > 65535 ) {
427 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); 430 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error"));
428 return; 431 return;
429 } 432 }
430 Q_UINT16 port = port_t; 433 Q_UINT16 port = port_t;
431 //qDebug("port %d ", port); 434 //qDebug("port %d ", port);
432 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 435 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
433 mServerSocket->setFileName( defaultFileName() );//bbb 436 mServerSocket->setFileName( defaultFileName() );//bbb
434 if ( !mServerSocket->ok() ) { 437 if ( !mServerSocket->ok() ) {
435 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); 438 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) );
436 delete mServerSocket; 439 delete mServerSocket;
437 mServerSocket = 0; 440 mServerSocket = 0;
438 return; 441 return;
439 } 442 }
440 mPrefs->mPassiveSyncAutoStart = autoStart; 443 mPrefs->mPassiveSyncAutoStart = autoStart;
441 if ( changed ) { 444 if ( changed ) {
442 mPrefs->writeConfig(); 445 mPrefs->writeConfig();
443 } 446 }
444 //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 447 //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
445 //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 448 //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
446 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); 449 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) );
447 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); 450 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) );
448} 451}
449void KSyncManager::displayErrorPort() 452void KSyncManager::displayErrorPort()
450{ 453{
451 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); 454 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error"));
452} 455}
453void KSyncManager::syncLocalFile() 456void KSyncManager::syncLocalFile()
454{ 457{
455 458
456 QString fn =mPrefs->mLastSyncedLocalFile; 459 QString fn =mPrefs->mLastSyncedLocalFile;
457 QString ext; 460 QString ext;
458 461
459 switch(mTargetApp) 462 switch(mTargetApp)
460 { 463 {
461 case (KAPI): 464 case (KAPI):
462 ext = "(*.vcf)"; 465 ext = "(*.vcf)";
463 break; 466 break;
464 case (KOPI): 467 case (KOPI):
465 ext = "(*.ics/*.vcs)"; 468 ext = "(*.ics/*.vcs)";
466 break; 469 break;
467 case (PWMPI): 470 case (PWMPI):
468 ext = "(*.pwm)"; 471 ext = "(*.pwm)";
469 break; 472 break;
470 default: 473 default:
471 qDebug("KSM::syncLocalFile: invalid apptype selected"); 474 qDebug("KSM::syncLocalFile: invalid apptype selected");
472 break; 475 break;
473 476
474 } 477 }
475 478
476 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 479 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
477 if ( fn == "" ) 480 if ( fn == "" )
478 return; 481 return;
479 if ( syncWithFile( fn, false ) ) { 482 if ( syncWithFile( fn, false ) ) {
480 qDebug("KSM::syncLocalFile() successful "); 483 qDebug("KSM::syncLocalFile() successful ");
481 } 484 }
482 485
483} 486}
484 487
485bool KSyncManager::syncWithFile( QString fn , bool quick ) 488bool KSyncManager::syncWithFile( QString fn , bool quick )
486{ 489{
487 bool ret = false; 490 bool ret = false;
488 QFileInfo info; 491 QFileInfo info;
489 info.setFile( fn ); 492 info.setFile( fn );
490 QString mess; 493 QString mess;
491 if ( !info. exists() ) { 494 if ( !info. exists() ) {
492 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 495 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
493 QMessageBox::warning( mParent, i18n("Warning!"), 496 QMessageBox::warning( mParent, i18n("Warning!"),
494 mess ); 497 mess );
495 return ret; 498 return ret;
496 } 499 }
497 int result = 0; 500 int result = 0;
498 if ( !quick ) { 501 if ( !quick ) {
499 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 502 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
500 result = QMessageBox::warning( mParent, i18n("Warning!"), 503 result = QMessageBox::warning( mParent, i18n("Warning!"),
501 mess, 504 mess,
502 i18n("Sync"), i18n("Cancel"), 0, 505 i18n("Sync"), i18n("Cancel"), 0,
503 0, 1 ); 506 0, 1 );
504 if ( result ) 507 if ( result )
505 return false; 508 return false;
506 } 509 }
507 if ( mAskForPreferences ) 510 if ( mAskForPreferences )
508 if ( !edit_sync_options()) { 511 if ( !edit_sync_options()) {
509 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 512 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
510 return false; 513 return false;
511 } 514 }
512 if ( result == 0 ) { 515 if ( result == 0 ) {
513 //qDebug("Now sycing ... "); 516 //qDebug("Now sycing ... ");
514 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) 517 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
515 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 518 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
516 else 519 else
517 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 520 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
518 if ( ! quick ) 521 if ( ! quick )
519 mPrefs->mLastSyncedLocalFile = fn; 522 mPrefs->mLastSyncedLocalFile = fn;
520 } 523 }
521 return ret; 524 return ret;
522} 525}
523 526
524void KSyncManager::quickSyncLocalFile() 527void KSyncManager::quickSyncLocalFile()
525{ 528{
526 529
527 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 530 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
528 qDebug("KSM::quick syncLocalFile() successful "); 531 qDebug("KSM::quick syncLocalFile() successful ");
529 532
530 } 533 }
531} 534}
532 535
533void KSyncManager::multiSync( bool askforPrefs ) 536void KSyncManager::multiSync( bool askforPrefs )
534{ 537{
535 if (blockSave()) 538 if (blockSave())
536 return; 539 return;
537 setBlockSave(true); 540 setBlockSave(true);
538 mCurrentResourceLocal = ""; 541 mCurrentResourceLocal = "";
539 if ( askforPrefs ) { 542 if ( askforPrefs ) {
540 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 543 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
541 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 544 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
542 question, 545 question,
543 i18n("Yes"), i18n("No"), 546 i18n("Yes"), i18n("No"),
544 0, 0 ) != 0 ) { 547 0, 0 ) != 0 ) {
545 setBlockSave(false); 548 setBlockSave(false);
546 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 549 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
547 return; 550 return;
548 } 551 }
549 } 552 }
550 mCurrentSyncDevice = i18n("Multiple profiles") ; 553 mCurrentSyncDevice = i18n("Multiple profiles") ;
551 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 554 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
552 if ( askforPrefs ) { 555 if ( askforPrefs ) {
553 if ( !edit_sync_options()) { 556 if ( !edit_sync_options()) {
554 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 557 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
555 return; 558 return;
556 } 559 }
557 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 560 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
558 } 561 }
559 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 562 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
560 qApp->processEvents(); 563 qApp->processEvents();
561 int num = ringSync() ; 564 int num = ringSync() ;
562 if ( num > 1 ) 565 if ( num > 1 )
563 ringSync(); 566 ringSync();
564 setBlockSave(false); 567 setBlockSave(false);
565 if ( num ) 568 if ( num )
566 emit save(); 569 emit save();
567 if ( num ) 570 if ( num )
568 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 571 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
569 else 572 else
570 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 573 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
571 return; 574 return;
572} 575}
573 576
574int KSyncManager::ringSync() 577int KSyncManager::ringSync()
575{ 578{
576 emit multiResourceSyncStart( false ); 579 emit multiResourceSyncStart( false );
577 int syncedProfiles = 0; 580 int syncedProfiles = 0;
578 unsigned int i; 581 unsigned int i;
579 QTime timer; 582 QTime timer;
580 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 583 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
581 QStringList syncProfileNames = mSyncProfileNames; 584 QStringList syncProfileNames = mSyncProfileNames;
582 KSyncProfile* temp = new KSyncProfile (); 585 KSyncProfile* temp = new KSyncProfile ();
583 mAskForPreferences = false; 586 mAskForPreferences = false;
584 mCurrentResourceLocal = ""; 587 mCurrentResourceLocal = "";
585 for ( i = 0; i < syncProfileNames.count(); ++i ) { 588 for ( i = 0; i < syncProfileNames.count(); ++i ) {
586 mCurrentSyncProfile = i; 589 mCurrentSyncProfile = i;
587 temp->setName(syncProfileNames[mCurrentSyncProfile]); 590 temp->setName(syncProfileNames[mCurrentSyncProfile]);
588 temp->readConfig(&config); 591 temp->readConfig(&config);
589 592
590 bool includeInRingSync = false; 593 bool includeInRingSync = false;
591 switch(mTargetApp) 594 switch(mTargetApp)
592 { 595 {
593 case (KAPI): 596 case (KAPI):
594 includeInRingSync = temp->getIncludeInRingSyncAB(); 597 includeInRingSync = temp->getIncludeInRingSyncAB();
595 break; 598 break;
596 case (KOPI): 599 case (KOPI):
597 includeInRingSync = temp->getIncludeInRingSync(); 600 includeInRingSync = temp->getIncludeInRingSync();
598 break; 601 break;
599 case (PWMPI): 602 case (PWMPI):
600 includeInRingSync = temp->getIncludeInRingSyncPWM(); 603 includeInRingSync = temp->getIncludeInRingSyncPWM();
601 break; 604 break;
602 default: 605 default:
603 qDebug("KSM::ringSync: invalid apptype selected"); 606 qDebug("KSM::ringSync: invalid apptype selected");
604 break; 607 break;
605 608
606 } 609 }
607 610
608 611
609 if ( includeInRingSync && ( i < 1 || i > 2 )) { 612 if ( includeInRingSync && ( i < 1 || i > 2 )) {
610 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 613 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
611 ++syncedProfiles; 614 ++syncedProfiles;
612 mSyncWithDesktop = false; 615 mSyncWithDesktop = false;
613 // mAskForPreferences = temp->getAskForPreferences(); 616 // mAskForPreferences = temp->getAskForPreferences();
614 mWriteBackFile = temp->getWriteBackFile(); 617 mWriteBackFile = temp->getWriteBackFile();
615 mWriteBackExistingOnly = temp->getWriteBackExisting(); 618 mWriteBackExistingOnly = temp->getWriteBackExisting();
616 mIsKapiFile = temp->getIsKapiFile(); 619 mIsKapiFile = temp->getIsKapiFile();
617 mWriteBackInFuture = 0; 620 mWriteBackInFuture = 0;
618 if ( temp->getWriteBackFuture() ) { 621 if ( temp->getWriteBackFuture() ) {
619 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 622 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
620 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 623 mWriteBackInPast = temp->getWriteBackPastWeeks( );
621 } 624 }
622 mFilterInCal = temp->getFilterInCal(); 625 mFilterInCal = temp->getFilterInCal();
623 mFilterOutCal = temp->getFilterOutCal(); 626 mFilterOutCal = temp->getFilterOutCal();
624 mFilterInAB = temp->getFilterInAB(); 627 mFilterInAB = temp->getFilterInAB();
625 mFilterOutAB = temp->getFilterOutAB(); 628 mFilterOutAB = temp->getFilterOutAB();
626 mShowSyncSummary = false; 629 mShowSyncSummary = false;
627 mCurrentSyncDevice = syncProfileNames[i] ; 630 mCurrentSyncDevice = syncProfileNames[i] ;
628 mCurrentSyncName = mLocalMachineName; 631 mCurrentSyncName = mLocalMachineName;
629 if ( i == 0 ) { 632 if ( i == 0 ) {
630 mIsKapiFile = false; 633 mIsKapiFile = false;
631#ifdef DESKTOP_VERSION 634#ifdef DESKTOP_VERSION
632 syncKDE(); 635 syncKDE();
633#else 636#else
634 syncSharp(); 637 syncSharp();
635#endif 638#endif
636 } else { 639 } else {
637 if ( temp->getIsLocalFileSync() ) { 640 if ( temp->getIsLocalFileSync() ) {
638 switch(mTargetApp) 641 switch(mTargetApp)
639 { 642 {
640 case (KAPI): 643 case (KAPI):
641 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 644 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
642 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 645 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
643 break; 646 break;
644 case (KOPI): 647 case (KOPI):
645 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 648 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
646 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 649 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
647 break; 650 break;
648 case (PWMPI): 651 case (PWMPI):
649 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 652 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
650 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 653 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
651 break; 654 break;
652 default: 655 default:
653 qDebug("KSM: invalid apptype selected"); 656 qDebug("KSM: invalid apptype selected");
654 break; 657 break;
655 } 658 }
656 } else { 659 } else {
657 if ( temp->getIsPhoneSync() ) { 660 if ( temp->getIsPhoneSync() ) {
658 mPhoneDevice = temp->getPhoneDevice( ) ; 661 mPhoneDevice = temp->getPhoneDevice( ) ;
659 mPhoneConnection = temp->getPhoneConnection( ); 662 mPhoneConnection = temp->getPhoneConnection( );
660 mPhoneModel = temp->getPhoneModel( ); 663 mPhoneModel = temp->getPhoneModel( );
661 syncPhone(); 664 syncPhone();
662 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { 665 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
663 mSpecificResources.clear(); 666 mSpecificResources.clear();
664 if ( mTargetApp == KAPI ) { 667 if ( mTargetApp == KAPI ) {
665 if ( temp->getIsPiSyncSpec() ) 668 if ( temp->getIsPiSyncSpec() )
666 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); 669 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true );
667 mPassWordPiSync = temp->getRemotePwAB(); 670 mPassWordPiSync = temp->getRemotePwAB();
668 mActiveSyncPort = temp->getRemotePortAB(); 671 mActiveSyncPort = temp->getRemotePortAB();
669 mActiveSyncIP = temp->getRemoteIPAB(); 672 mActiveSyncIP = temp->getRemoteIPAB();
670 } else if ( mTargetApp == KOPI ) { 673 } else if ( mTargetApp == KOPI ) {
671 if ( temp->getIsPiSyncSpec() ) 674 if ( temp->getIsPiSyncSpec() )
672 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); 675 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true );
673 mPassWordPiSync = temp->getRemotePw(); 676 mPassWordPiSync = temp->getRemotePw();
674 mActiveSyncPort = temp->getRemotePort(); 677 mActiveSyncPort = temp->getRemotePort();
675 mActiveSyncIP = temp->getRemoteIP(); 678 mActiveSyncIP = temp->getRemoteIP();
676 } else { 679 } else {
677 mPassWordPiSync = temp->getRemotePwPWM(); 680 mPassWordPiSync = temp->getRemotePwPWM();
678 mActiveSyncPort = temp->getRemotePortPWM(); 681 mActiveSyncPort = temp->getRemotePortPWM();
679 mActiveSyncIP = temp->getRemoteIPPWM(); 682 mActiveSyncIP = temp->getRemoteIPPWM();
680 } 683 }
681 syncPi(); 684 syncPi();
682 while ( !mPisyncFinished ) { 685 while ( !mPisyncFinished ) {
683 //qDebug("waiting "); 686 //qDebug("waiting ");
684 qApp->processEvents(); 687 qApp->processEvents();
685 } 688 }
686 timer.start(); 689 timer.start();
687 while ( timer.elapsed () < 2000 ) { 690 while ( timer.elapsed () < 2000 ) {
688 qApp->processEvents(); 691 qApp->processEvents();
689 } 692 }
690 } else 693 } else
691 syncRemote( temp, false ); 694 syncRemote( temp, false );
692 695
693 } 696 }
694 } 697 }
695 timer.start(); 698 timer.start();
696 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 699 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
697 while ( timer.elapsed () < 2000 ) { 700 while ( timer.elapsed () < 2000 ) {
698 qApp->processEvents(); 701 qApp->processEvents();
699#ifndef _WIN32_ 702#ifndef _WIN32_
700 sleep (1); 703 sleep (1);
701#endif 704#endif
702 } 705 }
703 706
704 } 707 }
705 708
706 } 709 }
707 delete temp; 710 delete temp;
708 return syncedProfiles; 711 return syncedProfiles;
709} 712}
710 713
711void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 714void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
712{ 715{
713 QString question; 716 QString question;
714 if ( ask ) { 717 if ( ask ) {
715 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 718 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
716 if ( QMessageBox::information( mParent, i18n("Sync"), 719 if ( QMessageBox::information( mParent, i18n("Sync"),
717 question, 720 question,
718 i18n("Yes"), i18n("No"), 721 i18n("Yes"), i18n("No"),
719 0, 0 ) != 0 ) 722 0, 0 ) != 0 )
720 return; 723 return;
721 } 724 }
722 725
723 QString preCommand; 726 QString preCommand;
724 QString localTempFile; 727 QString localTempFile;
725 QString postCommand; 728 QString postCommand;
726 729
727 switch(mTargetApp) 730 switch(mTargetApp)
728 { 731 {
729 case (KAPI): 732 case (KAPI):
730 preCommand = prof->getPreSyncCommandAB(); 733 preCommand = prof->getPreSyncCommandAB();
731 postCommand = prof->getPostSyncCommandAB(); 734 postCommand = prof->getPostSyncCommandAB();
732 localTempFile = prof->getLocalTempFileAB(); 735 localTempFile = prof->getLocalTempFileAB();
733 break; 736 break;
734 case (KOPI): 737 case (KOPI):
735 preCommand = prof->getPreSyncCommand(); 738 preCommand = prof->getPreSyncCommand();
736 postCommand = prof->getPostSyncCommand(); 739 postCommand = prof->getPostSyncCommand();
737 localTempFile = prof->getLocalTempFile(); 740 localTempFile = prof->getLocalTempFile();
738 break; 741 break;
739 case (PWMPI): 742 case (PWMPI):
740 preCommand = prof->getPreSyncCommandPWM(); 743 preCommand = prof->getPreSyncCommandPWM();
741 postCommand = prof->getPostSyncCommandPWM(); 744 postCommand = prof->getPostSyncCommandPWM();
742 localTempFile = prof->getLocalTempFilePWM(); 745 localTempFile = prof->getLocalTempFilePWM();
743 break; 746 break;
744 default: 747 default:
745 qDebug("KSM::syncRemote: invalid apptype selected"); 748 qDebug("KSM::syncRemote: invalid apptype selected");
746 break; 749 break;
747 } 750 }
748 751
749 752
750 int fi; 753 int fi;
751 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 754 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
752 QString pwd = getPassword(); 755 QString pwd = getPassword();
753 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 756 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
754 757
755 } 758 }
756 int maxlen = 30; 759 int maxlen = 30;
757 if ( QApplication::desktop()->width() > 320 ) 760 if ( QApplication::desktop()->width() > 320 )
758 maxlen += 25; 761 maxlen += 25;
759 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 762 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
760 int result = system ( preCommand ); 763 int result = system ( preCommand );
761 // 0 : okay 764 // 0 : okay
762 // 256: no such file or dir 765 // 256: no such file or dir
763 // 766 //
764 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); 767 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
765 if ( result != 0 ) { 768 if ( result != 0 ) {
766 unsigned int len = maxlen; 769 unsigned int len = maxlen;
767 while ( len < preCommand.length() ) { 770 while ( len < preCommand.length() ) {
768 preCommand.insert( len , "\n" ); 771 preCommand.insert( len , "\n" );
769 len += maxlen +2; 772 len += maxlen +2;
770 } 773 }
771 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 774 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
772 QMessageBox::information( mParent, i18n("Sync - ERROR"), 775 QMessageBox::information( mParent, i18n("Sync - ERROR"),
773 question, 776 question,
774 i18n("Okay!")) ; 777 i18n("Okay!")) ;
775 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 778 mParent->topLevelWidget()->setCaption ("KDE-Pim");
776 return; 779 return;
777 } 780 }
778 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 781 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
779 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 782 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
780 783
781 if ( syncWithFile( localTempFile, true ) ) { 784 if ( syncWithFile( localTempFile, true ) ) {
782 785
783 if ( mWriteBackFile ) { 786 if ( mWriteBackFile ) {
784 int fi; 787 int fi;
785 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 788 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
786 QString pwd = getPassword(); 789 QString pwd = getPassword();
787 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 790 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
788 791
789 } 792 }
790 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 793 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
791 result = system ( postCommand ); 794 result = system ( postCommand );
792 qDebug("KSM::Sync:Writing back file result: %d ", result); 795 qDebug("KSM::Sync:Writing back file result: %d ", result);
793 if ( result != 0 ) { 796 if ( result != 0 ) {
794 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 797 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
795 return; 798 return;
796 } else { 799 } else {
797 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 800 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
798 } 801 }
799 } 802 }
800 } 803 }
801 return; 804 return;
802} 805}
803bool KSyncManager::edit_pisync_options() 806bool KSyncManager::edit_pisync_options()
804{ 807{
805 QDialog dia( mParent, "dia", true ); 808 QDialog dia( mParent, "dia", true );
806 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 809 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
807 QVBoxLayout lay ( &dia ); 810 Q3VBoxLayout lay ( &dia );
808 lay.setSpacing( 5 ); 811 lay.setSpacing( 5 );
809 lay.setMargin( 3 ); 812 lay.setMargin( 3 );
810 QLabel lab1 ( i18n("Password for remote access:"), &dia); 813 QLabel lab1 ( i18n("Password for remote access:"), &dia);
811 lay.addWidget( &lab1 ); 814 lay.addWidget( &lab1 );
812 QLineEdit le1 (&dia ); 815 QLineEdit le1 (&dia );
813 lay.addWidget( &le1 ); 816 lay.addWidget( &le1 );
814 QLabel lab2 ( i18n("Remote IP address:"), &dia); 817 QLabel lab2 ( i18n("Remote IP address:"), &dia);
815 lay.addWidget( &lab2 ); 818 lay.addWidget( &lab2 );
816 QLineEdit le2 (&dia ); 819 QLineEdit le2 (&dia );
817 lay.addWidget( &le2 ); 820 lay.addWidget( &le2 );
818 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); 821 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia);
819 lay.addWidget( &lab3 ); 822 lay.addWidget( &lab3 );
820 QLineEdit le3 (&dia ); 823 QLineEdit le3 (&dia );
821 lay.addWidget( &le3 ); 824 lay.addWidget( &le3 );
822 QPushButton pb ( "OK", &dia); 825 QPushButton pb ( "OK", &dia);
823 lay.addWidget( &pb ); 826 lay.addWidget( &pb );
824 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 827 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
825 le1.setText( mPassWordPiSync ); 828 le1.setText( mPassWordPiSync );
826 le2.setText( mActiveSyncIP ); 829 le2.setText( mActiveSyncIP );
827 le3.setText( mActiveSyncPort ); 830 le3.setText( mActiveSyncPort );
828 if ( dia.exec() ) { 831 if ( dia.exec() ) {
829 mPassWordPiSync = le1.text(); 832 mPassWordPiSync = le1.text();
830 mActiveSyncPort = le3.text(); 833 mActiveSyncPort = le3.text();
831 mActiveSyncIP = le2.text(); 834 mActiveSyncIP = le2.text();
832 return true; 835 return true;
833 } 836 }
834 return false; 837 return false;
835} 838}
836bool KSyncManager::edit_sync_options() 839bool KSyncManager::edit_sync_options()
837{ 840{
838 841
839 QDialog dia( mParent, "dia", true ); 842 QDialog dia( mParent, "dia", true );
840 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 843 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
841 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 844 Q3ButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
842 QVBoxLayout lay ( &dia ); 845 Q3VBoxLayout lay ( &dia );
843 lay.setSpacing( 2 ); 846 lay.setSpacing( 2 );
844 lay.setMargin( 3 ); 847 lay.setMargin( 3 );
845 lay.addWidget(&gr); 848 lay.addWidget(&gr);
846 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 849 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
847 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 850 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
848 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 851 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
849 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 852 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
850 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 853 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
851 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 854 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
852 //QRadioButton both( i18n("Take both on conflict"), &gr ); 855 //QRadioButton both( i18n("Take both on conflict"), &gr );
853 QPushButton pb ( "OK", &dia); 856 QPushButton pb ( "OK", &dia);
854 lay.addWidget( &pb ); 857 lay.addWidget( &pb );
855 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 858 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
856 switch ( mSyncAlgoPrefs ) { 859 switch ( mSyncAlgoPrefs ) {
857 case 0: 860 case 0:
858 loc.setChecked( true); 861 loc.setChecked( true);
859 break; 862 break;
860 case 1: 863 case 1:
861 rem.setChecked( true ); 864 rem.setChecked( true );
862 break; 865 break;
863 case 2: 866 case 2:
864 newest.setChecked( true); 867 newest.setChecked( true);
865 break; 868 break;
866 case 3: 869 case 3:
867 ask.setChecked( true); 870 ask.setChecked( true);
868 break; 871 break;
869 case 4: 872 case 4:
870 f_loc.setChecked( true); 873 f_loc.setChecked( true);
871 break; 874 break;
872 case 5: 875 case 5:
873 f_rem.setChecked( true); 876 f_rem.setChecked( true);
874 break; 877 break;
875 case 6: 878 case 6:
876 // both.setChecked( true); 879 // both.setChecked( true);
877 break; 880 break;
878 default: 881 default:
879 break; 882 break;
880 } 883 }
881 if ( dia.exec() ) { 884 if ( dia.exec() ) {
882 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 885 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
883 return true; 886 return true;
884 } 887 }
885 return false; 888 return false;
886} 889}
887 890
888QString KSyncManager::getPassword( ) 891QString KSyncManager::getPassword( )
889{ 892{
890 QString retfile = ""; 893 QString retfile = "";
891 QDialog dia ( mParent, "input-dialog", true ); 894 QDialog dia ( mParent, "input-dialog", true );
892 QLineEdit lab ( &dia ); 895 QLineEdit lab ( &dia );
893 lab.setEchoMode( QLineEdit::Password ); 896 lab.setEchoMode( QLineEdit::Password );
894 QVBoxLayout lay( &dia ); 897 Q3VBoxLayout lay( &dia );
895 lay.setMargin(7); 898 lay.setMargin(7);
896 lay.setSpacing(7); 899 lay.setSpacing(7);
897 lay.addWidget( &lab); 900 lay.addWidget( &lab);
898 dia.setFixedSize( 230,50 ); 901 dia.setFixedSize( 230,50 );
899 dia.setCaption( i18n("Enter password") ); 902 dia.setCaption( i18n("Enter password") );
900 QPushButton pb ( "OK", &dia); 903 QPushButton pb ( "OK", &dia);
901 lay.addWidget( &pb ); 904 lay.addWidget( &pb );
902 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 905 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
903 dia.show(); 906 dia.show();
904 int res = dia.exec(); 907 int res = dia.exec();
905 if ( res ) 908 if ( res )
906 retfile = lab.text(); 909 retfile = lab.text();
907 dia.hide(); 910 dia.hide();
908 qApp->processEvents(); 911 qApp->processEvents();
909 return retfile; 912 return retfile;
910 913
911} 914}
912 915
913 916
914void KSyncManager::confSync() 917void KSyncManager::confSync()
915{ 918{
916 static KSyncPrefsDialog* sp = 0; 919 static KSyncPrefsDialog* sp = 0;
917 if ( ! sp ) { 920 if ( ! sp ) {
918 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 921 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
919 } 922 }
920 sp->usrReadConfig(); 923 sp->usrReadConfig();
921#ifndef DESKTOP_VERSION 924#ifndef DESKTOP_VERSION
922 sp->showMaximized(); 925 sp->showMaximized();
923#else 926#else
924 sp->show(); 927 sp->show();
925#endif 928#endif
926 sp->exec(); 929 sp->exec();
927 QStringList oldSyncProfileNames = mSyncProfileNames; 930 QStringList oldSyncProfileNames = mSyncProfileNames;
928 mSyncProfileNames = sp->getSyncProfileNames(); 931 mSyncProfileNames = sp->getSyncProfileNames();
929 mLocalMachineName = sp->getLocalMachineName (); 932 mLocalMachineName = sp->getLocalMachineName ();
930 uint ii; 933 uint ii;
931 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 934 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
932 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 935 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
933 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 936 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
934 } 937 }
935 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 938 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
936} 939}
937void KSyncManager::syncOL() 940void KSyncManager::syncOL()
938{ 941{
939 mSyncWithDesktop = true; 942 mSyncWithDesktop = true;
940 emit save(); 943 emit save();
941 switch(mTargetApp) 944 switch(mTargetApp)
942 { 945 {
943 case (KAPI): 946 case (KAPI):
944 { 947 {
945 syncExternalApplication("ol"); 948 syncExternalApplication("ol");
946 } 949 }
947 break; 950 break;
948 case (KOPI): 951 case (KOPI):
949 { 952 {
950#ifdef DESKTOP_VERSION 953#ifdef DESKTOP_VERSION
951 QString command = "kdecaldump33"; 954 QString command = "kdecaldump33";
952 QString commandfile = "kdecaldump33"; 955 QString commandfile = "kdecaldump33";
953 QString commandpath = qApp->applicationDirPath () + "/"; 956 QString commandpath = qApp->applicationDirPath () + "/";
954#else 957#else
955 QString command = "kdecaldump33"; 958 QString command = "kdecaldump33";
956 QString commandfile = "kdecaldump33"; 959 QString commandfile = "kdecaldump33";
957 QString commandpath = QDir::homeDirPath ()+"/"; 960 QString commandpath = QDir::homeDirPath ()+"/";
958#endif 961#endif
959 if ( ! QFile::exists ( commandpath+commandfile ) ) 962 if ( ! QFile::exists ( commandpath+commandfile ) )
960 command = commandfile; 963 command = commandfile;
961 else 964 else
962 command = commandpath+commandfile; 965 command = commandpath+commandfile;
963 966
964 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 967 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
965 int result = system ( command.latin1()); 968 int result = system ( command.latin1());
966 qDebug("Cal dump 33 command call result result: %d ", result); 969 qDebug("Cal dump 33 command call result result: %d ", result);
967 if ( result != 0 ) { 970 if ( result != 0 ) {
968 qDebug("Calling CAL dump version 33 failed. Trying 34... "); 971 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
969 commandfile = "kdecaldump34"; 972 commandfile = "kdecaldump34";
970 if ( ! QFile::exists ( commandpath+commandfile ) ) 973 if ( ! QFile::exists ( commandpath+commandfile ) )
971 command = commandfile; 974 command = commandfile;
972 else 975 else
973 command = commandpath+commandfile; 976 command = commandpath+commandfile;
974 result = system ( command.latin1()); 977 result = system ( command.latin1());
975 qDebug("Cal dump 34 command call result result: %d ", result); 978 qDebug("Cal dump 34 command call result result: %d ", result);
976 if ( result != 0 ) { 979 if ( result != 0 ) {
977 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 980 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
978 return; 981 return;
979 } 982 }
980 } 983 }
981 if ( syncWithFile( fileName,true ) ) { 984 if ( syncWithFile( fileName,true ) ) {
982 if ( mWriteBackFile ) { 985 if ( mWriteBackFile ) {
983 command += " --read"; 986 command += " --read";
984 system ( command.latin1()); 987 system ( command.latin1());
985 } 988 }
986 } 989 }
987 990
988 } 991 }
989 break; 992 break;
990 case (PWMPI): 993 case (PWMPI):
991 994
992 break; 995 break;
993 default: 996 default:
994 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 997 qDebug("KSM::slotSyncMenu: invalid apptype selected");
995 break; 998 break;
996 999
997 } 1000 }
998} 1001}
999void KSyncManager::syncKDE() 1002void KSyncManager::syncKDE()
1000{ 1003{
1001#ifdef _WIN32_ 1004#ifdef _WIN32_
1002 syncOL(); 1005 syncOL();
1003#else 1006#else
1004 1007
1005 mSyncWithDesktop = true; 1008 mSyncWithDesktop = true;
1006 emit save(); 1009 emit save();
1007 switch(mTargetApp) 1010 switch(mTargetApp)
1008 { 1011 {
1009 case (KAPI): 1012 case (KAPI):
1010 { 1013 {
1011#ifdef DESKTOP_VERSION 1014#ifdef DESKTOP_VERSION
1012 QString command = "kdeabdump33"; 1015 QString command = "kdeabdump33";
1013 QString commandfile = "kdeabdump33"; 1016 QString commandfile = "kdeabdump33";
1014 QString commandpath = qApp->applicationDirPath () + "/"; 1017 QString commandpath = qApp->applicationDirPath () + "/";
1015#else 1018#else
1016 QString command = "kdeabdump33"; 1019 QString command = "kdeabdump33";
1017 QString commandfile = "kdeabdump33"; 1020 QString commandfile = "kdeabdump33";
1018 QString commandpath = QDir::homeDirPath ()+"/"; 1021 QString commandpath = QDir::homeDirPath ()+"/";
1019#endif 1022#endif
1020 if ( ! QFile::exists ( commandpath+commandfile ) ) 1023 if ( ! QFile::exists ( commandpath+commandfile ) )
1021 command = commandfile; 1024 command = commandfile;
1022 else 1025 else
1023 command = commandpath+commandfile; 1026 command = commandpath+commandfile;
1024 1027
1025 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 1028 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
1026 int result = system ( command.latin1()); 1029 int result = system ( command.latin1());
1027 qDebug("AB dump 33 command call result: %d ", result); 1030 qDebug("AB dump 33 command call result: %d ", result);
1028 if ( result != 0 ) { 1031 if ( result != 0 ) {
1029 qDebug("Calling AB dump version 33 failed. Trying 34... "); 1032 qDebug("Calling AB dump version 33 failed. Trying 34... ");
1030 commandfile = "kdeabdump34"; 1033 commandfile = "kdeabdump34";
1031 if ( ! QFile::exists ( commandpath+commandfile ) ) 1034 if ( ! QFile::exists ( commandpath+commandfile ) )
1032 command = commandfile; 1035 command = commandfile;
1033 else 1036 else
1034 command = commandpath+commandfile; 1037 command = commandpath+commandfile;
1035 result = system ( command.latin1()); 1038 result = system ( command.latin1());
1036 qDebug("AB dump 34 command call result: %d ", result); 1039 qDebug("AB dump 34 command call result: %d ", result);
1037 if ( result != 0 ) { 1040 if ( result != 0 ) {
1038 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 1041 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
1039 return; 1042 return;
1040 } 1043 }
1041 } 1044 }
1042 if ( syncWithFile( fileName,true ) ) { 1045 if ( syncWithFile( fileName,true ) ) {
1043 if ( mWriteBackFile ) { 1046 if ( mWriteBackFile ) {
1044 command += " --read"; 1047 command += " --read";
1045 system ( command.latin1()); 1048 system ( command.latin1());
1046 } 1049 }
1047 } 1050 }
1048 1051
1049 } 1052 }
1050 break; 1053 break;
1051 case (KOPI): 1054 case (KOPI):
1052 { 1055 {
1053#ifdef DESKTOP_VERSION 1056#ifdef DESKTOP_VERSION
1054 QString command = "kdecaldump33"; 1057 QString command = "kdecaldump33";
1055 QString commandfile = "kdecaldump33"; 1058 QString commandfile = "kdecaldump33";
1056 QString commandpath = qApp->applicationDirPath () + "/"; 1059 QString commandpath = qApp->applicationDirPath () + "/";
1057#else 1060#else
1058 QString command = "kdecaldump33"; 1061 QString command = "kdecaldump33";
1059 QString commandfile = "kdecaldump33"; 1062 QString commandfile = "kdecaldump33";
1060 QString commandpath = QDir::homeDirPath ()+"/"; 1063 QString commandpath = QDir::homeDirPath ()+"/";
1061#endif 1064#endif
1062 if ( ! QFile::exists ( commandpath+commandfile ) ) 1065 if ( ! QFile::exists ( commandpath+commandfile ) )
1063 command = commandfile; 1066 command = commandfile;
1064 else 1067 else
1065 command = commandpath+commandfile; 1068 command = commandpath+commandfile;
1066 1069
1067 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 1070 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
1068 int result = system ( command.latin1()); 1071 int result = system ( command.latin1());
1069 qDebug("Cal dump 33 command call result result: %d ", result); 1072 qDebug("Cal dump 33 command call result result: %d ", result);
1070 if ( result != 0 ) { 1073 if ( result != 0 ) {
1071 qDebug("Calling CAL dump version 33 failed. Trying 34... "); 1074 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
1072 commandfile = "kdecaldump34"; 1075 commandfile = "kdecaldump34";
1073 if ( ! QFile::exists ( commandpath+commandfile ) ) 1076 if ( ! QFile::exists ( commandpath+commandfile ) )
1074 command = commandfile; 1077 command = commandfile;
1075 else 1078 else
1076 command = commandpath+commandfile; 1079 command = commandpath+commandfile;
1077 result = system ( command.latin1()); 1080 result = system ( command.latin1());
1078 qDebug("Cal dump 34 command call result result: %d ", result); 1081 qDebug("Cal dump 34 command call result result: %d ", result);
1079 if ( result != 0 ) { 1082 if ( result != 0 ) {
1080 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 1083 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
1081 return; 1084 return;
1082 } 1085 }
1083 } 1086 }
1084 if ( syncWithFile( fileName,true ) ) { 1087 if ( syncWithFile( fileName,true ) ) {
1085 if ( mWriteBackFile ) { 1088 if ( mWriteBackFile ) {
1086 command += " --read"; 1089 command += " --read";
1087 system ( command.latin1()); 1090 system ( command.latin1());
1088 } 1091 }
1089 } 1092 }
1090 1093
1091 } 1094 }
1092 break; 1095 break;
1093 case (PWMPI): 1096 case (PWMPI):
1094 1097
1095 break; 1098 break;
1096 default: 1099 default:
1097 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 1100 qDebug("KSM::slotSyncMenu: invalid apptype selected");
1098 break; 1101 break;
1099 1102
1100 } 1103 }
1101#endif 1104#endif
1102} 1105}
1103 1106
1104void KSyncManager::syncSharp() 1107void KSyncManager::syncSharp()
1105{ 1108{
1106 1109
1107 if ( ! syncExternalApplication("sharp") ) 1110 if ( ! syncExternalApplication("sharp") )
1108 qDebug("KSM::ERROR sync sharp "); 1111 qDebug("KSM::ERROR sync sharp ");
1109} 1112}
1110 1113
1111bool KSyncManager::syncExternalApplication(QString resource) 1114bool KSyncManager::syncExternalApplication(QString resource)
1112{ 1115{
1113 1116
1114 emit save(); 1117 emit save();
1115 1118
1116 if ( mAskForPreferences ) 1119 if ( mAskForPreferences )
1117 if ( !edit_sync_options()) { 1120 if ( !edit_sync_options()) {
1118 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1121 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1119 return false; 1122 return false;
1120 } 1123 }
1121 1124
1122 qDebug("KSM::Sync extern %s", resource.latin1()); 1125 qDebug("KSM::Sync extern %s", resource.latin1());
1123 1126
1124 bool syncOK = mImplementation->syncExternal(this, resource); 1127 bool syncOK = mImplementation->syncExternal(this, resource);
1125 1128
1126 return syncOK; 1129 return syncOK;
1127 1130
1128} 1131}
1129 1132
1130void KSyncManager::syncPhone() 1133void KSyncManager::syncPhone()
1131{ 1134{
1132 1135
1133 syncExternalApplication("phone"); 1136 syncExternalApplication("phone");
1134 1137
1135} 1138}
1136 1139
1137void KSyncManager::showProgressBar(int percentage, QString caption, int total) 1140void KSyncManager::showProgressBar(int percentage, QString caption, int total)
1138{ 1141{
1139 if (!bar->isVisible()) 1142 if (!bar->isVisible())
1140 { 1143 {
1141 int w = 300; 1144 int w = 300;
1142 if ( QApplication::desktop()->width() < 320 ) 1145 if ( QApplication::desktop()->width() < 320 )
1143 w = 220; 1146 w = 220;
1144 int h = bar->sizeHint().height() ; 1147 int h = bar->sizeHint().height() ;
1145 int dw = QApplication::desktop()->width(); 1148 int dw = QApplication::desktop()->width();
1146 int dh = QApplication::desktop()->height(); 1149 int dh = QApplication::desktop()->height();
1147 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1150 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1148 bar->setCaption (caption); 1151 bar->setCaption (caption);
1149 bar->setTotalSteps ( total ) ; 1152 bar->setTotalSteps ( total ) ;
1150 bar->show(); 1153 bar->show();
1151 } 1154 }
1152 bar->raise(); 1155 bar->raise();
1153 bar->setProgress( percentage ); 1156 bar->setProgress( percentage );
1154 qApp->processEvents(); 1157 qApp->processEvents();
1155} 1158}
1156 1159
1157void KSyncManager::hideProgressBar() 1160void KSyncManager::hideProgressBar()
1158{ 1161{
1159 bar->hide(); 1162 bar->hide();
1160 qApp->processEvents(); 1163 qApp->processEvents();
1161} 1164}
1162 1165
1163bool KSyncManager::isProgressBarCanceled() 1166bool KSyncManager::isProgressBarCanceled()
1164{ 1167{
1165 return !bar->isVisible(); 1168 return !bar->isVisible();
1166} 1169}
1167 1170
1168QString KSyncManager::syncFileName() 1171QString KSyncManager::syncFileName()
1169{ 1172{
1170 1173
1171 QString fn = "tempfile"; 1174 QString fn = "tempfile";
1172 switch(mTargetApp) 1175 switch(mTargetApp)
1173 { 1176 {
1174 case (KAPI): 1177 case (KAPI):
1175 fn = "tempsyncab.vcf"; 1178 fn = "tempsyncab.vcf";
1176 break; 1179 break;
1177 case (KOPI): 1180 case (KOPI):
1178 fn = "tempsynccal.ics"; 1181 fn = "tempsynccal.ics";
1179 break; 1182 break;
1180 case (PWMPI): 1183 case (PWMPI):
1181 fn = "tempsyncpw.pwm"; 1184 fn = "tempsyncpw.pwm";
1182 break; 1185 break;
1183 default: 1186 default:
1184 break; 1187 break;
1185 } 1188 }
1186#ifdef DESKTOP_VERSION 1189#ifdef DESKTOP_VERSION
1187 return locateLocal( "tmp", fn ); 1190 return locateLocal( "tmp", fn );
1188#else 1191#else
1189 return (QString( "/tmp/" )+ fn ); 1192 return (QString( "/tmp/" )+ fn );
1190#endif 1193#endif
1191} 1194}
1192 1195
1193void KSyncManager::syncPi() 1196void KSyncManager::syncPi()
1194{ 1197{
1195 mIsKapiFile = true; 1198 mIsKapiFile = true;
1196 mPisyncFinished = false; 1199 mPisyncFinished = false;
1197 qApp->processEvents(); 1200 qApp->processEvents();
1198 if ( mAskForPreferences ) 1201 if ( mAskForPreferences )
1199 if ( !edit_pisync_options()) { 1202 if ( !edit_pisync_options()) {
1200 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1203 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1201 mPisyncFinished = true; 1204 mPisyncFinished = true;
1202 return; 1205 return;
1203 } 1206 }
1204 bool ok; 1207 bool ok;
1205 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1208 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1206 if ( ! ok ) { 1209 if ( ! ok ) {
1207 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1210 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1208 mPisyncFinished = true; 1211 mPisyncFinished = true;
1209 return; 1212 return;
1210 } 1213 }
1211 mCurrentResourceLocal = ""; 1214 mCurrentResourceLocal = "";
1212 mCurrentResourceRemote = ""; 1215 mCurrentResourceRemote = "";
1213 if ( mSpecificResources.count() ) { 1216 if ( mSpecificResources.count() ) {
1214 uint lastSyncRes = mSpecificResources.count()/2; 1217 uint lastSyncRes = mSpecificResources.count()/2;
1215 int ccc = mSpecificResources.count()-1; 1218 int ccc = mSpecificResources.count()-1;
1216 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { 1219 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) {
1217 --ccc; 1220 --ccc;
1218 --lastSyncRes; 1221 --lastSyncRes;
1219 //qDebug ( "KSM: sync pi %d",ccc ); 1222 //qDebug ( "KSM: sync pi %d",ccc );
1220 } 1223 }
1221 uint startLocal = 0; 1224 uint startLocal = 0;
1222 uint startRemote = mSpecificResources.count()/2; 1225 uint startRemote = mSpecificResources.count()/2;
1223 emit multiResourceSyncStart( true ); 1226 emit multiResourceSyncStart( true );
1224 while ( startLocal < mSpecificResources.count()/2 ) { 1227 while ( startLocal < mSpecificResources.count()/2 ) {
1225 if ( startLocal+1 >= lastSyncRes ) 1228 if ( startLocal+1 >= lastSyncRes )
1226 emit multiResourceSyncStart( false ); 1229 emit multiResourceSyncStart( false );
1227 mPisyncFinished = false; 1230 mPisyncFinished = false;
1228 mCurrentResourceLocal = mSpecificResources[ startLocal ]; 1231 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1229 mCurrentResourceRemote = mSpecificResources[ startRemote ]; 1232 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1230 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1233 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1231 if ( !mCurrentResourceRemote.isEmpty() ) { 1234 if ( !mCurrentResourceRemote.isEmpty() ) {
1232 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1235 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1233 1236
1234 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1237 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1235 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1238 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1236 commandSocket->readFile( syncFileName() ); 1239 commandSocket->readFile( syncFileName() );
1237 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) ); 1240 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) );
1238 while ( !mPisyncFinished ) { 1241 while ( !mPisyncFinished ) {
1239 //qDebug("waiting "); 1242 //qDebug("waiting ");
1240 qApp->processEvents(); 1243 qApp->processEvents();
1241 } 1244 }
1242 if ( startLocal+1 < mSpecificResources.count()/2 ) { 1245 if ( startLocal+1 < mSpecificResources.count()/2 ) {
1243 mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") ); 1246 mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") );
1244 QTime timer; 1247 QTime timer;
1245 timer.start(); 1248 timer.start();
1246 while ( timer.elapsed () < 1000 ) { 1249 while ( timer.elapsed () < 1000 ) {
1247 qApp->processEvents(); 1250 qApp->processEvents();
1248 } 1251 }
1249 } 1252 }
1250 } 1253 }
1251 ++startRemote; 1254 ++startRemote;
1252 ++startLocal; 1255 ++startLocal;
1253 mAskForPreferences = false; 1256 mAskForPreferences = false;
1254 } 1257 }
1255 mPisyncFinished = true; 1258 mPisyncFinished = true;
1256 mParent->topLevelWidget()->setCaption( i18n("Multi-resource Pi-sync finished") ); 1259 mParent->topLevelWidget()->setCaption( i18n("Multi-resource Pi-sync finished") );
1257 } else { 1260 } else {
1258 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1261 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1259 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1262 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1260 commandSocket->readFile( syncFileName() ); 1263 commandSocket->readFile( syncFileName() );
1261 } 1264 }
1262} 1265}
1263 1266
1264void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1267void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1265{ 1268{
1266 //enum { success, errorW, errorR, quiet }; 1269 //enum { success, errorW, errorR, quiet };
1267 1270
1268 1271
1269 1272
1270 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || 1273 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
1271 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { 1274 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
1272 if ( state == KCommandSocket::errorPW ) 1275 if ( state == KCommandSocket::errorPW )
1273 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); 1276 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
1274 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) 1277 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
1275 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1278 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1276 else if ( state == KCommandSocket::errorCA ) 1279 else if ( state == KCommandSocket::errorCA )
1277 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); 1280 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
1278 else if ( state == KCommandSocket::errorFI ) 1281 else if ( state == KCommandSocket::errorFI )
1279 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); 1282 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
1280 else if ( state == KCommandSocket::errorED ) 1283 else if ( state == KCommandSocket::errorED )
1281 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); 1284 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
1282 else if ( state == KCommandSocket::errorUN ) 1285 else if ( state == KCommandSocket::errorUN )
1283 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); 1286 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
1284 delete s; 1287 delete s;
1285 if ( state == KCommandSocket::errorR ) { 1288 if ( state == KCommandSocket::errorR ) {
1286 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); 1289 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1287 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1290 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1288 commandSocket->sendStop(); 1291 commandSocket->sendStop();
1289 } 1292 }
1290 mPisyncFinished = true; 1293 mPisyncFinished = true;
1291 return; 1294 return;
1292 1295
1293 } else if ( state == KCommandSocket::errorW ) { 1296 } else if ( state == KCommandSocket::errorW ) {
1294 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1297 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1295 mPisyncFinished = true; 1298 mPisyncFinished = true;
1296 1299
1297 } else if ( state == KCommandSocket::successR ) { 1300 } else if ( state == KCommandSocket::successR ) {
1298 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1301 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1299 1302
1300 } else if ( state == KCommandSocket::successW ) { 1303 } else if ( state == KCommandSocket::successW ) {
1301 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1304 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1302 mPisyncFinished = true; 1305 mPisyncFinished = true;
1303 } else if ( state == KCommandSocket::quiet ){ 1306 } else if ( state == KCommandSocket::quiet ){
1304 qDebug("KSS: quiet "); 1307 qDebug("KSS: quiet ");
1305 mPisyncFinished = true; 1308 mPisyncFinished = true;
1306 } else { 1309 } else {
1307 qDebug("KSS: Error: unknown state: %d ", state); 1310 qDebug("KSS: Error: unknown state: %d ", state);
1308 mPisyncFinished = true; 1311 mPisyncFinished = true;
1309 } 1312 }
1310 1313
1311 delete s; 1314 delete s;
1312} 1315}
1313 1316
1314void KSyncManager::readFileFromSocket() 1317void KSyncManager::readFileFromSocket()
1315{ 1318{
1316 QString fileName = syncFileName(); 1319 QString fileName = syncFileName();
1317 bool syncOK = true; 1320 bool syncOK = true;
1318 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1321 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1319 if ( ! syncWithFile( fileName , true ) ) { 1322 if ( ! syncWithFile( fileName , true ) ) {
1320 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1323 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1321 syncOK = false; 1324 syncOK = false;
1322 } 1325 }
1323 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1326 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1324 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1327 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1325 if ( mWriteBackFile && syncOK ) { 1328 if ( mWriteBackFile && syncOK ) {
1326 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1329 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
1327 commandSocket->writeFile( fileName ); 1330 commandSocket->writeFile( fileName );
1328 } 1331 }
1329 else { 1332 else {
1330 commandSocket->sendStop(); 1333 commandSocket->sendStop();
1331 if ( syncOK ) 1334 if ( syncOK )
1332 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1335 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1333 mPisyncFinished = true; 1336 mPisyncFinished = true;
1334 } 1337 }
1335} 1338}
1336 1339
1337KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1340KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : Q3ServerSocket( port, backlog, parent, name )
1338{ 1341{
1339 mPendingConnect = 0; 1342 mPendingConnect = 0;
1340 mPassWord = pw; 1343 mPassWord = pw;
1341 mSocket = 0; 1344 mSocket = 0;
1342 mSyncActionDialog = 0; 1345 mSyncActionDialog = 0;
1343 blockRC = false; 1346 blockRC = false;
1344 mErrorMessage = 0; 1347 mErrorMessage = 0;
1345} 1348}
1346void KServerSocket::waitForSocketFinish() 1349void KServerSocket::waitForSocketFinish()
1347{ 1350{
1348 if ( mSocket ) { 1351 if ( mSocket ) {
1349 //qDebug("KSS:: waiting for finish operation"); 1352 //qDebug("KSS:: waiting for finish operation");
1350 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); 1353 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
1351 return; 1354 return;
1352 } 1355 }
1353 mSocket = new QSocket( this ); 1356 mSocket = new Q3Socket( this );
1354 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1357 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1355 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1358 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1356 mSocket->setSocket( mPendingConnect ); 1359 mSocket->setSocket( mPendingConnect );
1357 mPendingConnect = 0; 1360 mPendingConnect = 0;
1358} 1361}
1359void KServerSocket::newConnection ( int socket ) 1362void KServerSocket::newConnection ( int socket )
1360{ 1363{
1361 // qDebug("KServerSocket:New connection %d ", socket); 1364 // qDebug("KServerSocket:New connection %d ", socket);
1362 if ( mPendingConnect ) { 1365 if ( mPendingConnect ) {
1363 qDebug("KSS::Error : new Connection"); 1366 qDebug("KSS::Error : new Connection");
1364 return; 1367 return;
1365 } 1368 }
1366 if ( mSocket ) { 1369 if ( mSocket ) {
1367 mPendingConnect = socket; 1370 mPendingConnect = socket;
1368 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); 1371 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
1369 return; 1372 return;
1370 qDebug("KSS::newConnection Socket deleted! "); 1373 qDebug("KSS::newConnection Socket deleted! ");
1371 delete mSocket; 1374 delete mSocket;
1372 mSocket = 0; 1375 mSocket = 0;
1373 } 1376 }
1374 mPendingConnect = 0; 1377 mPendingConnect = 0;
1375 mSocket = new QSocket( this ); 1378 mSocket = new Q3Socket( this );
1376 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1379 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1377 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1380 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1378 mSocket->setSocket( socket ); 1381 mSocket->setSocket( socket );
1379} 1382}
1380 1383
1381void KServerSocket::discardClient() 1384void KServerSocket::discardClient()
1382{ 1385{
1383 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1386 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1384} 1387}
1385void KServerSocket::deleteSocket() 1388void KServerSocket::deleteSocket()
1386{ 1389{
1387 //qDebug("KSS::deleteSocket"); 1390 //qDebug("KSS::deleteSocket");
1388 if ( mSocket ) { 1391 if ( mSocket ) {
1389 delete mSocket; 1392 delete mSocket;
1390 mSocket = 0; 1393 mSocket = 0;
1391 } 1394 }
1392 if ( mErrorMessage ) 1395 if ( mErrorMessage )
1393 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); 1396 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage()));
1394} 1397}
1395void KServerSocket::readClient() 1398void KServerSocket::readClient()
1396{ 1399{
1397 if ( blockRC ) 1400 if ( blockRC )
1398 return; 1401 return;
1399 if ( mSocket == 0 ) { 1402 if ( mSocket == 0 ) {
1400 qDebug("ERROR::KSS::readClient(): mSocket == 0 "); 1403 qDebug("ERROR::KSS::readClient(): mSocket == 0 ");
1401 return; 1404 return;
1402 } 1405 }
1403 if ( mErrorMessage ) { 1406 if ( mErrorMessage ) {
1404 mErrorMessage = 999; 1407 mErrorMessage = 999;
1405 error_connect("ERROR_ED\r\n\r\n"); 1408 error_connect("ERROR_ED\r\n\r\n");
1406 return; 1409 return;
1407 } 1410 }
1408 mResource = ""; 1411 mResource = "";
1409 mErrorMessage = 0; 1412 mErrorMessage = 0;
1410 //qDebug("KServerSocket::readClient()"); 1413 //qDebug("KServerSocket::readClient()");
1411 if ( mSocket->canReadLine() ) { 1414 if ( mSocket->canReadLine() ) {
1412 QString line = mSocket->readLine(); 1415 QString line = mSocket->readLine();
1413 //qDebug("KServerSocket readline: %s ", line.latin1()); 1416 //qDebug("KServerSocket readline: %s ", line.latin1());
1414 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1417 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1415 if ( tokens[0] == "GET" ) { 1418 if ( tokens[0] == "GET" ) {
1416 if ( tokens[1] == mPassWord ) { 1419 if ( tokens[1] == mPassWord ) {
1417 //emit sendFile( mSocket ); 1420 //emit sendFile( mSocket );
1418 bool ok = false; 1421 bool ok = false;
1419 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1422 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1420 if ( ok ) { 1423 if ( ok ) {
1421 KSyncManager::mRequestedSyncEvent = dt; 1424 KSyncManager::mRequestedSyncEvent = dt;
1422 } 1425 }
1423 else 1426 else
1424 KSyncManager::mRequestedSyncEvent = QDateTime(); 1427 KSyncManager::mRequestedSyncEvent = QDateTime();
1425 mResource =tokens[3]; 1428 mResource =tokens[3];
1426 send_file(); 1429 send_file();
1427 } 1430 }
1428 else { 1431 else {
1429 mErrorMessage = 1; 1432 mErrorMessage = 1;
1430 error_connect("ERROR_PW\r\n\r\n"); 1433 error_connect("ERROR_PW\r\n\r\n");
1431 } 1434 }
1432 } 1435 }
1433 if ( tokens[0] == "PUT" ) { 1436 if ( tokens[0] == "PUT" ) {
1434 if ( tokens[1] == mPassWord ) { 1437 if ( tokens[1] == mPassWord ) {
1435 //emit getFile( mSocket ); 1438 //emit getFile( mSocket );
1436 blockRC = true; 1439 blockRC = true;
1437 mResource =tokens[2]; 1440 mResource =tokens[2];
1438 get_file(); 1441 get_file();
1439 } 1442 }
1440 else { 1443 else {
1441 mErrorMessage = 2; 1444 mErrorMessage = 2;
1442 error_connect("ERROR_PW\r\n\r\n"); 1445 error_connect("ERROR_PW\r\n\r\n");
1443 end_connect(); 1446 end_connect();
1444 } 1447 }
1445 } 1448 }
1446 if ( tokens[0] == "STOP" ) { 1449 if ( tokens[0] == "STOP" ) {
1447 //emit endConnect(); 1450 //emit endConnect();
1448 end_connect(); 1451 end_connect();
1449 } 1452 }
1450 } 1453 }
1451} 1454}
1452void KServerSocket::displayErrorMessage() 1455void KServerSocket::displayErrorMessage()
1453{ 1456{
1454 if ( mErrorMessage == 1 ) { 1457 if ( mErrorMessage == 1 ) {
1455 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); 1458 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error"));
1456 mErrorMessage = 0; 1459 mErrorMessage = 0;
1457 } 1460 }
1458 else if ( mErrorMessage == 2 ) { 1461 else if ( mErrorMessage == 2 ) {
1459 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); 1462 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error"));
1460 mErrorMessage = 0; 1463 mErrorMessage = 0;
1461 } 1464 }
1462} 1465}
1463void KServerSocket::error_connect( QString errmess ) 1466void KServerSocket::error_connect( QString errmess )
1464{ 1467{
1465 QTextStream os( mSocket ); 1468 Q3TextStream os( mSocket );
1466 os.setEncoding( QTextStream::Latin1 ); 1469 os.setEncoding( Q3TextStream::Latin1 );
1467 os << errmess ; 1470 os << errmess ;
1468 mSocket->close(); 1471 mSocket->close();
1469 if ( mSocket->state() == QSocket::Idle ) { 1472 if ( mSocket->state() == Q3Socket::Idle ) {
1470 QTimer::singleShot( 0, this , SLOT ( discardClient())); 1473 QTimer::singleShot( 0, this , SLOT ( discardClient()));
1471 } 1474 }
1472} 1475}
1473void KServerSocket::end_connect() 1476void KServerSocket::end_connect()
1474{ 1477{
1475 delete mSyncActionDialog; 1478 delete mSyncActionDialog;
1476 mSyncActionDialog = 0; 1479 mSyncActionDialog = 0;
1477} 1480}
1478void KServerSocket::send_file() 1481void KServerSocket::send_file()
1479{ 1482{
1480 //qDebug("MainWindow::sendFile(QSocket* s) "); 1483 //qDebug("MainWindow::sendFile(QSocket* s) ");
1481 if ( mSyncActionDialog ) 1484 if ( mSyncActionDialog )
1482 delete mSyncActionDialog; 1485 delete mSyncActionDialog;
1483 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1486 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1484 mSyncActionDialog->setCaption(i18n("Received sync request")); 1487 mSyncActionDialog->setCaption(i18n("Received sync request"));
1485 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1488 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1486 label->setAlignment ( Qt::AlignHCenter ); 1489 label->setAlignment ( Qt::AlignHCenter );
1487 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1490 Q3VBoxLayout* lay = new Q3VBoxLayout( mSyncActionDialog );
1488 lay->addWidget( label); 1491 lay->addWidget( label);
1489 lay->setMargin(7); 1492 lay->setMargin(7);
1490 lay->setSpacing(7); 1493 lay->setSpacing(7);
1491 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1494 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1492 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1495 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1493 //secs = 333; 1496 //secs = 333;
1494 if ( secs < 0 ) 1497 if ( secs < 0 )
1495 secs = secs * (-1); 1498 secs = secs * (-1);
1496 if ( secs > 30 ) 1499 if ( secs > 30 )
1497 //if ( true ) 1500 //if ( true )
1498 { 1501 {
1499 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1502 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1500 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1503 QLabel* label = new QLabel( warning, mSyncActionDialog );
1501 label->setAlignment ( Qt::AlignHCenter ); 1504 label->setAlignment ( Qt::AlignHCenter );
1502 lay->addWidget( label); 1505 lay->addWidget( label);
1503 if ( secs > 180 ) 1506 if ( secs > 180 )
1504 { 1507 {
1505 if ( secs > 300 ) { 1508 if ( secs > 300 ) {
1506 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1509 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1507 qDebug("KSS::Sync cancelled ,cs"); 1510 qDebug("KSS::Sync cancelled ,cs");
1508 mErrorMessage = 0; 1511 mErrorMessage = 0;
1509 end_connect(); 1512 end_connect();
1510 error_connect("ERROR_CA\r\n\r\n"); 1513 error_connect("ERROR_CA\r\n\r\n");
1511 return ; 1514 return ;
1512 } 1515 }
1513 } 1516 }
1514 QFont f = label->font(); 1517 QFont f = label->font();
1515 f.setPointSize ( f.pointSize() *2 ); 1518 f.setPointSize ( f.pointSize() *2 );
1516 f. setBold (true ); 1519 f. setBold (true );
1517 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1520 QLabel* label = new QLabel( warning, mSyncActionDialog );
1518 label->setFont( f ); 1521 label->setFont( f );
1519 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1522 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1520 label->setText( warning ); 1523 label->setText( warning );
1521 label->setAlignment ( Qt::AlignHCenter ); 1524 label->setAlignment ( Qt::AlignHCenter );
1522 lay->addWidget( label); 1525 lay->addWidget( label);
1523 mSyncActionDialog->setFixedSize( 230, 300); 1526 mSyncActionDialog->setFixedSize( 230, 300);
1524 } else { 1527 } else {
1525 mSyncActionDialog->setFixedSize( 230, 200); 1528 mSyncActionDialog->setFixedSize( 230, 200);
1526 } 1529 }
1527 } else { 1530 } else {
1528 mSyncActionDialog->setFixedSize( 230, 120); 1531 mSyncActionDialog->setFixedSize( 230, 120);
1529 } 1532 }
1530 } else 1533 } else
1531 mSyncActionDialog->setFixedSize( 230, 120); 1534 mSyncActionDialog->setFixedSize( 230, 120);
1532 mSyncActionDialog->show(); 1535 mSyncActionDialog->show();
1533 mSyncActionDialog->raise(); 1536 mSyncActionDialog->raise();
1534 emit request_file(mResource); 1537 emit request_file(mResource);
1535 //emit request_file(); 1538 //emit request_file();
1536 qApp->processEvents(); 1539 qApp->processEvents();
1537 QString fileName = mFileName; 1540 QString fileName = mFileName;
1538 QFile file( fileName ); 1541 QFile file( fileName );
1539 if (!file.open( IO_ReadOnly ) ) { 1542 if (!file.open( QIODevice::ReadOnly ) ) {
1540 mErrorMessage = 0; 1543 mErrorMessage = 0;
1541 end_connect(); 1544 end_connect();
1542 error_connect("ERROR_FI\r\n\r\n"); 1545 error_connect("ERROR_FI\r\n\r\n");
1543 return ; 1546 return ;
1544 } 1547 }
1545 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1548 mSyncActionDialog->setCaption( i18n("Sending file...") );
1546 QTextStream ts( &file ); 1549 Q3TextStream ts( &file );
1547 ts.setEncoding( QTextStream::Latin1 ); 1550 ts.setEncoding( Q3TextStream::Latin1 );
1548 1551
1549 QTextStream os( mSocket ); 1552 Q3TextStream os( mSocket );
1550 os.setEncoding( QTextStream::Latin1 ); 1553 os.setEncoding( Q3TextStream::Latin1 );
1551 while ( ! ts.atEnd() ) { 1554 while ( ! ts.atEnd() ) {
1552 os << ts.readLine() << "\r\n"; 1555 os << ts.readLine() << "\r\n";
1553 } 1556 }
1554 os << "\r\n"; 1557 os << "\r\n";
1555 //os << ts.read(); 1558 //os << ts.read();
1556 file.close(); 1559 file.close();
1557 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1560 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1558 mSocket->close(); 1561 mSocket->close();
1559 if ( mSocket->state() == QSocket::Idle ) 1562 if ( mSocket->state() == Q3Socket::Idle )
1560 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1563 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1561} 1564}
1562void KServerSocket::get_file() 1565void KServerSocket::get_file()
1563{ 1566{
1564 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1567 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1565 1568
1566 piTime.start(); 1569 piTime.start();
1567 piFileString = ""; 1570 piFileString = "";
1568 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1571 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1569} 1572}
1570 1573
1571 1574
1572void KServerSocket::readBackFileFromSocket() 1575void KServerSocket::readBackFileFromSocket()
1573{ 1576{
1574 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1577 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1575 while ( mSocket->canReadLine () ) { 1578 while ( mSocket->canReadLine () ) {
1576 piTime.restart(); 1579 piTime.restart();
1577 QString line = mSocket->readLine (); 1580 QString line = mSocket->readLine ();
1578 piFileString += line; 1581 piFileString += line;
1579 //qDebug("readline: %s ", line.latin1()); 1582 //qDebug("readline: %s ", line.latin1());
1580 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1583 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1581 1584
1582 } 1585 }
1583 if ( piTime.elapsed () < 3000 ) { 1586 if ( piTime.elapsed () < 3000 ) {
1584 // wait for more 1587 // wait for more
1585 //qDebug("waitformore "); 1588 //qDebug("waitformore ");
1586 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1589 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1587 return; 1590 return;
1588 } 1591 }
1589 QString fileName = mFileName; 1592 QString fileName = mFileName;
1590 QFile file ( fileName ); 1593 QFile file ( fileName );
1591 if (!file.open( IO_WriteOnly ) ) { 1594 if (!file.open( QIODevice::WriteOnly ) ) {
1592 delete mSyncActionDialog; 1595 delete mSyncActionDialog;
1593 mSyncActionDialog = 0; 1596 mSyncActionDialog = 0;
1594 qDebug("KSS:Error open read back file "); 1597 qDebug("KSS:Error open read back file ");
1595 piFileString = ""; 1598 piFileString = "";
1596 emit file_received( false, mResource); 1599 emit file_received( false, mResource);
1597 emit file_received( false); 1600 emit file_received( false);
1598 blockRC = false; 1601 blockRC = false;
1599 return ; 1602 return ;
1600 1603
1601 } 1604 }
1602 1605
1603 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1606 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1604 QTextStream ts ( &file ); 1607 Q3TextStream ts ( &file );
1605 ts.setEncoding( QTextStream::Latin1 ); 1608 ts.setEncoding( Q3TextStream::Latin1 );
1606 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1609 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1607 ts << piFileString; 1610 ts << piFileString;
1608 mSocket->close(); 1611 mSocket->close();
1609 if ( mSocket->state() == QSocket::Idle ) 1612 if ( mSocket->state() == Q3Socket::Idle )
1610 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1613 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1611 file.close(); 1614 file.close();
1612 piFileString = ""; 1615 piFileString = "";
1613 emit file_received( true, mResource ); 1616 emit file_received( true, mResource );
1614 emit file_received( true); 1617 emit file_received( true);
1615 delete mSyncActionDialog; 1618 delete mSyncActionDialog;
1616 mSyncActionDialog = 0; 1619 mSyncActionDialog = 0;
1617 blockRC = false; 1620 blockRC = false;
1618 1621
1619} 1622}
1620 1623
1621KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) 1624KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
1622{ 1625{
1623 mRemoteResource = remres; 1626 mRemoteResource = remres;
1624 if ( mRemoteResource.isEmpty() ) 1627 if ( mRemoteResource.isEmpty() )
1625 mRemoteResource = "ALL"; 1628 mRemoteResource = "ALL";
1626 else 1629 else
1627 mRemoteResource.replace (QRegExp (" "),"_" ); 1630 mRemoteResource.replace (QRegExp (" "),"_" );
1628 mPassWord = password; 1631 mPassWord = password;
1629 mSocket = 0; 1632 mSocket = 0;
1630 mFirst = false; 1633 mFirst = false;
1631 mFirstLine = true; 1634 mFirstLine = true;
1632 mPort = port; 1635 mPort = port;
1633 mHost = host; 1636 mHost = host;
1634 tlw = cap; 1637 tlw = cap;
1635 mRetVal = quiet; 1638 mRetVal = quiet;
1636 mTimerSocket = new QTimer ( this ); 1639 mTimerSocket = new QTimer ( this );
1637 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); 1640 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) );
1638 mConnectProgress.setCaption( i18n("Pi-Sync") ); 1641 mConnectProgress.setCaption( i18n("Pi-Sync") );
1639 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); 1642 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) );
1640 mConnectCount = -1; 1643 mConnectCount = -1;
1641} 1644}
1642void KCommandSocket::sendFileRequest() 1645void KCommandSocket::sendFileRequest()
1643{ 1646{
1644 if ( tlw ) 1647 if ( tlw )
1645 tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); 1648 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1646 mConnectProgress.hide(); 1649 mConnectProgress.hide();
1647 mConnectCount = 300;mConnectMax = 300; 1650 mConnectCount = 300;mConnectMax = 300;
1648 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); 1651 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
1649 mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); 1652 mConnectProgress.setLabelText( i18n("Waiting for remote file...") );
1650 mTimerSocket->start( 100, true ); 1653 mTimerSocket->start( 100, true );
1651 QTextStream os( mSocket ); 1654 Q3TextStream os( mSocket );
1652 os.setEncoding( QTextStream::Latin1 ); 1655 os.setEncoding( Q3TextStream::Latin1 );
1653 1656
1654 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1657 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1655 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; 1658 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n";
1656} 1659}
1657 1660
1658void KCommandSocket::readFile( QString fn ) 1661void KCommandSocket::readFile( QString fn )
1659{ 1662{
1660 if ( !mSocket ) { 1663 if ( !mSocket ) {
1661 mSocket = new QSocket( this ); 1664 mSocket = new Q3Socket( this );
1662 //qDebug("KCS: read file - new socket"); 1665 //qDebug("KCS: read file - new socket");
1663 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1666 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1664 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1667 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1665 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); 1668 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1666 } 1669 }
1667 mFileString = ""; 1670 mFileString = "";
1668 mFileName = fn; 1671 mFileName = fn;
1669 mFirst = true; 1672 mFirst = true;
1670 if ( tlw ) 1673 if ( tlw )
1671 tlw->setCaption( i18n("Trying to connect to remote...") ); 1674 tlw->setCaption( i18n("Trying to connect to remote...") );
1672 mConnectCount = 30;mConnectMax = 30; 1675 mConnectCount = 30;mConnectMax = 30;
1673 mTimerSocket->start( 1000, true ); 1676 mTimerSocket->start( 1000, true );
1674 mSocket->connectToHost( mHost, mPort ); 1677 mSocket->connectToHost( mHost, mPort );
1675 //qDebug("KCS: Waiting for connection"); 1678 //qDebug("KCS: Waiting for connection");
1676} 1679}
1677void KCommandSocket::updateConnectDialog() 1680void KCommandSocket::updateConnectDialog()
1678{ 1681{
1679 1682
1680 if ( mConnectCount == mConnectMax ) { 1683 if ( mConnectCount == mConnectMax ) {
1681 //qDebug("MAXX %d", mConnectMax); 1684 //qDebug("MAXX %d", mConnectMax);
1682 mConnectProgress.setTotalSteps ( 30 ); 1685 mConnectProgress.setTotalSteps ( 30 );
1683 mConnectProgress.show(); 1686 mConnectProgress.show();
1684 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); 1687 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") );
1685 } 1688 }
1686 //qDebug("updateConnectDialog() %d", mConnectCount); 1689 //qDebug("updateConnectDialog() %d", mConnectCount);
1687 mConnectProgress.raise(); 1690 mConnectProgress.raise();
1688 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); 1691 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 );
1689 --mConnectCount; 1692 --mConnectCount;
1690 if ( mConnectCount > 0 ) 1693 if ( mConnectCount > 0 )
1691 mTimerSocket->start( 1000, true ); 1694 mTimerSocket->start( 1000, true );
1692 else 1695 else
1693 deleteSocket(); 1696 deleteSocket();
1694 1697
1695} 1698}
1696void KCommandSocket::writeFile( QString fileName ) 1699void KCommandSocket::writeFile( QString fileName )
1697{ 1700{
1698 if ( !mSocket ) { 1701 if ( !mSocket ) {
1699 mSocket = new QSocket( this ); 1702 mSocket = new Q3Socket( this );
1700 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1703 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1701 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1704 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1702 } 1705 }
1703 mFileName = fileName ; 1706 mFileName = fileName ;
1704 mConnectCount = 30;mConnectMax = 30; 1707 mConnectCount = 30;mConnectMax = 30;
1705 mTimerSocket->start( 1000, true ); 1708 mTimerSocket->start( 1000, true );
1706 mSocket->connectToHost( mHost, mPort ); 1709 mSocket->connectToHost( mHost, mPort );
1707} 1710}
1708void KCommandSocket::writeFileToSocket() 1711void KCommandSocket::writeFileToSocket()
1709{ 1712{
1710 mTimerSocket->stop(); 1713 mTimerSocket->stop();
1711 QFile file2( mFileName ); 1714 QFile file2( mFileName );
1712 if (!file2.open( IO_ReadOnly ) ) { 1715 if (!file2.open( QIODevice::ReadOnly ) ) {
1713 mConnectProgress.hide(); 1716 mConnectProgress.hide();
1714 mConnectCount = -1; 1717 mConnectCount = -1;
1715 mRetVal= errorW; 1718 mRetVal= errorW;
1716 mSocket->close(); 1719 mSocket->close();
1717 if ( mSocket->state() == QSocket::Idle ) 1720 if ( mSocket->state() == Q3Socket::Idle )
1718 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1721 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1719 return ; 1722 return ;
1720 } 1723 }
1721 mConnectProgress.setTotalSteps ( file2.size() ); 1724 mConnectProgress.setTotalSteps ( file2.size() );
1722 mConnectProgress.show(); 1725 mConnectProgress.show();
1723 int count = 0; 1726 int count = 0;
1724 mConnectProgress.setLabelText( i18n("Sending back synced file...") ); 1727 mConnectProgress.setLabelText( i18n("Sending back synced file...") );
1725 mConnectProgress.setProgress( count ); 1728 mConnectProgress.setProgress( count );
1726 mConnectProgress.blockSignals( true ); 1729 mConnectProgress.blockSignals( true );
1727 QTextStream ts2( &file2 ); 1730 Q3TextStream ts2( &file2 );
1728 ts2.setEncoding( QTextStream::Latin1 ); 1731 ts2.setEncoding( Q3TextStream::Latin1 );
1729 QTextStream os2( mSocket ); 1732 Q3TextStream os2( mSocket );
1730 os2.setEncoding( QTextStream::Latin1 ); 1733 os2.setEncoding( Q3TextStream::Latin1 );
1731 os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";; 1734 os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";;
1732 int byteCount = 0; 1735 int byteCount = 0;
1733 int byteMax = file2.size()/53; 1736 int byteMax = file2.size()/53;
1734 while ( ! ts2.atEnd() ) { 1737 while ( ! ts2.atEnd() ) {
1735 qApp->processEvents(); 1738 qApp->processEvents();
1736 if ( byteCount > byteMax ) { 1739 if ( byteCount > byteMax ) {
1737 byteCount = 0; 1740 byteCount = 0;
1738 mConnectProgress.setProgress( count ); 1741 mConnectProgress.setProgress( count );
1739 } 1742 }
1740 QString temp = ts2.readLine(); 1743 QString temp = ts2.readLine();
1741 count += temp.length(); 1744 count += temp.length();
1742 byteCount += temp.length(); 1745 byteCount += temp.length();
1743 os2 << temp << "\r\n"; 1746 os2 << temp << "\r\n";
1744 } 1747 }
1745 file2.close(); 1748 file2.close();
1746 mConnectProgress.hide(); 1749 mConnectProgress.hide();
1747 mConnectCount = -1; 1750 mConnectCount = -1;
1748 os2 << "\r\n"; 1751 os2 << "\r\n";
1749 mRetVal= successW; 1752 mRetVal= successW;
1750 mSocket->close(); 1753 mSocket->close();
1751 if ( mSocket->state() == QSocket::Idle ) 1754 if ( mSocket->state() == Q3Socket::Idle )
1752 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1755 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1753 mConnectProgress.blockSignals( false ); 1756 mConnectProgress.blockSignals( false );
1754} 1757}
1755void KCommandSocket::sendStop() 1758void KCommandSocket::sendStop()
1756{ 1759{
1757 if ( !mSocket ) { 1760 if ( !mSocket ) {
1758 mSocket = new QSocket( this ); 1761 mSocket = new Q3Socket( this );
1759 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1762 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1760 } 1763 }
1761 mSocket->connectToHost( mHost, mPort ); 1764 mSocket->connectToHost( mHost, mPort );
1762 QTextStream os2( mSocket ); 1765 Q3TextStream os2( mSocket );
1763 os2.setEncoding( QTextStream::Latin1 ); 1766 os2.setEncoding( Q3TextStream::Latin1 );
1764 os2 << "STOP\r\n\r\n"; 1767 os2 << "STOP\r\n\r\n";
1765 mSocket->close(); 1768 mSocket->close();
1766 if ( mSocket->state() == QSocket::Idle ) 1769 if ( mSocket->state() == Q3Socket::Idle )
1767 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1770 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1768} 1771}
1769 1772
1770void KCommandSocket::startReadFileFromSocket() 1773void KCommandSocket::startReadFileFromSocket()
1771{ 1774{
1772 if ( ! mFirst ) 1775 if ( ! mFirst )
1773 return; 1776 return;
1774 mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); 1777 mConnectProgress.setLabelText( i18n("Receiving file from remote...") );
1775 mFirst = false; 1778 mFirst = false;
1776 mFileString = ""; 1779 mFileString = "";
1777 mTime.start(); 1780 mTime.start();
1778 mFirstLine = true; 1781 mFirstLine = true;
1779 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1782 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1780 1783
1781} 1784}
1782void KCommandSocket::readFileFromSocket() 1785void KCommandSocket::readFileFromSocket()
1783{ 1786{
1784 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1787 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1785 while ( mSocket->canReadLine () ) { 1788 while ( mSocket->canReadLine () ) {
1786 mTime.restart(); 1789 mTime.restart();
1787 QString line = mSocket->readLine (); 1790 QString line = mSocket->readLine ();
1788 if ( mFirstLine ) { 1791 if ( mFirstLine ) {
1789 mFirstLine = false; 1792 mFirstLine = false;
1790 if ( line.left( 6 ) == "ERROR_" ) { 1793 if ( line.left( 6 ) == "ERROR_" ) {
1791 mTimerSocket->stop(); 1794 mTimerSocket->stop();
1792 mConnectCount = -1; 1795 mConnectCount = -1;
1793 if ( line.left( 8 ) == "ERROR_PW" ) { 1796 if ( line.left( 8 ) == "ERROR_PW" ) {
1794 mRetVal = errorPW; 1797 mRetVal = errorPW;
1795 deleteSocket(); 1798 deleteSocket();
1796 return ; 1799 return ;
1797 } 1800 }
1798 if ( line.left( 8 ) == "ERROR_CA" ) { 1801 if ( line.left( 8 ) == "ERROR_CA" ) {
1799 mRetVal = errorCA; 1802 mRetVal = errorCA;
1800 deleteSocket(); 1803 deleteSocket();
1801 return ; 1804 return ;
1802 } 1805 }
1803 if ( line.left( 8 ) == "ERROR_FI" ) { 1806 if ( line.left( 8 ) == "ERROR_FI" ) {
1804 mRetVal = errorFI; 1807 mRetVal = errorFI;
1805 deleteSocket(); 1808 deleteSocket();
1806 return ; 1809 return ;
1807 } 1810 }
1808 if ( line.left( 8 ) == "ERROR_ED" ) { 1811 if ( line.left( 8 ) == "ERROR_ED" ) {
1809 mRetVal = errorED; 1812 mRetVal = errorED;
1810 deleteSocket(); 1813 deleteSocket();
1811 return ; 1814 return ;
1812 } 1815 }
1813 mRetVal = errorUN; 1816 mRetVal = errorUN;
1814 deleteSocket(); 1817 deleteSocket();
1815 return ; 1818 return ;
1816 } 1819 }
1817 } 1820 }
1818 mFileString += line; 1821 mFileString += line;
1819 //qDebug("readline: %s ", line.latin1()); 1822 //qDebug("readline: %s ", line.latin1());
1820 } 1823 }
1821 if ( mTime.elapsed () < 3000 ) { 1824 if ( mTime.elapsed () < 3000 ) {
1822 // wait for more 1825 // wait for more
1823 //qDebug("waitformore "); 1826 //qDebug("waitformore ");
1824 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1827 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1825 return; 1828 return;
1826 } 1829 }
1827 mTimerSocket->stop(); 1830 mTimerSocket->stop();
1828 mConnectCount = -1; 1831 mConnectCount = -1;
1829 mConnectProgress.hide(); 1832 mConnectProgress.hide();
1830 QString fileName = mFileName; 1833 QString fileName = mFileName;
1831 QFile file ( fileName ); 1834 QFile file ( fileName );
1832 if (!file.open( IO_WriteOnly ) ) { 1835 if (!file.open( QIODevice::WriteOnly ) ) {
1833 mFileString = ""; 1836 mFileString = "";
1834 mRetVal = errorR; 1837 mRetVal = errorR;
1835 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1838 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1836 deleteSocket(); 1839 deleteSocket();
1837 return ; 1840 return ;
1838 1841
1839 } 1842 }
1840 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1843 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1841 QTextStream ts ( &file ); 1844 Q3TextStream ts ( &file );
1842 ts.setEncoding( QTextStream::Latin1 ); 1845 ts.setEncoding( Q3TextStream::Latin1 );
1843 ts << mFileString; 1846 ts << mFileString;
1844 file.close(); 1847 file.close();
1845 mFileString = ""; 1848 mFileString = "";
1846 mRetVal = successR; 1849 mRetVal = successR;
1847 mSocket->close(); 1850 mSocket->close();
1848 // if state is not idle, deleteSocket(); is called via 1851 // if state is not idle, deleteSocket(); is called via
1849 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1852 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1850 if ( mSocket->state() == QSocket::Idle ) 1853 if ( mSocket->state() == Q3Socket::Idle )
1851 deleteSocket(); 1854 deleteSocket();
1852} 1855}
1853 1856
1854void KCommandSocket::deleteSocket() 1857void KCommandSocket::deleteSocket()
1855{ 1858{
1856 //qDebug("KCommandSocket::deleteSocket() "); 1859 //qDebug("KCommandSocket::deleteSocket() ");
1857 mConnectProgress.hide(); 1860 mConnectProgress.hide();
1858 1861
1859 if ( mConnectCount >= 0 ) { 1862 if ( mConnectCount >= 0 ) {
1860 mTimerSocket->stop(); 1863 mTimerSocket->stop();
1861 mRetVal = errorTO; 1864 mRetVal = errorTO;
1862 qDebug("KCS::Connection to remote host timed out"); 1865 qDebug("KCS::Connection to remote host timed out");
1863 if ( mSocket ) { 1866 if ( mSocket ) {
1864 mSocket->close(); 1867 mSocket->close();
1865 //if ( mSocket->state() == QSocket::Idle ) 1868 //if ( mSocket->state() == QSocket::Idle )
1866 // deleteSocket(); 1869 // deleteSocket();
1867 delete mSocket; 1870 delete mSocket;
1868 mSocket = 0; 1871 mSocket = 0;
1869 } 1872 }
1870 if ( mConnectCount == 0 ) 1873 if ( mConnectCount == 0 )
1871 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); 1874 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?"));
1872 else if ( tlw ) 1875 else if ( tlw )
1873 tlw->setCaption( i18n("Connection to remote host cancelled!") ); 1876 tlw->setCaption( i18n("Connection to remote host cancelled!") );
1874 emit commandFinished( this, mRetVal ); 1877 emit commandFinished( this, mRetVal );
1875 return; 1878 return;
1876 } 1879 }
1877 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1880 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1878 if ( mSocket) 1881 if ( mSocket)
1879 delete mSocket; 1882 delete mSocket;
1880 mSocket = 0; 1883 mSocket = 0;
1881 //qDebug("commandFinished "); 1884 //qDebug("commandFinished ");
1882 emit commandFinished( this, mRetVal ); 1885 emit commandFinished( this, mRetVal );
1883} 1886}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 71d17e9..32c6557 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,248 +1,250 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20 $Id$ 20 $Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h> 27#include <q3socket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <q3serversocket.h>
30#include <qtextstream.h> 30#include <q3textstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qprogressdialog.h> 32#include <q3progressdialog.h>
33//Added by qt3to4:
34#include <Q3PopupMenu>
33#include <kdialog.h> 35#include <kdialog.h>
34 36
35class QPopupMenu; 37class Q3PopupMenu;
36class KSyncProfile; 38class KSyncProfile;
37class KPimPrefs; 39class KPimPrefs;
38class QWidget; 40class QWidget;
39class KSyncManager; 41class KSyncManager;
40class KSyncInterface; 42class KSyncInterface;
41class QProgressBar; 43class Q3ProgressBar;
42 44
43 45
44class KServerSocket : public QServerSocket 46class KServerSocket : public Q3ServerSocket
45{ 47{
46 Q_OBJECT 48 Q_OBJECT
47 49
48 public: 50 public:
49 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 51 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
50 52
51 void newConnection ( int socket ) ; 53 void newConnection ( int socket ) ;
52 void setFileName( QString fn ) {mFileName = fn;}; 54 void setFileName( QString fn ) {mFileName = fn;};
53 signals: 55 signals:
54 void file_received( bool ); 56 void file_received( bool );
55 void request_file(); 57 void request_file();
56 void file_received( bool, const QString &); 58 void file_received( bool, const QString &);
57 void request_file(const QString &); 59 void request_file(const QString &);
58 void saveFile(); 60 void saveFile();
59 void endConnect(); 61 void endConnect();
60 private slots: 62 private slots:
61 void waitForSocketFinish(); 63 void waitForSocketFinish();
62 void discardClient(); 64 void discardClient();
63 void deleteSocket(); 65 void deleteSocket();
64 void readClient(); 66 void readClient();
65 void displayErrorMessage(); 67 void displayErrorMessage();
66 void readBackFileFromSocket(); 68 void readBackFileFromSocket();
67 private : 69 private :
68 int mPendingConnect; 70 int mPendingConnect;
69 QString mResource; 71 QString mResource;
70 int mErrorMessage; 72 int mErrorMessage;
71 bool blockRC; 73 bool blockRC;
72 void send_file(); 74 void send_file();
73 void get_file(); 75 void get_file();
74 void end_connect(); 76 void end_connect();
75 void error_connect( QString ); 77 void error_connect( QString );
76 QDialog* mSyncActionDialog; 78 QDialog* mSyncActionDialog;
77 QSocket* mSocket; 79 Q3Socket* mSocket;
78 QString mPassWord; 80 QString mPassWord;
79 QString mFileName; 81 QString mFileName;
80 QTime piTime; 82 QTime piTime;
81 QString piFileString; 83 QString piFileString;
82}; 84};
83 85
84class KCommandSocket : public QObject 86class KCommandSocket : public QObject
85{ 87{
86 Q_OBJECT 88 Q_OBJECT
87 public: 89 public:
88 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; 90 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet };
89 KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); 91 KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
90 void readFile( QString ); 92 void readFile( QString );
91 void writeFile( QString ); 93 void writeFile( QString );
92 void sendStop(); 94 void sendStop();
93 95
94 private slots : 96 private slots :
95 void sendFileRequest(); 97 void sendFileRequest();
96 void updateConnectDialog(); 98 void updateConnectDialog();
97 99
98 signals: 100 signals:
99 void commandFinished( KCommandSocket*, int ); 101 void commandFinished( KCommandSocket*, int );
100 private slots: 102 private slots:
101 void startReadFileFromSocket(); 103 void startReadFileFromSocket();
102 void readFileFromSocket(); 104 void readFileFromSocket();
103 void deleteSocket(); 105 void deleteSocket();
104 void writeFileToSocket(); 106 void writeFileToSocket();
105 private : 107 private :
106 QString mRemoteResource; 108 QString mRemoteResource;
107 int mConnectCount; 109 int mConnectCount;
108 int mConnectMax; 110 int mConnectMax;
109 KProgressDialog mConnectProgress; 111 KProgressDialog mConnectProgress;
110 QWidget* tlw; 112 QWidget* tlw;
111 QSocket* mSocket; 113 Q3Socket* mSocket;
112 QString mPassWord; 114 QString mPassWord;
113 Q_UINT16 mPort; 115 Q_UINT16 mPort;
114 QString mHost; 116 QString mHost;
115 QString mFileName; 117 QString mFileName;
116 QTimer* mTimerSocket; 118 QTimer* mTimerSocket;
117 int mRetVal; 119 int mRetVal;
118 QTime mTime; 120 QTime mTime;
119 QString mFileString; 121 QString mFileString;
120 bool mFirst; 122 bool mFirst;
121 bool mFirstLine; 123 bool mFirstLine;
122}; 124};
123 125
124 126
125class KSyncManager : public QObject 127class KSyncManager : public QObject
126{ 128{
127 Q_OBJECT 129 Q_OBJECT
128 130
129 public: 131 public:
130 enum TargetApp { 132 enum TargetApp {
131 KOPI = 0, 133 KOPI = 0,
132 KAPI = 1, 134 KAPI = 1,
133 PWMPI = 2 }; 135 PWMPI = 2 };
134 136
135 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 137 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, Q3PopupMenu* syncmenu);
136 ~KSyncManager() ; 138 ~KSyncManager() ;
137 139
138 void multiSync( bool askforPrefs ); 140 void multiSync( bool askforPrefs );
139 bool blockSave() { return mBlockSaveFlag; } 141 bool blockSave() { return mBlockSaveFlag; }
140 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 142 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
141 void setDefaultFileName( QString s) ; 143 void setDefaultFileName( QString s) ;
142 QString defaultFileName() { return mDefFileName ;} 144 QString defaultFileName() { return mDefFileName ;}
143 QString syncFileName(); 145 QString syncFileName();
144 void enableQuick( bool ask = true); 146 void enableQuick( bool ask = true);
145 147
146 bool syncWithDesktop () { return mSyncWithDesktop;} 148 bool syncWithDesktop () { return mSyncWithDesktop;}
147 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 149 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
148 QString getCurrentSyncName() { return mCurrentSyncName; } 150 QString getCurrentSyncName() { return mCurrentSyncName; }
149 151
150 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 152 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
151 void hideProgressBar(); 153 void hideProgressBar();
152 bool isProgressBarCanceled(); 154 bool isProgressBarCanceled();
153 155
154 // sync stuff 156 // sync stuff
155 QString mLocalMachineName; 157 QString mLocalMachineName;
156 QStringList mExternSyncProfiles; 158 QStringList mExternSyncProfiles;
157 QStringList mSyncProfileNames; 159 QStringList mSyncProfileNames;
158 bool mAskForPreferences; 160 bool mAskForPreferences;
159 bool mShowSyncSummary; 161 bool mShowSyncSummary;
160 bool mIsKapiFile; 162 bool mIsKapiFile;
161 bool mWriteBackExistingOnly; 163 bool mWriteBackExistingOnly;
162 int mSyncAlgoPrefs; 164 int mSyncAlgoPrefs;
163 bool mWriteBackFile; 165 bool mWriteBackFile;
164 int mWriteBackInFuture; 166 int mWriteBackInFuture;
165 int mWriteBackInPast; 167 int mWriteBackInPast;
166 QString mPhoneDevice; 168 QString mPhoneDevice;
167 QString mPhoneConnection; 169 QString mPhoneConnection;
168 QString mPhoneModel; 170 QString mPhoneModel;
169 QString mPassWordPiSync; 171 QString mPassWordPiSync;
170 QString mActiveSyncPort; 172 QString mActiveSyncPort;
171 QString mActiveSyncIP ; 173 QString mActiveSyncIP ;
172 QString mFilterInCal; 174 QString mFilterInCal;
173 QString mFilterOutCal; 175 QString mFilterOutCal;
174 QString mFilterInAB; 176 QString mFilterInAB;
175 QString mFilterOutAB; 177 QString mFilterOutAB;
176 static QDateTime mRequestedSyncEvent; 178 static QDateTime mRequestedSyncEvent;
177 179
178 signals: 180 signals:
179 void save(); 181 void save();
180 void request_file(); 182 void request_file();
181 void getFile( bool ); 183 void getFile( bool );
182 void getFile( bool, const QString &); 184 void getFile( bool, const QString &);
183 void request_file(const QString &); 185 void request_file(const QString &);
184 void multiResourceSyncStart( bool ); 186 void multiResourceSyncStart( bool );
185 187
186 public slots: 188 public slots:
187 void slotSyncMenu( int ); 189 void slotSyncMenu( int );
188 void slotClearMenu( int action ); 190 void slotClearMenu( int action );
189 void deleteCommandSocket(KCommandSocket*s, int state); 191 void deleteCommandSocket(KCommandSocket*s, int state);
190 void readFileFromSocket(); 192 void readFileFromSocket();
191 void fillSyncMenu(); 193 void fillSyncMenu();
192 194
193 private: 195 private:
194 void syncPi(); 196 void syncPi();
195 KServerSocket * mServerSocket; 197 KServerSocket * mServerSocket;
196 KPimPrefs* mPrefs; 198 KPimPrefs* mPrefs;
197 QString mDefFileName; 199 QString mDefFileName;
198 QString mCurrentSyncDevice; 200 QString mCurrentSyncDevice;
199 QString mCurrentSyncName; 201 QString mCurrentSyncName;
200 void quickSyncLocalFile(); 202 void quickSyncLocalFile();
201 bool syncWithFile( QString fn , bool quick ); 203 bool syncWithFile( QString fn , bool quick );
202 void syncLocalFile(); 204 void syncLocalFile();
203 void syncPhone(); 205 void syncPhone();
204 void syncSharp(); 206 void syncSharp();
205 void syncKDE(); 207 void syncKDE();
206 void syncOL(); 208 void syncOL();
207 bool syncExternalApplication(QString); 209 bool syncExternalApplication(QString);
208 int mCurrentSyncProfile ; 210 int mCurrentSyncProfile ;
209 void syncRemote( KSyncProfile* prof, bool ask = true); 211 void syncRemote( KSyncProfile* prof, bool ask = true);
210 bool edit_sync_options(); 212 bool edit_sync_options();
211 bool edit_pisync_options(); 213 bool edit_pisync_options();
212 int ringSync(); 214 int ringSync();
213 QString getPassword( ); 215 QString getPassword( );
214 bool mPisyncFinished; 216 bool mPisyncFinished;
215 QStringList mSpecificResources; 217 QStringList mSpecificResources;
216 QString mCurrentResourceLocal; 218 QString mCurrentResourceLocal;
217 QString mCurrentResourceRemote; 219 QString mCurrentResourceRemote;
218 bool mBlockSaveFlag; 220 bool mBlockSaveFlag;
219 QWidget* mParent; 221 QWidget* mParent;
220 KSyncInterface* mImplementation; 222 KSyncInterface* mImplementation;
221 TargetApp mTargetApp; 223 TargetApp mTargetApp;
222 QPopupMenu* mSyncMenu; 224 Q3PopupMenu* mSyncMenu;
223 QProgressBar* bar; 225 Q3ProgressBar* bar;
224 bool mSyncWithDesktop; 226 bool mSyncWithDesktop;
225 227
226private slots: 228private slots:
227 void displayErrorPort(); 229 void displayErrorPort();
228 void confSync(); 230 void confSync();
229 231
230 232
231}; 233};
232 234
233 235
234class KSyncInterface 236class KSyncInterface
235{ 237{
236 public : 238 public :
237 virtual void removeSyncInfo( QString syncProfile) = 0; 239 virtual void removeSyncInfo( QString syncProfile) = 0;
238 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; 240 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0;
239 virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/) 241 virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/)
240 { 242 {
241 // empty implementation, because some syncable applications do not 243 // empty implementation, because some syncable applications do not
242 // have an external(sharpdtm) syncmode, like pwmanager. 244 // have an external(sharpdtm) syncmode, like pwmanager.
243 return false; 245 return false;
244 } 246 }
245}; 247};
246 248
247 249
248#endif 250#endif
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 2b87298..fd5bbca 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -1,943 +1,947 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <q3groupbox.h>
27#include <qbuttongroup.h> 27#include <q3buttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qtextstream.h> 33#include <q3textstream.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qvbox.h> 35#include <q3vbox.h>
36#include <qhbox.h> 36#include <q3hbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <q3strlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qscrollview.h> 45#include <q3scrollview.h>
46#include <qvgroupbox.h> 46#include <q3vgroupbox.h>
47#include <qhgroupbox.h> 47#include <q3hgroupbox.h>
48//Added by qt3to4:
49#include <Q3HBoxLayout>
50#include <Q3GridLayout>
51#include <Q3Frame>
48 52
49#include <kcolorbutton.h> 53#include <kcolorbutton.h>
50#include <kdebug.h> 54#include <kdebug.h>
51#include <klocale.h> 55#include <klocale.h>
52#include <kglobal.h> 56#include <kglobal.h>
53#include <kfontdialog.h> 57#include <kfontdialog.h>
54#include <kmessagebox.h> 58#include <kmessagebox.h>
55#include <kcolordialog.h> 59#include <kcolordialog.h>
56#include <kiconloader.h> 60#include <kiconloader.h>
57#include <kemailsettings.h> 61#include <kemailsettings.h>
58#include <kstandarddirs.h> 62#include <kstandarddirs.h>
59#include <kfiledialog.h> 63#include <kfiledialog.h>
60#include <kmessagebox.h> 64#include <kmessagebox.h>
61 65
62//#include <kurlrequester.h> 66//#include <kurlrequester.h>
63#include <klineedit.h> 67#include <klineedit.h>
64#include "ksyncprofile.h" 68#include "ksyncprofile.h"
65 69
66 70
67//#include "koprefs.h" 71//#include "koprefs.h"
68 72
69#include "ksyncprefsdialog.h" 73#include "ksyncprefsdialog.h"
70//#include "koglobals.h" 74//#include "koglobals.h"
71 75
72 76
73KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 77KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
74 KDialog(parent,name,true) 78 KDialog(parent,name,true)
75{ 79{
76 80
77 setCaption( i18n("Synchronization Preferences")); 81 setCaption( i18n("Synchronization Preferences"));
78 82
79 mSyncProfiles.setAutoDelete( true ); 83 mSyncProfiles.setAutoDelete( true );
80 setupSyncAlgTab(); 84 setupSyncAlgTab();
81} 85}
82 86
83 87
84KSyncPrefsDialog::~KSyncPrefsDialog() 88KSyncPrefsDialog::~KSyncPrefsDialog()
85{ 89{
86} 90}
87 91
88void KSyncPrefsDialog::setupSyncAlgTab() 92void KSyncPrefsDialog::setupSyncAlgTab()
89{ 93{
90 QLabel * lab; 94 QLabel * lab;
91 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 95 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
92 QVBox * mainbox = new QVBox( this ); 96 Q3VBox * mainbox = new Q3VBox( this );
93 QScrollView* sv = new QScrollView( mainbox ); 97 Q3ScrollView* sv = new Q3ScrollView( mainbox );
94 QHBoxLayout * lay = new QHBoxLayout( this ); 98 Q3HBoxLayout * lay = new Q3HBoxLayout( this );
95 lay->addWidget( mainbox ); 99 lay->addWidget( mainbox );
96 QHBox * b_box = new QHBox( mainbox ); 100 Q3HBox * b_box = new Q3HBox( mainbox );
97 101
98 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 102 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 103 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
100 button = new QPushButton( i18n("Cancel"), b_box ); 104 button = new QPushButton( i18n("Cancel"), b_box );
101 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 105 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
102 //QBoxLayout * sl = new QVBoxLayout(this ); 106 //QBoxLayout * sl = new QVBoxLayout(this );
103 //sl->addWidget ( sv ); 107 //sl->addWidget ( sv );
104 sv->setResizePolicy ( QScrollView::AutoOneFit ); 108 sv->setResizePolicy ( Q3ScrollView::AutoOneFit );
105 QFrame *topFrame = new QFrame ( sv ); 109 Q3Frame *topFrame = new Q3Frame ( sv );
106 sv->addChild( topFrame ); 110 sv->addChild( topFrame );
107 mSetupSyncAlgTab = topFrame; 111 mSetupSyncAlgTab = topFrame;
108 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 112 Q3GridLayout *topLayout = new Q3GridLayout(topFrame,6,2);
109 topLayout->setSpacing(spacingHint()); 113 topLayout->setSpacing(spacingHint());
110 topLayout->setMargin(marginHint()); 114 topLayout->setMargin(marginHint());
111 115
112 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 116 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
113 int iii = 0; 117 int iii = 0;
114 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 118 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
115 //++iii; 119 //++iii;
116 120
117 mMyMachineName = new QLineEdit(topFrame); 121 mMyMachineName = new QLineEdit(topFrame);
118 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 122 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
119 topLayout->addWidget(lab ,iii,0); 123 topLayout->addWidget(lab ,iii,0);
120 topLayout->addWidget(mMyMachineName,iii,1); 124 topLayout->addWidget(mMyMachineName,iii,1);
121 ++iii; 125 ++iii;
122 126
123 QHBox* buttonbox = new QHBox( topFrame); 127 Q3HBox* buttonbox = new Q3HBox( topFrame);
124 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 128 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
125 ++iii; 129 ++iii;
126 button = new QPushButton( i18n("New profile"), buttonbox ); 130 button = new QPushButton( i18n("New profile"), buttonbox );
127 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 131 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
128 132
129 button = new QPushButton( i18n("Clone profile"), buttonbox ); 133 button = new QPushButton( i18n("Clone profile"), buttonbox );
130 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 134 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
131 135
132 button = new QPushButton( i18n("Delete profile"), buttonbox ); 136 button = new QPushButton( i18n("Delete profile"), buttonbox );
133 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 137 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
134 138
135 mProfileBox = new QComboBox(topFrame); 139 mProfileBox = new QComboBox(topFrame);
136 mProfileBox->setEditable ( true ); 140 mProfileBox->setEditable ( true );
137 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); 141 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion);
138 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 142 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
139 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 143 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
140 144
141 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 145 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
142 topLayout->addWidget(lab ,iii,0); 146 topLayout->addWidget(lab ,iii,0);
143 topLayout->addWidget(mProfileBox, iii,1); 147 topLayout->addWidget(mProfileBox, iii,1);
144 ++iii; 148 ++iii;
145 149
146 150
147 151
148 QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); 152 Q3HGroupBox *iims = new Q3HGroupBox( i18n("Multiple Sync options"), topFrame);
149 new QLabel( i18n("Include in multiple "), iims ); 153 new QLabel( i18n("Include in multiple "), iims );
150 mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); 154 mIncludeInRing = new QCheckBox( i18n("calendar "), iims );
151 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); 155 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims );
152 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); 156 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims );
153 new QLabel( i18n(" sync"), iims ); 157 new QLabel( i18n(" sync"), iims );
154 topLayout->addMultiCellWidget(iims, iii,iii,0,1); 158 topLayout->addMultiCellWidget(iims, iii,iii,0,1);
155 ++iii; 159 ++iii;
156 QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); 160 Q3VGroupBox* gb0 = new Q3VGroupBox( i18n("Sync algo options"), topFrame);
157 topLayout->addMultiCellWidget(gb0, iii,iii,0,1); 161 topLayout->addMultiCellWidget(gb0, iii,iii,0,1);
158 ++iii; 162 ++iii;
159 QButtonGroup* gr; 163 Q3ButtonGroup* gr;
160 { 164 {
161 QVGroupBox* topFrame = gb0; 165 Q3VGroupBox* topFrame = gb0;
162 166
163 167
164 168
165 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 169 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
166 //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 170 //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
167 //++iii; 171 //++iii;
168 gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 172 gr = new Q3ButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
169 //topLayout->addMultiCellWidget(gr, iii,iii,0,1); 173 //topLayout->addMultiCellWidget(gr, iii,iii,0,1);
170 //++iii; 174 //++iii;
171 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 175 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
172 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 176 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
173 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 177 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
174 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 178 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
175 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 179 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
176 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 180 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
177 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 181 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
178 182
179 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 183 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
180 //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 184 //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
181 //++iii; 185 //++iii;
182 186
183#if 0 187#if 0
184 QHGroupBox* gb51 = new QHGroupBox( i18n("Local resources to sync with:"), topFrame); 188 Q3HGroupBox* gb51 = new Q3HGroupBox( i18n("Local resources to sync with:"), topFrame);
185 { 189 {
186 QVBox * fibo2 = new QVBox ( gb51 ); 190 Q3VBox * fibo2 = new Q3VBox ( gb51 );
187 new QLabel ( i18n("Calendar resources:"), fibo2 ); 191 new QLabel ( i18n("Calendar resources:"), fibo2 );
188 //mFilterInCal = new QComboBox( fibo2 ); 192 //mFilterInCal = new QComboBox( fibo2 );
189 fibo2 = new QVBox ( gb51 ); 193 fibo2 = new Q3VBox ( gb51 );
190 new QLabel ( i18n("Addressbook resources:"), fibo2 ); 194 new QLabel ( i18n("Addressbook resources:"), fibo2 );
191 //mFilterInAB = new QComboBox( fibo2 ); 195 //mFilterInAB = new QComboBox( fibo2 );
192 } 196 }
193#endif 197#endif
194 QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); 198 Q3HGroupBox* gb5 = new Q3HGroupBox( i18n("Apply filter when adding data to local:"), topFrame);
195 QVBox * fibo2 = new QVBox ( gb5 ); 199 Q3VBox * fibo2 = new Q3VBox ( gb5 );
196 new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); 200 new QLabel ( i18n("Incoming calendar filter:"), fibo2 );
197 mFilterInCal = new QComboBox( fibo2 ); 201 mFilterInCal = new QComboBox( fibo2 );
198 fibo2 = new QVBox ( gb5 ); 202 fibo2 = new Q3VBox ( gb5 );
199 new QLabel ( i18n("Incoming addressbook filter:"), fibo2 ); 203 new QLabel ( i18n("Incoming addressbook filter:"), fibo2 );
200 mFilterInAB = new QComboBox( fibo2 ); 204 mFilterInAB = new QComboBox( fibo2 );
201 205
202 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); 206 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame );
203 // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 207 // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
204 // ++iii; 208 // ++iii;
205 209
206 QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); 210 Q3VGroupBox* gb2 = new Q3VGroupBox( i18n("Write back options"), topFrame);
207 //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); 211 //topLayout->addMultiCellWidget(gb2, iii,iii,0,1);
208 //++iii; 212 //++iii;
209 { 213 {
210 QVGroupBox*topFrame = gb2; 214 Q3VGroupBox*topFrame = gb2;
211 mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); 215 mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame );
212 QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); 216 Q3HGroupBox* gb4 = new Q3HGroupBox( i18n("Apply filter when adding data to remote:"), topFrame);
213 QVBox * fibo = new QVBox ( gb4 ); 217 Q3VBox * fibo = new Q3VBox ( gb4 );
214 new QLabel ( i18n("Outgoing calendar filter:"), fibo ); 218 new QLabel ( i18n("Outgoing calendar filter:"), fibo );
215 mFilterOutCal = new QComboBox( fibo ); 219 mFilterOutCal = new QComboBox( fibo );
216 fibo = new QVBox ( gb4 ); 220 fibo = new Q3VBox ( gb4 );
217 new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); 221 new QLabel ( i18n("Outgoing addressbook filter:"), fibo );
218 mFilterOutAB = new QComboBox( fibo ); 222 mFilterOutAB = new QComboBox( fibo );
219 //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 223 //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
220 //++iii; 224 //++iii;
221 mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); 225 mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame );
222 //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); 226 //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1);
223 //++iii; 227 //++iii;
224 QVGroupBox* gb3 = new QVGroupBox( i18n("Time period"), topFrame); 228 Q3VGroupBox* gb3 = new Q3VGroupBox( i18n("Time period"), topFrame);
225 connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); 229 connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) );
226 230
227 new QLabel( i18n("From ") , gb3 ); 231 new QLabel( i18n("From ") , gb3 );
228 QHBox * tf1 = new QHBox ( gb3 ); 232 Q3HBox * tf1 = new Q3HBox ( gb3 );
229 mWriteBackPastWeeks= new QSpinBox(1,104, 1, tf1 ); 233 mWriteBackPastWeeks= new QSpinBox(1,104, 1, tf1 );
230 mWriteBackPastWeeks->setMaximumWidth( 100 ); 234 mWriteBackPastWeeks->setMaximumWidth( 100 );
231 new QLabel( i18n(" weeks in the past to ") ,tf1 ); 235 new QLabel( i18n(" weeks in the past to ") ,tf1 );
232 QHBox * tf2 = new QHBox ( gb3 ); 236 Q3HBox * tf2 = new Q3HBox ( gb3 );
233 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, tf2); 237 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, tf2);
234 mWriteBackFutureWeeks->setMaximumWidth( 100 ); 238 mWriteBackFutureWeeks->setMaximumWidth( 100 );
235 new QLabel( i18n(" weeks in the future ") , tf2 ); 239 new QLabel( i18n(" weeks in the future ") , tf2 );
236 //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); 240 //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1);
237 //++iii; 241 //++iii;
238 gb3->setEnabled( false ); 242 gb3->setEnabled( false );
239 connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); 243 connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) );
240 } 244 }
241 connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); 245 connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) );
242 246
243 } 247 }
244 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 248 proGr = new Q3ButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
245 gr = proGr; 249 gr = proGr;
246 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 250 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
247 ++iii; 251 ++iii;
248 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 252 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
249 mIsPi = new QRadioButton ( i18n("Pi-Sync - all calendars ( direct Kx/Pi to Kx/Pi sync )"), gr ); 253 mIsPi = new QRadioButton ( i18n("Pi-Sync - all calendars ( direct Kx/Pi to Kx/Pi sync )"), gr );
250 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 254 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
251 mIsPiSpecific = new QRadioButton ( i18n("Pi-Sync - selected calendars ( direct Kx/Pi to Kx/Pi sync )"), gr ); 255 mIsPiSpecific = new QRadioButton ( i18n("Pi-Sync - selected calendars ( direct Kx/Pi to Kx/Pi sync )"), gr );
252 connect (mIsPiSpecific, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 256 connect (mIsPiSpecific, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
253 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 257 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
254 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 258 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
255 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); 259 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr );
256 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 260 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
257 261
258 QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); 262 Q3VGroupBox* gb1 = new Q3VGroupBox( i18n("Profile kind specific settings"), topFrame);
259 topLayout->addMultiCellWidget(gb1, iii,iii,0,1); 263 topLayout->addMultiCellWidget(gb1, iii,iii,0,1);
260 ++iii; 264 ++iii;
261 265
262 // ****************************************** 266 // ******************************************
263 // Profile kind specific settings 267 // Profile kind specific settings
264 { 268 {
265 // *** phone ******************************* 269 // *** phone *******************************
266 QVGroupBox* topFrame = gb1; 270 Q3VGroupBox* topFrame = gb1;
267 phoneWidget = new QVBox( topFrame); 271 phoneWidget = new Q3VBox( topFrame);
268 //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); 272 //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1);
269 //++iii; 273 //++iii;
270 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); 274 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget );
271 QHBox* temphb = new QHBox( phoneWidget ); 275 Q3HBox* temphb = new Q3HBox( phoneWidget );
272 new QLabel( i18n("I/O device: "), temphb ); 276 new QLabel( i18n("I/O device: "), temphb );
273 mPhoneDevice = new QLineEdit( temphb); 277 mPhoneDevice = new QLineEdit( temphb);
274 button = new QPushButton( i18n("Help..."), temphb ); 278 button = new QPushButton( i18n("Help..."), temphb );
275 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); 279 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) );
276 280
277 281
278 temphb = new QHBox( phoneWidget ); 282 temphb = new Q3HBox( phoneWidget );
279 new QLabel( i18n("Connection: "), temphb ); 283 new QLabel( i18n("Connection: "), temphb );
280 mPhoneConnection = new QLineEdit( temphb); 284 mPhoneConnection = new QLineEdit( temphb);
281 button = new QPushButton( i18n("Help..."), temphb ); 285 button = new QPushButton( i18n("Help..."), temphb );
282 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); 286 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) );
283 287
284 288
285 temphb = new QHBox( phoneWidget ); 289 temphb = new Q3HBox( phoneWidget );
286 new QLabel( i18n("Model(opt.): "), temphb ); 290 new QLabel( i18n("Model(opt.): "), temphb );
287 mPhoneModel = new QLineEdit( temphb); 291 mPhoneModel = new QLineEdit( temphb);
288 button = new QPushButton( i18n("Help..."), temphb ); 292 button = new QPushButton( i18n("Help..."), temphb );
289 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); 293 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) );
290 294
291 // *** local******************************* 295 // *** local*******************************
292 localFileWidget = new QVBox( topFrame); 296 localFileWidget = new Q3VBox( topFrame);
293 //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 297 //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
294 //++iii; 298 //++iii;
295 temphb = new QHBox( localFileWidget ); 299 temphb = new Q3HBox( localFileWidget );
296 300
297 lab = new QLabel( i18n("Local file Cal:"), temphb ); 301 lab = new QLabel( i18n("Local file Cal:"), temphb );
298 lab = new QLabel( i18n("Local file ABook:"), temphb ); 302 lab = new QLabel( i18n("Local file ABook:"), temphb );
299 lab = new QLabel( i18n("Local file PWMgr:"), temphb ); 303 lab = new QLabel( i18n("Local file PWMgr:"), temphb );
300 temphb = new QHBox( localFileWidget ); 304 temphb = new Q3HBox( localFileWidget );
301 button = new QPushButton( i18n("Choose..."), temphb ); 305 button = new QPushButton( i18n("Choose..."), temphb );
302 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 306 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
303 button = new QPushButton( i18n("Choose..."), temphb ); 307 button = new QPushButton( i18n("Choose..."), temphb );
304 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); 308 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) );
305 button = new QPushButton( i18n("Choose..."), temphb ); 309 button = new QPushButton( i18n("Choose..."), temphb );
306 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); 310 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) );
307 temphb = new QHBox( localFileWidget ); 311 temphb = new Q3HBox( localFileWidget );
308 312
309 mRemoteFile = new QLineEdit( temphb); 313 mRemoteFile = new QLineEdit( temphb);
310 mRemoteFileAB = new QLineEdit( temphb); 314 mRemoteFileAB = new QLineEdit( temphb);
311 mRemoteFilePWM = new QLineEdit( temphb); 315 mRemoteFilePWM = new QLineEdit( temphb);
312 mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); 316 mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget );
313 317
314 318
315 // *** remote******************************* 319 // *** remote*******************************
316 remoteFileWidget = new QVBox( topFrame); 320 remoteFileWidget = new Q3VBox( topFrame);
317 //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 321 //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
318 //++iii; 322 //++iii;
319 temphb = new QHBox( remoteFileWidget ); 323 temphb = new Q3HBox( remoteFileWidget );
320 new QLabel( i18n("Calendar:"), temphb); 324 new QLabel( i18n("Calendar:"), temphb);
321 new QLabel( i18n("AddressBook:"), temphb); 325 new QLabel( i18n("AddressBook:"), temphb);
322 new QLabel( i18n("PWManager:"), temphb); 326 new QLabel( i18n("PWManager:"), temphb);
323 327
324 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 328 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
325 temphb = new QHBox( remoteFileWidget ); 329 temphb = new Q3HBox( remoteFileWidget );
326 mRemotePrecommand = new QLineEdit(temphb); 330 mRemotePrecommand = new QLineEdit(temphb);
327 mRemotePrecommandAB = new QLineEdit(temphb); 331 mRemotePrecommandAB = new QLineEdit(temphb);
328 mRemotePrecommandPWM = new QLineEdit(temphb); 332 mRemotePrecommandPWM = new QLineEdit(temphb);
329 333
330 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 334 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
331 temphb = new QHBox( remoteFileWidget ); 335 temphb = new Q3HBox( remoteFileWidget );
332 mLocalTempFile = new QLineEdit(temphb); 336 mLocalTempFile = new QLineEdit(temphb);
333 mLocalTempFileAB = new QLineEdit(temphb); 337 mLocalTempFileAB = new QLineEdit(temphb);
334 mLocalTempFilePWM = new QLineEdit(temphb); 338 mLocalTempFilePWM = new QLineEdit(temphb);
335 339
336 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 340 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
337 temphb = new QHBox( remoteFileWidget ); 341 temphb = new Q3HBox( remoteFileWidget );
338 mRemotePostcommand = new QLineEdit(temphb ); 342 mRemotePostcommand = new QLineEdit(temphb );
339 mRemotePostcommandAB = new QLineEdit(temphb ); 343 mRemotePostcommandAB = new QLineEdit(temphb );
340 mRemotePostcommandPWM = new QLineEdit(temphb ); 344 mRemotePostcommandPWM = new QLineEdit(temphb );
341 mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); 345 mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget );
342 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 346 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
343 temphb = new QHBox( remoteFileWidget ); 347 temphb = new Q3HBox( remoteFileWidget );
344 button = new QPushButton( i18n("ssh/scp"), temphb ); 348 button = new QPushButton( i18n("ssh/scp"), temphb );
345 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 349 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
346 button = new QPushButton( i18n("ftp"), temphb ); 350 button = new QPushButton( i18n("ftp"), temphb );
347 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 351 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
348 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 352 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
349 353
350 // *** pi-sync******************************* 354 // *** pi-sync*******************************
351 piWidget = new QVBox( topFrame); 355 piWidget = new Q3VBox( topFrame);
352 //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); 356 //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1);
353 //++iii; 357 //++iii;
354 temphb = new QHBox( piWidget ); 358 temphb = new Q3HBox( piWidget );
355 new QLabel( i18n("Calendar:"), temphb); 359 new QLabel( i18n("Calendar:"), temphb);
356 new QLabel( i18n("AddressBook:"), temphb); 360 new QLabel( i18n("AddressBook:"), temphb);
357 new QLabel( i18n("PWManager:"), temphb); 361 new QLabel( i18n("PWManager:"), temphb);
358 362
359 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); 363 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget);
360 temphb = new QHBox( piWidget ); 364 temphb = new Q3HBox( piWidget );
361 mRemotePw = new QLineEdit(temphb); 365 mRemotePw = new QLineEdit(temphb);
362 mRemotePwAB = new QLineEdit(temphb); 366 mRemotePwAB = new QLineEdit(temphb);
363 mRemotePwPWM = new QLineEdit(temphb); 367 mRemotePwPWM = new QLineEdit(temphb);
364 368
365 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); 369 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget);
366 temphb = new QHBox( piWidget ); 370 temphb = new Q3HBox( piWidget );
367 mRemoteIP = new QLineEdit(temphb); 371 mRemoteIP = new QLineEdit(temphb);
368 mRemoteIPAB = new QLineEdit(temphb); 372 mRemoteIPAB = new QLineEdit(temphb);
369 mRemoteIPPWM = new QLineEdit(temphb); 373 mRemoteIPPWM = new QLineEdit(temphb);
370 374
371 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); 375 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget);
372 temphb = new QHBox( piWidget ); 376 temphb = new Q3HBox( piWidget );
373 mRemotePort = new QLineEdit(temphb); 377 mRemotePort = new QLineEdit(temphb);
374 mRemotePortAB = new QLineEdit(temphb); 378 mRemotePortAB = new QLineEdit(temphb);
375 mRemotePortPWM = new QLineEdit(temphb); 379 mRemotePortPWM = new QLineEdit(temphb);
376 380
377 lab = new QLabel( i18n("Local/remote Resource sync partners (Leave empty to not sync)"), piWidget); 381 lab = new QLabel( i18n("Local/remote Resource sync partners (Leave empty to not sync)"), piWidget);
378 mTableBox = new QHBox( piWidget ); 382 mTableBox = new Q3HBox( piWidget );
379 mResTableKopi = new QTable( 1, 1, mTableBox ); 383 mResTableKopi = new Q3Table( 1, 1, mTableBox );
380 mResTableKapi = new QTable( 1, 1, mTableBox ); 384 mResTableKapi = new Q3Table( 1, 1, mTableBox );
381 mResTablePwmpi = new QTable( 1, 1, mTableBox ); 385 mResTablePwmpi = new Q3Table( 1, 1, mTableBox );
382 mResTableKopi->horizontalHeader()->setLabel( 0, i18n("Remote") ); 386 mResTableKopi->horizontalHeader()->setLabel( 0, i18n("Remote") );
383 mResTableKapi->horizontalHeader()->setLabel( 0, i18n("Remote") ); 387 mResTableKapi->horizontalHeader()->setLabel( 0, i18n("Remote") );
384 mResTablePwmpi->horizontalHeader()->setLabel( 0, i18n("Remote") ); 388 mResTablePwmpi->horizontalHeader()->setLabel( 0, i18n("Remote") );
385 mResTableKopi->setLeftMargin( 80 ); 389 mResTableKopi->setLeftMargin( 80 );
386 mResTableKapi->setLeftMargin( 80 ); 390 mResTableKapi->setLeftMargin( 80 );
387 } 391 }
388 // ****************************************** 392 // ******************************************
389 // Profile kind specific settings END 393 // Profile kind specific settings END
390 394
391} 395}
392 396
393void KSyncPrefsDialog::readResources() 397void KSyncPrefsDialog::readResources()
394{ 398{
395 mResourcesKopi.clear(); 399 mResourcesKopi.clear();
396 KConfig fc(locateLocal("config","kopicalendarrc")); 400 KConfig fc(locateLocal("config","kopicalendarrc"));
397 fc.setGroup("CC"); 401 fc.setGroup("CC");
398 int numCals = fc.readNumEntry("NumberCalendars",0 ); 402 int numCals = fc.readNumEntry("NumberCalendars",0 );
399 int curCal = 1; 403 int curCal = 1;
400 while ( curCal <= numCals ) { 404 while ( curCal <= numCals ) {
401 QString prefix = "Cal_" +QString::number( curCal ); 405 QString prefix = "Cal_" +QString::number( curCal );
402 QString name = fc.readEntry( prefix+"_Name", "Calendar"); 406 QString name = fc.readEntry( prefix+"_Name", "Calendar");
403 mResourcesKopi.append( name ); 407 mResourcesKopi.append( name );
404 ++curCal; 408 ++curCal;
405 } 409 }
406 mResTableKopi->setNumRows( mResourcesKopi.count() ); 410 mResTableKopi->setNumRows( mResourcesKopi.count() );
407 int i; 411 int i;
408 for ( i = 0;i < mResourcesKopi.count(); ++i ) { 412 for ( i = 0;i < mResourcesKopi.count(); ++i ) {
409 mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] ); 413 mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] );
410 } 414 }
411 415
412 mResourcesKapi.clear(); 416 mResourcesKapi.clear();
413 417
414 KConfig conf ( locateLocal("config", "kabcrc") ); 418 KConfig conf ( locateLocal("config", "kabcrc") );
415 419
416 conf.setGroup( "General" ); 420 conf.setGroup( "General" );
417 421
418 QStringList keys = conf.readListEntry( "ResourceKeys" ); 422 QStringList keys = conf.readListEntry( "ResourceKeys" );
419 //keys += conf->readListEntry( "PassiveResourceKeys" ); 423 //keys += conf->readListEntry( "PassiveResourceKeys" );
420 424
421 //QString standardKey = mConfig->readEntry( "Standard" ); 425 //QString standardKey = mConfig->readEntry( "Standard" );
422 426
423 for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) { 427 for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) {
424 conf.setGroup("Resource_"+ (*it) ); 428 conf.setGroup("Resource_"+ (*it) );
425 QString name = conf.readEntry( "ResourceName" ); 429 QString name = conf.readEntry( "ResourceName" );
426 mResourcesKapi.append( name ); 430 mResourcesKapi.append( name );
427 } 431 }
428 mResTableKapi->setNumRows( mResourcesKapi.count() ); 432 mResTableKapi->setNumRows( mResourcesKapi.count() );
429 for ( i = 0;i < mResourcesKopi.count(); ++i ) { 433 for ( i = 0;i < mResourcesKopi.count(); ++i ) {
430 mResTableKapi->verticalHeader ()->setLabel( i, mResourcesKapi[i] ); 434 mResTableKapi->verticalHeader ()->setLabel( i, mResourcesKapi[i] );
431 } 435 }
432 436
433 437
434} 438}
435void KSyncPrefsDialog::readFilter() 439void KSyncPrefsDialog::readFilter()
436{ 440{
437 mFilterKapi.clear(); 441 mFilterKapi.clear();
438 mFilterKopi.clear(); 442 mFilterKopi.clear();
439 KConfig cfgko(locateLocal("config","korganizerrc")); 443 KConfig cfgko(locateLocal("config","korganizerrc"));
440 KConfig cfgka(locateLocal("config","kaddressbookrc")); 444 KConfig cfgka(locateLocal("config","kaddressbookrc"));
441 cfgko.setGroup("General"); 445 cfgko.setGroup("General");
442 mFilterKopi = cfgko.readListEntry("CalendarFilters"); 446 mFilterKopi = cfgko.readListEntry("CalendarFilters");
443 cfgka.setGroup("Filter"); 447 cfgka.setGroup("Filter");
444 int count = cfgka.readNumEntry( "Count", 0 ); 448 int count = cfgka.readNumEntry( "Count", 0 );
445 for ( int i = 0; i < count; i++ ) { 449 for ( int i = 0; i < count; i++ ) {
446 cfgka.setGroup("Filter_"+QString::number( i ) ); 450 cfgka.setGroup("Filter_"+QString::number( i ) );
447 mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); 451 mFilterKapi.append( cfgka.readEntry("Name", "internal error") );
448 } 452 }
449 mFilterOutCal->clear(); 453 mFilterOutCal->clear();
450 mFilterInCal->clear(); 454 mFilterInCal->clear();
451 mFilterOutAB->clear(); 455 mFilterOutAB->clear();
452 mFilterInAB->clear(); 456 mFilterInAB->clear();
453 QStringList temp = mFilterKopi; 457 QStringList temp = mFilterKopi;
454 temp.prepend(i18n("No Filter") ); 458 temp.prepend(i18n("No Filter") );
455 mFilterOutCal->insertStringList( temp ); 459 mFilterOutCal->insertStringList( temp );
456 mFilterInCal->insertStringList( temp ); 460 mFilterInCal->insertStringList( temp );
457 temp = mFilterKapi; 461 temp = mFilterKapi;
458 temp.prepend(i18n("No Filter") ); 462 temp.prepend(i18n("No Filter") );
459 mFilterOutAB->insertStringList( temp ); 463 mFilterOutAB->insertStringList( temp );
460 mFilterInAB->insertStringList( temp ); 464 mFilterInAB->insertStringList( temp );
461} 465}
462 466
463void KSyncPrefsDialog::slotOK() 467void KSyncPrefsDialog::slotOK()
464{ 468{
465 if ( mMyMachineName->text() == "undefined" ) { 469 if ( mMyMachineName->text() == "undefined" ) {
466 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 470 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
467 return; 471 return;
468 } 472 }
469 int i; 473 int i;
470 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 474 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
471 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 475 if ( mSyncProfileNames.count( mSyncProfileNames[i]) > 1 ) {
472 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 476 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
473 return; 477 return;
474 } 478 }
475 } 479 }
476 usrWriteConfig(); 480 usrWriteConfig();
477 QDialog::accept(); 481 QDialog::accept();
478} 482}
479void KSyncPrefsDialog::accept() 483void KSyncPrefsDialog::accept()
480{ 484{
481 slotOK(); 485 slotOK();
482} 486}
483void KSyncPrefsDialog::chooseFile() 487void KSyncPrefsDialog::chooseFile()
484{ 488{
485 QString fn = QDir::homeDirPath(); 489 QString fn = QDir::homeDirPath();
486 490
487 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 491 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
488 if ( fn == "" ) 492 if ( fn == "" )
489 return; 493 return;
490 mRemoteFile->setText( fn ); 494 mRemoteFile->setText( fn );
491} 495}
492 496
493void KSyncPrefsDialog::chooseFileAB() 497void KSyncPrefsDialog::chooseFileAB()
494{ 498{
495 QString fn = QDir::homeDirPath(); 499 QString fn = QDir::homeDirPath();
496 500
497 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); 501 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this );
498 if ( fn == "" ) 502 if ( fn == "" )
499 return; 503 return;
500 mRemoteFileAB->setText( fn ); 504 mRemoteFileAB->setText( fn );
501} 505}
502 506
503void KSyncPrefsDialog::chooseFilePWM() 507void KSyncPrefsDialog::chooseFilePWM()
504{ 508{
505 QString fn = QDir::homeDirPath(); 509 QString fn = QDir::homeDirPath();
506 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); 510 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this );
507 if ( fn == "" ) 511 if ( fn == "" )
508 return; 512 return;
509 mRemoteFilePWM->setText( fn ); 513 mRemoteFilePWM->setText( fn );
510} 514}
511void KSyncPrefsDialog::updateMyCaption() 515void KSyncPrefsDialog::updateMyCaption()
512{ 516{
513 setCaption( mProfileBox->currentText() + " : " +i18n("Synchronization Preferences")); 517 setCaption( mProfileBox->currentText() + " : " +i18n("Synchronization Preferences"));
514} 518}
515void KSyncPrefsDialog::textChanged( const QString & s ) 519void KSyncPrefsDialog::textChanged( const QString & s )
516{ 520{
517 if ( mProfileBox->count() == 0 ) 521 if ( mProfileBox->count() == 0 )
518 return; 522 return;
519 if ( currentSelection < 3 ) { 523 if ( currentSelection < 3 ) {
520 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 524 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
521 mProfileBox->blockSignals( true ); 525 mProfileBox->blockSignals( true );
522 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 526 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
523 mProfileBox->blockSignals( false ); 527 mProfileBox->blockSignals( false );
524 return; 528 return;
525 } 529 }
526 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 530 //qDebug("cur i %d ",mProfileBox-> currentItem () );
527 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 531 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
528 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 532 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
529 prof->setName( s ); 533 prof->setName( s );
530 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 534 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
531 updateMyCaption(); 535 updateMyCaption();
532} 536}
533void KSyncPrefsDialog::profileChanged( int item ) 537void KSyncPrefsDialog::profileChanged( int item )
534{ 538{
535 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); 539 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
536 KSyncProfile* prof; 540 KSyncProfile* prof;
537 saveProfile(); 541 saveProfile();
538 readFilter(); 542 readFilter();
539 readResources(); 543 readResources();
540 currentSelection = item; 544 currentSelection = item;
541 prof = mSyncProfiles.at(item) ; 545 prof = mSyncProfiles.at(item) ;
542 546
543 mRemotePw->setText(prof->getRemotePw()); 547 mRemotePw->setText(prof->getRemotePw());
544 mRemoteIP->setText(prof->getRemoteIP()); 548 mRemoteIP->setText(prof->getRemoteIP());
545 mRemotePort->setText(prof->getRemotePort()); 549 mRemotePort->setText(prof->getRemotePort());
546 550
547 mRemotePwAB->setText(prof->getRemotePwAB()); 551 mRemotePwAB->setText(prof->getRemotePwAB());
548 mRemoteIPAB->setText(prof->getRemoteIPAB()); 552 mRemoteIPAB->setText(prof->getRemoteIPAB());
549 mRemotePortAB->setText(prof->getRemotePortAB()); 553 mRemotePortAB->setText(prof->getRemotePortAB());
550 554
551 mRemotePwPWM->setText(prof->getRemotePwPWM()); 555 mRemotePwPWM->setText(prof->getRemotePwPWM());
552 mRemoteIPPWM->setText(prof->getRemoteIPPWM()); 556 mRemoteIPPWM->setText(prof->getRemoteIPPWM());
553 mRemotePortPWM->setText(prof->getRemotePortPWM()); 557 mRemotePortPWM->setText(prof->getRemotePortPWM());
554 558
555 mRemotePrecommand->setText(prof->getPreSyncCommand()); 559 mRemotePrecommand->setText(prof->getPreSyncCommand());
556 mRemotePostcommand->setText(prof->getPostSyncCommand()); 560 mRemotePostcommand->setText(prof->getPostSyncCommand());
557 mLocalTempFile->setText(prof->getLocalTempFile()); 561 mLocalTempFile->setText(prof->getLocalTempFile());
558 mRemoteFile->setText(prof->getRemoteFileName()) ; 562 mRemoteFile->setText(prof->getRemoteFileName()) ;
559 563
560 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); 564 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
561 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); 565 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
562 mLocalTempFileAB->setText(prof->getLocalTempFileAB()); 566 mLocalTempFileAB->setText(prof->getLocalTempFileAB());
563 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; 567 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
564 568
565 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); 569 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
566 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); 570 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
567 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); 571 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
568 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; 572 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
569 573
570 if ( mWriteContactToSIM ) 574 if ( mWriteContactToSIM )
571 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); 575 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
572 mPhoneDevice->setText(prof->getPhoneDevice()); 576 mPhoneDevice->setText(prof->getPhoneDevice());
573 mPhoneConnection->setText(prof->getPhoneConnection()); 577 mPhoneConnection->setText(prof->getPhoneConnection());
574 mPhoneModel->setText(prof->getPhoneModel()); 578 mPhoneModel->setText(prof->getPhoneModel());
575 579
576 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 580 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
577 mAskForPreferences->setChecked( prof->getAskForPreferences()); 581 mAskForPreferences->setChecked( prof->getAskForPreferences());
578 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 582 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
579 mWriteBackFile->setChecked( prof->getWriteBackFile()); 583 mWriteBackFile->setChecked( prof->getWriteBackFile());
580 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 584 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
581 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); 585 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
582 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); 586 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
583 mWriteBackFuture->setChecked( prof->getWriteBackFuture()); 587 mWriteBackFuture->setChecked( prof->getWriteBackFuture());
584 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); 588 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
585 mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() ); 589 mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() );
586 590
587 mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 ); 591 mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 );
588 mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 ); 592 mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 );
589 mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 ); 593 mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 );
590 mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 ); 594 mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 );
591 595
592 switch ( prof->getSyncPrefs() ) { 596 switch ( prof->getSyncPrefs() ) {
593 case 0: 597 case 0:
594 loc->setChecked( true); 598 loc->setChecked( true);
595 break; 599 break;
596 case 1: 600 case 1:
597 rem->setChecked( true ); 601 rem->setChecked( true );
598 break; 602 break;
599 case 2: 603 case 2:
600 newest->setChecked( true); 604 newest->setChecked( true);
601 break; 605 break;
602 case 3: 606 case 3:
603 ask->setChecked( true); 607 ask->setChecked( true);
604 break; 608 break;
605 case 4: 609 case 4:
606 f_loc->setChecked( true); 610 f_loc->setChecked( true);
607 break; 611 break;
608 case 5: 612 case 5:
609 f_rem->setChecked( true); 613 f_rem->setChecked( true);
610 break; 614 break;
611 case 6: 615 case 6:
612 //both->setChecked( true); 616 //both->setChecked( true);
613 break; 617 break;
614 default: 618 default:
615 break; 619 break;
616 } 620 }
617 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 621 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
618 mIsPhone->setChecked(prof->getIsPhoneSync()) ; 622 mIsPhone->setChecked(prof->getIsPhoneSync()) ;
619 mIsPi->setChecked(prof->getIsPiSync()) ; 623 mIsPi->setChecked(prof->getIsPiSync()) ;
620 mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ; 624 mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ;
621 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; 625 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ;
622 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; 626 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ;
623 627
624 628
625 QStringList res = QStringList::split( ":",prof->getResSpecKopi(), true ); 629 QStringList res = QStringList::split( ":",prof->getResSpecKopi(), true );
626 int add = res.count()/2; 630 int add = res.count()/2;
627 int i; 631 int i;
628 for ( i = 0;i < add ; ++i ) { 632 for ( i = 0;i < add ; ++i ) {
629 mResTableKopi->setText( i, 0, res[i+add] ); 633 mResTableKopi->setText( i, 0, res[i+add] );
630 } 634 }
631 res = QStringList::split( ":",prof->getResSpecKapi(), true); 635 res = QStringList::split( ":",prof->getResSpecKapi(), true);
632 add = res.count()/2; 636 add = res.count()/2;
633 for ( i = 0;i < add; ++i ) { 637 for ( i = 0;i < add; ++i ) {
634 mResTableKapi->setText( i, 0, res[i+add] ); 638 mResTableKapi->setText( i, 0, res[i+add] );
635 } 639 }
636 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec()); 640 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec());
637 proGr->setEnabled( item > 2 ); 641 proGr->setEnabled( item > 2 );
638 if ( item < 3 ) { 642 if ( item < 3 ) {
639 localFileWidget->hide(); 643 localFileWidget->hide();
640 remoteFileWidget->hide(); 644 remoteFileWidget->hide();
641 phoneWidget->hide(); 645 phoneWidget->hide();
642 piWidget->hide(); 646 piWidget->hide();
643 647
644 } else 648 } else
645 kindChanged( prof->getIsLocalFileSync() ); 649 kindChanged( prof->getIsLocalFileSync() );
646 updateMyCaption(); 650 updateMyCaption();
647} 651}
648 652
649void KSyncPrefsDialog::fillSSH() 653void KSyncPrefsDialog::fillSSH()
650{ 654{
651 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 655 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
652 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 656 mLocalTempFile->setText("/tmp/mycalendar.ics" );
653 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 657 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
654 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 658 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
655 mLocalTempFileAB->setText("/tmp/std.vcf" ); 659 mLocalTempFileAB->setText("/tmp/std.vcf" );
656 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); 660 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
657 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 661 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
658 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 662 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
659 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); 663 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
660} 664}
661void KSyncPrefsDialog::fillFTP() 665void KSyncPrefsDialog::fillFTP()
662{ 666{
663 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 667 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
664 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 668 mLocalTempFile->setText("/tmp/mycalendar.ics" );
665 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 669 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
666 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); 670 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
667 mLocalTempFileAB->setText("/tmp/std.vcf" ); 671 mLocalTempFileAB->setText("/tmp/std.vcf" );
668 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 672 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
669 673
670 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); 674 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
671 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 675 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
672 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 676 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
673 677
674} 678}
675void KSyncPrefsDialog::kindChanged( bool b ) 679void KSyncPrefsDialog::kindChanged( bool b )
676{ 680{
677 681
678 if ( mIsLocal->isChecked () ) { 682 if ( mIsLocal->isChecked () ) {
679 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); 683 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() );
680 } else { 684 } else {
681 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); 685 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() );
682 } 686 }
683 687
684 if ( mIsLocal->isChecked () ) 688 if ( mIsLocal->isChecked () )
685 localFileWidget->show(); 689 localFileWidget->show();
686 else 690 else
687 localFileWidget->hide(); 691 localFileWidget->hide();
688 692
689 if ( mIsNotLocal->isChecked () ) 693 if ( mIsNotLocal->isChecked () )
690 remoteFileWidget->show(); 694 remoteFileWidget->show();
691 else 695 else
692 remoteFileWidget->hide(); 696 remoteFileWidget->hide();
693 697
694 if ( mIsPhone->isChecked () ) { 698 if ( mIsPhone->isChecked () ) {
695 phoneWidget->show(); 699 phoneWidget->show();
696 } 700 }
697 else { 701 else {
698 phoneWidget->hide(); 702 phoneWidget->hide();
699 } 703 }
700 704
701 if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) { 705 if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) {
702 piWidget->show(); 706 piWidget->show();
703 if (mIsPiSpecific->isChecked () ) { 707 if (mIsPiSpecific->isChecked () ) {
704 mTableBox->show(); 708 mTableBox->show();
705 } 709 }
706 else { 710 else {
707 mTableBox->hide(); 711 mTableBox->hide();
708 } 712 }
709 } 713 }
710 else { 714 else {
711 piWidget->hide(); 715 piWidget->hide();
712 } 716 }
713 717
714 718
715} 719}
716void KSyncPrefsDialog::deleteProfile() 720void KSyncPrefsDialog::deleteProfile()
717{ 721{
718 //qDebug("KSyncPrefsDialog::deleteProfile() "); 722 //qDebug("KSyncPrefsDialog::deleteProfile() ");
719 if ( currentSelection >= 0 ) { 723 if ( currentSelection >= 0 ) {
720 if ( currentSelection < 3 ) { 724 if ( currentSelection < 3 ) {
721 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 725 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
722 return; 726 return;
723 } 727 }
724 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 728 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
725 mSyncProfiles.remove( temp ); 729 mSyncProfiles.remove( temp );
726 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 730 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
727 insertProfiles(); 731 insertProfiles();
728 } 732 }
729} 733}
730 734
731void KSyncPrefsDialog::saveProfile() 735void KSyncPrefsDialog::saveProfile()
732{ 736{
733 KSyncProfile* prof; 737 KSyncProfile* prof;
734 if ( currentSelection >= 0 ) { 738 if ( currentSelection >= 0 ) {
735 prof = mSyncProfiles.at(currentSelection) ; 739 prof = mSyncProfiles.at(currentSelection) ;
736 740
737 prof->setRemotePw( mRemotePw->text()); 741 prof->setRemotePw( mRemotePw->text());
738 prof->setRemoteIP( mRemoteIP->text()); 742 prof->setRemoteIP( mRemoteIP->text());
739 prof->setRemotePort( mRemotePort->text()); 743 prof->setRemotePort( mRemotePort->text());
740 744
741 prof->setRemotePwAB( mRemotePwAB->text()); 745 prof->setRemotePwAB( mRemotePwAB->text());
742 prof->setRemoteIPAB( mRemoteIPAB->text()); 746 prof->setRemoteIPAB( mRemoteIPAB->text());
743 prof->setRemotePortAB( mRemotePortAB->text()); 747 prof->setRemotePortAB( mRemotePortAB->text());
744 748
745 prof->setRemotePwPWM( mRemotePwPWM->text()); 749 prof->setRemotePwPWM( mRemotePwPWM->text());
746 prof->setRemoteIPPWM( mRemoteIPPWM->text()); 750 prof->setRemoteIPPWM( mRemoteIPPWM->text());
747 prof->setRemotePortPWM( mRemotePortPWM->text()); 751 prof->setRemotePortPWM( mRemotePortPWM->text());
748 752
749 prof->setPreSyncCommand( mRemotePrecommand->text()); 753 prof->setPreSyncCommand( mRemotePrecommand->text());
750 prof->setPostSyncCommand( mRemotePostcommand->text() ); 754 prof->setPostSyncCommand( mRemotePostcommand->text() );
751 prof->setLocalTempFile( mLocalTempFile->text()); 755 prof->setLocalTempFile( mLocalTempFile->text());
752 prof->setRemoteFileName( mRemoteFile->text() ); 756 prof->setRemoteFileName( mRemoteFile->text() );
753 prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); 757 prof->setPreSyncCommandAB( mRemotePrecommandAB->text());
754 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); 758 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() );
755 prof->setLocalTempFileAB( mLocalTempFileAB->text()); 759 prof->setLocalTempFileAB( mLocalTempFileAB->text());
756 prof->setRemoteFileNameAB( mRemoteFileAB->text() ); 760 prof->setRemoteFileNameAB( mRemoteFileAB->text() );
757 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); 761 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text());
758 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); 762 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() );
759 prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); 763 prof->setLocalTempFilePWM( mLocalTempFilePWM->text());
760 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); 764 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() );
761 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 765 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
762 prof->setAskForPreferences( mAskForPreferences->isChecked()); 766 prof->setAskForPreferences( mAskForPreferences->isChecked());
763 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 767 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
764 prof->setWriteBackFile( mWriteBackFile->isChecked()); 768 prof->setWriteBackFile( mWriteBackFile->isChecked());
765 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 769 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
766 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); 770 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
767 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); 771 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() );
768 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 772 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
769 prof->setSyncPrefs( syncprefs); 773 prof->setSyncPrefs( syncprefs);
770 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 774 prof->setIsLocalFileSync( mIsLocal->isChecked() );
771 prof->setIsPhoneSync( mIsPhone->isChecked() ); 775 prof->setIsPhoneSync( mIsPhone->isChecked() );
772 prof->setIsPiSync( mIsPi->isChecked() ); 776 prof->setIsPiSync( mIsPi->isChecked() );
773 prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() ); 777 prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() );
774 prof->setIsKapiFile( mIsKapiFileL->isChecked() ); 778 prof->setIsKapiFile( mIsKapiFileL->isChecked() );
775 prof->setWriteBackFuture(mWriteBackFuture->isChecked()); 779 prof->setWriteBackFuture(mWriteBackFuture->isChecked());
776 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); 780 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
777 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); 781 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value());
778 if ( mWriteContactToSIM ) 782 if ( mWriteContactToSIM )
779 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); 783 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
780 prof->setPhoneDevice( mPhoneDevice->text() ); 784 prof->setPhoneDevice( mPhoneDevice->text() );
781 prof->setPhoneConnection( mPhoneConnection->text() ); 785 prof->setPhoneConnection( mPhoneConnection->text() );
782 prof->setPhoneModel( mPhoneModel->text() ); 786 prof->setPhoneModel( mPhoneModel->text() );
783 prof->setFilterInCal ( mFilterInCal->currentText ()); 787 prof->setFilterInCal ( mFilterInCal->currentText ());
784 prof->setFilterOutCal ( mFilterOutCal ->currentText ()); 788 prof->setFilterOutCal ( mFilterOutCal ->currentText ());
785 prof->setFilterInAB ( mFilterInAB ->currentText ()); 789 prof->setFilterInAB ( mFilterInAB ->currentText ());
786 prof->setFilterOutAB ( mFilterOutAB ->currentText ()); 790 prof->setFilterOutAB ( mFilterOutAB ->currentText ());
787 mProfileBox->setFocus(); 791 mProfileBox->setFocus();
788 if ( mIsPiSpecific->isChecked() ) { 792 if ( mIsPiSpecific->isChecked() ) {
789 793
790 QStringList res = mResourcesKopi; 794 QStringList res = mResourcesKopi;
791 int i; 795 int i;
792 for ( i = 0;i < mResourcesKopi.count(); ++i ) { 796 for ( i = 0;i < mResourcesKopi.count(); ++i ) {
793 res.append( mResTableKopi->text( i, 0 )); 797 res.append( mResTableKopi->text( i, 0 ));
794 } 798 }
795 prof->setResSpecKopi( res.join(":")); 799 prof->setResSpecKopi( res.join(":"));
796 res = mResourcesKapi; 800 res = mResourcesKapi;
797 for ( i = 0;i < mResourcesKapi.count(); ++i ) { 801 for ( i = 0;i < mResourcesKapi.count(); ++i ) {
798 res.append( mResTableKapi->text( i, 0 )); 802 res.append( mResTableKapi->text( i, 0 ));
799 } 803 }
800 prof->setResSpecKapi( res.join(":")); 804 prof->setResSpecKapi( res.join(":"));
801 } 805 }
802 } 806 }
803} 807}
804 808
805void KSyncPrefsDialog::insertProfiles() 809void KSyncPrefsDialog::insertProfiles()
806{ 810{
807 int curItem = mProfileBox->currentItem(); 811 int curItem = mProfileBox->currentItem();
808 mProfileBox->blockSignals( true ); 812 mProfileBox->blockSignals( true );
809 mProfileBox->clear(); 813 mProfileBox->clear();
810 mProfileBox->insertStringList (mSyncProfileNames ); 814 mProfileBox->insertStringList (mSyncProfileNames );
811 int item = mSyncProfileNames.count() -1; 815 int item = mSyncProfileNames.count() -1;
812 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 816 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
813 mProfileBox->setCurrentItem( curItem ); 817 mProfileBox->setCurrentItem( curItem );
814 else if ( item >= 0 ) { 818 else if ( item >= 0 ) {
815 mProfileBox->setCurrentItem( item ); 819 mProfileBox->setCurrentItem( item );
816 } 820 }
817 currentSelection = -1; 821 currentSelection = -1;
818 if ( mSyncProfileNames.count() > 0 ) { 822 if ( mSyncProfileNames.count() > 0 ) {
819 //qDebug(" profileChanged( mProfileBox->currentItem() "); 823 //qDebug(" profileChanged( mProfileBox->currentItem() ");
820 profileChanged( mProfileBox->currentItem() ); 824 profileChanged( mProfileBox->currentItem() );
821 currentSelection = mProfileBox->currentItem(); 825 currentSelection = mProfileBox->currentItem();
822 } 826 }
823 mProfileBox->blockSignals( false ); 827 mProfileBox->blockSignals( false );
824} 828}
825 829
826void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 830void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
827{ 831{
828 saveProfile(); 832 saveProfile();
829 mSyncProfiles.append( temp ); 833 mSyncProfiles.append( temp );
830 mSyncProfileNames << temp->getName(); 834 mSyncProfileNames << temp->getName();
831 insertProfiles(); 835 insertProfiles();
832 int last = mProfileBox->count() -1; 836 int last = mProfileBox->count() -1;
833 mProfileBox->blockSignals( true ); 837 mProfileBox->blockSignals( true );
834 mProfileBox->setCurrentItem( last ); 838 mProfileBox->setCurrentItem( last );
835 mProfileBox->blockSignals( false ); 839 mProfileBox->blockSignals( false );
836 profileChanged(last); 840 profileChanged(last);
837} 841}
838void KSyncPrefsDialog::newProfile() 842void KSyncPrefsDialog::newProfile()
839{ 843{
840 addProfile ( new KSyncProfile () ); 844 addProfile ( new KSyncProfile () );
841} 845}
842 846
843void KSyncPrefsDialog::cloneProfile() 847void KSyncPrefsDialog::cloneProfile()
844{ 848{
845 if ( currentSelection >= 0 ) 849 if ( currentSelection >= 0 )
846 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 850 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
847 else 851 else
848 newProfile(); 852 newProfile();
849} 853}
850 854
851void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 855void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
852{ 856{
853 mMyMachineName->setText( name ); 857 mMyMachineName->setText( name );
854 858
855} 859}
856QString KSyncPrefsDialog::getLocalMachineName ( ) 860QString KSyncPrefsDialog::getLocalMachineName ( )
857{ 861{
858 return mMyMachineName->text(); 862 return mMyMachineName->text();
859} 863}
860 864
861QStringList KSyncPrefsDialog::getSyncProfileNames() 865QStringList KSyncPrefsDialog::getSyncProfileNames()
862{ 866{
863 return mSyncProfileNames; 867 return mSyncProfileNames;
864} 868}
865void KSyncPrefsDialog::usrReadConfig() 869void KSyncPrefsDialog::usrReadConfig()
866{ 870{
867 //KConfig *config = KOGlobals::config(); 871 //KConfig *config = KOGlobals::config();
868 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 872 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
869 config.setGroup("General"); 873 config.setGroup("General");
870 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 874 mSyncProfileNames =config.readListEntry("SyncProfileNames");
871 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); 875 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
872 int i; 876 int i;
873 KSyncProfile* temp ; 877 KSyncProfile* temp ;
874 mSyncProfiles.clear(); 878 mSyncProfiles.clear();
875 for ( i = 0; i < mSyncProfileNames.count();++i ) { 879 for ( i = 0; i < mSyncProfileNames.count();++i ) {
876 temp = new KSyncProfile (); 880 temp = new KSyncProfile ();
877 temp->setName( mSyncProfileNames[i] ); 881 temp->setName( mSyncProfileNames[i] );
878 temp->readConfig( &config ); 882 temp->readConfig( &config );
879 mSyncProfiles.append( temp ); 883 mSyncProfiles.append( temp );
880 } 884 }
881 insertProfiles(); 885 insertProfiles();
882 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 886 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
883} 887}
884 888
885 889
886void KSyncPrefsDialog::usrWriteConfig() 890void KSyncPrefsDialog::usrWriteConfig()
887{ 891{
888 saveProfile(); 892 saveProfile();
889 if ( currentSelection >= 0 ) 893 if ( currentSelection >= 0 )
890 profileChanged(currentSelection); 894 profileChanged(currentSelection);
891 //KConfig *config = KOGlobals::config(); 895 //KConfig *config = KOGlobals::config();
892 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 896 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
893 KSyncProfile* prof = mSyncProfiles.first(); 897 KSyncProfile* prof = mSyncProfiles.first();
894 QStringList externalSyncProfileNames; 898 QStringList externalSyncProfileNames;
895 externalSyncProfileNames.append("Sharp_DTM");; 899 externalSyncProfileNames.append("Sharp_DTM");;
896 while ( prof ) { 900 while ( prof ) {
897 prof->writeConfig(&config); 901 prof->writeConfig(&config);
898 if ( prof->getIsPhoneSync( ) ) 902 if ( prof->getIsPhoneSync( ) )
899 externalSyncProfileNames.append(prof->getName( ) ); 903 externalSyncProfileNames.append(prof->getName( ) );
900 prof = mSyncProfiles.next(); 904 prof = mSyncProfiles.next();
901 } 905 }
902 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 906 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
903 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 907 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
904 config.setGroup("General"); 908 config.setGroup("General");
905 config.writeEntry("SyncProfileNames",mSyncProfileNames); 909 config.writeEntry("SyncProfileNames",mSyncProfileNames);
906 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); 910 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames);
907 config.writeEntry("LocalMachineName",mMyMachineName->text()); 911 config.writeEntry("LocalMachineName",mMyMachineName->text());
908 config.sync(); 912 config.sync();
909} 913}
910 914
911void KSyncPrefsDialog::helpDevice() 915void KSyncPrefsDialog::helpDevice()
912{ 916{
913 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); 917 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n");
914#ifdef _WIN32_ 918#ifdef _WIN32_
915 hint += "Leave empty for Irda.\n" 919 hint += "Leave empty for Irda.\n"
916 "com1:\n(first serial port)\n" 920 "com1:\n(first serial port)\n"
917 "usb not supported\n" 921 "usb not supported\n"
918 "???\n(bluetooth device address)\n"; 922 "???\n(bluetooth device address)\n";
919 923
920#else 924#else
921 hint += "/dev/ircomm\n(Irda)\n" 925 hint += "/dev/ircomm\n(Irda)\n"
922 "/dev/ttyS0\n(first serial port)\n" 926 "/dev/ttyS0\n(first serial port)\n"
923 "/dev/ttyUSB0\n(first device usb port)\n" 927 "/dev/ttyUSB0\n(first device usb port)\n"
924 "???\n(bluetooth device address)\n"; 928 "???\n(bluetooth device address)\n";
925#endif 929#endif
926 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 930 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
927} 931}
928void KSyncPrefsDialog::helpModel() 932void KSyncPrefsDialog::helpModel()
929{ 933{
930 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); 934 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n");
931 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; 935 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection";
932 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 936 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
933 937
934} 938}
935void KSyncPrefsDialog::helpConnection() 939void KSyncPrefsDialog::helpConnection()
936{ 940{
937 QString hint = i18n("Insert kind of connection,e.g.:\n"); 941 QString hint = i18n("Insert kind of connection,e.g.:\n");
938 hint += "irda | Nokia FBUS over infrared\n" 942 hint += "irda | Nokia FBUS over infrared\n"
939 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" 943 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n"
940 "irdaobex | set also model as obex\n" 944 "irdaobex | set also model as obex\n"
941 "fbus | Nokia FBUS2 serial\n"; 945 "fbus | Nokia FBUS2 serial\n";
942 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 946 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
943} 947}
diff --git a/libkdepim/ksyncprefsdialog.h b/libkdepim/ksyncprefsdialog.h
index d8c02de..1d7503e 100644
--- a/libkdepim/ksyncprefsdialog.h
+++ b/libkdepim/ksyncprefsdialog.h
@@ -1,171 +1,171 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef _KSYNCPREFSDIALOG_H 23#ifndef _KSYNCPREFSDIALOG_H
24#define _KSYNCPREFSDIALOG_H 24#define _KSYNCPREFSDIALOG_H
25 25
26 26
27#include <kdialogbase.h> 27#include <kdialogbase.h>
28#include <qptrlist.h> 28#include <q3ptrlist.h>
29#include <qtable.h> 29#include <q3table.h>
30#include <qhbox.h> 30#include <q3hbox.h>
31 31
32//#include <libkdepim/kprefsdialog.h> 32//#include <libkdepim/kprefsdialog.h>
33 33
34class KColorButton; 34class KColorButton;
35class QSpinBox;; 35class QSpinBox;;
36class QRadioButton; 36class QRadioButton;
37class QCheckBox; 37class QCheckBox;
38class QSlider; 38class QSlider;
39class KURLRequester; 39class KURLRequester;
40class QComboBox; 40class QComboBox;
41class QButtonGroup; 41class Q3ButtonGroup;
42class QLineEdit; 42class QLineEdit;
43class QVBox; 43class Q3VBox;
44class QStringList; 44class QStringList;
45class KSyncProfile; 45class KSyncProfile;
46 46
47/** Dialog to change the korganizer configuration. 47/** Dialog to change the korganizer configuration.
48 */ 48 */
49class KSyncPrefsDialog : public KDialog 49class KSyncPrefsDialog : public KDialog
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 /** Initialize dialog and pages */ 53 /** Initialize dialog and pages */
54 KSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); 54 KSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false);
55 ~KSyncPrefsDialog(); 55 ~KSyncPrefsDialog();
56 void usrReadConfig(); 56 void usrReadConfig();
57 void setLocalMachineName ( const QString& name ); 57 void setLocalMachineName ( const QString& name );
58 QString getLocalMachineName ( ); 58 QString getLocalMachineName ( );
59 59
60 QStringList getSyncProfileNames(); 60 QStringList getSyncProfileNames();
61 61
62 public slots: 62 public slots:
63 protected slots: 63 protected slots:
64 void accept(); 64 void accept();
65 void deleteProfile(); 65 void deleteProfile();
66 void newProfile(); 66 void newProfile();
67 void cloneProfile(); 67 void cloneProfile();
68 void kindChanged(bool); 68 void kindChanged(bool);
69 void fillSSH(); 69 void fillSSH();
70 void fillFTP(); 70 void fillFTP();
71 void textChanged( const QString & ); 71 void textChanged( const QString & );
72 void profileChanged( int ); 72 void profileChanged( int );
73 void chooseFile(); 73 void chooseFile();
74 void chooseFileAB(); 74 void chooseFileAB();
75 void chooseFilePWM(); 75 void chooseFilePWM();
76 void slotOK(); 76 void slotOK();
77 void helpDevice(); 77 void helpDevice();
78 void helpModel(); 78 void helpModel();
79 void helpConnection(); 79 void helpConnection();
80 80
81 protected: 81 protected:
82 void usrWriteConfig(); 82 void usrWriteConfig();
83 void setupSyncAlgTab(); 83 void setupSyncAlgTab();
84 void readFilter(); 84 void readFilter();
85 void readResources(); 85 void readResources();
86 private: 86 private:
87 void updateMyCaption(); 87 void updateMyCaption();
88 int currentSelection; 88 int currentSelection;
89 QPtrList<KSyncProfile> mSyncProfiles; 89 Q3PtrList<KSyncProfile> mSyncProfiles;
90 QStringList mSyncProfileNames; 90 QStringList mSyncProfileNames;
91 QStringList mFilterKapi; 91 QStringList mFilterKapi;
92 QStringList mFilterKopi; 92 QStringList mFilterKopi;
93 QStringList mResourcesKopi; 93 QStringList mResourcesKopi;
94 QStringList mResourcesKapi; 94 QStringList mResourcesKapi;
95 QLineEdit * mMyMachineName; 95 QLineEdit * mMyMachineName;
96 QComboBox * mProfileBox; 96 QComboBox * mProfileBox;
97 QRadioButton* mIsLocal; 97 QRadioButton* mIsLocal;
98 QRadioButton* mIsNotLocal; 98 QRadioButton* mIsNotLocal;
99 QRadioButton* mIsPhone; 99 QRadioButton* mIsPhone;
100 QRadioButton* mIsPi; 100 QRadioButton* mIsPi;
101 QRadioButton* mIsPiSpecific; 101 QRadioButton* mIsPiSpecific;
102 QCheckBox* mIncludeInRing; 102 QCheckBox* mIncludeInRing;
103 QCheckBox* mIncludeInRingAB; 103 QCheckBox* mIncludeInRingAB;
104 QCheckBox* mIncludeInRingPWM; 104 QCheckBox* mIncludeInRingPWM;
105 void addProfile ( KSyncProfile* ); 105 void addProfile ( KSyncProfile* );
106 void insertProfiles(); 106 void insertProfiles();
107 void saveProfile(); 107 void saveProfile();
108 QButtonGroup* proGr; 108 Q3ButtonGroup* proGr;
109 QHBox * mTableBox; 109 Q3HBox * mTableBox;
110 QTable* mResTableKopi; 110 Q3Table* mResTableKopi;
111 QTable* mResTableKapi; 111 Q3Table* mResTableKapi;
112 QTable* mResTablePwmpi; 112 Q3Table* mResTablePwmpi;
113 113
114 QComboBox * mFilterOutCal; 114 QComboBox * mFilterOutCal;
115 QComboBox * mFilterInCal; 115 QComboBox * mFilterInCal;
116 QComboBox * mFilterOutAB; 116 QComboBox * mFilterOutAB;
117 QComboBox * mFilterInAB; 117 QComboBox * mFilterInAB;
118 118
119 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; 119 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both;
120 120
121 121
122 QLineEdit * mRemotePostcommand; 122 QLineEdit * mRemotePostcommand;
123 QLineEdit * mRemotePrecommand; 123 QLineEdit * mRemotePrecommand;
124 QLineEdit * mRemoteFile; 124 QLineEdit * mRemoteFile;
125 QLineEdit * mLocalTempFile; 125 QLineEdit * mLocalTempFile;
126 126
127 QLineEdit * mRemotePostcommandAB; 127 QLineEdit * mRemotePostcommandAB;
128 QLineEdit * mRemotePrecommandAB; 128 QLineEdit * mRemotePrecommandAB;
129 QLineEdit * mRemoteFileAB; 129 QLineEdit * mRemoteFileAB;
130 QLineEdit * mLocalTempFileAB; 130 QLineEdit * mLocalTempFileAB;
131 131
132 QLineEdit * mRemotePostcommandPWM; 132 QLineEdit * mRemotePostcommandPWM;
133 QLineEdit * mRemotePrecommandPWM; 133 QLineEdit * mRemotePrecommandPWM;
134 QLineEdit * mRemoteFilePWM; 134 QLineEdit * mRemoteFilePWM;
135 QLineEdit * mLocalTempFilePWM; 135 QLineEdit * mLocalTempFilePWM;
136 136
137 137
138 QLineEdit * mRemotePw; 138 QLineEdit * mRemotePw;
139 QLineEdit * mRemoteIP; 139 QLineEdit * mRemoteIP;
140 QLineEdit * mRemotePort; 140 QLineEdit * mRemotePort;
141 141
142 QLineEdit * mRemotePwAB; 142 QLineEdit * mRemotePwAB;
143 QLineEdit * mRemoteIPAB; 143 QLineEdit * mRemoteIPAB;
144 QLineEdit * mRemotePortAB; 144 QLineEdit * mRemotePortAB;
145 145
146 QLineEdit * mRemotePwPWM; 146 QLineEdit * mRemotePwPWM;
147 QLineEdit * mRemoteIPPWM; 147 QLineEdit * mRemoteIPPWM;
148 QLineEdit * mRemotePortPWM; 148 QLineEdit * mRemotePortPWM;
149 149
150 QLineEdit * mPhoneDevice; 150 QLineEdit * mPhoneDevice;
151 QLineEdit * mPhoneConnection; 151 QLineEdit * mPhoneConnection;
152 QLineEdit * mPhoneModel; 152 QLineEdit * mPhoneModel;
153 153
154 QWidget* mSetupSyncAlgTab; 154 QWidget* mSetupSyncAlgTab;
155 QVBox* localFileWidget; 155 Q3VBox* localFileWidget;
156 QVBox* remoteFileWidget; 156 Q3VBox* remoteFileWidget;
157 QVBox* phoneWidget; 157 Q3VBox* phoneWidget;
158 QVBox* piWidget; 158 Q3VBox* piWidget;
159 QCheckBox* mWriteBackFile; 159 QCheckBox* mWriteBackFile;
160 QCheckBox* mWriteBackFuture; 160 QCheckBox* mWriteBackFuture;
161 QSpinBox* mWriteBackFutureWeeks; 161 QSpinBox* mWriteBackFutureWeeks;
162 QSpinBox* mWriteBackPastWeeks; 162 QSpinBox* mWriteBackPastWeeks;
163 QCheckBox* mWriteBackExisting; 163 QCheckBox* mWriteBackExisting;
164 QCheckBox* mAskForPreferences; 164 QCheckBox* mAskForPreferences;
165 QCheckBox* mShowSummaryAfterSync; 165 QCheckBox* mShowSummaryAfterSync;
166 QCheckBox* mWriteContactToSIM; 166 QCheckBox* mWriteContactToSIM;
167 QCheckBox* mIsKapiFileL; 167 QCheckBox* mIsKapiFileL;
168 QCheckBox* mIsKapiFileR; 168 QCheckBox* mIsKapiFileR;
169}; 169};
170 170
171#endif 171#endif
diff --git a/libkdepim/ksyncprofile.h b/libkdepim/ksyncprofile.h
index 91fcfc5..1e41662 100644
--- a/libkdepim/ksyncprofile.h
+++ b/libkdepim/ksyncprofile.h
@@ -1,216 +1,216 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef _KSYNCPROFILE_H 20#ifndef _KSYNCPROFILE_H
21#define _KSYNCPROFILE_H 21#define _KSYNCPROFILE_H
22 22
23#include <qptrlist.h> 23#include <q3ptrlist.h>
24#include <qcolor.h> 24#include <qcolor.h>
25#include <qfont.h> 25#include <qfont.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qobject.h> 27#include <qobject.h>
28#include <qstring.h> 28#include <qstring.h>
29 29
30#include <libkcal/syncdefines.h> 30#include <libkcal/syncdefines.h>
31 31
32 32
33 33
34class KConfig; 34class KConfig;
35 35
36 36
37class KSyncProfile : public QObject { 37class KSyncProfile : public QObject {
38 public: 38 public:
39 KSyncProfile(); 39 KSyncProfile();
40 ~KSyncProfile() ; 40 ~KSyncProfile() ;
41 41
42 KSyncProfile* clone(); 42 KSyncProfile* clone();
43 void setDefault(); 43 void setDefault();
44 void readConfig(KConfig *); 44 void readConfig(KConfig *);
45 void writeConfig(KConfig *); 45 void writeConfig(KConfig *);
46 void deleteConfig(KConfig *); 46 void deleteConfig(KConfig *);
47 47
48 void setRemotePw( const QString& n ) {mRemotePw = n;} 48 void setRemotePw( const QString& n ) {mRemotePw = n;}
49 QString getRemotePw( ) { return mRemotePw; } 49 QString getRemotePw( ) { return mRemotePw; }
50 void setRemotePwAB( const QString& n ) {mRemotePwAB = n;} 50 void setRemotePwAB( const QString& n ) {mRemotePwAB = n;}
51 QString getRemotePwAB( ) { return mRemotePwAB; } 51 QString getRemotePwAB( ) { return mRemotePwAB; }
52 void setRemotePwPWM( const QString& n ) {mRemotePwPWM = n;} 52 void setRemotePwPWM( const QString& n ) {mRemotePwPWM = n;}
53 QString getRemotePwPWM( ) { return mRemotePwPWM; } 53 QString getRemotePwPWM( ) { return mRemotePwPWM; }
54 54
55 void setRemoteIP( const QString& n ) {mRemoteIP = n;} 55 void setRemoteIP( const QString& n ) {mRemoteIP = n;}
56 QString getRemoteIP( ) { return mRemoteIP; } 56 QString getRemoteIP( ) { return mRemoteIP; }
57 void setRemoteIPAB( const QString& n ) {mRemoteIPAB = n;} 57 void setRemoteIPAB( const QString& n ) {mRemoteIPAB = n;}
58 QString getRemoteIPAB( ) { return mRemoteIPAB; } 58 QString getRemoteIPAB( ) { return mRemoteIPAB; }
59 void setRemoteIPPWM( const QString& n ) {mRemoteIPPWM = n;} 59 void setRemoteIPPWM( const QString& n ) {mRemoteIPPWM = n;}
60 QString getRemoteIPPWM( ) { return mRemoteIPPWM; } 60 QString getRemoteIPPWM( ) { return mRemoteIPPWM; }
61 61
62 void setRemotePort( const QString& n ) {mRemotePort = n;} 62 void setRemotePort( const QString& n ) {mRemotePort = n;}
63 QString getRemotePort( ) { return mRemotePort; } 63 QString getRemotePort( ) { return mRemotePort; }
64 void setRemotePortAB( const QString& n ) {mRemotePortAB = n;} 64 void setRemotePortAB( const QString& n ) {mRemotePortAB = n;}
65 QString getRemotePortAB( ) { return mRemotePortAB; } 65 QString getRemotePortAB( ) { return mRemotePortAB; }
66 void setRemotePortPWM( const QString& n ) {mRemotePortPWM = n;} 66 void setRemotePortPWM( const QString& n ) {mRemotePortPWM = n;}
67 QString getRemotePortPWM( ) { return mRemotePortPWM; } 67 QString getRemotePortPWM( ) { return mRemotePortPWM; }
68 68
69 void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;} 69 void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;}
70 QString getPreSyncCommand( ) { return mPreSyncCommand; } 70 QString getPreSyncCommand( ) { return mPreSyncCommand; }
71 void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;} 71 void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;}
72 QString getPostSyncCommand( ) { return mPostSyncCommand;} 72 QString getPostSyncCommand( ) { return mPostSyncCommand;}
73 void setLocalTempFile( const QString& n ) { mLocalTempFile= n;} 73 void setLocalTempFile( const QString& n ) { mLocalTempFile= n;}
74 QString getLocalTempFile( ) { return mLocalTempFile;} 74 QString getLocalTempFile( ) { return mLocalTempFile;}
75 void setRemoteFileName( const QString& n ) { mRemoteFileName = n;} 75 void setRemoteFileName( const QString& n ) { mRemoteFileName = n;}
76 QString getRemoteFileName( ) { return mRemoteFileName;} 76 QString getRemoteFileName( ) { return mRemoteFileName;}
77 77
78 void setPreSyncCommandAB( const QString& n ) {mPreSyncCommandAB = n;} 78 void setPreSyncCommandAB( const QString& n ) {mPreSyncCommandAB = n;}
79 QString getPreSyncCommandAB( ) { return mPreSyncCommandAB; } 79 QString getPreSyncCommandAB( ) { return mPreSyncCommandAB; }
80 void setPostSyncCommandAB( const QString& n ) {mPostSyncCommandAB = n;} 80 void setPostSyncCommandAB( const QString& n ) {mPostSyncCommandAB = n;}
81 QString getPostSyncCommandAB( ) { return mPostSyncCommandAB;} 81 QString getPostSyncCommandAB( ) { return mPostSyncCommandAB;}
82 void setLocalTempFileAB( const QString& n ) { mLocalTempFileAB= n;} 82 void setLocalTempFileAB( const QString& n ) { mLocalTempFileAB= n;}
83 QString getLocalTempFileAB( ) { return mLocalTempFileAB;} 83 QString getLocalTempFileAB( ) { return mLocalTempFileAB;}
84 void setRemoteFileNameAB( const QString& n ) { mRemoteFileNameAB = n;} 84 void setRemoteFileNameAB( const QString& n ) { mRemoteFileNameAB = n;}
85 QString getRemoteFileNameAB( ) { return mRemoteFileNameAB;} 85 QString getRemoteFileNameAB( ) { return mRemoteFileNameAB;}
86 86
87 void setPreSyncCommandPWM( const QString& n ) {mPreSyncCommandPWM = n;} 87 void setPreSyncCommandPWM( const QString& n ) {mPreSyncCommandPWM = n;}
88 QString getPreSyncCommandPWM( ) { return mPreSyncCommandPWM; } 88 QString getPreSyncCommandPWM( ) { return mPreSyncCommandPWM; }
89 void setPostSyncCommandPWM( const QString& n ) {mPostSyncCommandPWM = n;} 89 void setPostSyncCommandPWM( const QString& n ) {mPostSyncCommandPWM = n;}
90 QString getPostSyncCommandPWM( ) { return mPostSyncCommandPWM;} 90 QString getPostSyncCommandPWM( ) { return mPostSyncCommandPWM;}
91 void setLocalTempFilePWM( const QString& n ) { mLocalTempFilePWM= n;} 91 void setLocalTempFilePWM( const QString& n ) { mLocalTempFilePWM= n;}
92 QString getLocalTempFilePWM( ) { return mLocalTempFilePWM;} 92 QString getLocalTempFilePWM( ) { return mLocalTempFilePWM;}
93 void setRemoteFileNamePWM( const QString& n ) { mRemoteFileNamePWM = n;} 93 void setRemoteFileNamePWM( const QString& n ) { mRemoteFileNamePWM = n;}
94 QString getRemoteFileNamePWM( ) { return mRemoteFileNamePWM;} 94 QString getRemoteFileNamePWM( ) { return mRemoteFileNamePWM;}
95 95
96 void setPhoneDevice( const QString& n ) { mPhoneDevice = n;} 96 void setPhoneDevice( const QString& n ) { mPhoneDevice = n;}
97 QString getPhoneDevice( ) { return mPhoneDevice;} 97 QString getPhoneDevice( ) { return mPhoneDevice;}
98 void setPhoneConnection( const QString& n ) { mPhoneConnection = n;} 98 void setPhoneConnection( const QString& n ) { mPhoneConnection = n;}
99 QString getPhoneConnection( ) { return mPhoneConnection;} 99 QString getPhoneConnection( ) { return mPhoneConnection;}
100 void setPhoneModel( const QString& n ) { mPhoneModel = n;} 100 void setPhoneModel( const QString& n ) { mPhoneModel = n;}
101 QString getPhoneModel( ) { return mPhoneModel;} 101 QString getPhoneModel( ) { return mPhoneModel;}
102 /* 102 /*
103 void set( const QString& n ) { = n;} 103 void set( const QString& n ) { = n;}
104 QString get( ) { return ;} 104 QString get( ) { return ;}
105 */ 105 */
106 106
107 void setFilterInCal (const QString& n ){ mFilterInCal = n;} 107 void setFilterInCal (const QString& n ){ mFilterInCal = n;}
108 void setFilterOutCal (const QString& n ){ mFilterOutCal = n;} 108 void setFilterOutCal (const QString& n ){ mFilterOutCal = n;}
109 void setFilterInAB (const QString& n ){ mFilterInAB = n;} 109 void setFilterInAB (const QString& n ){ mFilterInAB = n;}
110 void setFilterOutAB (const QString& n ){ mFilterOutAB = n;} 110 void setFilterOutAB (const QString& n ){ mFilterOutAB = n;}
111 QString getFilterInCal () { return mFilterInCal ;} 111 QString getFilterInCal () { return mFilterInCal ;}
112 QString getFilterOutCal () { return mFilterOutCal ;} 112 QString getFilterOutCal () { return mFilterOutCal ;}
113 QString getFilterInAB () { return mFilterInAB ;} 113 QString getFilterInAB () { return mFilterInAB ;}
114 QString getFilterOutAB () { return mFilterOutAB ;} 114 QString getFilterOutAB () { return mFilterOutAB ;}
115 115
116 void setName( const QString& n ) {mName = n;} 116 void setName( const QString& n ) {mName = n;}
117 QString getName( ) { return mName;} 117 QString getName( ) { return mName;}
118 void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;} 118 void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;}
119 bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;} 119 bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;}
120 void setAskForPreferences( bool b ) { mAskForPreferences= b;} 120 void setAskForPreferences( bool b ) { mAskForPreferences= b;}
121 bool getAskForPreferences( ) { return mAskForPreferences;} 121 bool getAskForPreferences( ) { return mAskForPreferences;}
122 void setWriteBackExisting( bool b ) { mWriteBackExisting = b;} 122 void setWriteBackExisting( bool b ) { mWriteBackExisting = b;}
123 bool getWriteBackExisting( ) { return mWriteBackExisting;} 123 bool getWriteBackExisting( ) { return mWriteBackExisting;}
124 void setWriteBackFuture( bool b ) { mWriteBackFuture = b;} 124 void setWriteBackFuture( bool b ) { mWriteBackFuture = b;}
125 bool getWriteBackFuture( ) { return mWriteBackFuture;} 125 bool getWriteBackFuture( ) { return mWriteBackFuture;}
126 void setWriteBackFile( bool b ) { mWriteBackFile= b;} 126 void setWriteBackFile( bool b ) { mWriteBackFile= b;}
127 bool getWriteBackFile( ) { return mWriteBackFile;} 127 bool getWriteBackFile( ) { return mWriteBackFile;}
128 void setWriteContactToSIM( bool b ) { mWriteContactToSIM= b;} 128 void setWriteContactToSIM( bool b ) { mWriteContactToSIM= b;}
129 bool getWriteContactToSIM( ) { return mWriteContactToSIM;} 129 bool getWriteContactToSIM( ) { return mWriteContactToSIM;}
130 void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;} 130 void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;}
131 bool getIncludeInRingSync( ) { return mIncludeInRingSync;} 131 bool getIncludeInRingSync( ) { return mIncludeInRingSync;}
132 void setIncludeInRingSyncAB( bool b ) {mIncludeInRingSyncAB = b;} 132 void setIncludeInRingSyncAB( bool b ) {mIncludeInRingSyncAB = b;}
133 bool getIncludeInRingSyncAB( ) { return mIncludeInRingSyncAB;} 133 bool getIncludeInRingSyncAB( ) { return mIncludeInRingSyncAB;}
134 void setIncludeInRingSyncPWM( bool b ) {mIncludeInRingSyncPWM = b;} 134 void setIncludeInRingSyncPWM( bool b ) {mIncludeInRingSyncPWM = b;}
135 bool getIncludeInRingSyncPWM( ) { return mIncludeInRingSyncPWM;} 135 bool getIncludeInRingSyncPWM( ) { return mIncludeInRingSyncPWM;}
136 void setSyncPrefs( int n ) { mSyncPrefs= n;} 136 void setSyncPrefs( int n ) { mSyncPrefs= n;}
137 int getSyncPrefs( ) { return mSyncPrefs;} 137 int getSyncPrefs( ) { return mSyncPrefs;}
138 void setWriteBackFutureWeeks( int n ) { mWriteBackFutureWeeks= n;} 138 void setWriteBackFutureWeeks( int n ) { mWriteBackFutureWeeks= n;}
139 int getWriteBackFutureWeeks( ) { return mWriteBackFutureWeeks;} 139 int getWriteBackFutureWeeks( ) { return mWriteBackFutureWeeks;}
140 void setWriteBackPastWeeks( int n ) { mWriteBackPastWeeks= n;} 140 void setWriteBackPastWeeks( int n ) { mWriteBackPastWeeks= n;}
141 int getWriteBackPastWeeks( ) { return mWriteBackPastWeeks;} 141 int getWriteBackPastWeeks( ) { return mWriteBackPastWeeks;}
142 void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;} 142 void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;}
143 bool getIsLocalFileSync( ) { return mIsLocalFileSync;} 143 bool getIsLocalFileSync( ) { return mIsLocalFileSync;}
144 void setIsPhoneSync( bool b ) { mIsPhoneSync= b;} 144 void setIsPhoneSync( bool b ) { mIsPhoneSync= b;}
145 bool getIsPhoneSync( ) { return mIsPhoneSync;} 145 bool getIsPhoneSync( ) { return mIsPhoneSync;}
146 void setIsPiSync( bool b ) { mIsPiSync= b;} 146 void setIsPiSync( bool b ) { mIsPiSync= b;}
147 void setIsPiSyncSpec( bool b ) { mIsPiSyncSpec= b;} 147 void setIsPiSyncSpec( bool b ) { mIsPiSyncSpec= b;}
148 bool getIsPiSync( ) { return mIsPiSync;} 148 bool getIsPiSync( ) { return mIsPiSync;}
149 bool getIsPiSyncSpec( ) { return mIsPiSyncSpec;} 149 bool getIsPiSyncSpec( ) { return mIsPiSyncSpec;}
150 void setIsKapiFile( bool b ) { mIsKapiFile= b;} 150 void setIsKapiFile( bool b ) { mIsKapiFile= b;}
151 bool getIsKapiFile( ) { return mIsKapiFile;} 151 bool getIsKapiFile( ) { return mIsKapiFile;}
152 152
153 153
154 QString getResSpecKopi() { return mResSpecKopi;} 154 QString getResSpecKopi() { return mResSpecKopi;}
155 QString getResSpecKapi() { return mResSpecKapi;} 155 QString getResSpecKapi() { return mResSpecKapi;}
156 void setResSpecKopi( const QString& n ) {mResSpecKopi = n;} 156 void setResSpecKopi( const QString& n ) {mResSpecKopi = n;}
157 void setResSpecKapi( const QString& n ) {mResSpecKapi = n;} 157 void setResSpecKapi( const QString& n ) {mResSpecKapi = n;}
158 private: 158 private:
159 QString mName; 159 QString mName;
160 QString mPreSyncCommand; 160 QString mPreSyncCommand;
161 QString mPostSyncCommand; 161 QString mPostSyncCommand;
162 QString mLocalTempFile; 162 QString mLocalTempFile;
163 QString mRemoteFileName; 163 QString mRemoteFileName;
164 QString mPreSyncCommandAB; 164 QString mPreSyncCommandAB;
165 QString mPostSyncCommandAB; 165 QString mPostSyncCommandAB;
166 QString mLocalTempFileAB; 166 QString mLocalTempFileAB;
167 QString mRemoteFileNameAB; 167 QString mRemoteFileNameAB;
168 QString mPreSyncCommandPWM; 168 QString mPreSyncCommandPWM;
169 QString mPostSyncCommandPWM; 169 QString mPostSyncCommandPWM;
170 QString mLocalTempFilePWM; 170 QString mLocalTempFilePWM;
171 QString mRemoteFileNamePWM; 171 QString mRemoteFileNamePWM;
172 172
173 QString mRemotePw; 173 QString mRemotePw;
174 QString mRemoteIP; 174 QString mRemoteIP;
175 QString mRemotePort; 175 QString mRemotePort;
176 176
177 QString mRemotePwAB; 177 QString mRemotePwAB;
178 QString mRemoteIPAB; 178 QString mRemoteIPAB;
179 QString mRemotePortAB; 179 QString mRemotePortAB;
180 180
181 QString mRemotePwPWM; 181 QString mRemotePwPWM;
182 QString mRemoteIPPWM; 182 QString mRemoteIPPWM;
183 QString mRemotePortPWM; 183 QString mRemotePortPWM;
184 184
185 QString mPhoneDevice; 185 QString mPhoneDevice;
186 QString mPhoneConnection; 186 QString mPhoneConnection;
187 QString mPhoneModel; 187 QString mPhoneModel;
188 188
189 QString mFilterInCal; 189 QString mFilterInCal;
190 QString mFilterOutCal; 190 QString mFilterOutCal;
191 QString mFilterInAB; 191 QString mFilterInAB;
192 QString mFilterOutAB; 192 QString mFilterOutAB;
193 193
194 bool mIncludeInRingSync; 194 bool mIncludeInRingSync;
195 bool mIncludeInRingSyncAB; 195 bool mIncludeInRingSyncAB;
196 bool mIncludeInRingSyncPWM; 196 bool mIncludeInRingSyncPWM;
197 int mSyncPrefs; 197 int mSyncPrefs;
198 bool mWriteBackFile; 198 bool mWriteBackFile;
199 bool mWriteBackExisting; 199 bool mWriteBackExisting;
200 bool mWriteBackFuture; 200 bool mWriteBackFuture;
201 int mWriteBackFutureWeeks; 201 int mWriteBackFutureWeeks;
202 int mWriteBackPastWeeks; 202 int mWriteBackPastWeeks;
203 bool mAskForPreferences; 203 bool mAskForPreferences;
204 bool mShowSummaryAfterSync; 204 bool mShowSummaryAfterSync;
205 bool mIsLocalFileSync; 205 bool mIsLocalFileSync;
206 bool mIsPhoneSync; 206 bool mIsPhoneSync;
207 bool mWriteContactToSIM; 207 bool mWriteContactToSIM;
208 208
209 bool mIsPiSync; 209 bool mIsPiSync;
210 bool mIsPiSyncSpec; 210 bool mIsPiSyncSpec;
211 bool mIsKapiFile; 211 bool mIsKapiFile;
212 QString mResSpecKopi; 212 QString mResSpecKopi;
213 QString mResSpecKapi; 213 QString mResSpecKapi;
214}; 214};
215 215
216#endif 216#endif
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
index 7160d0e..fb27311 100644
--- a/libkdepim/libkdepim.pro
+++ b/libkdepim/libkdepim.pro
@@ -1,76 +1,78 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3DEFINES +=KORG_NOKABC 3DEFINES +=KORG_NOKABC
4TARGET = microkdepim 4TARGET = xmicrokdepim
5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. 5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . ..
6DESTDIR=../bin 6DESTDIR=../bin
7 7
8DEFINES += DESKTOP_VERSION 8DEFINES += DESKTOP_VERSION
9include( ../variables.pri ) 9include( ../variables.pri )
10unix : { 10unix : {
11OBJECTS_DIR = obj/unix 11OBJECTS_DIR = obj/unix
12MOC_DIR = moc/unix 12MOC_DIR = moc/unix
13} 13}
14win32: { 14win32: {
15DEFINES += _WIN32_ 15DEFINES += _WIN32_
16OBJECTS_DIR = obj/win 16OBJECTS_DIR = obj/win
17MOC_DIR = moc/win 17MOC_DIR = moc/win
18} 18}
19INTERFACES = \ 19INTERFACES = \
20 20
21HEADERS = \ 21HEADERS = \
22 categoryeditdialog.h \ 22 categoryeditdialog.h \
23 categoryeditdialog_base.h \ 23 categoryeditdialog_base.h \
24 categoryselectdialog.h \ 24 categoryselectdialog.h \
25 categoryselectdialog_base.h \ 25 categoryselectdialog_base.h \
26 externalapphandler.h \ 26 externalapphandler.h \
27 kdateedit.h \ 27 kdateedit.h \
28 kdatepicker.h \ 28 kdatepicker.h \
29 kinputdialog.h \ 29 kinputdialog.h \
30 kpimprefs.h \ 30 kpimprefs.h \
31 kpimglobalprefs.h \ 31 kpimglobalprefs.h \
32 kprefsdialog.h \ 32 kprefsdialog.h \
33 kprefswidget.h \ 33 kprefswidget.h \
34 ksyncmanager.h \ 34 ksyncmanager.h \
35 ksyncprofile.h \ 35 ksyncprofile.h \
36 ksyncprefsdialog.h \ 36 ksyncprefsdialog.h \
37 kcmconfigs/kcmkdepimconfig.h \ 37 kcmconfigs/kcmkdepimconfig.h \
38 kcmconfigs/kdepimconfigwidget.h \ 38 kcmconfigs/kdepimconfigwidget.h \
39 phoneaccess.h 39 phoneaccess.h
40 40
41SOURCES = \ 41SOURCES = \
42 categoryeditdialog.cpp \ 42 categoryeditdialog.cpp \
43 categoryeditdialog_base.cpp \ 43 categoryeditdialog_base.cpp \
44 categoryselectdialog.cpp \ 44 categoryselectdialog.cpp \
45 categoryselectdialog_base.cpp \ 45 categoryselectdialog_base.cpp \
46 externalapphandler.cpp \ 46 externalapphandler.cpp \
47 kdateedit.cpp \ 47 kdateedit.cpp \
48 kdatepicker.cpp \ 48 kdatepicker.cpp \
49 kinputdialog.cpp \ 49 kinputdialog.cpp \
50 kpimprefs.cpp \ 50 kpimprefs.cpp \
51 kpimglobalprefs.cpp \ 51 kpimglobalprefs.cpp \
52 kprefsdialog.cpp \ 52 kprefsdialog.cpp \
53 kprefswidget.cpp \ 53 kprefswidget.cpp \
54 ksyncmanager.cpp \ 54 ksyncmanager.cpp \
55 ksyncprofile.cpp \ 55 ksyncprofile.cpp \
56 ksyncprefsdialog.cpp \ 56 ksyncprefsdialog.cpp \
57 kcmconfigs/kcmkdepimconfig.cpp \ 57 kcmconfigs/kcmkdepimconfig.cpp \
58 kcmconfigs/kdepimconfigwidget.cpp \ 58 kcmconfigs/kdepimconfigwidget.cpp \
59 phoneaccess.cpp 59 phoneaccess.cpp
60 60
61win32: { 61win32: {
62 62
63#olimport section 63#olimport section
64importol { 64importol {
65debug: { 65debug: {
66LIBS += mfc71ud.lib 66LIBS += mfc71ud.lib
67} 67}
68release: { 68release: {
69LIBS += mfc71u.lib 69LIBS += mfc71u.lib
70} 70}
71DEFINES += _OL_IMPORT_ 71DEFINES += _OL_IMPORT_
72HEADERS += ol_access.h 72HEADERS += ol_access.h
73SOURCES += ol_access.cpp 73SOURCES += ol_access.cpp
74#olimport section end 74#olimport section end
75} 75}
76} 76}
77#The following line was inserted by qt3to4
78QT += xml qt3support
diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro
index f3db68e..4b42184 100644
--- a/libkdepim/libkdepimE.pro
+++ b/libkdepim/libkdepimE.pro
@@ -1,57 +1,57 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3TARGET = microkdepim 3TARGET = xmicrokdepim
4INCLUDEPATH += . $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(QPEDIR)/include 4INCLUDEPATH += . $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(QPEDIR)/include
5LIBS += -lmicrokde 5LIBS += -lxmicrokde
6#LIBS += -lmicrokcal 6#LIBS += -lxmicrokcal
7LIBS += -L$(QPEDIR)/lib 7LIBS += -L$(QPEDIR)/lib
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR=$(QPEDIR)/lib 10DESTDIR=$(QPEDIR)/lib
11 11
12 12
13INTERFACES = \ 13INTERFACES = \
14 14
15HEADERS = \ 15HEADERS = \
16 categoryeditdialog.h \ 16 categoryeditdialog.h \
17 categoryeditdialog_base.h \ 17 categoryeditdialog_base.h \
18 categoryselectdialog.h \ 18 categoryselectdialog.h \
19 categoryselectdialog_base.h \ 19 categoryselectdialog_base.h \
20 externalapphandler.h \ 20 externalapphandler.h \
21 kdateedit.h \ 21 kdateedit.h \
22 kdatepicker.h \ 22 kdatepicker.h \
23 kinputdialog.h \ 23 kinputdialog.h \
24 kpimprefs.h \ 24 kpimprefs.h \
25 kpimglobalprefs.h \ 25 kpimglobalprefs.h \
26 kprefsdialog.h \ 26 kprefsdialog.h \
27 kprefswidget.h \ 27 kprefswidget.h \
28 ksyncmanager.h \ 28 ksyncmanager.h \
29 ksyncprofile.h \ 29 ksyncprofile.h \
30 ksyncprefsdialog.h \ 30 ksyncprefsdialog.h \
31 kcmconfigs/kcmkdepimconfig.h \ 31 kcmconfigs/kcmkdepimconfig.h \
32 kcmconfigs/kdepimconfigwidget.h \ 32 kcmconfigs/kdepimconfigwidget.h \
33 phoneaccess.h 33 phoneaccess.h
34 34
35 35
36 36
37SOURCES = \ 37SOURCES = \
38 categoryeditdialog.cpp \ 38 categoryeditdialog.cpp \
39 categoryeditdialog_base.cpp \ 39 categoryeditdialog_base.cpp \
40 categoryselectdialog.cpp \ 40 categoryselectdialog.cpp \
41 categoryselectdialog_base.cpp \ 41 categoryselectdialog_base.cpp \
42 externalapphandler.cpp \ 42 externalapphandler.cpp \
43 kdateedit.cpp \ 43 kdateedit.cpp \
44 kinputdialog.cpp \ 44 kinputdialog.cpp \
45 kdatepicker.cpp \ 45 kdatepicker.cpp \
46 kpimprefs.cpp \ 46 kpimprefs.cpp \
47 kpimglobalprefs.cpp \ 47 kpimglobalprefs.cpp \
48 kprefsdialog.cpp \ 48 kprefsdialog.cpp \
49 kprefswidget.cpp \ 49 kprefswidget.cpp \
50 ksyncmanager.cpp \ 50 ksyncmanager.cpp \
51 ksyncprofile.cpp \ 51 ksyncprofile.cpp \
52 ksyncprefsdialog.cpp \ 52 ksyncprefsdialog.cpp \
53 kcmconfigs/kcmkdepimconfig.cpp \ 53 kcmconfigs/kcmkdepimconfig.cpp \
54 kcmconfigs/kdepimconfigwidget.cpp \ 54 kcmconfigs/kdepimconfigwidget.cpp \
55 phoneaccess.cpp 55 phoneaccess.cpp
56 56
57 57
diff --git a/libkdepim/ol_access.cpp b/libkdepim/ol_access.cpp
index 1b05693..821f148 100755
--- a/libkdepim/ol_access.cpp
+++ b/libkdepim/ol_access.cpp
@@ -1,2074 +1,2074 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2006 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2006 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qframe.h> 25#include <q3frame.h>
26#include <qpixmap.h> 26#include <qpixmap.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qprogressbar.h> 28#include <q3progressbar.h>
29#include <qprogressdialog.h> 29#include <q3progressdialog.h>
30#include <qwidgetstack.h> 30#include <q3widgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qregexp.h> 34#include <qregexp.h>
35#include <qapplication.h> 35#include <qapplication.h>
36#include <qhbox.h> 36#include <q3hbox.h>
37#include <qheader.h> 37#include <q3header.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qlistview.h> 39#include <q3listview.h>
40 40
41#include <kdebug.h> 41#include <kdebug.h>
42#include <klocale.h> 42#include <klocale.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kmessagebox.h> 44#include <kmessagebox.h>
45#include <kfiledialog.h> 45#include <kfiledialog.h>
46#include <kstaticdeleter.h> 46#include <kstaticdeleter.h>
47#include <kdialogbase.h> 47#include <kdialogbase.h>
48 48
49 49
50#include <ol_access.h> 50#include <ol_access.h>
51 51
52#include "../outport/msoutl9.h" 52#include "../outport/msoutl9.h"
53#include <ole2.h> 53#include <ole2.h>
54#include <comutil.h> 54#include <comutil.h>
55 55
56 56
57class OLEListViewItem : public QCheckListItem 57class OLEListViewItem : public Q3CheckListItem
58{ 58{
59public: 59public:
60 OLEListViewItem( QListView *parent, QString text ) : 60 OLEListViewItem( Q3ListView *parent, QString text ) :
61 QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; 61 Q3CheckListItem( parent, text, Q3CheckListItem::CheckBox ) { ; };
62 OLEListViewItem( QListViewItem *after, QString text ) : 62 OLEListViewItem( Q3ListViewItem *after, QString text ) :
63 QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; 63 Q3CheckListItem( after, text, Q3CheckListItem::CheckBox ) { ; };
64 ~OLEListViewItem() {}; 64 ~OLEListViewItem() {};
65 void setData( DWORD data ) {mData= data; }; 65 void setData( DWORD data ) {mData= data; };
66 void setDataID( QString data ){ mDataID = data ;} 66 void setDataID( QString data ){ mDataID = data ;}
67 QString dataID() { return mDataID;} 67 QString dataID() { return mDataID;}
68 DWORD data() { return mData ;}; 68 DWORD data() { return mData ;};
69private: 69private:
70 DWORD mData; 70 DWORD mData;
71 QString mDataID; 71 QString mDataID;
72}; 72};
73 73
74class OLEFolderSelect : public KDialogBase 74class OLEFolderSelect : public KDialogBase
75{ 75{
76 public: 76 public:
77 OLEFolderSelect() : 77 OLEFolderSelect() :
78 KDialogBase( Plain, "", Ok | Cancel, Ok, 78 KDialogBase( Plain, "", Ok | Cancel, Ok,
79 0, "", true, false, i18n("Import!") ) 79 0, "", true, false, i18n("Import!") )
80 { 80 {
81 QHBox * mw = new QHBox( this ); 81 Q3HBox * mw = new Q3HBox( this );
82 setMainWidget( mw ); 82 setMainWidget( mw );
83 mListView = new QListView( mw ); 83 mListView = new Q3ListView( mw );
84 mListView->addColumn(i18n("Select Folder")); 84 mListView->addColumn(i18n("Select Folder"));
85 mListView->addColumn(i18n("Content Type")); 85 mListView->addColumn(i18n("Content Type"));
86 } 86 }
87 QListView* listView() { return mListView;} 87 Q3ListView* listView() { return mListView;}
88private: 88private:
89 QListView* mListView; 89 Q3ListView* mListView;
90}; 90};
91 91
92OL_access *OL_access::sInstance = 0; 92OL_access *OL_access::sInstance = 0;
93static KStaticDeleter<OL_access> staticDeleterPim; 93static KStaticDeleter<OL_access> staticDeleterPim;
94 94
95OL_access *OL_access::instance() 95OL_access *OL_access::instance()
96{ 96{
97 if ( !sInstance ) { 97 if ( !sInstance ) {
98 sInstance = staticDeleterPim.setObject( new OL_access() ); 98 sInstance = staticDeleterPim.setObject( new OL_access() );
99 } 99 }
100 return sInstance; 100 return sInstance;
101} 101}
102 102
103 103
104OL_access::OL_access() 104OL_access::OL_access()
105{ 105{
106 mErrorInit = true; 106 mErrorInit = true;
107 SCODE sc = ::OleInitialize(NULL); 107 SCODE sc = ::OleInitialize(NULL);
108 if ( FAILED ( sc ) ) { 108 if ( FAILED ( sc ) ) {
109 KMessageBox::information( 0 ,i18n("OLE initialisation failed" )); 109 KMessageBox::information( 0 ,i18n("OLE initialisation failed" ));
110 return; 110 return;
111 } 111 }
112 if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ 112 if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){
113 KMessageBox::information( 0, i18n("Sorry, cannot access Outlook") ); 113 KMessageBox::information( 0, i18n("Sorry, cannot access Outlook") );
114 return ; 114 return ;
115 } 115 }
116 mErrorInit = false; 116 mErrorInit = false;
117} 117}
118OL_access::~OL_access() 118OL_access::~OL_access()
119{ 119{
120 if (sInstance == this) 120 if (sInstance == this)
121 sInstance = staticDeleterPim.setObject(0); 121 sInstance = staticDeleterPim.setObject(0);
122} 122}
123 123
124KABC::Addressee::List OL_access::importOLcontacts() 124KABC::Addressee::List OL_access::importOLcontacts()
125{ 125{
126 KABC::Addressee::List retval; 126 KABC::Addressee::List retval;
127 if ( mErrorInit ) 127 if ( mErrorInit )
128 return retval; 128 return retval;
129 QStringList folderList = getFolderSelection( OL_CONTACT_DATA , i18n("Select Folders to import")); 129 QStringList folderList = getFolderSelection( OL_CONTACT_DATA , i18n("Select Folders to import"));
130 int numFolders = folderList.count()/2; 130 int numFolders = folderList.count()/2;
131 int i; 131 int i;
132 for ( i = 0; i < numFolders; ++i ) { 132 for ( i = 0; i < numFolders; ++i ) {
133 readContactData( getFolderFromID( 0, folderList[(i*2)+1] ) , &retval, false ); 133 readContactData( getFolderFromID( 0, folderList[(i*2)+1] ) , &retval, false );
134 } 134 }
135 KMessageBox::information( 0, i18n("%1 contacts read").arg( retval.count() ) ); 135 KMessageBox::information( 0, i18n("%1 contacts read").arg( retval.count() ) );
136 return retval; 136 return retval;
137} 137}
138void OL_access::readContactData( LPDISPATCH dispItem, KABC::Addressee::List* list, bool syncMode ) 138void OL_access::readContactData( LPDISPATCH dispItem, KABC::Addressee::List* list, bool syncMode )
139{ 139{
140 dispItem->AddRef(); 140 dispItem->AddRef();
141 MAPIFolder mf(dispItem); 141 MAPIFolder mf(dispItem);
142 mf.m_lpDispatch->AddRef(); 142 mf.m_lpDispatch->AddRef();
143 _Items folderItems; 143 _Items folderItems;
144 _variant_t indx((long)0); 144 _variant_t indx((long)0);
145 LPDISPATCH itm; 145 LPDISPATCH itm;
146 int i; 146 int i;
147 folderItems = mf.GetItems(); 147 folderItems = mf.GetItems();
148 QString cap = i18n("Importing contact data"); 148 QString cap = i18n("Importing contact data");
149 if ( syncMode ) { 149 if ( syncMode ) {
150 cap = i18n("Reading contact data..."); 150 cap = i18n("Reading contact data...");
151 } 151 }
152 QProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(), 0 ); 152 Q3ProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(), 0 );
153 bar.setCaption (i18n("Accessing OL") ); 153 bar.setCaption (i18n("Accessing OL") );
154 int h = bar.sizeHint().height() ; 154 int h = bar.sizeHint().height() ;
155 int w = 300; 155 int w = 300;
156 int dw = QApplication::desktop()->width(); 156 int dw = QApplication::desktop()->width();
157 int dh = QApplication::desktop()->height(); 157 int dh = QApplication::desktop()->height();
158 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 158 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
159 bar.show(); 159 bar.show();
160 for(i=1; i <= folderItems.GetCount(); ++i) 160 for(i=1; i <= folderItems.GetCount(); ++i)
161 { 161 {
162 qApp->processEvents(); 162 qApp->processEvents();
163 if ( ! bar.isVisible() ) 163 if ( ! bar.isVisible() )
164 return ; 164 return ;
165 bar.setProgress( i ); 165 bar.setProgress( i );
166 indx = (long)i; 166 indx = (long)i;
167 itm = folderItems.Item(indx.Detach()); 167 itm = folderItems.Item(indx.Detach());
168 _ContactItem * pItem = (_ContactItem *)&itm; 168 _ContactItem * pItem = (_ContactItem *)&itm;
169 list->append( ol2kapiContact( pItem, syncMode ) ); 169 list->append( ol2kapiContact( pItem, syncMode ) );
170 itm->Release(); 170 itm->Release();
171 } 171 }
172} 172}
173QStringList OL_access::getFolderSelection( int type , QString caption ) 173QStringList OL_access::getFolderSelection( int type , QString caption )
174{ 174{
175 OLEFolderSelect folder_dialog; 175 OLEFolderSelect folder_dialog;
176 QListView * listView = folder_dialog.listView(); 176 Q3ListView * listView = folder_dialog.listView();
177 MAPIFolder mfInbox; 177 MAPIFolder mfInbox;
178 MAPIFolder mfRoot; 178 MAPIFolder mfRoot;
179 CString szName; 179 CString szName;
180 _NameSpace olNS; 180 _NameSpace olNS;
181 olNS = gOlAppAB.GetNamespace(_T("MAPI")); 181 olNS = gOlAppAB.GetNamespace(_T("MAPI"));
182 mfInbox = olNS.GetDefaultFolder(6); 182 mfInbox = olNS.GetDefaultFolder(6);
183 mfRoot = mfInbox.GetParent(); 183 mfRoot = mfInbox.GetParent();
184 szName = mfRoot.GetName(); 184 szName = mfRoot.GetName();
185 long iType = mfRoot.GetDefaultItemType(); 185 long iType = mfRoot.GetDefaultItemType();
186 QString mes; 186 QString mes;
187 mes = QString::fromUcs2( szName.GetBuffer() ); 187 mes = QString::fromUcs2( szName.GetBuffer() );
188 OLEListViewItem * root = new OLEListViewItem( listView, mes ); 188 OLEListViewItem * root = new OLEListViewItem( listView, mes );
189 mfRoot.m_lpDispatch->AddRef(); 189 mfRoot.m_lpDispatch->AddRef();
190 addFolder( root, mfRoot.m_lpDispatch, type ); 190 addFolder( root, mfRoot.m_lpDispatch, type );
191 root->setOpen( true ); 191 root->setOpen( true );
192 listView->setSortColumn( 0 ); 192 listView->setSortColumn( 0 );
193 listView->sort( ); 193 listView->sort( );
194 folder_dialog.setCaption( caption ); 194 folder_dialog.setCaption( caption );
195 QStringList retval; 195 QStringList retval;
196 folder_dialog.resize( folder_dialog.sizeHint().width()+50, folder_dialog.sizeHint().height()+50 ); 196 folder_dialog.resize( folder_dialog.sizeHint().width()+50, folder_dialog.sizeHint().height()+50 );
197 if ( folder_dialog.exec() ) { 197 if ( folder_dialog.exec() ) {
198 OLEListViewItem* child = (OLEListViewItem*) listView->firstChild(); 198 OLEListViewItem* child = (OLEListViewItem*) listView->firstChild();
199 while ( child ) { 199 while ( child ) {
200 if ( child->isOn() && ! child->firstChild() ) { 200 if ( child->isOn() && ! child->firstChild() ) {
201 retval << child->text( 0 ); 201 retval << child->text( 0 );
202 retval << child->dataID(); 202 retval << child->dataID();
203 } 203 }
204 child = (OLEListViewItem*) child->itemBelow(); 204 child = (OLEListViewItem*) child->itemBelow();
205 } 205 }
206 //KMessageBox::information(0,retval.join(" \n ")); 206 //KMessageBox::information(0,retval.join(" \n "));
207 } 207 }
208 return retval; 208 return retval;
209} 209}
210void OL_access::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent, long fType) 210void OL_access::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent, long fType)
211{ 211{
212 MAPIFolder mfParent(dispParent), mfChild; 212 MAPIFolder mfParent(dispParent), mfChild;
213 _Folders folders; 213 _Folders folders;
214 _variant_t fndx((long)0); 214 _variant_t fndx((long)0);
215 CString szName; 215 CString szName;
216 long iType; 216 long iType;
217 OLEListViewItem* hChild; 217 OLEListViewItem* hChild;
218 218
219 folders = mfParent.GetFolders(); 219 folders = mfParent.GetFolders();
220 for(int i=1; i <= folders.GetCount(); ++i) 220 for(int i=1; i <= folders.GetCount(); ++i)
221 { 221 {
222 iParent->setEnabled( true ); 222 iParent->setEnabled( true );
223 fndx = (long)i; 223 fndx = (long)i;
224 mfChild = folders.Item(fndx.Detach()); 224 mfChild = folders.Item(fndx.Detach());
225 mfChild.m_lpDispatch->AddRef(); 225 mfChild.m_lpDispatch->AddRef();
226 szName = mfChild.GetName(); 226 szName = mfChild.GetName();
227 iType = mfChild.GetDefaultItemType(); 227 iType = mfChild.GetDefaultItemType();
228 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); 228 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
229 hChild->setDataID( QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) ); 229 hChild->setDataID( QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) );
230 if ( iType != fType) 230 if ( iType != fType)
231 hChild->setEnabled( false ); 231 hChild->setEnabled( false );
232 QString ts; 232 QString ts;
233 switch( iType ) { 233 switch( iType ) {
234 case 0: 234 case 0:
235 ts = i18n("Mail"); 235 ts = i18n("Mail");
236 break; 236 break;
237 case 1: 237 case 1:
238 ts = i18n("Calendar"); 238 ts = i18n("Calendar");
239 break; 239 break;
240 case 2: 240 case 2:
241 ts = i18n("Contacts"); 241 ts = i18n("Contacts");
242 break; 242 break;
243 case 3: 243 case 3:
244 ts = i18n("Todos"); 244 ts = i18n("Todos");
245 break; 245 break;
246 case 4: 246 case 4:
247 ts = i18n("Journals"); 247 ts = i18n("Journals");
248 break; 248 break;
249 case 5: 249 case 5:
250 ts = i18n("Notes"); 250 ts = i18n("Notes");
251 break; 251 break;
252 default: 252 default:
253 ts = i18n("Unknown"); 253 ts = i18n("Unknown");
254 } 254 }
255 hChild->setText( 1,ts); 255 hChild->setText( 1,ts);
256 hChild->setData( (DWORD) mfChild.m_lpDispatch ); 256 hChild->setData( (DWORD) mfChild.m_lpDispatch );
257 mfChild.m_lpDispatch->AddRef(); 257 mfChild.m_lpDispatch->AddRef();
258 addFolder(hChild, mfChild.m_lpDispatch, fType); 258 addFolder(hChild, mfChild.m_lpDispatch, fType);
259 } 259 }
260} 260}
261 261
262void OL_access::deleteAddressee( KABC::Addressee a ) 262void OL_access::deleteAddressee( KABC::Addressee a )
263{ 263{
264 LPDISPATCH itm = getOLcontactItemFromUid ( a.originalExternalUID() ); 264 LPDISPATCH itm = getOLcontactItemFromUid ( a.originalExternalUID() );
265 _ContactItem* cItem = (_ContactItem *)&itm; 265 _ContactItem* cItem = (_ContactItem *)&itm;
266 if ( cItem != 0 ) { 266 if ( cItem != 0 ) {
267 //KMessageBox::information(0,"delete: item found " + a.formattedName() + QString::fromUcs2(cItem->GetLastName().GetBuffer())); 267 //KMessageBox::information(0,"delete: item found " + a.formattedName() + QString::fromUcs2(cItem->GetLastName().GetBuffer()));
268 cItem->Delete(); 268 cItem->Delete();
269 } 269 }
270} 270}
271KABC::Addressee OL_access::changeAddressee( KABC::Addressee a ) 271KABC::Addressee OL_access::changeAddressee( KABC::Addressee a )
272{ 272{
273 LPDISPATCH itm = getOLcontactItemFromUid ( a.originalExternalUID() ); 273 LPDISPATCH itm = getOLcontactItemFromUid ( a.originalExternalUID() );
274 _ContactItem* cItem = (_ContactItem *)&itm; 274 _ContactItem* cItem = (_ContactItem *)&itm;
275 if ( cItem != 0 ) { 275 if ( cItem != 0 ) {
276 //KMessageBox::information(0,"Change: item found " + a.formattedName()); 276 //KMessageBox::information(0,"Change: item found " + a.formattedName());
277 writeData2OLitem( a, cItem ); 277 writeData2OLitem( a, cItem );
278 KABC::Addressee retval = ol2kapiContact( cItem , true ); 278 KABC::Addressee retval = ol2kapiContact( cItem , true );
279 retval.setUid( a.uid() ); 279 retval.setUid( a.uid() );
280 retval.setExternalUID( a.originalExternalUID() ); 280 retval.setExternalUID( a.originalExternalUID() );
281 retval.setOriginalExternalUID( a.originalExternalUID() ); 281 retval.setOriginalExternalUID( a.originalExternalUID() );
282 return retval; 282 return retval;
283 } 283 }
284 return KABC::Addressee(); 284 return KABC::Addressee();
285} 285}
286KABC::Addressee OL_access::addAddressee( KABC::Addressee a ) 286KABC::Addressee OL_access::addAddressee( KABC::Addressee a )
287{ 287{
288 QString newOLid; 288 QString newOLid;
289 LPDISPATCH c_itm = gOlAppAB.CreateItem(2); 289 LPDISPATCH c_itm = gOlAppAB.CreateItem(2);
290 _ContactItem * aItem = (_ContactItem *)&c_itm ; 290 _ContactItem * aItem = (_ContactItem *)&c_itm ;
291 writeData2OLitem( a, aItem ); 291 writeData2OLitem( a, aItem );
292 newOLid = QString::fromUcs2(aItem->GetEntryID().GetBuffer()); 292 newOLid = QString::fromUcs2(aItem->GetEntryID().GetBuffer());
293 KABC::Addressee retval = ol2kapiContact( aItem , true ); 293 KABC::Addressee retval = ol2kapiContact( aItem , true );
294 retval.setUid( a.uid() ); 294 retval.setUid( a.uid() );
295 retval.setExternalUID( newOLid ); 295 retval.setExternalUID( newOLid );
296 retval.setOriginalExternalUID( newOLid ); 296 retval.setOriginalExternalUID( newOLid );
297 return retval; 297 return retval;
298} 298}
299 299
300LPDISPATCH OL_access::getOLcontactItemFromUid( QString uid ) 300LPDISPATCH OL_access::getOLcontactItemFromUid( QString uid )
301{ 301{
302 _variant_t indx((long)0); 302 _variant_t indx((long)0);
303 LPDISPATCH itm; 303 LPDISPATCH itm;
304 int i; 304 int i;
305 for(i=1; i <= mFolderItems.GetCount(); ++i) 305 for(i=1; i <= mFolderItems.GetCount(); ++i)
306 { 306 {
307 qApp->processEvents(); 307 qApp->processEvents();
308 indx = (long)i; 308 indx = (long)i;
309 itm = mFolderItems.Item(indx.Detach()); 309 itm = mFolderItems.Item(indx.Detach());
310 _ContactItem * pItem = (_ContactItem *)&itm; 310 _ContactItem * pItem = (_ContactItem *)&itm;
311 if ( QString::fromUcs2(pItem->GetEntryID().GetBuffer()) == uid ) 311 if ( QString::fromUcs2(pItem->GetEntryID().GetBuffer()) == uid )
312 return itm; 312 return itm;
313 itm->Release(); 313 itm->Release();
314 } 314 }
315 return 0; 315 return 0;
316} 316}
317bool OL_access::setSelectedFolder( QString folderID ) 317bool OL_access::setSelectedFolder( QString folderID )
318{ 318{
319 if ( mErrorInit ) 319 if ( mErrorInit )
320 return false; 320 return false;
321 mSelectedFolderID = folderID; 321 mSelectedFolderID = folderID;
322 mSelectedFolder = getFolderFromID( 0,mSelectedFolderID ); 322 mSelectedFolder = getFolderFromID( 0,mSelectedFolderID );
323 if ( mSelectedFolder == 0 ) { 323 if ( mSelectedFolder == 0 ) {
324 KMessageBox::information(0,i18n("OL access: No folder found for id\n%1").arg( mSelectedFolderID )); 324 KMessageBox::information(0,i18n("OL access: No folder found for id\n%1").arg( mSelectedFolderID ));
325 return false; 325 return false;
326 } 326 }
327 LPDISPATCH dispItem = mSelectedFolder; 327 LPDISPATCH dispItem = mSelectedFolder;
328 dispItem->AddRef(); 328 dispItem->AddRef();
329 MAPIFolder mf(dispItem); 329 MAPIFolder mf(dispItem);
330 mf.m_lpDispatch->AddRef(); 330 mf.m_lpDispatch->AddRef();
331 mFolderItems = mf.GetItems(); 331 mFolderItems = mf.GetItems();
332 return true; 332 return true;
333} 333}
334 334
335QDateTime OL_access::mDdate2Qdtr( DATE dt) 335QDateTime OL_access::mDdate2Qdtr( DATE dt)
336{ 336{
337 COleDateTime odt; 337 COleDateTime odt;
338 SYSTEMTIME st; 338 SYSTEMTIME st;
339 odt = dt; 339 odt = dt;
340 if ( odt.GetStatus() != 0 ) 340 if ( odt.GetStatus() != 0 )
341 return QDateTime(); 341 return QDateTime();
342 odt.GetAsSystemTime(st); 342 odt.GetAsSystemTime(st);
343 if ( st.wYear > 4000 ) // this program as a year 4000 bug! 343 if ( st.wYear > 4000 ) // this program as a year 4000 bug!
344 return QDateTime(); 344 return QDateTime();
345 // it seems so, that 1.1.4501 indicates: DATE invalid 345 // it seems so, that 1.1.4501 indicates: DATE invalid
346 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); 346 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
347 return qdt; 347 return qdt;
348} 348}
349DATE OL_access::Qdt2date( QDateTime dt ) 349DATE OL_access::Qdt2date( QDateTime dt )
350{ 350{
351 DATE ddd; 351 DATE ddd;
352 COleDateTime odt; 352 COleDateTime odt;
353 odt.SetDateTime(dt.date().year(), dt.date().month(),dt.date().day(), 353 odt.SetDateTime(dt.date().year(), dt.date().month(),dt.date().day(),
354 dt.time().hour(), dt.time().minute(), dt.time().second() ); 354 dt.time().hour(), dt.time().minute(), dt.time().second() );
355 ddd = odt; 355 ddd = odt;
356 return ddd; 356 return ddd;
357} 357}
358 358
359LPDISPATCH OL_access::getFolderFromID( LPDISPATCH parentFolder, QString selectedFolderID ) 359LPDISPATCH OL_access::getFolderFromID( LPDISPATCH parentFolder, QString selectedFolderID )
360{ 360{
361 if ( parentFolder == 0 ) { 361 if ( parentFolder == 0 ) {
362 MAPIFolder mfInbox; 362 MAPIFolder mfInbox;
363 MAPIFolder mfRoot; 363 MAPIFolder mfRoot;
364 CString szName; 364 CString szName;
365 _NameSpace olNS; 365 _NameSpace olNS;
366 olNS = gOlAppAB.GetNamespace(_T("MAPI")); 366 olNS = gOlAppAB.GetNamespace(_T("MAPI"));
367 mfInbox = olNS.GetDefaultFolder(6); 367 mfInbox = olNS.GetDefaultFolder(6);
368 mfRoot = mfInbox.GetParent(); 368 mfRoot = mfInbox.GetParent();
369 szName = mfRoot.GetName(); 369 szName = mfRoot.GetName();
370 mfRoot.m_lpDispatch->AddRef(); 370 mfRoot.m_lpDispatch->AddRef();
371 return getFolderFromID( mfRoot.m_lpDispatch ,selectedFolderID); 371 return getFolderFromID( mfRoot.m_lpDispatch ,selectedFolderID);
372 } 372 }
373 373
374 MAPIFolder mfParent(parentFolder), mfChild; 374 MAPIFolder mfParent(parentFolder), mfChild;
375 _Folders folders; 375 _Folders folders;
376 _variant_t fndx((long)0); 376 _variant_t fndx((long)0);
377 CString szName; 377 CString szName;
378 long iType; 378 long iType;
379 OLEListViewItem* hChild; 379 OLEListViewItem* hChild;
380 folders = mfParent.GetFolders(); 380 folders = mfParent.GetFolders();
381 for(int i=1; i <= folders.GetCount(); ++i) 381 for(int i=1; i <= folders.GetCount(); ++i)
382 { 382 {
383 fndx = (long)i; 383 fndx = (long)i;
384 mfChild = folders.Item(fndx.Detach()); 384 mfChild = folders.Item(fndx.Detach());
385 mfChild.m_lpDispatch->AddRef(); 385 mfChild.m_lpDispatch->AddRef();
386 szName = mfChild.GetName(); 386 szName = mfChild.GetName();
387 iType = mfChild.GetDefaultItemType(); 387 iType = mfChild.GetDefaultItemType();
388 if ( selectedFolderID == QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) ) { 388 if ( selectedFolderID == QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) ) {
389 return mfChild.m_lpDispatch; 389 return mfChild.m_lpDispatch;
390 } 390 }
391 LPDISPATCH resultFolder = getFolderFromID(mfChild.m_lpDispatch ,selectedFolderID); 391 LPDISPATCH resultFolder = getFolderFromID(mfChild.m_lpDispatch ,selectedFolderID);
392 if ( resultFolder != 0 ) 392 if ( resultFolder != 0 )
393 return resultFolder; 393 return resultFolder;
394 } 394 }
395 return 0; 395 return 0;
396} 396}
397void OL_access::writeData2OLitem( KABC::Addressee addressee, _ContactItem * aItem ) 397void OL_access::writeData2OLitem( KABC::Addressee addressee, _ContactItem * aItem )
398{ 398{
399 // addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); 399 // addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer()));
400 //GetLastModificationTime() 400 //GetLastModificationTime()
401 //addressee.setName( const QString &name ); 401 //addressee.setName( const QString &name );
402 402
403 aItem->SetFileAs(addressee.formattedName().ucs2()); 403 aItem->SetFileAs(addressee.formattedName().ucs2());
404 aItem->SetLastName(addressee.familyName().ucs2()); 404 aItem->SetLastName(addressee.familyName().ucs2());
405 aItem->SetFirstName(addressee.givenName( ).ucs2()); 405 aItem->SetFirstName(addressee.givenName( ).ucs2());
406 aItem->SetMiddleName(addressee.additionalName( ).ucs2()); 406 aItem->SetMiddleName(addressee.additionalName( ).ucs2());
407 aItem->SetTitle(addressee.prefix().ucs2()); 407 aItem->SetTitle(addressee.prefix().ucs2());
408 aItem->SetSuffix(addressee.suffix( ).ucs2()); 408 aItem->SetSuffix(addressee.suffix( ).ucs2());
409 aItem->SetNickName(addressee.nickName( ).ucs2()); 409 aItem->SetNickName(addressee.nickName( ).ucs2());
410 if ( addressee.birthday().isValid() ) 410 if ( addressee.birthday().isValid() )
411 aItem->SetBirthday(Qdt2date(addressee.birthday())); 411 aItem->SetBirthday(Qdt2date(addressee.birthday()));
412 else 412 else
413 aItem->SetBirthday(Qdt2date(QDateTime(QDate( 4501,1,1 )))); 413 aItem->SetBirthday(Qdt2date(QDateTime(QDate( 4501,1,1 ))));
414 //).ucs2()(aItem->) 414 //).ucs2()(aItem->)
415 //addressee.Mailer( const QString &mailer ); 415 //addressee.Mailer( const QString &mailer );
416 //addressee.TimeZone( const TimeZone &timeZone ); 416 //addressee.TimeZone( const TimeZone &timeZone );
417 //addressee.Geo( const Geo &geo ); 417 //addressee.Geo( const Geo &geo );
418 //addressee.Title( ).ucs2()(aItem->SetJobTitle()) );// titel is the prefix 418 //addressee.Title( ).ucs2()(aItem->SetJobTitle()) );// titel is the prefix
419 aItem->SetJobTitle(addressee.role( ).ucs2()); 419 aItem->SetJobTitle(addressee.role( ).ucs2());
420 aItem->SetCompanyName(addressee.organization( ).ucs2()); 420 aItem->SetCompanyName(addressee.organization( ).ucs2());
421 QString notesStr = addressee.note(); 421 QString notesStr = addressee.note();
422 notesStr.replace( QRegExp("\\n"), "\n\r"); 422 notesStr.replace( QRegExp("\\n"), "\n\r");
423 aItem->SetBody(notesStr.ucs2()); 423 aItem->SetBody(notesStr.ucs2());
424 424
425 aItem->SetCustomerID(addressee.productId( ).ucs2()); 425 aItem->SetCustomerID(addressee.productId( ).ucs2());
426 //addressee.Revision( const QDateTime &revision ); 426 //addressee.Revision( const QDateTime &revision );
427 // addressee.SortString( const QString &sortString ); 427 // addressee.SortString( const QString &sortString );
428 aItem->SetWebPage( addressee.url().url().ucs2()); 428 aItem->SetWebPage( addressee.url().url().ucs2());
429 429
430 QString tempS; 430 QString tempS;
431 431
432 432
433 tempS = addressee.custom( "KADDRESSBOOK", "X-IMAddress"); 433 tempS = addressee.custom( "KADDRESSBOOK", "X-IMAddress");
434 aItem->SetNetMeetingAlias(tempS.ucs2()); 434 aItem->SetNetMeetingAlias(tempS.ucs2());
435 435
436 tempS = addressee.custom( "KADDRESSBOOK", "X-SpousesName" ); 436 tempS = addressee.custom( "KADDRESSBOOK", "X-SpousesName" );
437 aItem->SetSpouse(tempS.ucs2()); 437 aItem->SetSpouse(tempS.ucs2());
438 438
439 tempS = addressee.custom( "KADDRESSBOOK", "X-ManagersName" ); 439 tempS = addressee.custom( "KADDRESSBOOK", "X-ManagersName" );
440 aItem->SetManagerName(tempS.ucs2()); 440 aItem->SetManagerName(tempS.ucs2());
441 441
442 tempS = addressee.custom( "KADDRESSBOOK", "X-AssistantsName" ); 442 tempS = addressee.custom( "KADDRESSBOOK", "X-AssistantsName" );
443 aItem->SetAssistantName(tempS.ucs2()); 443 aItem->SetAssistantName(tempS.ucs2());
444 444
445 tempS = addressee.custom( "KADDRESSBOOK", "X-Department" ); 445 tempS = addressee.custom( "KADDRESSBOOK", "X-Department" );
446 aItem->SetDepartment(tempS.ucs2()); 446 aItem->SetDepartment(tempS.ucs2());
447 447
448 tempS = addressee.custom( "KADDRESSBOOK", "X-Office" ); 448 tempS = addressee.custom( "KADDRESSBOOK", "X-Office" );
449 aItem->SetOfficeLocation(tempS.ucs2()); 449 aItem->SetOfficeLocation(tempS.ucs2());
450 450
451 tempS = addressee.custom( "KADDRESSBOOK", "X-Profession"); 451 tempS = addressee.custom( "KADDRESSBOOK", "X-Profession");
452 aItem->SetProfession(tempS.ucs2()); 452 aItem->SetProfession(tempS.ucs2());
453 453
454 tempS = addressee.custom( "KADDRESSBOOK", "X-Anniversary"); 454 tempS = addressee.custom( "KADDRESSBOOK", "X-Anniversary");
455 if ( !tempS.isEmpty() ){ 455 if ( !tempS.isEmpty() ){
456 QDateTime dt = QDateTime ( KGlobal::locale()->readDate( tempS,"%Y-%m-%d") ); 456 QDateTime dt = QDateTime ( KGlobal::locale()->readDate( tempS,"%Y-%m-%d") );
457 aItem->SetAnniversary(Qdt2date( dt )); 457 aItem->SetAnniversary(Qdt2date( dt ));
458 } else { 458 } else {
459 aItem->SetAnniversary(Qdt2date(QDateTime(QDate( 4501,1,1 )))); 459 aItem->SetAnniversary(Qdt2date(QDateTime(QDate( 4501,1,1 ))));
460 } 460 }
461 int sec = (int)addressee.secrecy().type(); 461 int sec = (int)addressee.secrecy().type();
462 if ( sec > 0 )// mapping pers -> private 462 if ( sec > 0 )// mapping pers -> private
463 ++sec; 463 ++sec;
464 aItem->SetSensitivity( sec ) ; 464 aItem->SetSensitivity( sec ) ;
465 //addressee.Logo( const Picture &logo ); 465 //addressee.Logo( const Picture &logo );
466 //addressee.Photo( const Picture &photo ); 466 //addressee.Photo( const Picture &photo );
467 //addressee.Sound( const Sound &sound ); 467 //addressee.Sound( const Sound &sound );
468 //addressee.Agent( const Agent &agent ); 468 //addressee.Agent( const Agent &agent );
469 469
470 QString cat = addressee.categories().join("; "); 470 QString cat = addressee.categories().join("; ");
471 aItem->SetCategories( cat.ucs2()); 471 aItem->SetCategories( cat.ucs2());
472 472
473 473
474 KABC::PhoneNumber::List phoneNumbers; 474 KABC::PhoneNumber::List phoneNumbers;
475 KABC::PhoneNumber::List::Iterator phoneIter; 475 KABC::PhoneNumber::List::Iterator phoneIter;
476 phoneNumbers = addressee.phoneNumbers(); 476 phoneNumbers = addressee.phoneNumbers();
477 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 477 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
478 ++phoneIter ) { 478 ++phoneIter ) {
479 479
480 } 480 }
481 QString phoneS; 481 QString phoneS;
482 482
483 phoneS = addressee.phoneNumberString( 483 phoneS = addressee.phoneNumberString(
484 KABC::PhoneNumber::Work + 484 KABC::PhoneNumber::Work +
485 KABC::PhoneNumber::Voice + 485 KABC::PhoneNumber::Voice +
486 KABC::PhoneNumber::Msg ); 486 KABC::PhoneNumber::Msg );
487 aItem->SetAssistantTelephoneNumber(phoneS.ucs2()); 487 aItem->SetAssistantTelephoneNumber(phoneS.ucs2());
488 488
489 phoneS = addressee.phoneNumberString( 489 phoneS = addressee.phoneNumberString(
490 KABC::PhoneNumber::Work + 490 KABC::PhoneNumber::Work +
491 KABC::PhoneNumber::Pref) ; 491 KABC::PhoneNumber::Pref) ;
492 aItem->SetBusinessTelephoneNumber(phoneS.ucs2()); 492 aItem->SetBusinessTelephoneNumber(phoneS.ucs2());
493 493
494 phoneS = addressee.phoneNumberString( 494 phoneS = addressee.phoneNumberString(
495 KABC::PhoneNumber::Work ) ; 495 KABC::PhoneNumber::Work ) ;
496 aItem->SetBusiness2TelephoneNumber(phoneS.ucs2()); 496 aItem->SetBusiness2TelephoneNumber(phoneS.ucs2());
497 497
498 phoneS = addressee.phoneNumberString( 498 phoneS = addressee.phoneNumberString(
499 KABC::PhoneNumber::Work + 499 KABC::PhoneNumber::Work +
500 KABC::PhoneNumber::Fax ) ; 500 KABC::PhoneNumber::Fax ) ;
501 aItem->SetBusinessFaxNumber(phoneS.ucs2()); 501 aItem->SetBusinessFaxNumber(phoneS.ucs2());
502 502
503 503
504 phoneS = addressee.phoneNumberString( 504 phoneS = addressee.phoneNumberString(
505 KABC::PhoneNumber::Car ) ; 505 KABC::PhoneNumber::Car ) ;
506 aItem->SetCarTelephoneNumber(phoneS.ucs2()); 506 aItem->SetCarTelephoneNumber(phoneS.ucs2());
507 507
508 phoneS = addressee.phoneNumberString( 508 phoneS = addressee.phoneNumberString(
509 KABC::PhoneNumber::Home + 509 KABC::PhoneNumber::Home +
510 KABC::PhoneNumber::Pref ) ; 510 KABC::PhoneNumber::Pref ) ;
511 aItem->SetHomeTelephoneNumber(phoneS.ucs2()); 511 aItem->SetHomeTelephoneNumber(phoneS.ucs2());
512 512
513 phoneS = addressee.phoneNumberString( 513 phoneS = addressee.phoneNumberString(
514 KABC::PhoneNumber::Home ) ; 514 KABC::PhoneNumber::Home ) ;
515 aItem->SetHome2TelephoneNumber(phoneS.ucs2()); 515 aItem->SetHome2TelephoneNumber(phoneS.ucs2());
516 516
517 phoneS = addressee.phoneNumberString( 517 phoneS = addressee.phoneNumberString(
518 KABC::PhoneNumber::Home + 518 KABC::PhoneNumber::Home +
519 KABC::PhoneNumber::Fax ) ; 519 KABC::PhoneNumber::Fax ) ;
520 aItem->SetHomeFaxNumber(phoneS.ucs2()); 520 aItem->SetHomeFaxNumber(phoneS.ucs2());
521 521
522 phoneS = addressee.phoneNumberString( 522 phoneS = addressee.phoneNumberString(
523 KABC::PhoneNumber::Isdn ) ; 523 KABC::PhoneNumber::Isdn ) ;
524 aItem->SetISDNNumber(phoneS.ucs2()); 524 aItem->SetISDNNumber(phoneS.ucs2());
525 525
526 phoneS = addressee.phoneNumberString( 526 phoneS = addressee.phoneNumberString(
527 KABC::PhoneNumber::Cell ) ; 527 KABC::PhoneNumber::Cell ) ;
528 aItem->SetMobileTelephoneNumber(phoneS.ucs2()); 528 aItem->SetMobileTelephoneNumber(phoneS.ucs2());
529 529
530 phoneS = addressee.phoneNumberString( 530 phoneS = addressee.phoneNumberString(
531 KABC::PhoneNumber::Fax ) ; 531 KABC::PhoneNumber::Fax ) ;
532 aItem->SetOtherFaxNumber(phoneS.ucs2()); 532 aItem->SetOtherFaxNumber(phoneS.ucs2());
533 533
534 phoneS = addressee.phoneNumberString( 534 phoneS = addressee.phoneNumberString(
535 KABC::PhoneNumber::Voice ) ; 535 KABC::PhoneNumber::Voice ) ;
536 aItem->SetOtherTelephoneNumber(phoneS.ucs2()); 536 aItem->SetOtherTelephoneNumber(phoneS.ucs2());
537 537
538 phoneS = addressee.phoneNumberString( 538 phoneS = addressee.phoneNumberString(
539 KABC::PhoneNumber::Pager ) ; 539 KABC::PhoneNumber::Pager ) ;
540 aItem->SetPagerNumber(phoneS.ucs2()); 540 aItem->SetPagerNumber(phoneS.ucs2());
541 541
542 phoneS = addressee.phoneNumberString( 542 phoneS = addressee.phoneNumberString(
543 KABC::PhoneNumber::Pref ) ; 543 KABC::PhoneNumber::Pref ) ;
544 aItem->SetPrimaryTelephoneNumber(phoneS.ucs2()); 544 aItem->SetPrimaryTelephoneNumber(phoneS.ucs2());
545 545
546 phoneS = addressee.phoneNumberString( 546 phoneS = addressee.phoneNumberString(
547 KABC::PhoneNumber::Pcs + 547 KABC::PhoneNumber::Pcs +
548 KABC::PhoneNumber::Voice) ; 548 KABC::PhoneNumber::Voice) ;
549 aItem->SetTTYTDDTelephoneNumber(phoneS.ucs2()); 549 aItem->SetTTYTDDTelephoneNumber(phoneS.ucs2());
550 550
551 phoneS = addressee.phoneNumberString( 551 phoneS = addressee.phoneNumberString(
552 KABC::PhoneNumber::Pcs ) ; 552 KABC::PhoneNumber::Pcs ) ;
553 aItem->SetTelexNumber(phoneS.ucs2()); 553 aItem->SetTelexNumber(phoneS.ucs2());
554 554
555 phoneS = addressee.phoneNumberString( 555 phoneS = addressee.phoneNumberString(
556 KABC::PhoneNumber::Work + 556 KABC::PhoneNumber::Work +
557 KABC::PhoneNumber::Msg ) ; 557 KABC::PhoneNumber::Msg ) ;
558 aItem->SetCompanyMainTelephoneNumber(phoneS.ucs2()); 558 aItem->SetCompanyMainTelephoneNumber(phoneS.ucs2());
559 559
560 phoneS = addressee.phoneNumberString( 560 phoneS = addressee.phoneNumberString(
561 KABC::PhoneNumber::Pcs + 561 KABC::PhoneNumber::Pcs +
562 KABC::PhoneNumber::Pref ) ; 562 KABC::PhoneNumber::Pref ) ;
563 aItem->SetRadioTelephoneNumber(phoneS.ucs2()); 563 aItem->SetRadioTelephoneNumber(phoneS.ucs2());
564 564
565 phoneS = addressee.phoneNumberString( 565 phoneS = addressee.phoneNumberString(
566 KABC::PhoneNumber::Msg ) ; 566 KABC::PhoneNumber::Msg ) ;
567 aItem->SetCallbackTelephoneNumber(phoneS.ucs2()); 567 aItem->SetCallbackTelephoneNumber(phoneS.ucs2());
568 568
569 QStringList emails = addressee.emails(); 569 QStringList emails = addressee.emails();
570 emails << "" << "" << ""; 570 emails << "" << "" << "";
571 aItem->SetEmail1Address(emails[0].ucs2()); 571 aItem->SetEmail1Address(emails[0].ucs2());
572 aItem->SetEmail2Address(emails[1].ucs2()); 572 aItem->SetEmail2Address(emails[1].ucs2());
573 aItem->SetEmail3Address(emails[2].ucs2()); 573 aItem->SetEmail3Address(emails[2].ucs2());
574 574
575 // is this the number of the preferred email? 575 // is this the number of the preferred email?
576 //long GetSelectedMailingAddress();??? 576 //long GetSelectedMailingAddress();???
577 577
578 KABC::Address addressHome = addressee.address( KABC::Address::Home ); 578 KABC::Address addressHome = addressee.address( KABC::Address::Home );
579 KABC::Address* addressAdd = &addressHome; 579 KABC::Address* addressAdd = &addressHome;
580 aItem->SetHomeAddressCountry(addressAdd->country().ucs2()); 580 aItem->SetHomeAddressCountry(addressAdd->country().ucs2());
581 aItem->SetHomeAddressState(addressAdd->region().ucs2()); 581 aItem->SetHomeAddressState(addressAdd->region().ucs2());
582 aItem->SetHomeAddressCity(addressAdd->locality().ucs2()); 582 aItem->SetHomeAddressCity(addressAdd->locality().ucs2());
583 aItem->SetHomeAddressPostalCode(addressAdd->postalCode().ucs2()); 583 aItem->SetHomeAddressPostalCode(addressAdd->postalCode().ucs2());
584 aItem->SetHomeAddressPostOfficeBox(addressAdd->postOfficeBox().ucs2()); 584 aItem->SetHomeAddressPostOfficeBox(addressAdd->postOfficeBox().ucs2());
585 aItem->SetHomeAddressStreet(addressAdd->street().ucs2()); 585 aItem->SetHomeAddressStreet(addressAdd->street().ucs2());
586 586
587 addressHome = addressee.address( KABC::Address::Work ); 587 addressHome = addressee.address( KABC::Address::Work );
588 addressAdd = &addressHome; 588 addressAdd = &addressHome;
589 aItem->SetBusinessAddressCountry(addressAdd->country().ucs2()); 589 aItem->SetBusinessAddressCountry(addressAdd->country().ucs2());
590 aItem->SetBusinessAddressState(addressAdd->region().ucs2()); 590 aItem->SetBusinessAddressState(addressAdd->region().ucs2());
591 aItem->SetBusinessAddressCity(addressAdd->locality().ucs2()); 591 aItem->SetBusinessAddressCity(addressAdd->locality().ucs2());
592 aItem->SetBusinessAddressPostalCode(addressAdd->postalCode().ucs2()); 592 aItem->SetBusinessAddressPostalCode(addressAdd->postalCode().ucs2());
593 aItem->SetBusinessAddressPostOfficeBox(addressAdd->postOfficeBox().ucs2()); 593 aItem->SetBusinessAddressPostOfficeBox(addressAdd->postOfficeBox().ucs2());
594 aItem->SetBusinessAddressStreet(addressAdd->street().ucs2()); 594 aItem->SetBusinessAddressStreet(addressAdd->street().ucs2());
595 595
596 addressHome = addressee.otherAddress(); 596 addressHome = addressee.otherAddress();
597 addressAdd = &addressHome; 597 addressAdd = &addressHome;
598 aItem->SetOtherAddressCountry(addressAdd->country().ucs2()); 598 aItem->SetOtherAddressCountry(addressAdd->country().ucs2());
599 aItem->SetOtherAddressState(addressAdd->region().ucs2()); 599 aItem->SetOtherAddressState(addressAdd->region().ucs2());
600 aItem->SetOtherAddressCity(addressAdd->locality().ucs2()); 600 aItem->SetOtherAddressCity(addressAdd->locality().ucs2());
601 aItem->SetOtherAddressPostalCode(addressAdd->postalCode().ucs2()); 601 aItem->SetOtherAddressPostalCode(addressAdd->postalCode().ucs2());
602 aItem->SetOtherAddressPostOfficeBox(addressAdd->postOfficeBox().ucs2()); 602 aItem->SetOtherAddressPostOfficeBox(addressAdd->postOfficeBox().ucs2());
603 aItem->SetOtherAddressStreet(addressAdd->street().ucs2()); 603 aItem->SetOtherAddressStreet(addressAdd->street().ucs2());
604 604
605 aItem->SetInternetFreeBusyAddress(addressee.custom( "KADDRESSBOOK", "X-FreeBusyUrl" ).ucs2()); 605 aItem->SetInternetFreeBusyAddress(addressee.custom( "KADDRESSBOOK", "X-FreeBusyUrl" ).ucs2());
606 aItem->SetChildren(addressee.custom( "KADDRESSBOOK", "X-Children").ucs2()); 606 aItem->SetChildren(addressee.custom( "KADDRESSBOOK", "X-Children").ucs2());
607 607
608 int gen = 0;// 0 undef - 1 female - 2 male 608 int gen = 0;// 0 undef - 1 female - 2 male
609 QString gend = addressee.custom( "KADDRESSBOOK", "X-Gender" ); 609 QString gend = addressee.custom( "KADDRESSBOOK", "X-Gender" );
610 if ( gend == "female" ) 610 if ( gend == "female" )
611 gen = 1; 611 gen = 1;
612 if ( gend == "male" ) 612 if ( gend == "male" )
613 gen = 2; 613 gen = 2;
614 aItem->SetGender(gen); 614 aItem->SetGender(gen);
615 615
616 aItem->Save(); 616 aItem->Save();
617} 617}
618KABC::Addressee OL_access::ol2kapiContact( _ContactItem * aItem , bool syncMode) 618KABC::Addressee OL_access::ol2kapiContact( _ContactItem * aItem , bool syncMode)
619{ 619{
620 KABC::Addressee addressee; 620 KABC::Addressee addressee;
621 621
622 addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); 622 addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer()));
623 //GetLastModificationTime() 623 //GetLastModificationTime()
624 //addressee.setName( const QString &name ); 624 //addressee.setName( const QString &name );
625 addressee.setFormattedName( QString::fromUcs2(aItem->GetFileAs().GetBuffer()) ); 625 addressee.setFormattedName( QString::fromUcs2(aItem->GetFileAs().GetBuffer()) );
626 addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); 626 addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) );
627 addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); 627 addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) );
628 addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); 628 addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) );
629 addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); 629 addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) );
630 addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); 630 addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) );
631 addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); 631 addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) );
632 QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); 632 QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday());
633 if ( dtb.isValid() ) 633 if ( dtb.isValid() )
634 addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); 634 addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday()));
635 635
636 //QString::fromUcs2(aItem->.GetBuffer()) 636 //QString::fromUcs2(aItem->.GetBuffer())
637 //addressee.setMailer( const QString &mailer ); 637 //addressee.setMailer( const QString &mailer );
638 //addressee.setTimeZone( const TimeZone &timeZone ); 638 //addressee.setTimeZone( const TimeZone &timeZone );
639 //addressee.setGeo( const Geo &geo ); 639 //addressee.setGeo( const Geo &geo );
640 //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix 640 //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix
641 addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); 641 addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );
642 addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") ); 642 addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") );
643 QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer()); 643 QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer());
644 notesStr.replace( QRegExp("\\r"), ""); 644 notesStr.replace( QRegExp("\\r"), "");
645 645
646 addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); 646 addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) );
647 //addressee.setRevision( const QDateTime &revision ); 647 //addressee.setRevision( const QDateTime &revision );
648 // addressee.setSortString( const QString &sortString ); 648 // addressee.setSortString( const QString &sortString );
649 addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); 649 addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) );
650 650
651 QString tempS; 651 QString tempS;
652 tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer());//+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); 652 tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer());//+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer());
653 if ( tempS.length() > 12 ) 653 if ( tempS.length() > 12 )
654 addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); 654 addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS );
655 tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); 655 tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer());
656 if ( !tempS.isEmpty() ) 656 if ( !tempS.isEmpty() )
657 addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); 657 addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS );
658 tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); 658 tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer());
659 if ( !tempS.isEmpty() ) 659 if ( !tempS.isEmpty() )
660 addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); 660 addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS );
661 tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); 661 tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer());
662 if ( !tempS.isEmpty() ) 662 if ( !tempS.isEmpty() )
663 addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); 663 addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS );
664 tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); 664 tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer());
665 if ( !tempS.isEmpty() ) 665 if ( !tempS.isEmpty() )
666 addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); 666 addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS );
667 tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), ""); 667 tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), "");
668 if ( !tempS.isEmpty() ) 668 if ( !tempS.isEmpty() )
669 addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); 669 addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS );
670 tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); 670 tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer());
671 if ( !tempS.isEmpty() ) 671 if ( !tempS.isEmpty() )
672 addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); 672 addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS );
673 dtb = mDdate2Qdtr(aItem->GetAnniversary()); 673 dtb = mDdate2Qdtr(aItem->GetAnniversary());
674 if (dtb.isValid() ) { 674 if (dtb.isValid() ) {
675 QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); 675 QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate);
676 addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 676 addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
677 } 677 }
678 int sec = aItem->GetSensitivity() ; 678 int sec = aItem->GetSensitivity() ;
679 if ( sec > 1 )// mapping pers -> private 679 if ( sec > 1 )// mapping pers -> private
680 --sec; 680 --sec;
681 addressee.setSecrecy( sec ); 681 addressee.setSecrecy( sec );
682 //addressee.setLogo( const Picture &logo ); 682 //addressee.setLogo( const Picture &logo );
683 //addressee.setPhoto( const Picture &photo ); 683 //addressee.setPhoto( const Picture &photo );
684 //addressee.setSound( const Sound &sound ); 684 //addressee.setSound( const Sound &sound );
685 //addressee.setAgent( const Agent &agent ); 685 //addressee.setAgent( const Agent &agent );
686 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), ""); 686 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), "");
687 cat = cat.replace( QRegExp("; "), ";"); 687 cat = cat.replace( QRegExp("; "), ";");
688 addressee.setCategories( QStringList::split( ";", cat )); 688 addressee.setCategories( QStringList::split( ";", cat ));
689 689
690 QString phoneS; 690 QString phoneS;
691 691
692 phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer()); 692 phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer());
693 if ( ! phoneS.isEmpty()) 693 if ( ! phoneS.isEmpty())
694 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 694 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
695 KABC::PhoneNumber::Work + 695 KABC::PhoneNumber::Work +
696 KABC::PhoneNumber::Voice + 696 KABC::PhoneNumber::Voice +
697 KABC::PhoneNumber::Msg ) ); 697 KABC::PhoneNumber::Msg ) );
698 phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer()); 698 phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer());
699 if ( ! phoneS.isEmpty()) 699 if ( ! phoneS.isEmpty())
700 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 700 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
701 KABC::PhoneNumber::Work + 701 KABC::PhoneNumber::Work +
702 KABC::PhoneNumber::Pref) ); 702 KABC::PhoneNumber::Pref) );
703 phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer()); 703 phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer());
704 if ( ! phoneS.isEmpty()) 704 if ( ! phoneS.isEmpty())
705 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 705 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
706 KABC::PhoneNumber::Work ) ); 706 KABC::PhoneNumber::Work ) );
707 phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer()); 707 phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer());
708 if ( ! phoneS.isEmpty()) 708 if ( ! phoneS.isEmpty())
709 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 709 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
710 KABC::PhoneNumber::Work + 710 KABC::PhoneNumber::Work +
711 KABC::PhoneNumber::Fax ) ); 711 KABC::PhoneNumber::Fax ) );
712 phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer()); 712 phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer());
713 if ( ! phoneS.isEmpty()) 713 if ( ! phoneS.isEmpty())
714 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 714 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
715 KABC::PhoneNumber::Car ) ); 715 KABC::PhoneNumber::Car ) );
716 phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer()); 716 phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer());
717 if ( ! phoneS.isEmpty()) 717 if ( ! phoneS.isEmpty())
718 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 718 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
719 KABC::PhoneNumber::Home + 719 KABC::PhoneNumber::Home +
720 KABC::PhoneNumber::Pref ) ); 720 KABC::PhoneNumber::Pref ) );
721 phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer()); 721 phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer());
722 if ( ! phoneS.isEmpty()) 722 if ( ! phoneS.isEmpty())
723 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 723 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
724 KABC::PhoneNumber::Home ) ); 724 KABC::PhoneNumber::Home ) );
725 phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer()); 725 phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer());
726 if ( ! phoneS.isEmpty()) 726 if ( ! phoneS.isEmpty())
727 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 727 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
728 KABC::PhoneNumber::Home + 728 KABC::PhoneNumber::Home +
729 KABC::PhoneNumber::Fax ) ); 729 KABC::PhoneNumber::Fax ) );
730 phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer()); 730 phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer());
731 if ( ! phoneS.isEmpty()) 731 if ( ! phoneS.isEmpty())
732 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 732 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
733 KABC::PhoneNumber::Isdn ) ); 733 KABC::PhoneNumber::Isdn ) );
734 phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer()); 734 phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer());
735 if ( ! phoneS.isEmpty()) 735 if ( ! phoneS.isEmpty())
736 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 736 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
737 KABC::PhoneNumber::Cell ) ); 737 KABC::PhoneNumber::Cell ) );
738 phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer()); 738 phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer());
739 if ( ! phoneS.isEmpty()) 739 if ( ! phoneS.isEmpty())
740 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 740 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
741 KABC::PhoneNumber::Fax ) ); 741 KABC::PhoneNumber::Fax ) );
742 phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer()); 742 phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer());
743 if ( ! phoneS.isEmpty()) 743 if ( ! phoneS.isEmpty())
744 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 744 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
745 KABC::PhoneNumber::Voice ) ); 745 KABC::PhoneNumber::Voice ) );
746 phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer()); 746 phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer());
747 if ( ! phoneS.isEmpty()) 747 if ( ! phoneS.isEmpty())
748 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 748 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
749 KABC::PhoneNumber::Pager ) ); 749 KABC::PhoneNumber::Pager ) );
750 phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer()); 750 phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer());
751 if ( ! phoneS.isEmpty()) 751 if ( ! phoneS.isEmpty())
752 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 752 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
753 KABC::PhoneNumber::Pref ) ); 753 KABC::PhoneNumber::Pref ) );
754 phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer()); 754 phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer());
755 if ( ! phoneS.isEmpty()) 755 if ( ! phoneS.isEmpty())
756 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 756 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
757 KABC::PhoneNumber::Pcs + 757 KABC::PhoneNumber::Pcs +
758 KABC::PhoneNumber::Voice) ); 758 KABC::PhoneNumber::Voice) );
759 phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer()); 759 phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer());
760 if ( ! phoneS.isEmpty()) 760 if ( ! phoneS.isEmpty())
761 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 761 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
762 KABC::PhoneNumber::Pcs ) ); 762 KABC::PhoneNumber::Pcs ) );
763 phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer()); 763 phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer());
764 if ( ! phoneS.isEmpty()) 764 if ( ! phoneS.isEmpty())
765 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 765 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
766 KABC::PhoneNumber::Work + 766 KABC::PhoneNumber::Work +
767 KABC::PhoneNumber::Msg ) ); 767 KABC::PhoneNumber::Msg ) );
768 phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer()); 768 phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer());
769 if ( ! phoneS.isEmpty()) 769 if ( ! phoneS.isEmpty())
770 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 770 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
771 KABC::PhoneNumber::Pcs + 771 KABC::PhoneNumber::Pcs +
772 KABC::PhoneNumber::Pref ) ); 772 KABC::PhoneNumber::Pref ) );
773 phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer()); 773 phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer());
774 if ( ! phoneS.isEmpty()) 774 if ( ! phoneS.isEmpty())
775 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 775 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
776 KABC::PhoneNumber::Msg ) ); 776 KABC::PhoneNumber::Msg ) );
777 777
778 bool preferred = true; 778 bool preferred = true;
779 phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer()); 779 phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer());
780 if ( ! phoneS.isEmpty()) { 780 if ( ! phoneS.isEmpty()) {
781 addressee.insertEmail(phoneS , preferred ); 781 addressee.insertEmail(phoneS , preferred );
782 preferred = false; 782 preferred = false;
783 } 783 }
784 phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer()); 784 phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer());
785 if ( ! phoneS.isEmpty()) { 785 if ( ! phoneS.isEmpty()) {
786 addressee.insertEmail(phoneS , preferred ); 786 addressee.insertEmail(phoneS , preferred );
787 preferred = false; 787 preferred = false;
788 } 788 }
789 phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer()); 789 phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer());
790 if ( ! phoneS.isEmpty()) { 790 if ( ! phoneS.isEmpty()) {
791 addressee.insertEmail(phoneS , preferred ); 791 addressee.insertEmail(phoneS , preferred );
792 preferred = false; 792 preferred = false;
793 } 793 }
794 // is this the number of the preferred email? 794 // is this the number of the preferred email?
795 //long GetSelectedMailingAddress();??? 795 //long GetSelectedMailingAddress();???
796 796
797 KABC::Address addressHome; 797 KABC::Address addressHome;
798 KABC::Address* addressAdd = &addressHome; 798 KABC::Address* addressAdd = &addressHome;
799 bool insert = false; 799 bool insert = false;
800 phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer()); 800 phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer());
801 phoneS.replace( QRegExp("\\r"), ""); 801 phoneS.replace( QRegExp("\\r"), "");
802 if ( ! phoneS.isEmpty()) { 802 if ( ! phoneS.isEmpty()) {
803 addressAdd->setCountry(phoneS ); 803 addressAdd->setCountry(phoneS );
804 insert = true; 804 insert = true;
805 } 805 }
806 phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer()); 806 phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer());
807 phoneS.replace( QRegExp("\\r"), ""); 807 phoneS.replace( QRegExp("\\r"), "");
808 if ( ! phoneS.isEmpty()) { 808 if ( ! phoneS.isEmpty()) {
809 addressAdd->setRegion(phoneS ); 809 addressAdd->setRegion(phoneS );
810 insert = true; 810 insert = true;
811 } 811 }
812 phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer()); 812 phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer());
813 phoneS.replace( QRegExp("\\r"), ""); 813 phoneS.replace( QRegExp("\\r"), "");
814 if ( ! phoneS.isEmpty()) { 814 if ( ! phoneS.isEmpty()) {
815 addressAdd->setLocality(phoneS ); 815 addressAdd->setLocality(phoneS );
816 insert = true; 816 insert = true;
817 } 817 }
818 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer()); 818 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer());
819 phoneS.replace( QRegExp("\\r"), ""); 819 phoneS.replace( QRegExp("\\r"), "");
820 if ( ! phoneS.isEmpty()) { 820 if ( ! phoneS.isEmpty()) {
821 addressAdd->setPostalCode(phoneS ); 821 addressAdd->setPostalCode(phoneS );
822 insert = true; 822 insert = true;
823 } 823 }
824 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer()); 824 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer());
825 phoneS.replace( QRegExp("\\r"), ""); 825 phoneS.replace( QRegExp("\\r"), "");
826 if ( ! phoneS.isEmpty()) { 826 if ( ! phoneS.isEmpty()) {
827 addressAdd->setPostOfficeBox(phoneS ); 827 addressAdd->setPostOfficeBox(phoneS );
828 insert = true; 828 insert = true;
829 } 829 }
830 phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer()); 830 phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer());
831 phoneS.replace( QRegExp("\\r"), ""); 831 phoneS.replace( QRegExp("\\r"), "");
832 if ( ! phoneS.isEmpty()) { 832 if ( ! phoneS.isEmpty()) {
833 addressAdd->setStreet(phoneS ); 833 addressAdd->setStreet(phoneS );
834 insert = true; 834 insert = true;
835 } 835 }
836 phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer()); 836 phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer());
837 phoneS.replace( QRegExp("\\r"), ""); 837 phoneS.replace( QRegExp("\\r"), "");
838 if ( ! phoneS.isEmpty()) { 838 if ( ! phoneS.isEmpty()) {
839 // redundant !addressAdd->setExtended(phoneS ); 839 // redundant !addressAdd->setExtended(phoneS );
840 // insert = true; 840 // insert = true;
841 } 841 }
842 addressAdd->setType( KABC::Address::Home ); 842 addressAdd->setType( KABC::Address::Home );
843 if ( insert ) 843 if ( insert )
844 addressee.insertAddress( *addressAdd ); 844 addressee.insertAddress( *addressAdd );
845 // ++++++++++++++++++++++ end of address 845 // ++++++++++++++++++++++ end of address
846 846
847 KABC::Address addressWork; 847 KABC::Address addressWork;
848 addressAdd = &addressWork; 848 addressAdd = &addressWork;
849 insert = false; 849 insert = false;
850 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer()); 850 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer());
851 phoneS.replace( QRegExp("\\r"), ""); 851 phoneS.replace( QRegExp("\\r"), "");
852 if ( ! phoneS.isEmpty()) { 852 if ( ! phoneS.isEmpty()) {
853 addressAdd->setCountry(phoneS ); 853 addressAdd->setCountry(phoneS );
854 insert = true; 854 insert = true;
855 } 855 }
856 phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer()); 856 phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer());
857 phoneS.replace( QRegExp("\\r"), ""); 857 phoneS.replace( QRegExp("\\r"), "");
858 if ( ! phoneS.isEmpty()) { 858 if ( ! phoneS.isEmpty()) {
859 addressAdd->setRegion(phoneS ); 859 addressAdd->setRegion(phoneS );
860 insert = true; 860 insert = true;
861 } 861 }
862 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer()); 862 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer());
863 phoneS.replace( QRegExp("\\r"), ""); 863 phoneS.replace( QRegExp("\\r"), "");
864 if ( ! phoneS.isEmpty()) { 864 if ( ! phoneS.isEmpty()) {
865 addressAdd->setLocality(phoneS ); 865 addressAdd->setLocality(phoneS );
866 insert = true; 866 insert = true;
867 } 867 }
868 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer()); 868 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer());
869 phoneS.replace( QRegExp("\\r"), ""); 869 phoneS.replace( QRegExp("\\r"), "");
870 if ( ! phoneS.isEmpty()) { 870 if ( ! phoneS.isEmpty()) {
871 addressAdd->setPostalCode(phoneS ); 871 addressAdd->setPostalCode(phoneS );
872 insert = true; 872 insert = true;
873 } 873 }
874 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer()); 874 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer());
875 phoneS.replace( QRegExp("\\r"), ""); 875 phoneS.replace( QRegExp("\\r"), "");
876 if ( ! phoneS.isEmpty()) { 876 if ( ! phoneS.isEmpty()) {
877 addressAdd->setPostOfficeBox(phoneS ); 877 addressAdd->setPostOfficeBox(phoneS );
878 insert = true; 878 insert = true;
879 } 879 }
880 phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer()); 880 phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer());
881 phoneS.replace( QRegExp("\\r"), ""); 881 phoneS.replace( QRegExp("\\r"), "");
882 if ( ! phoneS.isEmpty()) { 882 if ( ! phoneS.isEmpty()) {
883 addressAdd->setStreet(phoneS ); 883 addressAdd->setStreet(phoneS );
884 insert = true; 884 insert = true;
885 } 885 }
886 phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer()); 886 phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer());
887 phoneS.replace( QRegExp("\\r"), ""); 887 phoneS.replace( QRegExp("\\r"), "");
888 if ( ! phoneS.isEmpty()) { 888 if ( ! phoneS.isEmpty()) {
889 // redundant !addressAdd->setExtended(phoneS ); 889 // redundant !addressAdd->setExtended(phoneS );
890 // insert = true; 890 // insert = true;
891 } 891 }
892 addressAdd->setType( KABC::Address::Work ); 892 addressAdd->setType( KABC::Address::Work );
893 if ( insert ) 893 if ( insert )
894 addressee.insertAddress( *addressAdd ); 894 addressee.insertAddress( *addressAdd );
895 // ++++++++++++++++++++++ end of address 895 // ++++++++++++++++++++++ end of address
896 896
897 KABC::Address addressOther; 897 KABC::Address addressOther;
898 addressAdd = &addressOther; 898 addressAdd = &addressOther;
899 insert = false; 899 insert = false;
900 phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer()); 900 phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer());
901 phoneS.replace( QRegExp("\\r"), ""); 901 phoneS.replace( QRegExp("\\r"), "");
902 if ( ! phoneS.isEmpty()) { 902 if ( ! phoneS.isEmpty()) {
903 addressAdd->setCountry(phoneS ); 903 addressAdd->setCountry(phoneS );
904 insert = true; 904 insert = true;
905 } 905 }
906 phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer()); 906 phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer());
907 phoneS.replace( QRegExp("\\r"), ""); 907 phoneS.replace( QRegExp("\\r"), "");
908 if ( ! phoneS.isEmpty()) { 908 if ( ! phoneS.isEmpty()) {
909 addressAdd->setRegion(phoneS ); 909 addressAdd->setRegion(phoneS );
910 insert = true; 910 insert = true;
911 } 911 }
912 phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer()); 912 phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer());
913 phoneS.replace( QRegExp("\\r"), ""); 913 phoneS.replace( QRegExp("\\r"), "");
914 if ( ! phoneS.isEmpty()) { 914 if ( ! phoneS.isEmpty()) {
915 addressAdd->setLocality(phoneS ); 915 addressAdd->setLocality(phoneS );
916 insert = true; 916 insert = true;
917 } 917 }
918 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer()); 918 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer());
919 phoneS.replace( QRegExp("\\r"), ""); 919 phoneS.replace( QRegExp("\\r"), "");
920 if ( ! phoneS.isEmpty()) { 920 if ( ! phoneS.isEmpty()) {
921 addressAdd->setPostalCode(phoneS ); 921 addressAdd->setPostalCode(phoneS );
922 insert = true; 922 insert = true;
923 } 923 }
924 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer()); 924 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer());
925 phoneS.replace( QRegExp("\\r"), ""); 925 phoneS.replace( QRegExp("\\r"), "");
926 if ( ! phoneS.isEmpty()) { 926 if ( ! phoneS.isEmpty()) {
927 addressAdd->setPostOfficeBox(phoneS ); 927 addressAdd->setPostOfficeBox(phoneS );
928 insert = true; 928 insert = true;
929 } 929 }
930 phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer()); 930 phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer());
931 phoneS.replace( QRegExp("\\r"), ""); 931 phoneS.replace( QRegExp("\\r"), "");
932 if ( ! phoneS.isEmpty()) { 932 if ( ! phoneS.isEmpty()) {
933 addressAdd->setStreet(phoneS ); 933 addressAdd->setStreet(phoneS );
934 insert = true; 934 insert = true;
935 } 935 }
936 phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer()); 936 phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer());
937 if ( ! phoneS.isEmpty()) { 937 if ( ! phoneS.isEmpty()) {
938 // redundant !addressAdd->setExtended(phoneS ); 938 // redundant !addressAdd->setExtended(phoneS );
939 //insert = true; 939 //insert = true;
940 } 940 }
941 //addressAdd->setId( ); 941 //addressAdd->setId( );
942 if ( insert ) 942 if ( insert )
943 addressee.insertAddress( *addressAdd ); 943 addressee.insertAddress( *addressAdd );
944 // ++++++++++++++++++++++ end of address 944 // ++++++++++++++++++++++ end of address
945#if 0 945#if 0
946 KABC::Address addressMail; 946 KABC::Address addressMail;
947 addressAdd = &addressMail; 947 addressAdd = &addressMail;
948 insert = false; 948 insert = false;
949 phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer()); 949 phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer());
950 phoneS.replace( QRegExp("\\r"), ""); 950 phoneS.replace( QRegExp("\\r"), "");
951 if ( ! phoneS.isEmpty()) { 951 if ( ! phoneS.isEmpty()) {
952 addressAdd->setCountry(phoneS ); 952 addressAdd->setCountry(phoneS );
953 insert = true; 953 insert = true;
954 } 954 }
955 phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer()); 955 phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer());
956 phoneS.replace( QRegExp("\\r"), ""); 956 phoneS.replace( QRegExp("\\r"), "");
957 if ( ! phoneS.isEmpty()) { 957 if ( ! phoneS.isEmpty()) {
958 addressAdd->setRegion(phoneS ); 958 addressAdd->setRegion(phoneS );
959 insert = true; 959 insert = true;
960 } 960 }
961 phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer()); 961 phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer());
962 phoneS.replace( QRegExp("\\r"), ""); 962 phoneS.replace( QRegExp("\\r"), "");
963 if ( ! phoneS.isEmpty()) { 963 if ( ! phoneS.isEmpty()) {
964 addressAdd->setLocality(phoneS ); 964 addressAdd->setLocality(phoneS );
965 insert = true; 965 insert = true;
966 } 966 }
967 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer()); 967 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer());
968 phoneS.replace( QRegExp("\\r"), ""); 968 phoneS.replace( QRegExp("\\r"), "");
969 if ( ! phoneS.isEmpty()) { 969 if ( ! phoneS.isEmpty()) {
970 addressAdd->setPostalCode(phoneS ); 970 addressAdd->setPostalCode(phoneS );
971 insert = true; 971 insert = true;
972 } 972 }
973 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer()); 973 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer());
974 phoneS.replace( QRegExp("\\r"), ""); 974 phoneS.replace( QRegExp("\\r"), "");
975 if ( ! phoneS.isEmpty()) { 975 if ( ! phoneS.isEmpty()) {
976 addressAdd->setPostOfficeBox(phoneS ); 976 addressAdd->setPostOfficeBox(phoneS );
977 insert = true; 977 insert = true;
978 } 978 }
979 phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer()); 979 phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer());
980 phoneS.replace( QRegExp("\\r"), ""); 980 phoneS.replace( QRegExp("\\r"), "");
981 if ( ! phoneS.isEmpty()) { 981 if ( ! phoneS.isEmpty()) {
982 addressAdd->setStreet(phoneS ); 982 addressAdd->setStreet(phoneS );
983 insert = true; 983 insert = true;
984 } 984 }
985 phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer()); 985 phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer());
986 phoneS.replace( QRegExp("\\r"), ""); 986 phoneS.replace( QRegExp("\\r"), "");
987 if ( ! phoneS.isEmpty()) { 987 if ( ! phoneS.isEmpty()) {
988 // redundant ! addressAdd->setExtended(phoneS ); 988 // redundant ! addressAdd->setExtended(phoneS );
989 // insert = true; 989 // insert = true;
990 } 990 }
991 addressAdd->setType( KABC::Address::Postal ); 991 addressAdd->setType( KABC::Address::Postal );
992 if ( insert ) { 992 if ( insert ) {
993 addressee.insertAddress( *addressAdd ); 993 addressee.insertAddress( *addressAdd );
994 } 994 }
995#endif 995#endif
996 // the following code is disabled 996 // the following code is disabled
997 // it does not seem to be useful 997 // it does not seem to be useful
998#if 0 998#if 0
999 if ( insert ) { 999 if ( insert ) {
1000 addressAdd->setType( KABC::Address::Home ); 1000 addressAdd->setType( KABC::Address::Home );
1001 if ( addressMail == addressHome ) { 1001 if ( addressMail == addressHome ) {
1002 addressHome.setType( KABC::Address::Postal+ KABC::Address::Home ); 1002 addressHome.setType( KABC::Address::Postal+ KABC::Address::Home );
1003 addressee.insertAddress( addressHome ); 1003 addressee.insertAddress( addressHome );
1004 } else { 1004 } else {
1005 addressAdd->setType( KABC::Address::Work ); 1005 addressAdd->setType( KABC::Address::Work );
1006 if ( addressMail == addressWork ){ 1006 if ( addressMail == addressWork ){
1007 addressWork.setType( KABC::Address::Postal+ KABC::Address::Work ); 1007 addressWork.setType( KABC::Address::Postal+ KABC::Address::Work );
1008 addressee.insertAddress( addressWork ); 1008 addressee.insertAddress( addressWork );
1009 1009
1010 } else { 1010 } else {
1011 addressAdd->setType( 0 ); 1011 addressAdd->setType( 0 );
1012 if ( addressOther == addressMail ){ 1012 if ( addressOther == addressMail ){
1013 addressOther.setType( KABC::Address::Postal ); 1013 addressOther.setType( KABC::Address::Postal );
1014 addressee.insertAddress( addressOther ); 1014 addressee.insertAddress( addressOther );
1015 } else { 1015 } else {
1016 addressee.insertAddress( *addressAdd ); 1016 addressee.insertAddress( *addressAdd );
1017 } 1017 }
1018 } 1018 }
1019 } 1019 }
1020 } 1020 }
1021#endif 1021#endif
1022 // ++++++++++++++++++++++ end of ALL addresses 1022 // ++++++++++++++++++++++ end of ALL addresses
1023 //GetUserProperties(); 1023 //GetUserProperties();
1024 tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer()); 1024 tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer());
1025 phoneS.replace( QRegExp("\\r"), ""); 1025 phoneS.replace( QRegExp("\\r"), "");
1026 if ( !tempS.isEmpty() ) 1026 if ( !tempS.isEmpty() )
1027 addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS ); 1027 addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS );
1028 tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer()); 1028 tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer());
1029 if ( !tempS.isEmpty() ) 1029 if ( !tempS.isEmpty() )
1030 addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS ); 1030 addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS );
1031 int gen = aItem->GetGender(); 1031 int gen = aItem->GetGender();
1032 if ( gen != 0 ) { // 0 undef - 1 female - 2 male 1032 if ( gen != 0 ) { // 0 undef - 1 female - 2 male
1033 if ( gen == 1 ) 1033 if ( gen == 1 )
1034 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); 1034 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
1035 else 1035 else
1036 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); 1036 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
1037 } 1037 }
1038 QString additionalInfo; 1038 QString additionalInfo;
1039 QString tempAdd; 1039 QString tempAdd;
1040 tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer()); 1040 tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer());
1041 if ( ! tempAdd.isEmpty() ) { 1041 if ( ! tempAdd.isEmpty() ) {
1042 additionalInfo += i18n("\nLanguage: "); 1042 additionalInfo += i18n("\nLanguage: ");
1043 additionalInfo += tempAdd; 1043 additionalInfo += tempAdd;
1044 } 1044 }
1045 tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer()); 1045 tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer());
1046 phoneS.replace( QRegExp("\\r"), ""); 1046 phoneS.replace( QRegExp("\\r"), "");
1047 if ( ! tempAdd.isEmpty() ) { 1047 if ( ! tempAdd.isEmpty() ) {
1048 additionalInfo += i18n("\nHobby: "); 1048 additionalInfo += i18n("\nHobby: ");
1049 additionalInfo += tempAdd;; 1049 additionalInfo += tempAdd;;
1050 } 1050 }
1051 tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer()); 1051 tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer());
1052 phoneS.replace( QRegExp("\\r"), ""); 1052 phoneS.replace( QRegExp("\\r"), "");
1053 if ( ! tempAdd.isEmpty() ) { 1053 if ( ! tempAdd.isEmpty() ) {
1054 additionalInfo += i18n("\nHomepage: "); 1054 additionalInfo += i18n("\nHomepage: ");
1055 additionalInfo += tempAdd;; 1055 additionalInfo += tempAdd;;
1056 } 1056 }
1057 tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer()); 1057 tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer());
1058 phoneS.replace( QRegExp("\\r"), ""); 1058 phoneS.replace( QRegExp("\\r"), "");
1059 if ( ! tempAdd.isEmpty() ) { 1059 if ( ! tempAdd.isEmpty() ) {
1060 additionalInfo += i18n("\nBilling information: "); 1060 additionalInfo += i18n("\nBilling information: ");
1061 additionalInfo += tempAdd;; 1061 additionalInfo += tempAdd;;
1062 } 1062 }
1063 tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer()); 1063 tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer());
1064 phoneS.replace( QRegExp("\\r"), ""); 1064 phoneS.replace( QRegExp("\\r"), "");
1065 if ( ! tempAdd.isEmpty() ) { 1065 if ( ! tempAdd.isEmpty() ) {
1066 additionalInfo += i18n("\nCustomer ID: "); 1066 additionalInfo += i18n("\nCustomer ID: ");
1067 additionalInfo += tempAdd;; 1067 additionalInfo += tempAdd;;
1068 } 1068 }
1069 tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer()); 1069 tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer());
1070 phoneS.replace( QRegExp("\\r"), ""); 1070 phoneS.replace( QRegExp("\\r"), "");
1071 if ( ! tempAdd.isEmpty() ) { 1071 if ( ! tempAdd.isEmpty() ) {
1072 additionalInfo += i18n("\nUser1: "); 1072 additionalInfo += i18n("\nUser1: ");
1073 additionalInfo += tempAdd;; 1073 additionalInfo += tempAdd;;
1074 } 1074 }
1075 tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer()); 1075 tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer());
1076 phoneS.replace( QRegExp("\\r"), ""); 1076 phoneS.replace( QRegExp("\\r"), "");
1077 if ( ! tempAdd.isEmpty() ) { 1077 if ( ! tempAdd.isEmpty() ) {
1078 additionalInfo += i18n("\nUser2: "); 1078 additionalInfo += i18n("\nUser2: ");
1079 additionalInfo += tempAdd;; 1079 additionalInfo += tempAdd;;
1080 } 1080 }
1081 tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer()); 1081 tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer());
1082 phoneS.replace( QRegExp("\\r"), ""); 1082 phoneS.replace( QRegExp("\\r"), "");
1083 if ( ! tempAdd.isEmpty() ) { 1083 if ( ! tempAdd.isEmpty() ) {
1084 additionalInfo += i18n("\nUser3: "); 1084 additionalInfo += i18n("\nUser3: ");
1085 additionalInfo += tempAdd;; 1085 additionalInfo += tempAdd;;
1086 } 1086 }
1087 tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer()); 1087 tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer());
1088 phoneS.replace( QRegExp("\\r"), ""); 1088 phoneS.replace( QRegExp("\\r"), "");
1089 if ( ! tempAdd.isEmpty() ) { 1089 if ( ! tempAdd.isEmpty() ) {
1090 additionalInfo += i18n("\nUser4: "); 1090 additionalInfo += i18n("\nUser4: ");
1091 additionalInfo += tempAdd;; 1091 additionalInfo += tempAdd;;
1092 } 1092 }
1093 if (!additionalInfo.isEmpty() && ! syncMode ) { 1093 if (!additionalInfo.isEmpty() && ! syncMode ) {
1094 tempAdd = notesStr; 1094 tempAdd = notesStr;
1095 notesStr = "+++++++++++++++++++++++++++\n"; 1095 notesStr = "+++++++++++++++++++++++++++\n";
1096 notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:"); 1096 notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:");
1097 notesStr += additionalInfo; 1097 notesStr += additionalInfo;
1098 notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n"); 1098 notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n");
1099 notesStr += "+++++++++++++++++++++++++++\n"; 1099 notesStr += "+++++++++++++++++++++++++++\n";
1100 notesStr += tempAdd; 1100 notesStr += tempAdd;
1101 } 1101 }
1102 addressee.setNote( notesStr ); 1102 addressee.setNote( notesStr );
1103#if 0 1103#if 0
1104 // pending 1104 // pending
1105 - IM address: no clue where to get info about the helper ID 1105 - IM address: no clue where to get info about the helper ID
1106 -custom fields: difficult to implement - not implemented 1106 -custom fields: difficult to implement - not implemented
1107 -keys: makes no sense 1107 -keys: makes no sense
1108#endif 1108#endif
1109 return addressee; 1109 return addressee;
1110} 1110}
1111#if 0 1111#if 0
1112 1112
1113 1113
1114QDateTime mDdate2Qdtr( DATE dt) 1114QDateTime mDdate2Qdtr( DATE dt)
1115{ 1115{
1116 COleDateTime odt; 1116 COleDateTime odt;
1117 SYSTEMTIME st; 1117 SYSTEMTIME st;
1118 odt = dt; 1118 odt = dt;
1119 if ( odt.GetStatus() != 0 ) 1119 if ( odt.GetStatus() != 0 )
1120 return QDateTime(); 1120 return QDateTime();
1121 odt.GetAsSystemTime(st); 1121 odt.GetAsSystemTime(st);
1122 if ( st.wYear > 4000 ) // this program as a year 4000 bug! 1122 if ( st.wYear > 4000 ) // this program as a year 4000 bug!
1123 return QDateTime(); 1123 return QDateTime();
1124 // it seems so, that 1.1.4501 indicates: DATE invalid 1124 // it seems so, that 1.1.4501 indicates: DATE invalid
1125 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); 1125 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
1126 return qdt; 1126 return qdt;
1127} 1127}
1128DATE Qdt2date( QDateTime dt ) 1128DATE Qdt2date( QDateTime dt )
1129{ 1129{
1130 DATE ddd; 1130 DATE ddd;
1131 COleDateTime odt; 1131 COleDateTime odt;
1132 odt.SetDateTime(dt.date().year(), dt.date().month(),dt.date().day(), 1132 odt.SetDateTime(dt.date().year(), dt.date().month(),dt.date().day(),
1133 dt.time().hour(), dt.time().minute(), dt.time().second() ); 1133 dt.time().hour(), dt.time().minute(), dt.time().second() );
1134 ddd = odt; 1134 ddd = odt;
1135 return ddd; 1135 return ddd;
1136} 1136}
1137 1137
1138class OLEListViewItem : public QCheckListItem 1138class OLEListViewItem : public Q3CheckListItem
1139{ 1139{
1140 public: 1140 public:
1141 OLEListViewItem( QListView *parent, QString text ) : 1141 OLEListViewItem( Q3ListView *parent, QString text ) :
1142 QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; 1142 Q3CheckListItem( parent, text, Q3CheckListItem::CheckBox ) { ; };
1143 OLEListViewItem( QListViewItem *after, QString text ) : 1143 OLEListViewItem( Q3ListViewItem *after, QString text ) :
1144 QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; 1144 Q3CheckListItem( after, text, Q3CheckListItem::CheckBox ) { ; };
1145 ~OLEListViewItem() {}; 1145 ~OLEListViewItem() {};
1146 void setData( DWORD data ) {mData= data; }; 1146 void setData( DWORD data ) {mData= data; };
1147 void setDataID( QString data ){ mDataID = data ;} 1147 void setDataID( QString data ){ mDataID = data ;}
1148 QString dataID() { return mDataID;} 1148 QString dataID() { return mDataID;}
1149 DWORD data() { return mData ;}; 1149 DWORD data() { return mData ;};
1150 private: 1150 private:
1151 DWORD mData; 1151 DWORD mData;
1152 QString mDataID; 1152 QString mDataID;
1153}; 1153};
1154bool KAImportOLdialog::sOLDispatch = false; 1154bool KAImportOLdialog::sOLDispatch = false;
1155 1155
1156KAImportOLdialog::KAImportOLdialog( const QString &caption, 1156KAImportOLdialog::KAImportOLdialog( const QString &caption,
1157 KABC::AddressBook * aBook, QWidget *parent ) : 1157 KABC::AddressBook * aBook, QWidget *parent ) :
1158 KDialogBase( Plain, caption, User1 | Close, Ok, 1158 KDialogBase( Plain, caption, User1 | Close, Ok,
1159 parent, caption, true, false, i18n("Import!") ) 1159 parent, caption, true, false, i18n("Import!") )
1160{ 1160{
1161 mSyncMode = false; 1161 mSyncMode = false;
1162 QHBox * mw = new QHBox( this ); 1162 Q3HBox * mw = new Q3HBox( this );
1163 setMainWidget( mw ); 1163 setMainWidget( mw );
1164 mListView = new QListView( mw ); 1164 mListView = new Q3ListView( mw );
1165 mListView->addColumn(i18n("Select Folder")); 1165 mListView->addColumn(i18n("Select Folder"));
1166 mListView->addColumn(i18n("Content Type")); 1166 mListView->addColumn(i18n("Content Type"));
1167 mABook = aBook; 1167 mABook = aBook;
1168 connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); 1168 connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply()));
1169 setupFolderView(); 1169 setupFolderView();
1170 resize( sizeHint().width()+50, sizeHint().height()+50 ); 1170 resize( sizeHint().width()+50, sizeHint().height()+50 );
1171} 1171}
1172 1172
1173KAImportOLdialog::~KAImportOLdialog() 1173KAImportOLdialog::~KAImportOLdialog()
1174{ 1174{
1175 1175
1176} 1176}
1177 1177
1178void KAImportOLdialog::setSyncMode() 1178void KAImportOLdialog::setSyncMode()
1179{ 1179{
1180 mSyncMode = true; 1180 mSyncMode = true;
1181 findButton( User1 )->setText( i18n("Synchronize!") ); 1181 findButton( User1 )->setText( i18n("Synchronize!") );
1182} 1182}
1183KABC::Addressee::List KAImportOLdialog::getAddressList() 1183KABC::Addressee::List KAImportOLdialog::getAddressList()
1184{ 1184{
1185 return mAList; 1185 return mAList;
1186} 1186}
1187void KAImportOLdialog::setupFolderView() 1187void KAImportOLdialog::setupFolderView()
1188{ 1188{
1189 SCODE sc = ::OleInitialize(NULL); 1189 SCODE sc = ::OleInitialize(NULL);
1190 if ( FAILED ( sc ) ) { 1190 if ( FAILED ( sc ) ) {
1191 KMessageBox::information(this,"OLE initialisation failed"); 1191 KMessageBox::information(this,"OLE initialisation failed");
1192 return; 1192 return;
1193 } 1193 }
1194 if( ! KAImportOLdialog::sOLDispatch ) { 1194 if( ! KAImportOLdialog::sOLDispatch ) {
1195 if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ 1195 if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){
1196 KMessageBox::information(this,"Sorry, cannot access Outlook"); 1196 KMessageBox::information(this,"Sorry, cannot access Outlook");
1197 return ; 1197 return ;
1198 } 1198 }
1199 KAImportOLdialog::sOLDispatch = true; 1199 KAImportOLdialog::sOLDispatch = true;
1200 } 1200 }
1201 MAPIFolder mfInbox; 1201 MAPIFolder mfInbox;
1202 MAPIFolder mfRoot; 1202 MAPIFolder mfRoot;
1203 CString szName; 1203 CString szName;
1204 _NameSpace olNS; 1204 _NameSpace olNS;
1205 olNS = gOlAppAB.GetNamespace(_T("MAPI")); 1205 olNS = gOlAppAB.GetNamespace(_T("MAPI"));
1206 mfInbox = olNS.GetDefaultFolder(6); 1206 mfInbox = olNS.GetDefaultFolder(6);
1207 mfRoot = mfInbox.GetParent(); 1207 mfRoot = mfInbox.GetParent();
1208 szName = mfRoot.GetName(); 1208 szName = mfRoot.GetName();
1209 long iType = mfRoot.GetDefaultItemType(); 1209 long iType = mfRoot.GetDefaultItemType();
1210 QString mes; 1210 QString mes;
1211 mes = QString::fromUcs2( szName.GetBuffer() ); 1211 mes = QString::fromUcs2( szName.GetBuffer() );
1212 OLEListViewItem * root = new OLEListViewItem( mListView, mes ); 1212 OLEListViewItem * root = new OLEListViewItem( mListView, mes );
1213 mfRoot.m_lpDispatch->AddRef(); 1213 mfRoot.m_lpDispatch->AddRef();
1214 addFolder( root, mfRoot.m_lpDispatch ); 1214 addFolder( root, mfRoot.m_lpDispatch );
1215 root->setOpen( true ); 1215 root->setOpen( true );
1216 mListView->setSortColumn( 0 ); 1216 mListView->setSortColumn( 0 );
1217 mListView->sort( ); 1217 mListView->sort( );
1218} 1218}
1219 1219
1220 1220
1221void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) 1221void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent)
1222{ 1222{
1223 MAPIFolder mfParent(dispParent), mfChild; 1223 MAPIFolder mfParent(dispParent), mfChild;
1224 _Folders folders; 1224 _Folders folders;
1225 _variant_t fndx((long)0); 1225 _variant_t fndx((long)0);
1226 CString szName; 1226 CString szName;
1227 long iType; 1227 long iType;
1228 OLEListViewItem* hChild; 1228 OLEListViewItem* hChild;
1229 1229
1230 folders = mfParent.GetFolders(); 1230 folders = mfParent.GetFolders();
1231 for(int i=1; i <= folders.GetCount(); ++i) 1231 for(int i=1; i <= folders.GetCount(); ++i)
1232 { 1232 {
1233 fndx = (long)i; 1233 fndx = (long)i;
1234 mfChild = folders.Item(fndx.Detach()); 1234 mfChild = folders.Item(fndx.Detach());
1235 mfChild.m_lpDispatch->AddRef(); 1235 mfChild.m_lpDispatch->AddRef();
1236 szName = mfChild.GetName(); 1236 szName = mfChild.GetName();
1237 iType = mfChild.GetDefaultItemType(); 1237 iType = mfChild.GetDefaultItemType();
1238 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); 1238 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
1239 hChild->setDataID( QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) ); 1239 hChild->setDataID( QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) );
1240 if ( iType != 2) 1240 if ( iType != 2)
1241 hChild->setEnabled( false ); 1241 hChild->setEnabled( false );
1242 QString ts; 1242 QString ts;
1243 switch( iType ) { 1243 switch( iType ) {
1244 case 0: 1244 case 0:
1245 ts = i18n("Mail"); 1245 ts = i18n("Mail");
1246 break; 1246 break;
1247 case 1: 1247 case 1:
1248 ts = i18n("Calendar"); 1248 ts = i18n("Calendar");
1249 break; 1249 break;
1250 case 2: 1250 case 2:
1251 ts = i18n("Contacts"); 1251 ts = i18n("Contacts");
1252 break; 1252 break;
1253 case 3: 1253 case 3:
1254 ts = i18n("Todos"); 1254 ts = i18n("Todos");
1255 break; 1255 break;
1256 case 4: 1256 case 4:
1257 ts = i18n("Journals"); 1257 ts = i18n("Journals");
1258 break; 1258 break;
1259 case 5: 1259 case 5:
1260 ts = i18n("Notes"); 1260 ts = i18n("Notes");
1261 break; 1261 break;
1262 default: 1262 default:
1263 ts = i18n("Unknown"); 1263 ts = i18n("Unknown");
1264 } 1264 }
1265 hChild->setText( 1,ts); 1265 hChild->setText( 1,ts);
1266 hChild->setData( (DWORD) mfChild.m_lpDispatch ); 1266 hChild->setData( (DWORD) mfChild.m_lpDispatch );
1267 mfChild.m_lpDispatch->AddRef(); 1267 mfChild.m_lpDispatch->AddRef();
1268 addFolder(hChild, mfChild.m_lpDispatch); 1268 addFolder(hChild, mfChild.m_lpDispatch);
1269 } 1269 }
1270} 1270}
1271 1271
1272void KAImportOLdialog::slotApply() 1272void KAImportOLdialog::slotApply()
1273{ 1273{
1274 importedItems = 0; 1274 importedItems = 0;
1275 OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); 1275 OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild();
1276 while ( child ) { 1276 while ( child ) {
1277 if ( child->isOn() ) { 1277 if ( child->isOn() ) {
1278 readContactData( child->data() ); 1278 readContactData( child->data() );
1279 if ( mSyncMode ) { 1279 if ( mSyncMode ) {
1280 mSelectedFolderID = child->dataID(); 1280 mSelectedFolderID = child->dataID();
1281 accept(); 1281 accept();
1282 return; 1282 return;
1283 } 1283 }
1284 } 1284 }
1285 child = (OLEListViewItem*) child->itemBelow(); 1285 child = (OLEListViewItem*) child->itemBelow();
1286 } 1286 }
1287 QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); 1287 QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems);
1288 KMessageBox::information(this,mes); 1288 KMessageBox::information(this,mes);
1289} 1289}
1290void KAImportOLdialog::readContactData( DWORD folder ) 1290void KAImportOLdialog::readContactData( DWORD folder )
1291{ 1291{
1292 1292
1293 LPDISPATCH dispItem = (LPDISPATCH)folder; 1293 LPDISPATCH dispItem = (LPDISPATCH)folder;
1294 dispItem->AddRef(); 1294 dispItem->AddRef();
1295 MAPIFolder mf(dispItem); 1295 MAPIFolder mf(dispItem);
1296 mf.m_lpDispatch->AddRef(); 1296 mf.m_lpDispatch->AddRef();
1297 _Items folderItems; 1297 _Items folderItems;
1298 _variant_t indx((long)0); 1298 _variant_t indx((long)0);
1299 LPDISPATCH itm; 1299 LPDISPATCH itm;
1300 int i; 1300 int i;
1301 folderItems = mf.GetItems(); 1301 folderItems = mf.GetItems();
1302 QString cap = i18n("Importing contact data"); 1302 QString cap = i18n("Importing contact data");
1303 if ( mSyncMode ) { 1303 if ( mSyncMode ) {
1304 cap = i18n("Reading contact data..."); 1304 cap = i18n("Reading contact data...");
1305 } 1305 }
1306 QProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(),this); 1306 Q3ProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(),this);
1307 bar.setCaption (i18n("Accessing OL") ); 1307 bar.setCaption (i18n("Accessing OL") );
1308 int h = bar.sizeHint().height() ; 1308 int h = bar.sizeHint().height() ;
1309 int w = 300; 1309 int w = 300;
1310 int dw = QApplication::desktop()->width(); 1310 int dw = QApplication::desktop()->width();
1311 int dh = QApplication::desktop()->height(); 1311 int dh = QApplication::desktop()->height();
1312 //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1312 //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1313 bar.show(); 1313 bar.show();
1314 for(i=1; i <= folderItems.GetCount(); ++i) 1314 for(i=1; i <= folderItems.GetCount(); ++i)
1315 { 1315 {
1316 qApp->processEvents(); 1316 qApp->processEvents();
1317 if ( ! bar.isVisible() ) 1317 if ( ! bar.isVisible() )
1318 return ; 1318 return ;
1319 bar.setProgress( i ); 1319 bar.setProgress( i );
1320 indx = (long)i; 1320 indx = (long)i;
1321 itm = folderItems.Item(indx.Detach()); 1321 itm = folderItems.Item(indx.Detach());
1322 _ContactItem * pItem = (_ContactItem *)&itm; 1322 _ContactItem * pItem = (_ContactItem *)&itm;
1323 if ( addAddressee( ol2kapiContact( pItem, mSyncMode ) )) 1323 if ( addAddressee( ol2kapiContact( pItem, mSyncMode ) ))
1324 ++importedItems; 1324 ++importedItems;
1325 itm->Release(); 1325 itm->Release();
1326 } 1326 }
1327} 1327}
1328void KAImportOLdialog::slotOk() 1328void KAImportOLdialog::slotOk()
1329{ 1329{
1330 QDialog::accept(); 1330 QDialog::accept();
1331} 1331}
1332 1332
1333KABC::Addressee KAImportOLdialog::ol2kapiContact( _ContactItem * aItem , bool syncMode) 1333KABC::Addressee KAImportOLdialog::ol2kapiContact( _ContactItem * aItem , bool syncMode)
1334{ 1334{
1335 KABC::Addressee addressee; 1335 KABC::Addressee addressee;
1336 1336
1337 addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); 1337 addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer()));
1338 //GetLastModificationTime() 1338 //GetLastModificationTime()
1339 //addressee.setName( const QString &name ); 1339 //addressee.setName( const QString &name );
1340 addressee.setFormattedName( QString::fromUcs2(aItem->GetFileAs().GetBuffer()) ); 1340 addressee.setFormattedName( QString::fromUcs2(aItem->GetFileAs().GetBuffer()) );
1341 addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); 1341 addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) );
1342 addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); 1342 addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) );
1343 addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); 1343 addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) );
1344 addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); 1344 addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) );
1345 addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); 1345 addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) );
1346 addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); 1346 addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) );
1347 QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); 1347 QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday());
1348 if ( dtb.isValid() ) 1348 if ( dtb.isValid() )
1349 addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); 1349 addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday()));
1350 1350
1351 //QString::fromUcs2(aItem->.GetBuffer()) 1351 //QString::fromUcs2(aItem->.GetBuffer())
1352 //addressee.setMailer( const QString &mailer ); 1352 //addressee.setMailer( const QString &mailer );
1353 //addressee.setTimeZone( const TimeZone &timeZone ); 1353 //addressee.setTimeZone( const TimeZone &timeZone );
1354 //addressee.setGeo( const Geo &geo ); 1354 //addressee.setGeo( const Geo &geo );
1355 //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix 1355 //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix
1356 addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); 1356 addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );
1357 addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") ); 1357 addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") );
1358 QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer()); 1358 QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer());
1359 notesStr.replace( QRegExp("\\r"), ""); 1359 notesStr.replace( QRegExp("\\r"), "");
1360 1360
1361 addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); 1361 addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) );
1362 //addressee.setRevision( const QDateTime &revision ); 1362 //addressee.setRevision( const QDateTime &revision );
1363 // addressee.setSortString( const QString &sortString ); 1363 // addressee.setSortString( const QString &sortString );
1364 addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); 1364 addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) );
1365 1365
1366 QString tempS; 1366 QString tempS;
1367 tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer());//+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); 1367 tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer());//+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer());
1368 if ( tempS.length() > 12 ) 1368 if ( tempS.length() > 12 )
1369 addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); 1369 addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS );
1370 tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); 1370 tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer());
1371 if ( !tempS.isEmpty() ) 1371 if ( !tempS.isEmpty() )
1372 addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); 1372 addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS );
1373 tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); 1373 tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer());
1374 if ( !tempS.isEmpty() ) 1374 if ( !tempS.isEmpty() )
1375 addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); 1375 addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS );
1376 tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); 1376 tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer());
1377 if ( !tempS.isEmpty() ) 1377 if ( !tempS.isEmpty() )
1378 addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); 1378 addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS );
1379 tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); 1379 tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer());
1380 if ( !tempS.isEmpty() ) 1380 if ( !tempS.isEmpty() )
1381 addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); 1381 addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS );
1382 tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), ""); 1382 tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), "");
1383 if ( !tempS.isEmpty() ) 1383 if ( !tempS.isEmpty() )
1384 addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); 1384 addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS );
1385 tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); 1385 tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer());
1386 if ( !tempS.isEmpty() ) 1386 if ( !tempS.isEmpty() )
1387 addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); 1387 addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS );
1388 dtb = mDdate2Qdtr(aItem->GetAnniversary()); 1388 dtb = mDdate2Qdtr(aItem->GetAnniversary());
1389 if (dtb.isValid() ) { 1389 if (dtb.isValid() ) {
1390 QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); 1390 QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate);
1391 addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 1391 addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
1392 } 1392 }
1393 int sec = aItem->GetSensitivity() ; 1393 int sec = aItem->GetSensitivity() ;
1394 if ( sec > 1 )// mapping pers -> private 1394 if ( sec > 1 )// mapping pers -> private
1395 --sec; 1395 --sec;
1396 addressee.setSecrecy( sec ); 1396 addressee.setSecrecy( sec );
1397 //addressee.setLogo( const Picture &logo ); 1397 //addressee.setLogo( const Picture &logo );
1398 //addressee.setPhoto( const Picture &photo ); 1398 //addressee.setPhoto( const Picture &photo );
1399 //addressee.setSound( const Sound &sound ); 1399 //addressee.setSound( const Sound &sound );
1400 //addressee.setAgent( const Agent &agent ); 1400 //addressee.setAgent( const Agent &agent );
1401 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), ""); 1401 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), "");
1402 cat = cat.replace( QRegExp("; "), ";"); 1402 cat = cat.replace( QRegExp("; "), ";");
1403 addressee.setCategories( QStringList::split( ";", cat )); 1403 addressee.setCategories( QStringList::split( ";", cat ));
1404 1404
1405 QString phoneS; 1405 QString phoneS;
1406 1406
1407 phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer()); 1407 phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer());
1408 if ( ! phoneS.isEmpty()) 1408 if ( ! phoneS.isEmpty())
1409 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1409 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1410 KABC::PhoneNumber::Work + 1410 KABC::PhoneNumber::Work +
1411 KABC::PhoneNumber::Voice + 1411 KABC::PhoneNumber::Voice +
1412 KABC::PhoneNumber::Msg ) ); 1412 KABC::PhoneNumber::Msg ) );
1413 phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer()); 1413 phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer());
1414 if ( ! phoneS.isEmpty()) 1414 if ( ! phoneS.isEmpty())
1415 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1415 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1416 KABC::PhoneNumber::Work + 1416 KABC::PhoneNumber::Work +
1417 KABC::PhoneNumber::Pref) ); 1417 KABC::PhoneNumber::Pref) );
1418 phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer()); 1418 phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer());
1419 if ( ! phoneS.isEmpty()) 1419 if ( ! phoneS.isEmpty())
1420 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1420 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1421 KABC::PhoneNumber::Work ) ); 1421 KABC::PhoneNumber::Work ) );
1422 phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer()); 1422 phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer());
1423 if ( ! phoneS.isEmpty()) 1423 if ( ! phoneS.isEmpty())
1424 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1424 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1425 KABC::PhoneNumber::Work + 1425 KABC::PhoneNumber::Work +
1426 KABC::PhoneNumber::Fax ) ); 1426 KABC::PhoneNumber::Fax ) );
1427 phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer()); 1427 phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer());
1428 if ( ! phoneS.isEmpty()) 1428 if ( ! phoneS.isEmpty())
1429 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1429 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1430 KABC::PhoneNumber::Car ) ); 1430 KABC::PhoneNumber::Car ) );
1431 phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer()); 1431 phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer());
1432 if ( ! phoneS.isEmpty()) 1432 if ( ! phoneS.isEmpty())
1433 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1433 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1434 KABC::PhoneNumber::Home + 1434 KABC::PhoneNumber::Home +
1435 KABC::PhoneNumber::Pref ) ); 1435 KABC::PhoneNumber::Pref ) );
1436 phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer()); 1436 phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer());
1437 if ( ! phoneS.isEmpty()) 1437 if ( ! phoneS.isEmpty())
1438 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1438 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1439 KABC::PhoneNumber::Home ) ); 1439 KABC::PhoneNumber::Home ) );
1440 phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer()); 1440 phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer());
1441 if ( ! phoneS.isEmpty()) 1441 if ( ! phoneS.isEmpty())
1442 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1442 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1443 KABC::PhoneNumber::Home + 1443 KABC::PhoneNumber::Home +
1444 KABC::PhoneNumber::Fax ) ); 1444 KABC::PhoneNumber::Fax ) );
1445 phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer()); 1445 phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer());
1446 if ( ! phoneS.isEmpty()) 1446 if ( ! phoneS.isEmpty())
1447 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1447 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1448 KABC::PhoneNumber::Isdn ) ); 1448 KABC::PhoneNumber::Isdn ) );
1449 phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer()); 1449 phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer());
1450 if ( ! phoneS.isEmpty()) 1450 if ( ! phoneS.isEmpty())
1451 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1451 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1452 KABC::PhoneNumber::Cell ) ); 1452 KABC::PhoneNumber::Cell ) );
1453 phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer()); 1453 phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer());
1454 if ( ! phoneS.isEmpty()) 1454 if ( ! phoneS.isEmpty())
1455 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1455 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1456 KABC::PhoneNumber::Fax ) ); 1456 KABC::PhoneNumber::Fax ) );
1457 phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer()); 1457 phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer());
1458 if ( ! phoneS.isEmpty()) 1458 if ( ! phoneS.isEmpty())
1459 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1459 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1460 KABC::PhoneNumber::Voice ) ); 1460 KABC::PhoneNumber::Voice ) );
1461 phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer()); 1461 phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer());
1462 if ( ! phoneS.isEmpty()) 1462 if ( ! phoneS.isEmpty())
1463 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1463 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1464 KABC::PhoneNumber::Pager ) ); 1464 KABC::PhoneNumber::Pager ) );
1465 phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer()); 1465 phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer());
1466 if ( ! phoneS.isEmpty()) 1466 if ( ! phoneS.isEmpty())
1467 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1467 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1468 KABC::PhoneNumber::Pref ) ); 1468 KABC::PhoneNumber::Pref ) );
1469 phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer()); 1469 phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer());
1470 if ( ! phoneS.isEmpty()) 1470 if ( ! phoneS.isEmpty())
1471 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1471 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1472 KABC::PhoneNumber::Pcs + 1472 KABC::PhoneNumber::Pcs +
1473 KABC::PhoneNumber::Voice) ); 1473 KABC::PhoneNumber::Voice) );
1474 phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer()); 1474 phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer());
1475 if ( ! phoneS.isEmpty()) 1475 if ( ! phoneS.isEmpty())
1476 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1476 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1477 KABC::PhoneNumber::Pcs ) ); 1477 KABC::PhoneNumber::Pcs ) );
1478 phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer()); 1478 phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer());
1479 if ( ! phoneS.isEmpty()) 1479 if ( ! phoneS.isEmpty())
1480 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1480 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1481 KABC::PhoneNumber::Work + 1481 KABC::PhoneNumber::Work +
1482 KABC::PhoneNumber::Msg ) ); 1482 KABC::PhoneNumber::Msg ) );
1483 phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer()); 1483 phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer());
1484 if ( ! phoneS.isEmpty()) 1484 if ( ! phoneS.isEmpty())
1485 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1485 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1486 KABC::PhoneNumber::Pcs + 1486 KABC::PhoneNumber::Pcs +
1487 KABC::PhoneNumber::Pref ) ); 1487 KABC::PhoneNumber::Pref ) );
1488 phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer()); 1488 phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer());
1489 if ( ! phoneS.isEmpty()) 1489 if ( ! phoneS.isEmpty())
1490 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS , 1490 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,
1491 KABC::PhoneNumber::Msg ) ); 1491 KABC::PhoneNumber::Msg ) );
1492 1492
1493 bool preferred = true; 1493 bool preferred = true;
1494 phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer()); 1494 phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer());
1495 if ( ! phoneS.isEmpty()) { 1495 if ( ! phoneS.isEmpty()) {
1496 addressee.insertEmail(phoneS , preferred ); 1496 addressee.insertEmail(phoneS , preferred );
1497 preferred = false; 1497 preferred = false;
1498 } 1498 }
1499 phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer()); 1499 phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer());
1500 if ( ! phoneS.isEmpty()) { 1500 if ( ! phoneS.isEmpty()) {
1501 addressee.insertEmail(phoneS , preferred ); 1501 addressee.insertEmail(phoneS , preferred );
1502 preferred = false; 1502 preferred = false;
1503 } 1503 }
1504 phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer()); 1504 phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer());
1505 if ( ! phoneS.isEmpty()) { 1505 if ( ! phoneS.isEmpty()) {
1506 addressee.insertEmail(phoneS , preferred ); 1506 addressee.insertEmail(phoneS , preferred );
1507 preferred = false; 1507 preferred = false;
1508 } 1508 }
1509 // is this the number of the preferred email? 1509 // is this the number of the preferred email?
1510 //long GetSelectedMailingAddress();??? 1510 //long GetSelectedMailingAddress();???
1511 1511
1512 KABC::Address addressHome; 1512 KABC::Address addressHome;
1513 KABC::Address* addressAdd = &addressHome; 1513 KABC::Address* addressAdd = &addressHome;
1514 bool insert = false; 1514 bool insert = false;
1515 phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer()); 1515 phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer());
1516 phoneS.replace( QRegExp("\\r"), ""); 1516 phoneS.replace( QRegExp("\\r"), "");
1517 if ( ! phoneS.isEmpty()) { 1517 if ( ! phoneS.isEmpty()) {
1518 addressAdd->setCountry(phoneS ); 1518 addressAdd->setCountry(phoneS );
1519 insert = true; 1519 insert = true;
1520 } 1520 }
1521 phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer()); 1521 phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer());
1522 phoneS.replace( QRegExp("\\r"), ""); 1522 phoneS.replace( QRegExp("\\r"), "");
1523 if ( ! phoneS.isEmpty()) { 1523 if ( ! phoneS.isEmpty()) {
1524 addressAdd->setRegion(phoneS ); 1524 addressAdd->setRegion(phoneS );
1525 insert = true; 1525 insert = true;
1526 } 1526 }
1527 phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer()); 1527 phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer());
1528 phoneS.replace( QRegExp("\\r"), ""); 1528 phoneS.replace( QRegExp("\\r"), "");
1529 if ( ! phoneS.isEmpty()) { 1529 if ( ! phoneS.isEmpty()) {
1530 addressAdd->setLocality(phoneS ); 1530 addressAdd->setLocality(phoneS );
1531 insert = true; 1531 insert = true;
1532 } 1532 }
1533 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer()); 1533 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer());
1534 phoneS.replace( QRegExp("\\r"), ""); 1534 phoneS.replace( QRegExp("\\r"), "");
1535 if ( ! phoneS.isEmpty()) { 1535 if ( ! phoneS.isEmpty()) {
1536 addressAdd->setPostalCode(phoneS ); 1536 addressAdd->setPostalCode(phoneS );
1537 insert = true; 1537 insert = true;
1538 } 1538 }
1539 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer()); 1539 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer());
1540 phoneS.replace( QRegExp("\\r"), ""); 1540 phoneS.replace( QRegExp("\\r"), "");
1541 if ( ! phoneS.isEmpty()) { 1541 if ( ! phoneS.isEmpty()) {
1542 addressAdd->setPostOfficeBox(phoneS ); 1542 addressAdd->setPostOfficeBox(phoneS );
1543 insert = true; 1543 insert = true;
1544 } 1544 }
1545 phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer()); 1545 phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer());
1546 phoneS.replace( QRegExp("\\r"), ""); 1546 phoneS.replace( QRegExp("\\r"), "");
1547 if ( ! phoneS.isEmpty()) { 1547 if ( ! phoneS.isEmpty()) {
1548 addressAdd->setStreet(phoneS ); 1548 addressAdd->setStreet(phoneS );
1549 insert = true; 1549 insert = true;
1550 } 1550 }
1551 phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer()); 1551 phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer());
1552 phoneS.replace( QRegExp("\\r"), ""); 1552 phoneS.replace( QRegExp("\\r"), "");
1553 if ( ! phoneS.isEmpty()) { 1553 if ( ! phoneS.isEmpty()) {
1554 // redundant !addressAdd->setExtended(phoneS ); 1554 // redundant !addressAdd->setExtended(phoneS );
1555 // insert = true; 1555 // insert = true;
1556 } 1556 }
1557 addressAdd->setType( KABC::Address::Home ); 1557 addressAdd->setType( KABC::Address::Home );
1558 if ( insert ) 1558 if ( insert )
1559 addressee.insertAddress( *addressAdd ); 1559 addressee.insertAddress( *addressAdd );
1560 // ++++++++++++++++++++++ end of address 1560 // ++++++++++++++++++++++ end of address
1561 1561
1562 KABC::Address addressWork; 1562 KABC::Address addressWork;
1563 addressAdd = &addressWork; 1563 addressAdd = &addressWork;
1564 insert = false; 1564 insert = false;
1565 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer()); 1565 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer());
1566 phoneS.replace( QRegExp("\\r"), ""); 1566 phoneS.replace( QRegExp("\\r"), "");
1567 if ( ! phoneS.isEmpty()) { 1567 if ( ! phoneS.isEmpty()) {
1568 addressAdd->setCountry(phoneS ); 1568 addressAdd->setCountry(phoneS );
1569 insert = true; 1569 insert = true;
1570 } 1570 }
1571 phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer()); 1571 phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer());
1572 phoneS.replace( QRegExp("\\r"), ""); 1572 phoneS.replace( QRegExp("\\r"), "");
1573 if ( ! phoneS.isEmpty()) { 1573 if ( ! phoneS.isEmpty()) {
1574 addressAdd->setRegion(phoneS ); 1574 addressAdd->setRegion(phoneS );
1575 insert = true; 1575 insert = true;
1576 } 1576 }
1577 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer()); 1577 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer());
1578 phoneS.replace( QRegExp("\\r"), ""); 1578 phoneS.replace( QRegExp("\\r"), "");
1579 if ( ! phoneS.isEmpty()) { 1579 if ( ! phoneS.isEmpty()) {
1580 addressAdd->setLocality(phoneS ); 1580 addressAdd->setLocality(phoneS );
1581 insert = true; 1581 insert = true;
1582 } 1582 }
1583 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer()); 1583 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer());
1584 phoneS.replace( QRegExp("\\r"), ""); 1584 phoneS.replace( QRegExp("\\r"), "");
1585 if ( ! phoneS.isEmpty()) { 1585 if ( ! phoneS.isEmpty()) {
1586 addressAdd->setPostalCode(phoneS ); 1586 addressAdd->setPostalCode(phoneS );
1587 insert = true; 1587 insert = true;
1588 } 1588 }
1589 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer()); 1589 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer());
1590 phoneS.replace( QRegExp("\\r"), ""); 1590 phoneS.replace( QRegExp("\\r"), "");
1591 if ( ! phoneS.isEmpty()) { 1591 if ( ! phoneS.isEmpty()) {
1592 addressAdd->setPostOfficeBox(phoneS ); 1592 addressAdd->setPostOfficeBox(phoneS );
1593 insert = true; 1593 insert = true;
1594 } 1594 }
1595 phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer()); 1595 phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer());
1596 phoneS.replace( QRegExp("\\r"), ""); 1596 phoneS.replace( QRegExp("\\r"), "");
1597 if ( ! phoneS.isEmpty()) { 1597 if ( ! phoneS.isEmpty()) {
1598 addressAdd->setStreet(phoneS ); 1598 addressAdd->setStreet(phoneS );
1599 insert = true; 1599 insert = true;
1600 } 1600 }
1601 phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer()); 1601 phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer());
1602 phoneS.replace( QRegExp("\\r"), ""); 1602 phoneS.replace( QRegExp("\\r"), "");
1603 if ( ! phoneS.isEmpty()) { 1603 if ( ! phoneS.isEmpty()) {
1604 // redundant !addressAdd->setExtended(phoneS ); 1604 // redundant !addressAdd->setExtended(phoneS );
1605 // insert = true; 1605 // insert = true;
1606 } 1606 }
1607 addressAdd->setType( KABC::Address::Work ); 1607 addressAdd->setType( KABC::Address::Work );
1608 if ( insert ) 1608 if ( insert )
1609 addressee.insertAddress( *addressAdd ); 1609 addressee.insertAddress( *addressAdd );
1610 // ++++++++++++++++++++++ end of address 1610 // ++++++++++++++++++++++ end of address
1611 1611
1612 KABC::Address addressOther; 1612 KABC::Address addressOther;
1613 addressAdd = &addressOther; 1613 addressAdd = &addressOther;
1614 insert = false; 1614 insert = false;
1615 phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer()); 1615 phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer());
1616 phoneS.replace( QRegExp("\\r"), ""); 1616 phoneS.replace( QRegExp("\\r"), "");
1617 if ( ! phoneS.isEmpty()) { 1617 if ( ! phoneS.isEmpty()) {
1618 addressAdd->setCountry(phoneS ); 1618 addressAdd->setCountry(phoneS );
1619 insert = true; 1619 insert = true;
1620 } 1620 }
1621 phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer()); 1621 phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer());
1622 phoneS.replace( QRegExp("\\r"), ""); 1622 phoneS.replace( QRegExp("\\r"), "");
1623 if ( ! phoneS.isEmpty()) { 1623 if ( ! phoneS.isEmpty()) {
1624 addressAdd->setRegion(phoneS ); 1624 addressAdd->setRegion(phoneS );
1625 insert = true; 1625 insert = true;
1626 } 1626 }
1627 phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer()); 1627 phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer());
1628 phoneS.replace( QRegExp("\\r"), ""); 1628 phoneS.replace( QRegExp("\\r"), "");
1629 if ( ! phoneS.isEmpty()) { 1629 if ( ! phoneS.isEmpty()) {
1630 addressAdd->setLocality(phoneS ); 1630 addressAdd->setLocality(phoneS );
1631 insert = true; 1631 insert = true;
1632 } 1632 }
1633 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer()); 1633 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer());
1634 phoneS.replace( QRegExp("\\r"), ""); 1634 phoneS.replace( QRegExp("\\r"), "");
1635 if ( ! phoneS.isEmpty()) { 1635 if ( ! phoneS.isEmpty()) {
1636 addressAdd->setPostalCode(phoneS ); 1636 addressAdd->setPostalCode(phoneS );
1637 insert = true; 1637 insert = true;
1638 } 1638 }
1639 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer()); 1639 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer());
1640 phoneS.replace( QRegExp("\\r"), ""); 1640 phoneS.replace( QRegExp("\\r"), "");
1641 if ( ! phoneS.isEmpty()) { 1641 if ( ! phoneS.isEmpty()) {
1642 addressAdd->setPostOfficeBox(phoneS ); 1642 addressAdd->setPostOfficeBox(phoneS );
1643 insert = true; 1643 insert = true;
1644 } 1644 }
1645 phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer()); 1645 phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer());
1646 phoneS.replace( QRegExp("\\r"), ""); 1646 phoneS.replace( QRegExp("\\r"), "");
1647 if ( ! phoneS.isEmpty()) { 1647 if ( ! phoneS.isEmpty()) {
1648 addressAdd->setStreet(phoneS ); 1648 addressAdd->setStreet(phoneS );
1649 insert = true; 1649 insert = true;
1650 } 1650 }
1651 phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer()); 1651 phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer());
1652 if ( ! phoneS.isEmpty()) { 1652 if ( ! phoneS.isEmpty()) {
1653 // redundant !addressAdd->setExtended(phoneS ); 1653 // redundant !addressAdd->setExtended(phoneS );
1654 //insert = true; 1654 //insert = true;
1655 } 1655 }
1656 //addressAdd->setId( ); 1656 //addressAdd->setId( );
1657 if ( insert ) 1657 if ( insert )
1658 addressee.insertAddress( *addressAdd ); 1658 addressee.insertAddress( *addressAdd );
1659 // ++++++++++++++++++++++ end of address 1659 // ++++++++++++++++++++++ end of address
1660#if 0 1660#if 0
1661 KABC::Address addressMail; 1661 KABC::Address addressMail;
1662 addressAdd = &addressMail; 1662 addressAdd = &addressMail;
1663 insert = false; 1663 insert = false;
1664 phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer()); 1664 phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer());
1665 phoneS.replace( QRegExp("\\r"), ""); 1665 phoneS.replace( QRegExp("\\r"), "");
1666 if ( ! phoneS.isEmpty()) { 1666 if ( ! phoneS.isEmpty()) {
1667 addressAdd->setCountry(phoneS ); 1667 addressAdd->setCountry(phoneS );
1668 insert = true; 1668 insert = true;
1669 } 1669 }
1670 phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer()); 1670 phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer());
1671 phoneS.replace( QRegExp("\\r"), ""); 1671 phoneS.replace( QRegExp("\\r"), "");
1672 if ( ! phoneS.isEmpty()) { 1672 if ( ! phoneS.isEmpty()) {
1673 addressAdd->setRegion(phoneS ); 1673 addressAdd->setRegion(phoneS );
1674 insert = true; 1674 insert = true;
1675 } 1675 }
1676 phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer()); 1676 phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer());
1677 phoneS.replace( QRegExp("\\r"), ""); 1677 phoneS.replace( QRegExp("\\r"), "");
1678 if ( ! phoneS.isEmpty()) { 1678 if ( ! phoneS.isEmpty()) {
1679 addressAdd->setLocality(phoneS ); 1679 addressAdd->setLocality(phoneS );
1680 insert = true; 1680 insert = true;
1681 } 1681 }
1682 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer()); 1682 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer());
1683 phoneS.replace( QRegExp("\\r"), ""); 1683 phoneS.replace( QRegExp("\\r"), "");
1684 if ( ! phoneS.isEmpty()) { 1684 if ( ! phoneS.isEmpty()) {
1685 addressAdd->setPostalCode(phoneS ); 1685 addressAdd->setPostalCode(phoneS );
1686 insert = true; 1686 insert = true;
1687 } 1687 }
1688 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer()); 1688 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer());
1689 phoneS.replace( QRegExp("\\r"), ""); 1689 phoneS.replace( QRegExp("\\r"), "");
1690 if ( ! phoneS.isEmpty()) { 1690 if ( ! phoneS.isEmpty()) {
1691 addressAdd->setPostOfficeBox(phoneS ); 1691 addressAdd->setPostOfficeBox(phoneS );
1692 insert = true; 1692 insert = true;
1693 } 1693 }
1694 phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer()); 1694 phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer());
1695 phoneS.replace( QRegExp("\\r"), ""); 1695 phoneS.replace( QRegExp("\\r"), "");
1696 if ( ! phoneS.isEmpty()) { 1696 if ( ! phoneS.isEmpty()) {
1697 addressAdd->setStreet(phoneS ); 1697 addressAdd->setStreet(phoneS );
1698 insert = true; 1698 insert = true;
1699 } 1699 }
1700 phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer()); 1700 phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer());
1701 phoneS.replace( QRegExp("\\r"), ""); 1701 phoneS.replace( QRegExp("\\r"), "");
1702 if ( ! phoneS.isEmpty()) { 1702 if ( ! phoneS.isEmpty()) {
1703 // redundant ! addressAdd->setExtended(phoneS ); 1703 // redundant ! addressAdd->setExtended(phoneS );
1704 // insert = true; 1704 // insert = true;
1705 } 1705 }
1706 addressAdd->setType( KABC::Address::Postal ); 1706 addressAdd->setType( KABC::Address::Postal );
1707 if ( insert ) { 1707 if ( insert ) {
1708 addressee.insertAddress( *addressAdd ); 1708 addressee.insertAddress( *addressAdd );
1709 } 1709 }
1710#endif 1710#endif
1711 // the following code is disabled 1711 // the following code is disabled
1712 // it does not seem to be useful 1712 // it does not seem to be useful
1713#if 0 1713#if 0
1714 if ( insert ) { 1714 if ( insert ) {
1715 addressAdd->setType( KABC::Address::Home ); 1715 addressAdd->setType( KABC::Address::Home );
1716 if ( addressMail == addressHome ) { 1716 if ( addressMail == addressHome ) {
1717 addressHome.setType( KABC::Address::Postal+ KABC::Address::Home ); 1717 addressHome.setType( KABC::Address::Postal+ KABC::Address::Home );
1718 addressee.insertAddress( addressHome ); 1718 addressee.insertAddress( addressHome );
1719 } else { 1719 } else {
1720 addressAdd->setType( KABC::Address::Work ); 1720 addressAdd->setType( KABC::Address::Work );
1721 if ( addressMail == addressWork ){ 1721 if ( addressMail == addressWork ){
1722 addressWork.setType( KABC::Address::Postal+ KABC::Address::Work ); 1722 addressWork.setType( KABC::Address::Postal+ KABC::Address::Work );
1723 addressee.insertAddress( addressWork ); 1723 addressee.insertAddress( addressWork );
1724 1724
1725 } else { 1725 } else {
1726 addressAdd->setType( 0 ); 1726 addressAdd->setType( 0 );
1727 if ( addressOther == addressMail ){ 1727 if ( addressOther == addressMail ){
1728 addressOther.setType( KABC::Address::Postal ); 1728 addressOther.setType( KABC::Address::Postal );
1729 addressee.insertAddress( addressOther ); 1729 addressee.insertAddress( addressOther );
1730 } else { 1730 } else {
1731 addressee.insertAddress( *addressAdd ); 1731 addressee.insertAddress( *addressAdd );
1732 } 1732 }
1733 } 1733 }
1734 } 1734 }
1735 } 1735 }
1736#endif 1736#endif
1737 // ++++++++++++++++++++++ end of ALL addresses 1737 // ++++++++++++++++++++++ end of ALL addresses
1738 //GetUserProperties(); 1738 //GetUserProperties();
1739 tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer()); 1739 tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer());
1740 phoneS.replace( QRegExp("\\r"), ""); 1740 phoneS.replace( QRegExp("\\r"), "");
1741 if ( !tempS.isEmpty() ) 1741 if ( !tempS.isEmpty() )
1742 addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS ); 1742 addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS );
1743 tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer()); 1743 tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer());
1744 if ( !tempS.isEmpty() ) 1744 if ( !tempS.isEmpty() )
1745 addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS ); 1745 addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS );
1746 int gen = aItem->GetGender(); 1746 int gen = aItem->GetGender();
1747 if ( gen != 0 ) { // 0 undef - 1 female - 2 male 1747 if ( gen != 0 ) { // 0 undef - 1 female - 2 male
1748 if ( gen == 1 ) 1748 if ( gen == 1 )
1749 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); 1749 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
1750 else 1750 else
1751 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); 1751 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
1752 } 1752 }
1753 QString additionalInfo; 1753 QString additionalInfo;
1754 QString tempAdd; 1754 QString tempAdd;
1755 tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer()); 1755 tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer());
1756 if ( ! tempAdd.isEmpty() ) { 1756 if ( ! tempAdd.isEmpty() ) {
1757 additionalInfo += i18n("\nLanguage: "); 1757 additionalInfo += i18n("\nLanguage: ");
1758 additionalInfo += tempAdd; 1758 additionalInfo += tempAdd;
1759 } 1759 }
1760 tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer()); 1760 tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer());
1761 phoneS.replace( QRegExp("\\r"), ""); 1761 phoneS.replace( QRegExp("\\r"), "");
1762 if ( ! tempAdd.isEmpty() ) { 1762 if ( ! tempAdd.isEmpty() ) {
1763 additionalInfo += i18n("\nHobby: "); 1763 additionalInfo += i18n("\nHobby: ");
1764 additionalInfo += tempAdd;; 1764 additionalInfo += tempAdd;;
1765 } 1765 }
1766 tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer()); 1766 tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer());
1767 phoneS.replace( QRegExp("\\r"), ""); 1767 phoneS.replace( QRegExp("\\r"), "");
1768 if ( ! tempAdd.isEmpty() ) { 1768 if ( ! tempAdd.isEmpty() ) {
1769 additionalInfo += i18n("\nHomepage: "); 1769 additionalInfo += i18n("\nHomepage: ");
1770 additionalInfo += tempAdd;; 1770 additionalInfo += tempAdd;;
1771 } 1771 }
1772 tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer()); 1772 tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer());
1773 phoneS.replace( QRegExp("\\r"), ""); 1773 phoneS.replace( QRegExp("\\r"), "");
1774 if ( ! tempAdd.isEmpty() ) { 1774 if ( ! tempAdd.isEmpty() ) {
1775 additionalInfo += i18n("\nBilling information: "); 1775 additionalInfo += i18n("\nBilling information: ");
1776 additionalInfo += tempAdd;; 1776 additionalInfo += tempAdd;;
1777 } 1777 }
1778 tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer()); 1778 tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer());
1779 phoneS.replace( QRegExp("\\r"), ""); 1779 phoneS.replace( QRegExp("\\r"), "");
1780 if ( ! tempAdd.isEmpty() ) { 1780 if ( ! tempAdd.isEmpty() ) {
1781 additionalInfo += i18n("\nCustomer ID: "); 1781 additionalInfo += i18n("\nCustomer ID: ");
1782 additionalInfo += tempAdd;; 1782 additionalInfo += tempAdd;;
1783 } 1783 }
1784 tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer()); 1784 tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer());
1785 phoneS.replace( QRegExp("\\r"), ""); 1785 phoneS.replace( QRegExp("\\r"), "");
1786 if ( ! tempAdd.isEmpty() ) { 1786 if ( ! tempAdd.isEmpty() ) {
1787 additionalInfo += i18n("\nUser1: "); 1787 additionalInfo += i18n("\nUser1: ");
1788 additionalInfo += tempAdd;; 1788 additionalInfo += tempAdd;;
1789 } 1789 }
1790 tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer()); 1790 tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer());
1791 phoneS.replace( QRegExp("\\r"), ""); 1791 phoneS.replace( QRegExp("\\r"), "");
1792 if ( ! tempAdd.isEmpty() ) { 1792 if ( ! tempAdd.isEmpty() ) {
1793 additionalInfo += i18n("\nUser2: "); 1793 additionalInfo += i18n("\nUser2: ");
1794 additionalInfo += tempAdd;; 1794 additionalInfo += tempAdd;;
1795 } 1795 }
1796 tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer()); 1796 tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer());
1797 phoneS.replace( QRegExp("\\r"), ""); 1797 phoneS.replace( QRegExp("\\r"), "");
1798 if ( ! tempAdd.isEmpty() ) { 1798 if ( ! tempAdd.isEmpty() ) {
1799 additionalInfo += i18n("\nUser3: "); 1799 additionalInfo += i18n("\nUser3: ");
1800 additionalInfo += tempAdd;; 1800 additionalInfo += tempAdd;;
1801 } 1801 }
1802 tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer()); 1802 tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer());
1803 phoneS.replace( QRegExp("\\r"), ""); 1803 phoneS.replace( QRegExp("\\r"), "");
1804 if ( ! tempAdd.isEmpty() ) { 1804 if ( ! tempAdd.isEmpty() ) {
1805 additionalInfo += i18n("\nUser4: "); 1805 additionalInfo += i18n("\nUser4: ");
1806 additionalInfo += tempAdd;; 1806 additionalInfo += tempAdd;;
1807 } 1807 }
1808 if (!additionalInfo.isEmpty() && ! syncMode ) { 1808 if (!additionalInfo.isEmpty() && ! syncMode ) {
1809 tempAdd = notesStr; 1809 tempAdd = notesStr;
1810 notesStr = "+++++++++++++++++++++++++++\n"; 1810 notesStr = "+++++++++++++++++++++++++++\n";
1811 notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:"); 1811 notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:");
1812 notesStr += additionalInfo; 1812 notesStr += additionalInfo;
1813 notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n"); 1813 notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n");
1814 notesStr += "+++++++++++++++++++++++++++\n"; 1814 notesStr += "+++++++++++++++++++++++++++\n";
1815 notesStr += tempAdd; 1815 notesStr += tempAdd;
1816 } 1816 }
1817 addressee.setNote( notesStr ); 1817 addressee.setNote( notesStr );
1818#if 0 1818#if 0
1819 // pending 1819 // pending
1820 - IM address: no clue where to get info about the helper ID 1820 - IM address: no clue where to get info about the helper ID
1821 -custom fields: difficult to implement - not implemented 1821 -custom fields: difficult to implement - not implemented
1822 -keys: makes no sense 1822 -keys: makes no sense
1823#endif 1823#endif
1824 return addressee; 1824 return addressee;
1825} 1825}
1826void KAImportOLdialog::slotCancel() 1826void KAImportOLdialog::slotCancel()
1827{ 1827{
1828 reject(); 1828 reject();
1829} 1829}
1830 1830
1831bool KAImportOLdialog::addAddressee( KABC::Addressee a ) 1831bool KAImportOLdialog::addAddressee( KABC::Addressee a )
1832{ 1832{
1833 bool add = true; 1833 bool add = true;
1834 KABC::Addressee::List::Iterator it; 1834 KABC::Addressee::List::Iterator it;
1835 for ( it = mAList.begin(); it != mAList.end(); ++it ) { 1835 for ( it = mAList.begin(); it != mAList.end(); ++it ) {
1836 if ( (*it).uid() == a.uid() ) { 1836 if ( (*it).uid() == a.uid() ) {
1837 add = false; 1837 add = false;
1838 break; 1838 break;
1839 } 1839 }
1840 } 1840 }
1841 if ( add ) { 1841 if ( add ) {
1842 if ( mABook->findByUid(a.uid() ).isEmpty()) 1842 if ( mABook->findByUid(a.uid() ).isEmpty())
1843 mAList.append ( a ); 1843 mAList.append ( a );
1844 else 1844 else
1845 add = false; 1845 add = false;
1846 } 1846 }
1847 return add; 1847 return add;
1848} 1848}
1849// ***************************************************************** 1849// *****************************************************************
1850// ***************************************************************** 1850// *****************************************************************
1851KAwritebackOL::KAwritebackOL( const QString &olFolderID ): QObject() 1851KAwritebackOL::KAwritebackOL( const QString &olFolderID ): QObject()
1852{ 1852{
1853 mSelectedFolderID = olFolderID; 1853 mSelectedFolderID = olFolderID;
1854} 1854}
1855 1855
1856 1856
1857KAwritebackOL::~KAwritebackOL() 1857KAwritebackOL::~KAwritebackOL()
1858{ 1858{
1859 1859
1860} 1860}
1861 1861
1862bool KAwritebackOL::init() 1862bool KAwritebackOL::init()
1863{ 1863{
1864 mSelectedFolder = getFolderFromID( 0 ); 1864 mSelectedFolder = getFolderFromID( 0 );
1865 if ( mSelectedFolder == 0 ) { 1865 if ( mSelectedFolder == 0 ) {
1866 KMessageBox::information(0,"KAwritebackOL: No contact folder found"); 1866 KMessageBox::information(0,"KAwritebackOL: No contact folder found");
1867 return false; 1867 return false;
1868 } 1868 }
1869 LPDISPATCH dispItem = mSelectedFolder; 1869 LPDISPATCH dispItem = mSelectedFolder;
1870 dispItem->AddRef(); 1870 dispItem->AddRef();
1871 MAPIFolder mf(dispItem); 1871 MAPIFolder mf(dispItem);
1872 mf.m_lpDispatch->AddRef(); 1872 mf.m_lpDispatch->AddRef();
1873 mFolderItems = mf.GetItems(); 1873 mFolderItems = mf.GetItems();
1874 return true; 1874 return true;
1875} 1875}
1876void KAwritebackOL::deleteAddressee( KABC::Addressee a ) 1876void KAwritebackOL::deleteAddressee( KABC::Addressee a )
1877{ 1877{
1878 LPDISPATCH itm = getOLitemFromUid ( a.originalExternalUID() ); 1878 LPDISPATCH itm = getOLitemFromUid ( a.originalExternalUID() );
1879 _ContactItem* cItem = (_ContactItem *)&itm; 1879 _ContactItem* cItem = (_ContactItem *)&itm;
1880 if ( cItem != 0 ) { 1880 if ( cItem != 0 ) {
1881 //KMessageBox::information(0,"delete: item found " + a.formattedName() + QString::fromUcs2(cItem->GetLastName().GetBuffer())); 1881 //KMessageBox::information(0,"delete: item found " + a.formattedName() + QString::fromUcs2(cItem->GetLastName().GetBuffer()));
1882 cItem->Delete(); 1882 cItem->Delete();
1883 } 1883 }
1884} 1884}
1885KABC::Addressee KAwritebackOL::changeAddressee( KABC::Addressee a ) 1885KABC::Addressee KAwritebackOL::changeAddressee( KABC::Addressee a )
1886{ 1886{
1887 1887
1888 LPDISPATCH itm = getOLitemFromUid ( a.originalExternalUID() ); 1888 LPDISPATCH itm = getOLitemFromUid ( a.originalExternalUID() );
1889 _ContactItem* cItem = (_ContactItem *)&itm; 1889 _ContactItem* cItem = (_ContactItem *)&itm;
1890 if ( cItem != 0 ) { 1890 if ( cItem != 0 ) {
1891 //KMessageBox::information(0,"Change: item found " + a.formattedName()); 1891 //KMessageBox::information(0,"Change: item found " + a.formattedName());
1892 writeData2OLitem( a, cItem ); 1892 writeData2OLitem( a, cItem );
1893 KABC::Addressee retval = KAImportOLdialog::ol2kapiContact( cItem , true ); 1893 KABC::Addressee retval = KAImportOLdialog::ol2kapiContact( cItem , true );
1894 retval.setUid( a.uid() ); 1894 retval.setUid( a.uid() );
1895 retval.setExternalUID( a.originalExternalUID() ); 1895 retval.setExternalUID( a.originalExternalUID() );
1896 retval.setOriginalExternalUID( a.originalExternalUID() ); 1896 retval.setOriginalExternalUID( a.originalExternalUID() );
1897 return retval; 1897 return retval;
1898 } 1898 }
1899 return KABC::Addressee(); 1899 return KABC::Addressee();
1900} 1900}
1901KABC::Addressee KAwritebackOL::addAddressee( KABC::Addressee a ) 1901KABC::Addressee KAwritebackOL::addAddressee( KABC::Addressee a )
1902{ 1902{
1903 QString newOLid; 1903 QString newOLid;
1904 LPDISPATCH c_itm = gOlAppAB.CreateItem(2); 1904 LPDISPATCH c_itm = gOlAppAB.CreateItem(2);
1905 _ContactItem * aItem = (_ContactItem *)&c_itm ; 1905 _ContactItem * aItem = (_ContactItem *)&c_itm ;
1906 writeData2OLitem( a, aItem ); 1906 writeData2OLitem( a, aItem );
1907 newOLid = QString::fromUcs2(aItem->GetEntryID().GetBuffer()); 1907 newOLid = QString::fromUcs2(aItem->GetEntryID().GetBuffer());
1908 KABC::Addressee retval = KAImportOLdialog::ol2kapiContact( aItem , true ); 1908 KABC::Addressee retval = KAImportOLdialog::ol2kapiContact( aItem , true );
1909 retval.setUid( a.uid() ); 1909 retval.setUid( a.uid() );
1910 retval.setExternalUID( newOLid ); 1910 retval.setExternalUID( newOLid );
1911 retval.setOriginalExternalUID( newOLid ); 1911 retval.setOriginalExternalUID( newOLid );
1912 return retval; 1912 return retval;
1913} 1913}
1914void KAwritebackOL::writeData2OLitem( KABC::Addressee addressee, _ContactItem * aItem ) 1914void KAwritebackOL::writeData2OLitem( KABC::Addressee addressee, _ContactItem * aItem )
1915{ 1915{
1916 // addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); 1916 // addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer()));
1917 //GetLastModificationTime() 1917 //GetLastModificationTime()
1918 //addressee.setName( const QString &name ); 1918 //addressee.setName( const QString &name );
1919 1919
1920 aItem->SetFileAs(addressee.formattedName().ucs2()); 1920 aItem->SetFileAs(addressee.formattedName().ucs2());
1921 aItem->SetLastName(addressee.familyName().ucs2()); 1921 aItem->SetLastName(addressee.familyName().ucs2());
1922 aItem->SetFirstName(addressee.givenName( ).ucs2()); 1922 aItem->SetFirstName(addressee.givenName( ).ucs2());
1923 aItem->SetMiddleName(addressee.additionalName( ).ucs2()); 1923 aItem->SetMiddleName(addressee.additionalName( ).ucs2());
1924 aItem->SetTitle(addressee.prefix().ucs2()); 1924 aItem->SetTitle(addressee.prefix().ucs2());
1925 aItem->SetSuffix(addressee.suffix( ).ucs2()); 1925 aItem->SetSuffix(addressee.suffix( ).ucs2());
1926 aItem->SetNickName(addressee.nickName( ).ucs2()); 1926 aItem->SetNickName(addressee.nickName( ).ucs2());
1927 if ( addressee.birthday().isValid() ) 1927 if ( addressee.birthday().isValid() )
1928 aItem->SetBirthday(Qdt2date(addressee.birthday())); 1928 aItem->SetBirthday(Qdt2date(addressee.birthday()));
1929 else 1929 else
1930 aItem->SetBirthday(Qdt2date(QDateTime(QDate( 4501,1,1 )))); 1930 aItem->SetBirthday(Qdt2date(QDateTime(QDate( 4501,1,1 ))));
1931 //).ucs2()(aItem->) 1931 //).ucs2()(aItem->)
1932 //addressee.Mailer( const QString &mailer ); 1932 //addressee.Mailer( const QString &mailer );
1933 //addressee.TimeZone( const TimeZone &timeZone ); 1933 //addressee.TimeZone( const TimeZone &timeZone );
1934 //addressee.Geo( const Geo &geo ); 1934 //addressee.Geo( const Geo &geo );
1935 //addressee.Title( ).ucs2()(aItem->SetJobTitle()) );// titel is the prefix 1935 //addressee.Title( ).ucs2()(aItem->SetJobTitle()) );// titel is the prefix
1936 aItem->SetJobTitle(addressee.role( ).ucs2()); 1936 aItem->SetJobTitle(addressee.role( ).ucs2());
1937 aItem->SetCompanyName(addressee.organization( ).ucs2()); 1937 aItem->SetCompanyName(addressee.organization( ).ucs2());
1938 QString notesStr = addressee.note(); 1938 QString notesStr = addressee.note();
1939 notesStr.replace( QRegExp("\\n"), "\n\r"); 1939 notesStr.replace( QRegExp("\\n"), "\n\r");
1940 aItem->SetBody(notesStr.ucs2()); 1940 aItem->SetBody(notesStr.ucs2());
1941 1941
1942 aItem->SetCustomerID(addressee.productId( ).ucs2()); 1942 aItem->SetCustomerID(addressee.productId( ).ucs2());
1943 //addressee.Revision( const QDateTime &revision ); 1943 //addressee.Revision( const QDateTime &revision );
1944 // addressee.SortString( const QString &sortString ); 1944 // addressee.SortString( const QString &sortString );
1945 aItem->SetWebPage( addressee.url().url().ucs2()); 1945 aItem->SetWebPage( addressee.url().url().ucs2());
1946 1946
1947 QString tempS; 1947 QString tempS;
1948 1948
1949 1949
1950 tempS = addressee.custom( "KADDRESSBOOK", "X-IMAddress"); 1950 tempS = addressee.custom( "KADDRESSBOOK", "X-IMAddress");
1951 aItem->SetNetMeetingAlias(tempS.ucs2()); 1951 aItem->SetNetMeetingAlias(tempS.ucs2());
1952 1952
1953 tempS = addressee.custom( "KADDRESSBOOK", "X-SpousesName" ); 1953 tempS = addressee.custom( "KADDRESSBOOK", "X-SpousesName" );
1954 aItem->SetSpouse(tempS.ucs2()); 1954 aItem->SetSpouse(tempS.ucs2());
1955 1955
1956 tempS = addressee.custom( "KADDRESSBOOK", "X-ManagersName" ); 1956 tempS = addressee.custom( "KADDRESSBOOK", "X-ManagersName" );
1957 aItem->SetManagerName(tempS.ucs2()); 1957 aItem->SetManagerName(tempS.ucs2());
1958 1958
1959 tempS = addressee.custom( "KADDRESSBOOK", "X-AssistantsName" ); 1959 tempS = addressee.custom( "KADDRESSBOOK", "X-AssistantsName" );
1960 aItem->SetAssistantName(tempS.ucs2()); 1960 aItem->SetAssistantName(tempS.ucs2());
1961 1961
1962 tempS = addressee.custom( "KADDRESSBOOK", "X-Department" ); 1962 tempS = addressee.custom( "KADDRESSBOOK", "X-Department" );
1963 aItem->SetDepartment(tempS.ucs2()); 1963 aItem->SetDepartment(tempS.ucs2());
1964 1964
1965 tempS = addressee.custom( "KADDRESSBOOK", "X-Office" ); 1965 tempS = addressee.custom( "KADDRESSBOOK", "X-Office" );
1966 aItem->SetOfficeLocation(tempS.ucs2()); 1966 aItem->SetOfficeLocation(tempS.ucs2());
1967 1967
1968 tempS = addressee.custom( "KADDRESSBOOK", "X-Profession"); 1968 tempS = addressee.custom( "KADDRESSBOOK", "X-Profession");
1969 aItem->SetProfession(tempS.ucs2()); 1969 aItem->SetProfession(tempS.ucs2());
1970 1970
1971 tempS = addressee.custom( "KADDRESSBOOK", "X-Anniversary"); 1971 tempS = addressee.custom( "KADDRESSBOOK", "X-Anniversary");
1972 if ( !tempS.isEmpty() ){ 1972 if ( !tempS.isEmpty() ){
1973 QDateTime dt = QDateTime ( KGlobal::locale()->readDate( tempS,"%Y-%m-%d") ); 1973 QDateTime dt = QDateTime ( KGlobal::locale()->readDate( tempS,"%Y-%m-%d") );
1974 aItem->SetAnniversary(Qdt2date( dt )); 1974 aItem->SetAnniversary(Qdt2date( dt ));
1975 } else { 1975 } else {
1976 aItem->SetAnniversary(Qdt2date(QDateTime(QDate( 4501,1,1 )))); 1976 aItem->SetAnniversary(Qdt2date(QDateTime(QDate( 4501,1,1 ))));
1977 } 1977 }
1978 int sec = (int)addressee.secrecy().type(); 1978 int sec = (int)addressee.secrecy().type();
1979 if ( sec > 0 )// mapping pers -> private 1979 if ( sec > 0 )// mapping pers -> private
1980 ++sec; 1980 ++sec;
1981 aItem->SetSensitivity( sec ) ; 1981 aItem->SetSensitivity( sec ) ;
1982 //addressee.Logo( const Picture &logo ); 1982 //addressee.Logo( const Picture &logo );
1983 //addressee.Photo( const Picture &photo ); 1983 //addressee.Photo( const Picture &photo );
1984 //addressee.Sound( const Sound &sound ); 1984 //addressee.Sound( const Sound &sound );
1985 //addressee.Agent( const Agent &agent ); 1985 //addressee.Agent( const Agent &agent );
1986 1986
1987 QString cat = addressee.categories().join("; "); 1987 QString cat = addressee.categories().join("; ");
1988 aItem->SetCategories( cat.ucs2()); 1988 aItem->SetCategories( cat.ucs2());
1989 1989
1990 1990
1991 KABC::PhoneNumber::List phoneNumbers; 1991 KABC::PhoneNumber::List phoneNumbers;
1992 KABC::PhoneNumber::List::Iterator phoneIter; 1992 KABC::PhoneNumber::List::Iterator phoneIter;
1993 phoneNumbers = addressee.phoneNumbers(); 1993 phoneNumbers = addressee.phoneNumbers();
1994 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 1994 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
1995 ++phoneIter ) { 1995 ++phoneIter ) {
1996 1996
1997 } 1997 }
1998 QString phoneS; 1998 QString phoneS;
1999 1999
2000 phoneS = addressee.phoneNumberString( 2000 phoneS = addressee.phoneNumberString(
2001 KABC::PhoneNumber::Work + 2001 KABC::PhoneNumber::Work +
2002 KABC::PhoneNumber::Voice + 2002 KABC::PhoneNumber::Voice +
2003 KABC::PhoneNumber::Msg ); 2003 KABC::PhoneNumber::Msg );
2004 aItem->SetAssistantTelephoneNumber(phoneS.ucs2()); 2004 aItem->SetAssistantTelephoneNumber(phoneS.ucs2());
2005 2005
2006 phoneS = addressee.phoneNumberString( 2006 phoneS = addressee.phoneNumberString(
2007 KABC::PhoneNumber::Work + 2007 KABC::PhoneNumber::Work +
2008 KABC::PhoneNumber::Pref) ; 2008 KABC::PhoneNumber::Pref) ;
2009 aItem->SetBusinessTelephoneNumber(phoneS.ucs2()); 2009 aItem->SetBusinessTelephoneNumber(phoneS.ucs2());
2010 2010
2011 phoneS = addressee.phoneNumberString( 2011 phoneS = addressee.phoneNumberString(
2012 KABC::PhoneNumber::Work ) ; 2012 KABC::PhoneNumber::Work ) ;
2013 aItem->SetBusiness2TelephoneNumber(phoneS.ucs2()); 2013 aItem->SetBusiness2TelephoneNumber(phoneS.ucs2());
2014 2014
2015 phoneS = addressee.phoneNumberString( 2015 phoneS = addressee.phoneNumberString(
2016 KABC::PhoneNumber::Work + 2016 KABC::PhoneNumber::Work +
2017 KABC::PhoneNumber::Fax ) ; 2017 KABC::PhoneNumber::Fax ) ;
2018 aItem->SetBusinessFaxNumber(phoneS.ucs2()); 2018 aItem->SetBusinessFaxNumber(phoneS.ucs2());
2019 2019
2020 2020
2021 phoneS = addressee.phoneNumberString( 2021 phoneS = addressee.phoneNumberString(
2022 KABC::PhoneNumber::Car ) ; 2022 KABC::PhoneNumber::Car ) ;
2023 aItem->SetCarTelephoneNumber(phoneS.ucs2()); 2023 aItem->SetCarTelephoneNumber(phoneS.ucs2());
2024 2024
2025 phoneS = addressee.phoneNumberString( 2025 phoneS = addressee.phoneNumberString(
2026 KABC::PhoneNumber::Home + 2026 KABC::PhoneNumber::Home +
2027 KABC::PhoneNumber::Pref ) ; 2027 KABC::PhoneNumber::Pref ) ;
2028 aItem->SetHomeTelephoneNumber(phoneS.ucs2()); 2028 aItem->SetHomeTelephoneNumber(phoneS.ucs2());
2029 2029
2030 phoneS = addressee.phoneNumberString( 2030 phoneS = addressee.phoneNumberString(
2031 KABC::PhoneNumber::Home ) ; 2031 KABC::PhoneNumber::Home ) ;
2032 aItem->SetHome2TelephoneNumber(phoneS.ucs2()); 2032 aItem->SetHome2TelephoneNumber(phoneS.ucs2());
2033 2033
2034 phoneS = addressee.phoneNumberString( 2034 phoneS = addressee.phoneNumberString(
2035 KABC::PhoneNumber::Home + 2035 KABC::PhoneNumber::Home +
2036 KABC::PhoneNumber::Fax ) ; 2036 KABC::PhoneNumber::Fax ) ;
2037 aItem->SetHomeFaxNumber(phoneS.ucs2()); 2037 aItem->SetHomeFaxNumber(phoneS.ucs2());
2038 2038
2039 phoneS = addressee.phoneNumberString( 2039 phoneS = addressee.phoneNumberString(
2040 KABC::PhoneNumber::Isdn ) ; 2040 KABC::PhoneNumber::Isdn ) ;
2041 aItem->SetISDNNumber(phoneS.ucs2()); 2041 aItem->SetISDNNumber(phoneS.ucs2());
2042 2042
2043 phoneS = addressee.phoneNumberString( 2043 phoneS = addressee.phoneNumberString(
2044 KABC::PhoneNumber::Cell ) ; 2044 KABC::PhoneNumber::Cell ) ;
2045 aItem->SetMobileTelephoneNumber(phoneS.ucs2()); 2045 aItem->SetMobileTelephoneNumber(phoneS.ucs2());
2046 2046
2047 phoneS = addressee.phoneNumberString( 2047 phoneS = addressee.phoneNumberString(
2048 KABC::PhoneNumber::Fax ) ; 2048 KABC::PhoneNumber::Fax ) ;
2049 aItem->SetOtherFaxNumber(phoneS.ucs2()); 2049 aItem->SetOtherFaxNumber(phoneS.ucs2());
2050 2050
2051 phoneS = addressee.phoneNumberString( 2051 phoneS = addressee.phoneNumberString(
2052 KABC::PhoneNumber::Voice ) ; 2052 KABC::PhoneNumber::Voice ) ;
2053 aItem->SetOtherTelephoneNumber(phoneS.ucs2()); 2053 aItem->SetOtherTelephoneNumber(phoneS.ucs2());
2054 2054
2055 phoneS = addressee.phoneNumberString( 2055 phoneS = addressee.phoneNumberString(
2056 KABC::PhoneNumber::Pager ) ; 2056 KABC::PhoneNumber::Pager ) ;
2057 aItem->SetPagerNumber(phoneS.ucs2()); 2057 aItem->SetPagerNumber(phoneS.ucs2());
2058 2058
2059 phoneS = addressee.phoneNumberString( 2059 phoneS = addressee.phoneNumberString(
2060 KABC::PhoneNumber::Pref ) ; 2060 KABC::PhoneNumber::Pref ) ;
2061 aItem->SetPrimaryTelephoneNumber(phoneS.ucs2()); 2061 aItem->SetPrimaryTelephoneNumber(phoneS.ucs2());
2062 2062
2063 phoneS = addressee.phoneNumberString( 2063 phoneS = addressee.phoneNumberString(
2064 KABC::PhoneNumber::Pcs + 2064 KABC::PhoneNumber::Pcs +
2065 KABC::PhoneNumber::Voice) ; 2065 KABC::PhoneNumber::Voice) ;
2066 aItem->SetTTYTDDTelephoneNumber(phoneS.ucs2()); 2066 aItem->SetTTYTDDTelephoneNumber(phoneS.ucs2());
2067 2067
2068 phoneS = addressee.phoneNumberString( 2068 phoneS = addressee.phoneNumberString(
2069 KABC::PhoneNumber::Pcs ) ; 2069 KABC::PhoneNumber::Pcs ) ;
2070 aItem->SetTelexNumber(phoneS.ucs2()); 2070 aItem->SetTelexNumber(phoneS.ucs2());
2071 2071
2072 phoneS = addressee.phoneNumberString( 2072 phoneS = addressee.phoneNumberString(
2073 KABC::PhoneNumber::Work + 2073 KABC::PhoneNumber::Work +
2074 KABC::PhoneNumber::Msg ) ; 2074 KABC::PhoneNumber::Msg ) ;
diff --git a/libkdepim/ol_access.h b/libkdepim/ol_access.h
index 85dbc6c..3422f65 100755
--- a/libkdepim/ol_access.h
+++ b/libkdepim/ol_access.h
@@ -1,174 +1,174 @@
1/* 1/*
2 This file is part of KDE/Pim-Pi 2 This file is part of KDE/Pim-Pi
3 Copyright (c) 2006 Lutz Rogowski 3 Copyright (c) 2006 Lutz Rogowski
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef OL_ACCESS_H 23#ifndef OL_ACCESS_H
24#define OL_ACCESS_H 24#define OL_ACCESS_H
25 25
26#include <qstring.h> 26#include <qstring.h>
27 27
28#include <kdialogbase.h> 28#include <kdialogbase.h>
29#include <kabc/addressee.h> 29#include <kabc/addressee.h>
30#include <kabc/addressbook.h> 30#include <kabc/addressbook.h>
31 31
32#include <afxdisp.h> 32#include <afxdisp.h>
33 33
34#include "../outport/msoutl9.h" 34#include "../outport/msoutl9.h"
35 35
36#define OL_CONTACT_DATA 2 36#define OL_CONTACT_DATA 2
37#define OL_CALENDAR_DATA 1 //pending is this the right number 37#define OL_CALENDAR_DATA 1 //pending is this the right number
38 38
39class QDateTime; 39class QDateTime;
40class QListView; 40class Q3ListView;
41class OLEListViewItem; 41class OLEListViewItem;
42class _ContactItem; 42class _ContactItem;
43class OL_access : public QObject 43class OL_access : public QObject
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 public: 46 public:
47 static OL_access *instance(); 47 static OL_access *instance();
48 ~OL_access(); 48 ~OL_access();
49 //static converter methods 49 //static converter methods
50 static QDateTime mDdate2Qdtr( DATE dt); 50 static QDateTime mDdate2Qdtr( DATE dt);
51 static DATE Qdt2date( QDateTime dt ); 51 static DATE Qdt2date( QDateTime dt );
52 static KABC::Addressee ol2kapiContact( _ContactItem * aItem , bool syncMode); 52 static KABC::Addressee ol2kapiContact( _ContactItem * aItem , bool syncMode);
53 static void writeData2OLitem( KABC::Addressee addressee, _ContactItem * aItem ); 53 static void writeData2OLitem( KABC::Addressee addressee, _ContactItem * aItem );
54 54
55 KABC::Addressee::List importOLcontacts(); 55 KABC::Addressee::List importOLcontacts();
56 QStringList getFolderSelection( int type, QString caption ); 56 QStringList getFolderSelection( int type, QString caption );
57 void readContactData( LPDISPATCH folder, KABC::Addressee::List* list, bool syncMode ); 57 void readContactData( LPDISPATCH folder, KABC::Addressee::List* list, bool syncMode );
58 58
59 LPDISPATCH getFolderFromID( LPDISPATCH parentFolder, QString selectedFolderID ); 59 LPDISPATCH getFolderFromID( LPDISPATCH parentFolder, QString selectedFolderID );
60 bool setSelectedFolder( QString folderID ); 60 bool setSelectedFolder( QString folderID );
61 //call setSelectedFolder() before using the next methods: 61 //call setSelectedFolder() before using the next methods:
62 void deleteAddressee( KABC::Addressee a ); 62 void deleteAddressee( KABC::Addressee a );
63 KABC::Addressee changeAddressee( KABC::Addressee a ); 63 KABC::Addressee changeAddressee( KABC::Addressee a );
64 KABC::Addressee addAddressee( KABC::Addressee a ); 64 KABC::Addressee addAddressee( KABC::Addressee a );
65 65
66 66
67 67
68 68
69 public slots: 69 public slots:
70 70
71 71
72 signals: 72 signals:
73 73
74 protected slots: 74 protected slots:
75 75
76 76
77 protected: 77 protected:
78 78
79 private: 79 private:
80 _Application gOlAppAB; 80 _Application gOlAppAB;
81 bool mErrorInit; 81 bool mErrorInit;
82 void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent, long fType); 82 void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent, long fType);
83 LPDISPATCH getOLcontactItemFromUid( QString uid ); 83 LPDISPATCH getOLcontactItemFromUid( QString uid );
84 84
85 QString mSelectedFolderID; 85 QString mSelectedFolderID;
86 LPDISPATCH mSelectedFolder; 86 LPDISPATCH mSelectedFolder;
87 _Items mFolderItems; 87 _Items mFolderItems;
88 88
89 OL_access(); 89 OL_access();
90 static OL_access *sInstance; 90 static OL_access *sInstance;
91}; 91};
92 92
93 93
94#if 0 94#if 0
95//using namespace KABC; 95//using namespace KABC;
96//class KABC::AddressBook; 96//class KABC::AddressBook;
97 97
98/** 98/**
99 This is the base class for the calendar component editors. 99 This is the base class for the calendar component editors.
100*/ 100*/
101class KAImportOLdialog : public KDialogBase 101class KAImportOLdialog : public KDialogBase
102{ 102{
103 Q__OBJECT 103 Q__OBJECT
104 public: 104 public:
105 /** 105 /**
106 Construct new IncidenceEditor. 106 Construct new IncidenceEditor.
107 */ 107 */
108 KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook, 108 KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook,
109 QWidget *parent ); 109 QWidget *parent );
110 ~KAImportOLdialog(); 110 ~KAImportOLdialog();
111 111
112 /** Initialize editor. This function creates the tab widgets. */ 112 /** Initialize editor. This function creates the tab widgets. */
113 void init(); 113 void init();
114 void setSyncMode(); 114 void setSyncMode();
115 KABC::Addressee::List getAddressList(); 115 KABC::Addressee::List getAddressList();
116 QString selectedFolderID() {return mSelectedFolderID;} 116 QString selectedFolderID() {return mSelectedFolderID;}
117 static KABC::Addressee ol2kapiContact( _ContactItem * , bool syncMode ); 117 static KABC::Addressee ol2kapiContact( _ContactItem * , bool syncMode );
118 static bool sOLDispatch; 118 static bool sOLDispatch;
119 pub_lic sl_ots: 119 pub_lic sl_ots:
120 120
121 121
122 sign_als: 122 sign_als:
123 123
124 prote_cted slo_ts: 124 prote_cted slo_ts:
125 void slotApply(); 125 void slotApply();
126 void slotOk(); 126 void slotOk();
127 void slotCancel(); 127 void slotCancel();
128 128
129 protected: 129 protected:
130 void setupFolderView(); 130 void setupFolderView();
131 void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent); 131 void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent);
132 void readContactData( DWORD folder ); 132 void readContactData( DWORD folder );
133 133
134 KABC::AddressBook * mABook; 134 KABC::AddressBook * mABook;
135 QListView * mListView; 135 Q3ListView * mListView;
136 KABC::Addressee::List mAList; 136 KABC::Addressee::List mAList;
137 bool addAddressee( KABC::Addressee a ); 137 bool addAddressee( KABC::Addressee a );
138 private: 138 private:
139 int importedItems; 139 int importedItems;
140 bool mSyncMode; 140 bool mSyncMode;
141 QString mSelectedFolderID; 141 QString mSelectedFolderID;
142}; 142};
143class KAwritebackOL : public QObject 143class KAwritebackOL : public QObject
144{ 144{
145 Q__OBJECT 145 Q__OBJECT
146 public: 146 public:
147 KAwritebackOL( const QString &olFolderID ); 147 KAwritebackOL( const QString &olFolderID );
148 ~KAwritebackOL(); 148 ~KAwritebackOL();
149 bool init(); 149 bool init();
150 void deleteAddressee( KABC::Addressee a ); 150 void deleteAddressee( KABC::Addressee a );
151 KABC::Addressee changeAddressee( KABC::Addressee a ); 151 KABC::Addressee changeAddressee( KABC::Addressee a );
152 KABC::Addressee addAddressee( KABC::Addressee a ); 152 KABC::Addressee addAddressee( KABC::Addressee a );
153 public sl_ots: 153 public sl_ots:
154 154
155 155
156 signals: 156 signals:
157 157
158 protected sl_ots: 158 protected sl_ots:
159 159
160 160
161 protected: 161 protected:
162 LPDISPATCH getFolderFromID( LPDISPATCH parentFolder ); 162 LPDISPATCH getFolderFromID( LPDISPATCH parentFolder );
163 LPDISPATCH getOLitemFromUid( QString uid ); 163 LPDISPATCH getOLitemFromUid( QString uid );
164 void writeData2OLitem( KABC::Addressee a, _ContactItem * olitem ); 164 void writeData2OLitem( KABC::Addressee a, _ContactItem * olitem );
165 private: 165 private:
166 QString mSelectedFolderID; 166 QString mSelectedFolderID;
167 LPDISPATCH mSelectedFolder; 167 LPDISPATCH mSelectedFolder;
168 _Items mFolderItems; 168 _Items mFolderItems;
169}; 169};
170 170
171#endif 171#endif
172#endif 172#endif
173 173
174 174
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp
index 89db22b..0ea73f5 100644
--- a/libkdepim/phoneaccess.cpp
+++ b/libkdepim/phoneaccess.cpp
@@ -1,216 +1,219 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 3
4 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 4 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22 22
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <QDesktopWidget>
26#include <q3ptrlist.h>
26#include <qregexp.h> 27#include <qregexp.h>
27#include <qfile.h> 28#include <qfile.h>
28#include <qlabel.h> 29#include <qlabel.h>
29#include <qtextstream.h> 30#include <q3textstream.h>
30#include <qtextcodec.h> 31#include <qtextcodec.h>
31#include <qdir.h> 32#include <qdir.h>
32#include <kmessagebox.h> 33#include <kmessagebox.h>
33#include <stdlib.h> 34#include <stdlib.h>
34#include "phoneaccess.h" 35#include "phoneaccess.h"
35 36
36void PhoneAccess::writeConfig( QString device, QString connection, QString model ) 37void PhoneAccess::writeConfig( QString device, QString connection, QString model )
37{ 38{
38#ifdef _WIN32_ 39#ifdef _WIN32_
39 QString fileName = qApp->applicationDirPath () +"\\gammurc"; 40 QString fileName = qApp->applicationDirPath () +"\\gammurc";
40#else 41#else
41 QString fileName = QDir::homeDirPath() +"/.gammurc"; 42 QString fileName = QDir::homeDirPath() +"/.gammurc";
42#endif 43#endif
43 //qDebug("save %d ", load ); 44 //qDebug("save %d ", load );
44 QString content = "[gammu]\n";; 45 QString content = "[gammu]\n";;
45 bool write = false; 46 bool write = false;
46 bool addPort = true, addConnection = true, addModel = true; 47 bool addPort = true, addConnection = true, addModel = true;
47 QFile file( fileName ); 48 QFile file( fileName );
48 if ( QFile::exists( fileName) ) { 49 if ( QFile::exists( fileName) ) {
49 if (!file.open( IO_ReadOnly ) ) { 50 if (!file.open( QIODevice::ReadOnly ) ) {
50 qDebug("Error: cannot open %s ", fileName.latin1() ); 51 qDebug("Error: cannot open %s ", fileName.latin1() );
51 return; 52 return;
52 } 53 }
53 QString line; 54 QString line;
54 while ( file.readLine( line, 1024 ) > 0 ) { 55 char tmp[1024];
56 while ( file.readLine( tmp, 1024 ) > 0 ) {
57 line = tmp;
55 //qDebug("*%s* ", line.latin1() ); 58 //qDebug("*%s* ", line.latin1() );
56 if ( line.left(7 ) == "[gammu]" ) { 59 if ( line.left(7 ) == "[gammu]" ) {
57 ; 60 ;
58 } else 61 } else
59 if ( line.left(4 ) == "port" ) { 62 if ( line.left(4 ) == "port" ) {
60 if ( line == "port = " + device+"\n" ) { 63 if ( line == "port = " + device+"\n" ) {
61 content += line ; 64 content += line ;
62 addPort = false; 65 addPort = false;
63 //qDebug("port found" ); 66 //qDebug("port found" );
64 } 67 }
65 68
66 } else if ( line.left(5 ) == "model" ) { 69 } else if ( line.left(5 ) == "model" ) {
67 if ( line == "model = " + model +"\n") { 70 if ( line == "model = " + model +"\n") {
68 content += line ; 71 content += line ;
69 addModel = false; 72 addModel = false;
70 //qDebug("model found" ); 73 //qDebug("model found" );
71 } 74 }
72 75
73 } else if ( line.left( 10 ) == "connection" ) { 76 } else if ( line.left( 10 ) == "connection" ) {
74 if ( line == "connection = " + connection +"\n") { 77 if ( line == "connection = " + connection +"\n") {
75 addConnection = false; 78 addConnection = false;
76 content += line ; 79 content += line ;
77 //qDebug("con found" ); 80 //qDebug("con found" );
78 } 81 }
79 82
80 } else { 83 } else {
81 content += line ; 84 content += line ;
82 } 85 }
83 } 86 }
84 file.close(); 87 file.close();
85 } else { 88 } else {
86 if ( ! connection.isEmpty() ) { 89 if ( ! connection.isEmpty() ) {
87 addConnection = true; 90 addConnection = true;
88 } 91 }
89 if ( ! device.isEmpty() ) { 92 if ( ! device.isEmpty() ) {
90 addPort = true; 93 addPort = true;
91 94
92 } 95 }
93 if ( ! model.isEmpty() ) { 96 if ( ! model.isEmpty() ) {
94 addModel = true; 97 addModel = true;
95 } 98 }
96 } 99 }
97 100
98 if ( addConnection ) { 101 if ( addConnection ) {
99 write = true; 102 write = true;
100 content += "connection = "; 103 content += "connection = ";
101 content += connection; 104 content += connection;
102 content += "\n"; 105 content += "\n";
103 } 106 }
104 if ( addPort ) { 107 if ( addPort ) {
105 write = true; 108 write = true;
106 content += "port = "; 109 content += "port = ";
107 content += device; 110 content += device;
108 content += "\n"; 111 content += "\n";
109 112
110 } 113 }
111 if ( addModel ) { 114 if ( addModel ) {
112 write = true; 115 write = true;
113 content += "model = "; 116 content += "model = ";
114 content += model; 117 content += model;
115 content += "\n"; 118 content += "\n";
116 } 119 }
117 if ( write ) { 120 if ( write ) {
118 if (!file.open( IO_WriteOnly ) ) { 121 if (!file.open( QIODevice::WriteOnly ) ) {
119 qDebug("Error: cannot write file %s ", fileName.latin1() ); 122 qDebug("Error: cannot write file %s ", fileName.latin1() );
120 return; 123 return;
121 } 124 }
122 qDebug("Writing file %s ", fileName.latin1() ); 125 qDebug("Writing file %s ", fileName.latin1() );
123 QTextStream ts( &file ); 126 Q3TextStream ts( &file );
124 ts << content ; 127 ts << content ;
125 file.close(); 128 file.close();
126 } 129 }
127 130
128} 131}
129 132
130 133
131bool PhoneAccess::writeToPhone( QString fileName) 134bool PhoneAccess::writeToPhone( QString fileName)
132{ 135{
133 136
134#ifdef DESKTOP_VERSION 137#ifdef DESKTOP_VERSION
135#ifdef _WIN32_ 138#ifdef _WIN32_
136 QString command ="kammu --restore " + fileName ; 139 QString command ="kammu --restore " + fileName ;
137#else 140#else
138 QString command ="./kammu --restore " + fileName ; 141 QString command ="./kammu --restore " + fileName ;
139#endif 142#endif
140#else 143#else
141 QString command ="kammu --restore " + fileName ; 144 QString command ="kammu --restore " + fileName ;
142#endif 145#endif
143 int ret = 1; 146 int ret = 1;
144 while ( ret != 0 ) { 147 while ( ret != 0 ) {
145 QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); 148 QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 );
146 int w = 235; 149 int w = 235;
147 int h = status->sizeHint().height()+20 ; 150 int h = status->sizeHint().height()+20 ;
148 int dw = QApplication::desktop()->width(); 151 int dw = QApplication::desktop()->width();
149 int dh = QApplication::desktop()->height(); 152 int dh = QApplication::desktop()->height();
150 if ( dw > 310 ) 153 if ( dw > 310 )
151 w = 310; 154 w = 310;
152 status->setCaption(i18n("Writing to phone...") ); 155 status->setCaption(i18n("Writing to phone...") );
153 status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 156 status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
154 status->show(); 157 status->show();
155 status->raise(); 158 status->raise();
156 status->update(); 159 status->update();
157 qApp->processEvents(); 160 qApp->processEvents();
158 status->update(); 161 status->update();
159 qApp->processEvents(); 162 qApp->processEvents();
160 ret = system ( command.latin1()); 163 ret = system ( command.latin1());
161 delete status; 164 delete status;
162 qApp->processEvents(); 165 qApp->processEvents();
163 if ( ret ) { 166 if ( ret ) {
164 qDebug("Error S::command returned %d.", ret); 167 qDebug("Error S::command returned %d.", ret);
165 int retval = KMessageBox::warningContinueCancel(0, 168 int retval = KMessageBox::warningContinueCancel(0,
166 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); 169 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel"));
167 if ( retval != KMessageBox::Continue ) 170 if ( retval != KMessageBox::Continue )
168 return false; 171 return false;
169 } 172 }
170 } 173 }
171 return true; 174 return true;
172} 175}
173bool PhoneAccess::readFromPhone( QString fileName) 176bool PhoneAccess::readFromPhone( QString fileName)
174{ 177{
175 178
176#ifdef DESKTOP_VERSION 179#ifdef DESKTOP_VERSION
177#ifdef _WIN32_ 180#ifdef _WIN32_
178 QString command ="kammu --backup " + fileName + " -yes" ; 181 QString command ="kammu --backup " + fileName + " -yes" ;
179#else 182#else
180 QString command ="./kammu --backup " + fileName + " -yes" ; 183 QString command ="./kammu --backup " + fileName + " -yes" ;
181#endif 184#endif
182#else 185#else
183 QString command ="kammu --backup " + fileName + " -yes" ; 186 QString command ="kammu --backup " + fileName + " -yes" ;
184#endif 187#endif
185 int ret = 1; 188 int ret = 1;
186 while ( ret != 0 ) { 189 while ( ret != 0 ) {
187 QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); 190 QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 );
188 int w = 235; 191 int w = 235;
189 int h = status->sizeHint().height()+20 ; 192 int h = status->sizeHint().height()+20 ;
190 int dw = QApplication::desktop()->width(); 193 int dw = QApplication::desktop()->width();
191 int dh = QApplication::desktop()->height(); 194 int dh = QApplication::desktop()->height();
192 if ( dw > 310 ) 195 if ( dw > 310 )
193 w = 310; 196 w = 310;
194 status->setCaption(i18n("Reading from phone...") ); 197 status->setCaption(i18n("Reading from phone...") );
195 status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 198 status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
196 status->show(); 199 status->show();
197 status->raise(); 200 status->raise();
198 status->update(); 201 status->update();
199 qApp->processEvents(); 202 qApp->processEvents();
200 status->update(); 203 status->update();
201 qApp->processEvents(); 204 qApp->processEvents();
202 ret = system ( command.latin1() ); 205 ret = system ( command.latin1() );
203 delete status; 206 delete status;
204 qApp->processEvents(); 207 qApp->processEvents();
205 if ( ret ) { 208 if ( ret ) {
206 qDebug("Error reading from phone:Command returned %d", ret); 209 qDebug("Error reading from phone:Command returned %d", ret);
207 int retval = KMessageBox::warningContinueCancel(0, 210 int retval = KMessageBox::warningContinueCancel(0,
208 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); 211 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel"));
209 if ( retval != KMessageBox::Continue ) 212 if ( retval != KMessageBox::Continue )
210 return false; 213 return false;
211 214
212 } 215 }
213 } 216 }
214 qApp->processEvents(); 217 qApp->processEvents();
215 return true; 218 return true;
216} 219}