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