-rw-r--r-- | kaddressbook/kaddressbookview.cpp | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp index a44fd82..da28870 100644 --- a/kaddressbook/kaddressbookview.cpp +++ b/kaddressbook/kaddressbookview.cpp | |||
@@ -1,47 +1,48 @@ | |||
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 KAB_EMBEDDED | 24 | #ifndef KAB_EMBEDDED |
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | 26 | ||
27 | #include <kabc/distributionlistdialog.h> | 27 | #include <kabc/distributionlistdialog.h> |
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | 30 | ||
31 | #include "viewmanager.h" | 31 | #include "viewmanager.h" |
32 | 32 | ||
33 | #endif //KAB_EMBEDDED | 33 | #endif //KAB_EMBEDDED |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | 35 | ||
36 | #include <kabc/distributionlistdialog.h> | ||
36 | #include <kabc/addressbook.h> | 37 | #include <kabc/addressbook.h> |
37 | #include <kdebug.h> | 38 | #include <kdebug.h> |
38 | 39 | ||
39 | #include "kaddressbookview.h" | 40 | #include "kaddressbookview.h" |
40 | 41 | ||
41 | KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, | 42 | KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, |
42 | const char *name ) | 43 | const char *name ) |
43 | : QWidget( parent, name ), mAddressBook( ab ), mFieldList() | 44 | : QWidget( parent, name ), mAddressBook( ab ), mFieldList() |
44 | { | 45 | { |
45 | initGUI(); | 46 | initGUI(); |
46 | } | 47 | } |
47 | 48 | ||
@@ -60,104 +61,97 @@ void KAddressBookView::readConfig( KConfig *config ) | |||
60 | 61 | ||
61 | mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 ); | 62 | mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 ); |
62 | mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null ); | 63 | mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null ); |
63 | } | 64 | } |
64 | 65 | ||
65 | void KAddressBookView::writeConfig( KConfig* ) | 66 | void KAddressBookView::writeConfig( KConfig* ) |
66 | { | 67 | { |
67 | // Most of writing the config is handled by the ConfigureViewDialog | 68 | // Most of writing the config is handled by the ConfigureViewDialog |
68 | } | 69 | } |
69 | 70 | ||
70 | QString KAddressBookView::selectedEmails() | 71 | QString KAddressBookView::selectedEmails() |
71 | { | 72 | { |
72 | #ifndef KAB_EMBEDDED | ||
73 | |||
74 | bool first = true; | 73 | bool first = true; |
75 | QString emailAddrs; | 74 | QString emailAddrs; |
76 | QStringList uidList = selectedUids(); | 75 | QStringList uidList = selectedUids(); |
77 | KABC::Addressee addr; | 76 | KABC::Addressee addr; |
78 | QString email; | 77 | QString email; |
79 | 78 | ||
80 | QStringList::Iterator it; | 79 | QStringList::Iterator it; |
81 | for ( it = uidList.begin(); it != uidList.end(); ++it ) { | 80 | for ( it = uidList.begin(); it != uidList.end(); ++it ) { |
82 | addr = mAddressBook->findByUid( *it ); | 81 | addr = mAddressBook->findByUid( *it ); |
83 | 82 | ||
84 | if ( !addr.isEmpty() ) { | 83 | if ( !addr.isEmpty() ) { |
85 | QString m = QString::null; | 84 | QString m = QString::null; |
86 | 85 | ||
87 | if ( addr.emails().count() > 1 ) | 86 | if ( addr.emails().count() > 1 ) |
88 | m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this ); | 87 | m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this ); |
89 | 88 | ||
90 | email = addr.fullEmail( m ); | 89 | email = addr.fullEmail( m ); |
91 | 90 | ||
92 | if ( !first ) | 91 | if ( !first ) |
93 | emailAddrs += ", "; | 92 | emailAddrs += ", "; |
94 | else | 93 | else |
95 | first = false; | 94 | first = false; |
96 | 95 | ||
97 | emailAddrs += email; | 96 | emailAddrs += email; |
98 | } | 97 | } |
99 | } | 98 | } |
100 | 99 | ||
101 | return emailAddrs; | 100 | return emailAddrs; |
102 | #else //KAB_EMBEDDED | ||
103 | qDebug("KAddressBookView::selectedEmails() update method"); | ||
104 | return 0; | ||
105 | #endif //KAB_EMBEDDED | ||
106 | |||
107 | } | 101 | } |
108 | 102 | ||
109 | KABC::Addressee::List KAddressBookView::addressees() | 103 | KABC::Addressee::List KAddressBookView::addressees() |
110 | { | 104 | { |
111 | KABC::Addressee::List addresseeList; | 105 | KABC::Addressee::List addresseeList; |
112 | 106 | ||
113 | KABC::AddressBook::Iterator it; | 107 | KABC::AddressBook::Iterator it; |
114 | for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 108 | for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
115 | if ( mFilter.filterAddressee( *it ) ) | 109 | if ( mFilter.filterAddressee( *it ) ) |
116 | addresseeList.append( *it ); | 110 | addresseeList.append( *it ); |
117 | } | 111 | } |
118 | 112 | ||
119 | return addresseeList; | 113 | return addresseeList; |
120 | } | 114 | } |
121 | 115 | ||
122 | void KAddressBookView::initGUI() | 116 | void KAddressBookView::initGUI() |
123 | { | 117 | { |
124 | // Create the layout | 118 | // Create the layout |
125 | QVBoxLayout *layout = new QVBoxLayout( this ); | 119 | QVBoxLayout *layout = new QVBoxLayout( this ); |
126 | 120 | ||
127 | // Add the view widget | 121 | // Add the view widget |
128 | mViewWidget = new QWidget( this ); | 122 | mViewWidget = new QWidget( this ); |
129 | layout->addWidget( mViewWidget ); | 123 | layout->addWidget( mViewWidget ); |
130 | } | 124 | } |
131 | 125 | ||
132 | KABC::Field::List KAddressBookView::fields() const | 126 | KABC::Field::List KAddressBookView::fields() const |
133 | { | 127 | { |
134 | return mFieldList; | 128 | return mFieldList; |
135 | } | 129 | } |
136 | 130 | ||
137 | void KAddressBookView::setFilter( const Filter &filter ) | 131 | void KAddressBookView::setFilter( const Filter &filter ) |
138 | { | 132 | { |
139 | mFilter = filter; | 133 | mFilter = filter; |
140 | } | 134 | } |
141 | 135 | ||
142 | KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const | 136 | KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const |
143 | { | 137 | { |
144 | return mDefaultFilterType; | 138 | return mDefaultFilterType; |
145 | } | 139 | } |
146 | 140 | ||
147 | const QString &KAddressBookView::defaultFilterName() const | 141 | const QString &KAddressBookView::defaultFilterName() const |
148 | { | 142 | { |
149 | return mDefaultFilterName; | 143 | return mDefaultFilterName; |
150 | } | 144 | } |
151 | 145 | ||
152 | KABC::AddressBook *KAddressBookView::addressBook() const | 146 | KABC::AddressBook *KAddressBookView::addressBook() const |
153 | { | 147 | { |
154 | return mAddressBook; | 148 | return mAddressBook; |
155 | } | 149 | } |
156 | 150 | ||
157 | QWidget *KAddressBookView::viewWidget() | 151 | QWidget *KAddressBookView::viewWidget() |
158 | { | 152 | { |
159 | return mViewWidget; | 153 | return mViewWidget; |
160 | } | 154 | } |
161 | 155 | ||
162 | ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab, | 156 | ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab, |
163 | QWidget *parent, | 157 | QWidget *parent, |