Diffstat (limited to 'kaddressbook/kaddressbookview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/kaddressbookview.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp index 09859c2..86898e2 100644 --- a/kaddressbook/kaddressbookview.cpp +++ b/kaddressbook/kaddressbookview.cpp | |||
@@ -1,110 +1,110 @@ | |||
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 | ||
47 | initGUI(); | 47 | initGUI(); |
48 | } | 48 | } |
49 | 49 | ||
50 | KAddressBookView::~KAddressBookView() | 50 | KAddressBookView::~KAddressBookView() |
51 | { | 51 | { |
52 | 52 | ||
53 | } | 53 | } |
54 | 54 | ||
55 | QRegExp KAddressBookView::getRegExp( const QString s ) | 55 | QRegExp KAddressBookView::getRegExp( const QString s ) |
56 | { | 56 | { |
57 | QRegExp re; | 57 | QRegExp re; |
58 | 58 | ||
59 | if ( s.length() == 3 && s.mid(1,1) == "-" ) { | 59 | if ( s.length() == 3 && s.mid(1,1) == "-" ) { |
60 | QString pattern = "^[" + s.lower() +"]"; | 60 | QString pattern = "^[" + s.lower() +"]"; |
61 | re.setCaseSensitive(false); | 61 | re.setCaseSensitive(false); |
62 | re.setPattern( pattern ); | 62 | re.setPattern( pattern ); |
63 | } else { | 63 | } else { |
64 | QString pattern = s.lower()+"*"; | 64 | QString pattern = s.lower()+"*"; |
65 | re.setWildcard(true); // most people understand these better. | 65 | re.setWildcard(true); // most people understand these better. |
66 | re.setCaseSensitive(false); | 66 | re.setCaseSensitive(false); |
67 | re.setPattern( pattern ); | 67 | re.setPattern( pattern ); |
68 | } | 68 | } |
69 | return re; | 69 | return re; |
70 | } | 70 | } |
71 | 71 | ||
72 | void KAddressBookView::readConfig( KConfig *config ) | 72 | void KAddressBookView::readConfig( KConfig *config ) |
73 | { | 73 | { |
74 | mFieldList = KABC::Field::restoreFields( config, "KABCFields" ); | 74 | mFieldList = KABC::Field::restoreFields( config, "KABCFields" ); |
75 | 75 | ||
76 | if ( mFieldList.isEmpty() ) | 76 | if ( mFieldList.isEmpty() ) |
77 | mFieldList = KABC::Field::defaultFields(); | 77 | mFieldList = KABC::Field::defaultFields(); |
78 | 78 | ||
79 | mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 ); | 79 | mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 ); |
80 | mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null ); | 80 | mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null ); |
81 | } | 81 | } |
82 | 82 | ||
83 | void KAddressBookView::writeConfig( KConfig* ) | 83 | void KAddressBookView::writeConfig( KConfig* ) |
84 | { | 84 | { |
85 | // Most of writing the config is handled by the ConfigureViewDialog | 85 | // Most of writing the config is handled by the ConfigureViewDialog |
86 | } | 86 | } |
87 | 87 | ||
88 | QString KAddressBookView::selectedEmails() | 88 | QString KAddressBookView::selectedEmails() |
89 | { | 89 | { |
90 | bool first = true; | 90 | bool first = true; |
91 | QString emailAddrs; | 91 | QString emailAddrs; |
92 | QStringList uidList = selectedUids(); | 92 | QStringList uidList = selectedUids(); |
93 | KABC::Addressee addr; | 93 | KABC::Addressee addr; |
94 | QString email; | 94 | QString email; |
95 | 95 | ||
96 | QStringList::Iterator it; | 96 | QStringList::Iterator it; |
97 | for ( it = uidList.begin(); it != uidList.end(); ++it ) { | 97 | for ( it = uidList.begin(); it != uidList.end(); ++it ) { |
98 | addr = mAddressBook->findByUid( *it ); | 98 | addr = mAddressBook->findByUid( *it ); |
99 | 99 | ||
100 | if ( !addr.isEmpty() ) { | 100 | if ( !addr.isEmpty() ) { |
101 | QString m = QString::null; | 101 | QString m = QString::null; |
102 | 102 | ||
103 | if ( addr.emails().count() > 1 ) | 103 | if ( addr.emails().count() > 1 ) |
104 | m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this ); | 104 | m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this ); |
105 | 105 | ||
106 | email = addr.fullEmail( m ); | 106 | email = addr.fullEmail( m ); |
107 | 107 | ||
108 | if ( !first ) | 108 | if ( !first ) |
109 | emailAddrs += ", "; | 109 | emailAddrs += ", "; |
110 | else | 110 | else |
@@ -120,67 +120,69 @@ QString KAddressBookView::selectedEmails() | |||
120 | KABC::Addressee::List KAddressBookView::addressees() | 120 | KABC::Addressee::List KAddressBookView::addressees() |
121 | { | 121 | { |
122 | KABC::Addressee::List addresseeList; | 122 | KABC::Addressee::List addresseeList; |
123 | 123 | ||
124 | KABC::AddressBook::Iterator it; | 124 | KABC::AddressBook::Iterator it; |
125 | for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 125 | for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
126 | if ( mFilter.filterAddressee( *it ) ) | 126 | if ( mFilter.filterAddressee( *it ) ) |
127 | addresseeList.append( *it ); | 127 | addresseeList.append( *it ); |
128 | } | 128 | } |
129 | 129 | ||
130 | return addresseeList; | 130 | return addresseeList; |
131 | } | 131 | } |
132 | 132 | ||
133 | void KAddressBookView::initGUI() | 133 | void KAddressBookView::initGUI() |
134 | { | 134 | { |
135 | // Create the layout | 135 | // Create the layout |
136 | QVBoxLayout *layout = new QVBoxLayout( this ); | 136 | QVBoxLayout *layout = new QVBoxLayout( this ); |
137 | 137 | ||
138 | // Add the view widget | 138 | // Add the view widget |
139 | mViewWidget = new QWidget( this ); | 139 | mViewWidget = new QWidget( this ); |
140 | layout->addWidget( mViewWidget ); | 140 | layout->addWidget( mViewWidget ); |
141 | } | 141 | } |
142 | 142 | ||
143 | KABC::Field::List KAddressBookView::fields() const | 143 | KABC::Field::List KAddressBookView::fields() const |
144 | { | 144 | { |
145 | return mFieldList; | 145 | return mFieldList; |
146 | } | 146 | } |
147 | KABC::Field::List KAddressBookView::allFields() const | 147 | KABC::Field::List KAddressBookView::allFields() const |
148 | { | 148 | { |
149 | return KABC::Field::allFields(); | 149 | return KABC::Field::allFields(); |
150 | } | 150 | } |
151 | 151 | ||
152 | void KAddressBookView::setFilter( const Filter &filter ) | 152 | void KAddressBookView::setFilter( const Filter &filter ) |
153 | { | 153 | { |
154 | mFilter = filter; | 154 | mFilter = filter; |
155 | } | 155 | } |
156 | 156 | ||
157 | KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const | 157 | KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const |
158 | { | 158 | { |
159 | return mDefaultFilterType; | 159 | return mDefaultFilterType; |
160 | } | 160 | } |
161 | 161 | ||
162 | const QString &KAddressBookView::defaultFilterName() const | 162 | const QString &KAddressBookView::defaultFilterName() const |
163 | { | 163 | { |
164 | return mDefaultFilterName; | 164 | return mDefaultFilterName; |
165 | } | 165 | } |
166 | 166 | ||
167 | KABC::AddressBook *KAddressBookView::addressBook() const | 167 | KABC::AddressBook *KAddressBookView::addressBook() const |
168 | { | 168 | { |
169 | return mAddressBook; | 169 | return mAddressBook; |
170 | } | 170 | } |
171 | 171 | ||
172 | QWidget *KAddressBookView::viewWidget() | 172 | QWidget *KAddressBookView::viewWidget() |
173 | { | 173 | { |
174 | return mViewWidget; | 174 | return mViewWidget; |
175 | } | 175 | } |
176 | 176 | ||
177 | ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab, | 177 | ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab, |
178 | QWidget *parent, | 178 | QWidget *parent, |
179 | const char *name ) | 179 | const char *name ) |
180 | { | 180 | { |
181 | return new ViewConfigureWidget( ab, parent, name ); | 181 | return new ViewConfigureWidget( ab, parent, name ); |
182 | } | 182 | } |
183 | 183 | ||
184 | |||
185 | |||
184 | #ifndef KAB_EMBEDDED | 186 | #ifndef KAB_EMBEDDED |
185 | #include "kaddressbookview.moc" | 187 | #include "kaddressbookview.moc" |
186 | #endif //KAB_EMBEDDED | 188 | #endif //KAB_EMBEDDED |