summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-04-07 07:42:53 (UTC)
committer zautrix <zautrix>2005-04-07 07:42:53 (UTC)
commitc82f9b40f6023dc7b39ac555cba8c4c313f15ca8 (patch) (unidiff)
treee9e4f0c0ed3243ec060a475983b271bd27b40d15 /kaddressbook
parent76e220bf1236ae6afa9d91f18f0cd9ced730cff0 (diff)
downloadkdepimpi-c82f9b40f6023dc7b39ac555cba8c4c313f15ca8.zip
kdepimpi-c82f9b40f6023dc7b39ac555cba8c4c313f15ca8.tar.gz
kdepimpi-c82f9b40f6023dc7b39ac555cba8c4c313f15ca8.tar.bz2
added fields to kapi
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index e322473..565cd1d 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -93,193 +93,193 @@ void KAddressBookTableView::reconstructListView()
93 93
94 mListView = new ContactListView( this, addressBook(), viewWidget() ); 94 mListView = new ContactListView( this, addressBook(), viewWidget() );
95 95
96 connect(this, SIGNAL(printView()), 96 connect(this, SIGNAL(printView()),
97 mListView , SLOT(printMe())); 97 mListView , SLOT(printMe()));
98 //US set singleClick manually, because it is no global configparameter in embedded space 98 //US set singleClick manually, because it is no global configparameter in embedded space
99 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); 99 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
100 100
101 // Add the columns 101 // Add the columns
102 KABC::Field::List fieldList = fields(); 102 KABC::Field::List fieldList = fields();
103 KABC::Field::List::ConstIterator it; 103 KABC::Field::List::ConstIterator it;
104 104
105 int c = 0; 105 int c = 0;
106 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 106 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
107 mListView->addColumn( (*it)->label() ); 107 mListView->addColumn( (*it)->label() );
108 mListView->setColumnWidthMode(c++, QListView::Manual); 108 mListView->setColumnWidthMode(c++, QListView::Manual);
109//US 109//US
110 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 110 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
111 } 111 }
112 112
113 connect(mListView, SIGNAL(selectionChanged()), 113 connect(mListView, SIGNAL(selectionChanged()),
114 this, SLOT(addresseeSelected())); 114 this, SLOT(addresseeSelected()));
115 connect(mListView, SIGNAL(startAddresseeDrag()), this, 115 connect(mListView, SIGNAL(startAddresseeDrag()), this,
116 SIGNAL(startDrag())); 116 SIGNAL(startDrag()));
117 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 117 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
118 SIGNAL(dropped(QDropEvent*))); 118 SIGNAL(dropped(QDropEvent*)));
119 119
120 if (KABPrefs::instance()->mHonorSingleClick) { 120 if (KABPrefs::instance()->mHonorSingleClick) {
121 // qDebug("KAddressBookTableView::reconstructListView single"); 121 // qDebug("KAddressBookTableView::reconstructListView single");
122 connect(mListView, SIGNAL(executed(QListViewItem*)), 122 connect(mListView, SIGNAL(executed(QListViewItem*)),
123 this, SLOT(addresseeExecuted(QListViewItem*))); 123 this, SLOT(addresseeExecuted(QListViewItem*)));
124 } else { 124 } else {
125 // qDebug("KAddressBookTableView::reconstructListView double"); 125 // qDebug("KAddressBookTableView::reconstructListView double");
126 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 126 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
127 this, SLOT(addresseeExecuted(QListViewItem*))); 127 this, SLOT(addresseeExecuted(QListViewItem*)));
128 } 128 }
129 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 129 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
130 this, SLOT(addresseeExecuted(QListViewItem*))); 130 this, SLOT(addresseeExecuted(QListViewItem*)));
131 connect(mListView, SIGNAL(signalDelete()), 131 connect(mListView, SIGNAL(signalDelete()),
132 this, SLOT(addresseeDeleted())); 132 this, SLOT(addresseeDeleted()));
133 133
134//US performceimprovement. Refresh is done from the outside 134//US performceimprovement. Refresh is done from the outside
135//US refresh(); 135//US refresh();
136 136
137 mListView->setSorting( 0, true ); 137 mListView->setSorting( 0, true );
138 mainLayout->addWidget( mListView ); 138 mainLayout->addWidget( mListView );
139 mainLayout->activate(); 139 mainLayout->activate();
140 mListView->show(); 140 mListView->show();
141} 141}
142 142
143void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 143void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
144{ 144{
145 mListView->clear(); 145 mListView->clear();
146 if ( s.isEmpty() || s == "*" ) { 146 if ( s.isEmpty() || s == "*" ) {
147 refresh(); 147 refresh();
148 return; 148 return;
149 } 149 }
150 QRegExp re = getRegExp( s ); 150 QRegExp re = getRegExp( s );
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 //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() );
181 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 181 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
182 break; 182 break;
183 } 183 }
184 } 184 }
185 } 185 }
186 } 186 }
187 // Sometimes the background pixmap gets messed up when we add lots 187 // Sometimes the background pixmap gets messed up when we add lots
188 // of items. 188 // of items.
189 mListView->repaint(); 189 //mListView->repaint();
190 if ( mListView->firstChild() ) { 190 if ( mListView->firstChild() ) {
191 mListView->setCurrentItem ( mListView->firstChild() ); 191 mListView->setCurrentItem ( mListView->firstChild() );
192 mListView->setSelected ( mListView->firstChild(), true ); 192 mListView->setSelected ( mListView->firstChild(), true );
193 } 193 }
194 else 194 else
195 emit selected(QString::null); 195 emit selected(QString::null);
196 196
197} 197}
198void KAddressBookTableView::writeConfig(KConfig *config) 198void KAddressBookTableView::writeConfig(KConfig *config)
199{ 199{
200 KAddressBookView::writeConfig(config); 200 KAddressBookView::writeConfig(config);
201 201
202 mListView->saveLayout(config, config->group()); 202 mListView->saveLayout(config, config->group());
203} 203}
204 204
205void KAddressBookTableView::readConfig(KConfig *config) 205void KAddressBookTableView::readConfig(KConfig *config)
206{ 206{
207 KAddressBookView::readConfig( config ); 207 KAddressBookView::readConfig( config );
208 // 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
209 // the listview. 209 // the listview.
210 reconstructListView(); 210 reconstructListView();
211 211
212 // costum colors? 212 // costum colors?
213 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 213 if ( config->readBoolEntry( "EnableCustomColors", false ) )
214 { 214 {
215 QPalette p( mListView->palette() ); 215 QPalette p( mListView->palette() );
216 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 216 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
217 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 217 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
218 c = p.color(QPalette::Normal, QColorGroup::Text ); 218 c = p.color(QPalette::Normal, QColorGroup::Text );
219 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 219 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
220 c = p.color(QPalette::Normal, QColorGroup::Button ); 220 c = p.color(QPalette::Normal, QColorGroup::Button );
221 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 221 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
222 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 222 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
223 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 223 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
224 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 224 c = p.color(QPalette::Normal, QColorGroup::Highlight );
225 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 225 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
226 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 226 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
227 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 227 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
228#ifndef KAB_EMBEDDED 228#ifndef KAB_EMBEDDED
229 c = KGlobalSettings::alternateBackgroundColor(); 229 c = KGlobalSettings::alternateBackgroundColor();
230#else //KAB_EMBEDDED 230#else //KAB_EMBEDDED
231 c = QColor(240, 240, 240); 231 c = QColor(240, 240, 240);
232#endif //KAB_EMBEDDED 232#endif //KAB_EMBEDDED
233 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 233 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
234 mListView->setAlternateColor(c); 234 mListView->setAlternateColor(c);
235 235
236 236
237 //US mListView->viewport()->setPalette( p ); 237 //US mListView->viewport()->setPalette( p );
238 mListView->setPalette( p ); 238 mListView->setPalette( p );
239 } 239 }
240 else 240 else
241 { 241 {
242 // needed if turned off during a session. 242 // needed if turned off during a session.
243 //US mListView->viewport()->setPalette( mListView->palette() ); 243 //US mListView->viewport()->setPalette( mListView->palette() );
244 mListView->setPalette( mListView->palette() ); 244 mListView->setPalette( mListView->palette() );
245 } 245 }
246 246
247 //custom fonts? 247 //custom fonts?
248 QFont f( font() ); 248 QFont f( font() );
249 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 249 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
250 { 250 {
251 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 251 mListView->setFont( config->readFontEntry( "TextFont", &f) );
252 f.setBold( true ); 252 f.setBold( true );
253 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 253 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
254 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 254 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
255 } 255 }
256 else 256 else
257 { 257 {
258 mListView->setFont( f ); 258 mListView->setFont( f );
259 f.setBold( true ); 259 f.setBold( true );
260 //US mListView->setHeaderFont( f ); 260 //US mListView->setHeaderFont( f );
261 mListView->header()->setFont( f ); 261 mListView->header()->setFont( f );
262 } 262 }
263 263
264 // Set the list view options 264 // Set the list view options
265 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 265 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
266 true)); 266 true));
267 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 267 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
268 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 268 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
269 269
270 if (config->readBoolEntry("Background", false)) 270 if (config->readBoolEntry("Background", false))
271 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 271 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
272 272
273 // Restore the layout of the listview 273 // Restore the layout of the listview
274 mListView->restoreLayout(config, config->group()); 274 mListView->restoreLayout(config, config->group());
275} 275}
276 276
277void KAddressBookTableView::refresh(QString uid) 277void KAddressBookTableView::refresh(QString uid)
278{ 278{
279 // For now just repopulate. In reality this method should 279 // For now just repopulate. In reality this method should
280 // check the value of uid, and if valid iterate through 280 // check the value of uid, and if valid iterate through
281 // the listview to find the entry, then tell it to refresh. 281 // the listview to find the entry, then tell it to refresh.
282 282
283 if (uid.isNull()) { 283 if (uid.isNull()) {
284 // Clear the list view 284 // Clear the list view
285 QString currentUID, nextUID; 285 QString currentUID, nextUID;