author | ulf69 <ulf69> | 2004-10-28 00:13:27 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-28 00:13:27 (UTC) |
commit | 0b7fefe9f97ced1e4b2d93d26e12385aadb7b7e9 (patch) (unidiff) | |
tree | e46a98f6d1ac10b2a8378ef9d1dd77fb0d82fed1 | |
parent | 0766b449ccdcc125c18c401d87cc51c277464728 (diff) | |
download | kdepimpi-0b7fefe9f97ced1e4b2d93d26e12385aadb7b7e9.zip kdepimpi-0b7fefe9f97ced1e4b2d93d26e12385aadb7b7e9.tar.gz kdepimpi-0b7fefe9f97ced1e4b2d93d26e12385aadb7b7e9.tar.bz2 |
bugfix: pass singleclick parameter to the tableview
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index e40eb9e..6f20e05 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -1,372 +1,378 @@ | |||
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 | |||
92 | //US set singleClick manually, because it is no global configparameter in embedded space | ||
93 | mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); | ||
91 | 94 | ||
92 | // Add the columns | 95 | // Add the columns |
93 | KABC::Field::List fieldList = fields(); | 96 | KABC::Field::List fieldList = fields(); |
94 | KABC::Field::List::ConstIterator it; | 97 | KABC::Field::List::ConstIterator it; |
95 | 98 | ||
96 | int c = 0; | 99 | int c = 0; |
97 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 100 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
98 | mListView->addColumn( (*it)->label() ); | 101 | mListView->addColumn( (*it)->label() ); |
99 | mListView->setColumnWidthMode(c++, QListView::Manual); | 102 | mListView->setColumnWidthMode(c++, QListView::Manual); |
100 | //US | 103 | //US |
101 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 104 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
102 | } | 105 | } |
103 | 106 | ||
104 | connect(mListView, SIGNAL(selectionChanged()), | 107 | connect(mListView, SIGNAL(selectionChanged()), |
105 | this, SLOT(addresseeSelected())); | 108 | this, SLOT(addresseeSelected())); |
106 | connect(mListView, SIGNAL(startAddresseeDrag()), this, | 109 | connect(mListView, SIGNAL(startAddresseeDrag()), this, |
107 | SIGNAL(startDrag())); | 110 | SIGNAL(startDrag())); |
108 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 111 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
109 | SIGNAL(dropped(QDropEvent*))); | 112 | SIGNAL(dropped(QDropEvent*))); |
110 | 113 | ||
111 | if (KABPrefs::instance()->mHonorSingleClick) | 114 | if (KABPrefs::instance()->mHonorSingleClick) { |
115 | // qDebug("KAddressBookTableView::reconstructListView single"); | ||
112 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 116 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
113 | this, SLOT(addresseeExecuted(QListViewItem*))); | 117 | this, SLOT(addresseeExecuted(QListViewItem*))); |
114 | else | 118 | } else { |
119 | // qDebug("KAddressBookTableView::reconstructListView double"); | ||
115 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 120 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
116 | this, SLOT(addresseeExecuted(QListViewItem*))); | 121 | this, SLOT(addresseeExecuted(QListViewItem*))); |
122 | } | ||
117 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 123 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
118 | this, SLOT(addresseeExecuted(QListViewItem*))); | 124 | this, SLOT(addresseeExecuted(QListViewItem*))); |
119 | connect(mListView, SIGNAL(signalDelete()), | 125 | connect(mListView, SIGNAL(signalDelete()), |
120 | this, SLOT(addresseeDeleted())); | 126 | this, SLOT(addresseeDeleted())); |
121 | 127 | ||
122 | //US performceimprovement. Refresh is done from the outside | 128 | //US performceimprovement. Refresh is done from the outside |
123 | //US refresh(); | 129 | //US refresh(); |
124 | 130 | ||
125 | mListView->setSorting( 0, true ); | 131 | mListView->setSorting( 0, true ); |
126 | mainLayout->addWidget( mListView ); | 132 | mainLayout->addWidget( mListView ); |
127 | mainLayout->activate(); | 133 | mainLayout->activate(); |
128 | mListView->show(); | 134 | mListView->show(); |
129 | } | 135 | } |
130 | 136 | ||
131 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 137 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) |
132 | { | 138 | { |
133 | mListView->clear(); | 139 | mListView->clear(); |
134 | if ( s.isEmpty() || s == "*" ) { | 140 | if ( s.isEmpty() || s == "*" ) { |
135 | refresh(); | 141 | refresh(); |
136 | return; | 142 | return; |
137 | } | 143 | } |
138 | QString pattern = s.lower()+"*"; | 144 | QString pattern = s.lower()+"*"; |
139 | QRegExp re; | 145 | QRegExp re; |
140 | re.setWildcard(true); // most people understand these better. | 146 | re.setWildcard(true); // most people understand these better. |
141 | re.setCaseSensitive(false); | 147 | re.setCaseSensitive(false); |
142 | re.setPattern( pattern ); | 148 | re.setPattern( pattern ); |
143 | if (!re.isValid()) | 149 | if (!re.isValid()) |
144 | return; | 150 | return; |
145 | KABC::Addressee::List addresseeList = addressees(); | 151 | KABC::Addressee::List addresseeList = addressees(); |
146 | KABC::Addressee::List::Iterator it; | 152 | KABC::Addressee::List::Iterator it; |
147 | if ( field ) { | 153 | if ( field ) { |
148 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 154 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
149 | #if QT_VERSION >= 300 | 155 | #if QT_VERSION >= 300 |
150 | if (re.search(field->value( *it ).lower()) != -1) | 156 | if (re.search(field->value( *it ).lower()) != -1) |
151 | #else | 157 | #else |
152 | if (re.match(field->value( *it ).lower()) != -1) | 158 | if (re.match(field->value( *it ).lower()) != -1) |
153 | #endif | 159 | #endif |
154 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 160 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
155 | 161 | ||
156 | } | 162 | } |
157 | } else { | 163 | } else { |
158 | KABC::Field::List fieldList = fields(); | 164 | KABC::Field::List fieldList = fields(); |
159 | KABC::Field::List::ConstIterator fieldIt; | 165 | KABC::Field::List::ConstIterator fieldIt; |
160 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 166 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
161 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 167 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
162 | #if QT_VERSION >= 300 | 168 | #if QT_VERSION >= 300 |
163 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 169 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
164 | #else | 170 | #else |
165 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 171 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
166 | #endif | 172 | #endif |
167 | { | 173 | { |
168 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 174 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
169 | break; | 175 | break; |
170 | } | 176 | } |
171 | } | 177 | } |
172 | } | 178 | } |
173 | } | 179 | } |
174 | // Sometimes the background pixmap gets messed up when we add lots | 180 | // Sometimes the background pixmap gets messed up when we add lots |
175 | // of items. | 181 | // of items. |
176 | mListView->repaint(); | 182 | mListView->repaint(); |
177 | if ( mListView->firstChild() ) { | 183 | if ( mListView->firstChild() ) { |
178 | mListView->setCurrentItem ( mListView->firstChild() ); | 184 | mListView->setCurrentItem ( mListView->firstChild() ); |
179 | mListView->setSelected ( mListView->firstChild(), true ); | 185 | mListView->setSelected ( mListView->firstChild(), true ); |
180 | } | 186 | } |
181 | else | 187 | else |
182 | emit selected(QString::null); | 188 | emit selected(QString::null); |
183 | 189 | ||
184 | } | 190 | } |
185 | void KAddressBookTableView::writeConfig(KConfig *config) | 191 | void KAddressBookTableView::writeConfig(KConfig *config) |
186 | { | 192 | { |
187 | KAddressBookView::writeConfig(config); | 193 | KAddressBookView::writeConfig(config); |
188 | 194 | ||
189 | mListView->saveLayout(config, config->group()); | 195 | mListView->saveLayout(config, config->group()); |
190 | } | 196 | } |
191 | 197 | ||
192 | void KAddressBookTableView::readConfig(KConfig *config) | 198 | void KAddressBookTableView::readConfig(KConfig *config) |
193 | { | 199 | { |
194 | KAddressBookView::readConfig( config ); | 200 | KAddressBookView::readConfig( config ); |
195 | // The config could have changed the fields, so we need to reconstruct | 201 | // The config could have changed the fields, so we need to reconstruct |
196 | // the listview. | 202 | // the listview. |
197 | reconstructListView(); | 203 | reconstructListView(); |
198 | 204 | ||
199 | // costum colors? | 205 | // costum colors? |
200 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 206 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
201 | { | 207 | { |
202 | QPalette p( mListView->palette() ); | 208 | QPalette p( mListView->palette() ); |
203 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 209 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
204 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 210 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
205 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 211 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
206 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 212 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
207 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 213 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
208 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 214 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
209 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 215 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
210 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 216 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
211 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 217 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
212 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 218 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
213 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 219 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
214 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 220 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
215 | #ifndef KAB_EMBEDDED | 221 | #ifndef KAB_EMBEDDED |
216 | c = KGlobalSettings::alternateBackgroundColor(); | 222 | c = KGlobalSettings::alternateBackgroundColor(); |
217 | #else //KAB_EMBEDDED | 223 | #else //KAB_EMBEDDED |
218 | c = QColor(240, 240, 240); | 224 | c = QColor(240, 240, 240); |
219 | #endif //KAB_EMBEDDED | 225 | #endif //KAB_EMBEDDED |
220 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 226 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
221 | mListView->setAlternateColor(c); | 227 | mListView->setAlternateColor(c); |
222 | 228 | ||
223 | 229 | ||
224 | //US mListView->viewport()->setPalette( p ); | 230 | //US mListView->viewport()->setPalette( p ); |
225 | mListView->setPalette( p ); | 231 | mListView->setPalette( p ); |
226 | } | 232 | } |
227 | else | 233 | else |
228 | { | 234 | { |
229 | // needed if turned off during a session. | 235 | // needed if turned off during a session. |
230 | //US mListView->viewport()->setPalette( mListView->palette() ); | 236 | //US mListView->viewport()->setPalette( mListView->palette() ); |
231 | mListView->setPalette( mListView->palette() ); | 237 | mListView->setPalette( mListView->palette() ); |
232 | } | 238 | } |
233 | 239 | ||
234 | //custom fonts? | 240 | //custom fonts? |
235 | QFont f( font() ); | 241 | QFont f( font() ); |
236 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 242 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
237 | { | 243 | { |
238 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 244 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
239 | f.setBold( true ); | 245 | f.setBold( true ); |
240 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 246 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
241 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 247 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
242 | } | 248 | } |
243 | else | 249 | else |
244 | { | 250 | { |
245 | mListView->setFont( f ); | 251 | mListView->setFont( f ); |
246 | f.setBold( true ); | 252 | f.setBold( true ); |
247 | //US mListView->setHeaderFont( f ); | 253 | //US mListView->setHeaderFont( f ); |
248 | mListView->header()->setFont( f ); | 254 | mListView->header()->setFont( f ); |
249 | } | 255 | } |
250 | 256 | ||
251 | 257 | ||
252 | 258 | ||
253 | 259 | ||
254 | 260 | ||
255 | // Set the list view options | 261 | // Set the list view options |
256 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 262 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
257 | true)); | 263 | true)); |
258 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 264 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
259 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 265 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
260 | 266 | ||
261 | if (config->readBoolEntry("Background", false)) | 267 | if (config->readBoolEntry("Background", false)) |
262 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 268 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
263 | 269 | ||
264 | // Restore the layout of the listview | 270 | // Restore the layout of the listview |
265 | mListView->restoreLayout(config, config->group()); | 271 | mListView->restoreLayout(config, config->group()); |
266 | } | 272 | } |
267 | 273 | ||
268 | void KAddressBookTableView::refresh(QString uid) | 274 | void KAddressBookTableView::refresh(QString uid) |
269 | { | 275 | { |
270 | // For now just repopulate. In reality this method should | 276 | // For now just repopulate. In reality this method should |
271 | // check the value of uid, and if valid iterate through | 277 | // check the value of uid, and if valid iterate through |
272 | // the listview to find the entry, then tell it to refresh. | 278 | // the listview to find the entry, then tell it to refresh. |
273 | 279 | ||
274 | if (uid.isNull()) { | 280 | if (uid.isNull()) { |
275 | // Clear the list view | 281 | // Clear the list view |
276 | QString currentUID, nextUID; | 282 | QString currentUID, nextUID; |
277 | #ifndef KAB_EMBEDDED | 283 | #ifndef KAB_EMBEDDED |
278 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 284 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
279 | #else //KAB_EMBEDDED | 285 | #else //KAB_EMBEDDED |
280 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 286 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
281 | #endif //KAB_EMBEDDED | 287 | #endif //KAB_EMBEDDED |
282 | 288 | ||
283 | if ( currentItem ) { | 289 | if ( currentItem ) { |
284 | #ifndef KAB_EMBEDDED | 290 | #ifndef KAB_EMBEDDED |
285 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 291 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
286 | #else //KAB_EMBEDDED | 292 | #else //KAB_EMBEDDED |
287 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 293 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
288 | #endif //KAB_EMBEDDED | 294 | #endif //KAB_EMBEDDED |
289 | if ( nextItem ) | 295 | if ( nextItem ) |
290 | nextUID = nextItem->addressee().uid(); | 296 | nextUID = nextItem->addressee().uid(); |
291 | currentUID = currentItem->addressee().uid(); | 297 | currentUID = currentItem->addressee().uid(); |
292 | } | 298 | } |
293 | 299 | ||
294 | mListView->clear(); | 300 | mListView->clear(); |
295 | 301 | ||
296 | currentItem = 0; | 302 | currentItem = 0; |
297 | KABC::Addressee::List addresseeList = addressees(); | 303 | KABC::Addressee::List addresseeList = addressees(); |
298 | KABC::Addressee::List::Iterator it; | 304 | KABC::Addressee::List::Iterator it; |
299 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 305 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
300 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 306 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
301 | continue; | 307 | continue; |
302 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 308 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
303 | if ( (*it).uid() == currentUID ) | 309 | if ( (*it).uid() == currentUID ) |
304 | currentItem = item; | 310 | currentItem = item; |
305 | else if ( (*it).uid() == nextUID && !currentItem ) | 311 | else if ( (*it).uid() == nextUID && !currentItem ) |
306 | currentItem = item; | 312 | currentItem = item; |
307 | } | 313 | } |
308 | 314 | ||
309 | // Sometimes the background pixmap gets messed up when we add lots | 315 | // Sometimes the background pixmap gets messed up when we add lots |
310 | // of items. | 316 | // of items. |
311 | mListView->repaint(); | 317 | mListView->repaint(); |
312 | 318 | ||
313 | if ( currentItem ) { | 319 | if ( currentItem ) { |
314 | mListView->setCurrentItem( currentItem ); | 320 | mListView->setCurrentItem( currentItem ); |
315 | mListView->ensureItemVisible( currentItem ); | 321 | mListView->ensureItemVisible( currentItem ); |
316 | } | 322 | } |
317 | } else { | 323 | } else { |
318 | // Only need to update on entry. Iterate through and try to find it | 324 | // Only need to update on entry. Iterate through and try to find it |
319 | ContactListViewItem *ceItem; | 325 | ContactListViewItem *ceItem; |
320 | QListViewItemIterator it( mListView ); | 326 | QListViewItemIterator it( mListView ); |
321 | while ( it.current() ) { | 327 | while ( it.current() ) { |
322 | #ifndef KAB_EMBEDDED | 328 | #ifndef KAB_EMBEDDED |
323 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 329 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
324 | #else //KAB_EMBEDDED | 330 | #else //KAB_EMBEDDED |
325 | ceItem = (ContactListViewItem*)( it.current() ); | 331 | ceItem = (ContactListViewItem*)( it.current() ); |
326 | #endif //KAB_EMBEDDED | 332 | #endif //KAB_EMBEDDED |
327 | 333 | ||
328 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 334 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
329 | ceItem->refresh(); | 335 | ceItem->refresh(); |
330 | return; | 336 | return; |
331 | } | 337 | } |
332 | ++it; | 338 | ++it; |
333 | } | 339 | } |
334 | 340 | ||
335 | refresh( QString::null ); | 341 | refresh( QString::null ); |
336 | } | 342 | } |
337 | } | 343 | } |
338 | 344 | ||
339 | QStringList KAddressBookTableView::selectedUids() | 345 | QStringList KAddressBookTableView::selectedUids() |
340 | { | 346 | { |
341 | QStringList uidList; | 347 | QStringList uidList; |
342 | QListViewItem *item; | 348 | QListViewItem *item; |
343 | ContactListViewItem *ceItem; | 349 | ContactListViewItem *ceItem; |
344 | 350 | ||
345 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 351 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
346 | { | 352 | { |
347 | if (mListView->isSelected( item )) | 353 | if (mListView->isSelected( item )) |
348 | { | 354 | { |
349 | #ifndef KAB_EMBEDDED | 355 | #ifndef KAB_EMBEDDED |
350 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 356 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
351 | #else //KAB_EMBEDDED | 357 | #else //KAB_EMBEDDED |
352 | ceItem = (ContactListViewItem*)(item); | 358 | ceItem = (ContactListViewItem*)(item); |
353 | #endif //KAB_EMBEDDED | 359 | #endif //KAB_EMBEDDED |
354 | 360 | ||
355 | if (ceItem != 0L) | 361 | if (ceItem != 0L) |
356 | uidList << ceItem->addressee().uid(); | 362 | uidList << ceItem->addressee().uid(); |
357 | } | 363 | } |
358 | } | 364 | } |
359 | if ( uidList.count() == 0 ) | 365 | if ( uidList.count() == 0 ) |
360 | if ( mListView->currentItem() ) { | 366 | if ( mListView->currentItem() ) { |
361 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; | 367 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; |
362 | uidList << ceItem->addressee().uid(); | 368 | uidList << ceItem->addressee().uid(); |
363 | } | 369 | } |
364 | 370 | ||
365 | return uidList; | 371 | return uidList; |
366 | } | 372 | } |
367 | 373 | ||
368 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 374 | void KAddressBookTableView::setSelected(QString uid, bool selected) |
369 | { | 375 | { |
370 | QListViewItem *item; | 376 | QListViewItem *item; |
371 | ContactListViewItem *ceItem; | 377 | ContactListViewItem *ceItem; |
372 | 378 | ||