summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-09-12 10:30:29 (UTC)
committer zautrix <zautrix>2004-09-12 10:30:29 (UTC)
commita3a24948c51aa2983e415c990eaf0db9ac3c0005 (patch) (unidiff)
tree558fee47ff2cacbb591c72b9ab16c830cc2f857a /kaddressbook
parent31fab1d7e531b492d1075964ddcbebe7a563a41a (diff)
downloadkdepimpi-a3a24948c51aa2983e415c990eaf0db9ac3c0005.zip
kdepimpi-a3a24948c51aa2983e415c990eaf0db9ac3c0005.tar.gz
kdepimpi-a3a24948c51aa2983e415c990eaf0db9ac3c0005.tar.bz2
Desktop compile fixes
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp1
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp1
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp1
3 files changed, 3 insertions, 0 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 49c0691..8d0fca1 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -1,156 +1,157 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qdragobject.h> 24#include <qdragobject.h>
25#include <qevent.h> 25#include <qevent.h>
26#include <qiconview.h> 26#include <qiconview.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qregexp.h>
29 30
30#include <kabc/addressbook.h> 31#include <kabc/addressbook.h>
31#include <kabc/addressee.h> 32#include <kabc/addressee.h>
32#include <kconfig.h> 33#include <kconfig.h>
33#include <kdebug.h> 34#include <kdebug.h>
34#include <klocale.h> 35#include <klocale.h>
35 36
36#include "kabprefs.h" 37#include "kabprefs.h"
37#include "viewmanager.h" 38#include "viewmanager.h"
38 39
39#include "kaddressbookcardview.h" 40#include "kaddressbookcardview.h"
40 41
41#ifndef KAB_EMBEDDED 42#ifndef KAB_EMBEDDED
42extern "C" { 43extern "C" {
43 void *init_libkaddrbk_cardview() 44 void *init_libkaddrbk_cardview()
44 { 45 {
45 return ( new CardViewFactory ); 46 return ( new CardViewFactory );
46 } 47 }
47} 48}
48#endif //KAB_EMBEDDED 49#endif //KAB_EMBEDDED
49 50
50//////////////////////////////// 51////////////////////////////////
51// AddresseeCardViewItem (internal class) 52// AddresseeCardViewItem (internal class)
52class AddresseeCardViewItem : public CardViewItem 53class AddresseeCardViewItem : public CardViewItem
53{ 54{
54 public: 55 public:
55 AddresseeCardViewItem(const KABC::Field::List &fields, 56 AddresseeCardViewItem(const KABC::Field::List &fields,
56 bool showEmptyFields, 57 bool showEmptyFields,
57 KABC::AddressBook *doc, const KABC::Addressee &a, 58 KABC::AddressBook *doc, const KABC::Addressee &a,
58 CardView *parent) 59 CardView *parent)
59 : CardViewItem(parent, a.formattedName()), 60 : CardViewItem(parent, a.formattedName()),
60 mFields( fields ), mShowEmptyFields(showEmptyFields), 61 mFields( fields ), mShowEmptyFields(showEmptyFields),
61 mDocument(doc), mAddressee(a) 62 mDocument(doc), mAddressee(a)
62 { 63 {
63 if ( mFields.isEmpty() ) { 64 if ( mFields.isEmpty() ) {
64 mFields = KABC::Field::defaultFields(); 65 mFields = KABC::Field::defaultFields();
65 } 66 }
66 refresh(); 67 refresh();
67 } 68 }
68 69
69 const KABC::Addressee &addressee() const { return mAddressee; } 70 const KABC::Addressee &addressee() const { return mAddressee; }
70 71
71 void refresh() 72 void refresh()
72 { 73 {
73 // Update our addressee, since it may have changed elsewhere 74 // Update our addressee, since it may have changed elsewhere
74 mAddressee = mDocument->findByUid(mAddressee.uid()); 75 mAddressee = mDocument->findByUid(mAddressee.uid());
75 76
76 if (!mAddressee.isEmpty()) 77 if (!mAddressee.isEmpty())
77 { 78 {
78 clearFields(); 79 clearFields();
79 80
80 // Try all the selected fields until we find one with text. 81 // Try all the selected fields until we find one with text.
81 // This will limit the number of unlabeled icons in the view 82 // This will limit the number of unlabeled icons in the view
82 KABC::Field::List::Iterator iter; 83 KABC::Field::List::Iterator iter;
83 for (iter = mFields.begin(); iter != mFields.end(); ++iter) 84 for (iter = mFields.begin(); iter != mFields.end(); ++iter)
84 { 85 {
85 // insert empty fields or not? not doing so saves a bit of memory and CPU 86 // insert empty fields or not? not doing so saves a bit of memory and CPU
86 // (during geometry calculations), but prevents having equally 87 // (during geometry calculations), but prevents having equally
87 // wide label columns in all cards, unless CardViewItem/CardView search 88 // wide label columns in all cards, unless CardViewItem/CardView search
88 // globally for the widest label. (anders) 89 // globally for the widest label. (anders)
89 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) 90 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty())
90 insertField((*iter)->label(), (*iter)->value( mAddressee )); 91 insertField((*iter)->label(), (*iter)->value( mAddressee ));
91 } 92 }
92 93
93 // We might want to make this the first field. hmm... -mpilone 94 // We might want to make this the first field. hmm... -mpilone
94 setCaption( mAddressee.realName() ); 95 setCaption( mAddressee.realName() );
95 } 96 }
96 } 97 }
97 98
98 private: 99 private:
99 KABC::Field::List mFields; 100 KABC::Field::List mFields;
100 bool mShowEmptyFields; 101 bool mShowEmptyFields;
101 KABC::AddressBook *mDocument; 102 KABC::AddressBook *mDocument;
102 KABC::Addressee mAddressee; 103 KABC::Addressee mAddressee;
103}; 104};
104 105
105/////////////////////////////// 106///////////////////////////////
106// AddresseeCardView 107// AddresseeCardView
107 108
108AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) 109AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name)
109 : CardView(parent, name) 110 : CardView(parent, name)
110{ 111{
111 setAcceptDrops(true); 112 setAcceptDrops(true);
112} 113}
113 114
114AddresseeCardView::~AddresseeCardView() 115AddresseeCardView::~AddresseeCardView()
115{ 116{
116} 117}
117 118
118 119
119void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) 120void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
120{ 121{
121#ifndef KAB_EMBEDDED 122#ifndef KAB_EMBEDDED
122 if (QTextDrag::canDecode(e)) 123 if (QTextDrag::canDecode(e))
123 e->accept(); 124 e->accept();
124#else //KAB_EMBEDDED 125#else //KAB_EMBEDDED
125qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); 126qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented");
126#endif //KAB_EMBEDDED 127#endif //KAB_EMBEDDED
127} 128}
128 129
129void AddresseeCardView::dropEvent(QDropEvent *e) 130void AddresseeCardView::dropEvent(QDropEvent *e)
130{ 131{
131 emit addresseeDropped(e); 132 emit addresseeDropped(e);
132} 133}
133 134
134void AddresseeCardView::startDrag() 135void AddresseeCardView::startDrag()
135{ 136{
136 emit startAddresseeDrag(); 137 emit startAddresseeDrag();
137} 138}
138 139
139 140
140/////////////////////////////// 141///////////////////////////////
141// KAddressBookCardView 142// KAddressBookCardView
142 143
143KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, 144KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab,
144 QWidget *parent, const char *name ) 145 QWidget *parent, const char *name )
145 : KAddressBookView( ab, parent, name ) 146 : KAddressBookView( ab, parent, name )
146{ 147{
147 mShowEmptyFields = false; 148 mShowEmptyFields = false;
148 149
149 // Init the GUI 150 // Init the GUI
150 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 151 QVBoxLayout *layout = new QVBoxLayout(viewWidget());
151 152
152 mCardView = new AddresseeCardView(viewWidget(), "mCardView"); 153 mCardView = new AddresseeCardView(viewWidget(), "mCardView");
153 mCardView->setSelectionMode(CardView::Extended); 154 mCardView->setSelectionMode(CardView::Extended);
154 layout->addWidget(mCardView); 155 layout->addWidget(mCardView);
155 156
156 // Connect up the signals 157 // Connect up the signals
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index 78d63b0..0ffc674 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -1,170 +1,171 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KAB_EMBEDDED 24#ifndef KAB_EMBEDDED
25#include <qiconview.h> 25#include <qiconview.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27 27
28#include <kabc/addressee.h> 28#include <kabc/addressee.h>
29#include <kconfig.h> 29#include <kconfig.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#else //KAB_EMBEDDED 35#else //KAB_EMBEDDED
36#endif //KAB_EMBEDDED 36#endif //KAB_EMBEDDED
37 37
38#include <kabc/addressbook.h> 38#include <kabc/addressbook.h>
39#include "kabprefs.h" 39#include "kabprefs.h"
40#include "viewmanager.h" 40#include "viewmanager.h"
41#include "kaddressbookiconview.h" 41#include "kaddressbookiconview.h"
42#include <qlayout.h> 42#include <qlayout.h>
43#include <qregexp.h>
43#include <kglobal.h> 44#include <kglobal.h>
44/*US transfered to the headerfile 45/*US transfered to the headerfile
45class IconViewFactory : public ViewFactory 46class IconViewFactory : public ViewFactory
46{ 47{
47 public: 48 public:
48 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 49 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
49 { 50 {
50 return new KAddressBookIconView( ab, parent, name ); 51 return new KAddressBookIconView( ab, parent, name );
51 } 52 }
52 53
53 QString type() const { return "Icon"; } 54 QString type() const { return "Icon"; }
54 55
55 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } 56 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); }
56}; 57};
57 58
58*/ 59*/
59 60
60extern "C" { 61extern "C" {
61 void *init_libkaddrbk_iconview() 62 void *init_libkaddrbk_iconview()
62 { 63 {
63 return ( new IconViewFactory ); 64 return ( new IconViewFactory );
64 } 65 }
65} 66}
66 67
67//////////////////////////////// 68////////////////////////////////
68// AddresseeIconView (internal class) 69// AddresseeIconView (internal class)
69#ifndef KAB_EMBEDDED 70#ifndef KAB_EMBEDDED
70AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 71AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
71 : KIconView(parent, name) 72 : KIconView(parent, name)
72#else //KAB_EMBEDDED 73#else //KAB_EMBEDDED
73AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 74AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
74 : QIconView(parent, name) 75 : QIconView(parent, name)
75#endif //KAB_EMBEDDED 76#endif //KAB_EMBEDDED
76 77
77{ 78{
78 setSelectionMode( QIconView::Extended ); 79 setSelectionMode( QIconView::Extended );
79 setResizeMode( QIconView::Adjust ); 80 setResizeMode( QIconView::Adjust );
80 setWordWrapIconText( true ); 81 setWordWrapIconText( true );
81 setGridX( 100 ); 82 setGridX( 100 );
82 setItemsMovable(false); 83 setItemsMovable(false);
83 setSorting(true, true); 84 setSorting(true, true);
84 85
85 86
86//US ??? setMode( KIconView::Select ); 87//US ??? setMode( KIconView::Select );
87 88
88#ifndef KAB_EMBEDDED 89#ifndef KAB_EMBEDDED
89 90
90 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), 91 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)),
91 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); 92 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&)));
92#endif //KAB_EMBEDDED 93#endif //KAB_EMBEDDED
93} 94}
94 95
95AddresseeIconView::~AddresseeIconView() 96AddresseeIconView::~AddresseeIconView()
96{ 97{
97} 98}
98 99
99 100
100void AddresseeIconView::itemDropped(QDropEvent *e, 101void AddresseeIconView::itemDropped(QDropEvent *e,
101 const QValueList<QIconDragItem> &) 102 const QValueList<QIconDragItem> &)
102{ 103{
103 emit addresseeDropped(e); 104 emit addresseeDropped(e);
104} 105}
105 106
106QDragObject *AddresseeIconView::dragObject() 107QDragObject *AddresseeIconView::dragObject()
107{ 108{
108 emit startAddresseeDrag(); 109 emit startAddresseeDrag();
109 110
110 // We never want IconView to start the drag 111 // We never want IconView to start the drag
111 return 0; 112 return 0;
112} 113}
113//////////////////////////////// 114////////////////////////////////
114// AddresseeIconViewItem (internal class) 115// AddresseeIconViewItem (internal class)
115#ifndef KAB_EMBEDDED 116#ifndef KAB_EMBEDDED
116class AddresseeIconViewItem : public KIconViewItem 117class AddresseeIconViewItem : public KIconViewItem
117#else //KAB_EMBEDDED 118#else //KAB_EMBEDDED
118class AddresseeIconViewItem : public QIconViewItem 119class AddresseeIconViewItem : public QIconViewItem
119#endif //KAB_EMBEDDED 120#endif //KAB_EMBEDDED
120{ 121{
121 public: 122 public:
122#ifndef KAB_EMBEDDED 123#ifndef KAB_EMBEDDED
123 AddresseeIconViewItem(const KABC::Field::List &fields, 124 AddresseeIconViewItem(const KABC::Field::List &fields,
124 KABC::AddressBook *doc, const KABC::Addressee &a, 125 KABC::AddressBook *doc, const KABC::Addressee &a,
125 QIconView *parent) 126 QIconView *parent)
126 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 127 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
127#else //KAB_EMBEDDED 128#else //KAB_EMBEDDED
128 AddresseeIconViewItem(const KABC::Field::List &fields, 129 AddresseeIconViewItem(const KABC::Field::List &fields,
129 KABC::AddressBook *doc, const KABC::Addressee &a, 130 KABC::AddressBook *doc, const KABC::Addressee &a,
130 QIconView *parent) 131 QIconView *parent)
131 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 132 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
132#endif //KAB_EMBEDDED 133#endif //KAB_EMBEDDED
133 { 134 {
134 if ( mFields.isEmpty() ) { 135 if ( mFields.isEmpty() ) {
135 mFields = KABC::Field::defaultFields(); 136 mFields = KABC::Field::defaultFields();
136 } 137 }
137 refresh(); 138 refresh();
138 } 139 }
139 140
140 const KABC::Addressee &addressee() const { return mAddressee; } 141 const KABC::Addressee &addressee() const { return mAddressee; }
141 142
142 void refresh() 143 void refresh()
143 { 144 {
144 // Update our addressee, since it may have changed elsewhere 145 // Update our addressee, since it may have changed elsewhere
145 mAddressee = mDocument->findByUid(mAddressee.uid()); 146 mAddressee = mDocument->findByUid(mAddressee.uid());
146 147
147 if (!mAddressee.isEmpty()) 148 if (!mAddressee.isEmpty())
148 setText( mAddressee.givenName() + " " + mAddressee.familyName() ); 149 setText( mAddressee.givenName() + " " + mAddressee.familyName() );
149 150
150 QPixmap icon; 151 QPixmap icon;
151 QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); 152 QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) );
152 KABC::Picture pic = mAddressee.photo(); 153 KABC::Picture pic = mAddressee.photo();
153 if ( pic.data().isNull() ) 154 if ( pic.data().isNull() )
154 pic = mAddressee.logo(); 155 pic = mAddressee.logo();
155 156
156 if ( pic.isIntern() && !pic.data().isNull() ) { 157 if ( pic.isIntern() && !pic.data().isNull() ) {
157 QImage img = pic.data(); 158 QImage img = pic.data();
158#ifndef KAB_EMBEDDED 159#ifndef KAB_EMBEDDED
159 if ( img.width() > img.height() ) 160 if ( img.width() > img.height() )
160 icon = img.scaleWidth( 32 ); 161 icon = img.scaleWidth( 32 );
161 else 162 else
162 icon = img.scaleHeight( 32 ); 163 icon = img.scaleHeight( 32 );
163#else //KAB_EMBEDDED 164#else //KAB_EMBEDDED
164 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); 165 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor");
165 icon.convertFromImage(img.smoothScale(32, 32)); 166 icon.convertFromImage(img.smoothScale(32, 32));
166#endif //KAB_EMBEDDED 167#endif //KAB_EMBEDDED
167 168
168 } else 169 } else
169 icon = defaultIcon; 170 icon = defaultIcon;
170 171
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 63ad0ed..1dc9198 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -1,163 +1,164 @@
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 37
37#include "kaddressbooktableview.h" 38#include "kaddressbooktableview.h"
38 39
39 40
40KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
41 QWidget *parent, const char *name ) 42 QWidget *parent, const char *name )
42 : KAddressBookView( ab, parent, name ) 43 : KAddressBookView( ab, parent, name )
43{ 44{
44 mainLayout = new QVBoxLayout( viewWidget(), 2 ); 45 mainLayout = new QVBoxLayout( viewWidget(), 2 );
45 46
46 // The list view will be created when the config is read. 47 // The list view will be created when the config is read.
47 mListView = 0; 48 mListView = 0;
48} 49}
49 50
50KAddressBookTableView::~KAddressBookTableView() 51KAddressBookTableView::~KAddressBookTableView()
51{ 52{
52} 53}
53 54
54void KAddressBookTableView::reconstructListView() 55void KAddressBookTableView::reconstructListView()
55{ 56{
56 if (mListView) 57 if (mListView)
57 { 58 {
58 disconnect(mListView, SIGNAL(selectionChanged()), 59 disconnect(mListView, SIGNAL(selectionChanged()),
59 this, SLOT(addresseeSelected())); 60 this, SLOT(addresseeSelected()));
60 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 61 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
61 this, SLOT(addresseeExecuted(QListViewItem*))); 62 this, SLOT(addresseeExecuted(QListViewItem*)));
62 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 63 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
63 this, SLOT(addresseeExecuted(QListViewItem*))); 64 this, SLOT(addresseeExecuted(QListViewItem*)));
64 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 65 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
65 SIGNAL(startDrag())); 66 SIGNAL(startDrag()));
66 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 67 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
67 this, SLOT(addresseeExecuted(QListViewItem*))); 68 this, SLOT(addresseeExecuted(QListViewItem*)));
68 69
69 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 70 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
70 SIGNAL(dropped(QDropEvent*))); 71 SIGNAL(dropped(QDropEvent*)));
71 delete mListView; 72 delete mListView;
72 } 73 }
73 74
74 mListView = new ContactListView( this, addressBook(), viewWidget() ); 75 mListView = new ContactListView( this, addressBook(), viewWidget() );
75 76
76 // Add the columns 77 // Add the columns
77 KABC::Field::List fieldList = fields(); 78 KABC::Field::List fieldList = fields();
78 KABC::Field::List::ConstIterator it; 79 KABC::Field::List::ConstIterator it;
79 80
80 int c = 0; 81 int c = 0;
81 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 82 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
82 mListView->addColumn( (*it)->label() ); 83 mListView->addColumn( (*it)->label() );
83 mListView->setColumnWidthMode(c++, QListView::Manual); 84 mListView->setColumnWidthMode(c++, QListView::Manual);
84//US 85//US
85 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 86 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
86 } 87 }
87 88
88 connect(mListView, SIGNAL(selectionChanged()), 89 connect(mListView, SIGNAL(selectionChanged()),
89 this, SLOT(addresseeSelected())); 90 this, SLOT(addresseeSelected()));
90 connect(mListView, SIGNAL(startAddresseeDrag()), this, 91 connect(mListView, SIGNAL(startAddresseeDrag()), this,
91 SIGNAL(startDrag())); 92 SIGNAL(startDrag()));
92 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 93 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
93 SIGNAL(dropped(QDropEvent*))); 94 SIGNAL(dropped(QDropEvent*)));
94 95
95 if (KABPrefs::instance()->mHonorSingleClick) 96 if (KABPrefs::instance()->mHonorSingleClick)
96 connect(mListView, SIGNAL(executed(QListViewItem*)), 97 connect(mListView, SIGNAL(executed(QListViewItem*)),
97 this, SLOT(addresseeExecuted(QListViewItem*))); 98 this, SLOT(addresseeExecuted(QListViewItem*)));
98 else 99 else
99 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 100 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
100 this, SLOT(addresseeExecuted(QListViewItem*))); 101 this, SLOT(addresseeExecuted(QListViewItem*)));
101 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 102 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
102 this, SLOT(addresseeExecuted(QListViewItem*))); 103 this, SLOT(addresseeExecuted(QListViewItem*)));
103 connect(mListView, SIGNAL(signalDelete()), 104 connect(mListView, SIGNAL(signalDelete()),
104 this, SLOT(addresseeDeleted())); 105 this, SLOT(addresseeDeleted()));
105 106
106//US performceimprovement. Refresh is done from the outside 107//US performceimprovement. Refresh is done from the outside
107//US refresh(); 108//US refresh();
108 109
109 mListView->setSorting( 0, true ); 110 mListView->setSorting( 0, true );
110 mainLayout->addWidget( mListView ); 111 mainLayout->addWidget( mListView );
111 mainLayout->activate(); 112 mainLayout->activate();
112 mListView->show(); 113 mListView->show();
113} 114}
114 115
115void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 116void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
116{ 117{
117 mListView->clear(); 118 mListView->clear();
118 if ( s.isEmpty() || s == "*" ) { 119 if ( s.isEmpty() || s == "*" ) {
119 refresh(); 120 refresh();
120 return; 121 return;
121 } 122 }
122 QString pattern = s.lower()+"*"; 123 QString pattern = s.lower()+"*";
123 QRegExp re; 124 QRegExp re;
124 re.setWildcard(true); // most people understand these better. 125 re.setWildcard(true); // most people understand these better.
125 re.setCaseSensitive(false); 126 re.setCaseSensitive(false);
126 re.setPattern( pattern ); 127 re.setPattern( pattern );
127 if (!re.isValid()) 128 if (!re.isValid())
128 return; 129 return;
129 KABC::Addressee::List addresseeList = addressees(); 130 KABC::Addressee::List addresseeList = addressees();
130 KABC::Addressee::List::Iterator it; 131 KABC::Addressee::List::Iterator it;
131 if ( field ) { 132 if ( field ) {
132 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 133 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
133#if QT_VERSION >= 300 134#if QT_VERSION >= 300
134 if (re.search(field->value( *it ).lower()) != -1) 135 if (re.search(field->value( *it ).lower()) != -1)
135#else 136#else
136 if (re.match(field->value( *it ).lower()) != -1) 137 if (re.match(field->value( *it ).lower()) != -1)
137#endif 138#endif
138 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 139 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
139 140
140 } 141 }
141 } else { 142 } else {
142 KABC::Field::List fieldList = fields(); 143 KABC::Field::List fieldList = fields();
143 KABC::Field::List::ConstIterator fieldIt; 144 KABC::Field::List::ConstIterator fieldIt;
144 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 145 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
145 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 146 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
146#if QT_VERSION >= 300 147#if QT_VERSION >= 300
147 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 148 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
148#else 149#else
149 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 150 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
150#endif 151#endif
151 { 152 {
152 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 153 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
153 break; 154 break;
154 } 155 }
155 } 156 }
156 } 157 }
157 } 158 }
158 // Sometimes the background pixmap gets messed up when we add lots 159 // Sometimes the background pixmap gets messed up when we add lots
159 // of items. 160 // of items.
160 mListView->repaint(); 161 mListView->repaint();
161 emit selected(QString::null); 162 emit selected(QString::null);
162 163
163} 164}