summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
Unidiff
Diffstat (limited to 'kaddressbook/views') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp5
-rw-r--r--kaddressbook/views/kaddressbookcardview.h1
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp6
-rw-r--r--kaddressbook/views/kaddressbookiconview.h1
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp6
-rw-r--r--kaddressbook/views/kaddressbooktableview.h1
6 files changed, 20 insertions, 0 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index a7bf6c9..7f33bb4 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -44,257 +44,262 @@
44extern "C" { 44extern "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)
54class AddresseeCardViewItem : public CardViewItem 54class 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
110AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) 110AddresseeCardView::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
116AddresseeCardView::~AddresseeCardView() 116AddresseeCardView::~AddresseeCardView()
117{ 117{
118} 118}
119 119
120 120
121void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) 121void 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
127qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); 127qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented");
128#endif //KAB_EMBEDDED 128#endif //KAB_EMBEDDED
129} 129}
130 130
131void AddresseeCardView::dropEvent(QDropEvent *e) 131void AddresseeCardView::dropEvent(QDropEvent *e)
132{ 132{
133 emit addresseeDropped(e); 133 emit addresseeDropped(e);
134} 134}
135 135
136void AddresseeCardView::startDrag() 136void AddresseeCardView::startDrag()
137{ 137{
138 emit startAddresseeDrag(); 138 emit startAddresseeDrag();
139} 139}
140 140
141 141
142/////////////////////////////// 142///////////////////////////////
143// KAddressBookCardView 143// KAddressBookCardView
144 144
145KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, 145KAddressBookCardView::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
169KAddressBookCardView::~KAddressBookCardView() 169KAddressBookCardView::~KAddressBookCardView()
170{ 170{
171} 171}
172void KAddressBookCardView::setFocusAV()
173{
174 if ( mCardView )
175 mCardView->setFocus();
172 176
177}
173void KAddressBookCardView::scrollUP() 178void KAddressBookCardView::scrollUP()
174{ 179{
175 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 180 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
176 QApplication::postEvent( mCardView, ev ); 181 QApplication::postEvent( mCardView, ev );
177 182
178} 183}
179void KAddressBookCardView::scrollDOWN() 184void KAddressBookCardView::scrollDOWN()
180{ 185{
181 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 186 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
182 QApplication::postEvent( mCardView, ev ); 187 QApplication::postEvent( mCardView, ev );
183} 188}
184void KAddressBookCardView::readConfig(KConfig *config) 189void KAddressBookCardView::readConfig(KConfig *config)
185{ 190{
186 KAddressBookView::readConfig(config); 191 KAddressBookView::readConfig(config);
187 192
188 // costum colors? 193 // costum colors?
189 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 194 if ( config->readBoolEntry( "EnableCustomColors", false ) )
190 { 195 {
191 QPalette p( mCardView->palette() ); 196 QPalette p( mCardView->palette() );
192 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 197 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
193 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 198 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
194 c = p.color(QPalette::Normal, QColorGroup::Text ); 199 c = p.color(QPalette::Normal, QColorGroup::Text );
195 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 200 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
196 c = p.color(QPalette::Normal, QColorGroup::Button ); 201 c = p.color(QPalette::Normal, QColorGroup::Button );
197 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 202 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
198 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 203 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
199 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 204 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
200 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 205 c = p.color(QPalette::Normal, QColorGroup::Highlight );
201 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 206 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
202 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 207 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
203 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 208 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
204 mCardView->viewport()->setPalette( p ); 209 mCardView->viewport()->setPalette( p );
205 } 210 }
206 else 211 else
207 { 212 {
208 // needed if turned off during a session. 213 // needed if turned off during a session.
209 mCardView->viewport()->setPalette( mCardView->palette() ); 214 mCardView->viewport()->setPalette( mCardView->palette() );
210 } 215 }
211 216
212 //custom fonts? 217 //custom fonts?
213 QFont f( font() ); 218 QFont f( font() );
214 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 219 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
215 { 220 {
216 mCardView->setFont( config->readFontEntry( "TextFont", &f) ); 221 mCardView->setFont( config->readFontEntry( "TextFont", &f) );
217 f.setBold( true ); 222 f.setBold( true );
218 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 223 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
219 } 224 }
220 else 225 else
221 { 226 {
222 mCardView->setFont( f ); 227 mCardView->setFont( f );
223 f.setBold( true ); 228 f.setBold( true );
224 mCardView->setHeaderFont( f ); 229 mCardView->setHeaderFont( f );
225 } 230 }
226 231
227 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); 232 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true));
228 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", 233 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators",
229 true)); 234 true));
230 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); 235 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false));
231 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); 236 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false);
232 237
233 mCardView->setShowEmptyFields( mShowEmptyFields ); 238 mCardView->setShowEmptyFields( mShowEmptyFields );
234 239
235 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); 240 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) );
236 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); 241 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) );
237 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); 242 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) );
238 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); 243 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) );
239 244
240 disconnect(mCardView, SIGNAL(executed(CardViewItem *)), 245 disconnect(mCardView, SIGNAL(executed(CardViewItem *)),
241 this, SLOT(addresseeExecuted(CardViewItem *))); 246 this, SLOT(addresseeExecuted(CardViewItem *)));
242 247
243 if (KABPrefs::instance()->mHonorSingleClick) 248 if (KABPrefs::instance()->mHonorSingleClick)
244 connect(mCardView, SIGNAL(executed(CardViewItem *)), 249 connect(mCardView, SIGNAL(executed(CardViewItem *)),
245 this, SLOT(addresseeExecuted(CardViewItem *))); 250 this, SLOT(addresseeExecuted(CardViewItem *)));
246 else 251 else
247 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 252 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
248 this, SLOT(addresseeExecuted(CardViewItem *))); 253 this, SLOT(addresseeExecuted(CardViewItem *)));
249 254
250} 255}
251 256
252void KAddressBookCardView::writeConfig( KConfig *config ) 257void KAddressBookCardView::writeConfig( KConfig *config )
253{ 258{
254 config->writeEntry( "ItemWidth", mCardView->itemWidth() ); 259 config->writeEntry( "ItemWidth", mCardView->itemWidth() );
255 KAddressBookView::writeConfig( config ); 260 KAddressBookView::writeConfig( config );
256} 261}
257void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) 262void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
258{ 263{
259 mCardView->clear(); 264 mCardView->clear();
260 if ( s.isEmpty() || s == "*" ) { 265 if ( s.isEmpty() || s == "*" ) {
261 refresh(); 266 refresh();
262 return; 267 return;
263 } 268 }
264 QString pattern = s.lower()+"*"; 269 QString pattern = s.lower()+"*";
265 QRegExp re; 270 QRegExp re;
266 re.setWildcard(true); // most people understand these better. 271 re.setWildcard(true); // most people understand these better.
267 re.setCaseSensitive(false); 272 re.setCaseSensitive(false);
268 re.setPattern( pattern ); 273 re.setPattern( pattern );
269 if (!re.isValid()) 274 if (!re.isValid())
270 return; 275 return;
271 mCardView->viewport()->setUpdatesEnabled( false ); 276 mCardView->viewport()->setUpdatesEnabled( false );
272 KABC::Addressee::List addresseeList = addressees(); 277 KABC::Addressee::List addresseeList = addressees();
273 KABC::Addressee::List::Iterator it; 278 KABC::Addressee::List::Iterator it;
274 if ( field ) { 279 if ( field ) {
275 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 280 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
276#if QT_VERSION >= 300 281#if QT_VERSION >= 300
277 if (re.search(field->value( *it ).lower()) != -1) 282 if (re.search(field->value( *it ).lower()) != -1)
278#else 283#else
279 if (re.match(field->value( *it ).lower()) != -1) 284 if (re.match(field->value( *it ).lower()) != -1)
280#endif 285#endif
281 new AddresseeCardViewItem(fields(), mShowEmptyFields, 286 new AddresseeCardViewItem(fields(), mShowEmptyFields,
282 addressBook(), *it, mCardView); 287 addressBook(), *it, mCardView);
283 288
284 } 289 }
285 } else { 290 } else {
286 KABC::Field::List fieldList = fields(); 291 KABC::Field::List fieldList = fields();
287 KABC::Field::List::ConstIterator fieldIt; 292 KABC::Field::List::ConstIterator fieldIt;
288 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 293 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
289 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 294 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
290#if QT_VERSION >= 300 295#if QT_VERSION >= 300
291 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 296 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
292#else 297#else
293 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 298 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
294#endif 299#endif
295 { 300 {
296 new AddresseeCardViewItem(fields(), mShowEmptyFields, 301 new AddresseeCardViewItem(fields(), mShowEmptyFields,
297 addressBook(), *it, mCardView); 302 addressBook(), *it, mCardView);
298 continue; 303 continue;
299 } 304 }
300 } 305 }
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h
index 45a9781..8f22d54 100644
--- a/kaddressbook/views/kaddressbookcardview.h
+++ b/kaddressbook/views/kaddressbookcardview.h
@@ -1,119 +1,120 @@
1#ifndef KADDRESSBOOKCARDVIEW_H 1#ifndef KADDRESSBOOKCARDVIEW_H
2#define KADDRESSBOOKCARDVIEW_H 2#define KADDRESSBOOKCARDVIEW_H
3 3
4/* 4/*
5 This file is part of KAddressBook. 5 This file is part of KAddressBook.
6 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 6 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#include <qstring.h> 27#include <qstring.h>
28#ifndef KAB_EMBEDDED 28#ifndef KAB_EMBEDDED
29#include <kiconview.h> 29#include <kiconview.h>
30#else //KAB_EMBEDDED 30#else //KAB_EMBEDDED
31#include <klocale.h> 31#include <klocale.h>
32#endif //KAB_EMBEDDED 32#endif //KAB_EMBEDDED
33 33
34#include "cardview.h" 34#include "cardview.h"
35#include "kaddressbookview.h" 35#include "kaddressbookview.h"
36#include "configurecardviewdialog.h" 36#include "configurecardviewdialog.h"
37 37
38class QDragEnterEvent; 38class QDragEnterEvent;
39class QDragEntryEvent; 39class QDragEntryEvent;
40class QDropEvent; 40class QDropEvent;
41class KConfig; 41class KConfig;
42class AddresseeCardView; 42class AddresseeCardView;
43 43
44/** 44/**
45 This view uses the CardView class to create a card view. At some 45 This view uses the CardView class to create a card view. At some
46 point in the future I think this will be the default view of 46 point in the future I think this will be the default view of
47 KAddressBook. 47 KAddressBook.
48 */ 48 */
49class KAddressBookCardView : public KAddressBookView 49class KAddressBookCardView : public KAddressBookView
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 52
53 public: 53 public:
54 KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, 54 KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent,
55 const char *name = 0 ); 55 const char *name = 0 );
56 virtual ~KAddressBookCardView(); 56 virtual ~KAddressBookCardView();
57 void doSearch( const QString& s,KABC::Field *field ); 57 void doSearch( const QString& s,KABC::Field *field );
58 virtual QStringList selectedUids(); 58 virtual QStringList selectedUids();
59 virtual QString type() const { return "Card"; } 59 virtual QString type() const { return "Card"; }
60 60
61 virtual void readConfig(KConfig *config); 61 virtual void readConfig(KConfig *config);
62 virtual void writeConfig(KConfig *); 62 virtual void writeConfig(KConfig *);
63 virtual void scrollUP(); 63 virtual void scrollUP();
64 virtual void scrollDOWN(); 64 virtual void scrollDOWN();
65 virtual void setFocusAV();
65 66
66 public slots: 67 public slots:
67 void refresh(QString uid = QString::null); 68 void refresh(QString uid = QString::null);
68 void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); 69 void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/);
69//US added an additional method without parameter 70//US added an additional method without parameter
70 void setSelected(); 71 void setSelected();
71 72
72 protected slots: 73 protected slots:
73 void addresseeExecuted(CardViewItem *item); 74 void addresseeExecuted(CardViewItem *item);
74 void addresseeSelected(); 75 void addresseeSelected();
75 76
76 private: 77 private:
77 AddresseeCardView *mCardView; 78 AddresseeCardView *mCardView;
78 bool mShowEmptyFields; 79 bool mShowEmptyFields;
79}; 80};
80 81
81class AddresseeCardView : public CardView 82class AddresseeCardView : public CardView
82{ 83{
83 Q_OBJECT 84 Q_OBJECT
84 public: 85 public:
85 AddresseeCardView(QWidget *parent, const char *name = 0); 86 AddresseeCardView(QWidget *parent, const char *name = 0);
86 ~AddresseeCardView(); 87 ~AddresseeCardView();
87 88
88 signals: 89 signals:
89 void startAddresseeDrag(); 90 void startAddresseeDrag();
90 void addresseeDropped(QDropEvent *); 91 void addresseeDropped(QDropEvent *);
91 92
92 protected: 93 protected:
93 virtual void dragEnterEvent(QDragEnterEvent *); 94 virtual void dragEnterEvent(QDragEnterEvent *);
94 virtual void dropEvent(QDropEvent *); 95 virtual void dropEvent(QDropEvent *);
95 virtual void startDrag(); 96 virtual void startDrag();
96}; 97};
97 98
98 99
99class CardViewFactory : public ViewFactory 100class CardViewFactory : public ViewFactory
100{ 101{
101 public: 102 public:
102 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 103 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
103 { 104 {
104 return new KAddressBookCardView( ab, parent, name ); 105 return new KAddressBookCardView( ab, parent, name );
105 } 106 }
106 107
107 QString type() const { return "Card"; } 108 QString type() const { return "Card"; }
108 109
109 QString description() const { return i18n( "Rolodex style cards represent contacts." ); } 110 QString description() const { return i18n( "Rolodex style cards represent contacts." ); }
110 111
111 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, 112 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent,
112 const char *name = 0 ) 113 const char *name = 0 )
113 { 114 {
114 return new ConfigureCardViewWidget( ab, parent, name ); 115 return new ConfigureCardViewWidget( ab, parent, name );
115 } 116 }
116}; 117};
117 118
118 119
119#endif 120#endif
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index f4c68b8..41c3cb2 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -86,256 +86,262 @@ AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
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
97AddresseeIconView::~AddresseeIconView() 97AddresseeIconView::~AddresseeIconView()
98{ 98{
99} 99}
100 100
101 101
102void AddresseeIconView::itemDropped(QDropEvent *e, 102void 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
108QDragObject *AddresseeIconView::dragObject() 108QDragObject *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
118class AddresseeIconViewItem : public KIconViewItem 118class AddresseeIconViewItem : public KIconViewItem
119#else //KAB_EMBEDDED 119#else //KAB_EMBEDDED
120class AddresseeIconViewItem : public QIconViewItem 120class 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
185KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, 185KAddressBookIconView::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
211KAddressBookIconView::~KAddressBookIconView() 211KAddressBookIconView::~KAddressBookIconView()
212{ 212{
213} 213}
214void KAddressBookIconView::setFocusAV()
215{
216 if ( mIconView )
217 mIconView->setFocus();
218}
219
214 220
215void KAddressBookIconView::scrollUP() 221void KAddressBookIconView::scrollUP()
216{ 222{
217 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 223 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
218 QApplication::postEvent( mIconView, ev ); 224 QApplication::postEvent( mIconView, ev );
219} 225}
220void KAddressBookIconView::scrollDOWN() 226void KAddressBookIconView::scrollDOWN()
221{ 227{
222 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 228 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
223 QApplication::postEvent( mIconView, ev ); 229 QApplication::postEvent( mIconView, ev );
224} 230}
225void KAddressBookIconView::readConfig(KConfig *config) 231void KAddressBookIconView::readConfig(KConfig *config)
226{ 232{
227 KAddressBookView::readConfig(config); 233 KAddressBookView::readConfig(config);
228 234
229//US method executed is part of KIconView 235//US method executed is part of KIconView
230//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), 236//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)),
231//US this, SLOT(addresseeExecuted(QIconViewItem *))); 237//US this, SLOT(addresseeExecuted(QIconViewItem *)));
232 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 238 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
233 this, SLOT(addresseeExecuted(QIconViewItem *))); 239 this, SLOT(addresseeExecuted(QIconViewItem *)));
234 240
235//US method executed is part of KIconView. Use selectionChanged instead 241//US method executed is part of KIconView. Use selectionChanged instead
236/*US 242/*US
237 if (KABPrefs::instance()->mHonorSingleClick) 243 if (KABPrefs::instance()->mHonorSingleClick)
238 connect(mIconView, SIGNAL(executed(QIconViewItem *)), 244 connect(mIconView, SIGNAL(executed(QIconViewItem *)),
239 this, SLOT(addresseeExecuted(QIconViewItem *))); 245 this, SLOT(addresseeExecuted(QIconViewItem *)));
240 else 246 else
241 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), 247 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)),
242 this, SLOT(addresseeExecuted(QIconViewItem *))); 248 this, SLOT(addresseeExecuted(QIconViewItem *)));
243*/ 249*/
244 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 250 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
245 this, SLOT(addresseeExecuted(QIconViewItem *))); 251 this, SLOT(addresseeExecuted(QIconViewItem *)));
246 252
247} 253}
248void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) 254void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
249{ 255{
250 mIconView->clear(); 256 mIconView->clear();
251 mIconList.clear(); 257 mIconList.clear();
252 if ( s.isEmpty() || s == "*" ) { 258 if ( s.isEmpty() || s == "*" ) {
253 refresh(); 259 refresh();
254 return; 260 return;
255 } 261 }
256 QString pattern = s.lower()+"*"; 262 QString pattern = s.lower()+"*";
257 QRegExp re; 263 QRegExp re;
258 re.setWildcard(true); // most people understand these better. 264 re.setWildcard(true); // most people understand these better.
259 re.setCaseSensitive(false); 265 re.setCaseSensitive(false);
260 re.setPattern( pattern ); 266 re.setPattern( pattern );
261 if (!re.isValid()) 267 if (!re.isValid())
262 return; 268 return;
263 KABC::Addressee::List addresseeList = addressees(); 269 KABC::Addressee::List addresseeList = addressees();
264 KABC::Addressee::List::Iterator it; 270 KABC::Addressee::List::Iterator it;
265 if ( field ) { 271 if ( field ) {
266 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 272 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
267#if QT_VERSION >= 300 273#if QT_VERSION >= 300
268 if (re.search(field->value( *it ).lower()) != -1) 274 if (re.search(field->value( *it ).lower()) != -1)
269#else 275#else
270 if (re.match(field->value( *it ).lower()) != -1) 276 if (re.match(field->value( *it ).lower()) != -1)
271#endif 277#endif
272 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 278 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
273 279
274 280
275 } 281 }
276 } else { 282 } else {
277 KABC::Field::List fieldList = fields(); 283 KABC::Field::List fieldList = fields();
278 KABC::Field::List::ConstIterator fieldIt; 284 KABC::Field::List::ConstIterator fieldIt;
279 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 285 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
280 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 286 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
281#if QT_VERSION >= 300 287#if QT_VERSION >= 300
282 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 288 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
283#else 289#else
284 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 290 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
285#endif 291#endif
286 { 292 {
287 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 293 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
288 continue; 294 continue;
289 } 295 }
290 } 296 }
291 } 297 }
292 } 298 }
293 mIconView->arrangeItemsInGrid( true ); 299 mIconView->arrangeItemsInGrid( true );
294 if ( mIconView->firstItem() ) { 300 if ( mIconView->firstItem() ) {
295 mIconView->setCurrentItem ( mIconView->firstItem() ); 301 mIconView->setCurrentItem ( mIconView->firstItem() );
296 mIconView->setSelected ( mIconView->firstItem() , true ); 302 mIconView->setSelected ( mIconView->firstItem() , true );
297 } 303 }
298 else 304 else
299 emit selected(QString::null); 305 emit selected(QString::null);
300} 306}
301QStringList KAddressBookIconView::selectedUids() 307QStringList KAddressBookIconView::selectedUids()
302{ 308{
303 QStringList uidList; 309 QStringList uidList;
304 QIconViewItem *item; 310 QIconViewItem *item;
305 AddresseeIconViewItem *aItem; 311 AddresseeIconViewItem *aItem;
306 312
307 for (item = mIconView->firstItem(); item; item = item->nextItem()) 313 for (item = mIconView->firstItem(); item; item = item->nextItem())
308 { 314 {
309 if (item->isSelected()) 315 if (item->isSelected())
310 { 316 {
311#ifndef KAB_EMBEDDED 317#ifndef KAB_EMBEDDED
312 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 318 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
313#else //KAB_EMBEDDED 319#else //KAB_EMBEDDED
314 aItem = (AddresseeIconViewItem*)(item); 320 aItem = (AddresseeIconViewItem*)(item);
315#endif //KAB_EMBEDDED 321#endif //KAB_EMBEDDED
316 if (aItem) 322 if (aItem)
317 uidList << aItem->addressee().uid(); 323 uidList << aItem->addressee().uid();
318 } 324 }
319 } 325 }
320 326
321 return uidList; 327 return uidList;
322} 328}
323 329
324void KAddressBookIconView::refresh(QString uid) 330void KAddressBookIconView::refresh(QString uid)
325{ 331{
326 QIconViewItem *item; 332 QIconViewItem *item;
327 AddresseeIconViewItem *aItem; 333 AddresseeIconViewItem *aItem;
328 334
329 if ( uid.isNull() ) { 335 if ( uid.isNull() ) {
330 // Rebuild the view 336 // Rebuild the view
331 mIconView->clear(); 337 mIconView->clear();
332 mIconList.clear(); 338 mIconList.clear();
333 339
334 KABC::Addressee::List addresseeList = addressees(); 340 KABC::Addressee::List addresseeList = addressees();
335 KABC::Addressee::List::Iterator iter; 341 KABC::Addressee::List::Iterator iter;
336 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { 342 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) {
337 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 343 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
338 continue; 344 continue;
339 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); 345 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView );
340 } 346 }
341 347
diff --git a/kaddressbook/views/kaddressbookiconview.h b/kaddressbook/views/kaddressbookiconview.h
index acfcd71..b0b9fea 100644
--- a/kaddressbook/views/kaddressbookiconview.h
+++ b/kaddressbook/views/kaddressbookiconview.h
@@ -1,133 +1,134 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KADDRESSBOOKICONVIEW_H 24#ifndef KADDRESSBOOKICONVIEW_H
25#define KADDRESSBOOKICONVIEW_H 25#define KADDRESSBOOKICONVIEW_H
26 26
27#include <qstring.h> 27#include <qstring.h>
28#ifndef KAB_EMBEDDED 28#ifndef KAB_EMBEDDED
29#include <kiconview.h> 29#include <kiconview.h>
30#else //KAB_EMBEDDED 30#else //KAB_EMBEDDED
31#include <qiconview.h> 31#include <qiconview.h>
32#include <qptrlist.h> 32#include <qptrlist.h>
33#include <klocale.h> 33#include <klocale.h>
34#endif //KAB_EMBEDDED 34#endif //KAB_EMBEDDED
35#include "kaddressbookview.h" 35#include "kaddressbookview.h"
36 36
37class QIconViewItem; 37class QIconViewItem;
38class KConfig; 38class KConfig;
39class AddresseeIconView; 39class AddresseeIconView;
40class AddresseeIconViewItem; 40class AddresseeIconViewItem;
41class QIconDragItem; 41class QIconDragItem;
42class KAddressBookIconView; 42class KAddressBookIconView;
43 43
44namespace KABC { class AddressBook; } 44namespace KABC { class AddressBook; }
45 45
46/** This is an example kaddressbook view that is implemented using 46/** This is an example kaddressbook view that is implemented using
47* KIconView. This view is not the most useful view, but it displays 47* KIconView. This view is not the most useful view, but it displays
48* how simple implementing a new view can be. 48* how simple implementing a new view can be.
49*/ 49*/
50class KAddressBookIconView : public KAddressBookView 50class KAddressBookIconView : public KAddressBookView
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54 public: 54 public:
55 KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent, 55 KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent,
56 const char *name = 0 ); 56 const char *name = 0 );
57 virtual ~KAddressBookIconView(); 57 virtual ~KAddressBookIconView();
58 58
59 virtual QStringList selectedUids(); 59 virtual QStringList selectedUids();
60 virtual QString type() const { return "Icon"; } 60 virtual QString type() const { return "Icon"; }
61 void doSearch( const QString& s ,KABC::Field *field ); 61 void doSearch( const QString& s ,KABC::Field *field );
62 62
63 virtual void readConfig(KConfig *config); 63 virtual void readConfig(KConfig *config);
64 virtual void scrollUP(); 64 virtual void scrollUP();
65 virtual void scrollDOWN(); 65 virtual void scrollDOWN();
66 virtual void setFocusAV();
66 67
67 public slots: 68 public slots:
68 void refresh(QString uid = QString::null); 69 void refresh(QString uid = QString::null);
69#ifndef KAB_EMBEDDED 70#ifndef KAB_EMBEDDED
70//MOC_SKIP_BEGIN 71//MOC_SKIP_BEGIN
71 void setSelected(QString uid = QString::null, bool selected = true); 72 void setSelected(QString uid = QString::null, bool selected = true);
72//MOC_SKIP_END 73//MOC_SKIP_END
73#else //KAB_EMBEDDED 74#else //KAB_EMBEDDED
74//US my MOC do not like default parameters ??? 75//US my MOC do not like default parameters ???
75 void setSelected(QString uid, bool selected); 76 void setSelected(QString uid, bool selected);
76#endif //KAB_EMBEDDED 77#endif //KAB_EMBEDDED
77 78
78 protected slots: 79 protected slots:
79 void addresseeExecuted(QIconViewItem *item); 80 void addresseeExecuted(QIconViewItem *item);
80 void addresseeSelected(); 81 void addresseeSelected();
81 82
82 private: 83 private:
83 AddresseeIconView *mIconView; 84 AddresseeIconView *mIconView;
84 QPtrList<AddresseeIconViewItem> mIconList; 85 QPtrList<AddresseeIconViewItem> mIconList;
85}; 86};
86 87
87 88
88#ifndef KAB_EMBEDDED 89#ifndef KAB_EMBEDDED
89//MOC_SKIP_BEGIN 90//MOC_SKIP_BEGIN
90class AddresseeIconView : public KIconView 91class AddresseeIconView : public KIconView
91//MOC_SKIP_END 92//MOC_SKIP_END
92#else //KAB_EMBEDDED 93#else //KAB_EMBEDDED
93class AddresseeIconView : public QIconView 94class AddresseeIconView : public QIconView
94#endif //KAB_EMBEDDED 95#endif //KAB_EMBEDDED
95{ 96{
96 Q_OBJECT 97 Q_OBJECT
97 98
98 public: 99 public:
99 AddresseeIconView(QWidget *parent, const char *name); 100 AddresseeIconView(QWidget *parent, const char *name);
100 ~AddresseeIconView(); 101 ~AddresseeIconView();
101 102
102 signals: 103 signals:
103 void addresseeDropped(QDropEvent *); 104 void addresseeDropped(QDropEvent *);
104 void startAddresseeDrag(); 105 void startAddresseeDrag();
105 106
106 protected: 107 protected:
107 virtual QDragObject *dragObject(); 108 virtual QDragObject *dragObject();
108 109
109 protected slots: 110 protected slots:
110 void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &); 111 void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &);
111}; 112};
112 113
113class IconViewFactory : public ViewFactory 114class IconViewFactory : public ViewFactory
114{ 115{
115 public: 116 public:
116 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 117 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
117 { 118 {
118 return new KAddressBookIconView( ab, parent, name ); 119 return new KAddressBookIconView( ab, parent, name );
119 } 120 }
120 121
121 QString type() const { return "Icon"; } 122 QString type() const { return "Icon"; }
122 123
123 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } 124 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); }
124}; 125};
125/* 126/*
126extern "C" { 127extern "C" {
127 void *init_libkaddrbk_iconview() 128 void *init_libkaddrbk_iconview()
128 { 129 {
129 return ( new IconViewFactory ); 130 return ( new IconViewFactory );
130 } 131 }
131} 132}
132*/ 133*/
133#endif 134#endif
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 2412170..e40eb9e 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -1,181 +1,187 @@
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
41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 41KAddressBookTableView::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
51KAddressBookTableView::~KAddressBookTableView() 51KAddressBookTableView::~KAddressBookTableView()
52{ 52{
53} 53}
54void KAddressBookTableView::setFocusAV()
55{
56 if ( mListView )
57 mListView->setFocus();
58
59}
54void KAddressBookTableView::scrollUP() 60void KAddressBookTableView::scrollUP()
55{ 61{
56 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
57 QApplication::postEvent( mListView, ev ); 63 QApplication::postEvent( mListView, ev );
58} 64}
59void KAddressBookTableView::scrollDOWN() 65void KAddressBookTableView::scrollDOWN()
60{ 66{
61 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 67 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
62 QApplication::postEvent( mListView, ev ); 68 QApplication::postEvent( mListView, ev );
63} 69}
64void KAddressBookTableView::reconstructListView() 70void KAddressBookTableView::reconstructListView()
65{ 71{
66 if (mListView) 72 if (mListView)
67 { 73 {
68 disconnect(mListView, SIGNAL(selectionChanged()), 74 disconnect(mListView, SIGNAL(selectionChanged()),
69 this, SLOT(addresseeSelected())); 75 this, SLOT(addresseeSelected()));
70 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 76 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
71 this, SLOT(addresseeExecuted(QListViewItem*))); 77 this, SLOT(addresseeExecuted(QListViewItem*)));
72 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 78 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
73 this, SLOT(addresseeExecuted(QListViewItem*))); 79 this, SLOT(addresseeExecuted(QListViewItem*)));
74 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 80 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
75 SIGNAL(startDrag())); 81 SIGNAL(startDrag()));
76 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 82 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
77 this, SLOT(addresseeExecuted(QListViewItem*))); 83 this, SLOT(addresseeExecuted(QListViewItem*)));
78 84
79 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 85 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
80 SIGNAL(dropped(QDropEvent*))); 86 SIGNAL(dropped(QDropEvent*)));
81 delete mListView; 87 delete mListView;
82 } 88 }
83 89
84 mListView = new ContactListView( this, addressBook(), viewWidget() ); 90 mListView = new ContactListView( this, addressBook(), viewWidget() );
85 91
86 // Add the columns 92 // Add the columns
87 KABC::Field::List fieldList = fields(); 93 KABC::Field::List fieldList = fields();
88 KABC::Field::List::ConstIterator it; 94 KABC::Field::List::ConstIterator it;
89 95
90 int c = 0; 96 int c = 0;
91 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 97 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
92 mListView->addColumn( (*it)->label() ); 98 mListView->addColumn( (*it)->label() );
93 mListView->setColumnWidthMode(c++, QListView::Manual); 99 mListView->setColumnWidthMode(c++, QListView::Manual);
94//US 100//US
95 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 101 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
96 } 102 }
97 103
98 connect(mListView, SIGNAL(selectionChanged()), 104 connect(mListView, SIGNAL(selectionChanged()),
99 this, SLOT(addresseeSelected())); 105 this, SLOT(addresseeSelected()));
100 connect(mListView, SIGNAL(startAddresseeDrag()), this, 106 connect(mListView, SIGNAL(startAddresseeDrag()), this,
101 SIGNAL(startDrag())); 107 SIGNAL(startDrag()));
102 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 108 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
103 SIGNAL(dropped(QDropEvent*))); 109 SIGNAL(dropped(QDropEvent*)));
104 110
105 if (KABPrefs::instance()->mHonorSingleClick) 111 if (KABPrefs::instance()->mHonorSingleClick)
106 connect(mListView, SIGNAL(executed(QListViewItem*)), 112 connect(mListView, SIGNAL(executed(QListViewItem*)),
107 this, SLOT(addresseeExecuted(QListViewItem*))); 113 this, SLOT(addresseeExecuted(QListViewItem*)));
108 else 114 else
109 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 115 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
110 this, SLOT(addresseeExecuted(QListViewItem*))); 116 this, SLOT(addresseeExecuted(QListViewItem*)));
111 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 117 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
112 this, SLOT(addresseeExecuted(QListViewItem*))); 118 this, SLOT(addresseeExecuted(QListViewItem*)));
113 connect(mListView, SIGNAL(signalDelete()), 119 connect(mListView, SIGNAL(signalDelete()),
114 this, SLOT(addresseeDeleted())); 120 this, SLOT(addresseeDeleted()));
115 121
116//US performceimprovement. Refresh is done from the outside 122//US performceimprovement. Refresh is done from the outside
117//US refresh(); 123//US refresh();
118 124
119 mListView->setSorting( 0, true ); 125 mListView->setSorting( 0, true );
120 mainLayout->addWidget( mListView ); 126 mainLayout->addWidget( mListView );
121 mainLayout->activate(); 127 mainLayout->activate();
122 mListView->show(); 128 mListView->show();
123} 129}
124 130
125void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 131void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
126{ 132{
127 mListView->clear(); 133 mListView->clear();
128 if ( s.isEmpty() || s == "*" ) { 134 if ( s.isEmpty() || s == "*" ) {
129 refresh(); 135 refresh();
130 return; 136 return;
131 } 137 }
132 QString pattern = s.lower()+"*"; 138 QString pattern = s.lower()+"*";
133 QRegExp re; 139 QRegExp re;
134 re.setWildcard(true); // most people understand these better. 140 re.setWildcard(true); // most people understand these better.
135 re.setCaseSensitive(false); 141 re.setCaseSensitive(false);
136 re.setPattern( pattern ); 142 re.setPattern( pattern );
137 if (!re.isValid()) 143 if (!re.isValid())
138 return; 144 return;
139 KABC::Addressee::List addresseeList = addressees(); 145 KABC::Addressee::List addresseeList = addressees();
140 KABC::Addressee::List::Iterator it; 146 KABC::Addressee::List::Iterator it;
141 if ( field ) { 147 if ( field ) {
142 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 148 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
143#if QT_VERSION >= 300 149#if QT_VERSION >= 300
144 if (re.search(field->value( *it ).lower()) != -1) 150 if (re.search(field->value( *it ).lower()) != -1)
145#else 151#else
146 if (re.match(field->value( *it ).lower()) != -1) 152 if (re.match(field->value( *it ).lower()) != -1)
147#endif 153#endif
148 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 154 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
149 155
150 } 156 }
151 } else { 157 } else {
152 KABC::Field::List fieldList = fields(); 158 KABC::Field::List fieldList = fields();
153 KABC::Field::List::ConstIterator fieldIt; 159 KABC::Field::List::ConstIterator fieldIt;
154 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 160 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
155 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 161 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
156#if QT_VERSION >= 300 162#if QT_VERSION >= 300
157 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 163 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
158#else 164#else
159 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 165 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
160#endif 166#endif
161 { 167 {
162 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 168 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
163 break; 169 break;
164 } 170 }
165 } 171 }
166 } 172 }
167 } 173 }
168 // Sometimes the background pixmap gets messed up when we add lots 174 // Sometimes the background pixmap gets messed up when we add lots
169 // of items. 175 // of items.
170 mListView->repaint(); 176 mListView->repaint();
171 if ( mListView->firstChild() ) { 177 if ( mListView->firstChild() ) {
172 mListView->setCurrentItem ( mListView->firstChild() ); 178 mListView->setCurrentItem ( mListView->firstChild() );
173 mListView->setSelected ( mListView->firstChild(), true ); 179 mListView->setSelected ( mListView->firstChild(), true );
174 } 180 }
175 else 181 else
176 emit selected(QString::null); 182 emit selected(QString::null);
177 183
178} 184}
179void KAddressBookTableView::writeConfig(KConfig *config) 185void KAddressBookTableView::writeConfig(KConfig *config)
180{ 186{
181 KAddressBookView::writeConfig(config); 187 KAddressBookView::writeConfig(config);
diff --git a/kaddressbook/views/kaddressbooktableview.h b/kaddressbook/views/kaddressbooktableview.h
index 865f8d5..38db7b4 100644
--- a/kaddressbook/views/kaddressbooktableview.h
+++ b/kaddressbook/views/kaddressbooktableview.h
@@ -1,117 +1,118 @@
1#ifndef KADDRESSBOOKTABLEVIEW_H 1#ifndef KADDRESSBOOKTABLEVIEW_H
2#define KADDRESSBOOKTABLEVIEW_H 2#define KADDRESSBOOKTABLEVIEW_H
3 3
4 4
5#ifndef KAB_EMBEDDED 5#ifndef KAB_EMBEDDED
6 6
7 7
8#ifdef HAVE_CONFIG_H 8#ifdef HAVE_CONFIG_H
9#include <config.h> 9#include <config.h>
10#endif 10#endif
11 11
12#include <qwidget.h> 12#include <qwidget.h>
13#include <qlistview.h> 13#include <qlistview.h>
14#include <qstring.h> 14#include <qstring.h>
15#include <qdialog.h> 15#include <qdialog.h>
16#include <qtabdialog.h> 16#include <qtabdialog.h>
17#include <qstringlist.h> 17#include <qstringlist.h>
18#include <qvaluelist.h> 18#include <qvaluelist.h>
19 19
20#include "undo.h" 20#include "undo.h"
21 21
22#else //KAB_EMBEDDED 22#else //KAB_EMBEDDED
23#include "views/configuretableviewdialog.h" 23#include "views/configuretableviewdialog.h"
24#endif //KAB_EMBEDDED 24#endif //KAB_EMBEDDED
25 25
26#include "klocale.h" 26#include "klocale.h"
27#include "kaddressbookview.h" 27#include "kaddressbookview.h"
28 28
29class QListViewItem; 29class QListViewItem;
30class QListBox; 30class QListBox;
31class QVBoxLayout; 31class QVBoxLayout;
32class KConfig; 32class KConfig;
33 33
34class ContactListViewItem; 34class ContactListViewItem;
35class ContactListView; 35class ContactListView;
36 36
37 37
38namespace KABC { class AddressBook; } 38namespace KABC { class AddressBook; }
39 39
40/** 40/**
41 * This class is the table view for kaddressbook. This view is a KListView 41 * This class is the table view for kaddressbook. This view is a KListView
42 * with multiple columns for the selected fields. 42 * with multiple columns for the selected fields.
43 * 43 *
44 * @short Table View 44 * @short Table View
45 * @author Don Sanders <dsanders@kde.org> 45 * @author Don Sanders <dsanders@kde.org>
46 * @version 0.1 46 * @version 0.1
47 */ 47 */
48class KAddressBookTableView : public KAddressBookView 48class KAddressBookTableView : public KAddressBookView
49{ 49{
50friend class ContactListView; 50friend class ContactListView;
51 51
52 Q_OBJECT 52 Q_OBJECT
53 53
54 public: 54 public:
55 KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, 55 KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent,
56 const char *name = 0 ); 56 const char *name = 0 );
57 virtual ~KAddressBookTableView(); 57 virtual ~KAddressBookTableView();
58 58
59 virtual void refresh(QString uid = QString::null); 59 virtual void refresh(QString uid = QString::null);
60 virtual QStringList selectedUids(); 60 virtual QStringList selectedUids();
61 virtual void setSelected(QString uid = QString::null, bool selected = false); 61 virtual void setSelected(QString uid = QString::null, bool selected = false);
62 virtual void readConfig(KConfig *config); 62 virtual void readConfig(KConfig *config);
63 virtual void writeConfig(KConfig *config); 63 virtual void writeConfig(KConfig *config);
64 virtual QString type() const { return "Table"; } 64 virtual QString type() const { return "Table"; }
65 void doSearch( const QString& s ,KABC::Field *field ); 65 void doSearch( const QString& s ,KABC::Field *field );
66 virtual void scrollUP(); 66 virtual void scrollUP();
67 virtual void scrollDOWN(); 67 virtual void scrollDOWN();
68 virtual void setFocusAV();
68 69
69 public slots: 70 public slots:
70 virtual void reconstructListView(); 71 virtual void reconstructListView();
71 72
72 protected slots: 73 protected slots:
73 /** Called whenever the user selects an addressee in the list view. 74 /** Called whenever the user selects an addressee in the list view.
74 */ 75 */
75 void addresseeSelected(); 76 void addresseeSelected();
76 void addresseeDeleted(); 77 void addresseeDeleted();
77 78
78 /** Called whenever the user executes an addressee. In terms of the 79 /** Called whenever the user executes an addressee. In terms of the
79 * list view, this is probably a double click 80 * list view, this is probably a double click
80 */ 81 */
81 void addresseeExecuted(QListViewItem*); 82 void addresseeExecuted(QListViewItem*);
82 83
83 private: 84 private:
84 QVBoxLayout *mainLayout; 85 QVBoxLayout *mainLayout;
85 ContactListView *mListView; 86 ContactListView *mListView;
86}; 87};
87 88
88 89
89class TableViewFactory : public ViewFactory 90class TableViewFactory : public ViewFactory
90{ 91{
91 public: 92 public:
92 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 93 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
93 { 94 {
94 return new KAddressBookTableView( ab, parent, name ); 95 return new KAddressBookTableView( ab, parent, name );
95 } 96 }
96 97
97 QString type() const { return "Table"; } 98 QString type() const { return "Table"; }
98 99
99 QString description() const { return i18n( "A listing of contacts in a table. Each cell of " 100 QString description() const { return i18n( "A listing of contacts in a table. Each cell of "
100 "the table holds a field of the contact." ); } 101 "the table holds a field of the contact." ); }
101 102
102 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, 103 ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent,
103 const char *name = 0 ) 104 const char *name = 0 )
104 { 105 {
105 return new ConfigureTableViewWidget( ab, parent, name ); 106 return new ConfigureTableViewWidget( ab, parent, name );
106 } 107 }
107}; 108};
108/*US 109/*US
109extern "C" { 110extern "C" {
110 void *init_libkaddrbk_tableview() 111 void *init_libkaddrbk_tableview()
111 { 112 {
112 return ( new TableViewFactory ); 113 return ( new TableViewFactory );
113 } 114 }
114} 115}
115*/ 116*/
116 117
117#endif 118#endif