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