author | zautrix <zautrix> | 2004-09-09 20:39:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-09 20:39:55 (UTC) |
commit | 480ffef4859d24cc0a936377f8983fd59312d4b6 (patch) (unidiff) | |
tree | 9661e8b5e892ef653ffc2ed630dbe89acfeb4851 /kaddressbook/views | |
parent | 880518b6f1d4b06e3df45224c244d9c62f6fb7a9 (diff) | |
download | kdepimpi-480ffef4859d24cc0a936377f8983fd59312d4b6.zip kdepimpi-480ffef4859d24cc0a936377f8983fd59312d4b6.tar.gz kdepimpi-480ffef4859d24cc0a936377f8983fd59312d4b6.tar.bz2 |
Added senseful searching in Kapi
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 53 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 47 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 49 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.h | 1 |
6 files changed, 151 insertions, 2 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 239429f..49c0691 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -1,394 +1,445 @@ | |||
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 | #include <qdragobject.h> | 24 | #include <qdragobject.h> |
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qiconview.h> | 26 | #include <qiconview.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | 29 | ||
30 | #include <kabc/addressbook.h> | 30 | #include <kabc/addressbook.h> |
31 | #include <kabc/addressee.h> | 31 | #include <kabc/addressee.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <kdebug.h> | 33 | #include <kdebug.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | 35 | ||
36 | #include "kabprefs.h" | 36 | #include "kabprefs.h" |
37 | #include "viewmanager.h" | 37 | #include "viewmanager.h" |
38 | 38 | ||
39 | #include "kaddressbookcardview.h" | 39 | #include "kaddressbookcardview.h" |
40 | 40 | ||
41 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
42 | extern "C" { | 42 | extern "C" { |
43 | void *init_libkaddrbk_cardview() | 43 | void *init_libkaddrbk_cardview() |
44 | { | 44 | { |
45 | return ( new CardViewFactory ); | 45 | return ( new CardViewFactory ); |
46 | } | 46 | } |
47 | } | 47 | } |
48 | #endif //KAB_EMBEDDED | 48 | #endif //KAB_EMBEDDED |
49 | 49 | ||
50 | //////////////////////////////// | 50 | //////////////////////////////// |
51 | // AddresseeCardViewItem (internal class) | 51 | // AddresseeCardViewItem (internal class) |
52 | class AddresseeCardViewItem : public CardViewItem | 52 | class AddresseeCardViewItem : public CardViewItem |
53 | { | 53 | { |
54 | public: | 54 | public: |
55 | AddresseeCardViewItem(const KABC::Field::List &fields, | 55 | AddresseeCardViewItem(const KABC::Field::List &fields, |
56 | bool showEmptyFields, | 56 | bool showEmptyFields, |
57 | KABC::AddressBook *doc, const KABC::Addressee &a, | 57 | KABC::AddressBook *doc, const KABC::Addressee &a, |
58 | CardView *parent) | 58 | CardView *parent) |
59 | : CardViewItem(parent, a.formattedName()), | 59 | : CardViewItem(parent, a.formattedName()), |
60 | mFields( fields ), mShowEmptyFields(showEmptyFields), | 60 | mFields( fields ), mShowEmptyFields(showEmptyFields), |
61 | mDocument(doc), mAddressee(a) | 61 | mDocument(doc), mAddressee(a) |
62 | { | 62 | { |
63 | if ( mFields.isEmpty() ) { | 63 | if ( mFields.isEmpty() ) { |
64 | mFields = KABC::Field::defaultFields(); | 64 | mFields = KABC::Field::defaultFields(); |
65 | } | 65 | } |
66 | refresh(); | 66 | refresh(); |
67 | } | 67 | } |
68 | 68 | ||
69 | const KABC::Addressee &addressee() const { return mAddressee; } | 69 | const KABC::Addressee &addressee() const { return mAddressee; } |
70 | 70 | ||
71 | void refresh() | 71 | void refresh() |
72 | { | 72 | { |
73 | // Update our addressee, since it may have changed elsewhere | 73 | // Update our addressee, since it may have changed elsewhere |
74 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 74 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
75 | 75 | ||
76 | if (!mAddressee.isEmpty()) | 76 | if (!mAddressee.isEmpty()) |
77 | { | 77 | { |
78 | clearFields(); | 78 | clearFields(); |
79 | 79 | ||
80 | // Try all the selected fields until we find one with text. | 80 | // Try all the selected fields until we find one with text. |
81 | // This will limit the number of unlabeled icons in the view | 81 | // This will limit the number of unlabeled icons in the view |
82 | KABC::Field::List::Iterator iter; | 82 | KABC::Field::List::Iterator iter; |
83 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) | 83 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) |
84 | { | 84 | { |
85 | // insert empty fields or not? not doing so saves a bit of memory and CPU | 85 | // insert empty fields or not? not doing so saves a bit of memory and CPU |
86 | // (during geometry calculations), but prevents having equally | 86 | // (during geometry calculations), but prevents having equally |
87 | // wide label columns in all cards, unless CardViewItem/CardView search | 87 | // wide label columns in all cards, unless CardViewItem/CardView search |
88 | // globally for the widest label. (anders) | 88 | // globally for the widest label. (anders) |
89 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) | 89 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) |
90 | insertField((*iter)->label(), (*iter)->value( mAddressee )); | 90 | insertField((*iter)->label(), (*iter)->value( mAddressee )); |
91 | } | 91 | } |
92 | 92 | ||
93 | // We might want to make this the first field. hmm... -mpilone | 93 | // We might want to make this the first field. hmm... -mpilone |
94 | setCaption( mAddressee.realName() ); | 94 | setCaption( mAddressee.realName() ); |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | private: | 98 | private: |
99 | KABC::Field::List mFields; | 99 | KABC::Field::List mFields; |
100 | bool mShowEmptyFields; | 100 | bool mShowEmptyFields; |
101 | KABC::AddressBook *mDocument; | 101 | KABC::AddressBook *mDocument; |
102 | KABC::Addressee mAddressee; | 102 | KABC::Addressee mAddressee; |
103 | }; | 103 | }; |
104 | 104 | ||
105 | /////////////////////////////// | 105 | /////////////////////////////// |
106 | // AddresseeCardView | 106 | // AddresseeCardView |
107 | 107 | ||
108 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) | 108 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) |
109 | : CardView(parent, name) | 109 | : CardView(parent, name) |
110 | { | 110 | { |
111 | setAcceptDrops(true); | 111 | setAcceptDrops(true); |
112 | } | 112 | } |
113 | 113 | ||
114 | AddresseeCardView::~AddresseeCardView() | 114 | AddresseeCardView::~AddresseeCardView() |
115 | { | 115 | { |
116 | } | 116 | } |
117 | 117 | ||
118 | |||
118 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 119 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) |
119 | { | 120 | { |
120 | #ifndef KAB_EMBEDDED | 121 | #ifndef KAB_EMBEDDED |
121 | if (QTextDrag::canDecode(e)) | 122 | if (QTextDrag::canDecode(e)) |
122 | e->accept(); | 123 | e->accept(); |
123 | #else //KAB_EMBEDDED | 124 | #else //KAB_EMBEDDED |
124 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); | 125 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); |
125 | #endif //KAB_EMBEDDED | 126 | #endif //KAB_EMBEDDED |
126 | } | 127 | } |
127 | 128 | ||
128 | void AddresseeCardView::dropEvent(QDropEvent *e) | 129 | void AddresseeCardView::dropEvent(QDropEvent *e) |
129 | { | 130 | { |
130 | emit addresseeDropped(e); | 131 | emit addresseeDropped(e); |
131 | } | 132 | } |
132 | 133 | ||
133 | void AddresseeCardView::startDrag() | 134 | void AddresseeCardView::startDrag() |
134 | { | 135 | { |
135 | emit startAddresseeDrag(); | 136 | emit startAddresseeDrag(); |
136 | } | 137 | } |
137 | 138 | ||
138 | 139 | ||
139 | /////////////////////////////// | 140 | /////////////////////////////// |
140 | // KAddressBookCardView | 141 | // KAddressBookCardView |
141 | 142 | ||
142 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | 143 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, |
143 | QWidget *parent, const char *name ) | 144 | QWidget *parent, const char *name ) |
144 | : KAddressBookView( ab, parent, name ) | 145 | : KAddressBookView( ab, parent, name ) |
145 | { | 146 | { |
146 | mShowEmptyFields = false; | 147 | mShowEmptyFields = false; |
147 | 148 | ||
148 | // Init the GUI | 149 | // Init the GUI |
149 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 150 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
150 | 151 | ||
151 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); | 152 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); |
152 | mCardView->setSelectionMode(CardView::Extended); | 153 | mCardView->setSelectionMode(CardView::Extended); |
153 | layout->addWidget(mCardView); | 154 | layout->addWidget(mCardView); |
154 | 155 | ||
155 | // Connect up the signals | 156 | // Connect up the signals |
156 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 157 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
157 | this, SLOT(addresseeExecuted(CardViewItem *))); | 158 | this, SLOT(addresseeExecuted(CardViewItem *))); |
158 | connect(mCardView, SIGNAL(selectionChanged()), | 159 | connect(mCardView, SIGNAL(selectionChanged()), |
159 | this, SLOT(addresseeSelected())); | 160 | this, SLOT(addresseeSelected())); |
160 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), | 161 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), |
161 | this, SIGNAL(dropped(QDropEvent*))); | 162 | this, SIGNAL(dropped(QDropEvent*))); |
162 | connect(mCardView, SIGNAL(startAddresseeDrag()), | 163 | connect(mCardView, SIGNAL(startAddresseeDrag()), |
163 | this, SIGNAL(startDrag())); | 164 | this, SIGNAL(startDrag())); |
164 | } | 165 | } |
165 | 166 | ||
166 | KAddressBookCardView::~KAddressBookCardView() | 167 | KAddressBookCardView::~KAddressBookCardView() |
167 | { | 168 | { |
168 | } | 169 | } |
169 | 170 | ||
170 | void KAddressBookCardView::readConfig(KConfig *config) | 171 | void KAddressBookCardView::readConfig(KConfig *config) |
171 | { | 172 | { |
172 | KAddressBookView::readConfig(config); | 173 | KAddressBookView::readConfig(config); |
173 | 174 | ||
174 | // costum colors? | 175 | // costum colors? |
175 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 176 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
176 | { | 177 | { |
177 | QPalette p( mCardView->palette() ); | 178 | QPalette p( mCardView->palette() ); |
178 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 179 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
179 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 180 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
180 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 181 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
181 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 182 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
182 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 183 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
183 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 184 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
184 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 185 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
185 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 186 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
186 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 187 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
187 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 188 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
188 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 189 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
189 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 190 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
190 | mCardView->viewport()->setPalette( p ); | 191 | mCardView->viewport()->setPalette( p ); |
191 | } | 192 | } |
192 | else | 193 | else |
193 | { | 194 | { |
194 | // needed if turned off during a session. | 195 | // needed if turned off during a session. |
195 | mCardView->viewport()->setPalette( mCardView->palette() ); | 196 | mCardView->viewport()->setPalette( mCardView->palette() ); |
196 | } | 197 | } |
197 | 198 | ||
198 | //custom fonts? | 199 | //custom fonts? |
199 | QFont f( font() ); | 200 | QFont f( font() ); |
200 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 201 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
201 | { | 202 | { |
202 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); | 203 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); |
203 | f.setBold( true ); | 204 | f.setBold( true ); |
204 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 205 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
205 | } | 206 | } |
206 | else | 207 | else |
207 | { | 208 | { |
208 | mCardView->setFont( f ); | 209 | mCardView->setFont( f ); |
209 | f.setBold( true ); | 210 | f.setBold( true ); |
210 | mCardView->setHeaderFont( f ); | 211 | mCardView->setHeaderFont( f ); |
211 | } | 212 | } |
212 | 213 | ||
213 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); | 214 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); |
214 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", | 215 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", |
215 | true)); | 216 | true)); |
216 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); | 217 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); |
217 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); | 218 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); |
218 | 219 | ||
219 | mCardView->setShowEmptyFields( mShowEmptyFields ); | 220 | mCardView->setShowEmptyFields( mShowEmptyFields ); |
220 | 221 | ||
221 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); | 222 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); |
222 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); | 223 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); |
223 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); | 224 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); |
224 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); | 225 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); |
225 | 226 | ||
226 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), | 227 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), |
227 | this, SLOT(addresseeExecuted(CardViewItem *))); | 228 | this, SLOT(addresseeExecuted(CardViewItem *))); |
228 | 229 | ||
229 | if (KABPrefs::instance()->mHonorSingleClick) | 230 | if (KABPrefs::instance()->mHonorSingleClick) |
230 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 231 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
231 | this, SLOT(addresseeExecuted(CardViewItem *))); | 232 | this, SLOT(addresseeExecuted(CardViewItem *))); |
232 | else | 233 | else |
233 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 234 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
234 | this, SLOT(addresseeExecuted(CardViewItem *))); | 235 | this, SLOT(addresseeExecuted(CardViewItem *))); |
235 | 236 | ||
236 | } | 237 | } |
237 | 238 | ||
238 | void KAddressBookCardView::writeConfig( KConfig *config ) | 239 | void KAddressBookCardView::writeConfig( KConfig *config ) |
239 | { | 240 | { |
240 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); | 241 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); |
241 | KAddressBookView::writeConfig( config ); | 242 | KAddressBookView::writeConfig( config ); |
242 | } | 243 | } |
243 | 244 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | |
245 | { | ||
246 | mCardView->clear(); | ||
247 | if ( s.isEmpty() || s == "*" ) { | ||
248 | refresh(); | ||
249 | return; | ||
250 | } | ||
251 | QString pattern = s.lower()+"*"; | ||
252 | QRegExp re; | ||
253 | re.setWildcard(true); // most people understand these better. | ||
254 | re.setCaseSensitive(false); | ||
255 | re.setPattern( pattern ); | ||
256 | if (!re.isValid()) | ||
257 | return; | ||
258 | mCardView->viewport()->setUpdatesEnabled( false ); | ||
259 | KABC::Addressee::List addresseeList = addressees(); | ||
260 | KABC::Addressee::List::Iterator it; | ||
261 | if ( field ) { | ||
262 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
263 | #if QT_VERSION >= 300 | ||
264 | if (re.search(field->value( *it ).lower()) != -1) | ||
265 | #else | ||
266 | if (re.match(field->value( *it ).lower()) != -1) | ||
267 | #endif | ||
268 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | ||
269 | addressBook(), *it, mCardView); | ||
270 | |||
271 | } | ||
272 | } else { | ||
273 | KABC::Field::List fieldList = fields(); | ||
274 | KABC::Field::List::ConstIterator fieldIt; | ||
275 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
276 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
277 | #if QT_VERSION >= 300 | ||
278 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
279 | #else | ||
280 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
281 | #endif | ||
282 | { | ||
283 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | ||
284 | addressBook(), *it, mCardView); | ||
285 | continue; | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | mCardView->viewport()->setUpdatesEnabled( true ); | ||
291 | mCardView->viewport()->update(); | ||
292 | // by default nothing is selected | ||
293 | emit selected(QString::null); | ||
294 | } | ||
244 | QStringList KAddressBookCardView::selectedUids() | 295 | QStringList KAddressBookCardView::selectedUids() |
245 | { | 296 | { |
246 | QStringList uidList; | 297 | QStringList uidList; |
247 | CardViewItem *item; | 298 | CardViewItem *item; |
248 | AddresseeCardViewItem *aItem; | 299 | AddresseeCardViewItem *aItem; |
249 | 300 | ||
250 | for (item = mCardView->firstItem(); item; item = item->nextItem()) | 301 | for (item = mCardView->firstItem(); item; item = item->nextItem()) |
251 | { | 302 | { |
252 | if (item->isSelected()) | 303 | if (item->isSelected()) |
253 | { | 304 | { |
254 | #ifndef KAB_EMBEDDED | 305 | #ifndef KAB_EMBEDDED |
255 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 306 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
256 | #else //KAB_EMBEDDED | 307 | #else //KAB_EMBEDDED |
257 | aItem = (AddresseeCardViewItem*)(item); | 308 | aItem = (AddresseeCardViewItem*)(item); |
258 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
259 | if (aItem) | 310 | if (aItem) |
260 | uidList << aItem->addressee().uid(); | 311 | uidList << aItem->addressee().uid(); |
261 | } | 312 | } |
262 | } | 313 | } |
263 | 314 | ||
264 | return uidList; | 315 | return uidList; |
265 | } | 316 | } |
266 | 317 | ||
267 | void KAddressBookCardView::refresh(QString uid) | 318 | void KAddressBookCardView::refresh(QString uid) |
268 | { | 319 | { |
269 | CardViewItem *item; | 320 | CardViewItem *item; |
270 | AddresseeCardViewItem *aItem; | 321 | AddresseeCardViewItem *aItem; |
271 | 322 | ||
272 | if (uid.isNull()) | 323 | if (uid.isNull()) |
273 | { | 324 | { |
274 | // Rebuild the view | 325 | // Rebuild the view |
275 | mCardView->viewport()->setUpdatesEnabled( false ); | 326 | mCardView->viewport()->setUpdatesEnabled( false ); |
276 | mCardView->clear(); | 327 | mCardView->clear(); |
277 | 328 | ||
278 | KABC::Addressee::List addresseeList = addressees(); | 329 | KABC::Addressee::List addresseeList = addressees(); |
279 | KABC::Addressee::List::Iterator iter; | 330 | KABC::Addressee::List::Iterator iter; |
280 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) | 331 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) |
281 | { | 332 | { |
282 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, | 333 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, |
283 | addressBook(), *iter, mCardView); | 334 | addressBook(), *iter, mCardView); |
284 | } | 335 | } |
285 | mCardView->viewport()->setUpdatesEnabled( true ); | 336 | mCardView->viewport()->setUpdatesEnabled( true ); |
286 | mCardView->viewport()->update(); | 337 | mCardView->viewport()->update(); |
287 | 338 | ||
288 | // by default nothing is selected | 339 | // by default nothing is selected |
289 | emit selected(QString::null); | 340 | emit selected(QString::null); |
290 | } | 341 | } |
291 | else | 342 | else |
292 | { | 343 | { |
293 | // Try to find the one to refresh | 344 | // Try to find the one to refresh |
294 | bool found = false; | 345 | bool found = false; |
295 | for (item = mCardView->firstItem(); item && !found; | 346 | for (item = mCardView->firstItem(); item && !found; |
296 | item = item->nextItem()) | 347 | item = item->nextItem()) |
297 | { | 348 | { |
298 | #ifndef KAB_EMBEDDED | 349 | #ifndef KAB_EMBEDDED |
299 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 350 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
300 | #else //KAB_EMBEDDED | 351 | #else //KAB_EMBEDDED |
301 | aItem = (AddresseeCardViewItem*)(item); | 352 | aItem = (AddresseeCardViewItem*)(item); |
302 | #endif //KAB_EMBEDDED | 353 | #endif //KAB_EMBEDDED |
303 | 354 | ||
304 | if ((aItem) && (aItem->addressee().uid() == uid)) | 355 | if ((aItem) && (aItem->addressee().uid() == uid)) |
305 | { | 356 | { |
306 | aItem->refresh(); | 357 | aItem->refresh(); |
307 | found = true; | 358 | found = true; |
308 | } | 359 | } |
309 | } | 360 | } |
310 | } | 361 | } |
311 | } | 362 | } |
312 | 363 | ||
313 | void KAddressBookCardView::setSelected(QString uid, bool selected) | 364 | void KAddressBookCardView::setSelected(QString uid, bool selected) |
314 | { | 365 | { |
315 | CardViewItem *item; | 366 | CardViewItem *item; |
316 | AddresseeCardViewItem *aItem; | 367 | AddresseeCardViewItem *aItem; |
317 | 368 | ||
318 | if (uid.isNull()) | 369 | if (uid.isNull()) |
319 | { | 370 | { |
320 | mCardView->selectAll(selected); | 371 | mCardView->selectAll(selected); |
321 | } | 372 | } |
322 | else | 373 | else |
323 | { | 374 | { |
324 | bool found = false; | 375 | bool found = false; |
325 | for (item = mCardView->firstItem(); item && !found; | 376 | for (item = mCardView->firstItem(); item && !found; |
326 | item = item->nextItem()) | 377 | item = item->nextItem()) |
327 | { | 378 | { |
328 | #ifndef KAB_EMBEDDED | 379 | #ifndef KAB_EMBEDDED |
329 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 380 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
330 | #else //KAB_EMBEDDED | 381 | #else //KAB_EMBEDDED |
331 | aItem = (AddresseeCardViewItem*)(item); | 382 | aItem = (AddresseeCardViewItem*)(item); |
332 | #endif //KAB_EMBEDDED | 383 | #endif //KAB_EMBEDDED |
333 | 384 | ||
334 | if ((aItem) && (aItem->addressee().uid() == uid)) | 385 | if ((aItem) && (aItem->addressee().uid() == uid)) |
335 | { | 386 | { |
336 | mCardView->setSelected(aItem, selected); | 387 | mCardView->setSelected(aItem, selected); |
337 | mCardView->ensureItemVisible(item); | 388 | mCardView->ensureItemVisible(item); |
338 | found = true; | 389 | found = true; |
339 | } | 390 | } |
340 | } | 391 | } |
341 | } | 392 | } |
342 | } | 393 | } |
343 | 394 | ||
344 | //US added an additional method without parameter | 395 | //US added an additional method without parameter |
345 | void KAddressBookCardView::setSelected() | 396 | void KAddressBookCardView::setSelected() |
346 | { | 397 | { |
347 | setSelected(QString::null, true); | 398 | setSelected(QString::null, true); |
348 | } | 399 | } |
349 | 400 | ||
350 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) | 401 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) |
351 | { | 402 | { |
352 | #ifndef KAB_EMBEDDED | 403 | #ifndef KAB_EMBEDDED |
353 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 404 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
354 | #else //KAB_EMBEDDED | 405 | #else //KAB_EMBEDDED |
355 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); | 406 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); |
356 | #endif //KAB_EMBEDDED | 407 | #endif //KAB_EMBEDDED |
357 | if (aItem) | 408 | if (aItem) |
358 | { | 409 | { |
359 | //kdDebug()<<"... even has a valid item:)"<<endl; | 410 | //kdDebug()<<"... even has a valid item:)"<<endl; |
360 | emit executed(aItem->addressee().uid()); | 411 | emit executed(aItem->addressee().uid()); |
361 | } | 412 | } |
362 | } | 413 | } |
363 | 414 | ||
364 | void KAddressBookCardView::addresseeSelected() | 415 | void KAddressBookCardView::addresseeSelected() |
365 | { | 416 | { |
366 | CardViewItem *item; | 417 | CardViewItem *item; |
367 | AddresseeCardViewItem *aItem; | 418 | AddresseeCardViewItem *aItem; |
368 | 419 | ||
369 | bool found = false; | 420 | bool found = false; |
370 | for (item = mCardView->firstItem(); item && !found; | 421 | for (item = mCardView->firstItem(); item && !found; |
371 | item = item->nextItem()) | 422 | item = item->nextItem()) |
372 | { | 423 | { |
373 | if (item->isSelected()) | 424 | if (item->isSelected()) |
374 | { | 425 | { |
375 | #ifndef KAB_EMBEDDED | 426 | #ifndef KAB_EMBEDDED |
376 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 427 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
377 | #else //KAB_EMBEDDED | 428 | #else //KAB_EMBEDDED |
378 | aItem = (AddresseeCardViewItem*)(item); | 429 | aItem = (AddresseeCardViewItem*)(item); |
379 | #endif //KAB_EMBEDDED | 430 | #endif //KAB_EMBEDDED |
380 | if ( aItem ) | 431 | if ( aItem ) |
381 | { | 432 | { |
382 | emit selected(aItem->addressee().uid()); | 433 | emit selected(aItem->addressee().uid()); |
383 | found = true; | 434 | found = true; |
384 | } | 435 | } |
385 | } | 436 | } |
386 | } | 437 | } |
387 | 438 | ||
388 | if (!found) | 439 | if (!found) |
389 | emit selected(QString::null); | 440 | emit selected(QString::null); |
390 | 441 | ||
391 | } | 442 | } |
392 | #ifndef KAB_EMBEDDED | 443 | #ifndef KAB_EMBEDDED |
393 | #include "kaddressbookcardview.moc" | 444 | #include "kaddressbookcardview.moc" |
394 | #endif //KAB_EMBEDDED | 445 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h index cd70371..b8efb01 100644 --- a/kaddressbook/views/kaddressbookcardview.h +++ b/kaddressbook/views/kaddressbookcardview.h | |||
@@ -1,117 +1,117 @@ | |||
1 | #ifndef KADDRESSBOOKCARDVIEW_H | 1 | #ifndef KADDRESSBOOKCARDVIEW_H |
2 | #define KADDRESSBOOKCARDVIEW_H | 2 | #define KADDRESSBOOKCARDVIEW_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | This file is part of KAddressBook. | 5 | This file is part of KAddressBook. |
6 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 6 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #ifndef KAB_EMBEDDED | 28 | #ifndef KAB_EMBEDDED |
29 | #include <kiconview.h> | 29 | #include <kiconview.h> |
30 | #else //KAB_EMBEDDED | 30 | #else //KAB_EMBEDDED |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #endif //KAB_EMBEDDED | 32 | #endif //KAB_EMBEDDED |
33 | 33 | ||
34 | #include "cardview.h" | 34 | #include "cardview.h" |
35 | #include "kaddressbookview.h" | 35 | #include "kaddressbookview.h" |
36 | #include "configurecardviewdialog.h" | 36 | #include "configurecardviewdialog.h" |
37 | 37 | ||
38 | class QDragEnterEvent; | 38 | class QDragEnterEvent; |
39 | class QDragEntryEvent; | 39 | class QDragEntryEvent; |
40 | class QDropEvent; | 40 | class QDropEvent; |
41 | class KConfig; | 41 | class KConfig; |
42 | class AddresseeCardView; | 42 | class AddresseeCardView; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | This view uses the CardView class to create a card view. At some | 45 | This view uses the CardView class to create a card view. At some |
46 | point in the future I think this will be the default view of | 46 | point in the future I think this will be the default view of |
47 | KAddressBook. | 47 | KAddressBook. |
48 | */ | 48 | */ |
49 | class KAddressBookCardView : public KAddressBookView | 49 | class KAddressBookCardView : public KAddressBookView |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | 52 | ||
53 | public: | 53 | public: |
54 | KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, | 54 | KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, |
55 | const char *name = 0 ); | 55 | const char *name = 0 ); |
56 | virtual ~KAddressBookCardView(); | 56 | virtual ~KAddressBookCardView(); |
57 | 57 | void doSearch( const QString& s,KABC::Field *field ); | |
58 | virtual QStringList selectedUids(); | 58 | virtual QStringList selectedUids(); |
59 | virtual QString type() const { return "Card"; } | 59 | virtual QString type() const { return "Card"; } |
60 | 60 | ||
61 | virtual void readConfig(KConfig *config); | 61 | virtual void readConfig(KConfig *config); |
62 | virtual void writeConfig(KConfig *); | 62 | virtual void writeConfig(KConfig *); |
63 | 63 | ||
64 | public slots: | 64 | public slots: |
65 | void refresh(QString uid = QString::null); | 65 | void refresh(QString uid = QString::null); |
66 | void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); | 66 | void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); |
67 | //US added an additional method without parameter | 67 | //US added an additional method without parameter |
68 | void setSelected(); | 68 | void setSelected(); |
69 | 69 | ||
70 | protected slots: | 70 | protected slots: |
71 | void addresseeExecuted(CardViewItem *item); | 71 | void addresseeExecuted(CardViewItem *item); |
72 | void addresseeSelected(); | 72 | void addresseeSelected(); |
73 | 73 | ||
74 | private: | 74 | private: |
75 | AddresseeCardView *mCardView; | 75 | AddresseeCardView *mCardView; |
76 | bool mShowEmptyFields; | 76 | bool mShowEmptyFields; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | class AddresseeCardView : public CardView | 79 | class AddresseeCardView : public CardView |
80 | { | 80 | { |
81 | Q_OBJECT | 81 | Q_OBJECT |
82 | public: | 82 | public: |
83 | AddresseeCardView(QWidget *parent, const char *name = 0); | 83 | AddresseeCardView(QWidget *parent, const char *name = 0); |
84 | ~AddresseeCardView(); | 84 | ~AddresseeCardView(); |
85 | 85 | ||
86 | signals: | 86 | signals: |
87 | void startAddresseeDrag(); | 87 | void startAddresseeDrag(); |
88 | void addresseeDropped(QDropEvent *); | 88 | void addresseeDropped(QDropEvent *); |
89 | 89 | ||
90 | protected: | 90 | protected: |
91 | virtual void dragEnterEvent(QDragEnterEvent *); | 91 | virtual void dragEnterEvent(QDragEnterEvent *); |
92 | virtual void dropEvent(QDropEvent *); | 92 | virtual void dropEvent(QDropEvent *); |
93 | virtual void startDrag(); | 93 | virtual void startDrag(); |
94 | }; | 94 | }; |
95 | 95 | ||
96 | 96 | ||
97 | class CardViewFactory : public ViewFactory | 97 | class CardViewFactory : public ViewFactory |
98 | { | 98 | { |
99 | public: | 99 | public: |
100 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 100 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
101 | { | 101 | { |
102 | return new KAddressBookCardView( ab, parent, name ); | 102 | return new KAddressBookCardView( ab, parent, name ); |
103 | } | 103 | } |
104 | 104 | ||
105 | QString type() const { return "Card"; } | 105 | QString type() const { return "Card"; } |
106 | 106 | ||
107 | QString description() const { return i18n( "Rolodex style cards represent contacts." ); } | 107 | QString description() const { return i18n( "Rolodex style cards represent contacts." ); } |
108 | 108 | ||
109 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, | 109 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, |
110 | const char *name = 0 ) | 110 | const char *name = 0 ) |
111 | { | 111 | { |
112 | return new ConfigureCardViewWidget( ab, parent, name ); | 112 | return new ConfigureCardViewWidget( ab, parent, name ); |
113 | } | 113 | } |
114 | }; | 114 | }; |
115 | 115 | ||
116 | 116 | ||
117 | #endif | 117 | #endif |
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index 50ff285..78d63b0 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp | |||
@@ -1,378 +1,425 @@ | |||
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 <qiconview.h> | 25 | #include <qiconview.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | 27 | ||
28 | #include <kabc/addressee.h> | 28 | #include <kabc/addressee.h> |
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | #include <kdebug.h> | 30 | #include <kdebug.h> |
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #else //KAB_EMBEDDED | 35 | #else //KAB_EMBEDDED |
36 | #endif //KAB_EMBEDDED | 36 | #endif //KAB_EMBEDDED |
37 | 37 | ||
38 | #include <kabc/addressbook.h> | 38 | #include <kabc/addressbook.h> |
39 | #include "kabprefs.h" | 39 | #include "kabprefs.h" |
40 | #include "viewmanager.h" | 40 | #include "viewmanager.h" |
41 | #include "kaddressbookiconview.h" | 41 | #include "kaddressbookiconview.h" |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <kglobal.h> | 43 | #include <kglobal.h> |
44 | /*US transfered to the headerfile | 44 | /*US transfered to the headerfile |
45 | class IconViewFactory : public ViewFactory | 45 | class IconViewFactory : public ViewFactory |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 48 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
49 | { | 49 | { |
50 | return new KAddressBookIconView( ab, parent, name ); | 50 | return new KAddressBookIconView( ab, parent, name ); |
51 | } | 51 | } |
52 | 52 | ||
53 | QString type() const { return "Icon"; } | 53 | QString type() const { return "Icon"; } |
54 | 54 | ||
55 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } | 55 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } |
56 | }; | 56 | }; |
57 | 57 | ||
58 | */ | 58 | */ |
59 | 59 | ||
60 | extern "C" { | 60 | extern "C" { |
61 | void *init_libkaddrbk_iconview() | 61 | void *init_libkaddrbk_iconview() |
62 | { | 62 | { |
63 | return ( new IconViewFactory ); | 63 | return ( new IconViewFactory ); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | //////////////////////////////// | 67 | //////////////////////////////// |
68 | // AddresseeIconView (internal class) | 68 | // AddresseeIconView (internal class) |
69 | #ifndef KAB_EMBEDDED | 69 | #ifndef KAB_EMBEDDED |
70 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 70 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
71 | : KIconView(parent, name) | 71 | : KIconView(parent, name) |
72 | #else //KAB_EMBEDDED | 72 | #else //KAB_EMBEDDED |
73 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 73 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
74 | : QIconView(parent, name) | 74 | : QIconView(parent, name) |
75 | #endif //KAB_EMBEDDED | 75 | #endif //KAB_EMBEDDED |
76 | 76 | ||
77 | { | 77 | { |
78 | setSelectionMode( QIconView::Extended ); | 78 | setSelectionMode( QIconView::Extended ); |
79 | setResizeMode( QIconView::Adjust ); | 79 | setResizeMode( QIconView::Adjust ); |
80 | setWordWrapIconText( true ); | 80 | setWordWrapIconText( true ); |
81 | setGridX( 100 ); | 81 | setGridX( 100 ); |
82 | setItemsMovable(false); | 82 | setItemsMovable(false); |
83 | setSorting(true, true); | 83 | setSorting(true, true); |
84 | 84 | ||
85 | 85 | ||
86 | //US ??? setMode( KIconView::Select ); | 86 | //US ??? setMode( KIconView::Select ); |
87 | 87 | ||
88 | #ifndef KAB_EMBEDDED | 88 | #ifndef KAB_EMBEDDED |
89 | 89 | ||
90 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), | 90 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), |
91 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); | 91 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); |
92 | #endif //KAB_EMBEDDED | 92 | #endif //KAB_EMBEDDED |
93 | } | 93 | } |
94 | 94 | ||
95 | AddresseeIconView::~AddresseeIconView() | 95 | AddresseeIconView::~AddresseeIconView() |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
99 | |||
99 | void AddresseeIconView::itemDropped(QDropEvent *e, | 100 | void AddresseeIconView::itemDropped(QDropEvent *e, |
100 | const QValueList<QIconDragItem> &) | 101 | const QValueList<QIconDragItem> &) |
101 | { | 102 | { |
102 | emit addresseeDropped(e); | 103 | emit addresseeDropped(e); |
103 | } | 104 | } |
104 | 105 | ||
105 | QDragObject *AddresseeIconView::dragObject() | 106 | QDragObject *AddresseeIconView::dragObject() |
106 | { | 107 | { |
107 | emit startAddresseeDrag(); | 108 | emit startAddresseeDrag(); |
108 | 109 | ||
109 | // We never want IconView to start the drag | 110 | // We never want IconView to start the drag |
110 | return 0; | 111 | return 0; |
111 | } | 112 | } |
112 | //////////////////////////////// | 113 | //////////////////////////////// |
113 | // AddresseeIconViewItem (internal class) | 114 | // AddresseeIconViewItem (internal class) |
114 | #ifndef KAB_EMBEDDED | 115 | #ifndef KAB_EMBEDDED |
115 | class AddresseeIconViewItem : public KIconViewItem | 116 | class AddresseeIconViewItem : public KIconViewItem |
116 | #else //KAB_EMBEDDED | 117 | #else //KAB_EMBEDDED |
117 | class AddresseeIconViewItem : public QIconViewItem | 118 | class AddresseeIconViewItem : public QIconViewItem |
118 | #endif //KAB_EMBEDDED | 119 | #endif //KAB_EMBEDDED |
119 | { | 120 | { |
120 | public: | 121 | public: |
121 | #ifndef KAB_EMBEDDED | 122 | #ifndef KAB_EMBEDDED |
122 | AddresseeIconViewItem(const KABC::Field::List &fields, | 123 | AddresseeIconViewItem(const KABC::Field::List &fields, |
123 | KABC::AddressBook *doc, const KABC::Addressee &a, | 124 | KABC::AddressBook *doc, const KABC::Addressee &a, |
124 | QIconView *parent) | 125 | QIconView *parent) |
125 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 126 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
126 | #else //KAB_EMBEDDED | 127 | #else //KAB_EMBEDDED |
127 | AddresseeIconViewItem(const KABC::Field::List &fields, | 128 | AddresseeIconViewItem(const KABC::Field::List &fields, |
128 | KABC::AddressBook *doc, const KABC::Addressee &a, | 129 | KABC::AddressBook *doc, const KABC::Addressee &a, |
129 | QIconView *parent) | 130 | QIconView *parent) |
130 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 131 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
131 | #endif //KAB_EMBEDDED | 132 | #endif //KAB_EMBEDDED |
132 | { | 133 | { |
133 | if ( mFields.isEmpty() ) { | 134 | if ( mFields.isEmpty() ) { |
134 | mFields = KABC::Field::defaultFields(); | 135 | mFields = KABC::Field::defaultFields(); |
135 | } | 136 | } |
136 | refresh(); | 137 | refresh(); |
137 | } | 138 | } |
138 | 139 | ||
139 | const KABC::Addressee &addressee() const { return mAddressee; } | 140 | const KABC::Addressee &addressee() const { return mAddressee; } |
140 | 141 | ||
141 | void refresh() | 142 | void refresh() |
142 | { | 143 | { |
143 | // Update our addressee, since it may have changed elsewhere | 144 | // Update our addressee, since it may have changed elsewhere |
144 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 145 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
145 | 146 | ||
146 | if (!mAddressee.isEmpty()) | 147 | if (!mAddressee.isEmpty()) |
147 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); | 148 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); |
148 | 149 | ||
149 | QPixmap icon; | 150 | QPixmap icon; |
150 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); | 151 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); |
151 | KABC::Picture pic = mAddressee.photo(); | 152 | KABC::Picture pic = mAddressee.photo(); |
152 | if ( pic.data().isNull() ) | 153 | if ( pic.data().isNull() ) |
153 | pic = mAddressee.logo(); | 154 | pic = mAddressee.logo(); |
154 | 155 | ||
155 | if ( pic.isIntern() && !pic.data().isNull() ) { | 156 | if ( pic.isIntern() && !pic.data().isNull() ) { |
156 | QImage img = pic.data(); | 157 | QImage img = pic.data(); |
157 | #ifndef KAB_EMBEDDED | 158 | #ifndef KAB_EMBEDDED |
158 | if ( img.width() > img.height() ) | 159 | if ( img.width() > img.height() ) |
159 | icon = img.scaleWidth( 32 ); | 160 | icon = img.scaleWidth( 32 ); |
160 | else | 161 | else |
161 | icon = img.scaleHeight( 32 ); | 162 | icon = img.scaleHeight( 32 ); |
162 | #else //KAB_EMBEDDED | 163 | #else //KAB_EMBEDDED |
163 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); | 164 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); |
164 | icon.convertFromImage(img.smoothScale(32, 32)); | 165 | icon.convertFromImage(img.smoothScale(32, 32)); |
165 | #endif //KAB_EMBEDDED | 166 | #endif //KAB_EMBEDDED |
166 | 167 | ||
167 | } else | 168 | } else |
168 | icon = defaultIcon; | 169 | icon = defaultIcon; |
169 | 170 | ||
170 | setPixmap( icon ); | 171 | setPixmap( icon ); |
171 | } | 172 | } |
172 | 173 | ||
173 | private: | 174 | private: |
174 | KABC::Field::List mFields; | 175 | KABC::Field::List mFields; |
175 | KABC::AddressBook *mDocument; | 176 | KABC::AddressBook *mDocument; |
176 | KABC::Addressee mAddressee; | 177 | KABC::Addressee mAddressee; |
177 | }; | 178 | }; |
178 | 179 | ||
179 | /////////////////////////////// | 180 | /////////////////////////////// |
180 | // KAddressBookView | 181 | // KAddressBookView |
181 | 182 | ||
182 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | 183 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, |
183 | QWidget *parent, const char *name) | 184 | QWidget *parent, const char *name) |
184 | : KAddressBookView( ab, parent, name ) | 185 | : KAddressBookView( ab, parent, name ) |
185 | { | 186 | { |
186 | // Init the GUI | 187 | // Init the GUI |
187 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 188 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
188 | 189 | ||
189 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); | 190 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); |
190 | layout->addWidget(mIconView); | 191 | layout->addWidget(mIconView); |
191 | 192 | ||
192 | // Connect up the signals | 193 | // Connect up the signals |
193 | 194 | ||
194 | //US method executed is part of KIconView | 195 | //US method executed is part of KIconView |
195 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 196 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
196 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 197 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
197 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 198 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
198 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 199 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
199 | 200 | ||
200 | connect(mIconView, SIGNAL(selectionChanged()), | 201 | connect(mIconView, SIGNAL(selectionChanged()), |
201 | this, SLOT(addresseeSelected())); | 202 | this, SLOT(addresseeSelected())); |
202 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), | 203 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), |
203 | this, SIGNAL(dropped(QDropEvent*))); | 204 | this, SIGNAL(dropped(QDropEvent*))); |
204 | connect(mIconView, SIGNAL(startAddresseeDrag()), | 205 | connect(mIconView, SIGNAL(startAddresseeDrag()), |
205 | this, SIGNAL(startDrag())); | 206 | this, SIGNAL(startDrag())); |
206 | } | 207 | } |
207 | 208 | ||
208 | KAddressBookIconView::~KAddressBookIconView() | 209 | KAddressBookIconView::~KAddressBookIconView() |
209 | { | 210 | { |
210 | } | 211 | } |
211 | 212 | ||
212 | void KAddressBookIconView::readConfig(KConfig *config) | 213 | void KAddressBookIconView::readConfig(KConfig *config) |
213 | { | 214 | { |
214 | KAddressBookView::readConfig(config); | 215 | KAddressBookView::readConfig(config); |
215 | 216 | ||
216 | //US method executed is part of KIconView | 217 | //US method executed is part of KIconView |
217 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), | 218 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), |
218 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 219 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
219 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 220 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
220 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 221 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
221 | 222 | ||
222 | //US method executed is part of KIconView. Use selectionChanged instead | 223 | //US method executed is part of KIconView. Use selectionChanged instead |
223 | /*US | 224 | /*US |
224 | if (KABPrefs::instance()->mHonorSingleClick) | 225 | if (KABPrefs::instance()->mHonorSingleClick) |
225 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 226 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
226 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 227 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
227 | else | 228 | else |
228 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), | 229 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), |
229 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 230 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
230 | */ | 231 | */ |
231 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 232 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
232 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 233 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
233 | 234 | ||
234 | } | 235 | } |
236 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | ||
237 | { | ||
238 | mIconView->clear(); | ||
239 | mIconList.clear(); | ||
240 | if ( s.isEmpty() || s == "*" ) { | ||
241 | refresh(); | ||
242 | return; | ||
243 | } | ||
244 | QString pattern = s.lower()+"*"; | ||
245 | QRegExp re; | ||
246 | re.setWildcard(true); // most people understand these better. | ||
247 | re.setCaseSensitive(false); | ||
248 | re.setPattern( pattern ); | ||
249 | if (!re.isValid()) | ||
250 | return; | ||
251 | KABC::Addressee::List addresseeList = addressees(); | ||
252 | KABC::Addressee::List::Iterator it; | ||
253 | if ( field ) { | ||
254 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
255 | #if QT_VERSION >= 300 | ||
256 | if (re.search(field->value( *it ).lower()) != -1) | ||
257 | #else | ||
258 | if (re.match(field->value( *it ).lower()) != -1) | ||
259 | #endif | ||
260 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | ||
261 | |||
235 | 262 | ||
263 | } | ||
264 | } else { | ||
265 | KABC::Field::List fieldList = fields(); | ||
266 | KABC::Field::List::ConstIterator fieldIt; | ||
267 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
268 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
269 | #if QT_VERSION >= 300 | ||
270 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
271 | #else | ||
272 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
273 | #endif | ||
274 | { | ||
275 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | ||
276 | continue; | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | } | ||
281 | mIconView->arrangeItemsInGrid( true ); | ||
282 | } | ||
236 | QStringList KAddressBookIconView::selectedUids() | 283 | QStringList KAddressBookIconView::selectedUids() |
237 | { | 284 | { |
238 | QStringList uidList; | 285 | QStringList uidList; |
239 | QIconViewItem *item; | 286 | QIconViewItem *item; |
240 | AddresseeIconViewItem *aItem; | 287 | AddresseeIconViewItem *aItem; |
241 | 288 | ||
242 | for (item = mIconView->firstItem(); item; item = item->nextItem()) | 289 | for (item = mIconView->firstItem(); item; item = item->nextItem()) |
243 | { | 290 | { |
244 | if (item->isSelected()) | 291 | if (item->isSelected()) |
245 | { | 292 | { |
246 | #ifndef KAB_EMBEDDED | 293 | #ifndef KAB_EMBEDDED |
247 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 294 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
248 | #else //KAB_EMBEDDED | 295 | #else //KAB_EMBEDDED |
249 | aItem = (AddresseeIconViewItem*)(item); | 296 | aItem = (AddresseeIconViewItem*)(item); |
250 | #endif //KAB_EMBEDDED | 297 | #endif //KAB_EMBEDDED |
251 | if (aItem) | 298 | if (aItem) |
252 | uidList << aItem->addressee().uid(); | 299 | uidList << aItem->addressee().uid(); |
253 | } | 300 | } |
254 | } | 301 | } |
255 | 302 | ||
256 | return uidList; | 303 | return uidList; |
257 | } | 304 | } |
258 | 305 | ||
259 | void KAddressBookIconView::refresh(QString uid) | 306 | void KAddressBookIconView::refresh(QString uid) |
260 | { | 307 | { |
261 | QIconViewItem *item; | 308 | QIconViewItem *item; |
262 | AddresseeIconViewItem *aItem; | 309 | AddresseeIconViewItem *aItem; |
263 | 310 | ||
264 | if ( uid.isNull() ) { | 311 | if ( uid.isNull() ) { |
265 | // Rebuild the view | 312 | // Rebuild the view |
266 | mIconView->clear(); | 313 | mIconView->clear(); |
267 | mIconList.clear(); | 314 | mIconList.clear(); |
268 | 315 | ||
269 | KABC::Addressee::List addresseeList = addressees(); | 316 | KABC::Addressee::List addresseeList = addressees(); |
270 | KABC::Addressee::List::Iterator iter; | 317 | KABC::Addressee::List::Iterator iter; |
271 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) | 318 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) |
272 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); | 319 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); |
273 | 320 | ||
274 | mIconView->arrangeItemsInGrid( true ); | 321 | mIconView->arrangeItemsInGrid( true ); |
275 | 322 | ||
276 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) | 323 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) |
277 | { | 324 | { |
278 | #ifndef KAB_EMBEDDED | 325 | #ifndef KAB_EMBEDDED |
279 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); | 326 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); |
280 | #else //KAB_EMBEDDED | 327 | #else //KAB_EMBEDDED |
281 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); | 328 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); |
282 | #endif //KAB_EMBEDDED | 329 | #endif //KAB_EMBEDDED |
283 | mIconList.append( aivi ); | 330 | mIconList.append( aivi ); |
284 | } | 331 | } |
285 | 332 | ||
286 | } else { | 333 | } else { |
287 | // Try to find the one to refresh | 334 | // Try to find the one to refresh |
288 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { | 335 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { |
289 | #ifndef KAB_EMBEDDED | 336 | #ifndef KAB_EMBEDDED |
290 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 337 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
291 | #else //KAB_EMBEDDED | 338 | #else //KAB_EMBEDDED |
292 | aItem = (AddresseeIconViewItem*)(item); | 339 | aItem = (AddresseeIconViewItem*)(item); |
293 | #endif //KAB_EMBEDDED | 340 | #endif //KAB_EMBEDDED |
294 | if ((aItem) && (aItem->addressee().uid() == uid)) { | 341 | if ((aItem) && (aItem->addressee().uid() == uid)) { |
295 | aItem->refresh(); | 342 | aItem->refresh(); |
296 | mIconView->arrangeItemsInGrid( true ); | 343 | mIconView->arrangeItemsInGrid( true ); |
297 | return; | 344 | return; |
298 | } | 345 | } |
299 | } | 346 | } |
300 | refresh( QString::null ); | 347 | refresh( QString::null ); |
301 | } | 348 | } |
302 | } | 349 | } |
303 | 350 | ||
304 | void KAddressBookIconView::setSelected(QString uid, bool selected) | 351 | void KAddressBookIconView::setSelected(QString uid, bool selected) |
305 | { | 352 | { |
306 | QIconViewItem *item; | 353 | QIconViewItem *item; |
307 | AddresseeIconViewItem *aItem; | 354 | AddresseeIconViewItem *aItem; |
308 | 355 | ||
309 | if (uid.isNull()) | 356 | if (uid.isNull()) |
310 | { | 357 | { |
311 | mIconView->selectAll(selected); | 358 | mIconView->selectAll(selected); |
312 | } | 359 | } |
313 | else | 360 | else |
314 | { | 361 | { |
315 | bool found = false; | 362 | bool found = false; |
316 | for (item = mIconView->firstItem(); item && !found; | 363 | for (item = mIconView->firstItem(); item && !found; |
317 | item = item->nextItem()) | 364 | item = item->nextItem()) |
318 | { | 365 | { |
319 | #ifndef KAB_EMBEDDED | 366 | #ifndef KAB_EMBEDDED |
320 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 367 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
321 | #else //KAB_EMBEDDED | 368 | #else //KAB_EMBEDDED |
322 | aItem = (AddresseeIconViewItem*)(item); | 369 | aItem = (AddresseeIconViewItem*)(item); |
323 | #endif //KAB_EMBEDDED | 370 | #endif //KAB_EMBEDDED |
324 | 371 | ||
325 | if ((aItem) && (aItem->addressee().uid() == uid)) | 372 | if ((aItem) && (aItem->addressee().uid() == uid)) |
326 | { | 373 | { |
327 | mIconView->setSelected(aItem, selected); | 374 | mIconView->setSelected(aItem, selected); |
328 | mIconView->ensureItemVisible( aItem ); | 375 | mIconView->ensureItemVisible( aItem ); |
329 | found = true; | 376 | found = true; |
330 | } | 377 | } |
331 | } | 378 | } |
332 | } | 379 | } |
333 | } | 380 | } |
334 | 381 | ||
335 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) | 382 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) |
336 | { | 383 | { |
337 | #ifndef KAB_EMBEDDED | 384 | #ifndef KAB_EMBEDDED |
338 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 385 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
339 | #else //KAB_EMBEDDED | 386 | #else //KAB_EMBEDDED |
340 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); | 387 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); |
341 | #endif //KAB_EMBEDDED | 388 | #endif //KAB_EMBEDDED |
342 | 389 | ||
343 | if (aItem) { | 390 | if (aItem) { |
344 | emit executed(aItem->addressee().uid()); | 391 | emit executed(aItem->addressee().uid()); |
345 | } | 392 | } |
346 | } | 393 | } |
347 | 394 | ||
348 | void KAddressBookIconView::addresseeSelected() | 395 | void KAddressBookIconView::addresseeSelected() |
349 | { | 396 | { |
350 | QIconViewItem *item; | 397 | QIconViewItem *item; |
351 | AddresseeIconViewItem *aItem; | 398 | AddresseeIconViewItem *aItem; |
352 | 399 | ||
353 | bool found = false; | 400 | bool found = false; |
354 | for (item = mIconView->firstItem(); item && !found; | 401 | for (item = mIconView->firstItem(); item && !found; |
355 | item = item->nextItem()) | 402 | item = item->nextItem()) |
356 | { | 403 | { |
357 | if (item->isSelected()) | 404 | if (item->isSelected()) |
358 | { | 405 | { |
359 | #ifndef KAB_EMBEDDED | 406 | #ifndef KAB_EMBEDDED |
360 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 407 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
361 | #else //KAB_EMBEDDED | 408 | #else //KAB_EMBEDDED |
362 | aItem = (AddresseeIconViewItem*)(item); | 409 | aItem = (AddresseeIconViewItem*)(item); |
363 | #endif //KAB_EMBEDDED | 410 | #endif //KAB_EMBEDDED |
364 | if (aItem) | 411 | if (aItem) |
365 | { | 412 | { |
366 | emit selected(aItem->addressee().uid()); | 413 | emit selected(aItem->addressee().uid()); |
367 | found = true; | 414 | found = true; |
368 | } | 415 | } |
369 | } | 416 | } |
370 | } | 417 | } |
371 | 418 | ||
372 | if (!found) | 419 | if (!found) |
373 | emit selected(QString::null); | 420 | emit selected(QString::null); |
374 | } | 421 | } |
375 | 422 | ||
376 | #ifndef KAB_EMBEDDED | 423 | #ifndef KAB_EMBEDDED |
377 | #include "kaddressbookiconview.moc" | 424 | #include "kaddressbookiconview.moc" |
378 | #endif //KAB_EMBEDDED | 425 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbookiconview.h b/kaddressbook/views/kaddressbookiconview.h index 3afada3..963ee7c 100644 --- a/kaddressbook/views/kaddressbookiconview.h +++ b/kaddressbook/views/kaddressbookiconview.h | |||
@@ -1,130 +1,131 @@ | |||
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 KADDRESSBOOKICONVIEW_H | 24 | #ifndef KADDRESSBOOKICONVIEW_H |
25 | #define KADDRESSBOOKICONVIEW_H | 25 | #define KADDRESSBOOKICONVIEW_H |
26 | 26 | ||
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #ifndef KAB_EMBEDDED | 28 | #ifndef KAB_EMBEDDED |
29 | #include <kiconview.h> | 29 | #include <kiconview.h> |
30 | #else //KAB_EMBEDDED | 30 | #else //KAB_EMBEDDED |
31 | #include <qiconview.h> | 31 | #include <qiconview.h> |
32 | #include <qptrlist.h> | 32 | #include <qptrlist.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #endif //KAB_EMBEDDED | 34 | #endif //KAB_EMBEDDED |
35 | #include "kaddressbookview.h" | 35 | #include "kaddressbookview.h" |
36 | 36 | ||
37 | class QIconViewItem; | 37 | class QIconViewItem; |
38 | class KConfig; | 38 | class KConfig; |
39 | class AddresseeIconView; | 39 | class AddresseeIconView; |
40 | class AddresseeIconViewItem; | 40 | class AddresseeIconViewItem; |
41 | class QIconDragItem; | 41 | class QIconDragItem; |
42 | class KAddressBookIconView; | 42 | class KAddressBookIconView; |
43 | 43 | ||
44 | namespace KABC { class AddressBook; } | 44 | namespace KABC { class AddressBook; } |
45 | 45 | ||
46 | /** This is an example kaddressbook view that is implemented using | 46 | /** This is an example kaddressbook view that is implemented using |
47 | * KIconView. This view is not the most useful view, but it displays | 47 | * KIconView. This view is not the most useful view, but it displays |
48 | * how simple implementing a new view can be. | 48 | * how simple implementing a new view can be. |
49 | */ | 49 | */ |
50 | class KAddressBookIconView : public KAddressBookView | 50 | class KAddressBookIconView : public KAddressBookView |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent, | 55 | KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent, |
56 | const char *name = 0 ); | 56 | const char *name = 0 ); |
57 | virtual ~KAddressBookIconView(); | 57 | virtual ~KAddressBookIconView(); |
58 | 58 | ||
59 | virtual QStringList selectedUids(); | 59 | virtual QStringList selectedUids(); |
60 | virtual QString type() const { return "Icon"; } | 60 | virtual QString type() const { return "Icon"; } |
61 | void doSearch( const QString& s ,KABC::Field *field ); | ||
61 | 62 | ||
62 | virtual void readConfig(KConfig *config); | 63 | virtual void readConfig(KConfig *config); |
63 | 64 | ||
64 | public slots: | 65 | public slots: |
65 | void refresh(QString uid = QString::null); | 66 | void refresh(QString uid = QString::null); |
66 | #ifndef KAB_EMBEDDED | 67 | #ifndef KAB_EMBEDDED |
67 | //MOC_SKIP_BEGIN | 68 | //MOC_SKIP_BEGIN |
68 | void setSelected(QString uid = QString::null, bool selected = true); | 69 | void setSelected(QString uid = QString::null, bool selected = true); |
69 | //MOC_SKIP_END | 70 | //MOC_SKIP_END |
70 | #else //KAB_EMBEDDED | 71 | #else //KAB_EMBEDDED |
71 | //US my MOC do not like default parameters ??? | 72 | //US my MOC do not like default parameters ??? |
72 | void setSelected(QString uid, bool selected); | 73 | void setSelected(QString uid, bool selected); |
73 | #endif //KAB_EMBEDDED | 74 | #endif //KAB_EMBEDDED |
74 | 75 | ||
75 | protected slots: | 76 | protected slots: |
76 | void addresseeExecuted(QIconViewItem *item); | 77 | void addresseeExecuted(QIconViewItem *item); |
77 | void addresseeSelected(); | 78 | void addresseeSelected(); |
78 | 79 | ||
79 | private: | 80 | private: |
80 | AddresseeIconView *mIconView; | 81 | AddresseeIconView *mIconView; |
81 | QPtrList<AddresseeIconViewItem> mIconList; | 82 | QPtrList<AddresseeIconViewItem> mIconList; |
82 | }; | 83 | }; |
83 | 84 | ||
84 | 85 | ||
85 | #ifndef KAB_EMBEDDED | 86 | #ifndef KAB_EMBEDDED |
86 | //MOC_SKIP_BEGIN | 87 | //MOC_SKIP_BEGIN |
87 | class AddresseeIconView : public KIconView | 88 | class AddresseeIconView : public KIconView |
88 | //MOC_SKIP_END | 89 | //MOC_SKIP_END |
89 | #else //KAB_EMBEDDED | 90 | #else //KAB_EMBEDDED |
90 | class AddresseeIconView : public QIconView | 91 | class AddresseeIconView : public QIconView |
91 | #endif //KAB_EMBEDDED | 92 | #endif //KAB_EMBEDDED |
92 | { | 93 | { |
93 | Q_OBJECT | 94 | Q_OBJECT |
94 | 95 | ||
95 | public: | 96 | public: |
96 | AddresseeIconView(QWidget *parent, const char *name); | 97 | AddresseeIconView(QWidget *parent, const char *name); |
97 | ~AddresseeIconView(); | 98 | ~AddresseeIconView(); |
98 | 99 | ||
99 | signals: | 100 | signals: |
100 | void addresseeDropped(QDropEvent *); | 101 | void addresseeDropped(QDropEvent *); |
101 | void startAddresseeDrag(); | 102 | void startAddresseeDrag(); |
102 | 103 | ||
103 | protected: | 104 | protected: |
104 | virtual QDragObject *dragObject(); | 105 | virtual QDragObject *dragObject(); |
105 | 106 | ||
106 | protected slots: | 107 | protected slots: |
107 | void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &); | 108 | void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &); |
108 | }; | 109 | }; |
109 | 110 | ||
110 | class IconViewFactory : public ViewFactory | 111 | class IconViewFactory : public ViewFactory |
111 | { | 112 | { |
112 | public: | 113 | public: |
113 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 114 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
114 | { | 115 | { |
115 | return new KAddressBookIconView( ab, parent, name ); | 116 | return new KAddressBookIconView( ab, parent, name ); |
116 | } | 117 | } |
117 | 118 | ||
118 | QString type() const { return "Icon"; } | 119 | QString type() const { return "Icon"; } |
119 | 120 | ||
120 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } | 121 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } |
121 | }; | 122 | }; |
122 | /* | 123 | /* |
123 | extern "C" { | 124 | extern "C" { |
124 | void *init_libkaddrbk_iconview() | 125 | void *init_libkaddrbk_iconview() |
125 | { | 126 | { |
126 | return ( new IconViewFactory ); | 127 | return ( new IconViewFactory ); |
127 | } | 128 | } |
128 | } | 129 | } |
129 | */ | 130 | */ |
130 | #endif | 131 | #endif |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index ab11e2a..12f7c27 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -1,393 +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 ) | ||
116 | { | ||
117 | mListView->clear(); | ||
118 | if ( s.isEmpty() || s == "*" ) { | ||
119 | refresh(); | ||
120 | return; | ||
121 | } | ||
122 | QString pattern = s.lower()+"*"; | ||
123 | QRegExp re; | ||
124 | re.setWildcard(true); // most people understand these better. | ||
125 | re.setCaseSensitive(false); | ||
126 | re.setPattern( pattern ); | ||
127 | if (!re.isValid()) | ||
128 | return; | ||
129 | KABC::Addressee::List addresseeList = addressees(); | ||
130 | KABC::Addressee::List::Iterator it; | ||
131 | if ( field ) { | ||
132 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
133 | #if QT_VERSION >= 300 | ||
134 | if (re.search(field->value( *it ).lower()) != -1) | ||
135 | #else | ||
136 | if (re.match(field->value( *it ).lower()) != -1) | ||
137 | #endif | ||
138 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | ||
139 | |||
140 | } | ||
141 | } else { | ||
142 | KABC::Field::List fieldList = fields(); | ||
143 | KABC::Field::List::ConstIterator fieldIt; | ||
144 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
145 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
146 | #if QT_VERSION >= 300 | ||
147 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
148 | #else | ||
149 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
150 | #endif | ||
151 | { | ||
152 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | ||
153 | continue; | ||
154 | } | ||
155 | } | ||
156 | } | ||
157 | } | ||
158 | // Sometimes the background pixmap gets messed up when we add lots | ||
159 | // of items. | ||
160 | mListView->repaint(); | ||
161 | emit selected(QString::null); | ||
162 | |||
163 | } | ||
115 | void KAddressBookTableView::writeConfig(KConfig *config) | 164 | void KAddressBookTableView::writeConfig(KConfig *config) |
116 | { | 165 | { |
117 | KAddressBookView::writeConfig(config); | 166 | KAddressBookView::writeConfig(config); |
118 | 167 | ||
119 | mListView->saveLayout(config, config->group()); | 168 | mListView->saveLayout(config, config->group()); |
120 | } | 169 | } |
121 | 170 | ||
122 | void KAddressBookTableView::readConfig(KConfig *config) | 171 | void KAddressBookTableView::readConfig(KConfig *config) |
123 | { | 172 | { |
124 | KAddressBookView::readConfig( config ); | 173 | KAddressBookView::readConfig( config ); |
125 | // 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 |
126 | // the listview. | 175 | // the listview. |
127 | reconstructListView(); | 176 | reconstructListView(); |
128 | 177 | ||
129 | // costum colors? | 178 | // costum colors? |
130 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 179 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
131 | { | 180 | { |
132 | QPalette p( mListView->palette() ); | 181 | QPalette p( mListView->palette() ); |
133 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 182 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
134 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 183 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
135 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 184 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
136 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 185 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
137 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 186 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
138 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 187 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
139 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 188 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
140 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 189 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
141 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 190 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
142 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 191 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
143 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 192 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
144 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 193 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
145 | #ifndef KAB_EMBEDDED | 194 | #ifndef KAB_EMBEDDED |
146 | c = KGlobalSettings::alternateBackgroundColor(); | 195 | c = KGlobalSettings::alternateBackgroundColor(); |
147 | #else //KAB_EMBEDDED | 196 | #else //KAB_EMBEDDED |
148 | c = QColor(240, 240, 240); | 197 | c = QColor(240, 240, 240); |
149 | #endif //KAB_EMBEDDED | 198 | #endif //KAB_EMBEDDED |
150 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 199 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
151 | mListView->setAlternateColor(c); | 200 | mListView->setAlternateColor(c); |
152 | 201 | ||
153 | 202 | ||
154 | //US mListView->viewport()->setPalette( p ); | 203 | //US mListView->viewport()->setPalette( p ); |
155 | mListView->setPalette( p ); | 204 | mListView->setPalette( p ); |
156 | } | 205 | } |
157 | else | 206 | else |
158 | { | 207 | { |
159 | // needed if turned off during a session. | 208 | // needed if turned off during a session. |
160 | //US mListView->viewport()->setPalette( mListView->palette() ); | 209 | //US mListView->viewport()->setPalette( mListView->palette() ); |
161 | mListView->setPalette( mListView->palette() ); | 210 | mListView->setPalette( mListView->palette() ); |
162 | } | 211 | } |
163 | 212 | ||
164 | //custom fonts? | 213 | //custom fonts? |
165 | QFont f( font() ); | 214 | QFont f( font() ); |
166 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 215 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
167 | { | 216 | { |
168 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 217 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
169 | f.setBold( true ); | 218 | f.setBold( true ); |
170 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 219 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
171 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 220 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
172 | } | 221 | } |
173 | else | 222 | else |
174 | { | 223 | { |
175 | mListView->setFont( f ); | 224 | mListView->setFont( f ); |
176 | f.setBold( true ); | 225 | f.setBold( true ); |
177 | //US mListView->setHeaderFont( f ); | 226 | //US mListView->setHeaderFont( f ); |
178 | mListView->header()->setFont( f ); | 227 | mListView->header()->setFont( f ); |
179 | } | 228 | } |
180 | 229 | ||
181 | 230 | ||
182 | 231 | ||
183 | 232 | ||
184 | 233 | ||
185 | // Set the list view options | 234 | // Set the list view options |
186 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 235 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
187 | true)); | 236 | true)); |
188 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 237 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
189 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 238 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
190 | 239 | ||
191 | if (config->readBoolEntry("Background", false)) | 240 | if (config->readBoolEntry("Background", false)) |
192 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 241 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
193 | 242 | ||
194 | // Restore the layout of the listview | 243 | // Restore the layout of the listview |
195 | mListView->restoreLayout(config, config->group()); | 244 | mListView->restoreLayout(config, config->group()); |
196 | } | 245 | } |
197 | 246 | ||
198 | void KAddressBookTableView::refresh(QString uid) | 247 | void KAddressBookTableView::refresh(QString uid) |
199 | { | 248 | { |
200 | // For now just repopulate. In reality this method should | 249 | // For now just repopulate. In reality this method should |
201 | // check the value of uid, and if valid iterate through | 250 | // check the value of uid, and if valid iterate through |
202 | // the listview to find the entry, then tell it to refresh. | 251 | // the listview to find the entry, then tell it to refresh. |
203 | 252 | ||
204 | if (uid.isNull()) { | 253 | if (uid.isNull()) { |
205 | // Clear the list view | 254 | // Clear the list view |
206 | QString currentUID, nextUID; | 255 | QString currentUID, nextUID; |
207 | #ifndef KAB_EMBEDDED | 256 | #ifndef KAB_EMBEDDED |
208 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 257 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
209 | #else //KAB_EMBEDDED | 258 | #else //KAB_EMBEDDED |
210 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 259 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
211 | #endif //KAB_EMBEDDED | 260 | #endif //KAB_EMBEDDED |
212 | 261 | ||
213 | if ( currentItem ) { | 262 | if ( currentItem ) { |
214 | #ifndef KAB_EMBEDDED | 263 | #ifndef KAB_EMBEDDED |
215 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 264 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
216 | #else //KAB_EMBEDDED | 265 | #else //KAB_EMBEDDED |
217 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 266 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
218 | #endif //KAB_EMBEDDED | 267 | #endif //KAB_EMBEDDED |
219 | if ( nextItem ) | 268 | if ( nextItem ) |
220 | nextUID = nextItem->addressee().uid(); | 269 | nextUID = nextItem->addressee().uid(); |
221 | currentUID = currentItem->addressee().uid(); | 270 | currentUID = currentItem->addressee().uid(); |
222 | } | 271 | } |
223 | 272 | ||
224 | mListView->clear(); | 273 | mListView->clear(); |
225 | 274 | ||
226 | currentItem = 0; | 275 | currentItem = 0; |
227 | KABC::Addressee::List addresseeList = addressees(); | 276 | KABC::Addressee::List addresseeList = addressees(); |
228 | KABC::Addressee::List::Iterator it; | 277 | KABC::Addressee::List::Iterator it; |
229 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 278 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
230 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 279 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
231 | if ( (*it).uid() == currentUID ) | 280 | if ( (*it).uid() == currentUID ) |
232 | currentItem = item; | 281 | currentItem = item; |
233 | else if ( (*it).uid() == nextUID && !currentItem ) | 282 | else if ( (*it).uid() == nextUID && !currentItem ) |
234 | currentItem = item; | 283 | currentItem = item; |
235 | } | 284 | } |
236 | 285 | ||
237 | // Sometimes the background pixmap gets messed up when we add lots | 286 | // Sometimes the background pixmap gets messed up when we add lots |
238 | // of items. | 287 | // of items. |
239 | mListView->repaint(); | 288 | mListView->repaint(); |
240 | 289 | ||
241 | if ( currentItem ) { | 290 | if ( currentItem ) { |
242 | mListView->setCurrentItem( currentItem ); | 291 | mListView->setCurrentItem( currentItem ); |
243 | mListView->ensureItemVisible( currentItem ); | 292 | mListView->ensureItemVisible( currentItem ); |
244 | } | 293 | } |
245 | } else { | 294 | } else { |
246 | // 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 |
247 | ContactListViewItem *ceItem; | 296 | ContactListViewItem *ceItem; |
248 | QListViewItemIterator it( mListView ); | 297 | QListViewItemIterator it( mListView ); |
249 | while ( it.current() ) { | 298 | while ( it.current() ) { |
250 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
251 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 300 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
252 | #else //KAB_EMBEDDED | 301 | #else //KAB_EMBEDDED |
253 | ceItem = (ContactListViewItem*)( it.current() ); | 302 | ceItem = (ContactListViewItem*)( it.current() ); |
254 | #endif //KAB_EMBEDDED | 303 | #endif //KAB_EMBEDDED |
255 | 304 | ||
256 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 305 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
257 | ceItem->refresh(); | 306 | ceItem->refresh(); |
258 | return; | 307 | return; |
259 | } | 308 | } |
260 | ++it; | 309 | ++it; |
261 | } | 310 | } |
262 | 311 | ||
263 | refresh( QString::null ); | 312 | refresh( QString::null ); |
264 | } | 313 | } |
265 | } | 314 | } |
266 | 315 | ||
267 | QStringList KAddressBookTableView::selectedUids() | 316 | QStringList KAddressBookTableView::selectedUids() |
268 | { | 317 | { |
269 | QStringList uidList; | 318 | QStringList uidList; |
270 | QListViewItem *item; | 319 | QListViewItem *item; |
271 | ContactListViewItem *ceItem; | 320 | ContactListViewItem *ceItem; |
272 | 321 | ||
273 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 322 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
274 | { | 323 | { |
275 | if (mListView->isSelected( item )) | 324 | if (mListView->isSelected( item )) |
276 | { | 325 | { |
277 | #ifndef KAB_EMBEDDED | 326 | #ifndef KAB_EMBEDDED |
278 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 327 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
279 | #else //KAB_EMBEDDED | 328 | #else //KAB_EMBEDDED |
280 | ceItem = (ContactListViewItem*)(item); | 329 | ceItem = (ContactListViewItem*)(item); |
281 | #endif //KAB_EMBEDDED | 330 | #endif //KAB_EMBEDDED |
282 | 331 | ||
283 | if (ceItem != 0L) | 332 | if (ceItem != 0L) |
284 | uidList << ceItem->addressee().uid(); | 333 | uidList << ceItem->addressee().uid(); |
285 | } | 334 | } |
286 | } | 335 | } |
287 | if ( uidList.count() == 0 ) | 336 | if ( uidList.count() == 0 ) |
288 | if ( mListView->currentItem() ) { | 337 | if ( mListView->currentItem() ) { |
289 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; | 338 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; |
290 | uidList << ceItem->addressee().uid(); | 339 | uidList << ceItem->addressee().uid(); |
291 | } | 340 | } |
292 | 341 | ||
293 | return uidList; | 342 | return uidList; |
294 | } | 343 | } |
295 | 344 | ||
296 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 345 | void KAddressBookTableView::setSelected(QString uid, bool selected) |
297 | { | 346 | { |
298 | QListViewItem *item; | 347 | QListViewItem *item; |
299 | ContactListViewItem *ceItem; | 348 | ContactListViewItem *ceItem; |
300 | 349 | ||
301 | if (uid.isNull()) | 350 | if (uid.isNull()) |
302 | { | 351 | { |
303 | mListView->selectAll(selected); | 352 | mListView->selectAll(selected); |
304 | } | 353 | } |
305 | else | 354 | else |
306 | { | 355 | { |
307 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 356 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
308 | { | 357 | { |
309 | #ifndef KAB_EMBEDDED | 358 | #ifndef KAB_EMBEDDED |
310 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 359 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
311 | #else //KAB_EMBEDDED | 360 | #else //KAB_EMBEDDED |
312 | ceItem = (ContactListViewItem*)(item); | 361 | ceItem = (ContactListViewItem*)(item); |
313 | #endif //KAB_EMBEDDED | 362 | #endif //KAB_EMBEDDED |
314 | 363 | ||
315 | 364 | ||
316 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) | 365 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) |
317 | { | 366 | { |
318 | mListView->setSelected(item, selected); | 367 | mListView->setSelected(item, selected); |
319 | 368 | ||
320 | if (selected) | 369 | if (selected) |
321 | mListView->ensureItemVisible(item); | 370 | mListView->ensureItemVisible(item); |
322 | } | 371 | } |
323 | } | 372 | } |
324 | } | 373 | } |
325 | } | 374 | } |
326 | 375 | ||
327 | void KAddressBookTableView::addresseeSelected() | 376 | void KAddressBookTableView::addresseeSelected() |
328 | { | 377 | { |
329 | // 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 |
330 | // last selected item, but when QListView is in multiselection mode, | 379 | // last selected item, but when QListView is in multiselection mode, |
331 | // there is no way to figure out which one was | 380 | // there is no way to figure out which one was |
332 | // selected last. | 381 | // selected last. |
333 | QListViewItem *item; | 382 | QListViewItem *item; |
334 | bool found =false; | 383 | bool found =false; |
335 | for (item = mListView->firstChild(); item && !found; | 384 | for (item = mListView->firstChild(); item && !found; |
336 | item = item->nextSibling()) | 385 | item = item->nextSibling()) |
337 | { | 386 | { |
338 | if (item->isSelected()) | 387 | if (item->isSelected()) |
339 | { | 388 | { |
340 | found = true; | 389 | found = true; |
341 | #ifndef KAB_EMBEDDED | 390 | #ifndef KAB_EMBEDDED |
342 | ContactListViewItem *ceItem | 391 | ContactListViewItem *ceItem |
343 | = dynamic_cast<ContactListViewItem*>(item); | 392 | = dynamic_cast<ContactListViewItem*>(item); |
344 | #else //KAB_EMBEDDED | 393 | #else //KAB_EMBEDDED |
345 | ContactListViewItem *ceItem | 394 | ContactListViewItem *ceItem |
346 | = (ContactListViewItem*)(item); | 395 | = (ContactListViewItem*)(item); |
347 | #endif //KAB_EMBEDDED | 396 | #endif //KAB_EMBEDDED |
348 | 397 | ||
349 | if ( ceItem ) emit selected(ceItem->addressee().uid()); | 398 | if ( ceItem ) emit selected(ceItem->addressee().uid()); |
350 | } | 399 | } |
351 | } | 400 | } |
352 | 401 | ||
353 | if (!found) | 402 | if (!found) |
354 | emit selected(QString::null); | 403 | emit selected(QString::null); |
355 | } | 404 | } |
356 | 405 | ||
357 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 406 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) |
358 | { | 407 | { |
359 | if (item) | 408 | if (item) |
360 | { | 409 | { |
361 | #ifndef KAB_EMBEDDED | 410 | #ifndef KAB_EMBEDDED |
362 | ContactListViewItem *ceItem | 411 | ContactListViewItem *ceItem |
363 | = dynamic_cast<ContactListViewItem*>(item); | 412 | = dynamic_cast<ContactListViewItem*>(item); |
364 | #else //KAB_EMBEDDED | 413 | #else //KAB_EMBEDDED |
365 | ContactListViewItem *ceItem | 414 | ContactListViewItem *ceItem |
366 | = (ContactListViewItem*)(item); | 415 | = (ContactListViewItem*)(item); |
367 | #endif //KAB_EMBEDDED | 416 | #endif //KAB_EMBEDDED |
368 | 417 | ||
369 | if (ceItem) | 418 | if (ceItem) |
370 | { | 419 | { |
371 | emit executed(ceItem->addressee().uid()); | 420 | emit executed(ceItem->addressee().uid()); |
372 | } | 421 | } |
373 | } | 422 | } |
374 | else | 423 | else |
375 | { | 424 | { |
376 | emit executed(QString::null); | 425 | emit executed(QString::null); |
377 | } | 426 | } |
378 | } | 427 | } |
379 | 428 | ||
380 | void KAddressBookTableView::addresseeDeleted() | 429 | void KAddressBookTableView::addresseeDeleted() |
381 | { | 430 | { |
382 | 431 | ||
383 | emit deleteRequest(); | 432 | emit deleteRequest(); |
384 | 433 | ||
385 | } | 434 | } |
386 | 435 | ||
387 | 436 | ||
388 | 437 | ||
389 | 438 | ||
390 | 439 | ||
391 | #ifndef KAB_EMBEDDED | 440 | #ifndef KAB_EMBEDDED |
392 | #include "kaddressbooktableview.moc" | 441 | #include "kaddressbooktableview.moc" |
393 | #endif //KAB_EMBEDDED | 442 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbooktableview.h b/kaddressbook/views/kaddressbooktableview.h index bb991bc..ecfe7a1 100644 --- a/kaddressbook/views/kaddressbooktableview.h +++ b/kaddressbook/views/kaddressbooktableview.h | |||
@@ -1,114 +1,115 @@ | |||
1 | #ifndef KADDRESSBOOKTABLEVIEW_H | 1 | #ifndef KADDRESSBOOKTABLEVIEW_H |
2 | #define KADDRESSBOOKTABLEVIEW_H | 2 | #define KADDRESSBOOKTABLEVIEW_H |
3 | 3 | ||
4 | 4 | ||
5 | #ifndef KAB_EMBEDDED | 5 | #ifndef KAB_EMBEDDED |
6 | 6 | ||
7 | 7 | ||
8 | #ifdef HAVE_CONFIG_H | 8 | #ifdef HAVE_CONFIG_H |
9 | #include <config.h> | 9 | #include <config.h> |
10 | #endif | 10 | #endif |
11 | 11 | ||
12 | #include <qwidget.h> | 12 | #include <qwidget.h> |
13 | #include <qlistview.h> | 13 | #include <qlistview.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qdialog.h> | 15 | #include <qdialog.h> |
16 | #include <qtabdialog.h> | 16 | #include <qtabdialog.h> |
17 | #include <qstringlist.h> | 17 | #include <qstringlist.h> |
18 | #include <qvaluelist.h> | 18 | #include <qvaluelist.h> |
19 | 19 | ||
20 | #include "undo.h" | 20 | #include "undo.h" |
21 | 21 | ||
22 | #else //KAB_EMBEDDED | 22 | #else //KAB_EMBEDDED |
23 | #include "views/configuretableviewdialog.h" | 23 | #include "views/configuretableviewdialog.h" |
24 | #endif //KAB_EMBEDDED | 24 | #endif //KAB_EMBEDDED |
25 | 25 | ||
26 | #include "klocale.h" | 26 | #include "klocale.h" |
27 | #include "kaddressbookview.h" | 27 | #include "kaddressbookview.h" |
28 | 28 | ||
29 | class QListViewItem; | 29 | class QListViewItem; |
30 | class QListBox; | 30 | class QListBox; |
31 | class QVBoxLayout; | 31 | class QVBoxLayout; |
32 | class KConfig; | 32 | class KConfig; |
33 | 33 | ||
34 | class ContactListViewItem; | 34 | class ContactListViewItem; |
35 | class ContactListView; | 35 | class ContactListView; |
36 | 36 | ||
37 | 37 | ||
38 | namespace KABC { class AddressBook; } | 38 | namespace KABC { class AddressBook; } |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * This class is the table view for kaddressbook. This view is a KListView | 41 | * This class is the table view for kaddressbook. This view is a KListView |
42 | * with multiple columns for the selected fields. | 42 | * with multiple columns for the selected fields. |
43 | * | 43 | * |
44 | * @short Table View | 44 | * @short Table View |
45 | * @author Don Sanders <dsanders@kde.org> | 45 | * @author Don Sanders <dsanders@kde.org> |
46 | * @version 0.1 | 46 | * @version 0.1 |
47 | */ | 47 | */ |
48 | class KAddressBookTableView : public KAddressBookView | 48 | class KAddressBookTableView : public KAddressBookView |
49 | { | 49 | { |
50 | friend class ContactListView; | 50 | friend class ContactListView; |
51 | 51 | ||
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, | 55 | KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, |
56 | const char *name = 0 ); | 56 | const char *name = 0 ); |
57 | virtual ~KAddressBookTableView(); | 57 | virtual ~KAddressBookTableView(); |
58 | 58 | ||
59 | virtual void refresh(QString uid = QString::null); | 59 | virtual void refresh(QString uid = QString::null); |
60 | virtual QStringList selectedUids(); | 60 | virtual QStringList selectedUids(); |
61 | virtual void setSelected(QString uid = QString::null, bool selected = false); | 61 | virtual void setSelected(QString uid = QString::null, bool selected = false); |
62 | virtual void readConfig(KConfig *config); | 62 | virtual void readConfig(KConfig *config); |
63 | virtual void writeConfig(KConfig *config); | 63 | virtual void writeConfig(KConfig *config); |
64 | virtual QString type() const { return "Table"; } | 64 | virtual QString type() const { return "Table"; } |
65 | void doSearch( const QString& s ,KABC::Field *field ); | ||
65 | 66 | ||
66 | public slots: | 67 | public slots: |
67 | virtual void reconstructListView(); | 68 | virtual void reconstructListView(); |
68 | 69 | ||
69 | protected slots: | 70 | protected slots: |
70 | /** Called whenever the user selects an addressee in the list view. | 71 | /** Called whenever the user selects an addressee in the list view. |
71 | */ | 72 | */ |
72 | void addresseeSelected(); | 73 | void addresseeSelected(); |
73 | void addresseeDeleted(); | 74 | void addresseeDeleted(); |
74 | 75 | ||
75 | /** Called whenever the user executes an addressee. In terms of the | 76 | /** Called whenever the user executes an addressee. In terms of the |
76 | * list view, this is probably a double click | 77 | * list view, this is probably a double click |
77 | */ | 78 | */ |
78 | void addresseeExecuted(QListViewItem*); | 79 | void addresseeExecuted(QListViewItem*); |
79 | 80 | ||
80 | private: | 81 | private: |
81 | QVBoxLayout *mainLayout; | 82 | QVBoxLayout *mainLayout; |
82 | ContactListView *mListView; | 83 | ContactListView *mListView; |
83 | }; | 84 | }; |
84 | 85 | ||
85 | 86 | ||
86 | class TableViewFactory : public ViewFactory | 87 | class TableViewFactory : public ViewFactory |
87 | { | 88 | { |
88 | public: | 89 | public: |
89 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 90 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
90 | { | 91 | { |
91 | return new KAddressBookTableView( ab, parent, name ); | 92 | return new KAddressBookTableView( ab, parent, name ); |
92 | } | 93 | } |
93 | 94 | ||
94 | QString type() const { return "Table"; } | 95 | QString type() const { return "Table"; } |
95 | 96 | ||
96 | QString description() const { return i18n( "A listing of contacts in a table. Each cell of " | 97 | QString description() const { return i18n( "A listing of contacts in a table. Each cell of " |
97 | "the table holds a field of the contact." ); } | 98 | "the table holds a field of the contact." ); } |
98 | 99 | ||
99 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, | 100 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, |
100 | const char *name = 0 ) | 101 | const char *name = 0 ) |
101 | { | 102 | { |
102 | return new ConfigureTableViewWidget( ab, parent, name ); | 103 | return new ConfigureTableViewWidget( ab, parent, name ); |
103 | } | 104 | } |
104 | }; | 105 | }; |
105 | /*US | 106 | /*US |
106 | extern "C" { | 107 | extern "C" { |
107 | void *init_libkaddrbk_tableview() | 108 | void *init_libkaddrbk_tableview() |
108 | { | 109 | { |
109 | return ( new TableViewFactory ); | 110 | return ( new TableViewFactory ); |
110 | } | 111 | } |
111 | } | 112 | } |
112 | */ | 113 | */ |
113 | 114 | ||
114 | #endif | 115 | #endif |