-rw-r--r-- | kaddressbook/incsearchwidget.cpp | 19 | ||||
-rw-r--r-- | kaddressbook/incsearchwidget.h | 1 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/kabprefs.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/kabprefs.h | 1 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 2 |
8 files changed, 28 insertions, 7 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp index 2ffa357..3533427 100644 --- a/kaddressbook/incsearchwidget.cpp +++ b/kaddressbook/incsearchwidget.cpp | |||
@@ -1,150 +1,161 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qcombobox.h> | 27 | #include <qcombobox.h> |
28 | 28 | ||
29 | #include <kdialog.h> | 29 | #include <kdialog.h> |
30 | #include <klineedit.h> | 30 | #include <klineedit.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kglobal.h> | ||
34 | #include "kabprefs.h" | ||
33 | 35 | ||
34 | #include "incsearchwidget.h" | 36 | #include "incsearchwidget.h" |
35 | 37 | ||
36 | IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) | 38 | IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) |
37 | : QWidget( parent, name ) | 39 | : QWidget( parent, name ) |
38 | { | 40 | { |
39 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
40 | //US setCaption( i18n( "Incremental Search" ) ); | 42 | //US setCaption( i18n( "Incremental Search" ) ); |
41 | #endif //KAB_EMBEDDED | 43 | #endif //KAB_EMBEDDED |
42 | 44 | ||
43 | QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); | 45 | QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); |
44 | 46 | ||
45 | #ifdef DESKTOP_VERSION | 47 | #ifdef DESKTOP_VERSION |
46 | QLabel *label = new QLabel( i18n( "Search:" ), this ); | 48 | QLabel *label = new QLabel( i18n( "Search:" ), this ); |
47 | label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); | 49 | label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); |
48 | layout->addWidget( label ); | 50 | layout->addWidget( label ); |
49 | #endif //KAB_EMBEDDED | 51 | #endif //KAB_EMBEDDED |
50 | 52 | ||
51 | mSearchText = new KLineEdit( this ); | 53 | mSearchText = new KLineEdit( this ); |
52 | layout->addWidget( mSearchText ); | 54 | layout->addWidget( mSearchText ); |
53 | // #ifdef KAB_EMBEDDED | 55 | // #ifdef KAB_EMBEDDED |
54 | // if (KGlobal::getOrientation() == KGlobal::Portrait) | 56 | // if (KGlobal::getOrientation() == KGlobal::Portrait) |
55 | // mSearchText->setMaximumWidth(30); | 57 | // mSearchText->setMaximumWidth(30); |
56 | // #endif //KAB_EMBEDDED | 58 | // #endif //KAB_EMBEDDED |
57 | 59 | ||
58 | 60 | ||
59 | mFieldCombo = new QComboBox( false, this ); | 61 | mFieldCombo = new QComboBox( false, this ); |
60 | layout->addWidget( mFieldCombo ); | 62 | layout->addWidget( mFieldCombo ); |
61 | mFieldCombo->setMaximumHeight( 34 ); | 63 | mFieldCombo->setMaximumHeight( 34 ); |
62 | QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); | 64 | QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); |
63 | 65 | ||
64 | // #ifndef KAB_EMBEDDED | 66 | // #ifndef KAB_EMBEDDED |
65 | // resize( QSize(420, 50).expandedTo( sizeHint() ) ); | 67 | // resize( QSize(420, 50).expandedTo( sizeHint() ) ); |
66 | // #else //KAB_EMBEDDED | 68 | // #else //KAB_EMBEDDED |
67 | // resize( QSize(30, 10).expandedTo( sizeHint() ) ); | 69 | // resize( QSize(30, 10).expandedTo( sizeHint() ) ); |
68 | // #endif //KAB_EMBEDDED | 70 | // #endif //KAB_EMBEDDED |
69 | 71 | ||
70 | #ifdef DESKTOP_VERSION | 72 | |
71 | // for performance reasons, we do a search on the pda only after return is pressed | 73 | // for performance reasons, we do a search on the pda only after return is pressed |
72 | connect( mSearchText, SIGNAL( textChanged( const QString& ) ), | 74 | connect( mSearchText, SIGNAL( textChanged( const QString& ) ), |
73 | SLOT( announceDoSearch() ) ); | 75 | SLOT( announceDoSearch2() ) ); |
74 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), | 76 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), |
75 | SLOT( announceDoSearch() ) ); | 77 | SLOT( announceDoSearch2() ) ); |
76 | #endif | 78 | |
77 | connect( mSearchText, SIGNAL( returnPressed() ), | 79 | connect( mSearchText, SIGNAL( returnPressed() ), |
78 | SLOT( announceDoSearch() ) ); | 80 | SLOT( announceDoSearch() ) ); |
79 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), | 81 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), |
80 | SLOT( announceFieldChanged() ) ); | 82 | SLOT( announceFieldChanged() ) ); |
81 | 83 | ||
82 | setFocusProxy( mSearchText ); | 84 | setFocusProxy( mSearchText ); |
83 | } | 85 | } |
84 | 86 | ||
85 | IncSearchWidget::~IncSearchWidget() | 87 | IncSearchWidget::~IncSearchWidget() |
86 | { | 88 | { |
87 | 89 | ||
88 | } | 90 | } |
91 | void IncSearchWidget::announceDoSearch2() | ||
92 | { | ||
93 | if ( KABPrefs::instance()->mSearchWithReturn ) | ||
94 | return; | ||
95 | emit doSearch( mSearchText->text() ); | ||
96 | //qDebug("emit dosreach "); | ||
97 | } | ||
89 | 98 | ||
90 | void IncSearchWidget::announceDoSearch() | 99 | void IncSearchWidget::announceDoSearch() |
91 | { | 100 | { |
101 | |||
92 | emit doSearch( mSearchText->text() ); | 102 | emit doSearch( mSearchText->text() ); |
103 | // qDebug("emit dosreach "); | ||
93 | } | 104 | } |
94 | 105 | ||
95 | void IncSearchWidget::announceFieldChanged() | 106 | void IncSearchWidget::announceFieldChanged() |
96 | { | 107 | { |
97 | emit fieldChanged(); | 108 | emit fieldChanged(); |
98 | } | 109 | } |
99 | 110 | ||
100 | void IncSearchWidget::setFields( const KABC::Field::List &list ) | 111 | void IncSearchWidget::setFields( const KABC::Field::List &list ) |
101 | { | 112 | { |
102 | 113 | ||
103 | mFieldCombo->clear(); | 114 | mFieldCombo->clear(); |
104 | mFieldCombo->insertItem( i18n( "All Fields" ) ); | 115 | mFieldCombo->insertItem( i18n( "All Fields" ) ); |
105 | QFontMetrics fm ( mFieldCombo->font() ); | 116 | QFontMetrics fm ( mFieldCombo->font() ); |
106 | int wid = fm.width(i18n( "All Fields" ) ); | 117 | int wid = fm.width(i18n( "All Fields" ) ); |
107 | int max = wid; | 118 | int max = wid; |
108 | 119 | ||
109 | KABC::Field::List::ConstIterator it; | 120 | KABC::Field::List::ConstIterator it; |
110 | for ( it = list.begin(); it != list.end(); ++it ) { | 121 | for ( it = list.begin(); it != list.end(); ++it ) { |
111 | mFieldCombo->insertItem( (*it)->label() ); | 122 | mFieldCombo->insertItem( (*it)->label() ); |
112 | // wid = fm.width((*it)->label() ); | 123 | // wid = fm.width((*it)->label() ); |
113 | //if ( wid > max ) | 124 | //if ( wid > max ) |
114 | // max = wid; | 125 | // max = wid; |
115 | } | 126 | } |
116 | 127 | ||
117 | mFieldList = list; | 128 | mFieldList = list; |
118 | 129 | ||
119 | announceDoSearch(); | 130 | announceDoSearch(); |
120 | announceFieldChanged(); | 131 | announceFieldChanged(); |
121 | mFieldCombo->setMaximumWidth( wid+60 ); | 132 | mFieldCombo->setMaximumWidth( wid+60 ); |
122 | } | 133 | } |
123 | 134 | ||
124 | KABC::Field::List IncSearchWidget::fields() const | 135 | KABC::Field::List IncSearchWidget::fields() const |
125 | { | 136 | { |
126 | return mFieldList; | 137 | return mFieldList; |
127 | } | 138 | } |
128 | 139 | ||
129 | KABC::Field *IncSearchWidget::currentField()const | 140 | KABC::Field *IncSearchWidget::currentField()const |
130 | { | 141 | { |
131 | if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) | 142 | if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) |
132 | return 0; // for error or 'use all fields' | 143 | return 0; // for error or 'use all fields' |
133 | else | 144 | else |
134 | return mFieldList[ mFieldCombo->currentItem() - 1 ]; | 145 | return mFieldList[ mFieldCombo->currentItem() - 1 ]; |
135 | } | 146 | } |
136 | 147 | ||
137 | void IncSearchWidget::setCurrentItem( int pos ) | 148 | void IncSearchWidget::setCurrentItem( int pos ) |
138 | { | 149 | { |
139 | mFieldCombo->setCurrentItem( pos ); | 150 | mFieldCombo->setCurrentItem( pos ); |
140 | announceFieldChanged(); | 151 | announceFieldChanged(); |
141 | } | 152 | } |
142 | 153 | ||
143 | int IncSearchWidget::currentItem() const | 154 | int IncSearchWidget::currentItem() const |
144 | { | 155 | { |
145 | 156 | ||
146 | return mFieldCombo->currentItem(); | 157 | return mFieldCombo->currentItem(); |
147 | } | 158 | } |
148 | #ifndef KAB_EMBEDDED | 159 | #ifndef KAB_EMBEDDED |
149 | #include "incsearchwidget.moc" | 160 | #include "incsearchwidget.moc" |
150 | #endif //KAB_EMBEDDED | 161 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/incsearchwidget.h b/kaddressbook/incsearchwidget.h index 09fb8ac..5c95438 100644 --- a/kaddressbook/incsearchwidget.h +++ b/kaddressbook/incsearchwidget.h | |||
@@ -1,73 +1,74 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef INCSEARCHWIDGET_H | 24 | #ifndef INCSEARCHWIDGET_H |
25 | #define INCSEARCHWIDGET_H | 25 | #define INCSEARCHWIDGET_H |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | 28 | ||
29 | #include <kabc/field.h> | 29 | #include <kabc/field.h> |
30 | 30 | ||
31 | class QComboBox; | 31 | class QComboBox; |
32 | class KLineEdit; | 32 | class KLineEdit; |
33 | 33 | ||
34 | class IncSearchWidget : public QWidget | 34 | class IncSearchWidget : public QWidget |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | 37 | ||
38 | public: | 38 | public: |
39 | IncSearchWidget( QWidget *parent, const char *name = 0 ); | 39 | IncSearchWidget( QWidget *parent, const char *name = 0 ); |
40 | ~IncSearchWidget(); | 40 | ~IncSearchWidget(); |
41 | 41 | ||
42 | void setFields( const KABC::Field::List &list ); | 42 | void setFields( const KABC::Field::List &list ); |
43 | KABC::Field::List fields() const; | 43 | KABC::Field::List fields() const; |
44 | 44 | ||
45 | KABC::Field *currentField() const; | 45 | KABC::Field *currentField() const; |
46 | 46 | ||
47 | void setCurrentItem( int pos ); | 47 | void setCurrentItem( int pos ); |
48 | int currentItem() const; | 48 | int currentItem() const; |
49 | 49 | ||
50 | signals: | 50 | signals: |
51 | /** | 51 | /** |
52 | This signal is emmited whenever the text in the input | 52 | This signal is emmited whenever the text in the input |
53 | widget is changed. You can get the sorting field by | 53 | widget is changed. You can get the sorting field by |
54 | @ref currentField. | 54 | @ref currentField. |
55 | */ | 55 | */ |
56 | void doSearch( const QString& text ); | 56 | void doSearch( const QString& text ); |
57 | 57 | ||
58 | /** | 58 | /** |
59 | This signal is emmited whenever the search field changes. | 59 | This signal is emmited whenever the search field changes. |
60 | */ | 60 | */ |
61 | void fieldChanged(); | 61 | void fieldChanged(); |
62 | 62 | ||
63 | private slots: | 63 | private slots: |
64 | void announceDoSearch(); | 64 | void announceDoSearch(); |
65 | void announceDoSearch2(); | ||
65 | void announceFieldChanged(); | 66 | void announceFieldChanged(); |
66 | 67 | ||
67 | private: | 68 | private: |
68 | QComboBox* mFieldCombo; | 69 | QComboBox* mFieldCombo; |
69 | KLineEdit* mSearchText; | 70 | KLineEdit* mSearchText; |
70 | KABC::Field::List mFieldList; | 71 | KABC::Field::List mFieldList; |
71 | }; | 72 | }; |
72 | 73 | ||
73 | #endif | 74 | #endif |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index bbf8e1b..f0a49f8 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2091 +1,2091 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | 35 | ||
36 | #ifndef KAB_EMBEDDED | 36 | #ifndef KAB_EMBEDDED |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qdir.h> | 38 | #include <qdir.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qapplicaton.h> | 40 | #include <qapplicaton.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qregexp.h> | 42 | #include <qregexp.h> |
43 | #include <qvbox.h> | 43 | #include <qvbox.h> |
44 | #include <kabc/addresseelist.h> | 44 | #include <kabc/addresseelist.h> |
45 | #include <kabc/errorhandler.h> | 45 | #include <kabc/errorhandler.h> |
46 | #include <kabc/resource.h> | 46 | #include <kabc/resource.h> |
47 | #include <kabc/vcardconverter.h> | 47 | #include <kabc/vcardconverter.h> |
48 | #include <kapplication.h> | 48 | #include <kapplication.h> |
49 | #include <kactionclasses.h> | 49 | #include <kactionclasses.h> |
50 | #include <kcmultidialog.h> | 50 | #include <kcmultidialog.h> |
51 | #include <kdebug.h> | 51 | #include <kdebug.h> |
52 | #include <kdeversion.h> | 52 | #include <kdeversion.h> |
53 | #include <kkeydialog.h> | 53 | #include <kkeydialog.h> |
54 | #include <kmessagebox.h> | 54 | #include <kmessagebox.h> |
55 | #include <kprinter.h> | 55 | #include <kprinter.h> |
56 | #include <kprotocolinfo.h> | 56 | #include <kprotocolinfo.h> |
57 | #include <kresources/selectdialog.h> | 57 | #include <kresources/selectdialog.h> |
58 | #include <kstandarddirs.h> | 58 | #include <kstandarddirs.h> |
59 | #include <ktempfile.h> | 59 | #include <ktempfile.h> |
60 | #include <kxmlguiclient.h> | 60 | #include <kxmlguiclient.h> |
61 | #include <kaboutdata.h> | 61 | #include <kaboutdata.h> |
62 | #include <libkdepim/categoryselectdialog.h> | 62 | #include <libkdepim/categoryselectdialog.h> |
63 | 63 | ||
64 | #include "addresseeutil.h" | 64 | #include "addresseeutil.h" |
65 | #include "addresseeeditordialog.h" | 65 | #include "addresseeeditordialog.h" |
66 | #include "extensionmanager.h" | 66 | #include "extensionmanager.h" |
67 | #include "kstdaction.h" | 67 | #include "kstdaction.h" |
68 | #include "kaddressbookservice.h" | 68 | #include "kaddressbookservice.h" |
69 | #include "ldapsearchdialog.h" | 69 | #include "ldapsearchdialog.h" |
70 | #include "printing/printingwizard.h" | 70 | #include "printing/printingwizard.h" |
71 | #else // KAB_EMBEDDED | 71 | #else // KAB_EMBEDDED |
72 | 72 | ||
73 | #include <kapplication.h> | 73 | #include <kapplication.h> |
74 | #include "KDGanttMinimizeSplitter.h" | 74 | #include "KDGanttMinimizeSplitter.h" |
75 | #include "kaddressbookmain.h" | 75 | #include "kaddressbookmain.h" |
76 | #include "kactioncollection.h" | 76 | #include "kactioncollection.h" |
77 | #include "addresseedialog.h" | 77 | #include "addresseedialog.h" |
78 | //US | 78 | //US |
79 | #include <libkdepim/addresseeview.h> | 79 | #include <libkdepim/addresseeview.h> |
80 | 80 | ||
81 | #include <qapp.h> | 81 | #include <qapp.h> |
82 | #include <qmenubar.h> | 82 | #include <qmenubar.h> |
83 | //#include <qtoolbar.h> | 83 | //#include <qtoolbar.h> |
84 | #include <qmessagebox.h> | 84 | #include <qmessagebox.h> |
85 | #include <kdebug.h> | 85 | #include <kdebug.h> |
86 | #include <kiconloader.h> // needed for SmallIcon | 86 | #include <kiconloader.h> // needed for SmallIcon |
87 | #include <kresources/kcmkresources.h> | 87 | #include <kresources/kcmkresources.h> |
88 | #include <ktoolbar.h> | 88 | #include <ktoolbar.h> |
89 | 89 | ||
90 | 90 | ||
91 | //#include <qlabel.h> | 91 | //#include <qlabel.h> |
92 | 92 | ||
93 | 93 | ||
94 | #ifndef DESKTOP_VERSION | 94 | #ifndef DESKTOP_VERSION |
95 | #include <qpe/ir.h> | 95 | #include <qpe/ir.h> |
96 | #include <qpe/qpemenubar.h> | 96 | #include <qpe/qpemenubar.h> |
97 | #include <qtopia/qcopenvelope_qws.h> | 97 | #include <qtopia/qcopenvelope_qws.h> |
98 | #else | 98 | #else |
99 | 99 | ||
100 | #include <qmenubar.h> | 100 | #include <qmenubar.h> |
101 | #endif | 101 | #endif |
102 | 102 | ||
103 | #endif // KAB_EMBEDDED | 103 | #endif // KAB_EMBEDDED |
104 | #include "kcmconfigs/kcmkabconfig.h" | 104 | #include "kcmconfigs/kcmkabconfig.h" |
105 | #include "kcmconfigs/kcmkdepimconfig.h" | 105 | #include "kcmconfigs/kcmkdepimconfig.h" |
106 | #include "kpimglobalprefs.h" | 106 | #include "kpimglobalprefs.h" |
107 | #include "externalapphandler.h" | 107 | #include "externalapphandler.h" |
108 | 108 | ||
109 | 109 | ||
110 | #include <kresources/selectdialog.h> | 110 | #include <kresources/selectdialog.h> |
111 | #include <kmessagebox.h> | 111 | #include <kmessagebox.h> |
112 | 112 | ||
113 | #include <picture.h> | 113 | #include <picture.h> |
114 | #include <resource.h> | 114 | #include <resource.h> |
115 | 115 | ||
116 | //US#include <qsplitter.h> | 116 | //US#include <qsplitter.h> |
117 | #include <qmap.h> | 117 | #include <qmap.h> |
118 | #include <qdir.h> | 118 | #include <qdir.h> |
119 | #include <qfile.h> | 119 | #include <qfile.h> |
120 | #include <qvbox.h> | 120 | #include <qvbox.h> |
121 | #include <qlayout.h> | 121 | #include <qlayout.h> |
122 | #include <qclipboard.h> | 122 | #include <qclipboard.h> |
123 | #include <qtextstream.h> | 123 | #include <qtextstream.h> |
124 | 124 | ||
125 | #include <libkdepim/categoryselectdialog.h> | 125 | #include <libkdepim/categoryselectdialog.h> |
126 | #include <kabc/vcardconverter.h> | 126 | #include <kabc/vcardconverter.h> |
127 | 127 | ||
128 | 128 | ||
129 | #include "addresseeutil.h" | 129 | #include "addresseeutil.h" |
130 | #include "undocmds.h" | 130 | #include "undocmds.h" |
131 | #include "addresseeeditordialog.h" | 131 | #include "addresseeeditordialog.h" |
132 | #include "viewmanager.h" | 132 | #include "viewmanager.h" |
133 | #include "details/detailsviewcontainer.h" | 133 | #include "details/detailsviewcontainer.h" |
134 | #include "kabprefs.h" | 134 | #include "kabprefs.h" |
135 | #include "xxportmanager.h" | 135 | #include "xxportmanager.h" |
136 | #include "incsearchwidget.h" | 136 | #include "incsearchwidget.h" |
137 | #include "jumpbuttonbar.h" | 137 | #include "jumpbuttonbar.h" |
138 | #include "extensionmanager.h" | 138 | #include "extensionmanager.h" |
139 | #include "addresseeconfig.h" | 139 | #include "addresseeconfig.h" |
140 | #include <kcmultidialog.h> | 140 | #include <kcmultidialog.h> |
141 | 141 | ||
142 | #ifdef _WIN32_ | 142 | #ifdef _WIN32_ |
143 | 143 | ||
144 | #include "kaimportoldialog.h" | 144 | #include "kaimportoldialog.h" |
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | bool pasteWithNewUid = true; | 147 | bool pasteWithNewUid = true; |
148 | 148 | ||
149 | #ifdef KAB_EMBEDDED | 149 | #ifdef KAB_EMBEDDED |
150 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 150 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
151 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 151 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
152 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 152 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
153 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 153 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
154 | #else //KAB_EMBEDDED | 154 | #else //KAB_EMBEDDED |
155 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 155 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
156 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 156 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
157 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 157 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
158 | mReadWrite( readWrite ), mModified( false ) | 158 | mReadWrite( readWrite ), mModified( false ) |
159 | #endif //KAB_EMBEDDED | 159 | #endif //KAB_EMBEDDED |
160 | { | 160 | { |
161 | 161 | ||
162 | mExtensionBarSplitter = 0; | 162 | mExtensionBarSplitter = 0; |
163 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 163 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
164 | 164 | ||
165 | mAddressBook = KABC::StdAddressBook::self(); | 165 | mAddressBook = KABC::StdAddressBook::self(); |
166 | KABC::StdAddressBook::setAutomaticSave( false ); | 166 | KABC::StdAddressBook::setAutomaticSave( false ); |
167 | 167 | ||
168 | #ifndef KAB_EMBEDDED | 168 | #ifndef KAB_EMBEDDED |
169 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 169 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
170 | #endif //KAB_EMBEDDED | 170 | #endif //KAB_EMBEDDED |
171 | 171 | ||
172 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 172 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
173 | SLOT( addressBookChanged() ) ); | 173 | SLOT( addressBookChanged() ) ); |
174 | 174 | ||
175 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 175 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
176 | "X-Department", "KADDRESSBOOK" ); | 176 | "X-Department", "KADDRESSBOOK" ); |
177 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 177 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
178 | "X-Profession", "KADDRESSBOOK" ); | 178 | "X-Profession", "KADDRESSBOOK" ); |
179 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 179 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
180 | "X-AssistantsName", "KADDRESSBOOK" ); | 180 | "X-AssistantsName", "KADDRESSBOOK" ); |
181 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 181 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
182 | "X-ManagersName", "KADDRESSBOOK" ); | 182 | "X-ManagersName", "KADDRESSBOOK" ); |
183 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 183 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
184 | "X-SpousesName", "KADDRESSBOOK" ); | 184 | "X-SpousesName", "KADDRESSBOOK" ); |
185 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 185 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
186 | "X-Office", "KADDRESSBOOK" ); | 186 | "X-Office", "KADDRESSBOOK" ); |
187 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 187 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
188 | "X-IMAddress", "KADDRESSBOOK" ); | 188 | "X-IMAddress", "KADDRESSBOOK" ); |
189 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 189 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
190 | "X-Anniversary", "KADDRESSBOOK" ); | 190 | "X-Anniversary", "KADDRESSBOOK" ); |
191 | 191 | ||
192 | //US added this field to become compatible with Opie/qtopia addressbook | 192 | //US added this field to become compatible with Opie/qtopia addressbook |
193 | // values can be "female" or "male" or "". An empty field represents undefined. | 193 | // values can be "female" or "male" or "". An empty field represents undefined. |
194 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 194 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
195 | "X-Gender", "KADDRESSBOOK" ); | 195 | "X-Gender", "KADDRESSBOOK" ); |
196 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 196 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
197 | "X-Children", "KADDRESSBOOK" ); | 197 | "X-Children", "KADDRESSBOOK" ); |
198 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 198 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
199 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 199 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
200 | 200 | ||
201 | initGUI(); | 201 | initGUI(); |
202 | 202 | ||
203 | mIncSearchWidget->setFocus(); | 203 | mIncSearchWidget->setFocus(); |
204 | 204 | ||
205 | 205 | ||
206 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 206 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
207 | SLOT( setContactSelected( const QString& ) ) ); | 207 | SLOT( setContactSelected( const QString& ) ) ); |
208 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 208 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
209 | SLOT( executeContact( const QString& ) ) ); | 209 | SLOT( executeContact( const QString& ) ) ); |
210 | 210 | ||
211 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 211 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
212 | SLOT( deleteContacts( ) ) ); | 212 | SLOT( deleteContacts( ) ) ); |
213 | connect( mViewManager, SIGNAL( modified() ), | 213 | connect( mViewManager, SIGNAL( modified() ), |
214 | SLOT( setModified() ) ); | 214 | SLOT( setModified() ) ); |
215 | 215 | ||
216 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 216 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
217 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 217 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
218 | 218 | ||
219 | connect( mXXPortManager, SIGNAL( modified() ), | 219 | connect( mXXPortManager, SIGNAL( modified() ), |
220 | SLOT( setModified() ) ); | 220 | SLOT( setModified() ) ); |
221 | 221 | ||
222 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 222 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
223 | SLOT( incrementalSearch( const QString& ) ) ); | 223 | SLOT( incrementalSearch( const QString& ) ) ); |
224 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 224 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
225 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 225 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
226 | 226 | ||
227 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 227 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
228 | SLOT( sendMail( const QString& ) ) ); | 228 | SLOT( sendMail( const QString& ) ) ); |
229 | 229 | ||
230 | 230 | ||
231 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 231 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
232 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 232 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
233 | 233 | ||
234 | 234 | ||
235 | #ifndef KAB_EMBEDDED | 235 | #ifndef KAB_EMBEDDED |
236 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 236 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
237 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 237 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
238 | 238 | ||
239 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 239 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
240 | SLOT( browse( const QString& ) ) ); | 240 | SLOT( browse( const QString& ) ) ); |
241 | 241 | ||
242 | 242 | ||
243 | mAddressBookService = new KAddressBookService( this ); | 243 | mAddressBookService = new KAddressBookService( this ); |
244 | 244 | ||
245 | #endif //KAB_EMBEDDED | 245 | #endif //KAB_EMBEDDED |
246 | mEditorDialog = 0; | 246 | mEditorDialog = 0; |
247 | createAddresseeEditorDialog( this ); | 247 | createAddresseeEditorDialog( this ); |
248 | setModified( false ); | 248 | setModified( false ); |
249 | } | 249 | } |
250 | 250 | ||
251 | KABCore::~KABCore() | 251 | KABCore::~KABCore() |
252 | { | 252 | { |
253 | // save(); | 253 | // save(); |
254 | //saveSettings(); | 254 | //saveSettings(); |
255 | //KABPrefs::instance()->writeConfig(); | 255 | //KABPrefs::instance()->writeConfig(); |
256 | delete AddresseeConfig::instance(); | 256 | delete AddresseeConfig::instance(); |
257 | mAddressBook = 0; | 257 | mAddressBook = 0; |
258 | KABC::StdAddressBook::close(); | 258 | KABC::StdAddressBook::close(); |
259 | } | 259 | } |
260 | 260 | ||
261 | void KABCore::restoreSettings() | 261 | void KABCore::restoreSettings() |
262 | { | 262 | { |
263 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 263 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
264 | 264 | ||
265 | bool state; | 265 | bool state; |
266 | 266 | ||
267 | if (mMultipleViewsAtOnce) | 267 | if (mMultipleViewsAtOnce) |
268 | state = KABPrefs::instance()->mDetailsPageVisible; | 268 | state = KABPrefs::instance()->mDetailsPageVisible; |
269 | else | 269 | else |
270 | state = false; | 270 | state = false; |
271 | 271 | ||
272 | mActionDetails->setChecked( state ); | 272 | mActionDetails->setChecked( state ); |
273 | setDetailsVisible( state ); | 273 | setDetailsVisible( state ); |
274 | 274 | ||
275 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 275 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
276 | 276 | ||
277 | mActionJumpBar->setChecked( state ); | 277 | mActionJumpBar->setChecked( state ); |
278 | setJumpButtonBarVisible( state ); | 278 | setJumpButtonBarVisible( state ); |
279 | /*US | 279 | /*US |
280 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 280 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
281 | if ( splitterSize.count() == 0 ) { | 281 | if ( splitterSize.count() == 0 ) { |
282 | splitterSize.append( width() / 2 ); | 282 | splitterSize.append( width() / 2 ); |
283 | splitterSize.append( width() / 2 ); | 283 | splitterSize.append( width() / 2 ); |
284 | } | 284 | } |
285 | mMiniSplitter->setSizes( splitterSize ); | 285 | mMiniSplitter->setSizes( splitterSize ); |
286 | if ( mExtensionBarSplitter ) { | 286 | if ( mExtensionBarSplitter ) { |
287 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 287 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
288 | if ( splitterSize.count() == 0 ) { | 288 | if ( splitterSize.count() == 0 ) { |
289 | splitterSize.append( width() / 2 ); | 289 | splitterSize.append( width() / 2 ); |
290 | splitterSize.append( width() / 2 ); | 290 | splitterSize.append( width() / 2 ); |
291 | } | 291 | } |
292 | mExtensionBarSplitter->setSizes( splitterSize ); | 292 | mExtensionBarSplitter->setSizes( splitterSize ); |
293 | 293 | ||
294 | } | 294 | } |
295 | */ | 295 | */ |
296 | mViewManager->restoreSettings(); | 296 | mViewManager->restoreSettings(); |
297 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 297 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
298 | mExtensionManager->restoreSettings(); | 298 | mExtensionManager->restoreSettings(); |
299 | #ifdef DESKTOP_VERSION | 299 | #ifdef DESKTOP_VERSION |
300 | int wid = width(); | 300 | int wid = width(); |
301 | if ( wid < 10 ) | 301 | if ( wid < 10 ) |
302 | wid = 400; | 302 | wid = 400; |
303 | #else | 303 | #else |
304 | int wid = QApplication::desktop()->width(); | 304 | int wid = QApplication::desktop()->width(); |
305 | if ( wid < 640 ) | 305 | if ( wid < 640 ) |
306 | wid = QApplication::desktop()->height(); | 306 | wid = QApplication::desktop()->height(); |
307 | #endif | 307 | #endif |
308 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 308 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
309 | if ( true /*splitterSize.count() == 0*/ ) { | 309 | if ( true /*splitterSize.count() == 0*/ ) { |
310 | splitterSize.append( wid / 2 ); | 310 | splitterSize.append( wid / 2 ); |
311 | splitterSize.append( wid / 2 ); | 311 | splitterSize.append( wid / 2 ); |
312 | } | 312 | } |
313 | mMiniSplitter->setSizes( splitterSize ); | 313 | mMiniSplitter->setSizes( splitterSize ); |
314 | if ( mExtensionBarSplitter ) { | 314 | if ( mExtensionBarSplitter ) { |
315 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 315 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
316 | if ( true /*splitterSize.count() == 0*/ ) { | 316 | if ( true /*splitterSize.count() == 0*/ ) { |
317 | splitterSize.append( wid / 2 ); | 317 | splitterSize.append( wid / 2 ); |
318 | splitterSize.append( wid / 2 ); | 318 | splitterSize.append( wid / 2 ); |
319 | } | 319 | } |
320 | mExtensionBarSplitter->setSizes( splitterSize ); | 320 | mExtensionBarSplitter->setSizes( splitterSize ); |
321 | 321 | ||
322 | } | 322 | } |
323 | 323 | ||
324 | 324 | ||
325 | } | 325 | } |
326 | 326 | ||
327 | void KABCore::saveSettings() | 327 | void KABCore::saveSettings() |
328 | { | 328 | { |
329 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 329 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
330 | if ( mExtensionBarSplitter ) | 330 | if ( mExtensionBarSplitter ) |
331 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 331 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
332 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 332 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
333 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 333 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
334 | #ifndef KAB_EMBEDDED | 334 | #ifndef KAB_EMBEDDED |
335 | 335 | ||
336 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 336 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
337 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 337 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
338 | #endif //KAB_EMBEDDED | 338 | #endif //KAB_EMBEDDED |
339 | mExtensionManager->saveSettings(); | 339 | mExtensionManager->saveSettings(); |
340 | mViewManager->saveSettings(); | 340 | mViewManager->saveSettings(); |
341 | 341 | ||
342 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 342 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
343 | } | 343 | } |
344 | 344 | ||
345 | KABC::AddressBook *KABCore::addressBook() const | 345 | KABC::AddressBook *KABCore::addressBook() const |
346 | { | 346 | { |
347 | return mAddressBook; | 347 | return mAddressBook; |
348 | } | 348 | } |
349 | 349 | ||
350 | KConfig *KABCore::config() | 350 | KConfig *KABCore::config() |
351 | { | 351 | { |
352 | #ifndef KAB_EMBEDDED | 352 | #ifndef KAB_EMBEDDED |
353 | return KABPrefs::instance()->config(); | 353 | return KABPrefs::instance()->config(); |
354 | #else //KAB_EMBEDDED | 354 | #else //KAB_EMBEDDED |
355 | return KABPrefs::instance()->getConfig(); | 355 | return KABPrefs::instance()->getConfig(); |
356 | #endif //KAB_EMBEDDED | 356 | #endif //KAB_EMBEDDED |
357 | } | 357 | } |
358 | 358 | ||
359 | KActionCollection *KABCore::actionCollection() const | 359 | KActionCollection *KABCore::actionCollection() const |
360 | { | 360 | { |
361 | return mGUIClient->actionCollection(); | 361 | return mGUIClient->actionCollection(); |
362 | } | 362 | } |
363 | 363 | ||
364 | KABC::Field *KABCore::currentSearchField() const | 364 | KABC::Field *KABCore::currentSearchField() const |
365 | { | 365 | { |
366 | if (mIncSearchWidget) | 366 | if (mIncSearchWidget) |
367 | return mIncSearchWidget->currentField(); | 367 | return mIncSearchWidget->currentField(); |
368 | else | 368 | else |
369 | return 0; | 369 | return 0; |
370 | } | 370 | } |
371 | 371 | ||
372 | QStringList KABCore::selectedUIDs() const | 372 | QStringList KABCore::selectedUIDs() const |
373 | { | 373 | { |
374 | return mViewManager->selectedUids(); | 374 | return mViewManager->selectedUids(); |
375 | } | 375 | } |
376 | 376 | ||
377 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 377 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
378 | { | 378 | { |
379 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 379 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
380 | 380 | ||
381 | QPtrList<KRES::Resource> kresResources; | 381 | QPtrList<KRES::Resource> kresResources; |
382 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 382 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
383 | KABC::Resource *resource; | 383 | KABC::Resource *resource; |
384 | while ( ( resource = resIt.current() ) != 0 ) { | 384 | while ( ( resource = resIt.current() ) != 0 ) { |
385 | ++resIt; | 385 | ++resIt; |
386 | if ( !resource->readOnly() ) { | 386 | if ( !resource->readOnly() ) { |
387 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 387 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
388 | if ( res ) | 388 | if ( res ) |
389 | kresResources.append( res ); | 389 | kresResources.append( res ); |
390 | } | 390 | } |
391 | } | 391 | } |
392 | 392 | ||
393 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 393 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
394 | return static_cast<KABC::Resource*>( res ); | 394 | return static_cast<KABC::Resource*>( res ); |
395 | } | 395 | } |
396 | 396 | ||
397 | #ifndef KAB_EMBEDDED | 397 | #ifndef KAB_EMBEDDED |
398 | KAboutData *KABCore::createAboutData() | 398 | KAboutData *KABCore::createAboutData() |
399 | #else //KAB_EMBEDDED | 399 | #else //KAB_EMBEDDED |
400 | void KABCore::createAboutData() | 400 | void KABCore::createAboutData() |
401 | #endif //KAB_EMBEDDED | 401 | #endif //KAB_EMBEDDED |
402 | { | 402 | { |
403 | #ifndef KAB_EMBEDDED | 403 | #ifndef KAB_EMBEDDED |
404 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 404 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
405 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 405 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
406 | KAboutData::License_GPL_V2, | 406 | KAboutData::License_GPL_V2, |
407 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 407 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
408 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 408 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
409 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 409 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
410 | about->addAuthor( "Cornelius Schumacher", | 410 | about->addAuthor( "Cornelius Schumacher", |
411 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 411 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
412 | "schumacher@kde.org" ); | 412 | "schumacher@kde.org" ); |
413 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 413 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
414 | "mpilone@slac.com" ); | 414 | "mpilone@slac.com" ); |
415 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 415 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
416 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 416 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
417 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 417 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
418 | "michel@klaralvdalens-datakonsult.se" ); | 418 | "michel@klaralvdalens-datakonsult.se" ); |
419 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 419 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
420 | "hansen@kde.org" ); | 420 | "hansen@kde.org" ); |
421 | 421 | ||
422 | return about; | 422 | return about; |
423 | #endif //KAB_EMBEDDED | 423 | #endif //KAB_EMBEDDED |
424 | 424 | ||
425 | QString version; | 425 | QString version; |
426 | #include <../version> | 426 | #include <../version> |
427 | QMessageBox::about( this, "About KAddressbook/Pi", | 427 | QMessageBox::about( this, "About KAddressbook/Pi", |
428 | "KAddressbook/Platform-independent\n" | 428 | "KAddressbook/Platform-independent\n" |
429 | "(KA/Pi) " +version + " - " + | 429 | "(KA/Pi) " +version + " - " + |
430 | #ifdef DESKTOP_VERSION | 430 | #ifdef DESKTOP_VERSION |
431 | "Desktop Edition\n" | 431 | "Desktop Edition\n" |
432 | #else | 432 | #else |
433 | "PDA-Edition\n" | 433 | "PDA-Edition\n" |
434 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 434 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
435 | #endif | 435 | #endif |
436 | 436 | ||
437 | "(c) 2004 Ulf Schenk\n" | 437 | "(c) 2004 Ulf Schenk\n" |
438 | "(c) 2004 Lutz Rogowski\n" | 438 | "(c) 2004 Lutz Rogowski\n" |
439 | "(c) 1997-2003, The KDE PIM Team\n" | 439 | "(c) 1997-2003, The KDE PIM Team\n" |
440 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 440 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
441 | "Don Sanders Original author\n" | 441 | "Don Sanders Original author\n" |
442 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 442 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
443 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 443 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
444 | "Greg Stern DCOP interface\n" | 444 | "Greg Stern DCOP interface\n" |
445 | "Mark Westcot Contact pinning\n" | 445 | "Mark Westcot Contact pinning\n" |
446 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 446 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
447 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 447 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
448 | #ifdef _WIN32_ | 448 | #ifdef _WIN32_ |
449 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 449 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
450 | #endif | 450 | #endif |
451 | ); | 451 | ); |
452 | } | 452 | } |
453 | 453 | ||
454 | void KABCore::setContactSelected( const QString &uid ) | 454 | void KABCore::setContactSelected( const QString &uid ) |
455 | { | 455 | { |
456 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 456 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
457 | if ( !mDetails->isHidden() ) | 457 | if ( !mDetails->isHidden() ) |
458 | mDetails->setAddressee( addr ); | 458 | mDetails->setAddressee( addr ); |
459 | 459 | ||
460 | if ( !addr.isEmpty() ) { | 460 | if ( !addr.isEmpty() ) { |
461 | emit contactSelected( addr.formattedName() ); | 461 | emit contactSelected( addr.formattedName() ); |
462 | KABC::Picture pic = addr.photo(); | 462 | KABC::Picture pic = addr.photo(); |
463 | if ( pic.isIntern() ) { | 463 | if ( pic.isIntern() ) { |
464 | //US emit contactSelected( pic.data() ); | 464 | //US emit contactSelected( pic.data() ); |
465 | //US instead use: | 465 | //US instead use: |
466 | QPixmap px; | 466 | QPixmap px; |
467 | if (pic.data().isNull() != true) | 467 | if (pic.data().isNull() != true) |
468 | { | 468 | { |
469 | px.convertFromImage(pic.data()); | 469 | px.convertFromImage(pic.data()); |
470 | } | 470 | } |
471 | 471 | ||
472 | emit contactSelected( px ); | 472 | emit contactSelected( px ); |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | 476 | ||
477 | mExtensionManager->setSelectionChanged(); | 477 | mExtensionManager->setSelectionChanged(); |
478 | 478 | ||
479 | // update the actions | 479 | // update the actions |
480 | bool selected = !uid.isEmpty(); | 480 | bool selected = !uid.isEmpty(); |
481 | 481 | ||
482 | if ( mReadWrite ) { | 482 | if ( mReadWrite ) { |
483 | mActionCut->setEnabled( selected ); | 483 | mActionCut->setEnabled( selected ); |
484 | mActionPaste->setEnabled( selected ); | 484 | mActionPaste->setEnabled( selected ); |
485 | } | 485 | } |
486 | 486 | ||
487 | mActionCopy->setEnabled( selected ); | 487 | mActionCopy->setEnabled( selected ); |
488 | mActionDelete->setEnabled( selected ); | 488 | mActionDelete->setEnabled( selected ); |
489 | mActionEditAddressee->setEnabled( selected ); | 489 | mActionEditAddressee->setEnabled( selected ); |
490 | mActionMail->setEnabled( selected ); | 490 | mActionMail->setEnabled( selected ); |
491 | mActionMailVCard->setEnabled( selected ); | 491 | mActionMailVCard->setEnabled( selected ); |
492 | //if (mActionBeam) | 492 | //if (mActionBeam) |
493 | //mActionBeam->setEnabled( selected ); | 493 | //mActionBeam->setEnabled( selected ); |
494 | 494 | ||
495 | if (mActionBeamVCard) | 495 | if (mActionBeamVCard) |
496 | mActionBeamVCard->setEnabled( selected ); | 496 | mActionBeamVCard->setEnabled( selected ); |
497 | 497 | ||
498 | mActionWhoAmI->setEnabled( selected ); | 498 | mActionWhoAmI->setEnabled( selected ); |
499 | mActionCategories->setEnabled( selected ); | 499 | mActionCategories->setEnabled( selected ); |
500 | } | 500 | } |
501 | 501 | ||
502 | void KABCore::sendMail() | 502 | void KABCore::sendMail() |
503 | { | 503 | { |
504 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 504 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
505 | } | 505 | } |
506 | 506 | ||
507 | void KABCore::sendMail( const QString& emaillist ) | 507 | void KABCore::sendMail( const QString& emaillist ) |
508 | { | 508 | { |
509 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 509 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
510 | if (emaillist.contains(",") > 0) | 510 | if (emaillist.contains(",") > 0) |
511 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 511 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
512 | else | 512 | else |
513 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 513 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
514 | } | 514 | } |
515 | 515 | ||
516 | 516 | ||
517 | 517 | ||
518 | void KABCore::mailVCard() | 518 | void KABCore::mailVCard() |
519 | { | 519 | { |
520 | QStringList uids = mViewManager->selectedUids(); | 520 | QStringList uids = mViewManager->selectedUids(); |
521 | if ( !uids.isEmpty() ) | 521 | if ( !uids.isEmpty() ) |
522 | mailVCard( uids ); | 522 | mailVCard( uids ); |
523 | } | 523 | } |
524 | 524 | ||
525 | void KABCore::mailVCard( const QStringList& uids ) | 525 | void KABCore::mailVCard( const QStringList& uids ) |
526 | { | 526 | { |
527 | QStringList urls; | 527 | QStringList urls; |
528 | 528 | ||
529 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 529 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
530 | 530 | ||
531 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 531 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
532 | 532 | ||
533 | 533 | ||
534 | 534 | ||
535 | QDir().mkdir( dirName, true ); | 535 | QDir().mkdir( dirName, true ); |
536 | 536 | ||
537 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 537 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
538 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 538 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
539 | 539 | ||
540 | if ( a.isEmpty() ) | 540 | if ( a.isEmpty() ) |
541 | continue; | 541 | continue; |
542 | 542 | ||
543 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 543 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
544 | 544 | ||
545 | QString fileName = dirName + "/" + name; | 545 | QString fileName = dirName + "/" + name; |
546 | 546 | ||
547 | QFile outFile(fileName); | 547 | QFile outFile(fileName); |
548 | 548 | ||
549 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 549 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
550 | KABC::VCardConverter converter; | 550 | KABC::VCardConverter converter; |
551 | QString vcard; | 551 | QString vcard; |
552 | 552 | ||
553 | converter.addresseeToVCard( a, vcard ); | 553 | converter.addresseeToVCard( a, vcard ); |
554 | 554 | ||
555 | QTextStream t( &outFile ); // use a text stream | 555 | QTextStream t( &outFile ); // use a text stream |
556 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 556 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
557 | t << vcard; | 557 | t << vcard; |
558 | 558 | ||
559 | outFile.close(); | 559 | outFile.close(); |
560 | 560 | ||
561 | urls.append( fileName ); | 561 | urls.append( fileName ); |
562 | } | 562 | } |
563 | } | 563 | } |
564 | 564 | ||
565 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 565 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
566 | 566 | ||
567 | 567 | ||
568 | /*US | 568 | /*US |
569 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 569 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
570 | QString::null, // subject | 570 | QString::null, // subject |
571 | QString::null, // body | 571 | QString::null, // body |
572 | QString::null, | 572 | QString::null, |
573 | urls ); // attachments | 573 | urls ); // attachments |
574 | */ | 574 | */ |
575 | 575 | ||
576 | } | 576 | } |
577 | 577 | ||
578 | /** | 578 | /** |
579 | Beams the "WhoAmI contact. | 579 | Beams the "WhoAmI contact. |
580 | */ | 580 | */ |
581 | void KABCore::beamMySelf() | 581 | void KABCore::beamMySelf() |
582 | { | 582 | { |
583 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 583 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
584 | if (!a.isEmpty()) | 584 | if (!a.isEmpty()) |
585 | { | 585 | { |
586 | QStringList uids; | 586 | QStringList uids; |
587 | uids << a.uid(); | 587 | uids << a.uid(); |
588 | 588 | ||
589 | beamVCard(uids); | 589 | beamVCard(uids); |
590 | } else { | 590 | } else { |
591 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 591 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
592 | 592 | ||
593 | 593 | ||
594 | } | 594 | } |
595 | } | 595 | } |
596 | 596 | ||
597 | void KABCore::beamVCard() | 597 | void KABCore::beamVCard() |
598 | { | 598 | { |
599 | QStringList uids = mViewManager->selectedUids(); | 599 | QStringList uids = mViewManager->selectedUids(); |
600 | if ( !uids.isEmpty() ) | 600 | if ( !uids.isEmpty() ) |
601 | beamVCard( uids ); | 601 | beamVCard( uids ); |
602 | } | 602 | } |
603 | 603 | ||
604 | 604 | ||
605 | void KABCore::beamVCard(const QStringList& uids) | 605 | void KABCore::beamVCard(const QStringList& uids) |
606 | { | 606 | { |
607 | /*US | 607 | /*US |
608 | QString beamFilename; | 608 | QString beamFilename; |
609 | Opie::OPimContact c; | 609 | Opie::OPimContact c; |
610 | if ( actionPersonal->isOn() ) { | 610 | if ( actionPersonal->isOn() ) { |
611 | beamFilename = addressbookPersonalVCardName(); | 611 | beamFilename = addressbookPersonalVCardName(); |
612 | if ( !QFile::exists( beamFilename ) ) | 612 | if ( !QFile::exists( beamFilename ) ) |
613 | return; // can't beam a non-existent file | 613 | return; // can't beam a non-existent file |
614 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 614 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
615 | beamFilename ); | 615 | beamFilename ); |
616 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 616 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
617 | Opie::OPimContactAccess::List allList = access->allRecords(); | 617 | Opie::OPimContactAccess::List allList = access->allRecords(); |
618 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 618 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
619 | c = *it; | 619 | c = *it; |
620 | 620 | ||
621 | delete access; | 621 | delete access; |
622 | } else { | 622 | } else { |
623 | unlink( beamfile ); // delete if exists | 623 | unlink( beamfile ); // delete if exists |
624 | mkdir("/tmp/obex/", 0755); | 624 | mkdir("/tmp/obex/", 0755); |
625 | c = m_abView -> currentEntry(); | 625 | c = m_abView -> currentEntry(); |
626 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 626 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
627 | beamfile ); | 627 | beamfile ); |
628 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 628 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
629 | access->add( c ); | 629 | access->add( c ); |
630 | access->save(); | 630 | access->save(); |
631 | delete access; | 631 | delete access; |
632 | 632 | ||
633 | beamFilename = beamfile; | 633 | beamFilename = beamfile; |
634 | } | 634 | } |
635 | 635 | ||
636 | owarn << "Beaming: " << beamFilename << oendl; | 636 | owarn << "Beaming: " << beamFilename << oendl; |
637 | */ | 637 | */ |
638 | 638 | ||
639 | #if 0 | 639 | #if 0 |
640 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 640 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
641 | 641 | ||
642 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 642 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
643 | 643 | ||
644 | QString name = "contact.vcf"; | 644 | QString name = "contact.vcf"; |
645 | 645 | ||
646 | QString fileName = dirName + "/" + name; | 646 | QString fileName = dirName + "/" + name; |
647 | #endif | 647 | #endif |
648 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 648 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
649 | // | 649 | // |
650 | QString fileName = "/tmp/kapibeamfile.vcf"; | 650 | QString fileName = "/tmp/kapibeamfile.vcf"; |
651 | 651 | ||
652 | 652 | ||
653 | //QDir().mkdir( dirName, true ); | 653 | //QDir().mkdir( dirName, true ); |
654 | 654 | ||
655 | 655 | ||
656 | KABC::VCardConverter converter; | 656 | KABC::VCardConverter converter; |
657 | QString description; | 657 | QString description; |
658 | QString datastream; | 658 | QString datastream; |
659 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 659 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
660 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 660 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
661 | 661 | ||
662 | if ( a.isEmpty() ) | 662 | if ( a.isEmpty() ) |
663 | continue; | 663 | continue; |
664 | 664 | ||
665 | if (description.isEmpty()) | 665 | if (description.isEmpty()) |
666 | description = a.formattedName(); | 666 | description = a.formattedName(); |
667 | 667 | ||
668 | QString vcard; | 668 | QString vcard; |
669 | converter.addresseeToVCard( a, vcard ); | 669 | converter.addresseeToVCard( a, vcard ); |
670 | int start = 0; | 670 | int start = 0; |
671 | int next; | 671 | int next; |
672 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 672 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
673 | int semi = vcard.find(";", next); | 673 | int semi = vcard.find(";", next); |
674 | int dopp = vcard.find(":", next); | 674 | int dopp = vcard.find(":", next); |
675 | int sep; | 675 | int sep; |
676 | if ( semi < dopp && semi >= 0 ) | 676 | if ( semi < dopp && semi >= 0 ) |
677 | sep = semi ; | 677 | sep = semi ; |
678 | else | 678 | else |
679 | sep = dopp; | 679 | sep = dopp; |
680 | datastream +=vcard.mid( start, next - start); | 680 | datastream +=vcard.mid( start, next - start); |
681 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 681 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
682 | start = sep; | 682 | start = sep; |
683 | } | 683 | } |
684 | datastream += vcard.mid( start,vcard.length() ); | 684 | datastream += vcard.mid( start,vcard.length() ); |
685 | } | 685 | } |
686 | #ifndef DESKTOP_VERSION | 686 | #ifndef DESKTOP_VERSION |
687 | QFile outFile(fileName); | 687 | QFile outFile(fileName); |
688 | if ( outFile.open(IO_WriteOnly) ) { | 688 | if ( outFile.open(IO_WriteOnly) ) { |
689 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 689 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
690 | QTextStream t( &outFile ); // use a text stream | 690 | QTextStream t( &outFile ); // use a text stream |
691 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 691 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
692 | t <<datastream; | 692 | t <<datastream; |
693 | outFile.close(); | 693 | outFile.close(); |
694 | Ir *ir = new Ir( this ); | 694 | Ir *ir = new Ir( this ); |
695 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 695 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
696 | ir->send( fileName, description, "text/x-vCard" ); | 696 | ir->send( fileName, description, "text/x-vCard" ); |
697 | } else { | 697 | } else { |
698 | qDebug("Error open temp beam file "); | 698 | qDebug("Error open temp beam file "); |
699 | return; | 699 | return; |
700 | } | 700 | } |
701 | #endif | 701 | #endif |
702 | 702 | ||
703 | } | 703 | } |
704 | 704 | ||
705 | void KABCore::beamDone( Ir *ir ) | 705 | void KABCore::beamDone( Ir *ir ) |
706 | { | 706 | { |
707 | #ifndef DESKTOP_VERSION | 707 | #ifndef DESKTOP_VERSION |
708 | delete ir; | 708 | delete ir; |
709 | #endif | 709 | #endif |
710 | } | 710 | } |
711 | 711 | ||
712 | 712 | ||
713 | void KABCore::browse( const QString& url ) | 713 | void KABCore::browse( const QString& url ) |
714 | { | 714 | { |
715 | #ifndef KAB_EMBEDDED | 715 | #ifndef KAB_EMBEDDED |
716 | kapp->invokeBrowser( url ); | 716 | kapp->invokeBrowser( url ); |
717 | #else //KAB_EMBEDDED | 717 | #else //KAB_EMBEDDED |
718 | qDebug("KABCore::browse must be fixed"); | 718 | qDebug("KABCore::browse must be fixed"); |
719 | #endif //KAB_EMBEDDED | 719 | #endif //KAB_EMBEDDED |
720 | } | 720 | } |
721 | 721 | ||
722 | void KABCore::selectAllContacts() | 722 | void KABCore::selectAllContacts() |
723 | { | 723 | { |
724 | mViewManager->setSelected( QString::null, true ); | 724 | mViewManager->setSelected( QString::null, true ); |
725 | } | 725 | } |
726 | 726 | ||
727 | void KABCore::deleteContacts() | 727 | void KABCore::deleteContacts() |
728 | { | 728 | { |
729 | QStringList uidList = mViewManager->selectedUids(); | 729 | QStringList uidList = mViewManager->selectedUids(); |
730 | deleteContacts( uidList ); | 730 | deleteContacts( uidList ); |
731 | } | 731 | } |
732 | 732 | ||
733 | void KABCore::deleteContacts( const QStringList &uids ) | 733 | void KABCore::deleteContacts( const QStringList &uids ) |
734 | { | 734 | { |
735 | if ( uids.count() > 0 ) { | 735 | if ( uids.count() > 0 ) { |
736 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 736 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
737 | UndoStack::instance()->push( command ); | 737 | UndoStack::instance()->push( command ); |
738 | RedoStack::instance()->clear(); | 738 | RedoStack::instance()->clear(); |
739 | 739 | ||
740 | // now if we deleted anything, refresh | 740 | // now if we deleted anything, refresh |
741 | setContactSelected( QString::null ); | 741 | setContactSelected( QString::null ); |
742 | setModified( true ); | 742 | setModified( true ); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | 745 | ||
746 | void KABCore::copyContacts() | 746 | void KABCore::copyContacts() |
747 | { | 747 | { |
748 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 748 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
749 | 749 | ||
750 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 750 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
751 | 751 | ||
752 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 752 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
753 | 753 | ||
754 | QClipboard *cb = QApplication::clipboard(); | 754 | QClipboard *cb = QApplication::clipboard(); |
755 | cb->setText( clipText ); | 755 | cb->setText( clipText ); |
756 | } | 756 | } |
757 | 757 | ||
758 | void KABCore::cutContacts() | 758 | void KABCore::cutContacts() |
759 | { | 759 | { |
760 | QStringList uidList = mViewManager->selectedUids(); | 760 | QStringList uidList = mViewManager->selectedUids(); |
761 | 761 | ||
762 | //US if ( uidList.size() > 0 ) { | 762 | //US if ( uidList.size() > 0 ) { |
763 | if ( uidList.count() > 0 ) { | 763 | if ( uidList.count() > 0 ) { |
764 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 764 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
765 | UndoStack::instance()->push( command ); | 765 | UndoStack::instance()->push( command ); |
766 | RedoStack::instance()->clear(); | 766 | RedoStack::instance()->clear(); |
767 | 767 | ||
768 | setModified( true ); | 768 | setModified( true ); |
769 | } | 769 | } |
770 | } | 770 | } |
771 | 771 | ||
772 | void KABCore::pasteContacts() | 772 | void KABCore::pasteContacts() |
773 | { | 773 | { |
774 | QClipboard *cb = QApplication::clipboard(); | 774 | QClipboard *cb = QApplication::clipboard(); |
775 | 775 | ||
776 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 776 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
777 | 777 | ||
778 | pasteContacts( list ); | 778 | pasteContacts( list ); |
779 | } | 779 | } |
780 | 780 | ||
781 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 781 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
782 | { | 782 | { |
783 | KABC::Resource *resource = requestResource( this ); | 783 | KABC::Resource *resource = requestResource( this ); |
784 | KABC::Addressee::List::Iterator it; | 784 | KABC::Addressee::List::Iterator it; |
785 | for ( it = list.begin(); it != list.end(); ++it ) | 785 | for ( it = list.begin(); it != list.end(); ++it ) |
786 | (*it).setResource( resource ); | 786 | (*it).setResource( resource ); |
787 | 787 | ||
788 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 788 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
789 | UndoStack::instance()->push( command ); | 789 | UndoStack::instance()->push( command ); |
790 | RedoStack::instance()->clear(); | 790 | RedoStack::instance()->clear(); |
791 | 791 | ||
792 | setModified( true ); | 792 | setModified( true ); |
793 | } | 793 | } |
794 | 794 | ||
795 | void KABCore::setWhoAmI() | 795 | void KABCore::setWhoAmI() |
796 | { | 796 | { |
797 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 797 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
798 | 798 | ||
799 | if ( addrList.count() > 1 ) { | 799 | if ( addrList.count() > 1 ) { |
800 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 800 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
801 | return; | 801 | return; |
802 | } | 802 | } |
803 | 803 | ||
804 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 804 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
805 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 805 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
806 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 806 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
807 | } | 807 | } |
808 | 808 | ||
809 | void KABCore::setCategories() | 809 | void KABCore::setCategories() |
810 | { | 810 | { |
811 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 811 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
812 | if ( !dlg.exec() ) | 812 | if ( !dlg.exec() ) |
813 | return; | 813 | return; |
814 | 814 | ||
815 | bool merge = false; | 815 | bool merge = false; |
816 | QString msg = i18n( "Merge with existing categories?" ); | 816 | QString msg = i18n( "Merge with existing categories?" ); |
817 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 817 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
818 | merge = true; | 818 | merge = true; |
819 | 819 | ||
820 | QStringList categories = dlg.selectedCategories(); | 820 | QStringList categories = dlg.selectedCategories(); |
821 | 821 | ||
822 | QStringList uids = mViewManager->selectedUids(); | 822 | QStringList uids = mViewManager->selectedUids(); |
823 | QStringList::Iterator it; | 823 | QStringList::Iterator it; |
824 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 824 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
825 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 825 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
826 | if ( !addr.isEmpty() ) { | 826 | if ( !addr.isEmpty() ) { |
827 | if ( !merge ) | 827 | if ( !merge ) |
828 | addr.setCategories( categories ); | 828 | addr.setCategories( categories ); |
829 | else { | 829 | else { |
830 | QStringList addrCategories = addr.categories(); | 830 | QStringList addrCategories = addr.categories(); |
831 | QStringList::Iterator catIt; | 831 | QStringList::Iterator catIt; |
832 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 832 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
833 | if ( !addrCategories.contains( *catIt ) ) | 833 | if ( !addrCategories.contains( *catIt ) ) |
834 | addrCategories.append( *catIt ); | 834 | addrCategories.append( *catIt ); |
835 | } | 835 | } |
836 | addr.setCategories( addrCategories ); | 836 | addr.setCategories( addrCategories ); |
837 | } | 837 | } |
838 | 838 | ||
839 | mAddressBook->insertAddressee( addr ); | 839 | mAddressBook->insertAddressee( addr ); |
840 | } | 840 | } |
841 | } | 841 | } |
842 | 842 | ||
843 | if ( uids.count() > 0 ) | 843 | if ( uids.count() > 0 ) |
844 | setModified( true ); | 844 | setModified( true ); |
845 | } | 845 | } |
846 | 846 | ||
847 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 847 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
848 | { | 848 | { |
849 | mIncSearchWidget->setFields( fields ); | 849 | mIncSearchWidget->setFields( fields ); |
850 | } | 850 | } |
851 | 851 | ||
852 | void KABCore::incrementalSearch( const QString& text ) | 852 | void KABCore::incrementalSearch( const QString& text ) |
853 | { | 853 | { |
854 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 854 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
855 | } | 855 | } |
856 | 856 | ||
857 | void KABCore::setModified() | 857 | void KABCore::setModified() |
858 | { | 858 | { |
859 | setModified( true ); | 859 | setModified( true ); |
860 | } | 860 | } |
861 | 861 | ||
862 | void KABCore::setModifiedWOrefresh() | 862 | void KABCore::setModifiedWOrefresh() |
863 | { | 863 | { |
864 | // qDebug("KABCore::setModifiedWOrefresh() "); | 864 | // qDebug("KABCore::setModifiedWOrefresh() "); |
865 | mModified = true; | 865 | mModified = true; |
866 | mActionSave->setEnabled( mModified ); | 866 | mActionSave->setEnabled( mModified ); |
867 | #ifdef DESKTOP_VERSION | 867 | #ifdef DESKTOP_VERSION |
868 | mDetails->refreshView(); | 868 | mDetails->refreshView(); |
869 | #endif | 869 | #endif |
870 | 870 | ||
871 | } | 871 | } |
872 | void KABCore::setModified( bool modified ) | 872 | void KABCore::setModified( bool modified ) |
873 | { | 873 | { |
874 | mModified = modified; | 874 | mModified = modified; |
875 | mActionSave->setEnabled( mModified ); | 875 | mActionSave->setEnabled( mModified ); |
876 | 876 | ||
877 | if ( modified ) | 877 | if ( modified ) |
878 | mJumpButtonBar->recreateButtons(); | 878 | mJumpButtonBar->recreateButtons(); |
879 | 879 | ||
880 | mViewManager->refreshView(); | 880 | mViewManager->refreshView(); |
881 | mDetails->refreshView(); | 881 | mDetails->refreshView(); |
882 | 882 | ||
883 | } | 883 | } |
884 | 884 | ||
885 | bool KABCore::modified() const | 885 | bool KABCore::modified() const |
886 | { | 886 | { |
887 | return mModified; | 887 | return mModified; |
888 | } | 888 | } |
889 | 889 | ||
890 | void KABCore::contactModified( const KABC::Addressee &addr ) | 890 | void KABCore::contactModified( const KABC::Addressee &addr ) |
891 | { | 891 | { |
892 | 892 | ||
893 | Command *command = 0; | 893 | Command *command = 0; |
894 | QString uid; | 894 | QString uid; |
895 | 895 | ||
896 | // check if it exists already | 896 | // check if it exists already |
897 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 897 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
898 | if ( origAddr.isEmpty() ) | 898 | if ( origAddr.isEmpty() ) |
899 | command = new PwNewCommand( mAddressBook, addr ); | 899 | command = new PwNewCommand( mAddressBook, addr ); |
900 | else { | 900 | else { |
901 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 901 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
902 | uid = addr.uid(); | 902 | uid = addr.uid(); |
903 | } | 903 | } |
904 | 904 | ||
905 | UndoStack::instance()->push( command ); | 905 | UndoStack::instance()->push( command ); |
906 | RedoStack::instance()->clear(); | 906 | RedoStack::instance()->clear(); |
907 | 907 | ||
908 | setModified( true ); | 908 | setModified( true ); |
909 | } | 909 | } |
910 | 910 | ||
911 | void KABCore::newContact() | 911 | void KABCore::newContact() |
912 | { | 912 | { |
913 | 913 | ||
914 | 914 | ||
915 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 915 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
916 | 916 | ||
917 | QPtrList<KRES::Resource> kresResources; | 917 | QPtrList<KRES::Resource> kresResources; |
918 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 918 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
919 | KABC::Resource *resource; | 919 | KABC::Resource *resource; |
920 | while ( ( resource = it.current() ) != 0 ) { | 920 | while ( ( resource = it.current() ) != 0 ) { |
921 | ++it; | 921 | ++it; |
922 | if ( !resource->readOnly() ) { | 922 | if ( !resource->readOnly() ) { |
923 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 923 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
924 | if ( res ) | 924 | if ( res ) |
925 | kresResources.append( res ); | 925 | kresResources.append( res ); |
926 | } | 926 | } |
927 | } | 927 | } |
928 | 928 | ||
929 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 929 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
930 | resource = static_cast<KABC::Resource*>( res ); | 930 | resource = static_cast<KABC::Resource*>( res ); |
931 | 931 | ||
932 | if ( resource ) { | 932 | if ( resource ) { |
933 | KABC::Addressee addr; | 933 | KABC::Addressee addr; |
934 | addr.setResource( resource ); | 934 | addr.setResource( resource ); |
935 | mEditorDialog->setAddressee( addr ); | 935 | mEditorDialog->setAddressee( addr ); |
936 | KApplication::execDialog ( mEditorDialog ); | 936 | KApplication::execDialog ( mEditorDialog ); |
937 | 937 | ||
938 | } else | 938 | } else |
939 | return; | 939 | return; |
940 | 940 | ||
941 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 941 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
942 | 942 | ||
943 | 943 | ||
944 | } | 944 | } |
945 | 945 | ||
946 | void KABCore::addEmail( QString aStr ) | 946 | void KABCore::addEmail( QString aStr ) |
947 | { | 947 | { |
948 | #ifndef KAB_EMBEDDED | 948 | #ifndef KAB_EMBEDDED |
949 | QString fullName, email; | 949 | QString fullName, email; |
950 | 950 | ||
951 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 951 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
952 | 952 | ||
953 | // Try to lookup the addressee matching the email address | 953 | // Try to lookup the addressee matching the email address |
954 | bool found = false; | 954 | bool found = false; |
955 | QStringList emailList; | 955 | QStringList emailList; |
956 | KABC::AddressBook::Iterator it; | 956 | KABC::AddressBook::Iterator it; |
957 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 957 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
958 | emailList = (*it).emails(); | 958 | emailList = (*it).emails(); |
959 | if ( emailList.contains( email ) > 0 ) { | 959 | if ( emailList.contains( email ) > 0 ) { |
960 | found = true; | 960 | found = true; |
961 | (*it).setNameFromString( fullName ); | 961 | (*it).setNameFromString( fullName ); |
962 | editContact( (*it).uid() ); | 962 | editContact( (*it).uid() ); |
963 | } | 963 | } |
964 | } | 964 | } |
965 | 965 | ||
966 | if ( !found ) { | 966 | if ( !found ) { |
967 | KABC::Addressee addr; | 967 | KABC::Addressee addr; |
968 | addr.setNameFromString( fullName ); | 968 | addr.setNameFromString( fullName ); |
969 | addr.insertEmail( email, true ); | 969 | addr.insertEmail( email, true ); |
970 | 970 | ||
971 | mAddressBook->insertAddressee( addr ); | 971 | mAddressBook->insertAddressee( addr ); |
972 | mViewManager->refreshView( addr.uid() ); | 972 | mViewManager->refreshView( addr.uid() ); |
973 | editContact( addr.uid() ); | 973 | editContact( addr.uid() ); |
974 | } | 974 | } |
975 | #else //KAB_EMBEDDED | 975 | #else //KAB_EMBEDDED |
976 | qDebug("KABCore::addEmail finsih method"); | 976 | qDebug("KABCore::addEmail finsih method"); |
977 | #endif //KAB_EMBEDDED | 977 | #endif //KAB_EMBEDDED |
978 | } | 978 | } |
979 | 979 | ||
980 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 980 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
981 | { | 981 | { |
982 | mXXPortManager->importVCard( url, showPreview ); | 982 | mXXPortManager->importVCard( url, showPreview ); |
983 | } | 983 | } |
984 | void KABCore::importFromOL() | 984 | void KABCore::importFromOL() |
985 | { | 985 | { |
986 | #ifdef _WIN32_ | 986 | #ifdef _WIN32_ |
987 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 987 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
988 | idgl->exec(); | 988 | idgl->exec(); |
989 | KABC::Addressee::List list = idgl->getAddressList(); | 989 | KABC::Addressee::List list = idgl->getAddressList(); |
990 | if ( list.count() > 0 ) { | 990 | if ( list.count() > 0 ) { |
991 | KABC::Addressee::List listNew; | 991 | KABC::Addressee::List listNew; |
992 | KABC::Addressee::List listExisting; | 992 | KABC::Addressee::List listExisting; |
993 | KABC::Addressee::List::Iterator it; | 993 | KABC::Addressee::List::Iterator it; |
994 | KABC::AddressBook::Iterator iter; | 994 | KABC::AddressBook::Iterator iter; |
995 | for ( it = list.begin(); it != list.end(); ++it ) { | 995 | for ( it = list.begin(); it != list.end(); ++it ) { |
996 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 996 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
997 | listNew.append( (*it) ); | 997 | listNew.append( (*it) ); |
998 | else | 998 | else |
999 | listExisting.append( (*it) ); | 999 | listExisting.append( (*it) ); |
1000 | } | 1000 | } |
1001 | if ( listExisting.count() > 0 ) | 1001 | if ( listExisting.count() > 0 ) |
1002 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1002 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1003 | if ( listNew.count() > 0 ) { | 1003 | if ( listNew.count() > 0 ) { |
1004 | pasteWithNewUid = false; | 1004 | pasteWithNewUid = false; |
1005 | pasteContacts( listNew ); | 1005 | pasteContacts( listNew ); |
1006 | pasteWithNewUid = true; | 1006 | pasteWithNewUid = true; |
1007 | } | 1007 | } |
1008 | } | 1008 | } |
1009 | delete idgl; | 1009 | delete idgl; |
1010 | #endif | 1010 | #endif |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1013 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1014 | { | 1014 | { |
1015 | mXXPortManager->importVCard( vCard, showPreview ); | 1015 | mXXPortManager->importVCard( vCard, showPreview ); |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | //US added a second method without defaultparameter | 1018 | //US added a second method without defaultparameter |
1019 | void KABCore::editContact2() { | 1019 | void KABCore::editContact2() { |
1020 | editContact( QString::null ); | 1020 | editContact( QString::null ); |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void KABCore::editContact( const QString &uid ) | 1023 | void KABCore::editContact( const QString &uid ) |
1024 | { | 1024 | { |
1025 | 1025 | ||
1026 | if ( mExtensionManager->isQuickEditVisible() ) | 1026 | if ( mExtensionManager->isQuickEditVisible() ) |
1027 | return; | 1027 | return; |
1028 | 1028 | ||
1029 | // First, locate the contact entry | 1029 | // First, locate the contact entry |
1030 | QString localUID = uid; | 1030 | QString localUID = uid; |
1031 | if ( localUID.isNull() ) { | 1031 | if ( localUID.isNull() ) { |
1032 | QStringList uidList = mViewManager->selectedUids(); | 1032 | QStringList uidList = mViewManager->selectedUids(); |
1033 | if ( uidList.count() > 0 ) | 1033 | if ( uidList.count() > 0 ) |
1034 | localUID = *( uidList.at( 0 ) ); | 1034 | localUID = *( uidList.at( 0 ) ); |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1037 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1038 | if ( !addr.isEmpty() ) { | 1038 | if ( !addr.isEmpty() ) { |
1039 | mEditorDialog->setAddressee( addr ); | 1039 | mEditorDialog->setAddressee( addr ); |
1040 | KApplication::execDialog ( mEditorDialog ); | 1040 | KApplication::execDialog ( mEditorDialog ); |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | /** | 1044 | /** |
1045 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1045 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1046 | the method will try to find a selected addressee in the view. | 1046 | the method will try to find a selected addressee in the view. |
1047 | */ | 1047 | */ |
1048 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1048 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1049 | { | 1049 | { |
1050 | if ( mMultipleViewsAtOnce ) | 1050 | if ( mMultipleViewsAtOnce ) |
1051 | { | 1051 | { |
1052 | editContact( uid ); | 1052 | editContact( uid ); |
1053 | } | 1053 | } |
1054 | else | 1054 | else |
1055 | { | 1055 | { |
1056 | setDetailsVisible( true ); | 1056 | setDetailsVisible( true ); |
1057 | mActionDetails->setChecked(true); | 1057 | mActionDetails->setChecked(true); |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | void KABCore::save() | 1062 | void KABCore::save() |
1063 | { | 1063 | { |
1064 | if ( !mModified ) | 1064 | if ( !mModified ) |
1065 | return; | 1065 | return; |
1066 | QString text = i18n( "There was an error while attempting to save\n the " | 1066 | QString text = i18n( "There was an error while attempting to save\n the " |
1067 | "address book. Please check that some \nother application is " | 1067 | "address book. Please check that some \nother application is " |
1068 | "not using it. " ); | 1068 | "not using it. " ); |
1069 | statusMessage(i18n("Saving addressbook ... ")); | 1069 | statusMessage(i18n("Saving addressbook ... ")); |
1070 | #ifndef KAB_EMBEDDED | 1070 | #ifndef KAB_EMBEDDED |
1071 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1071 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1072 | if ( !b || !b->save() ) { | 1072 | if ( !b || !b->save() ) { |
1073 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1073 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1074 | } | 1074 | } |
1075 | #else //KAB_EMBEDDED | 1075 | #else //KAB_EMBEDDED |
1076 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1076 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1077 | if ( !b || !b->save() ) { | 1077 | if ( !b || !b->save() ) { |
1078 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1078 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1079 | } | 1079 | } |
1080 | #endif //KAB_EMBEDDED | 1080 | #endif //KAB_EMBEDDED |
1081 | 1081 | ||
1082 | statusMessage(i18n("Addressbook saved!")); | 1082 | statusMessage(i18n("Addressbook saved!")); |
1083 | setModified( false ); | 1083 | setModified( false ); |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | void KABCore::statusMessage(QString mess , int time ) | 1086 | void KABCore::statusMessage(QString mess , int time ) |
1087 | { | 1087 | { |
1088 | //topLevelWidget()->setCaption( mess ); | 1088 | //topLevelWidget()->setCaption( mess ); |
1089 | // pending setting timer to revome message | 1089 | // pending setting timer to revome message |
1090 | } | 1090 | } |
1091 | void KABCore::undo() | 1091 | void KABCore::undo() |
1092 | { | 1092 | { |
1093 | UndoStack::instance()->undo(); | 1093 | UndoStack::instance()->undo(); |
1094 | 1094 | ||
1095 | // Refresh the view | 1095 | // Refresh the view |
1096 | mViewManager->refreshView(); | 1096 | mViewManager->refreshView(); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | void KABCore::redo() | 1099 | void KABCore::redo() |
1100 | { | 1100 | { |
1101 | RedoStack::instance()->redo(); | 1101 | RedoStack::instance()->redo(); |
1102 | 1102 | ||
1103 | // Refresh the view | 1103 | // Refresh the view |
1104 | mViewManager->refreshView(); | 1104 | mViewManager->refreshView(); |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1107 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1108 | { | 1108 | { |
1109 | if (mMultipleViewsAtOnce) | 1109 | if (mMultipleViewsAtOnce) |
1110 | { | 1110 | { |
1111 | if ( visible ) | 1111 | if ( visible ) |
1112 | mJumpButtonBar->show(); | 1112 | mJumpButtonBar->show(); |
1113 | else | 1113 | else |
1114 | mJumpButtonBar->hide(); | 1114 | mJumpButtonBar->hide(); |
1115 | } | 1115 | } |
1116 | else | 1116 | else |
1117 | { | 1117 | { |
1118 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1118 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1119 | if (mViewManager->isVisible()) | 1119 | if (mViewManager->isVisible()) |
1120 | { | 1120 | { |
1121 | if ( visible ) | 1121 | if ( visible ) |
1122 | mJumpButtonBar->show(); | 1122 | mJumpButtonBar->show(); |
1123 | else | 1123 | else |
1124 | mJumpButtonBar->hide(); | 1124 | mJumpButtonBar->hide(); |
1125 | } | 1125 | } |
1126 | else | 1126 | else |
1127 | { | 1127 | { |
1128 | mJumpButtonBar->hide(); | 1128 | mJumpButtonBar->hide(); |
1129 | } | 1129 | } |
1130 | } | 1130 | } |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | 1133 | ||
1134 | void KABCore::setDetailsToState() | 1134 | void KABCore::setDetailsToState() |
1135 | { | 1135 | { |
1136 | setDetailsVisible( mActionDetails->isChecked() ); | 1136 | setDetailsVisible( mActionDetails->isChecked() ); |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | 1139 | ||
1140 | 1140 | ||
1141 | void KABCore::setDetailsVisible( bool visible ) | 1141 | void KABCore::setDetailsVisible( bool visible ) |
1142 | { | 1142 | { |
1143 | if (visible && mDetails->isHidden()) | 1143 | if (visible && mDetails->isHidden()) |
1144 | { | 1144 | { |
1145 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1145 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1146 | if ( addrList.count() > 0 ) | 1146 | if ( addrList.count() > 0 ) |
1147 | mDetails->setAddressee( addrList[ 0 ] ); | 1147 | mDetails->setAddressee( addrList[ 0 ] ); |
1148 | } | 1148 | } |
1149 | 1149 | ||
1150 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1150 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1151 | // the listview and the detailview. We do that by changing the splitbar size. | 1151 | // the listview and the detailview. We do that by changing the splitbar size. |
1152 | if (mMultipleViewsAtOnce) | 1152 | if (mMultipleViewsAtOnce) |
1153 | { | 1153 | { |
1154 | if ( visible ) | 1154 | if ( visible ) |
1155 | mDetails->show(); | 1155 | mDetails->show(); |
1156 | else | 1156 | else |
1157 | mDetails->hide(); | 1157 | mDetails->hide(); |
1158 | } | 1158 | } |
1159 | else | 1159 | else |
1160 | { | 1160 | { |
1161 | if ( visible ) { | 1161 | if ( visible ) { |
1162 | mViewManager->hide(); | 1162 | mViewManager->hide(); |
1163 | mDetails->show(); | 1163 | mDetails->show(); |
1164 | } | 1164 | } |
1165 | else { | 1165 | else { |
1166 | mViewManager->show(); | 1166 | mViewManager->show(); |
1167 | mDetails->hide(); | 1167 | mDetails->hide(); |
1168 | } | 1168 | } |
1169 | setJumpButtonBarVisible( !visible ); | 1169 | setJumpButtonBarVisible( !visible ); |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | void KABCore::extensionChanged( int id ) | 1174 | void KABCore::extensionChanged( int id ) |
1175 | { | 1175 | { |
1176 | //change the details view only for non desktop systems | 1176 | //change the details view only for non desktop systems |
1177 | #ifndef DESKTOP_VERSION | 1177 | #ifndef DESKTOP_VERSION |
1178 | 1178 | ||
1179 | if (id == 0) | 1179 | if (id == 0) |
1180 | { | 1180 | { |
1181 | //the user disabled the extension. | 1181 | //the user disabled the extension. |
1182 | 1182 | ||
1183 | if (mMultipleViewsAtOnce) | 1183 | if (mMultipleViewsAtOnce) |
1184 | { // enable detailsview again | 1184 | { // enable detailsview again |
1185 | setDetailsVisible( true ); | 1185 | setDetailsVisible( true ); |
1186 | mActionDetails->setChecked( true ); | 1186 | mActionDetails->setChecked( true ); |
1187 | } | 1187 | } |
1188 | else | 1188 | else |
1189 | { //go back to the listview | 1189 | { //go back to the listview |
1190 | setDetailsVisible( false ); | 1190 | setDetailsVisible( false ); |
1191 | mActionDetails->setChecked( false ); | 1191 | mActionDetails->setChecked( false ); |
1192 | mActionDetails->setEnabled(true); | 1192 | mActionDetails->setEnabled(true); |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | } | 1195 | } |
1196 | else | 1196 | else |
1197 | { | 1197 | { |
1198 | //the user enabled the extension. | 1198 | //the user enabled the extension. |
1199 | setDetailsVisible( false ); | 1199 | setDetailsVisible( false ); |
1200 | mActionDetails->setChecked( false ); | 1200 | mActionDetails->setChecked( false ); |
1201 | 1201 | ||
1202 | if (!mMultipleViewsAtOnce) | 1202 | if (!mMultipleViewsAtOnce) |
1203 | { | 1203 | { |
1204 | mActionDetails->setEnabled(false); | 1204 | mActionDetails->setEnabled(false); |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | mExtensionManager->setSelectionChanged(); | 1207 | mExtensionManager->setSelectionChanged(); |
1208 | 1208 | ||
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | #endif// DESKTOP_VERSION | 1211 | #endif// DESKTOP_VERSION |
1212 | 1212 | ||
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | 1215 | ||
1216 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1216 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1217 | { | 1217 | { |
1218 | 1218 | ||
1219 | if ( list.count() != 0 ) { | 1219 | if ( list.count() != 0 ) { |
1220 | KABC::Addressee::List::ConstIterator it; | 1220 | KABC::Addressee::List::ConstIterator it; |
1221 | for ( it = list.begin(); it != list.end(); ++it ) | 1221 | for ( it = list.begin(); it != list.end(); ++it ) |
1222 | mAddressBook->insertAddressee( *it ); | 1222 | mAddressBook->insertAddressee( *it ); |
1223 | if ( list.count() > 1 ) | 1223 | if ( list.count() > 1 ) |
1224 | setModified(); | 1224 | setModified(); |
1225 | else | 1225 | else |
1226 | setModifiedWOrefresh(); | 1226 | setModifiedWOrefresh(); |
1227 | } | 1227 | } |
1228 | if ( list.count() == 0 ) | 1228 | if ( list.count() == 0 ) |
1229 | mViewManager->refreshView(); | 1229 | mViewManager->refreshView(); |
1230 | else | 1230 | else |
1231 | mViewManager->refreshView( list[ 0 ].uid() ); | 1231 | mViewManager->refreshView( list[ 0 ].uid() ); |
1232 | 1232 | ||
1233 | 1233 | ||
1234 | 1234 | ||
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | QString KABCore::getNameByPhone( const QString &phone ) | 1237 | QString KABCore::getNameByPhone( const QString &phone ) |
1238 | { | 1238 | { |
1239 | #ifndef KAB_EMBEDDED | 1239 | #ifndef KAB_EMBEDDED |
1240 | QRegExp r( "[/*/-/ ]" ); | 1240 | QRegExp r( "[/*/-/ ]" ); |
1241 | QString localPhone( phone ); | 1241 | QString localPhone( phone ); |
1242 | 1242 | ||
1243 | bool found = false; | 1243 | bool found = false; |
1244 | QString ownerName = ""; | 1244 | QString ownerName = ""; |
1245 | KABC::AddressBook::Iterator iter; | 1245 | KABC::AddressBook::Iterator iter; |
1246 | KABC::PhoneNumber::List::Iterator phoneIter; | 1246 | KABC::PhoneNumber::List::Iterator phoneIter; |
1247 | KABC::PhoneNumber::List phoneList; | 1247 | KABC::PhoneNumber::List phoneList; |
1248 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1248 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1249 | phoneList = (*iter).phoneNumbers(); | 1249 | phoneList = (*iter).phoneNumbers(); |
1250 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1250 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1251 | ++phoneIter) { | 1251 | ++phoneIter) { |
1252 | // Get rid of separator chars so just the numbers are compared. | 1252 | // Get rid of separator chars so just the numbers are compared. |
1253 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1253 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1254 | ownerName = (*iter).formattedName(); | 1254 | ownerName = (*iter).formattedName(); |
1255 | found = true; | 1255 | found = true; |
1256 | } | 1256 | } |
1257 | } | 1257 | } |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | return ownerName; | 1260 | return ownerName; |
1261 | #else //KAB_EMBEDDED | 1261 | #else //KAB_EMBEDDED |
1262 | qDebug("KABCore::getNameByPhone finsih method"); | 1262 | qDebug("KABCore::getNameByPhone finsih method"); |
1263 | return ""; | 1263 | return ""; |
1264 | #endif //KAB_EMBEDDED | 1264 | #endif //KAB_EMBEDDED |
1265 | 1265 | ||
1266 | } | 1266 | } |
1267 | 1267 | ||
1268 | void KABCore::openConfigDialog() | 1268 | void KABCore::openConfigDialog() |
1269 | { | 1269 | { |
1270 | KABPrefs* kab_prefs = KABPrefs::instance(); | 1270 | KABPrefs* kab_prefs = KABPrefs::instance(); |
1271 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); | 1271 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); |
1272 | 1272 | ||
1273 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1273 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1274 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1274 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1275 | ConfigureDialog->addModule(kabcfg ); | 1275 | ConfigureDialog->addModule(kabcfg ); |
1276 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1276 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1277 | ConfigureDialog->addModule(kdelibcfg ); | 1277 | ConfigureDialog->addModule(kdelibcfg ); |
1278 | 1278 | ||
1279 | 1279 | ||
1280 | 1280 | ||
1281 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1281 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1282 | this, SLOT( configurationChanged() ) ); | 1282 | this, SLOT( configurationChanged() ) ); |
1283 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1283 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1284 | this, SLOT( configurationChanged() ) ); | 1284 | this, SLOT( configurationChanged() ) ); |
1285 | saveSettings(); | 1285 | saveSettings(); |
1286 | #ifndef DESKTOP_VERSION | 1286 | #ifndef DESKTOP_VERSION |
1287 | ConfigureDialog->showMaximized(); | 1287 | ConfigureDialog->showMaximized(); |
1288 | #endif | 1288 | #endif |
1289 | if ( ConfigureDialog->exec() ) | 1289 | if ( ConfigureDialog->exec() ) |
1290 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1290 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1291 | delete ConfigureDialog; | 1291 | delete ConfigureDialog; |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | void KABCore::openLDAPDialog() | 1294 | void KABCore::openLDAPDialog() |
1295 | { | 1295 | { |
1296 | #ifndef KAB_EMBEDDED | 1296 | #ifndef KAB_EMBEDDED |
1297 | if ( !mLdapSearchDialog ) { | 1297 | if ( !mLdapSearchDialog ) { |
1298 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1298 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1299 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1299 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1300 | SLOT( refreshView() ) ); | 1300 | SLOT( refreshView() ) ); |
1301 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1301 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1302 | SLOT( setModified() ) ); | 1302 | SLOT( setModified() ) ); |
1303 | } else | 1303 | } else |
1304 | mLdapSearchDialog->restoreSettings(); | 1304 | mLdapSearchDialog->restoreSettings(); |
1305 | 1305 | ||
1306 | if ( mLdapSearchDialog->isOK() ) | 1306 | if ( mLdapSearchDialog->isOK() ) |
1307 | mLdapSearchDialog->exec(); | 1307 | mLdapSearchDialog->exec(); |
1308 | #else //KAB_EMBEDDED | 1308 | #else //KAB_EMBEDDED |
1309 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1309 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1310 | #endif //KAB_EMBEDDED | 1310 | #endif //KAB_EMBEDDED |
1311 | } | 1311 | } |
1312 | 1312 | ||
1313 | void KABCore::print() | 1313 | void KABCore::print() |
1314 | { | 1314 | { |
1315 | #ifndef KAB_EMBEDDED | 1315 | #ifndef KAB_EMBEDDED |
1316 | KPrinter printer; | 1316 | KPrinter printer; |
1317 | if ( !printer.setup( this ) ) | 1317 | if ( !printer.setup( this ) ) |
1318 | return; | 1318 | return; |
1319 | 1319 | ||
1320 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1320 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1321 | mViewManager->selectedUids(), this ); | 1321 | mViewManager->selectedUids(), this ); |
1322 | 1322 | ||
1323 | wizard.exec(); | 1323 | wizard.exec(); |
1324 | #else //KAB_EMBEDDED | 1324 | #else //KAB_EMBEDDED |
1325 | qDebug("KABCore::print() finsih method"); | 1325 | qDebug("KABCore::print() finsih method"); |
1326 | #endif //KAB_EMBEDDED | 1326 | #endif //KAB_EMBEDDED |
1327 | 1327 | ||
1328 | } | 1328 | } |
1329 | 1329 | ||
1330 | 1330 | ||
1331 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1331 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1332 | { | 1332 | { |
1333 | if ( mGUIClient ) | 1333 | if ( mGUIClient ) |
1334 | mGUIClient->insertChildClient( client ); | 1334 | mGUIClient->insertChildClient( client ); |
1335 | else | 1335 | else |
1336 | KMessageBox::error( this, "no KXMLGUICLient"); | 1336 | KMessageBox::error( this, "no KXMLGUICLient"); |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | 1339 | ||
1340 | void KABCore::configurationChanged() | 1340 | void KABCore::configurationChanged() |
1341 | { | 1341 | { |
1342 | mExtensionManager->reconfigure(); | 1342 | mExtensionManager->reconfigure(); |
1343 | } | 1343 | } |
1344 | 1344 | ||
1345 | void KABCore::addressBookChanged() | 1345 | void KABCore::addressBookChanged() |
1346 | { | 1346 | { |
1347 | /*US | 1347 | /*US |
1348 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1348 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1349 | while ( it.current() ) { | 1349 | while ( it.current() ) { |
1350 | if ( it.current()->dirty() ) { | 1350 | if ( it.current()->dirty() ) { |
1351 | QString text = i18n( "Data has been changed externally. Unsaved " | 1351 | QString text = i18n( "Data has been changed externally. Unsaved " |
1352 | "changes will be lost." ); | 1352 | "changes will be lost." ); |
1353 | KMessageBox::information( this, text ); | 1353 | KMessageBox::information( this, text ); |
1354 | } | 1354 | } |
1355 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1355 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1356 | ++it; | 1356 | ++it; |
1357 | } | 1357 | } |
1358 | */ | 1358 | */ |
1359 | if (mEditorDialog) | 1359 | if (mEditorDialog) |
1360 | { | 1360 | { |
1361 | if (mEditorDialog->dirty()) | 1361 | if (mEditorDialog->dirty()) |
1362 | { | 1362 | { |
1363 | QString text = i18n( "Data has been changed externally. Unsaved " | 1363 | QString text = i18n( "Data has been changed externally. Unsaved " |
1364 | "changes will be lost." ); | 1364 | "changes will be lost." ); |
1365 | KMessageBox::information( this, text ); | 1365 | KMessageBox::information( this, text ); |
1366 | } | 1366 | } |
1367 | QString currentuid = mEditorDialog->addressee().uid(); | 1367 | QString currentuid = mEditorDialog->addressee().uid(); |
1368 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1368 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1369 | } | 1369 | } |
1370 | mViewManager->refreshView(); | 1370 | mViewManager->refreshView(); |
1371 | // mDetails->refreshView(); | 1371 | // mDetails->refreshView(); |
1372 | 1372 | ||
1373 | 1373 | ||
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1376 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1377 | const char *name ) | 1377 | const char *name ) |
1378 | { | 1378 | { |
1379 | 1379 | ||
1380 | if ( mEditorDialog == 0 ) { | 1380 | if ( mEditorDialog == 0 ) { |
1381 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1381 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1382 | name ? name : "editorDialog" ); | 1382 | name ? name : "editorDialog" ); |
1383 | 1383 | ||
1384 | 1384 | ||
1385 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1385 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1386 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1386 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1387 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1387 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1388 | // SLOT( slotEditorDestroyed( const QString& ) ) ); | 1388 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | return mEditorDialog; | 1391 | return mEditorDialog; |
1392 | } | 1392 | } |
1393 | 1393 | ||
1394 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1394 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1395 | { | 1395 | { |
1396 | //mEditorDict.remove( uid ); | 1396 | //mEditorDict.remove( uid ); |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | void KABCore::initGUI() | 1399 | void KABCore::initGUI() |
1400 | { | 1400 | { |
1401 | #ifndef KAB_EMBEDDED | 1401 | #ifndef KAB_EMBEDDED |
1402 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1402 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1403 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1403 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1404 | 1404 | ||
1405 | mExtensionBarSplitter = new QSplitter( this ); | 1405 | mExtensionBarSplitter = new QSplitter( this ); |
1406 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1406 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1407 | 1407 | ||
1408 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1408 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1409 | 1409 | ||
1410 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1410 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1411 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1411 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1412 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1412 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1413 | SLOT( incrementalSearch( const QString& ) ) ); | 1413 | SLOT( incrementalSearch( const QString& ) ) ); |
1414 | 1414 | ||
1415 | mViewManager = new ViewManager( this, viewSpace ); | 1415 | mViewManager = new ViewManager( this, viewSpace ); |
1416 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1416 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1417 | 1417 | ||
1418 | mDetails = new ViewContainer( mDetailsSplitter ); | 1418 | mDetails = new ViewContainer( mDetailsSplitter ); |
1419 | 1419 | ||
1420 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1420 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1421 | 1421 | ||
1422 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1422 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1423 | 1423 | ||
1424 | topLayout->addWidget( mExtensionBarSplitter ); | 1424 | topLayout->addWidget( mExtensionBarSplitter ); |
1425 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1425 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1426 | topLayout->addWidget( mJumpButtonBar ); | 1426 | topLayout->addWidget( mJumpButtonBar ); |
1427 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1427 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1428 | 1428 | ||
1429 | mXXPortManager = new XXPortManager( this, this ); | 1429 | mXXPortManager = new XXPortManager( this, this ); |
1430 | 1430 | ||
1431 | #else //KAB_EMBEDDED | 1431 | #else //KAB_EMBEDDED |
1432 | //US initialize viewMenu before settingup viewmanager. | 1432 | //US initialize viewMenu before settingup viewmanager. |
1433 | // Viewmanager needs this menu to plugin submenues. | 1433 | // Viewmanager needs this menu to plugin submenues. |
1434 | viewMenu = new QPopupMenu( this ); | 1434 | viewMenu = new QPopupMenu( this ); |
1435 | settingsMenu = new QPopupMenu( this ); | 1435 | settingsMenu = new QPopupMenu( this ); |
1436 | //filterMenu = new QPopupMenu( this ); | 1436 | //filterMenu = new QPopupMenu( this ); |
1437 | ImportMenu = new QPopupMenu( this ); | 1437 | ImportMenu = new QPopupMenu( this ); |
1438 | ExportMenu = new QPopupMenu( this ); | 1438 | ExportMenu = new QPopupMenu( this ); |
1439 | 1439 | ||
1440 | changeMenu= new QPopupMenu( this ); | 1440 | changeMenu= new QPopupMenu( this ); |
1441 | 1441 | ||
1442 | //US since we have no splitter for the embedded system, setup | 1442 | //US since we have no splitter for the embedded system, setup |
1443 | // a layout with two frames. One left and one right. | 1443 | // a layout with two frames. One left and one right. |
1444 | 1444 | ||
1445 | QBoxLayout *topLayout; | 1445 | QBoxLayout *topLayout; |
1446 | 1446 | ||
1447 | // = new QHBoxLayout( this ); | 1447 | // = new QHBoxLayout( this ); |
1448 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1448 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1449 | 1449 | ||
1450 | // QWidget *mainBox = new QWidget( this ); | 1450 | // QWidget *mainBox = new QWidget( this ); |
1451 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1451 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1452 | 1452 | ||
1453 | #ifdef DESKTOP_VERSION | 1453 | #ifdef DESKTOP_VERSION |
1454 | topLayout = new QHBoxLayout( this ); | 1454 | topLayout = new QHBoxLayout( this ); |
1455 | 1455 | ||
1456 | 1456 | ||
1457 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1457 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1458 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1458 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1459 | 1459 | ||
1460 | topLayout->addWidget(mMiniSplitter ); | 1460 | topLayout->addWidget(mMiniSplitter ); |
1461 | 1461 | ||
1462 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1462 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1463 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1463 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1464 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1464 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1465 | mDetails = new ViewContainer( mMiniSplitter ); | 1465 | mDetails = new ViewContainer( mMiniSplitter ); |
1466 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1466 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1467 | #else | 1467 | #else |
1468 | if ( QApplication::desktop()->width() > 480 ) { | 1468 | if ( QApplication::desktop()->width() > 480 ) { |
1469 | topLayout = new QHBoxLayout( this ); | 1469 | topLayout = new QHBoxLayout( this ); |
1470 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1470 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1471 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1471 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1472 | } else { | 1472 | } else { |
1473 | 1473 | ||
1474 | topLayout = new QHBoxLayout( this ); | 1474 | topLayout = new QHBoxLayout( this ); |
1475 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1475 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1476 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1476 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1477 | } | 1477 | } |
1478 | 1478 | ||
1479 | topLayout->addWidget(mMiniSplitter ); | 1479 | topLayout->addWidget(mMiniSplitter ); |
1480 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1480 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1481 | mDetails = new ViewContainer( mMiniSplitter ); | 1481 | mDetails = new ViewContainer( mMiniSplitter ); |
1482 | 1482 | ||
1483 | 1483 | ||
1484 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1484 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1485 | #endif | 1485 | #endif |
1486 | //eh->hide(); | 1486 | //eh->hide(); |
1487 | // topLayout->addWidget(mExtensionManager ); | 1487 | // topLayout->addWidget(mExtensionManager ); |
1488 | 1488 | ||
1489 | 1489 | ||
1490 | /*US | 1490 | /*US |
1491 | #ifndef KAB_NOSPLITTER | 1491 | #ifndef KAB_NOSPLITTER |
1492 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1492 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1493 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1493 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1494 | topLayout->setSpacing( 10 ); | 1494 | topLayout->setSpacing( 10 ); |
1495 | 1495 | ||
1496 | mDetailsSplitter = new QSplitter( this ); | 1496 | mDetailsSplitter = new QSplitter( this ); |
1497 | 1497 | ||
1498 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1498 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1499 | 1499 | ||
1500 | mViewManager = new ViewManager( this, viewSpace ); | 1500 | mViewManager = new ViewManager( this, viewSpace ); |
1501 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1501 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1502 | 1502 | ||
1503 | mDetails = new ViewContainer( mDetailsSplitter ); | 1503 | mDetails = new ViewContainer( mDetailsSplitter ); |
1504 | 1504 | ||
1505 | topLayout->addWidget( mDetailsSplitter ); | 1505 | topLayout->addWidget( mDetailsSplitter ); |
1506 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1506 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1507 | #else //KAB_NOSPLITTER | 1507 | #else //KAB_NOSPLITTER |
1508 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1508 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1509 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1509 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1510 | topLayout->setSpacing( 10 ); | 1510 | topLayout->setSpacing( 10 ); |
1511 | 1511 | ||
1512 | // mDetailsSplitter = new QSplitter( this ); | 1512 | // mDetailsSplitter = new QSplitter( this ); |
1513 | 1513 | ||
1514 | QVBox *viewSpace = new QVBox( this ); | 1514 | QVBox *viewSpace = new QVBox( this ); |
1515 | 1515 | ||
1516 | mViewManager = new ViewManager( this, viewSpace ); | 1516 | mViewManager = new ViewManager( this, viewSpace ); |
1517 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1517 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1518 | 1518 | ||
1519 | mDetails = new ViewContainer( this ); | 1519 | mDetails = new ViewContainer( this ); |
1520 | 1520 | ||
1521 | topLayout->addWidget( viewSpace ); | 1521 | topLayout->addWidget( viewSpace ); |
1522 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1522 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1523 | topLayout->addWidget( mDetails ); | 1523 | topLayout->addWidget( mDetails ); |
1524 | #endif //KAB_NOSPLITTER | 1524 | #endif //KAB_NOSPLITTER |
1525 | */ | 1525 | */ |
1526 | 1526 | ||
1527 | 1527 | ||
1528 | #endif //KAB_EMBEDDED | 1528 | #endif //KAB_EMBEDDED |
1529 | initActions(); | 1529 | initActions(); |
1530 | 1530 | ||
1531 | #ifdef KAB_EMBEDDED | 1531 | #ifdef KAB_EMBEDDED |
1532 | addActionsManually(); | 1532 | addActionsManually(); |
1533 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1533 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1534 | mXXPortManager = new XXPortManager( this, this ); | 1534 | mXXPortManager = new XXPortManager( this, this ); |
1535 | 1535 | ||
1536 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1536 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1537 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1537 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1538 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1538 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1539 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1539 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1540 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1540 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1541 | // mIncSearchWidget->hide(); | 1541 | // mIncSearchWidget->hide(); |
1542 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1542 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1543 | SLOT( incrementalSearch( const QString& ) ) ); | 1543 | SLOT( incrementalSearch( const QString& ) ) ); |
1544 | 1544 | ||
1545 | 1545 | ||
1546 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1546 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1547 | 1547 | ||
1548 | topLayout->addWidget( mJumpButtonBar ); | 1548 | topLayout->addWidget( mJumpButtonBar ); |
1549 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1549 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1550 | 1550 | ||
1551 | // mMainWindow->getIconToolBar()->raise(); | 1551 | // mMainWindow->getIconToolBar()->raise(); |
1552 | 1552 | ||
1553 | #endif //KAB_EMBEDDED | 1553 | #endif //KAB_EMBEDDED |
1554 | 1554 | ||
1555 | } | 1555 | } |
1556 | void KABCore::initActions() | 1556 | void KABCore::initActions() |
1557 | { | 1557 | { |
1558 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1558 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1559 | 1559 | ||
1560 | #ifndef KAB_EMBEDDED | 1560 | #ifndef KAB_EMBEDDED |
1561 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1561 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1562 | SLOT( clipboardDataChanged() ) ); | 1562 | SLOT( clipboardDataChanged() ) ); |
1563 | #endif //KAB_EMBEDDED | 1563 | #endif //KAB_EMBEDDED |
1564 | 1564 | ||
1565 | // file menu | 1565 | // file menu |
1566 | if ( mIsPart ) { | 1566 | if ( mIsPart ) { |
1567 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1567 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1568 | SLOT( sendMail() ), actionCollection(), | 1568 | SLOT( sendMail() ), actionCollection(), |
1569 | "kaddressbook_mail" ); | 1569 | "kaddressbook_mail" ); |
1570 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1570 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1571 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1571 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1572 | 1572 | ||
1573 | } else { | 1573 | } else { |
1574 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1574 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1575 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1575 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1576 | } | 1576 | } |
1577 | 1577 | ||
1578 | 1578 | ||
1579 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1579 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1580 | SLOT( save() ), actionCollection(), "file_sync" ); | 1580 | SLOT( save() ), actionCollection(), "file_sync" ); |
1581 | 1581 | ||
1582 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1582 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1583 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1583 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1584 | 1584 | ||
1585 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1585 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1586 | this, SLOT( mailVCard() ), | 1586 | this, SLOT( mailVCard() ), |
1587 | actionCollection(), "file_mail_vcard"); | 1587 | actionCollection(), "file_mail_vcard"); |
1588 | 1588 | ||
1589 | mActionBeamVCard = 0; | 1589 | mActionBeamVCard = 0; |
1590 | mActionBeam = 0; | 1590 | mActionBeam = 0; |
1591 | 1591 | ||
1592 | #ifndef DESKTOP_VERSION | 1592 | #ifndef DESKTOP_VERSION |
1593 | if ( Ir::supported() ) { | 1593 | if ( Ir::supported() ) { |
1594 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1594 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1595 | SLOT( beamVCard() ), actionCollection(), | 1595 | SLOT( beamVCard() ), actionCollection(), |
1596 | "kaddressbook_beam_vcard" ); | 1596 | "kaddressbook_beam_vcard" ); |
1597 | 1597 | ||
1598 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1598 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1599 | SLOT( beamMySelf() ), actionCollection(), | 1599 | SLOT( beamMySelf() ), actionCollection(), |
1600 | "kaddressbook_beam_myself" ); | 1600 | "kaddressbook_beam_myself" ); |
1601 | } | 1601 | } |
1602 | #endif | 1602 | #endif |
1603 | 1603 | ||
1604 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1604 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1605 | this, SLOT( editContact2() ), | 1605 | this, SLOT( editContact2() ), |
1606 | actionCollection(), "file_properties" ); | 1606 | actionCollection(), "file_properties" ); |
1607 | 1607 | ||
1608 | #ifdef KAB_EMBEDDED | 1608 | #ifdef KAB_EMBEDDED |
1609 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1609 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1610 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1610 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1611 | mMainWindow, SLOT( exit() ), | 1611 | mMainWindow, SLOT( exit() ), |
1612 | actionCollection(), "quit" ); | 1612 | actionCollection(), "quit" ); |
1613 | #endif //KAB_EMBEDDED | 1613 | #endif //KAB_EMBEDDED |
1614 | 1614 | ||
1615 | // edit menu | 1615 | // edit menu |
1616 | if ( mIsPart ) { | 1616 | if ( mIsPart ) { |
1617 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1617 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1618 | SLOT( copyContacts() ), actionCollection(), | 1618 | SLOT( copyContacts() ), actionCollection(), |
1619 | "kaddressbook_copy" ); | 1619 | "kaddressbook_copy" ); |
1620 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1620 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1621 | SLOT( cutContacts() ), actionCollection(), | 1621 | SLOT( cutContacts() ), actionCollection(), |
1622 | "kaddressbook_cut" ); | 1622 | "kaddressbook_cut" ); |
1623 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1623 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1624 | SLOT( pasteContacts() ), actionCollection(), | 1624 | SLOT( pasteContacts() ), actionCollection(), |
1625 | "kaddressbook_paste" ); | 1625 | "kaddressbook_paste" ); |
1626 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1626 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1627 | SLOT( selectAllContacts() ), actionCollection(), | 1627 | SLOT( selectAllContacts() ), actionCollection(), |
1628 | "kaddressbook_select_all" ); | 1628 | "kaddressbook_select_all" ); |
1629 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1629 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1630 | SLOT( undo() ), actionCollection(), | 1630 | SLOT( undo() ), actionCollection(), |
1631 | "kaddressbook_undo" ); | 1631 | "kaddressbook_undo" ); |
1632 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1632 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1633 | this, SLOT( redo() ), actionCollection(), | 1633 | this, SLOT( redo() ), actionCollection(), |
1634 | "kaddressbook_redo" ); | 1634 | "kaddressbook_redo" ); |
1635 | } else { | 1635 | } else { |
1636 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1636 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1637 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1637 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1638 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1638 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1639 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1639 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1640 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1640 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1641 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1641 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1642 | } | 1642 | } |
1643 | 1643 | ||
1644 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1644 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1645 | Key_Delete, this, SLOT( deleteContacts() ), | 1645 | Key_Delete, this, SLOT( deleteContacts() ), |
1646 | actionCollection(), "edit_delete" ); | 1646 | actionCollection(), "edit_delete" ); |
1647 | 1647 | ||
1648 | mActionUndo->setEnabled( false ); | 1648 | mActionUndo->setEnabled( false ); |
1649 | mActionRedo->setEnabled( false ); | 1649 | mActionRedo->setEnabled( false ); |
1650 | 1650 | ||
1651 | // settings menu | 1651 | // settings menu |
1652 | #ifdef KAB_EMBEDDED | 1652 | #ifdef KAB_EMBEDDED |
1653 | //US special menuentry to configure the addressbook resources. On KDE | 1653 | //US special menuentry to configure the addressbook resources. On KDE |
1654 | // you do that through the control center !!! | 1654 | // you do that through the control center !!! |
1655 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1655 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1656 | SLOT( configureResources() ), actionCollection(), | 1656 | SLOT( configureResources() ), actionCollection(), |
1657 | "kaddressbook_configure_resources" ); | 1657 | "kaddressbook_configure_resources" ); |
1658 | #endif //KAB_EMBEDDED | 1658 | #endif //KAB_EMBEDDED |
1659 | 1659 | ||
1660 | if ( mIsPart ) { | 1660 | if ( mIsPart ) { |
1661 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1661 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1662 | SLOT( openConfigDialog() ), actionCollection(), | 1662 | SLOT( openConfigDialog() ), actionCollection(), |
1663 | "kaddressbook_configure" ); | 1663 | "kaddressbook_configure" ); |
1664 | 1664 | ||
1665 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1665 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1666 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1666 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1667 | "kaddressbook_configure_shortcuts" ); | 1667 | "kaddressbook_configure_shortcuts" ); |
1668 | #ifdef KAB_EMBEDDED | 1668 | #ifdef KAB_EMBEDDED |
1669 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1669 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1670 | mActionConfigureToolbars->setEnabled( false ); | 1670 | mActionConfigureToolbars->setEnabled( false ); |
1671 | #endif //KAB_EMBEDDED | 1671 | #endif //KAB_EMBEDDED |
1672 | 1672 | ||
1673 | } else { | 1673 | } else { |
1674 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1674 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1675 | 1675 | ||
1676 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1676 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1677 | } | 1677 | } |
1678 | 1678 | ||
1679 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1679 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1680 | actionCollection(), "options_show_jump_bar" ); | 1680 | actionCollection(), "options_show_jump_bar" ); |
1681 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1681 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1682 | 1682 | ||
1683 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1683 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1684 | actionCollection(), "options_show_details" ); | 1684 | actionCollection(), "options_show_details" ); |
1685 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1685 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1686 | 1686 | ||
1687 | // misc | 1687 | // misc |
1688 | // only enable LDAP lookup if we can handle the protocol | 1688 | // only enable LDAP lookup if we can handle the protocol |
1689 | #ifndef KAB_EMBEDDED | 1689 | #ifndef KAB_EMBEDDED |
1690 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1690 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1691 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1691 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1692 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1692 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1693 | "ldap_lookup" ); | 1693 | "ldap_lookup" ); |
1694 | } | 1694 | } |
1695 | #else //KAB_EMBEDDED | 1695 | #else //KAB_EMBEDDED |
1696 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1696 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1697 | #endif //KAB_EMBEDDED | 1697 | #endif //KAB_EMBEDDED |
1698 | 1698 | ||
1699 | 1699 | ||
1700 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1700 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1701 | SLOT( setWhoAmI() ), actionCollection(), | 1701 | SLOT( setWhoAmI() ), actionCollection(), |
1702 | "set_personal" ); | 1702 | "set_personal" ); |
1703 | 1703 | ||
1704 | 1704 | ||
1705 | 1705 | ||
1706 | 1706 | ||
1707 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1707 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1708 | SLOT( setCategories() ), actionCollection(), | 1708 | SLOT( setCategories() ), actionCollection(), |
1709 | "edit_set_categories" ); | 1709 | "edit_set_categories" ); |
1710 | 1710 | ||
1711 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1711 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1712 | SLOT( removeVoice() ), actionCollection(), | 1712 | SLOT( removeVoice() ), actionCollection(), |
1713 | "remove_voice" ); | 1713 | "remove_voice" ); |
1714 | mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, | 1714 | mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, |
1715 | SLOT( importFromOL() ), actionCollection(), | 1715 | SLOT( importFromOL() ), actionCollection(), |
1716 | "import_OL" ); | 1716 | "import_OL" ); |
1717 | #ifdef KAB_EMBEDDED | 1717 | #ifdef KAB_EMBEDDED |
1718 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1718 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1719 | this, SLOT( showLicence() ), actionCollection(), | 1719 | this, SLOT( showLicence() ), actionCollection(), |
1720 | "licence_about_data" ); | 1720 | "licence_about_data" ); |
1721 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1721 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1722 | this, SLOT( faq() ), actionCollection(), | 1722 | this, SLOT( faq() ), actionCollection(), |
1723 | "faq_about_data" ); | 1723 | "faq_about_data" ); |
1724 | 1724 | ||
1725 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1725 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1726 | this, SLOT( createAboutData() ), actionCollection(), | 1726 | this, SLOT( createAboutData() ), actionCollection(), |
1727 | "kaddressbook_about_data" ); | 1727 | "kaddressbook_about_data" ); |
1728 | #endif //KAB_EMBEDDED | 1728 | #endif //KAB_EMBEDDED |
1729 | 1729 | ||
1730 | clipboardDataChanged(); | 1730 | clipboardDataChanged(); |
1731 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1731 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1732 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1732 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1733 | } | 1733 | } |
1734 | 1734 | ||
1735 | //US we need this function, to plug all actions into the correct menues. | 1735 | //US we need this function, to plug all actions into the correct menues. |
1736 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1736 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1737 | void KABCore::addActionsManually() | 1737 | void KABCore::addActionsManually() |
1738 | { | 1738 | { |
1739 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1739 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1740 | 1740 | ||
1741 | #ifdef KAB_EMBEDDED | 1741 | #ifdef KAB_EMBEDDED |
1742 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1742 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1743 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1743 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1744 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1744 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1745 | 1745 | ||
1746 | KToolBar* tb = mMainWindow->toolBar(); | 1746 | KToolBar* tb = mMainWindow->toolBar(); |
1747 | 1747 | ||
1748 | #ifdef DESKTOP_VERSION | 1748 | #ifdef DESKTOP_VERSION |
1749 | QMenuBar* mb = mMainWindow->menuBar(); | 1749 | QMenuBar* mb = mMainWindow->menuBar(); |
1750 | 1750 | ||
1751 | //US setup menubar. | 1751 | //US setup menubar. |
1752 | //Disable the following block if you do not want to have a menubar. | 1752 | //Disable the following block if you do not want to have a menubar. |
1753 | mb->insertItem( "&File", fileMenu ); | 1753 | mb->insertItem( "&File", fileMenu ); |
1754 | mb->insertItem( "&Edit", editMenu ); | 1754 | mb->insertItem( "&Edit", editMenu ); |
1755 | mb->insertItem( "&View", viewMenu ); | 1755 | mb->insertItem( "&View", viewMenu ); |
1756 | mb->insertItem( "&Settings", settingsMenu ); | 1756 | mb->insertItem( "&Settings", settingsMenu ); |
1757 | mb->insertItem( "&Change selected", changeMenu ); | 1757 | mb->insertItem( "&Change selected", changeMenu ); |
1758 | mb->insertItem( "&Help", helpMenu ); | 1758 | mb->insertItem( "&Help", helpMenu ); |
1759 | mIncSearchWidget = new IncSearchWidget( tb ); | 1759 | mIncSearchWidget = new IncSearchWidget( tb ); |
1760 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1760 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1761 | 1761 | ||
1762 | #else | 1762 | #else |
1763 | //US setup toolbar | 1763 | //US setup toolbar |
1764 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1764 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1765 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1765 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1766 | menuBarTB->insertItem( "ME", popupBarTB); | 1766 | menuBarTB->insertItem( "ME", popupBarTB); |
1767 | tb->insertWidget(-1, 0, menuBarTB); | 1767 | tb->insertWidget(-1, 0, menuBarTB); |
1768 | mIncSearchWidget = new IncSearchWidget( tb ); | 1768 | mIncSearchWidget = new IncSearchWidget( tb ); |
1769 | 1769 | ||
1770 | tb->enableMoving(false); | 1770 | tb->enableMoving(false); |
1771 | popupBarTB->insertItem( "&File", fileMenu ); | 1771 | popupBarTB->insertItem( "&File", fileMenu ); |
1772 | popupBarTB->insertItem( "&Edit", editMenu ); | 1772 | popupBarTB->insertItem( "&Edit", editMenu ); |
1773 | popupBarTB->insertItem( "&View", viewMenu ); | 1773 | popupBarTB->insertItem( "&View", viewMenu ); |
1774 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1774 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1775 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1775 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1776 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1776 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1777 | popupBarTB->insertItem( "&Help", helpMenu ); | 1777 | popupBarTB->insertItem( "&Help", helpMenu ); |
1778 | if (QApplication::desktop()->width() > 320 ) { | 1778 | if (QApplication::desktop()->width() > 320 ) { |
1779 | // mViewManager->getFilterAction()->plug ( tb); | 1779 | // mViewManager->getFilterAction()->plug ( tb); |
1780 | } | 1780 | } |
1781 | #endif | 1781 | #endif |
1782 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1782 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1783 | 1783 | ||
1784 | 1784 | ||
1785 | 1785 | ||
1786 | //US Now connect the actions with the menue entries. | 1786 | //US Now connect the actions with the menue entries. |
1787 | mActionPrint->plug( fileMenu ); | 1787 | mActionPrint->plug( fileMenu ); |
1788 | mActionMail->plug( fileMenu ); | 1788 | mActionMail->plug( fileMenu ); |
1789 | fileMenu->insertSeparator(); | 1789 | fileMenu->insertSeparator(); |
1790 | 1790 | ||
1791 | mActionNewContact->plug( fileMenu ); | 1791 | mActionNewContact->plug( fileMenu ); |
1792 | mActionNewContact->plug( tb ); | 1792 | mActionNewContact->plug( tb ); |
1793 | 1793 | ||
1794 | mActionEditAddressee->plug( fileMenu ); | 1794 | mActionEditAddressee->plug( fileMenu ); |
1795 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1795 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1796 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1796 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1797 | mActionEditAddressee->plug( tb ); | 1797 | mActionEditAddressee->plug( tb ); |
1798 | 1798 | ||
1799 | fileMenu->insertSeparator(); | 1799 | fileMenu->insertSeparator(); |
1800 | mActionSave->plug( fileMenu ); | 1800 | mActionSave->plug( fileMenu ); |
1801 | fileMenu->insertItem( "&Import", ImportMenu ); | 1801 | fileMenu->insertItem( "&Import", ImportMenu ); |
1802 | fileMenu->insertItem( "&Emport", ExportMenu ); | 1802 | fileMenu->insertItem( "&Emport", ExportMenu ); |
1803 | fileMenu->insertSeparator(); | 1803 | fileMenu->insertSeparator(); |
1804 | mActionMailVCard->plug( fileMenu ); | 1804 | mActionMailVCard->plug( fileMenu ); |
1805 | #ifndef DESKTOP_VERSION | 1805 | #ifndef DESKTOP_VERSION |
1806 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1806 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1807 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1807 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1808 | #endif | 1808 | #endif |
1809 | fileMenu->insertSeparator(); | 1809 | fileMenu->insertSeparator(); |
1810 | mActionQuit->plug( fileMenu ); | 1810 | mActionQuit->plug( fileMenu ); |
1811 | #ifdef _WIN32_ | 1811 | #ifdef _WIN32_ |
1812 | mActionImportOL->plug( ImportMenu ); | 1812 | mActionImportOL->plug( ImportMenu ); |
1813 | #endif | 1813 | #endif |
1814 | // edit menu | 1814 | // edit menu |
1815 | mActionUndo->plug( editMenu ); | 1815 | mActionUndo->plug( editMenu ); |
1816 | mActionRedo->plug( editMenu ); | 1816 | mActionRedo->plug( editMenu ); |
1817 | editMenu->insertSeparator(); | 1817 | editMenu->insertSeparator(); |
1818 | mActionCut->plug( editMenu ); | 1818 | mActionCut->plug( editMenu ); |
1819 | mActionCopy->plug( editMenu ); | 1819 | mActionCopy->plug( editMenu ); |
1820 | mActionPaste->plug( editMenu ); | 1820 | mActionPaste->plug( editMenu ); |
1821 | mActionDelete->plug( editMenu ); | 1821 | mActionDelete->plug( editMenu ); |
1822 | editMenu->insertSeparator(); | 1822 | editMenu->insertSeparator(); |
1823 | mActionSelectAll->plug( editMenu ); | 1823 | mActionSelectAll->plug( editMenu ); |
1824 | 1824 | ||
1825 | mActionRemoveVoice->plug( changeMenu ); | 1825 | mActionRemoveVoice->plug( changeMenu ); |
1826 | // settings menu | 1826 | // settings menu |
1827 | //US special menuentry to configure the addressbook resources. On KDE | 1827 | //US special menuentry to configure the addressbook resources. On KDE |
1828 | // you do that through the control center !!! | 1828 | // you do that through the control center !!! |
1829 | mActionConfigResources->plug( settingsMenu ); | 1829 | mActionConfigResources->plug( settingsMenu ); |
1830 | settingsMenu->insertSeparator(); | 1830 | settingsMenu->insertSeparator(); |
1831 | 1831 | ||
1832 | mActionConfigKAddressbook->plug( settingsMenu ); | 1832 | mActionConfigKAddressbook->plug( settingsMenu ); |
1833 | 1833 | ||
1834 | if ( mIsPart ) { | 1834 | if ( mIsPart ) { |
1835 | mActionConfigShortcuts->plug( settingsMenu ); | 1835 | mActionConfigShortcuts->plug( settingsMenu ); |
1836 | mActionConfigureToolbars->plug( settingsMenu ); | 1836 | mActionConfigureToolbars->plug( settingsMenu ); |
1837 | 1837 | ||
1838 | } else { | 1838 | } else { |
1839 | mActionKeyBindings->plug( settingsMenu ); | 1839 | mActionKeyBindings->plug( settingsMenu ); |
1840 | } | 1840 | } |
1841 | 1841 | ||
1842 | settingsMenu->insertSeparator(); | 1842 | settingsMenu->insertSeparator(); |
1843 | 1843 | ||
1844 | mActionJumpBar->plug( settingsMenu ); | 1844 | mActionJumpBar->plug( settingsMenu ); |
1845 | mActionDetails->plug( settingsMenu ); | 1845 | mActionDetails->plug( settingsMenu ); |
1846 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 1846 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1847 | mActionDetails->plug( tb ); | 1847 | mActionDetails->plug( tb ); |
1848 | settingsMenu->insertSeparator(); | 1848 | settingsMenu->insertSeparator(); |
1849 | 1849 | ||
1850 | mActionWhoAmI->plug( settingsMenu ); | 1850 | mActionWhoAmI->plug( settingsMenu ); |
1851 | mActionCategories->plug( settingsMenu ); | 1851 | mActionCategories->plug( settingsMenu ); |
1852 | 1852 | ||
1853 | mActionLicence->plug( helpMenu ); | 1853 | mActionLicence->plug( helpMenu ); |
1854 | mActionFaq->plug( helpMenu ); | 1854 | mActionFaq->plug( helpMenu ); |
1855 | mActionAboutKAddressbook->plug( helpMenu ); | 1855 | mActionAboutKAddressbook->plug( helpMenu ); |
1856 | 1856 | ||
1857 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1857 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1858 | 1858 | ||
1859 | mActionSave->plug( tb ); | 1859 | mActionSave->plug( tb ); |
1860 | mViewManager->getFilterAction()->plug ( tb); | 1860 | mViewManager->getFilterAction()->plug ( tb); |
1861 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1861 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1862 | mActionUndo->plug( tb ); | 1862 | mActionUndo->plug( tb ); |
1863 | mActionDelete->plug( tb ); | 1863 | mActionDelete->plug( tb ); |
1864 | mActionRedo->plug( tb ); | 1864 | mActionRedo->plug( tb ); |
1865 | } | 1865 | } |
1866 | } | 1866 | } |
1867 | //mActionQuit->plug ( tb ); | 1867 | //mActionQuit->plug ( tb ); |
1868 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1868 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1869 | 1869 | ||
1870 | //US link the searchwidget first to this. | 1870 | //US link the searchwidget first to this. |
1871 | // The real linkage to the toolbar happens later. | 1871 | // The real linkage to the toolbar happens later. |
1872 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1872 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1873 | //US tb->insertItem( mIncSearchWidget ); | 1873 | //US tb->insertItem( mIncSearchWidget ); |
1874 | /*US | 1874 | /*US |
1875 | mIncSearchWidget = new IncSearchWidget( tb ); | 1875 | mIncSearchWidget = new IncSearchWidget( tb ); |
1876 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1876 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1877 | SLOT( incrementalSearch( const QString& ) ) ); | 1877 | SLOT( incrementalSearch( const QString& ) ) ); |
1878 | 1878 | ||
1879 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1879 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1880 | 1880 | ||
1881 | //US topLayout->addWidget( mJumpButtonBar ); | 1881 | //US topLayout->addWidget( mJumpButtonBar ); |
1882 | this->layout()->add( mJumpButtonBar ); | 1882 | this->layout()->add( mJumpButtonBar ); |
1883 | */ | 1883 | */ |
1884 | 1884 | ||
1885 | #endif //KAB_EMBEDDED | 1885 | #endif //KAB_EMBEDDED |
1886 | } | 1886 | } |
1887 | void KABCore::showLicence() | 1887 | void KABCore::showLicence() |
1888 | { | 1888 | { |
1889 | KApplication::showLicence(); | 1889 | KApplication::showLicence(); |
1890 | } | 1890 | } |
1891 | void KABCore::removeVoice() | 1891 | void KABCore::removeVoice() |
1892 | { | 1892 | { |
1893 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 1893 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
1894 | return; | 1894 | return; |
1895 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1895 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1896 | KABC::Addressee::List::Iterator it; | 1896 | KABC::Addressee::List::Iterator it; |
1897 | for ( it = list.begin(); it != list.end(); ++it ) { | 1897 | for ( it = list.begin(); it != list.end(); ++it ) { |
1898 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1898 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1899 | PhoneNumber::List::Iterator phoneIt; | 1899 | PhoneNumber::List::Iterator phoneIt; |
1900 | bool found = false; | 1900 | bool found = false; |
1901 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1901 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1902 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1902 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1903 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1903 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1904 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1904 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1905 | (*it).insertPhoneNumber( (*phoneIt) ); | 1905 | (*it).insertPhoneNumber( (*phoneIt) ); |
1906 | found = true; | 1906 | found = true; |
1907 | } | 1907 | } |
1908 | } | 1908 | } |
1909 | 1909 | ||
1910 | } | 1910 | } |
1911 | if ( found ) | 1911 | if ( found ) |
1912 | contactModified((*it) ); | 1912 | contactModified((*it) ); |
1913 | } | 1913 | } |
1914 | } | 1914 | } |
1915 | 1915 | ||
1916 | 1916 | ||
1917 | 1917 | ||
1918 | void KABCore::clipboardDataChanged() | 1918 | void KABCore::clipboardDataChanged() |
1919 | { | 1919 | { |
1920 | 1920 | ||
1921 | if ( mReadWrite ) | 1921 | if ( mReadWrite ) |
1922 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1922 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1923 | 1923 | ||
1924 | } | 1924 | } |
1925 | 1925 | ||
1926 | void KABCore::updateActionMenu() | 1926 | void KABCore::updateActionMenu() |
1927 | { | 1927 | { |
1928 | UndoStack *undo = UndoStack::instance(); | 1928 | UndoStack *undo = UndoStack::instance(); |
1929 | RedoStack *redo = RedoStack::instance(); | 1929 | RedoStack *redo = RedoStack::instance(); |
1930 | 1930 | ||
1931 | if ( undo->isEmpty() ) | 1931 | if ( undo->isEmpty() ) |
1932 | mActionUndo->setText( i18n( "Undo" ) ); | 1932 | mActionUndo->setText( i18n( "Undo" ) ); |
1933 | else | 1933 | else |
1934 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1934 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1935 | 1935 | ||
1936 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1936 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1937 | 1937 | ||
1938 | if ( !redo->top() ) | 1938 | if ( !redo->top() ) |
1939 | mActionRedo->setText( i18n( "Redo" ) ); | 1939 | mActionRedo->setText( i18n( "Redo" ) ); |
1940 | else | 1940 | else |
1941 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1941 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1942 | 1942 | ||
1943 | mActionRedo->setEnabled( !redo->isEmpty() ); | 1943 | mActionRedo->setEnabled( !redo->isEmpty() ); |
1944 | } | 1944 | } |
1945 | 1945 | ||
1946 | void KABCore::configureKeyBindings() | 1946 | void KABCore::configureKeyBindings() |
1947 | { | 1947 | { |
1948 | #ifndef KAB_EMBEDDED | 1948 | #ifndef KAB_EMBEDDED |
1949 | KKeyDialog::configure( actionCollection(), true ); | 1949 | KKeyDialog::configure( actionCollection(), true ); |
1950 | #else //KAB_EMBEDDED | 1950 | #else //KAB_EMBEDDED |
1951 | qDebug("KABCore::configureKeyBindings() not implemented"); | 1951 | qDebug("KABCore::configureKeyBindings() not implemented"); |
1952 | #endif //KAB_EMBEDDED | 1952 | #endif //KAB_EMBEDDED |
1953 | } | 1953 | } |
1954 | 1954 | ||
1955 | #ifdef KAB_EMBEDDED | 1955 | #ifdef KAB_EMBEDDED |
1956 | void KABCore::configureResources() | 1956 | void KABCore::configureResources() |
1957 | { | 1957 | { |
1958 | KRES::KCMKResources dlg( this, "" , 0 ); | 1958 | KRES::KCMKResources dlg( this, "" , 0 ); |
1959 | 1959 | ||
1960 | if ( !dlg.exec() ) | 1960 | if ( !dlg.exec() ) |
1961 | return; | 1961 | return; |
1962 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 1962 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
1963 | } | 1963 | } |
1964 | #endif //KAB_EMBEDDED | 1964 | #endif //KAB_EMBEDDED |
1965 | 1965 | ||
1966 | 1966 | ||
1967 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 1967 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
1968 | * for the attendees list of an event. | 1968 | * for the attendees list of an event. |
1969 | */ | 1969 | */ |
1970 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 1970 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
1971 | { | 1971 | { |
1972 | QStringList nameList; | 1972 | QStringList nameList; |
1973 | QStringList emailList; | 1973 | QStringList emailList; |
1974 | QStringList uidList; | 1974 | QStringList uidList; |
1975 | 1975 | ||
1976 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 1976 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
1977 | uint i=0; | 1977 | uint i=0; |
1978 | for (i=0; i < list.count(); i++) | 1978 | for (i=0; i < list.count(); i++) |
1979 | { | 1979 | { |
1980 | nameList.append(list[i].realName()); | 1980 | nameList.append(list[i].realName()); |
1981 | emailList.append(list[i].preferredEmail()); | 1981 | emailList.append(list[i].preferredEmail()); |
1982 | uidList.append(list[i].uid()); | 1982 | uidList.append(list[i].uid()); |
1983 | } | 1983 | } |
1984 | 1984 | ||
1985 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 1985 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
1986 | 1986 | ||
1987 | } | 1987 | } |
1988 | 1988 | ||
1989 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 1989 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
1990 | */ | 1990 | */ |
1991 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 1991 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
1992 | { | 1992 | { |
1993 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 1993 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
1994 | 1994 | ||
1995 | QString foundUid = QString::null; | 1995 | QString foundUid = QString::null; |
1996 | if ( ! uid.isEmpty() ) { | 1996 | if ( ! uid.isEmpty() ) { |
1997 | Addressee adrr = mAddressBook->findByUid( uid ); | 1997 | Addressee adrr = mAddressBook->findByUid( uid ); |
1998 | if ( !adrr.isEmpty() ) { | 1998 | if ( !adrr.isEmpty() ) { |
1999 | foundUid = uid; | 1999 | foundUid = uid; |
2000 | } | 2000 | } |
2001 | if ( email == "sendbacklist" ) { | 2001 | if ( email == "sendbacklist" ) { |
2002 | //qDebug("ssssssssssssssssssssssend "); | 2002 | //qDebug("ssssssssssssssssssssssend "); |
2003 | QStringList nameList; | 2003 | QStringList nameList; |
2004 | QStringList emailList; | 2004 | QStringList emailList; |
2005 | QStringList uidList; | 2005 | QStringList uidList; |
2006 | nameList.append(adrr.realName()); | 2006 | nameList.append(adrr.realName()); |
2007 | emailList = adrr.emails(); | 2007 | emailList = adrr.emails(); |
2008 | uidList.append( adrr.preferredEmail()); | 2008 | uidList.append( adrr.preferredEmail()); |
2009 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2009 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2010 | return; | 2010 | return; |
2011 | } | 2011 | } |
2012 | 2012 | ||
2013 | } | 2013 | } |
2014 | 2014 | ||
2015 | if ( email == "sendbacklist" ) | 2015 | if ( email == "sendbacklist" ) |
2016 | return; | 2016 | return; |
2017 | if (foundUid.isEmpty()) | 2017 | if (foundUid.isEmpty()) |
2018 | { | 2018 | { |
2019 | //find the uid of the person first | 2019 | //find the uid of the person first |
2020 | Addressee::List namelist; | 2020 | Addressee::List namelist; |
2021 | Addressee::List emaillist; | 2021 | Addressee::List emaillist; |
2022 | 2022 | ||
2023 | if (!name.isEmpty()) | 2023 | if (!name.isEmpty()) |
2024 | namelist = mAddressBook->findByName( name ); | 2024 | namelist = mAddressBook->findByName( name ); |
2025 | 2025 | ||
2026 | if (!email.isEmpty()) | 2026 | if (!email.isEmpty()) |
2027 | emaillist = mAddressBook->findByEmail( email ); | 2027 | emaillist = mAddressBook->findByEmail( email ); |
2028 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2028 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2029 | //check if we have a match in Namelist and Emaillist | 2029 | //check if we have a match in Namelist and Emaillist |
2030 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2030 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2031 | foundUid = emaillist[0].uid(); | 2031 | foundUid = emaillist[0].uid(); |
2032 | } | 2032 | } |
2033 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2033 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2034 | foundUid = namelist[0].uid(); | 2034 | foundUid = namelist[0].uid(); |
2035 | else | 2035 | else |
2036 | { | 2036 | { |
2037 | for (int i = 0; i < namelist.count(); i++) | 2037 | for (int i = 0; i < namelist.count(); i++) |
2038 | { | 2038 | { |
2039 | for (int j = 0; j < emaillist.count(); j++) | 2039 | for (int j = 0; j < emaillist.count(); j++) |
2040 | { | 2040 | { |
2041 | if (namelist[i] == emaillist[j]) | 2041 | if (namelist[i] == emaillist[j]) |
2042 | { | 2042 | { |
2043 | foundUid = namelist[i].uid(); | 2043 | foundUid = namelist[i].uid(); |
2044 | } | 2044 | } |
2045 | } | 2045 | } |
2046 | } | 2046 | } |
2047 | } | 2047 | } |
2048 | } | 2048 | } |
2049 | else | 2049 | else |
2050 | { | 2050 | { |
2051 | foundUid = uid; | 2051 | foundUid = uid; |
2052 | } | 2052 | } |
2053 | 2053 | ||
2054 | if (!foundUid.isEmpty()) | 2054 | if (!foundUid.isEmpty()) |
2055 | { | 2055 | { |
2056 | 2056 | ||
2057 | // raise Ka/Pi if it is in the background | 2057 | // raise Ka/Pi if it is in the background |
2058 | #ifndef DESKTOP_VERSION | 2058 | #ifndef DESKTOP_VERSION |
2059 | #ifndef KORG_NODCOP | 2059 | #ifndef KORG_NODCOP |
2060 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2060 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2061 | #endif | 2061 | #endif |
2062 | #endif | 2062 | #endif |
2063 | 2063 | ||
2064 | mMainWindow->showMaximized(); | 2064 | mMainWindow->showMaximized(); |
2065 | mMainWindow-> raise(); | 2065 | mMainWindow-> raise(); |
2066 | 2066 | ||
2067 | mViewManager->setSelected( "", false); | 2067 | mViewManager->setSelected( "", false); |
2068 | mViewManager->refreshView( "" ); | 2068 | mViewManager->refreshView( "" ); |
2069 | mViewManager->setSelected( foundUid, true ); | 2069 | mViewManager->setSelected( foundUid, true ); |
2070 | mViewManager->refreshView( foundUid ); | 2070 | mViewManager->refreshView( foundUid ); |
2071 | 2071 | ||
2072 | if ( !mMultipleViewsAtOnce ) | 2072 | if ( !mMultipleViewsAtOnce ) |
2073 | { | 2073 | { |
2074 | setDetailsVisible( true ); | 2074 | setDetailsVisible( true ); |
2075 | mActionDetails->setChecked(true); | 2075 | mActionDetails->setChecked(true); |
2076 | } | 2076 | } |
2077 | } | 2077 | } |
2078 | } | 2078 | } |
2079 | 2079 | ||
2080 | 2080 | ||
2081 | void KABCore::faq() | 2081 | void KABCore::faq() |
2082 | { | 2082 | { |
2083 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2083 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2084 | } | 2084 | } |
2085 | 2085 | ||
2086 | 2086 | ||
2087 | 2087 | ||
2088 | 2088 | ||
2089 | #ifndef KAB_EMBEDDED | 2089 | #ifndef KAB_EMBEDDED |
2090 | #include "kabcore.moc" | 2090 | #include "kabcore.moc" |
2091 | #endif //KAB_EMBEDDED | 2091 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index 2425158..552c933 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp | |||
@@ -1,130 +1,132 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | //US#ifdef KAB_EMBEDDED | 24 | //US#ifdef KAB_EMBEDDED |
25 | //#include <qstring.h> | 25 | //#include <qstring.h> |
26 | //#endif //KAB_EMBEDDED | 26 | //#endif //KAB_EMBEDDED |
27 | 27 | ||
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | #include <kstaticdeleter.h> | 31 | #include <kstaticdeleter.h> |
32 | //US#include <kdebug.h> // defines kdDebug() | 32 | //US#include <kdebug.h> // defines kdDebug() |
33 | 33 | ||
34 | #include "kabprefs.h" | 34 | #include "kabprefs.h" |
35 | 35 | ||
36 | KABPrefs *KABPrefs::sInstance = 0; | 36 | KABPrefs *KABPrefs::sInstance = 0; |
37 | static KStaticDeleter<KABPrefs> staticDeleter; | 37 | static KStaticDeleter<KABPrefs> staticDeleter; |
38 | 38 | ||
39 | KABPrefs::KABPrefs() | 39 | KABPrefs::KABPrefs() |
40 | : KPimPrefs("kaddressbookrc") | 40 | : KPimPrefs("kaddressbookrc") |
41 | { | 41 | { |
42 | KPrefs::setCurrentGroup( "Views" ); | 42 | KPrefs::setCurrentGroup( "Views" ); |
43 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); | 43 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); |
44 | 44 | ||
45 | KPrefs::setCurrentGroup( "General" ); | 45 | KPrefs::setCurrentGroup( "General" ); |
46 | addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); | 46 | addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); |
47 | addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); | 47 | addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); |
48 | 48 | ||
49 | #ifdef KAB_EMBEDDED | 49 | #ifdef KAB_EMBEDDED |
50 | addItemBool("AskForQuit",&mAskForQuit,true); | 50 | addItemBool("AskForQuit",&mAskForQuit,true); |
51 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 51 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
52 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 52 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
53 | addItemBool("SearchWithReturn",&mSearchWithReturn, true ); | ||
54 | |||
53 | 55 | ||
54 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
55 | 57 | ||
56 | KPrefs::setCurrentGroup( "MainWindow" ); | 58 | KPrefs::setCurrentGroup( "MainWindow" ); |
57 | addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); | 59 | addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); |
58 | addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); | 60 | addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); |
59 | addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); | 61 | addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); |
60 | addItemIntList( "DetailsSplitter", &mDetailsSplitter ); | 62 | addItemIntList( "DetailsSplitter", &mDetailsSplitter ); |
61 | addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); | 63 | addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); |
62 | 64 | ||
63 | 65 | ||
64 | KPrefs::setCurrentGroup( "Extensions_General" ); | 66 | KPrefs::setCurrentGroup( "Extensions_General" ); |
65 | QStringList defaultExtensions; | 67 | QStringList defaultExtensions; |
66 | defaultExtensions << "merge"; | 68 | defaultExtensions << "merge"; |
67 | defaultExtensions << "distribution_list_editor"; | 69 | defaultExtensions << "distribution_list_editor"; |
68 | addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); | 70 | addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); |
69 | addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); | 71 | addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); |
70 | 72 | ||
71 | KPrefs::setCurrentGroup( "Views" ); | 73 | KPrefs::setCurrentGroup( "Views" ); |
72 | QString defaultView = i18n( "Default Table View" ); | 74 | QString defaultView = i18n( "Default Table View" ); |
73 | addItemString( "CurrentView", &mCurrentView, defaultView ); | 75 | addItemString( "CurrentView", &mCurrentView, defaultView ); |
74 | addItemStringList( "ViewNames", &mViewNames, defaultView ); | 76 | addItemStringList( "ViewNames", &mViewNames, defaultView ); |
75 | 77 | ||
76 | KPrefs::setCurrentGroup( "Filters" ); | 78 | KPrefs::setCurrentGroup( "Filters" ); |
77 | addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); | 79 | addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); |
78 | 80 | ||
79 | } | 81 | } |
80 | 82 | ||
81 | KABPrefs::~KABPrefs() | 83 | KABPrefs::~KABPrefs() |
82 | { | 84 | { |
83 | } | 85 | } |
84 | 86 | ||
85 | KABPrefs *KABPrefs::instance() | 87 | KABPrefs *KABPrefs::instance() |
86 | { | 88 | { |
87 | if ( !sInstance ) { | 89 | if ( !sInstance ) { |
88 | #ifdef KAB_EMBEDDED | 90 | #ifdef KAB_EMBEDDED |
89 | sInstance = staticDeleter.setObject( new KABPrefs() ); | 91 | sInstance = staticDeleter.setObject( new KABPrefs() ); |
90 | #else //KAB_EMBEDDED | 92 | #else //KAB_EMBEDDED |
91 | //US the following line has changed ???. Why | 93 | //US the following line has changed ???. Why |
92 | staticDeleter.setObject( sInstance, new KABPrefs() ); | 94 | staticDeleter.setObject( sInstance, new KABPrefs() ); |
93 | #endif //KAB_EMBEDDED | 95 | #endif //KAB_EMBEDDED |
94 | sInstance->readConfig(); | 96 | sInstance->readConfig(); |
95 | } | 97 | } |
96 | 98 | ||
97 | return sInstance; | 99 | return sInstance; |
98 | } | 100 | } |
99 | 101 | ||
100 | void KABPrefs::setCategoryDefaults() | 102 | void KABPrefs::setCategoryDefaults() |
101 | { | 103 | { |
102 | mCustomCategories.clear(); | 104 | mCustomCategories.clear(); |
103 | 105 | ||
104 | mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) | 106 | mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) |
105 | << i18n( "Customer" ) << i18n( "Friend" ); | 107 | << i18n( "Customer" ) << i18n( "Friend" ); |
106 | } | 108 | } |
107 | 109 | ||
108 | // US introduce a nonconst way to return the config object. | 110 | // US introduce a nonconst way to return the config object. |
109 | KConfig* KABPrefs::getConfig() | 111 | KConfig* KABPrefs::getConfig() |
110 | { | 112 | { |
111 | return config(); | 113 | return config(); |
112 | } | 114 | } |
113 | 115 | ||
114 | 116 | ||
115 | /*US | 117 | /*US |
116 | void KABPrefs::usrSetDefaults() | 118 | void KABPrefs::usrSetDefaults() |
117 | { | 119 | { |
118 | KPimPrefs::usrSetDefaults(); | 120 | KPimPrefs::usrSetDefaults(); |
119 | } | 121 | } |
120 | 122 | ||
121 | void KABPrefs::usrReadConfig() | 123 | void KABPrefs::usrReadConfig() |
122 | { | 124 | { |
123 | KPimPrefs::usrReadConfig(); | 125 | KPimPrefs::usrReadConfig(); |
124 | } | 126 | } |
125 | 127 | ||
126 | void KABPrefs::usrWriteConfig() | 128 | void KABPrefs::usrWriteConfig() |
127 | { | 129 | { |
128 | KPimPrefs::usrWriteConfig(); | 130 | KPimPrefs::usrWriteConfig(); |
129 | } | 131 | } |
130 | */ | 132 | */ |
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h index 03e529f..e4f359c 100644 --- a/kaddressbook/kabprefs.h +++ b/kaddressbook/kabprefs.h | |||
@@ -1,91 +1,92 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KABPREFS_H | 24 | #ifndef KABPREFS_H |
25 | #define KABPREFS_H | 25 | #define KABPREFS_H |
26 | 26 | ||
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | 28 | ||
29 | #include <libkdepim/kpimprefs.h> | 29 | #include <libkdepim/kpimprefs.h> |
30 | 30 | ||
31 | class KConfig; | 31 | class KConfig; |
32 | 32 | ||
33 | class KABPrefs : public KPimPrefs | 33 | class KABPrefs : public KPimPrefs |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | virtual ~KABPrefs(); | 36 | virtual ~KABPrefs(); |
37 | 37 | ||
38 | static KABPrefs *instance(); | 38 | static KABPrefs *instance(); |
39 | 39 | ||
40 | // General | 40 | // General |
41 | bool mHonorSingleClick; | 41 | bool mHonorSingleClick; |
42 | bool mAutomaticNameParsing; | 42 | bool mAutomaticNameParsing; |
43 | int mCurrentIncSearchField; | 43 | int mCurrentIncSearchField; |
44 | 44 | ||
45 | #ifdef KAB_EMBEDDED | 45 | #ifdef KAB_EMBEDDED |
46 | // US introduce a nonconst way to return the config object. | 46 | // US introduce a nonconst way to return the config object. |
47 | KConfig* getConfig(); | 47 | KConfig* getConfig(); |
48 | 48 | ||
49 | bool mToolBarHor; | 49 | bool mToolBarHor; |
50 | bool mToolBarUp; | 50 | bool mToolBarUp; |
51 | bool mAskForQuit; | 51 | bool mAskForQuit; |
52 | 52 | ||
53 | 53 | ||
54 | /** Set preferences to default values */ | 54 | /** Set preferences to default values */ |
55 | // void usrSetDefaults(); | 55 | // void usrSetDefaults(); |
56 | 56 | ||
57 | /** Read preferences from config file */ | 57 | /** Read preferences from config file */ |
58 | // void usrReadConfig(); | 58 | // void usrReadConfig(); |
59 | 59 | ||
60 | /** Write preferences to config file */ | 60 | /** Write preferences to config file */ |
61 | // void usrWriteConfig(); | 61 | // void usrWriteConfig(); |
62 | #endif //KAB_EMBEDDED | 62 | #endif //KAB_EMBEDDED |
63 | 63 | ||
64 | 64 | ||
65 | // GUI | 65 | // GUI |
66 | bool mJumpButtonBarVisible; | 66 | bool mJumpButtonBarVisible; |
67 | bool mDetailsPageVisible; | 67 | bool mDetailsPageVisible; |
68 | bool mMultipleViewsAtOnce; | 68 | bool mMultipleViewsAtOnce; |
69 | bool mSearchWithReturn; | ||
69 | QValueList<int> mExtensionsSplitter; | 70 | QValueList<int> mExtensionsSplitter; |
70 | QValueList<int> mDetailsSplitter; | 71 | QValueList<int> mDetailsSplitter; |
71 | 72 | ||
72 | // Extensions stuff | 73 | // Extensions stuff |
73 | int mCurrentExtension; | 74 | int mCurrentExtension; |
74 | QStringList mActiveExtensions; | 75 | QStringList mActiveExtensions; |
75 | 76 | ||
76 | // Views stuff | 77 | // Views stuff |
77 | QString mCurrentView; | 78 | QString mCurrentView; |
78 | QStringList mViewNames; | 79 | QStringList mViewNames; |
79 | 80 | ||
80 | // Filter | 81 | // Filter |
81 | int mCurrentFilter; | 82 | int mCurrentFilter; |
82 | 83 | ||
83 | void setCategoryDefaults(); | 84 | void setCategoryDefaults(); |
84 | 85 | ||
85 | private: | 86 | private: |
86 | KABPrefs(); | 87 | KABPrefs(); |
87 | 88 | ||
88 | static KABPrefs *sInstance; | 89 | static KABPrefs *sInstance; |
89 | }; | 90 | }; |
90 | 91 | ||
91 | #endif | 92 | #endif |
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp index 3a2ccbb..0c3a199 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp +++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp | |||
@@ -1,397 +1,403 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | 35 | ||
36 | #include <kconfig.h> | 36 | #include <kconfig.h> |
37 | #include <kdebug.h> | 37 | #include <kdebug.h> |
38 | #include <kdialog.h> | 38 | #include <kdialog.h> |
39 | #include <klistview.h> | 39 | #include <klistview.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kglobal.h> | 41 | #include <kglobal.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <ktrader.h> | 46 | #include <ktrader.h> |
47 | #else // KAB_EMBEDDED | 47 | #else // KAB_EMBEDDED |
48 | #include <mergewidget.h> | 48 | #include <mergewidget.h> |
49 | #include <distributionlistwidget.h> | 49 | #include <distributionlistwidget.h> |
50 | #endif // KAB_EMBEDDED | 50 | #endif // KAB_EMBEDDED |
51 | 51 | ||
52 | #include "addresseewidget.h" | 52 | #include "addresseewidget.h" |
53 | #include "extensionconfigdialog.h" | 53 | #include "extensionconfigdialog.h" |
54 | #include "extensionwidget.h" | 54 | #include "extensionwidget.h" |
55 | #include "kabprefs.h" | 55 | #include "kabprefs.h" |
56 | 56 | ||
57 | #include "kabconfigwidget.h" | 57 | #include "kabconfigwidget.h" |
58 | 58 | ||
59 | class ExtensionItem : public QCheckListItem | 59 | class ExtensionItem : public QCheckListItem |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | 62 | ||
63 | #ifndef KAB_EMBEDDED | 63 | #ifndef KAB_EMBEDDED |
64 | ExtensionItem( QListView *parent, const QString &text ); | 64 | ExtensionItem( QListView *parent, const QString &text ); |
65 | void setService( const KService::Ptr &ptr ); | 65 | void setService( const KService::Ptr &ptr ); |
66 | #else //KAB_EMBEDDED | 66 | #else //KAB_EMBEDDED |
67 | ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); | 67 | ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); |
68 | void setFactory( ExtensionFactory* fac ); | 68 | void setFactory( ExtensionFactory* fac ); |
69 | #endif //KAB_EMBEDDED | 69 | #endif //KAB_EMBEDDED |
70 | 70 | ||
71 | bool configWidgetAvailable() const; | 71 | bool configWidgetAvailable() const; |
72 | ExtensionFactory *factory() const; | 72 | ExtensionFactory *factory() const; |
73 | 73 | ||
74 | virtual QString text( int column ) const; | 74 | virtual QString text( int column ) const; |
75 | 75 | ||
76 | private: | 76 | private: |
77 | #ifndef KAB_EMBEDDED | 77 | #ifndef KAB_EMBEDDED |
78 | KService::Ptr mPtr; | 78 | KService::Ptr mPtr; |
79 | #else //KAB_EMBEDDED | 79 | #else //KAB_EMBEDDED |
80 | ExtensionFactory* mFactory; | 80 | ExtensionFactory* mFactory; |
81 | QString mName; | 81 | QString mName; |
82 | QString mComment; | 82 | QString mComment; |
83 | 83 | ||
84 | #endif //KAB_EMBEDDED | 84 | #endif //KAB_EMBEDDED |
85 | 85 | ||
86 | }; | 86 | }; |
87 | 87 | ||
88 | KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) | 88 | KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) |
89 | : QWidget( parent, name ) | 89 | : QWidget( parent, name ) |
90 | { | 90 | { |
91 | QVBoxLayout *topLayout = new QVBoxLayout( this, 0, | 91 | QVBoxLayout *topLayout = new QVBoxLayout( this, 0, |
92 | KDialog::spacingHint() ); | 92 | KDialog::spacingHint() ); |
93 | 93 | ||
94 | QTabWidget *tabWidget = new QTabWidget( this ); | 94 | QTabWidget *tabWidget = new QTabWidget( this ); |
95 | topLayout->addWidget( tabWidget ); | 95 | topLayout->addWidget( tabWidget ); |
96 | 96 | ||
97 | // General page | 97 | // General page |
98 | QWidget *generalPage = new QWidget( this ); | 98 | QWidget *generalPage = new QWidget( this ); |
99 | QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), | 99 | QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), |
100 | KDialog::spacingHintSmall() ); | 100 | KDialog::spacingHintSmall() ); |
101 | //general groupbox | 101 | //general groupbox |
102 | QVBox *vBox = new QVBox( generalPage, "qvbox" ); | 102 | QVBox *vBox = new QVBox( generalPage, "qvbox" ); |
103 | QVBoxLayout *boxLayout = new QVBoxLayout( vBox->layout(), -1, "qvboxlayout" ); | 103 | QVBoxLayout *boxLayout = new QVBoxLayout( vBox->layout(), -1, "qvboxlayout" ); |
104 | boxLayout->setAlignment( Qt::AlignTop ); | 104 | boxLayout->setAlignment( Qt::AlignTop ); |
105 | boxLayout->setMargin(KDialog::marginHintSmall() ); | 105 | boxLayout->setMargin(KDialog::marginHintSmall() ); |
106 | vBox->layout()->setMargin(KDialog::marginHintSmall()) ; | 106 | vBox->layout()->setMargin(KDialog::marginHintSmall()) ; |
107 | vBox->layout()->setSpacing(KDialog::spacingHintSmall()); | 107 | vBox->layout()->setSpacing(KDialog::spacingHintSmall()); |
108 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); | 108 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); |
109 | mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); | ||
110 | boxLayout->addWidget( mSearchReturnBox ); | ||
109 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); | 111 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); |
110 | boxLayout->addWidget( mViewsSingleClickBox ); | 112 | boxLayout->addWidget( mViewsSingleClickBox ); |
111 | 113 | ||
112 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); | 114 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); |
113 | boxLayout->addWidget( mNameParsing ); | 115 | boxLayout->addWidget( mNameParsing ); |
114 | 116 | ||
115 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); | 117 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); |
116 | boxLayout->addWidget( mMultipleViewsAtOnce ); | 118 | boxLayout->addWidget( mMultipleViewsAtOnce ); |
117 | 119 | ||
118 | mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); | 120 | mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); |
119 | boxLayout->addWidget( mAskForQuit ); | 121 | boxLayout->addWidget( mAskForQuit ); |
120 | 122 | ||
121 | layout->addWidget( vBox ); | 123 | layout->addWidget( vBox ); |
122 | 124 | ||
123 | tabWidget->addTab( generalPage, i18n( "General" ) ); | 125 | tabWidget->addTab( generalPage, i18n( "General" ) ); |
124 | 126 | ||
125 | // Extension page | 127 | // Extension page |
126 | QWidget *extensionPage = new QWidget( this ); | 128 | QWidget *extensionPage = new QWidget( this ); |
127 | QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), | 129 | QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), |
128 | KDialog::spacingHintSmall() ); | 130 | KDialog::spacingHintSmall() ); |
129 | 131 | ||
130 | //extensions groupbox | 132 | //extensions groupbox |
131 | 133 | ||
132 | QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); | 134 | QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); |
133 | boxLayout = new QVBoxLayout( groupBox->layout() ); | 135 | boxLayout = new QVBoxLayout( groupBox->layout() ); |
134 | boxLayout->setAlignment( Qt::AlignTop ); | 136 | boxLayout->setAlignment( Qt::AlignTop ); |
135 | boxLayout->setMargin(KDialog::marginHintSmall()); | 137 | boxLayout->setMargin(KDialog::marginHintSmall()); |
136 | boxLayout->setSpacing(KDialog::spacingHintSmall()); | 138 | boxLayout->setSpacing(KDialog::spacingHintSmall()); |
137 | groupBox->layout()->setMargin(1) ; | 139 | groupBox->layout()->setMargin(1) ; |
138 | groupBox->layout()->setSpacing(0); | 140 | groupBox->layout()->setSpacing(0); |
139 | mExtensionView = new KListView( groupBox ); | 141 | mExtensionView = new KListView( groupBox ); |
140 | mExtensionView->setAllColumnsShowFocus( true ); | 142 | mExtensionView->setAllColumnsShowFocus( true ); |
141 | mExtensionView->addColumn( i18n( "Name" ) ); | 143 | mExtensionView->addColumn( i18n( "Name" ) ); |
142 | mExtensionView->addColumn( i18n( "Description" ) ); | 144 | mExtensionView->addColumn( i18n( "Description" ) ); |
143 | mExtensionView->setMaximumHeight(80); | 145 | mExtensionView->setMaximumHeight(80); |
144 | 146 | ||
145 | boxLayout->addWidget( mExtensionView ); | 147 | boxLayout->addWidget( mExtensionView ); |
146 | 148 | ||
147 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); | 149 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); |
148 | mConfigureButton->setEnabled( false ); | 150 | mConfigureButton->setEnabled( false ); |
149 | boxLayout->addWidget( mConfigureButton ); | 151 | boxLayout->addWidget( mConfigureButton ); |
150 | 152 | ||
151 | extensionLayout->addWidget( groupBox ); | 153 | extensionLayout->addWidget( groupBox ); |
152 | 154 | ||
153 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 155 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
154 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 156 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
157 | connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | ||
155 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 158 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
156 | connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 159 | connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
157 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), | 160 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), |
158 | SLOT( selectionChanged( QListViewItem* ) ) ); | 161 | SLOT( selectionChanged( QListViewItem* ) ) ); |
159 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), | 162 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), |
160 | SLOT( itemClicked( QListViewItem* ) ) ); | 163 | SLOT( itemClicked( QListViewItem* ) ) ); |
161 | connect( mConfigureButton, SIGNAL( clicked() ), | 164 | connect( mConfigureButton, SIGNAL( clicked() ), |
162 | SLOT( configureExtension() ) ); | 165 | SLOT( configureExtension() ) ); |
163 | 166 | ||
164 | tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); | 167 | tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); |
165 | 168 | ||
166 | // Addressee page | 169 | // Addressee page |
167 | mAddresseeWidget = new AddresseeWidget( this ); | 170 | mAddresseeWidget = new AddresseeWidget( this ); |
168 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); | 171 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); |
169 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); | 172 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); |
170 | 173 | ||
171 | } | 174 | } |
172 | 175 | ||
173 | 176 | ||
174 | void KABConfigWidget::restoreSettings(KABPrefs* prefs) | 177 | void KABConfigWidget::restoreSettings(KABPrefs* prefs) |
175 | { | 178 | { |
176 | //US prefs was KABPrefs::instance() before | 179 | //US prefs was KABPrefs::instance() before |
177 | 180 | ||
178 | bool blocked = signalsBlocked(); | 181 | bool blocked = signalsBlocked(); |
179 | blockSignals( true ); | 182 | blockSignals( true ); |
180 | 183 | ||
181 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); | 184 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); |
182 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); | 185 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); |
186 | mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); | ||
183 | mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); | 187 | mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); |
184 | mAskForQuit->setChecked( prefs->mAskForQuit ); | 188 | mAskForQuit->setChecked( prefs->mAskForQuit ); |
185 | 189 | ||
186 | mAddresseeWidget->restoreSettings(); | 190 | mAddresseeWidget->restoreSettings(); |
187 | 191 | ||
188 | restoreExtensionSettings(); | 192 | restoreExtensionSettings(); |
189 | 193 | ||
190 | blockSignals( blocked ); | 194 | blockSignals( blocked ); |
191 | 195 | ||
192 | emit changed( false ); | 196 | emit changed( false ); |
193 | } | 197 | } |
194 | 198 | ||
195 | void KABConfigWidget::saveSettings(KABPrefs* prefs) | 199 | void KABConfigWidget::saveSettings(KABPrefs* prefs) |
196 | { | 200 | { |
197 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); | 201 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); |
198 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); | 202 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); |
203 | prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); | ||
199 | prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); | 204 | prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); |
200 | prefs->mAskForQuit = mAskForQuit->isChecked(); | 205 | prefs->mAskForQuit = mAskForQuit->isChecked(); |
201 | 206 | ||
202 | mAddresseeWidget->saveSettings(); | 207 | mAddresseeWidget->saveSettings(); |
203 | 208 | ||
204 | saveExtensionSettings(); | 209 | saveExtensionSettings(); |
205 | KABPrefs::instance()->writeConfig(); | 210 | KABPrefs::instance()->writeConfig(); |
206 | 211 | ||
207 | emit changed( false ); | 212 | emit changed( false ); |
208 | } | 213 | } |
209 | 214 | ||
210 | void KABConfigWidget::defaults(KABPrefs* prefs) | 215 | void KABConfigWidget::defaults(KABPrefs* prefs) |
211 | { | 216 | { |
212 | mNameParsing->setChecked( true ); | 217 | mNameParsing->setChecked( true ); |
213 | mViewsSingleClickBox->setChecked( false ); | 218 | mViewsSingleClickBox->setChecked( false ); |
214 | mMultipleViewsAtOnce->setChecked( true ); | 219 | mMultipleViewsAtOnce->setChecked( true ); |
220 | mSearchReturnBox->setChecked( true ); | ||
215 | mAskForQuit->setChecked (true); | 221 | mAskForQuit->setChecked (true); |
216 | 222 | ||
217 | emit changed( true ); | 223 | emit changed( true ); |
218 | } | 224 | } |
219 | 225 | ||
220 | void KABConfigWidget::modified() | 226 | void KABConfigWidget::modified() |
221 | { | 227 | { |
222 | emit changed( true ); | 228 | emit changed( true ); |
223 | } | 229 | } |
224 | 230 | ||
225 | void KABConfigWidget::restoreExtensionSettings() | 231 | void KABConfigWidget::restoreExtensionSettings() |
226 | { | 232 | { |
227 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; | 233 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; |
228 | 234 | ||
229 | mExtensionView->clear(); | 235 | mExtensionView->clear(); |
230 | 236 | ||
231 | #ifndef KAB_EMBEDDED | 237 | #ifndef KAB_EMBEDDED |
232 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); | 238 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); |
233 | KTrader::OfferList::ConstIterator it; | 239 | KTrader::OfferList::ConstIterator it; |
234 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 240 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
235 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) | 241 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) |
236 | continue; | 242 | continue; |
237 | 243 | ||
238 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); | 244 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); |
239 | item->setService( *it ); | 245 | item->setService( *it ); |
240 | if ( activeExtensions.contains( item->factory()->identifier() ) ) | 246 | if ( activeExtensions.contains( item->factory()->identifier() ) ) |
241 | item->setOn( true ); | 247 | item->setOn( true ); |
242 | } | 248 | } |
243 | #else //KAB_EMBEDDED | 249 | #else //KAB_EMBEDDED |
244 | ExtensionFactory *extensionFactory = new MergeFactory(); | 250 | ExtensionFactory *extensionFactory = new MergeFactory(); |
245 | 251 | ||
246 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); | 252 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); |
247 | 253 | ||
248 | item->setFactory( extensionFactory ); | 254 | item->setFactory( extensionFactory ); |
249 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 255 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
250 | item->setOn( true ); | 256 | item->setOn( true ); |
251 | 257 | ||
252 | 258 | ||
253 | 259 | ||
254 | extensionFactory = new DistributionListFactory(); | 260 | extensionFactory = new DistributionListFactory(); |
255 | 261 | ||
256 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); | 262 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); |
257 | 263 | ||
258 | item->setFactory( extensionFactory ); | 264 | item->setFactory( extensionFactory ); |
259 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 265 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
260 | item->setOn( true ); | 266 | item->setOn( true ); |
261 | 267 | ||
262 | 268 | ||
263 | #endif //KAB_EMBEDDED | 269 | #endif //KAB_EMBEDDED |
264 | 270 | ||
265 | } | 271 | } |
266 | 272 | ||
267 | void KABConfigWidget::saveExtensionSettings() | 273 | void KABConfigWidget::saveExtensionSettings() |
268 | { | 274 | { |
269 | QStringList activeExtensions; | 275 | QStringList activeExtensions; |
270 | 276 | ||
271 | QPtrList<QListViewItem> list; | 277 | QPtrList<QListViewItem> list; |
272 | QListViewItemIterator it( mExtensionView ); | 278 | QListViewItemIterator it( mExtensionView ); |
273 | while ( it.current() ) { | 279 | while ( it.current() ) { |
274 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); | 280 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); |
275 | if ( item ) { | 281 | if ( item ) { |
276 | if ( item->isOn() ) | 282 | if ( item->isOn() ) |
277 | activeExtensions.append( item->factory()->identifier() ); | 283 | activeExtensions.append( item->factory()->identifier() ); |
278 | } | 284 | } |
279 | ++it; | 285 | ++it; |
280 | } | 286 | } |
281 | 287 | ||
282 | KABPrefs::instance()->mActiveExtensions = activeExtensions; | 288 | KABPrefs::instance()->mActiveExtensions = activeExtensions; |
283 | } | 289 | } |
284 | 290 | ||
285 | void KABConfigWidget::configureExtension() | 291 | void KABConfigWidget::configureExtension() |
286 | { | 292 | { |
287 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); | 293 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); |
288 | if ( !item ) | 294 | if ( !item ) |
289 | return; | 295 | return; |
290 | 296 | ||
291 | #ifndef KAB_EMBEDDED | 297 | #ifndef KAB_EMBEDDED |
292 | KConfig config( "kaddressbookrc" ); | 298 | KConfig config( "kaddressbookrc" ); |
293 | #else //KAB_EMBEDDED | 299 | #else //KAB_EMBEDDED |
294 | KConfig config( locateLocal("config", "kaddressbookrc") ); | 300 | KConfig config( locateLocal("config", "kaddressbookrc") ); |
295 | #endif //KAB_EMBEDDED | 301 | #endif //KAB_EMBEDDED |
296 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); | 302 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); |
297 | 303 | ||
298 | ExtensionConfigDialog dlg( item->factory(), &config, this ); | 304 | ExtensionConfigDialog dlg( item->factory(), &config, this ); |
299 | dlg.exec(); | 305 | dlg.exec(); |
300 | 306 | ||
301 | config.sync(); | 307 | config.sync(); |
302 | } | 308 | } |
303 | 309 | ||
304 | void KABConfigWidget::selectionChanged( QListViewItem *i ) | 310 | void KABConfigWidget::selectionChanged( QListViewItem *i ) |
305 | { | 311 | { |
306 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); | 312 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); |
307 | if ( !item ) | 313 | if ( !item ) |
308 | return; | 314 | return; |
309 | 315 | ||
310 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); | 316 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); |
311 | } | 317 | } |
312 | 318 | ||
313 | void KABConfigWidget::itemClicked( QListViewItem *item ) | 319 | void KABConfigWidget::itemClicked( QListViewItem *item ) |
314 | { | 320 | { |
315 | if ( item != 0 ) | 321 | if ( item != 0 ) |
316 | modified(); | 322 | modified(); |
317 | } | 323 | } |
318 | 324 | ||
319 | #ifndef KAB_EMBEDDED | 325 | #ifndef KAB_EMBEDDED |
320 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) | 326 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) |
321 | : QCheckListItem( parent, text, CheckBox ) | 327 | : QCheckListItem( parent, text, CheckBox ) |
322 | { | 328 | { |
323 | } | 329 | } |
324 | 330 | ||
325 | void ExtensionItem::setService( const KService::Ptr &ptr ) | 331 | void ExtensionItem::setService( const KService::Ptr &ptr ) |
326 | { | 332 | { |
327 | mPtr = ptr; | 333 | mPtr = ptr; |
328 | } | 334 | } |
329 | #else //KAB_EMBEDDED | 335 | #else //KAB_EMBEDDED |
330 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) | 336 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) |
331 | : QCheckListItem( parent, text, CheckBox ) | 337 | : QCheckListItem( parent, text, CheckBox ) |
332 | { | 338 | { |
333 | mName = name; | 339 | mName = name; |
334 | mComment = comment; | 340 | mComment = comment; |
335 | } | 341 | } |
336 | 342 | ||
337 | 343 | ||
338 | void ExtensionItem::setFactory( ExtensionFactory* fac ) | 344 | void ExtensionItem::setFactory( ExtensionFactory* fac ) |
339 | { | 345 | { |
340 | mFactory = fac; | 346 | mFactory = fac; |
341 | } | 347 | } |
342 | #endif //KAB_EMBEDDED | 348 | #endif //KAB_EMBEDDED |
343 | 349 | ||
344 | bool ExtensionItem::configWidgetAvailable() const | 350 | bool ExtensionItem::configWidgetAvailable() const |
345 | { | 351 | { |
346 | #ifndef KAB_EMBEDDED | 352 | #ifndef KAB_EMBEDDED |
347 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | 353 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); |
348 | if ( !factory ) | 354 | if ( !factory ) |
349 | return false; | 355 | return false; |
350 | 356 | ||
351 | ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); | 357 | ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); |
352 | if ( !extensionFactory ) | 358 | if ( !extensionFactory ) |
353 | return false; | 359 | return false; |
354 | 360 | ||
355 | return extensionFactory->configureWidgetAvailable(); | 361 | return extensionFactory->configureWidgetAvailable(); |
356 | #else //KAB_EMBEDDED | 362 | #else //KAB_EMBEDDED |
357 | return mFactory->configureWidgetAvailable(); | 363 | return mFactory->configureWidgetAvailable(); |
358 | #endif //KAB_EMBEDDED | 364 | #endif //KAB_EMBEDDED |
359 | 365 | ||
360 | } | 366 | } |
361 | 367 | ||
362 | ExtensionFactory *ExtensionItem::factory() const | 368 | ExtensionFactory *ExtensionItem::factory() const |
363 | { | 369 | { |
364 | #ifndef KAB_EMBEDDED | 370 | #ifndef KAB_EMBEDDED |
365 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | 371 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); |
366 | if ( !factory ) | 372 | if ( !factory ) |
367 | return 0; | 373 | return 0; |
368 | 374 | ||
369 | return static_cast<ExtensionFactory*>( factory ); | 375 | return static_cast<ExtensionFactory*>( factory ); |
370 | #else //KAB_EMBEDDED | 376 | #else //KAB_EMBEDDED |
371 | return mFactory; | 377 | return mFactory; |
372 | #endif //KAB_EMBEDDED | 378 | #endif //KAB_EMBEDDED |
373 | } | 379 | } |
374 | 380 | ||
375 | QString ExtensionItem::text( int column ) const | 381 | QString ExtensionItem::text( int column ) const |
376 | { | 382 | { |
377 | #ifndef KAB_EMBEDDED | 383 | #ifndef KAB_EMBEDDED |
378 | if ( column == 0 ) | 384 | if ( column == 0 ) |
379 | return mPtr->name(); | 385 | return mPtr->name(); |
380 | else if ( column == 1 ) | 386 | else if ( column == 1 ) |
381 | return mPtr->comment(); | 387 | return mPtr->comment(); |
382 | else | 388 | else |
383 | return QString::null; | 389 | return QString::null; |
384 | #else //KAB_EMBEDDED | 390 | #else //KAB_EMBEDDED |
385 | if ( column == 0 ) | 391 | if ( column == 0 ) |
386 | return mName; | 392 | return mName; |
387 | else if ( column == 1 ) | 393 | else if ( column == 1 ) |
388 | return mComment; | 394 | return mComment; |
389 | else | 395 | else |
390 | return QString::null; | 396 | return QString::null; |
391 | #endif //KAB_EMBEDDED | 397 | #endif //KAB_EMBEDDED |
392 | } | 398 | } |
393 | 399 | ||
394 | #ifndef KAB_EMBEDDED | 400 | #ifndef KAB_EMBEDDED |
395 | #include "kabconfigwidget.moc" | 401 | #include "kabconfigwidget.moc" |
396 | #endif //KAB_EMBEDDED | 402 | #endif //KAB_EMBEDDED |
397 | 403 | ||
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h index 831efc1..6cd4223 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.h +++ b/kaddressbook/kcmconfigs/kabconfigwidget.h | |||
@@ -1,79 +1,79 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KABCONFIGWIDGET_H | 24 | #ifndef KABCONFIGWIDGET_H |
25 | #define KABCONFIGWIDGET_H | 25 | #define KABCONFIGWIDGET_H |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | 28 | ||
29 | class QCheckBox; | 29 | class QCheckBox; |
30 | class QListViewItem; | 30 | class QListViewItem; |
31 | class QPushButton; | 31 | class QPushButton; |
32 | class QComboBox; | 32 | class QComboBox; |
33 | class QLineEdit; | 33 | class QLineEdit; |
34 | class KListView; | 34 | class KListView; |
35 | class KABPrefs; | 35 | class KABPrefs; |
36 | 36 | ||
37 | class AddresseeWidget; | 37 | class AddresseeWidget; |
38 | 38 | ||
39 | class KABConfigWidget : public QWidget | 39 | class KABConfigWidget : public QWidget |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | KABConfigWidget( QWidget *parent, const char *name = 0 ); | 44 | KABConfigWidget( QWidget *parent, const char *name = 0 ); |
45 | 45 | ||
46 | void restoreSettings(KABPrefs* prefs); | 46 | void restoreSettings(KABPrefs* prefs); |
47 | void saveSettings(KABPrefs* prefs); | 47 | void saveSettings(KABPrefs* prefs); |
48 | void defaults(KABPrefs* prefs); | 48 | void defaults(KABPrefs* prefs); |
49 | 49 | ||
50 | signals: | 50 | signals: |
51 | void changed( bool ); | 51 | void changed( bool ); |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void modified(); | 54 | void modified(); |
55 | 55 | ||
56 | 56 | ||
57 | 57 | ||
58 | private slots: | 58 | private slots: |
59 | void configureExtension(); | 59 | void configureExtension(); |
60 | void selectionChanged( QListViewItem* ); | 60 | void selectionChanged( QListViewItem* ); |
61 | void itemClicked( QListViewItem* ); | 61 | void itemClicked( QListViewItem* ); |
62 | 62 | ||
63 | private: | 63 | private: |
64 | void restoreExtensionSettings(); | 64 | void restoreExtensionSettings(); |
65 | void saveExtensionSettings(); | 65 | void saveExtensionSettings(); |
66 | 66 | ||
67 | KListView *mExtensionView; | 67 | KListView *mExtensionView; |
68 | 68 | QCheckBox *mSearchReturnBox; | |
69 | QCheckBox *mNameParsing; | 69 | QCheckBox *mNameParsing; |
70 | QCheckBox *mViewsSingleClickBox; | 70 | QCheckBox *mViewsSingleClickBox; |
71 | QCheckBox *mMultipleViewsAtOnce; | 71 | QCheckBox *mMultipleViewsAtOnce; |
72 | QCheckBox *mAskForQuit; | 72 | QCheckBox *mAskForQuit; |
73 | 73 | ||
74 | QPushButton *mConfigureButton; | 74 | QPushButton *mConfigureButton; |
75 | 75 | ||
76 | AddresseeWidget *mAddresseeWidget; | 76 | AddresseeWidget *mAddresseeWidget; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | #endif | 79 | #endif |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 12f7c27..63ad0ed 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -1,442 +1,442 @@ | |||
1 | // $Id$ | 1 | // $Id$ |
2 | 2 | ||
3 | #include <qvbox.h> | 3 | #include <qvbox.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qdragobject.h> | 10 | #include <qdragobject.h> |
11 | #include <qevent.h> | 11 | #include <qevent.h> |
12 | #include <qurl.h> | 12 | #include <qurl.h> |
13 | #include <qpixmap.h> | 13 | #include <qpixmap.h> |
14 | 14 | ||
15 | #include <kabc/addressbook.h> | 15 | #include <kabc/addressbook.h> |
16 | #include <kapplication.h> | 16 | #include <kapplication.h> |
17 | #include <kconfig.h> | 17 | #include <kconfig.h> |
18 | #include <kcolorbutton.h> | 18 | #include <kcolorbutton.h> |
19 | #include <kdebug.h> | 19 | #include <kdebug.h> |
20 | #include <kglobal.h> | 20 | #include <kglobal.h> |
21 | #include <kiconloader.h> | 21 | #include <kiconloader.h> |
22 | #include <klineedit.h> | 22 | #include <klineedit.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> |
25 | #include <kurl.h> | 25 | #include <kurl.h> |
26 | #include <kurlrequester.h> | 26 | #include <kurlrequester.h> |
27 | 27 | ||
28 | //US#include "configuretableviewdialog.h" | 28 | //US#include "configuretableviewdialog.h" |
29 | #include "contactlistview.h" | 29 | #include "contactlistview.h" |
30 | #include "kabprefs.h" | 30 | #include "kabprefs.h" |
31 | #include "undocmds.h" | 31 | #include "undocmds.h" |
32 | #include "viewmanager.h" | 32 | #include "viewmanager.h" |
33 | 33 | ||
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qheader.h> | 35 | #include <qheader.h> |
36 | 36 | ||
37 | #include "kaddressbooktableview.h" | 37 | #include "kaddressbooktableview.h" |
38 | 38 | ||
39 | 39 | ||
40 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 40 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, |
41 | QWidget *parent, const char *name ) | 41 | QWidget *parent, const char *name ) |
42 | : KAddressBookView( ab, parent, name ) | 42 | : KAddressBookView( ab, parent, name ) |
43 | { | 43 | { |
44 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); | 44 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); |
45 | 45 | ||
46 | // The list view will be created when the config is read. | 46 | // The list view will be created when the config is read. |
47 | mListView = 0; | 47 | mListView = 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | KAddressBookTableView::~KAddressBookTableView() | 50 | KAddressBookTableView::~KAddressBookTableView() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | void KAddressBookTableView::reconstructListView() | 54 | void KAddressBookTableView::reconstructListView() |
55 | { | 55 | { |
56 | if (mListView) | 56 | if (mListView) |
57 | { | 57 | { |
58 | disconnect(mListView, SIGNAL(selectionChanged()), | 58 | disconnect(mListView, SIGNAL(selectionChanged()), |
59 | this, SLOT(addresseeSelected())); | 59 | this, SLOT(addresseeSelected())); |
60 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 60 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |
61 | this, SLOT(addresseeExecuted(QListViewItem*))); | 61 | this, SLOT(addresseeExecuted(QListViewItem*))); |
62 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 62 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
63 | this, SLOT(addresseeExecuted(QListViewItem*))); | 63 | this, SLOT(addresseeExecuted(QListViewItem*))); |
64 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, | 64 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, |
65 | SIGNAL(startDrag())); | 65 | SIGNAL(startDrag())); |
66 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 66 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
67 | this, SLOT(addresseeExecuted(QListViewItem*))); | 67 | this, SLOT(addresseeExecuted(QListViewItem*))); |
68 | 68 | ||
69 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 69 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
70 | SIGNAL(dropped(QDropEvent*))); | 70 | SIGNAL(dropped(QDropEvent*))); |
71 | delete mListView; | 71 | delete mListView; |
72 | } | 72 | } |
73 | 73 | ||
74 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 74 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
75 | 75 | ||
76 | // Add the columns | 76 | // Add the columns |
77 | KABC::Field::List fieldList = fields(); | 77 | KABC::Field::List fieldList = fields(); |
78 | KABC::Field::List::ConstIterator it; | 78 | KABC::Field::List::ConstIterator it; |
79 | 79 | ||
80 | int c = 0; | 80 | int c = 0; |
81 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 81 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
82 | mListView->addColumn( (*it)->label() ); | 82 | mListView->addColumn( (*it)->label() ); |
83 | mListView->setColumnWidthMode(c++, QListView::Manual); | 83 | mListView->setColumnWidthMode(c++, QListView::Manual); |
84 | //US | 84 | //US |
85 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 85 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
86 | } | 86 | } |
87 | 87 | ||
88 | connect(mListView, SIGNAL(selectionChanged()), | 88 | connect(mListView, SIGNAL(selectionChanged()), |
89 | this, SLOT(addresseeSelected())); | 89 | this, SLOT(addresseeSelected())); |
90 | connect(mListView, SIGNAL(startAddresseeDrag()), this, | 90 | connect(mListView, SIGNAL(startAddresseeDrag()), this, |
91 | SIGNAL(startDrag())); | 91 | SIGNAL(startDrag())); |
92 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 92 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
93 | SIGNAL(dropped(QDropEvent*))); | 93 | SIGNAL(dropped(QDropEvent*))); |
94 | 94 | ||
95 | if (KABPrefs::instance()->mHonorSingleClick) | 95 | if (KABPrefs::instance()->mHonorSingleClick) |
96 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 96 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
97 | this, SLOT(addresseeExecuted(QListViewItem*))); | 97 | this, SLOT(addresseeExecuted(QListViewItem*))); |
98 | else | 98 | else |
99 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 99 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
100 | this, SLOT(addresseeExecuted(QListViewItem*))); | 100 | this, SLOT(addresseeExecuted(QListViewItem*))); |
101 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 101 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
102 | this, SLOT(addresseeExecuted(QListViewItem*))); | 102 | this, SLOT(addresseeExecuted(QListViewItem*))); |
103 | connect(mListView, SIGNAL(signalDelete()), | 103 | connect(mListView, SIGNAL(signalDelete()), |
104 | this, SLOT(addresseeDeleted())); | 104 | this, SLOT(addresseeDeleted())); |
105 | 105 | ||
106 | //US performceimprovement. Refresh is done from the outside | 106 | //US performceimprovement. Refresh is done from the outside |
107 | //US refresh(); | 107 | //US refresh(); |
108 | 108 | ||
109 | mListView->setSorting( 0, true ); | 109 | mListView->setSorting( 0, true ); |
110 | mainLayout->addWidget( mListView ); | 110 | mainLayout->addWidget( mListView ); |
111 | mainLayout->activate(); | 111 | mainLayout->activate(); |
112 | mListView->show(); | 112 | mListView->show(); |
113 | } | 113 | } |
114 | 114 | ||
115 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 115 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) |
116 | { | 116 | { |
117 | mListView->clear(); | 117 | mListView->clear(); |
118 | if ( s.isEmpty() || s == "*" ) { | 118 | if ( s.isEmpty() || s == "*" ) { |
119 | refresh(); | 119 | refresh(); |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | QString pattern = s.lower()+"*"; | 122 | QString pattern = s.lower()+"*"; |
123 | QRegExp re; | 123 | QRegExp re; |
124 | re.setWildcard(true); // most people understand these better. | 124 | re.setWildcard(true); // most people understand these better. |
125 | re.setCaseSensitive(false); | 125 | re.setCaseSensitive(false); |
126 | re.setPattern( pattern ); | 126 | re.setPattern( pattern ); |
127 | if (!re.isValid()) | 127 | if (!re.isValid()) |
128 | return; | 128 | return; |
129 | KABC::Addressee::List addresseeList = addressees(); | 129 | KABC::Addressee::List addresseeList = addressees(); |
130 | KABC::Addressee::List::Iterator it; | 130 | KABC::Addressee::List::Iterator it; |
131 | if ( field ) { | 131 | if ( field ) { |
132 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 132 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
133 | #if QT_VERSION >= 300 | 133 | #if QT_VERSION >= 300 |
134 | if (re.search(field->value( *it ).lower()) != -1) | 134 | if (re.search(field->value( *it ).lower()) != -1) |
135 | #else | 135 | #else |
136 | if (re.match(field->value( *it ).lower()) != -1) | 136 | if (re.match(field->value( *it ).lower()) != -1) |
137 | #endif | 137 | #endif |
138 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 138 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
139 | 139 | ||
140 | } | 140 | } |
141 | } else { | 141 | } else { |
142 | KABC::Field::List fieldList = fields(); | 142 | KABC::Field::List fieldList = fields(); |
143 | KABC::Field::List::ConstIterator fieldIt; | 143 | KABC::Field::List::ConstIterator fieldIt; |
144 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 144 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
145 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 145 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
146 | #if QT_VERSION >= 300 | 146 | #if QT_VERSION >= 300 |
147 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 147 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
148 | #else | 148 | #else |
149 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 149 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
150 | #endif | 150 | #endif |
151 | { | 151 | { |
152 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 152 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
153 | continue; | 153 | break; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | } | 157 | } |
158 | // Sometimes the background pixmap gets messed up when we add lots | 158 | // Sometimes the background pixmap gets messed up when we add lots |
159 | // of items. | 159 | // of items. |
160 | mListView->repaint(); | 160 | mListView->repaint(); |
161 | emit selected(QString::null); | 161 | emit selected(QString::null); |
162 | 162 | ||
163 | } | 163 | } |
164 | void KAddressBookTableView::writeConfig(KConfig *config) | 164 | void KAddressBookTableView::writeConfig(KConfig *config) |
165 | { | 165 | { |
166 | KAddressBookView::writeConfig(config); | 166 | KAddressBookView::writeConfig(config); |
167 | 167 | ||
168 | mListView->saveLayout(config, config->group()); | 168 | mListView->saveLayout(config, config->group()); |
169 | } | 169 | } |
170 | 170 | ||
171 | void KAddressBookTableView::readConfig(KConfig *config) | 171 | void KAddressBookTableView::readConfig(KConfig *config) |
172 | { | 172 | { |
173 | KAddressBookView::readConfig( config ); | 173 | KAddressBookView::readConfig( config ); |
174 | // The config could have changed the fields, so we need to reconstruct | 174 | // The config could have changed the fields, so we need to reconstruct |
175 | // the listview. | 175 | // the listview. |
176 | reconstructListView(); | 176 | reconstructListView(); |
177 | 177 | ||
178 | // costum colors? | 178 | // costum colors? |
179 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 179 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
180 | { | 180 | { |
181 | QPalette p( mListView->palette() ); | 181 | QPalette p( mListView->palette() ); |
182 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 182 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
183 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 183 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
184 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 184 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
185 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 185 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
186 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 186 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
187 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 187 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
188 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 188 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
189 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 189 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
190 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 190 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
191 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 191 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
192 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 192 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
193 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 193 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
194 | #ifndef KAB_EMBEDDED | 194 | #ifndef KAB_EMBEDDED |
195 | c = KGlobalSettings::alternateBackgroundColor(); | 195 | c = KGlobalSettings::alternateBackgroundColor(); |
196 | #else //KAB_EMBEDDED | 196 | #else //KAB_EMBEDDED |
197 | c = QColor(240, 240, 240); | 197 | c = QColor(240, 240, 240); |
198 | #endif //KAB_EMBEDDED | 198 | #endif //KAB_EMBEDDED |
199 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 199 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
200 | mListView->setAlternateColor(c); | 200 | mListView->setAlternateColor(c); |
201 | 201 | ||
202 | 202 | ||
203 | //US mListView->viewport()->setPalette( p ); | 203 | //US mListView->viewport()->setPalette( p ); |
204 | mListView->setPalette( p ); | 204 | mListView->setPalette( p ); |
205 | } | 205 | } |
206 | else | 206 | else |
207 | { | 207 | { |
208 | // needed if turned off during a session. | 208 | // needed if turned off during a session. |
209 | //US mListView->viewport()->setPalette( mListView->palette() ); | 209 | //US mListView->viewport()->setPalette( mListView->palette() ); |
210 | mListView->setPalette( mListView->palette() ); | 210 | mListView->setPalette( mListView->palette() ); |
211 | } | 211 | } |
212 | 212 | ||
213 | //custom fonts? | 213 | //custom fonts? |
214 | QFont f( font() ); | 214 | QFont f( font() ); |
215 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 215 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
216 | { | 216 | { |
217 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 217 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
218 | f.setBold( true ); | 218 | f.setBold( true ); |
219 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 219 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
220 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 220 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
221 | } | 221 | } |
222 | else | 222 | else |
223 | { | 223 | { |
224 | mListView->setFont( f ); | 224 | mListView->setFont( f ); |
225 | f.setBold( true ); | 225 | f.setBold( true ); |
226 | //US mListView->setHeaderFont( f ); | 226 | //US mListView->setHeaderFont( f ); |
227 | mListView->header()->setFont( f ); | 227 | mListView->header()->setFont( f ); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
231 | 231 | ||
232 | 232 | ||
233 | 233 | ||
234 | // Set the list view options | 234 | // Set the list view options |
235 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 235 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
236 | true)); | 236 | true)); |
237 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 237 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
238 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 238 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
239 | 239 | ||
240 | if (config->readBoolEntry("Background", false)) | 240 | if (config->readBoolEntry("Background", false)) |
241 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 241 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
242 | 242 | ||
243 | // Restore the layout of the listview | 243 | // Restore the layout of the listview |
244 | mListView->restoreLayout(config, config->group()); | 244 | mListView->restoreLayout(config, config->group()); |
245 | } | 245 | } |
246 | 246 | ||
247 | void KAddressBookTableView::refresh(QString uid) | 247 | void KAddressBookTableView::refresh(QString uid) |
248 | { | 248 | { |
249 | // For now just repopulate. In reality this method should | 249 | // For now just repopulate. In reality this method should |
250 | // check the value of uid, and if valid iterate through | 250 | // check the value of uid, and if valid iterate through |
251 | // the listview to find the entry, then tell it to refresh. | 251 | // the listview to find the entry, then tell it to refresh. |
252 | 252 | ||
253 | if (uid.isNull()) { | 253 | if (uid.isNull()) { |
254 | // Clear the list view | 254 | // Clear the list view |
255 | QString currentUID, nextUID; | 255 | QString currentUID, nextUID; |
256 | #ifndef KAB_EMBEDDED | 256 | #ifndef KAB_EMBEDDED |
257 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 257 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
258 | #else //KAB_EMBEDDED | 258 | #else //KAB_EMBEDDED |
259 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 259 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
260 | #endif //KAB_EMBEDDED | 260 | #endif //KAB_EMBEDDED |
261 | 261 | ||
262 | if ( currentItem ) { | 262 | if ( currentItem ) { |
263 | #ifndef KAB_EMBEDDED | 263 | #ifndef KAB_EMBEDDED |
264 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 264 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
265 | #else //KAB_EMBEDDED | 265 | #else //KAB_EMBEDDED |
266 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 266 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
267 | #endif //KAB_EMBEDDED | 267 | #endif //KAB_EMBEDDED |
268 | if ( nextItem ) | 268 | if ( nextItem ) |
269 | nextUID = nextItem->addressee().uid(); | 269 | nextUID = nextItem->addressee().uid(); |
270 | currentUID = currentItem->addressee().uid(); | 270 | currentUID = currentItem->addressee().uid(); |
271 | } | 271 | } |
272 | 272 | ||
273 | mListView->clear(); | 273 | mListView->clear(); |
274 | 274 | ||
275 | currentItem = 0; | 275 | currentItem = 0; |
276 | KABC::Addressee::List addresseeList = addressees(); | 276 | KABC::Addressee::List addresseeList = addressees(); |
277 | KABC::Addressee::List::Iterator it; | 277 | KABC::Addressee::List::Iterator it; |
278 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 278 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
279 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 279 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
280 | if ( (*it).uid() == currentUID ) | 280 | if ( (*it).uid() == currentUID ) |
281 | currentItem = item; | 281 | currentItem = item; |
282 | else if ( (*it).uid() == nextUID && !currentItem ) | 282 | else if ( (*it).uid() == nextUID && !currentItem ) |
283 | currentItem = item; | 283 | currentItem = item; |
284 | } | 284 | } |
285 | 285 | ||
286 | // Sometimes the background pixmap gets messed up when we add lots | 286 | // Sometimes the background pixmap gets messed up when we add lots |
287 | // of items. | 287 | // of items. |
288 | mListView->repaint(); | 288 | mListView->repaint(); |
289 | 289 | ||
290 | if ( currentItem ) { | 290 | if ( currentItem ) { |
291 | mListView->setCurrentItem( currentItem ); | 291 | mListView->setCurrentItem( currentItem ); |
292 | mListView->ensureItemVisible( currentItem ); | 292 | mListView->ensureItemVisible( currentItem ); |
293 | } | 293 | } |
294 | } else { | 294 | } else { |
295 | // Only need to update on entry. Iterate through and try to find it | 295 | // Only need to update on entry. Iterate through and try to find it |
296 | ContactListViewItem *ceItem; | 296 | ContactListViewItem *ceItem; |
297 | QListViewItemIterator it( mListView ); | 297 | QListViewItemIterator it( mListView ); |
298 | while ( it.current() ) { | 298 | while ( it.current() ) { |
299 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
300 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 300 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
301 | #else //KAB_EMBEDDED | 301 | #else //KAB_EMBEDDED |
302 | ceItem = (ContactListViewItem*)( it.current() ); | 302 | ceItem = (ContactListViewItem*)( it.current() ); |
303 | #endif //KAB_EMBEDDED | 303 | #endif //KAB_EMBEDDED |
304 | 304 | ||
305 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 305 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
306 | ceItem->refresh(); | 306 | ceItem->refresh(); |
307 | return; | 307 | return; |
308 | } | 308 | } |
309 | ++it; | 309 | ++it; |
310 | } | 310 | } |
311 | 311 | ||
312 | refresh( QString::null ); | 312 | refresh( QString::null ); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | QStringList KAddressBookTableView::selectedUids() | 316 | QStringList KAddressBookTableView::selectedUids() |
317 | { | 317 | { |
318 | QStringList uidList; | 318 | QStringList uidList; |
319 | QListViewItem *item; | 319 | QListViewItem *item; |
320 | ContactListViewItem *ceItem; | 320 | ContactListViewItem *ceItem; |
321 | 321 | ||
322 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 322 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
323 | { | 323 | { |
324 | if (mListView->isSelected( item )) | 324 | if (mListView->isSelected( item )) |
325 | { | 325 | { |
326 | #ifndef KAB_EMBEDDED | 326 | #ifndef KAB_EMBEDDED |
327 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 327 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
328 | #else //KAB_EMBEDDED | 328 | #else //KAB_EMBEDDED |
329 | ceItem = (ContactListViewItem*)(item); | 329 | ceItem = (ContactListViewItem*)(item); |
330 | #endif //KAB_EMBEDDED | 330 | #endif //KAB_EMBEDDED |
331 | 331 | ||
332 | if (ceItem != 0L) | 332 | if (ceItem != 0L) |
333 | uidList << ceItem->addressee().uid(); | 333 | uidList << ceItem->addressee().uid(); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | if ( uidList.count() == 0 ) | 336 | if ( uidList.count() == 0 ) |
337 | if ( mListView->currentItem() ) { | 337 | if ( mListView->currentItem() ) { |
338 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; | 338 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; |
339 | uidList << ceItem->addressee().uid(); | 339 | uidList << ceItem->addressee().uid(); |
340 | } | 340 | } |
341 | 341 | ||
342 | return uidList; | 342 | return uidList; |
343 | } | 343 | } |
344 | 344 | ||
345 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 345 | void KAddressBookTableView::setSelected(QString uid, bool selected) |
346 | { | 346 | { |
347 | QListViewItem *item; | 347 | QListViewItem *item; |
348 | ContactListViewItem *ceItem; | 348 | ContactListViewItem *ceItem; |
349 | 349 | ||
350 | if (uid.isNull()) | 350 | if (uid.isNull()) |
351 | { | 351 | { |
352 | mListView->selectAll(selected); | 352 | mListView->selectAll(selected); |
353 | } | 353 | } |
354 | else | 354 | else |
355 | { | 355 | { |
356 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 356 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
357 | { | 357 | { |
358 | #ifndef KAB_EMBEDDED | 358 | #ifndef KAB_EMBEDDED |
359 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 359 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
360 | #else //KAB_EMBEDDED | 360 | #else //KAB_EMBEDDED |
361 | ceItem = (ContactListViewItem*)(item); | 361 | ceItem = (ContactListViewItem*)(item); |
362 | #endif //KAB_EMBEDDED | 362 | #endif //KAB_EMBEDDED |
363 | 363 | ||
364 | 364 | ||
365 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) | 365 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) |
366 | { | 366 | { |
367 | mListView->setSelected(item, selected); | 367 | mListView->setSelected(item, selected); |
368 | 368 | ||
369 | if (selected) | 369 | if (selected) |
370 | mListView->ensureItemVisible(item); | 370 | mListView->ensureItemVisible(item); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | void KAddressBookTableView::addresseeSelected() | 376 | void KAddressBookTableView::addresseeSelected() |
377 | { | 377 | { |
378 | // We need to try to find the first selected item. This might not be the | 378 | // We need to try to find the first selected item. This might not be the |
379 | // last selected item, but when QListView is in multiselection mode, | 379 | // last selected item, but when QListView is in multiselection mode, |
380 | // there is no way to figure out which one was | 380 | // there is no way to figure out which one was |
381 | // selected last. | 381 | // selected last. |
382 | QListViewItem *item; | 382 | QListViewItem *item; |
383 | bool found =false; | 383 | bool found =false; |
384 | for (item = mListView->firstChild(); item && !found; | 384 | for (item = mListView->firstChild(); item && !found; |
385 | item = item->nextSibling()) | 385 | item = item->nextSibling()) |
386 | { | 386 | { |
387 | if (item->isSelected()) | 387 | if (item->isSelected()) |
388 | { | 388 | { |
389 | found = true; | 389 | found = true; |
390 | #ifndef KAB_EMBEDDED | 390 | #ifndef KAB_EMBEDDED |
391 | ContactListViewItem *ceItem | 391 | ContactListViewItem *ceItem |
392 | = dynamic_cast<ContactListViewItem*>(item); | 392 | = dynamic_cast<ContactListViewItem*>(item); |
393 | #else //KAB_EMBEDDED | 393 | #else //KAB_EMBEDDED |
394 | ContactListViewItem *ceItem | 394 | ContactListViewItem *ceItem |
395 | = (ContactListViewItem*)(item); | 395 | = (ContactListViewItem*)(item); |
396 | #endif //KAB_EMBEDDED | 396 | #endif //KAB_EMBEDDED |
397 | 397 | ||
398 | if ( ceItem ) emit selected(ceItem->addressee().uid()); | 398 | if ( ceItem ) emit selected(ceItem->addressee().uid()); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | if (!found) | 402 | if (!found) |
403 | emit selected(QString::null); | 403 | emit selected(QString::null); |
404 | } | 404 | } |
405 | 405 | ||
406 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 406 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) |
407 | { | 407 | { |
408 | if (item) | 408 | if (item) |
409 | { | 409 | { |
410 | #ifndef KAB_EMBEDDED | 410 | #ifndef KAB_EMBEDDED |
411 | ContactListViewItem *ceItem | 411 | ContactListViewItem *ceItem |
412 | = dynamic_cast<ContactListViewItem*>(item); | 412 | = dynamic_cast<ContactListViewItem*>(item); |
413 | #else //KAB_EMBEDDED | 413 | #else //KAB_EMBEDDED |
414 | ContactListViewItem *ceItem | 414 | ContactListViewItem *ceItem |
415 | = (ContactListViewItem*)(item); | 415 | = (ContactListViewItem*)(item); |
416 | #endif //KAB_EMBEDDED | 416 | #endif //KAB_EMBEDDED |
417 | 417 | ||
418 | if (ceItem) | 418 | if (ceItem) |
419 | { | 419 | { |
420 | emit executed(ceItem->addressee().uid()); | 420 | emit executed(ceItem->addressee().uid()); |
421 | } | 421 | } |
422 | } | 422 | } |
423 | else | 423 | else |
424 | { | 424 | { |
425 | emit executed(QString::null); | 425 | emit executed(QString::null); |
426 | } | 426 | } |
427 | } | 427 | } |
428 | 428 | ||
429 | void KAddressBookTableView::addresseeDeleted() | 429 | void KAddressBookTableView::addresseeDeleted() |
430 | { | 430 | { |
431 | 431 | ||
432 | emit deleteRequest(); | 432 | emit deleteRequest(); |
433 | 433 | ||
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | 439 | ||
440 | #ifndef KAB_EMBEDDED | 440 | #ifndef KAB_EMBEDDED |
441 | #include "kaddressbooktableview.moc" | 441 | #include "kaddressbooktableview.moc" |
442 | #endif //KAB_EMBEDDED | 442 | #endif //KAB_EMBEDDED |