author | zautrix <zautrix> | 2004-10-29 11:41:57 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-29 11:41:57 (UTC) |
commit | 8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8 (patch) (unidiff) | |
tree | eda3f48b2a157146d936afef45d0a72f864fedcd | |
parent | 443116d2682cd221c25201926e35d825170bdbbd (diff) | |
download | kdepimpi-8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8.zip kdepimpi-8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8.tar.gz kdepimpi-8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8.tar.bz2 |
fix of excluding last sync addreessees in search
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 6 |
3 files changed, 13 insertions, 1 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 15f154e..2c9b162 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -1,474 +1,478 @@ | |||
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 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kabc/addressbook.h> | 32 | #include <kabc/addressbook.h> |
33 | #include <kabc/addressee.h> | 33 | #include <kabc/addressee.h> |
34 | #include <kconfig.h> | 34 | #include <kconfig.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | 37 | ||
38 | #include "kabprefs.h" | 38 | #include "kabprefs.h" |
39 | #include "viewmanager.h" | 39 | #include "viewmanager.h" |
40 | 40 | ||
41 | #include "kaddressbookcardview.h" | 41 | #include "kaddressbookcardview.h" |
42 | 42 | ||
43 | #ifndef KAB_EMBEDDED | 43 | #ifndef KAB_EMBEDDED |
44 | extern "C" { | 44 | extern "C" { |
45 | void *init_libkaddrbk_cardview() | 45 | void *init_libkaddrbk_cardview() |
46 | { | 46 | { |
47 | return ( new CardViewFactory ); | 47 | return ( new CardViewFactory ); |
48 | } | 48 | } |
49 | } | 49 | } |
50 | #endif //KAB_EMBEDDED | 50 | #endif //KAB_EMBEDDED |
51 | 51 | ||
52 | //////////////////////////////// | 52 | //////////////////////////////// |
53 | // AddresseeCardViewItem (internal class) | 53 | // AddresseeCardViewItem (internal class) |
54 | class AddresseeCardViewItem : public CardViewItem | 54 | class AddresseeCardViewItem : public CardViewItem |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | AddresseeCardViewItem(const KABC::Field::List &fields, | 57 | AddresseeCardViewItem(const KABC::Field::List &fields, |
58 | bool showEmptyFields, | 58 | bool showEmptyFields, |
59 | KABC::AddressBook *doc, const KABC::Addressee &a, | 59 | KABC::AddressBook *doc, const KABC::Addressee &a, |
60 | CardView *parent) | 60 | CardView *parent) |
61 | : CardViewItem(parent, a.formattedName()), | 61 | : CardViewItem(parent, a.formattedName()), |
62 | mFields( fields ), mShowEmptyFields(showEmptyFields), | 62 | mFields( fields ), mShowEmptyFields(showEmptyFields), |
63 | mDocument(doc), mAddressee(a) | 63 | mDocument(doc), mAddressee(a) |
64 | { | 64 | { |
65 | if ( mFields.isEmpty() ) { | 65 | if ( mFields.isEmpty() ) { |
66 | mFields = KABC::Field::defaultFields(); | 66 | mFields = KABC::Field::defaultFields(); |
67 | } | 67 | } |
68 | refresh(); | 68 | refresh(); |
69 | } | 69 | } |
70 | 70 | ||
71 | const KABC::Addressee &addressee() const { return mAddressee; } | 71 | const KABC::Addressee &addressee() const { return mAddressee; } |
72 | 72 | ||
73 | void refresh() | 73 | void refresh() |
74 | { | 74 | { |
75 | // Update our addressee, since it may have changed elsewhere | 75 | // Update our addressee, since it may have changed elsewhere |
76 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 76 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
77 | 77 | ||
78 | if (!mAddressee.isEmpty()) | 78 | if (!mAddressee.isEmpty()) |
79 | { | 79 | { |
80 | clearFields(); | 80 | clearFields(); |
81 | 81 | ||
82 | // Try all the selected fields until we find one with text. | 82 | // Try all the selected fields until we find one with text. |
83 | // This will limit the number of unlabeled icons in the view | 83 | // This will limit the number of unlabeled icons in the view |
84 | KABC::Field::List::Iterator iter; | 84 | KABC::Field::List::Iterator iter; |
85 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) | 85 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) |
86 | { | 86 | { |
87 | // insert empty fields or not? not doing so saves a bit of memory and CPU | 87 | // insert empty fields or not? not doing so saves a bit of memory and CPU |
88 | // (during geometry calculations), but prevents having equally | 88 | // (during geometry calculations), but prevents having equally |
89 | // wide label columns in all cards, unless CardViewItem/CardView search | 89 | // wide label columns in all cards, unless CardViewItem/CardView search |
90 | // globally for the widest label. (anders) | 90 | // globally for the widest label. (anders) |
91 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) | 91 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) |
92 | insertField((*iter)->label(), (*iter)->value( mAddressee )); | 92 | insertField((*iter)->label(), (*iter)->value( mAddressee )); |
93 | } | 93 | } |
94 | 94 | ||
95 | // We might want to make this the first field. hmm... -mpilone | 95 | // We might want to make this the first field. hmm... -mpilone |
96 | setCaption( mAddressee.realName() ); | 96 | setCaption( mAddressee.realName() ); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | private: | 100 | private: |
101 | KABC::Field::List mFields; | 101 | KABC::Field::List mFields; |
102 | bool mShowEmptyFields; | 102 | bool mShowEmptyFields; |
103 | KABC::AddressBook *mDocument; | 103 | KABC::AddressBook *mDocument; |
104 | KABC::Addressee mAddressee; | 104 | KABC::Addressee mAddressee; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | /////////////////////////////// | 107 | /////////////////////////////// |
108 | // AddresseeCardView | 108 | // AddresseeCardView |
109 | 109 | ||
110 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) | 110 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) |
111 | : CardView(parent, name) | 111 | : CardView(parent, name) |
112 | { | 112 | { |
113 | setAcceptDrops(true); | 113 | setAcceptDrops(true); |
114 | } | 114 | } |
115 | 115 | ||
116 | AddresseeCardView::~AddresseeCardView() | 116 | AddresseeCardView::~AddresseeCardView() |
117 | { | 117 | { |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 121 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) |
122 | { | 122 | { |
123 | #ifndef KAB_EMBEDDED | 123 | #ifndef KAB_EMBEDDED |
124 | if (QTextDrag::canDecode(e)) | 124 | if (QTextDrag::canDecode(e)) |
125 | e->accept(); | 125 | e->accept(); |
126 | #else //KAB_EMBEDDED | 126 | #else //KAB_EMBEDDED |
127 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); | 127 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); |
128 | #endif //KAB_EMBEDDED | 128 | #endif //KAB_EMBEDDED |
129 | } | 129 | } |
130 | 130 | ||
131 | void AddresseeCardView::dropEvent(QDropEvent *e) | 131 | void AddresseeCardView::dropEvent(QDropEvent *e) |
132 | { | 132 | { |
133 | emit addresseeDropped(e); | 133 | emit addresseeDropped(e); |
134 | } | 134 | } |
135 | 135 | ||
136 | void AddresseeCardView::startDrag() | 136 | void AddresseeCardView::startDrag() |
137 | { | 137 | { |
138 | emit startAddresseeDrag(); | 138 | emit startAddresseeDrag(); |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | /////////////////////////////// | 142 | /////////////////////////////// |
143 | // KAddressBookCardView | 143 | // KAddressBookCardView |
144 | 144 | ||
145 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | 145 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, |
146 | QWidget *parent, const char *name ) | 146 | QWidget *parent, const char *name ) |
147 | : KAddressBookView( ab, parent, name ) | 147 | : KAddressBookView( ab, parent, name ) |
148 | { | 148 | { |
149 | mShowEmptyFields = false; | 149 | mShowEmptyFields = false; |
150 | 150 | ||
151 | // Init the GUI | 151 | // Init the GUI |
152 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 152 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
153 | 153 | ||
154 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); | 154 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); |
155 | mCardView->setSelectionMode(CardView::Extended); | 155 | mCardView->setSelectionMode(CardView::Extended); |
156 | layout->addWidget(mCardView); | 156 | layout->addWidget(mCardView); |
157 | 157 | ||
158 | // Connect up the signals | 158 | // Connect up the signals |
159 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 159 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
160 | this, SLOT(addresseeExecuted(CardViewItem *))); | 160 | this, SLOT(addresseeExecuted(CardViewItem *))); |
161 | connect(mCardView, SIGNAL(selectionChanged()), | 161 | connect(mCardView, SIGNAL(selectionChanged()), |
162 | this, SLOT(addresseeSelected())); | 162 | this, SLOT(addresseeSelected())); |
163 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), | 163 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), |
164 | this, SIGNAL(dropped(QDropEvent*))); | 164 | this, SIGNAL(dropped(QDropEvent*))); |
165 | connect(mCardView, SIGNAL(startAddresseeDrag()), | 165 | connect(mCardView, SIGNAL(startAddresseeDrag()), |
166 | this, SIGNAL(startDrag())); | 166 | this, SIGNAL(startDrag())); |
167 | } | 167 | } |
168 | 168 | ||
169 | KAddressBookCardView::~KAddressBookCardView() | 169 | KAddressBookCardView::~KAddressBookCardView() |
170 | { | 170 | { |
171 | } | 171 | } |
172 | void KAddressBookCardView::setFocusAV() | 172 | void KAddressBookCardView::setFocusAV() |
173 | { | 173 | { |
174 | if ( mCardView ) | 174 | if ( mCardView ) |
175 | mCardView->setFocus(); | 175 | mCardView->setFocus(); |
176 | 176 | ||
177 | } | 177 | } |
178 | void KAddressBookCardView::scrollUP() | 178 | void KAddressBookCardView::scrollUP() |
179 | { | 179 | { |
180 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | 180 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); |
181 | QApplication::postEvent( mCardView, ev ); | 181 | QApplication::postEvent( mCardView, ev ); |
182 | 182 | ||
183 | } | 183 | } |
184 | void KAddressBookCardView::scrollDOWN() | 184 | void KAddressBookCardView::scrollDOWN() |
185 | { | 185 | { |
186 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | 186 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); |
187 | QApplication::postEvent( mCardView, ev ); | 187 | QApplication::postEvent( mCardView, ev ); |
188 | } | 188 | } |
189 | void KAddressBookCardView::readConfig(KConfig *config) | 189 | void KAddressBookCardView::readConfig(KConfig *config) |
190 | { | 190 | { |
191 | KAddressBookView::readConfig(config); | 191 | KAddressBookView::readConfig(config); |
192 | 192 | ||
193 | // costum colors? | 193 | // costum colors? |
194 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 194 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
195 | { | 195 | { |
196 | QPalette p( mCardView->palette() ); | 196 | QPalette p( mCardView->palette() ); |
197 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 197 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
198 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 198 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
199 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 199 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
200 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 200 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
201 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 201 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
202 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 202 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
203 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 203 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
204 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 204 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
205 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 205 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
206 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 206 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
207 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 207 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
208 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 208 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
209 | mCardView->viewport()->setPalette( p ); | 209 | mCardView->viewport()->setPalette( p ); |
210 | } | 210 | } |
211 | else | 211 | else |
212 | { | 212 | { |
213 | // needed if turned off during a session. | 213 | // needed if turned off during a session. |
214 | mCardView->viewport()->setPalette( mCardView->palette() ); | 214 | mCardView->viewport()->setPalette( mCardView->palette() ); |
215 | } | 215 | } |
216 | 216 | ||
217 | //custom fonts? | 217 | //custom fonts? |
218 | QFont f( font() ); | 218 | QFont f( font() ); |
219 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 219 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
220 | { | 220 | { |
221 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); | 221 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); |
222 | f.setBold( true ); | 222 | f.setBold( true ); |
223 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 223 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
224 | } | 224 | } |
225 | else | 225 | else |
226 | { | 226 | { |
227 | mCardView->setFont( f ); | 227 | mCardView->setFont( f ); |
228 | f.setBold( true ); | 228 | f.setBold( true ); |
229 | mCardView->setHeaderFont( f ); | 229 | mCardView->setHeaderFont( f ); |
230 | } | 230 | } |
231 | 231 | ||
232 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); | 232 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); |
233 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", | 233 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", |
234 | true)); | 234 | true)); |
235 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); | 235 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); |
236 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); | 236 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); |
237 | 237 | ||
238 | mCardView->setShowEmptyFields( mShowEmptyFields ); | 238 | mCardView->setShowEmptyFields( mShowEmptyFields ); |
239 | 239 | ||
240 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); | 240 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); |
241 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); | 241 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); |
242 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); | 242 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); |
243 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); | 243 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); |
244 | 244 | ||
245 | #if 0 | 245 | #if 0 |
246 | // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven | 246 | // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven |
247 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), | 247 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), |
248 | this, SLOT(addresseeExecuted(CardViewItem *))); | 248 | this, SLOT(addresseeExecuted(CardViewItem *))); |
249 | 249 | ||
250 | if (KABPrefs::instance()->mHonorSingleClick) | 250 | if (KABPrefs::instance()->mHonorSingleClick) |
251 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 251 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
252 | this, SLOT(addresseeExecuted(CardViewItem *))); | 252 | this, SLOT(addresseeExecuted(CardViewItem *))); |
253 | else | 253 | else |
254 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 254 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
255 | this, SLOT(addresseeExecuted(CardViewItem *))); | 255 | this, SLOT(addresseeExecuted(CardViewItem *))); |
256 | #endif | 256 | #endif |
257 | 257 | ||
258 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 258 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
259 | this, SLOT(addresseeExecuted(CardViewItem *))); | 259 | this, SLOT(addresseeExecuted(CardViewItem *))); |
260 | } | 260 | } |
261 | 261 | ||
262 | void KAddressBookCardView::writeConfig( KConfig *config ) | 262 | void KAddressBookCardView::writeConfig( KConfig *config ) |
263 | { | 263 | { |
264 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); | 264 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); |
265 | KAddressBookView::writeConfig( config ); | 265 | KAddressBookView::writeConfig( config ); |
266 | } | 266 | } |
267 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | 267 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) |
268 | { | 268 | { |
269 | mCardView->clear(); | 269 | mCardView->clear(); |
270 | if ( s.isEmpty() || s == "*" ) { | 270 | if ( s.isEmpty() || s == "*" ) { |
271 | refresh(); | 271 | refresh(); |
272 | return; | 272 | return; |
273 | } | 273 | } |
274 | QString pattern = s.lower()+"*"; | 274 | QString pattern = s.lower()+"*"; |
275 | QRegExp re; | 275 | QRegExp re; |
276 | re.setWildcard(true); // most people understand these better. | 276 | re.setWildcard(true); // most people understand these better. |
277 | re.setCaseSensitive(false); | 277 | re.setCaseSensitive(false); |
278 | re.setPattern( pattern ); | 278 | re.setPattern( pattern ); |
279 | if (!re.isValid()) | 279 | if (!re.isValid()) |
280 | return; | 280 | return; |
281 | mCardView->viewport()->setUpdatesEnabled( false ); | 281 | mCardView->viewport()->setUpdatesEnabled( false ); |
282 | KABC::Addressee::List addresseeList = addressees(); | 282 | KABC::Addressee::List addresseeList = addressees(); |
283 | KABC::Addressee::List::Iterator it; | 283 | KABC::Addressee::List::Iterator it; |
284 | if ( field ) { | 284 | if ( field ) { |
285 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 285 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
286 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | ||
287 | continue; | ||
286 | #if QT_VERSION >= 300 | 288 | #if QT_VERSION >= 300 |
287 | if (re.search(field->value( *it ).lower()) != -1) | 289 | if (re.search(field->value( *it ).lower()) != -1) |
288 | #else | 290 | #else |
289 | if (re.match(field->value( *it ).lower()) != -1) | 291 | if (re.match(field->value( *it ).lower()) != -1) |
290 | #endif | 292 | #endif |
291 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 293 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
292 | addressBook(), *it, mCardView); | 294 | addressBook(), *it, mCardView); |
293 | 295 | ||
294 | } | 296 | } |
295 | } else { | 297 | } else { |
296 | KABC::Field::List fieldList = fields(); | 298 | KABC::Field::List fieldList = fields(); |
297 | KABC::Field::List::ConstIterator fieldIt; | 299 | KABC::Field::List::ConstIterator fieldIt; |
298 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 300 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
301 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | ||
302 | continue; | ||
299 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 303 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
300 | #if QT_VERSION >= 300 | 304 | #if QT_VERSION >= 300 |
301 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 305 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
302 | #else | 306 | #else |
303 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 307 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
304 | #endif | 308 | #endif |
305 | { | 309 | { |
306 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 310 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
307 | addressBook(), *it, mCardView); | 311 | addressBook(), *it, mCardView); |
308 | continue; | 312 | continue; |
309 | } | 313 | } |
310 | } | 314 | } |
311 | } | 315 | } |
312 | } | 316 | } |
313 | mCardView->viewport()->setUpdatesEnabled( true ); | 317 | mCardView->viewport()->setUpdatesEnabled( true ); |
314 | mCardView->viewport()->update(); | 318 | mCardView->viewport()->update(); |
315 | if ( mCardView->firstItem() ) { | 319 | if ( mCardView->firstItem() ) { |
316 | mCardView->setCurrentItem ( mCardView->firstItem() ); | 320 | mCardView->setCurrentItem ( mCardView->firstItem() ); |
317 | mCardView->setSelected ( mCardView->firstItem() , true ); | 321 | mCardView->setSelected ( mCardView->firstItem() , true ); |
318 | } | 322 | } |
319 | else | 323 | else |
320 | emit selected(QString::null); | 324 | emit selected(QString::null); |
321 | } | 325 | } |
322 | QStringList KAddressBookCardView::selectedUids() | 326 | QStringList KAddressBookCardView::selectedUids() |
323 | { | 327 | { |
324 | QStringList uidList; | 328 | QStringList uidList; |
325 | CardViewItem *item; | 329 | CardViewItem *item; |
326 | AddresseeCardViewItem *aItem; | 330 | AddresseeCardViewItem *aItem; |
327 | 331 | ||
328 | for (item = mCardView->firstItem(); item; item = item->nextItem()) | 332 | for (item = mCardView->firstItem(); item; item = item->nextItem()) |
329 | { | 333 | { |
330 | if (item->isSelected()) | 334 | if (item->isSelected()) |
331 | { | 335 | { |
332 | #ifndef KAB_EMBEDDED | 336 | #ifndef KAB_EMBEDDED |
333 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 337 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
334 | #else //KAB_EMBEDDED | 338 | #else //KAB_EMBEDDED |
335 | aItem = (AddresseeCardViewItem*)(item); | 339 | aItem = (AddresseeCardViewItem*)(item); |
336 | #endif //KAB_EMBEDDED | 340 | #endif //KAB_EMBEDDED |
337 | if (aItem) | 341 | if (aItem) |
338 | uidList << aItem->addressee().uid(); | 342 | uidList << aItem->addressee().uid(); |
339 | } | 343 | } |
340 | } | 344 | } |
341 | 345 | ||
342 | return uidList; | 346 | return uidList; |
343 | } | 347 | } |
344 | 348 | ||
345 | void KAddressBookCardView::refresh(QString uid) | 349 | void KAddressBookCardView::refresh(QString uid) |
346 | { | 350 | { |
347 | CardViewItem *item; | 351 | CardViewItem *item; |
348 | AddresseeCardViewItem *aItem; | 352 | AddresseeCardViewItem *aItem; |
349 | 353 | ||
350 | if (uid.isNull()) | 354 | if (uid.isNull()) |
351 | { | 355 | { |
352 | // Rebuild the view | 356 | // Rebuild the view |
353 | mCardView->viewport()->setUpdatesEnabled( false ); | 357 | mCardView->viewport()->setUpdatesEnabled( false ); |
354 | mCardView->clear(); | 358 | mCardView->clear(); |
355 | 359 | ||
356 | KABC::Addressee::List addresseeList = addressees(); | 360 | KABC::Addressee::List addresseeList = addressees(); |
357 | KABC::Addressee::List::Iterator iter; | 361 | KABC::Addressee::List::Iterator iter; |
358 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) | 362 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) |
359 | { | 363 | { |
360 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) | 364 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) |
361 | continue; | 365 | continue; |
362 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, | 366 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, |
363 | addressBook(), *iter, mCardView); | 367 | addressBook(), *iter, mCardView); |
364 | } | 368 | } |
365 | mCardView->viewport()->setUpdatesEnabled( true ); | 369 | mCardView->viewport()->setUpdatesEnabled( true ); |
366 | mCardView->viewport()->update(); | 370 | mCardView->viewport()->update(); |
367 | 371 | ||
368 | // by default nothing is selected | 372 | // by default nothing is selected |
369 | emit selected(QString::null); | 373 | emit selected(QString::null); |
370 | } | 374 | } |
371 | else | 375 | else |
372 | { | 376 | { |
373 | // Try to find the one to refresh | 377 | // Try to find the one to refresh |
374 | bool found = false; | 378 | bool found = false; |
375 | for (item = mCardView->firstItem(); item && !found; | 379 | for (item = mCardView->firstItem(); item && !found; |
376 | item = item->nextItem()) | 380 | item = item->nextItem()) |
377 | { | 381 | { |
378 | #ifndef KAB_EMBEDDED | 382 | #ifndef KAB_EMBEDDED |
379 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 383 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
380 | #else //KAB_EMBEDDED | 384 | #else //KAB_EMBEDDED |
381 | aItem = (AddresseeCardViewItem*)(item); | 385 | aItem = (AddresseeCardViewItem*)(item); |
382 | #endif //KAB_EMBEDDED | 386 | #endif //KAB_EMBEDDED |
383 | 387 | ||
384 | if ((aItem) && (aItem->addressee().uid() == uid)) | 388 | if ((aItem) && (aItem->addressee().uid() == uid)) |
385 | { | 389 | { |
386 | aItem->refresh(); | 390 | aItem->refresh(); |
387 | found = true; | 391 | found = true; |
388 | } | 392 | } |
389 | } | 393 | } |
390 | } | 394 | } |
391 | } | 395 | } |
392 | 396 | ||
393 | void KAddressBookCardView::setSelected(QString uid, bool selected) | 397 | void KAddressBookCardView::setSelected(QString uid, bool selected) |
394 | { | 398 | { |
395 | CardViewItem *item; | 399 | CardViewItem *item; |
396 | AddresseeCardViewItem *aItem; | 400 | AddresseeCardViewItem *aItem; |
397 | 401 | ||
398 | if (uid.isNull()) | 402 | if (uid.isNull()) |
399 | { | 403 | { |
400 | mCardView->selectAll(selected); | 404 | mCardView->selectAll(selected); |
401 | } | 405 | } |
402 | else | 406 | else |
403 | { | 407 | { |
404 | bool found = false; | 408 | bool found = false; |
405 | for (item = mCardView->firstItem(); item && !found; | 409 | for (item = mCardView->firstItem(); item && !found; |
406 | item = item->nextItem()) | 410 | item = item->nextItem()) |
407 | { | 411 | { |
408 | #ifndef KAB_EMBEDDED | 412 | #ifndef KAB_EMBEDDED |
409 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 413 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
410 | #else //KAB_EMBEDDED | 414 | #else //KAB_EMBEDDED |
411 | aItem = (AddresseeCardViewItem*)(item); | 415 | aItem = (AddresseeCardViewItem*)(item); |
412 | #endif //KAB_EMBEDDED | 416 | #endif //KAB_EMBEDDED |
413 | 417 | ||
414 | if ((aItem) && (aItem->addressee().uid() == uid)) | 418 | if ((aItem) && (aItem->addressee().uid() == uid)) |
415 | { | 419 | { |
416 | mCardView->setSelected(aItem, selected); | 420 | mCardView->setSelected(aItem, selected); |
417 | mCardView->ensureItemVisible(item); | 421 | mCardView->ensureItemVisible(item); |
418 | found = true; | 422 | found = true; |
419 | } | 423 | } |
420 | } | 424 | } |
421 | } | 425 | } |
422 | } | 426 | } |
423 | 427 | ||
424 | //US added an additional method without parameter | 428 | //US added an additional method without parameter |
425 | void KAddressBookCardView::setSelected() | 429 | void KAddressBookCardView::setSelected() |
426 | { | 430 | { |
427 | setSelected(QString::null, true); | 431 | setSelected(QString::null, true); |
428 | } | 432 | } |
429 | 433 | ||
430 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) | 434 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) |
431 | { | 435 | { |
432 | #ifndef KAB_EMBEDDED | 436 | #ifndef KAB_EMBEDDED |
433 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 437 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
434 | #else //KAB_EMBEDDED | 438 | #else //KAB_EMBEDDED |
435 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); | 439 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); |
436 | #endif //KAB_EMBEDDED | 440 | #endif //KAB_EMBEDDED |
437 | if (aItem) | 441 | if (aItem) |
438 | { | 442 | { |
439 | //kdDebug()<<"... even has a valid item:)"<<endl; | 443 | //kdDebug()<<"... even has a valid item:)"<<endl; |
440 | emit executed(aItem->addressee().uid()); | 444 | emit executed(aItem->addressee().uid()); |
441 | } | 445 | } |
442 | } | 446 | } |
443 | 447 | ||
444 | void KAddressBookCardView::addresseeSelected() | 448 | void KAddressBookCardView::addresseeSelected() |
445 | { | 449 | { |
446 | CardViewItem *item; | 450 | CardViewItem *item; |
447 | AddresseeCardViewItem *aItem; | 451 | AddresseeCardViewItem *aItem; |
448 | 452 | ||
449 | bool found = false; | 453 | bool found = false; |
450 | for (item = mCardView->firstItem(); item && !found; | 454 | for (item = mCardView->firstItem(); item && !found; |
451 | item = item->nextItem()) | 455 | item = item->nextItem()) |
452 | { | 456 | { |
453 | if (item->isSelected()) | 457 | if (item->isSelected()) |
454 | { | 458 | { |
455 | #ifndef KAB_EMBEDDED | 459 | #ifndef KAB_EMBEDDED |
456 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 460 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
457 | #else //KAB_EMBEDDED | 461 | #else //KAB_EMBEDDED |
458 | aItem = (AddresseeCardViewItem*)(item); | 462 | aItem = (AddresseeCardViewItem*)(item); |
459 | #endif //KAB_EMBEDDED | 463 | #endif //KAB_EMBEDDED |
460 | if ( aItem ) | 464 | if ( aItem ) |
461 | { | 465 | { |
462 | emit selected(aItem->addressee().uid()); | 466 | emit selected(aItem->addressee().uid()); |
463 | found = true; | 467 | found = true; |
464 | } | 468 | } |
465 | } | 469 | } |
466 | } | 470 | } |
467 | 471 | ||
468 | if (!found) | 472 | if (!found) |
469 | emit selected(QString::null); | 473 | emit selected(QString::null); |
470 | 474 | ||
471 | } | 475 | } |
472 | #ifndef KAB_EMBEDDED | 476 | #ifndef KAB_EMBEDDED |
473 | #include "kaddressbookcardview.moc" | 477 | #include "kaddressbookcardview.moc" |
474 | #endif //KAB_EMBEDDED | 478 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index 41c3cb2..0ce56c8 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp | |||
@@ -1,452 +1,456 @@ | |||
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 <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qapplication.h> | 44 | #include <qapplication.h> |
45 | #include <kglobal.h> | 45 | #include <kglobal.h> |
46 | /*US transfered to the headerfile | 46 | /*US transfered to the headerfile |
47 | class IconViewFactory : public ViewFactory | 47 | class IconViewFactory : public ViewFactory |
48 | { | 48 | { |
49 | public: | 49 | public: |
50 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 50 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
51 | { | 51 | { |
52 | return new KAddressBookIconView( ab, parent, name ); | 52 | return new KAddressBookIconView( ab, parent, name ); |
53 | } | 53 | } |
54 | 54 | ||
55 | QString type() const { return "Icon"; } | 55 | QString type() const { return "Icon"; } |
56 | 56 | ||
57 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } | 57 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } |
58 | }; | 58 | }; |
59 | 59 | ||
60 | */ | 60 | */ |
61 | 61 | ||
62 | extern "C" { | 62 | extern "C" { |
63 | void *init_libkaddrbk_iconview() | 63 | void *init_libkaddrbk_iconview() |
64 | { | 64 | { |
65 | return ( new IconViewFactory ); | 65 | return ( new IconViewFactory ); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | //////////////////////////////// | 69 | //////////////////////////////// |
70 | // AddresseeIconView (internal class) | 70 | // AddresseeIconView (internal class) |
71 | #ifndef KAB_EMBEDDED | 71 | #ifndef KAB_EMBEDDED |
72 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 72 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
73 | : KIconView(parent, name) | 73 | : KIconView(parent, name) |
74 | #else //KAB_EMBEDDED | 74 | #else //KAB_EMBEDDED |
75 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 75 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
76 | : QIconView(parent, name) | 76 | : QIconView(parent, name) |
77 | #endif //KAB_EMBEDDED | 77 | #endif //KAB_EMBEDDED |
78 | 78 | ||
79 | { | 79 | { |
80 | setSelectionMode( QIconView::Extended ); | 80 | setSelectionMode( QIconView::Extended ); |
81 | setResizeMode( QIconView::Adjust ); | 81 | setResizeMode( QIconView::Adjust ); |
82 | setWordWrapIconText( true ); | 82 | setWordWrapIconText( true ); |
83 | setGridX( 100 ); | 83 | setGridX( 100 ); |
84 | setItemsMovable(false); | 84 | setItemsMovable(false); |
85 | setSorting(true, true); | 85 | setSorting(true, true); |
86 | 86 | ||
87 | 87 | ||
88 | //US ??? setMode( KIconView::Select ); | 88 | //US ??? setMode( KIconView::Select ); |
89 | 89 | ||
90 | #ifndef KAB_EMBEDDED | 90 | #ifndef KAB_EMBEDDED |
91 | 91 | ||
92 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), | 92 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), |
93 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); | 93 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); |
94 | #endif //KAB_EMBEDDED | 94 | #endif //KAB_EMBEDDED |
95 | } | 95 | } |
96 | 96 | ||
97 | AddresseeIconView::~AddresseeIconView() | 97 | AddresseeIconView::~AddresseeIconView() |
98 | { | 98 | { |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void AddresseeIconView::itemDropped(QDropEvent *e, | 102 | void AddresseeIconView::itemDropped(QDropEvent *e, |
103 | const QValueList<QIconDragItem> &) | 103 | const QValueList<QIconDragItem> &) |
104 | { | 104 | { |
105 | emit addresseeDropped(e); | 105 | emit addresseeDropped(e); |
106 | } | 106 | } |
107 | 107 | ||
108 | QDragObject *AddresseeIconView::dragObject() | 108 | QDragObject *AddresseeIconView::dragObject() |
109 | { | 109 | { |
110 | emit startAddresseeDrag(); | 110 | emit startAddresseeDrag(); |
111 | 111 | ||
112 | // We never want IconView to start the drag | 112 | // We never want IconView to start the drag |
113 | return 0; | 113 | return 0; |
114 | } | 114 | } |
115 | //////////////////////////////// | 115 | //////////////////////////////// |
116 | // AddresseeIconViewItem (internal class) | 116 | // AddresseeIconViewItem (internal class) |
117 | #ifndef KAB_EMBEDDED | 117 | #ifndef KAB_EMBEDDED |
118 | class AddresseeIconViewItem : public KIconViewItem | 118 | class AddresseeIconViewItem : public KIconViewItem |
119 | #else //KAB_EMBEDDED | 119 | #else //KAB_EMBEDDED |
120 | class AddresseeIconViewItem : public QIconViewItem | 120 | class AddresseeIconViewItem : public QIconViewItem |
121 | #endif //KAB_EMBEDDED | 121 | #endif //KAB_EMBEDDED |
122 | { | 122 | { |
123 | public: | 123 | public: |
124 | #ifndef KAB_EMBEDDED | 124 | #ifndef KAB_EMBEDDED |
125 | AddresseeIconViewItem(const KABC::Field::List &fields, | 125 | AddresseeIconViewItem(const KABC::Field::List &fields, |
126 | KABC::AddressBook *doc, const KABC::Addressee &a, | 126 | KABC::AddressBook *doc, const KABC::Addressee &a, |
127 | QIconView *parent) | 127 | QIconView *parent) |
128 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 128 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
129 | #else //KAB_EMBEDDED | 129 | #else //KAB_EMBEDDED |
130 | AddresseeIconViewItem(const KABC::Field::List &fields, | 130 | AddresseeIconViewItem(const KABC::Field::List &fields, |
131 | KABC::AddressBook *doc, const KABC::Addressee &a, | 131 | KABC::AddressBook *doc, const KABC::Addressee &a, |
132 | QIconView *parent) | 132 | QIconView *parent) |
133 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 133 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
134 | #endif //KAB_EMBEDDED | 134 | #endif //KAB_EMBEDDED |
135 | { | 135 | { |
136 | if ( mFields.isEmpty() ) { | 136 | if ( mFields.isEmpty() ) { |
137 | mFields = KABC::Field::defaultFields(); | 137 | mFields = KABC::Field::defaultFields(); |
138 | } | 138 | } |
139 | refresh(); | 139 | refresh(); |
140 | } | 140 | } |
141 | 141 | ||
142 | const KABC::Addressee &addressee() const { return mAddressee; } | 142 | const KABC::Addressee &addressee() const { return mAddressee; } |
143 | 143 | ||
144 | void refresh() | 144 | void refresh() |
145 | { | 145 | { |
146 | // Update our addressee, since it may have changed elsewhere | 146 | // Update our addressee, since it may have changed elsewhere |
147 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 147 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
148 | 148 | ||
149 | if (!mAddressee.isEmpty()) | 149 | if (!mAddressee.isEmpty()) |
150 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); | 150 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); |
151 | 151 | ||
152 | QPixmap icon; | 152 | QPixmap icon; |
153 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); | 153 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); |
154 | KABC::Picture pic = mAddressee.photo(); | 154 | KABC::Picture pic = mAddressee.photo(); |
155 | if ( pic.data().isNull() ) | 155 | if ( pic.data().isNull() ) |
156 | pic = mAddressee.logo(); | 156 | pic = mAddressee.logo(); |
157 | 157 | ||
158 | if ( pic.isIntern() && !pic.data().isNull() ) { | 158 | if ( pic.isIntern() && !pic.data().isNull() ) { |
159 | QImage img = pic.data(); | 159 | QImage img = pic.data(); |
160 | #ifndef KAB_EMBEDDED | 160 | #ifndef KAB_EMBEDDED |
161 | if ( img.width() > img.height() ) | 161 | if ( img.width() > img.height() ) |
162 | icon = img.scaleWidth( 32 ); | 162 | icon = img.scaleWidth( 32 ); |
163 | else | 163 | else |
164 | icon = img.scaleHeight( 32 ); | 164 | icon = img.scaleHeight( 32 ); |
165 | #else //KAB_EMBEDDED | 165 | #else //KAB_EMBEDDED |
166 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); | 166 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); |
167 | icon.convertFromImage(img.smoothScale(32, 32)); | 167 | icon.convertFromImage(img.smoothScale(32, 32)); |
168 | #endif //KAB_EMBEDDED | 168 | #endif //KAB_EMBEDDED |
169 | 169 | ||
170 | } else | 170 | } else |
171 | icon = defaultIcon; | 171 | icon = defaultIcon; |
172 | 172 | ||
173 | setPixmap( icon ); | 173 | setPixmap( icon ); |
174 | } | 174 | } |
175 | 175 | ||
176 | private: | 176 | private: |
177 | KABC::Field::List mFields; | 177 | KABC::Field::List mFields; |
178 | KABC::AddressBook *mDocument; | 178 | KABC::AddressBook *mDocument; |
179 | KABC::Addressee mAddressee; | 179 | KABC::Addressee mAddressee; |
180 | }; | 180 | }; |
181 | 181 | ||
182 | /////////////////////////////// | 182 | /////////////////////////////// |
183 | // KAddressBookView | 183 | // KAddressBookView |
184 | 184 | ||
185 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | 185 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, |
186 | QWidget *parent, const char *name) | 186 | QWidget *parent, const char *name) |
187 | : KAddressBookView( ab, parent, name ) | 187 | : KAddressBookView( ab, parent, name ) |
188 | { | 188 | { |
189 | // Init the GUI | 189 | // Init the GUI |
190 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 190 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
191 | 191 | ||
192 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); | 192 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); |
193 | layout->addWidget(mIconView); | 193 | layout->addWidget(mIconView); |
194 | 194 | ||
195 | // Connect up the signals | 195 | // Connect up the signals |
196 | 196 | ||
197 | //US method executed is part of KIconView | 197 | //US method executed is part of KIconView |
198 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 198 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
199 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 199 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
200 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 200 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
201 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 201 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
202 | 202 | ||
203 | connect(mIconView, SIGNAL(selectionChanged()), | 203 | connect(mIconView, SIGNAL(selectionChanged()), |
204 | this, SLOT(addresseeSelected())); | 204 | this, SLOT(addresseeSelected())); |
205 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), | 205 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), |
206 | this, SIGNAL(dropped(QDropEvent*))); | 206 | this, SIGNAL(dropped(QDropEvent*))); |
207 | connect(mIconView, SIGNAL(startAddresseeDrag()), | 207 | connect(mIconView, SIGNAL(startAddresseeDrag()), |
208 | this, SIGNAL(startDrag())); | 208 | this, SIGNAL(startDrag())); |
209 | } | 209 | } |
210 | 210 | ||
211 | KAddressBookIconView::~KAddressBookIconView() | 211 | KAddressBookIconView::~KAddressBookIconView() |
212 | { | 212 | { |
213 | } | 213 | } |
214 | void KAddressBookIconView::setFocusAV() | 214 | void KAddressBookIconView::setFocusAV() |
215 | { | 215 | { |
216 | if ( mIconView ) | 216 | if ( mIconView ) |
217 | mIconView->setFocus(); | 217 | mIconView->setFocus(); |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | void KAddressBookIconView::scrollUP() | 221 | void KAddressBookIconView::scrollUP() |
222 | { | 222 | { |
223 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | 223 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); |
224 | QApplication::postEvent( mIconView, ev ); | 224 | QApplication::postEvent( mIconView, ev ); |
225 | } | 225 | } |
226 | void KAddressBookIconView::scrollDOWN() | 226 | void KAddressBookIconView::scrollDOWN() |
227 | { | 227 | { |
228 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | 228 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); |
229 | QApplication::postEvent( mIconView, ev ); | 229 | QApplication::postEvent( mIconView, ev ); |
230 | } | 230 | } |
231 | void KAddressBookIconView::readConfig(KConfig *config) | 231 | void KAddressBookIconView::readConfig(KConfig *config) |
232 | { | 232 | { |
233 | KAddressBookView::readConfig(config); | 233 | KAddressBookView::readConfig(config); |
234 | 234 | ||
235 | //US method executed is part of KIconView | 235 | //US method executed is part of KIconView |
236 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), | 236 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), |
237 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 237 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
238 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 238 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
239 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 239 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
240 | 240 | ||
241 | //US method executed is part of KIconView. Use selectionChanged instead | 241 | //US method executed is part of KIconView. Use selectionChanged instead |
242 | /*US | 242 | /*US |
243 | if (KABPrefs::instance()->mHonorSingleClick) | 243 | if (KABPrefs::instance()->mHonorSingleClick) |
244 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 244 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
245 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 245 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
246 | else | 246 | else |
247 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), | 247 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), |
248 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 248 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
249 | */ | 249 | */ |
250 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 250 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
251 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 251 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
252 | 252 | ||
253 | } | 253 | } |
254 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | 254 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) |
255 | { | 255 | { |
256 | mIconView->clear(); | 256 | mIconView->clear(); |
257 | mIconList.clear(); | 257 | mIconList.clear(); |
258 | if ( s.isEmpty() || s == "*" ) { | 258 | if ( s.isEmpty() || s == "*" ) { |
259 | refresh(); | 259 | refresh(); |
260 | return; | 260 | return; |
261 | } | 261 | } |
262 | QString pattern = s.lower()+"*"; | 262 | QString pattern = s.lower()+"*"; |
263 | QRegExp re; | 263 | QRegExp re; |
264 | re.setWildcard(true); // most people understand these better. | 264 | re.setWildcard(true); // most people understand these better. |
265 | re.setCaseSensitive(false); | 265 | re.setCaseSensitive(false); |
266 | re.setPattern( pattern ); | 266 | re.setPattern( pattern ); |
267 | if (!re.isValid()) | 267 | if (!re.isValid()) |
268 | return; | 268 | return; |
269 | KABC::Addressee::List addresseeList = addressees(); | 269 | KABC::Addressee::List addresseeList = addressees(); |
270 | KABC::Addressee::List::Iterator it; | 270 | KABC::Addressee::List::Iterator it; |
271 | if ( field ) { | 271 | if ( field ) { |
272 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 272 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
273 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | ||
274 | continue; | ||
273 | #if QT_VERSION >= 300 | 275 | #if QT_VERSION >= 300 |
274 | if (re.search(field->value( *it ).lower()) != -1) | 276 | if (re.search(field->value( *it ).lower()) != -1) |
275 | #else | 277 | #else |
276 | if (re.match(field->value( *it ).lower()) != -1) | 278 | if (re.match(field->value( *it ).lower()) != -1) |
277 | #endif | 279 | #endif |
278 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 280 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
279 | 281 | ||
280 | 282 | ||
281 | } | 283 | } |
282 | } else { | 284 | } else { |
283 | KABC::Field::List fieldList = fields(); | 285 | KABC::Field::List fieldList = fields(); |
284 | KABC::Field::List::ConstIterator fieldIt; | 286 | KABC::Field::List::ConstIterator fieldIt; |
285 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 287 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
288 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | ||
289 | continue; | ||
286 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 290 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
287 | #if QT_VERSION >= 300 | 291 | #if QT_VERSION >= 300 |
288 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 292 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
289 | #else | 293 | #else |
290 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 294 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
291 | #endif | 295 | #endif |
292 | { | 296 | { |
293 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 297 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
294 | continue; | 298 | continue; |
295 | } | 299 | } |
296 | } | 300 | } |
297 | } | 301 | } |
298 | } | 302 | } |
299 | mIconView->arrangeItemsInGrid( true ); | 303 | mIconView->arrangeItemsInGrid( true ); |
300 | if ( mIconView->firstItem() ) { | 304 | if ( mIconView->firstItem() ) { |
301 | mIconView->setCurrentItem ( mIconView->firstItem() ); | 305 | mIconView->setCurrentItem ( mIconView->firstItem() ); |
302 | mIconView->setSelected ( mIconView->firstItem() , true ); | 306 | mIconView->setSelected ( mIconView->firstItem() , true ); |
303 | } | 307 | } |
304 | else | 308 | else |
305 | emit selected(QString::null); | 309 | emit selected(QString::null); |
306 | } | 310 | } |
307 | QStringList KAddressBookIconView::selectedUids() | 311 | QStringList KAddressBookIconView::selectedUids() |
308 | { | 312 | { |
309 | QStringList uidList; | 313 | QStringList uidList; |
310 | QIconViewItem *item; | 314 | QIconViewItem *item; |
311 | AddresseeIconViewItem *aItem; | 315 | AddresseeIconViewItem *aItem; |
312 | 316 | ||
313 | for (item = mIconView->firstItem(); item; item = item->nextItem()) | 317 | for (item = mIconView->firstItem(); item; item = item->nextItem()) |
314 | { | 318 | { |
315 | if (item->isSelected()) | 319 | if (item->isSelected()) |
316 | { | 320 | { |
317 | #ifndef KAB_EMBEDDED | 321 | #ifndef KAB_EMBEDDED |
318 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 322 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
319 | #else //KAB_EMBEDDED | 323 | #else //KAB_EMBEDDED |
320 | aItem = (AddresseeIconViewItem*)(item); | 324 | aItem = (AddresseeIconViewItem*)(item); |
321 | #endif //KAB_EMBEDDED | 325 | #endif //KAB_EMBEDDED |
322 | if (aItem) | 326 | if (aItem) |
323 | uidList << aItem->addressee().uid(); | 327 | uidList << aItem->addressee().uid(); |
324 | } | 328 | } |
325 | } | 329 | } |
326 | 330 | ||
327 | return uidList; | 331 | return uidList; |
328 | } | 332 | } |
329 | 333 | ||
330 | void KAddressBookIconView::refresh(QString uid) | 334 | void KAddressBookIconView::refresh(QString uid) |
331 | { | 335 | { |
332 | QIconViewItem *item; | 336 | QIconViewItem *item; |
333 | AddresseeIconViewItem *aItem; | 337 | AddresseeIconViewItem *aItem; |
334 | 338 | ||
335 | if ( uid.isNull() ) { | 339 | if ( uid.isNull() ) { |
336 | // Rebuild the view | 340 | // Rebuild the view |
337 | mIconView->clear(); | 341 | mIconView->clear(); |
338 | mIconList.clear(); | 342 | mIconList.clear(); |
339 | 343 | ||
340 | KABC::Addressee::List addresseeList = addressees(); | 344 | KABC::Addressee::List addresseeList = addressees(); |
341 | KABC::Addressee::List::Iterator iter; | 345 | KABC::Addressee::List::Iterator iter; |
342 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { | 346 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { |
343 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) | 347 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) |
344 | continue; | 348 | continue; |
345 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); | 349 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); |
346 | } | 350 | } |
347 | 351 | ||
348 | mIconView->arrangeItemsInGrid( true ); | 352 | mIconView->arrangeItemsInGrid( true ); |
349 | 353 | ||
350 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) | 354 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) |
351 | { | 355 | { |
352 | #ifndef KAB_EMBEDDED | 356 | #ifndef KAB_EMBEDDED |
353 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); | 357 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); |
354 | #else //KAB_EMBEDDED | 358 | #else //KAB_EMBEDDED |
355 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); | 359 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); |
356 | #endif //KAB_EMBEDDED | 360 | #endif //KAB_EMBEDDED |
357 | mIconList.append( aivi ); | 361 | mIconList.append( aivi ); |
358 | } | 362 | } |
359 | 363 | ||
360 | } else { | 364 | } else { |
361 | // Try to find the one to refresh | 365 | // Try to find the one to refresh |
362 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { | 366 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { |
363 | #ifndef KAB_EMBEDDED | 367 | #ifndef KAB_EMBEDDED |
364 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 368 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
365 | #else //KAB_EMBEDDED | 369 | #else //KAB_EMBEDDED |
366 | aItem = (AddresseeIconViewItem*)(item); | 370 | aItem = (AddresseeIconViewItem*)(item); |
367 | #endif //KAB_EMBEDDED | 371 | #endif //KAB_EMBEDDED |
368 | if ((aItem) && (aItem->addressee().uid() == uid)) { | 372 | if ((aItem) && (aItem->addressee().uid() == uid)) { |
369 | aItem->refresh(); | 373 | aItem->refresh(); |
370 | mIconView->arrangeItemsInGrid( true ); | 374 | mIconView->arrangeItemsInGrid( true ); |
371 | return; | 375 | return; |
372 | } | 376 | } |
373 | } | 377 | } |
374 | refresh( QString::null ); | 378 | refresh( QString::null ); |
375 | } | 379 | } |
376 | } | 380 | } |
377 | 381 | ||
378 | void KAddressBookIconView::setSelected(QString uid, bool selected) | 382 | void KAddressBookIconView::setSelected(QString uid, bool selected) |
379 | { | 383 | { |
380 | QIconViewItem *item; | 384 | QIconViewItem *item; |
381 | AddresseeIconViewItem *aItem; | 385 | AddresseeIconViewItem *aItem; |
382 | 386 | ||
383 | if (uid.isNull()) | 387 | if (uid.isNull()) |
384 | { | 388 | { |
385 | mIconView->selectAll(selected); | 389 | mIconView->selectAll(selected); |
386 | } | 390 | } |
387 | else | 391 | else |
388 | { | 392 | { |
389 | bool found = false; | 393 | bool found = false; |
390 | for (item = mIconView->firstItem(); item && !found; | 394 | for (item = mIconView->firstItem(); item && !found; |
391 | item = item->nextItem()) | 395 | item = item->nextItem()) |
392 | { | 396 | { |
393 | #ifndef KAB_EMBEDDED | 397 | #ifndef KAB_EMBEDDED |
394 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 398 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
395 | #else //KAB_EMBEDDED | 399 | #else //KAB_EMBEDDED |
396 | aItem = (AddresseeIconViewItem*)(item); | 400 | aItem = (AddresseeIconViewItem*)(item); |
397 | #endif //KAB_EMBEDDED | 401 | #endif //KAB_EMBEDDED |
398 | 402 | ||
399 | if ((aItem) && (aItem->addressee().uid() == uid)) | 403 | if ((aItem) && (aItem->addressee().uid() == uid)) |
400 | { | 404 | { |
401 | mIconView->setSelected(aItem, selected); | 405 | mIconView->setSelected(aItem, selected); |
402 | mIconView->ensureItemVisible( aItem ); | 406 | mIconView->ensureItemVisible( aItem ); |
403 | found = true; | 407 | found = true; |
404 | } | 408 | } |
405 | } | 409 | } |
406 | } | 410 | } |
407 | } | 411 | } |
408 | 412 | ||
409 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) | 413 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) |
410 | { | 414 | { |
411 | #ifndef KAB_EMBEDDED | 415 | #ifndef KAB_EMBEDDED |
412 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 416 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
413 | #else //KAB_EMBEDDED | 417 | #else //KAB_EMBEDDED |
414 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); | 418 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); |
415 | #endif //KAB_EMBEDDED | 419 | #endif //KAB_EMBEDDED |
416 | 420 | ||
417 | if (aItem) { | 421 | if (aItem) { |
418 | emit executed(aItem->addressee().uid()); | 422 | emit executed(aItem->addressee().uid()); |
419 | } | 423 | } |
420 | } | 424 | } |
421 | 425 | ||
422 | void KAddressBookIconView::addresseeSelected() | 426 | void KAddressBookIconView::addresseeSelected() |
423 | { | 427 | { |
424 | QIconViewItem *item; | 428 | QIconViewItem *item; |
425 | AddresseeIconViewItem *aItem; | 429 | AddresseeIconViewItem *aItem; |
426 | 430 | ||
427 | bool found = false; | 431 | bool found = false; |
428 | for (item = mIconView->firstItem(); item && !found; | 432 | for (item = mIconView->firstItem(); item && !found; |
429 | item = item->nextItem()) | 433 | item = item->nextItem()) |
430 | { | 434 | { |
431 | if (item->isSelected()) | 435 | if (item->isSelected()) |
432 | { | 436 | { |
433 | #ifndef KAB_EMBEDDED | 437 | #ifndef KAB_EMBEDDED |
434 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 438 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
435 | #else //KAB_EMBEDDED | 439 | #else //KAB_EMBEDDED |
436 | aItem = (AddresseeIconViewItem*)(item); | 440 | aItem = (AddresseeIconViewItem*)(item); |
437 | #endif //KAB_EMBEDDED | 441 | #endif //KAB_EMBEDDED |
438 | if (aItem) | 442 | if (aItem) |
439 | { | 443 | { |
440 | emit selected(aItem->addressee().uid()); | 444 | emit selected(aItem->addressee().uid()); |
441 | found = true; | 445 | found = true; |
442 | } | 446 | } |
443 | } | 447 | } |
444 | } | 448 | } |
445 | 449 | ||
446 | if (!found) | 450 | if (!found) |
447 | emit selected(QString::null); | 451 | emit selected(QString::null); |
448 | } | 452 | } |
449 | 453 | ||
450 | #ifndef KAB_EMBEDDED | 454 | #ifndef KAB_EMBEDDED |
451 | #include "kaddressbookiconview.moc" | 455 | #include "kaddressbookiconview.moc" |
452 | #endif //KAB_EMBEDDED | 456 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 6f20e05..89053c2 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -1,471 +1,475 @@ | |||
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 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | 37 | ||
38 | #include "kaddressbooktableview.h" | 38 | #include "kaddressbooktableview.h" |
39 | 39 | ||
40 | 40 | ||
41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, |
42 | QWidget *parent, const char *name ) | 42 | QWidget *parent, const char *name ) |
43 | : KAddressBookView( ab, parent, name ) | 43 | : KAddressBookView( ab, parent, name ) |
44 | { | 44 | { |
45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); | 45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); |
46 | 46 | ||
47 | // The list view will be created when the config is read. | 47 | // The list view will be created when the config is read. |
48 | mListView = 0; | 48 | mListView = 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | KAddressBookTableView::~KAddressBookTableView() | 51 | KAddressBookTableView::~KAddressBookTableView() |
52 | { | 52 | { |
53 | } | 53 | } |
54 | void KAddressBookTableView::setFocusAV() | 54 | void KAddressBookTableView::setFocusAV() |
55 | { | 55 | { |
56 | if ( mListView ) | 56 | if ( mListView ) |
57 | mListView->setFocus(); | 57 | mListView->setFocus(); |
58 | 58 | ||
59 | } | 59 | } |
60 | void KAddressBookTableView::scrollUP() | 60 | void KAddressBookTableView::scrollUP() |
61 | { | 61 | { |
62 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | 62 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); |
63 | QApplication::postEvent( mListView, ev ); | 63 | QApplication::postEvent( mListView, ev ); |
64 | } | 64 | } |
65 | void KAddressBookTableView::scrollDOWN() | 65 | void KAddressBookTableView::scrollDOWN() |
66 | { | 66 | { |
67 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | 67 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); |
68 | QApplication::postEvent( mListView, ev ); | 68 | QApplication::postEvent( mListView, ev ); |
69 | } | 69 | } |
70 | void KAddressBookTableView::reconstructListView() | 70 | void KAddressBookTableView::reconstructListView() |
71 | { | 71 | { |
72 | if (mListView) | 72 | if (mListView) |
73 | { | 73 | { |
74 | disconnect(mListView, SIGNAL(selectionChanged()), | 74 | disconnect(mListView, SIGNAL(selectionChanged()), |
75 | this, SLOT(addresseeSelected())); | 75 | this, SLOT(addresseeSelected())); |
76 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 76 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |
77 | this, SLOT(addresseeExecuted(QListViewItem*))); | 77 | this, SLOT(addresseeExecuted(QListViewItem*))); |
78 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 78 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
79 | this, SLOT(addresseeExecuted(QListViewItem*))); | 79 | this, SLOT(addresseeExecuted(QListViewItem*))); |
80 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, | 80 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, |
81 | SIGNAL(startDrag())); | 81 | SIGNAL(startDrag())); |
82 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 82 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
83 | this, SLOT(addresseeExecuted(QListViewItem*))); | 83 | this, SLOT(addresseeExecuted(QListViewItem*))); |
84 | 84 | ||
85 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 85 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
86 | SIGNAL(dropped(QDropEvent*))); | 86 | SIGNAL(dropped(QDropEvent*))); |
87 | delete mListView; | 87 | delete mListView; |
88 | } | 88 | } |
89 | 89 | ||
90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 90 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
91 | 91 | ||
92 | //US set singleClick manually, because it is no global configparameter in embedded space | 92 | //US set singleClick manually, because it is no global configparameter in embedded space |
93 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); | 93 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); |
94 | 94 | ||
95 | // Add the columns | 95 | // Add the columns |
96 | KABC::Field::List fieldList = fields(); | 96 | KABC::Field::List fieldList = fields(); |
97 | KABC::Field::List::ConstIterator it; | 97 | KABC::Field::List::ConstIterator it; |
98 | 98 | ||
99 | int c = 0; | 99 | int c = 0; |
100 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 100 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
101 | mListView->addColumn( (*it)->label() ); | 101 | mListView->addColumn( (*it)->label() ); |
102 | mListView->setColumnWidthMode(c++, QListView::Manual); | 102 | mListView->setColumnWidthMode(c++, QListView::Manual); |
103 | //US | 103 | //US |
104 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 104 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
105 | } | 105 | } |
106 | 106 | ||
107 | connect(mListView, SIGNAL(selectionChanged()), | 107 | connect(mListView, SIGNAL(selectionChanged()), |
108 | this, SLOT(addresseeSelected())); | 108 | this, SLOT(addresseeSelected())); |
109 | connect(mListView, SIGNAL(startAddresseeDrag()), this, | 109 | connect(mListView, SIGNAL(startAddresseeDrag()), this, |
110 | SIGNAL(startDrag())); | 110 | SIGNAL(startDrag())); |
111 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 111 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
112 | SIGNAL(dropped(QDropEvent*))); | 112 | SIGNAL(dropped(QDropEvent*))); |
113 | 113 | ||
114 | if (KABPrefs::instance()->mHonorSingleClick) { | 114 | if (KABPrefs::instance()->mHonorSingleClick) { |
115 | // qDebug("KAddressBookTableView::reconstructListView single"); | 115 | // qDebug("KAddressBookTableView::reconstructListView single"); |
116 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 116 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
117 | this, SLOT(addresseeExecuted(QListViewItem*))); | 117 | this, SLOT(addresseeExecuted(QListViewItem*))); |
118 | } else { | 118 | } else { |
119 | // qDebug("KAddressBookTableView::reconstructListView double"); | 119 | // qDebug("KAddressBookTableView::reconstructListView double"); |
120 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 120 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
121 | this, SLOT(addresseeExecuted(QListViewItem*))); | 121 | this, SLOT(addresseeExecuted(QListViewItem*))); |
122 | } | 122 | } |
123 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 123 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
124 | this, SLOT(addresseeExecuted(QListViewItem*))); | 124 | this, SLOT(addresseeExecuted(QListViewItem*))); |
125 | connect(mListView, SIGNAL(signalDelete()), | 125 | connect(mListView, SIGNAL(signalDelete()), |
126 | this, SLOT(addresseeDeleted())); | 126 | this, SLOT(addresseeDeleted())); |
127 | 127 | ||
128 | //US performceimprovement. Refresh is done from the outside | 128 | //US performceimprovement. Refresh is done from the outside |
129 | //US refresh(); | 129 | //US refresh(); |
130 | 130 | ||
131 | mListView->setSorting( 0, true ); | 131 | mListView->setSorting( 0, true ); |
132 | mainLayout->addWidget( mListView ); | 132 | mainLayout->addWidget( mListView ); |
133 | mainLayout->activate(); | 133 | mainLayout->activate(); |
134 | mListView->show(); | 134 | mListView->show(); |
135 | } | 135 | } |
136 | 136 | ||
137 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 137 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) |
138 | { | 138 | { |
139 | mListView->clear(); | 139 | mListView->clear(); |
140 | if ( s.isEmpty() || s == "*" ) { | 140 | if ( s.isEmpty() || s == "*" ) { |
141 | refresh(); | 141 | refresh(); |
142 | return; | 142 | return; |
143 | } | 143 | } |
144 | QString pattern = s.lower()+"*"; | 144 | QString pattern = s.lower()+"*"; |
145 | QRegExp re; | 145 | QRegExp re; |
146 | re.setWildcard(true); // most people understand these better. | 146 | re.setWildcard(true); // most people understand these better. |
147 | re.setCaseSensitive(false); | 147 | re.setCaseSensitive(false); |
148 | re.setPattern( pattern ); | 148 | re.setPattern( pattern ); |
149 | if (!re.isValid()) | 149 | if (!re.isValid()) |
150 | return; | 150 | return; |
151 | KABC::Addressee::List addresseeList = addressees(); | 151 | KABC::Addressee::List addresseeList = addressees(); |
152 | KABC::Addressee::List::Iterator it; | 152 | KABC::Addressee::List::Iterator it; |
153 | if ( field ) { | 153 | if ( field ) { |
154 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 154 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
155 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | ||
156 | continue; | ||
155 | #if QT_VERSION >= 300 | 157 | #if QT_VERSION >= 300 |
156 | if (re.search(field->value( *it ).lower()) != -1) | 158 | if (re.search(field->value( *it ).lower()) != -1) |
157 | #else | 159 | #else |
158 | if (re.match(field->value( *it ).lower()) != -1) | 160 | if (re.match(field->value( *it ).lower()) != -1) |
159 | #endif | 161 | #endif |
160 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 162 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
161 | 163 | ||
162 | } | 164 | } |
163 | } else { | 165 | } else { |
164 | KABC::Field::List fieldList = fields(); | 166 | KABC::Field::List fieldList = fields(); |
165 | KABC::Field::List::ConstIterator fieldIt; | 167 | KABC::Field::List::ConstIterator fieldIt; |
166 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 168 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
169 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | ||
170 | continue; | ||
167 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 171 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
168 | #if QT_VERSION >= 300 | 172 | #if QT_VERSION >= 300 |
169 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 173 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
170 | #else | 174 | #else |
171 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 175 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
172 | #endif | 176 | #endif |
173 | { | 177 | { |
174 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 178 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
175 | break; | 179 | break; |
176 | } | 180 | } |
177 | } | 181 | } |
178 | } | 182 | } |
179 | } | 183 | } |
180 | // Sometimes the background pixmap gets messed up when we add lots | 184 | // Sometimes the background pixmap gets messed up when we add lots |
181 | // of items. | 185 | // of items. |
182 | mListView->repaint(); | 186 | mListView->repaint(); |
183 | if ( mListView->firstChild() ) { | 187 | if ( mListView->firstChild() ) { |
184 | mListView->setCurrentItem ( mListView->firstChild() ); | 188 | mListView->setCurrentItem ( mListView->firstChild() ); |
185 | mListView->setSelected ( mListView->firstChild(), true ); | 189 | mListView->setSelected ( mListView->firstChild(), true ); |
186 | } | 190 | } |
187 | else | 191 | else |
188 | emit selected(QString::null); | 192 | emit selected(QString::null); |
189 | 193 | ||
190 | } | 194 | } |
191 | void KAddressBookTableView::writeConfig(KConfig *config) | 195 | void KAddressBookTableView::writeConfig(KConfig *config) |
192 | { | 196 | { |
193 | KAddressBookView::writeConfig(config); | 197 | KAddressBookView::writeConfig(config); |
194 | 198 | ||
195 | mListView->saveLayout(config, config->group()); | 199 | mListView->saveLayout(config, config->group()); |
196 | } | 200 | } |
197 | 201 | ||
198 | void KAddressBookTableView::readConfig(KConfig *config) | 202 | void KAddressBookTableView::readConfig(KConfig *config) |
199 | { | 203 | { |
200 | KAddressBookView::readConfig( config ); | 204 | KAddressBookView::readConfig( config ); |
201 | // The config could have changed the fields, so we need to reconstruct | 205 | // The config could have changed the fields, so we need to reconstruct |
202 | // the listview. | 206 | // the listview. |
203 | reconstructListView(); | 207 | reconstructListView(); |
204 | 208 | ||
205 | // costum colors? | 209 | // costum colors? |
206 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 210 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
207 | { | 211 | { |
208 | QPalette p( mListView->palette() ); | 212 | QPalette p( mListView->palette() ); |
209 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 213 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
210 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 214 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
211 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 215 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
212 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 216 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
213 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 217 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
214 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 218 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
215 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 219 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
216 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 220 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
217 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 221 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
218 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 222 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
219 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 223 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
220 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 224 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
221 | #ifndef KAB_EMBEDDED | 225 | #ifndef KAB_EMBEDDED |
222 | c = KGlobalSettings::alternateBackgroundColor(); | 226 | c = KGlobalSettings::alternateBackgroundColor(); |
223 | #else //KAB_EMBEDDED | 227 | #else //KAB_EMBEDDED |
224 | c = QColor(240, 240, 240); | 228 | c = QColor(240, 240, 240); |
225 | #endif //KAB_EMBEDDED | 229 | #endif //KAB_EMBEDDED |
226 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 230 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
227 | mListView->setAlternateColor(c); | 231 | mListView->setAlternateColor(c); |
228 | 232 | ||
229 | 233 | ||
230 | //US mListView->viewport()->setPalette( p ); | 234 | //US mListView->viewport()->setPalette( p ); |
231 | mListView->setPalette( p ); | 235 | mListView->setPalette( p ); |
232 | } | 236 | } |
233 | else | 237 | else |
234 | { | 238 | { |
235 | // needed if turned off during a session. | 239 | // needed if turned off during a session. |
236 | //US mListView->viewport()->setPalette( mListView->palette() ); | 240 | //US mListView->viewport()->setPalette( mListView->palette() ); |
237 | mListView->setPalette( mListView->palette() ); | 241 | mListView->setPalette( mListView->palette() ); |
238 | } | 242 | } |
239 | 243 | ||
240 | //custom fonts? | 244 | //custom fonts? |
241 | QFont f( font() ); | 245 | QFont f( font() ); |
242 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 246 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
243 | { | 247 | { |
244 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 248 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
245 | f.setBold( true ); | 249 | f.setBold( true ); |
246 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 250 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
247 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 251 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
248 | } | 252 | } |
249 | else | 253 | else |
250 | { | 254 | { |
251 | mListView->setFont( f ); | 255 | mListView->setFont( f ); |
252 | f.setBold( true ); | 256 | f.setBold( true ); |
253 | //US mListView->setHeaderFont( f ); | 257 | //US mListView->setHeaderFont( f ); |
254 | mListView->header()->setFont( f ); | 258 | mListView->header()->setFont( f ); |
255 | } | 259 | } |
256 | 260 | ||
257 | 261 | ||
258 | 262 | ||
259 | 263 | ||
260 | 264 | ||
261 | // Set the list view options | 265 | // Set the list view options |
262 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 266 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
263 | true)); | 267 | true)); |
264 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 268 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
265 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 269 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
266 | 270 | ||
267 | if (config->readBoolEntry("Background", false)) | 271 | if (config->readBoolEntry("Background", false)) |
268 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 272 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
269 | 273 | ||
270 | // Restore the layout of the listview | 274 | // Restore the layout of the listview |
271 | mListView->restoreLayout(config, config->group()); | 275 | mListView->restoreLayout(config, config->group()); |
272 | } | 276 | } |
273 | 277 | ||
274 | void KAddressBookTableView::refresh(QString uid) | 278 | void KAddressBookTableView::refresh(QString uid) |
275 | { | 279 | { |
276 | // For now just repopulate. In reality this method should | 280 | // For now just repopulate. In reality this method should |
277 | // check the value of uid, and if valid iterate through | 281 | // check the value of uid, and if valid iterate through |
278 | // the listview to find the entry, then tell it to refresh. | 282 | // the listview to find the entry, then tell it to refresh. |
279 | 283 | ||
280 | if (uid.isNull()) { | 284 | if (uid.isNull()) { |
281 | // Clear the list view | 285 | // Clear the list view |
282 | QString currentUID, nextUID; | 286 | QString currentUID, nextUID; |
283 | #ifndef KAB_EMBEDDED | 287 | #ifndef KAB_EMBEDDED |
284 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 288 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
285 | #else //KAB_EMBEDDED | 289 | #else //KAB_EMBEDDED |
286 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 290 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
287 | #endif //KAB_EMBEDDED | 291 | #endif //KAB_EMBEDDED |
288 | 292 | ||
289 | if ( currentItem ) { | 293 | if ( currentItem ) { |
290 | #ifndef KAB_EMBEDDED | 294 | #ifndef KAB_EMBEDDED |
291 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 295 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
292 | #else //KAB_EMBEDDED | 296 | #else //KAB_EMBEDDED |
293 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 297 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
294 | #endif //KAB_EMBEDDED | 298 | #endif //KAB_EMBEDDED |
295 | if ( nextItem ) | 299 | if ( nextItem ) |
296 | nextUID = nextItem->addressee().uid(); | 300 | nextUID = nextItem->addressee().uid(); |
297 | currentUID = currentItem->addressee().uid(); | 301 | currentUID = currentItem->addressee().uid(); |
298 | } | 302 | } |
299 | 303 | ||
300 | mListView->clear(); | 304 | mListView->clear(); |
301 | 305 | ||
302 | currentItem = 0; | 306 | currentItem = 0; |
303 | KABC::Addressee::List addresseeList = addressees(); | 307 | KABC::Addressee::List addresseeList = addressees(); |
304 | KABC::Addressee::List::Iterator it; | 308 | KABC::Addressee::List::Iterator it; |
305 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 309 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
306 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 310 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
307 | continue; | 311 | continue; |
308 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 312 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
309 | if ( (*it).uid() == currentUID ) | 313 | if ( (*it).uid() == currentUID ) |
310 | currentItem = item; | 314 | currentItem = item; |
311 | else if ( (*it).uid() == nextUID && !currentItem ) | 315 | else if ( (*it).uid() == nextUID && !currentItem ) |
312 | currentItem = item; | 316 | currentItem = item; |
313 | } | 317 | } |
314 | 318 | ||
315 | // Sometimes the background pixmap gets messed up when we add lots | 319 | // Sometimes the background pixmap gets messed up when we add lots |
316 | // of items. | 320 | // of items. |
317 | mListView->repaint(); | 321 | mListView->repaint(); |
318 | 322 | ||
319 | if ( currentItem ) { | 323 | if ( currentItem ) { |
320 | mListView->setCurrentItem( currentItem ); | 324 | mListView->setCurrentItem( currentItem ); |
321 | mListView->ensureItemVisible( currentItem ); | 325 | mListView->ensureItemVisible( currentItem ); |
322 | } | 326 | } |
323 | } else { | 327 | } else { |
324 | // Only need to update on entry. Iterate through and try to find it | 328 | // Only need to update on entry. Iterate through and try to find it |
325 | ContactListViewItem *ceItem; | 329 | ContactListViewItem *ceItem; |
326 | QListViewItemIterator it( mListView ); | 330 | QListViewItemIterator it( mListView ); |
327 | while ( it.current() ) { | 331 | while ( it.current() ) { |
328 | #ifndef KAB_EMBEDDED | 332 | #ifndef KAB_EMBEDDED |
329 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 333 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
330 | #else //KAB_EMBEDDED | 334 | #else //KAB_EMBEDDED |
331 | ceItem = (ContactListViewItem*)( it.current() ); | 335 | ceItem = (ContactListViewItem*)( it.current() ); |
332 | #endif //KAB_EMBEDDED | 336 | #endif //KAB_EMBEDDED |
333 | 337 | ||
334 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 338 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
335 | ceItem->refresh(); | 339 | ceItem->refresh(); |
336 | return; | 340 | return; |
337 | } | 341 | } |
338 | ++it; | 342 | ++it; |
339 | } | 343 | } |
340 | 344 | ||
341 | refresh( QString::null ); | 345 | refresh( QString::null ); |
342 | } | 346 | } |
343 | } | 347 | } |
344 | 348 | ||
345 | QStringList KAddressBookTableView::selectedUids() | 349 | QStringList KAddressBookTableView::selectedUids() |
346 | { | 350 | { |
347 | QStringList uidList; | 351 | QStringList uidList; |
348 | QListViewItem *item; | 352 | QListViewItem *item; |
349 | ContactListViewItem *ceItem; | 353 | ContactListViewItem *ceItem; |
350 | 354 | ||
351 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 355 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
352 | { | 356 | { |
353 | if (mListView->isSelected( item )) | 357 | if (mListView->isSelected( item )) |
354 | { | 358 | { |
355 | #ifndef KAB_EMBEDDED | 359 | #ifndef KAB_EMBEDDED |
356 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 360 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
357 | #else //KAB_EMBEDDED | 361 | #else //KAB_EMBEDDED |
358 | ceItem = (ContactListViewItem*)(item); | 362 | ceItem = (ContactListViewItem*)(item); |
359 | #endif //KAB_EMBEDDED | 363 | #endif //KAB_EMBEDDED |
360 | 364 | ||
361 | if (ceItem != 0L) | 365 | if (ceItem != 0L) |
362 | uidList << ceItem->addressee().uid(); | 366 | uidList << ceItem->addressee().uid(); |
363 | } | 367 | } |
364 | } | 368 | } |
365 | if ( uidList.count() == 0 ) | 369 | if ( uidList.count() == 0 ) |
366 | if ( mListView->currentItem() ) { | 370 | if ( mListView->currentItem() ) { |
367 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; | 371 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; |
368 | uidList << ceItem->addressee().uid(); | 372 | uidList << ceItem->addressee().uid(); |
369 | } | 373 | } |
370 | 374 | ||
371 | return uidList; | 375 | return uidList; |
372 | } | 376 | } |
373 | 377 | ||
374 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 378 | void KAddressBookTableView::setSelected(QString uid, bool selected) |
375 | { | 379 | { |
376 | QListViewItem *item; | 380 | QListViewItem *item; |
377 | ContactListViewItem *ceItem; | 381 | ContactListViewItem *ceItem; |
378 | 382 | ||
379 | if (uid.isNull()) | 383 | if (uid.isNull()) |
380 | { | 384 | { |
381 | mListView->selectAll(selected); | 385 | mListView->selectAll(selected); |
382 | } | 386 | } |
383 | else | 387 | else |
384 | { | 388 | { |
385 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 389 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
386 | { | 390 | { |
387 | #ifndef KAB_EMBEDDED | 391 | #ifndef KAB_EMBEDDED |
388 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 392 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
389 | #else //KAB_EMBEDDED | 393 | #else //KAB_EMBEDDED |
390 | ceItem = (ContactListViewItem*)(item); | 394 | ceItem = (ContactListViewItem*)(item); |
391 | #endif //KAB_EMBEDDED | 395 | #endif //KAB_EMBEDDED |
392 | 396 | ||
393 | 397 | ||
394 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) | 398 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) |
395 | { | 399 | { |
396 | mListView->setSelected(item, selected); | 400 | mListView->setSelected(item, selected); |
397 | 401 | ||
398 | if (selected) | 402 | if (selected) |
399 | mListView->ensureItemVisible(item); | 403 | mListView->ensureItemVisible(item); |
400 | } | 404 | } |
401 | } | 405 | } |
402 | } | 406 | } |
403 | } | 407 | } |
404 | 408 | ||
405 | void KAddressBookTableView::addresseeSelected() | 409 | void KAddressBookTableView::addresseeSelected() |
406 | { | 410 | { |
407 | // We need to try to find the first selected item. This might not be the | 411 | // We need to try to find the first selected item. This might not be the |
408 | // last selected item, but when QListView is in multiselection mode, | 412 | // last selected item, but when QListView is in multiselection mode, |
409 | // there is no way to figure out which one was | 413 | // there is no way to figure out which one was |
410 | // selected last. | 414 | // selected last. |
411 | QListViewItem *item; | 415 | QListViewItem *item; |
412 | bool found =false; | 416 | bool found =false; |
413 | for (item = mListView->firstChild(); item && !found; | 417 | for (item = mListView->firstChild(); item && !found; |
414 | item = item->nextSibling()) | 418 | item = item->nextSibling()) |
415 | { | 419 | { |
416 | if (item->isSelected()) | 420 | if (item->isSelected()) |
417 | { | 421 | { |
418 | found = true; | 422 | found = true; |
419 | #ifndef KAB_EMBEDDED | 423 | #ifndef KAB_EMBEDDED |
420 | ContactListViewItem *ceItem | 424 | ContactListViewItem *ceItem |
421 | = dynamic_cast<ContactListViewItem*>(item); | 425 | = dynamic_cast<ContactListViewItem*>(item); |
422 | #else //KAB_EMBEDDED | 426 | #else //KAB_EMBEDDED |
423 | ContactListViewItem *ceItem | 427 | ContactListViewItem *ceItem |
424 | = (ContactListViewItem*)(item); | 428 | = (ContactListViewItem*)(item); |
425 | #endif //KAB_EMBEDDED | 429 | #endif //KAB_EMBEDDED |
426 | 430 | ||
427 | if ( ceItem ) emit selected(ceItem->addressee().uid()); | 431 | if ( ceItem ) emit selected(ceItem->addressee().uid()); |
428 | } | 432 | } |
429 | } | 433 | } |
430 | 434 | ||
431 | if (!found) | 435 | if (!found) |
432 | emit selected(QString::null); | 436 | emit selected(QString::null); |
433 | } | 437 | } |
434 | 438 | ||
435 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 439 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) |
436 | { | 440 | { |
437 | if (item) | 441 | if (item) |
438 | { | 442 | { |
439 | #ifndef KAB_EMBEDDED | 443 | #ifndef KAB_EMBEDDED |
440 | ContactListViewItem *ceItem | 444 | ContactListViewItem *ceItem |
441 | = dynamic_cast<ContactListViewItem*>(item); | 445 | = dynamic_cast<ContactListViewItem*>(item); |
442 | #else //KAB_EMBEDDED | 446 | #else //KAB_EMBEDDED |
443 | ContactListViewItem *ceItem | 447 | ContactListViewItem *ceItem |
444 | = (ContactListViewItem*)(item); | 448 | = (ContactListViewItem*)(item); |
445 | #endif //KAB_EMBEDDED | 449 | #endif //KAB_EMBEDDED |
446 | 450 | ||
447 | if (ceItem) | 451 | if (ceItem) |
448 | { | 452 | { |
449 | emit executed(ceItem->addressee().uid()); | 453 | emit executed(ceItem->addressee().uid()); |
450 | } | 454 | } |
451 | } | 455 | } |
452 | else | 456 | else |
453 | { | 457 | { |
454 | emit executed(QString::null); | 458 | emit executed(QString::null); |
455 | } | 459 | } |
456 | } | 460 | } |
457 | 461 | ||
458 | void KAddressBookTableView::addresseeDeleted() | 462 | void KAddressBookTableView::addresseeDeleted() |
459 | { | 463 | { |
460 | 464 | ||
461 | emit deleteRequest(); | 465 | emit deleteRequest(); |
462 | 466 | ||
463 | } | 467 | } |
464 | 468 | ||
465 | 469 | ||
466 | 470 | ||
467 | 471 | ||
468 | 472 | ||
469 | #ifndef KAB_EMBEDDED | 473 | #ifndef KAB_EMBEDDED |
470 | #include "kaddressbooktableview.moc" | 474 | #include "kaddressbooktableview.moc" |
471 | #endif //KAB_EMBEDDED | 475 | #endif //KAB_EMBEDDED |