summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
Unidiff
Diffstat (limited to 'kaddressbook/views') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp53
-rw-r--r--kaddressbook/views/kaddressbookcardview.h2
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp47
-rw-r--r--kaddressbook/views/kaddressbookiconview.h1
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp49
-rw-r--r--kaddressbook/views/kaddressbooktableview.h1
6 files changed, 151 insertions, 2 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 239429f..49c0691 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -106,24 +106,25 @@ class AddresseeCardViewItem : public CardViewItem
106// AddresseeCardView 106// AddresseeCardView
107 107
108AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) 108AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name)
109 : CardView(parent, name) 109 : CardView(parent, name)
110{ 110{
111 setAcceptDrops(true); 111 setAcceptDrops(true);
112} 112}
113 113
114AddresseeCardView::~AddresseeCardView() 114AddresseeCardView::~AddresseeCardView()
115{ 115{
116} 116}
117 117
118
118void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) 119void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
119{ 120{
120#ifndef KAB_EMBEDDED 121#ifndef KAB_EMBEDDED
121 if (QTextDrag::canDecode(e)) 122 if (QTextDrag::canDecode(e))
122 e->accept(); 123 e->accept();
123#else //KAB_EMBEDDED 124#else //KAB_EMBEDDED
124qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); 125qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented");
125#endif //KAB_EMBEDDED 126#endif //KAB_EMBEDDED
126} 127}
127 128
128void AddresseeCardView::dropEvent(QDropEvent *e) 129void AddresseeCardView::dropEvent(QDropEvent *e)
129{ 130{
@@ -231,25 +232,75 @@ void KAddressBookCardView::readConfig(KConfig *config)
231 this, SLOT(addresseeExecuted(CardViewItem *))); 232 this, SLOT(addresseeExecuted(CardViewItem *)));
232 else 233 else
233 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 234 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
234 this, SLOT(addresseeExecuted(CardViewItem *))); 235 this, SLOT(addresseeExecuted(CardViewItem *)));
235 236
236} 237}
237 238
238void KAddressBookCardView::writeConfig( KConfig *config ) 239void KAddressBookCardView::writeConfig( KConfig *config )
239{ 240{
240 config->writeEntry( "ItemWidth", mCardView->itemWidth() ); 241 config->writeEntry( "ItemWidth", mCardView->itemWidth() );
241 KAddressBookView::writeConfig( config ); 242 KAddressBookView::writeConfig( config );
242} 243}
243 244void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
245{
246 mCardView->clear();
247 if ( s.isEmpty() || s == "*" ) {
248 refresh();
249 return;
250 }
251 QString pattern = s.lower()+"*";
252 QRegExp re;
253 re.setWildcard(true); // most people understand these better.
254 re.setCaseSensitive(false);
255 re.setPattern( pattern );
256 if (!re.isValid())
257 return;
258 mCardView->viewport()->setUpdatesEnabled( false );
259 KABC::Addressee::List addresseeList = addressees();
260 KABC::Addressee::List::Iterator it;
261 if ( field ) {
262 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
263#if QT_VERSION >= 300
264 if (re.search(field->value( *it ).lower()) != -1)
265#else
266 if (re.match(field->value( *it ).lower()) != -1)
267#endif
268 new AddresseeCardViewItem(fields(), mShowEmptyFields,
269 addressBook(), *it, mCardView);
270
271 }
272 } else {
273 KABC::Field::List fieldList = fields();
274 KABC::Field::List::ConstIterator fieldIt;
275 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
276 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
277#if QT_VERSION >= 300
278 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
279#else
280 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
281#endif
282 {
283 new AddresseeCardViewItem(fields(), mShowEmptyFields,
284 addressBook(), *it, mCardView);
285 continue;
286 }
287 }
288 }
289 }
290 mCardView->viewport()->setUpdatesEnabled( true );
291 mCardView->viewport()->update();
292 // by default nothing is selected
293 emit selected(QString::null);
294}
244QStringList KAddressBookCardView::selectedUids() 295QStringList KAddressBookCardView::selectedUids()
245{ 296{
246 QStringList uidList; 297 QStringList uidList;
247 CardViewItem *item; 298 CardViewItem *item;
248 AddresseeCardViewItem *aItem; 299 AddresseeCardViewItem *aItem;
249 300
250 for (item = mCardView->firstItem(); item; item = item->nextItem()) 301 for (item = mCardView->firstItem(); item; item = item->nextItem())
251 { 302 {
252 if (item->isSelected()) 303 if (item->isSelected())
253 { 304 {
254#ifndef KAB_EMBEDDED 305#ifndef KAB_EMBEDDED
255 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 306 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h
index cd70371..b8efb01 100644
--- a/kaddressbook/views/kaddressbookcardview.h
+++ b/kaddressbook/views/kaddressbookcardview.h
@@ -45,25 +45,25 @@ class AddresseeCardView;
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 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 63
64 public slots: 64 public slots:
65 void refresh(QString uid = QString::null); 65 void refresh(QString uid = QString::null);
66 void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); 66 void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/);
67//US added an additional method without parameter 67//US added an additional method without parameter
68 void setSelected(); 68 void setSelected();
69 69
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index 50ff285..78d63b0 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -87,24 +87,25 @@ AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
87 87
88#ifndef KAB_EMBEDDED 88#ifndef KAB_EMBEDDED
89 89
90 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), 90 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)),
91 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); 91 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&)));
92#endif //KAB_EMBEDDED 92#endif //KAB_EMBEDDED
93} 93}
94 94
95AddresseeIconView::~AddresseeIconView() 95AddresseeIconView::~AddresseeIconView()
96{ 96{
97} 97}
98 98
99
99void AddresseeIconView::itemDropped(QDropEvent *e, 100void AddresseeIconView::itemDropped(QDropEvent *e,
100 const QValueList<QIconDragItem> &) 101 const QValueList<QIconDragItem> &)
101{ 102{
102 emit addresseeDropped(e); 103 emit addresseeDropped(e);
103} 104}
104 105
105QDragObject *AddresseeIconView::dragObject() 106QDragObject *AddresseeIconView::dragObject()
106{ 107{
107 emit startAddresseeDrag(); 108 emit startAddresseeDrag();
108 109
109 // We never want IconView to start the drag 110 // We never want IconView to start the drag
110 return 0; 111 return 0;
@@ -223,25 +224,71 @@ void KAddressBookIconView::readConfig(KConfig *config)
223/*US 224/*US
224 if (KABPrefs::instance()->mHonorSingleClick) 225 if (KABPrefs::instance()->mHonorSingleClick)
225 connect(mIconView, SIGNAL(executed(QIconViewItem *)), 226 connect(mIconView, SIGNAL(executed(QIconViewItem *)),
226 this, SLOT(addresseeExecuted(QIconViewItem *))); 227 this, SLOT(addresseeExecuted(QIconViewItem *)));
227 else 228 else
228 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), 229 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)),
229 this, SLOT(addresseeExecuted(QIconViewItem *))); 230 this, SLOT(addresseeExecuted(QIconViewItem *)));
230*/ 231*/
231 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 232 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
232 this, SLOT(addresseeExecuted(QIconViewItem *))); 233 this, SLOT(addresseeExecuted(QIconViewItem *)));
233 234
234} 235}
236void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
237{
238 mIconView->clear();
239 mIconList.clear();
240 if ( s.isEmpty() || s == "*" ) {
241 refresh();
242 return;
243 }
244 QString pattern = s.lower()+"*";
245 QRegExp re;
246 re.setWildcard(true); // most people understand these better.
247 re.setCaseSensitive(false);
248 re.setPattern( pattern );
249 if (!re.isValid())
250 return;
251 KABC::Addressee::List addresseeList = addressees();
252 KABC::Addressee::List::Iterator it;
253 if ( field ) {
254 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
255#if QT_VERSION >= 300
256 if (re.search(field->value( *it ).lower()) != -1)
257#else
258 if (re.match(field->value( *it ).lower()) != -1)
259#endif
260 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
261
235 262
263 }
264 } else {
265 KABC::Field::List fieldList = fields();
266 KABC::Field::List::ConstIterator fieldIt;
267 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
268 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
269#if QT_VERSION >= 300
270 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
271#else
272 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
273#endif
274 {
275 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
276 continue;
277 }
278 }
279 }
280 }
281 mIconView->arrangeItemsInGrid( true );
282}
236QStringList KAddressBookIconView::selectedUids() 283QStringList KAddressBookIconView::selectedUids()
237{ 284{
238 QStringList uidList; 285 QStringList uidList;
239 QIconViewItem *item; 286 QIconViewItem *item;
240 AddresseeIconViewItem *aItem; 287 AddresseeIconViewItem *aItem;
241 288
242 for (item = mIconView->firstItem(); item; item = item->nextItem()) 289 for (item = mIconView->firstItem(); item; item = item->nextItem())
243 { 290 {
244 if (item->isSelected()) 291 if (item->isSelected())
245 { 292 {
246#ifndef KAB_EMBEDDED 293#ifndef KAB_EMBEDDED
247 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 294 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
diff --git a/kaddressbook/views/kaddressbookiconview.h b/kaddressbook/views/kaddressbookiconview.h
index 3afada3..963ee7c 100644
--- a/kaddressbook/views/kaddressbookiconview.h
+++ b/kaddressbook/views/kaddressbookiconview.h
@@ -49,24 +49,25 @@ namespace KABC { class AddressBook; }
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 62
62 virtual void readConfig(KConfig *config); 63 virtual void readConfig(KConfig *config);
63 64
64 public slots: 65 public slots:
65 void refresh(QString uid = QString::null); 66 void refresh(QString uid = QString::null);
66#ifndef KAB_EMBEDDED 67#ifndef KAB_EMBEDDED
67//MOC_SKIP_BEGIN 68//MOC_SKIP_BEGIN
68 void setSelected(QString uid = QString::null, bool selected = true); 69 void setSelected(QString uid = QString::null, bool selected = true);
69//MOC_SKIP_END 70//MOC_SKIP_END
70#else //KAB_EMBEDDED 71#else //KAB_EMBEDDED
71//US my MOC do not like default parameters ??? 72//US my MOC do not like default parameters ???
72 void setSelected(QString uid, bool selected); 73 void setSelected(QString uid, bool selected);
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index ab11e2a..12f7c27 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -103,24 +103,73 @@ void KAddressBookTableView::reconstructListView()
103 connect(mListView, SIGNAL(signalDelete()), 103 connect(mListView, SIGNAL(signalDelete()),
104 this, SLOT(addresseeDeleted())); 104 this, SLOT(addresseeDeleted()));
105 105
106//US performceimprovement. Refresh is done from the outside 106//US performceimprovement. Refresh is done from the outside
107//US refresh(); 107//US refresh();
108 108
109 mListView->setSorting( 0, true ); 109 mListView->setSorting( 0, true );
110 mainLayout->addWidget( mListView ); 110 mainLayout->addWidget( mListView );
111 mainLayout->activate(); 111 mainLayout->activate();
112 mListView->show(); 112 mListView->show();
113} 113}
114 114
115void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
116{
117 mListView->clear();
118 if ( s.isEmpty() || s == "*" ) {
119 refresh();
120 return;
121 }
122 QString pattern = s.lower()+"*";
123 QRegExp re;
124 re.setWildcard(true); // most people understand these better.
125 re.setCaseSensitive(false);
126 re.setPattern( pattern );
127 if (!re.isValid())
128 return;
129 KABC::Addressee::List addresseeList = addressees();
130 KABC::Addressee::List::Iterator it;
131 if ( field ) {
132 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
133#if QT_VERSION >= 300
134 if (re.search(field->value( *it ).lower()) != -1)
135#else
136 if (re.match(field->value( *it ).lower()) != -1)
137#endif
138 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
139
140 }
141 } else {
142 KABC::Field::List fieldList = fields();
143 KABC::Field::List::ConstIterator fieldIt;
144 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
145 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
146#if QT_VERSION >= 300
147 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
148#else
149 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
150#endif
151 {
152 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
153 continue;
154 }
155 }
156 }
157 }
158 // Sometimes the background pixmap gets messed up when we add lots
159 // of items.
160 mListView->repaint();
161 emit selected(QString::null);
162
163}
115void KAddressBookTableView::writeConfig(KConfig *config) 164void KAddressBookTableView::writeConfig(KConfig *config)
116{ 165{
117 KAddressBookView::writeConfig(config); 166 KAddressBookView::writeConfig(config);
118 167
119 mListView->saveLayout(config, config->group()); 168 mListView->saveLayout(config, config->group());
120} 169}
121 170
122void KAddressBookTableView::readConfig(KConfig *config) 171void KAddressBookTableView::readConfig(KConfig *config)
123{ 172{
124 KAddressBookView::readConfig( config ); 173 KAddressBookView::readConfig( config );
125 // The config could have changed the fields, so we need to reconstruct 174 // The config could have changed the fields, so we need to reconstruct
126 // the listview. 175 // the listview.
diff --git a/kaddressbook/views/kaddressbooktableview.h b/kaddressbook/views/kaddressbooktableview.h
index bb991bc..ecfe7a1 100644
--- a/kaddressbook/views/kaddressbooktableview.h
+++ b/kaddressbook/views/kaddressbooktableview.h
@@ -53,24 +53,25 @@ friend class ContactListView;
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 66
66 public slots: 67 public slots:
67 virtual void reconstructListView(); 68 virtual void reconstructListView();
68 69
69 protected slots: 70 protected slots:
70 /** Called whenever the user selects an addressee in the list view. 71 /** Called whenever the user selects an addressee in the list view.
71 */ 72 */
72 void addresseeSelected(); 73 void addresseeSelected();
73 void addresseeDeleted(); 74 void addresseeDeleted();
74 75
75 /** Called whenever the user executes an addressee. In terms of the 76 /** Called whenever the user executes an addressee. In terms of the
76 * list view, this is probably a double click 77 * list view, this is probably a double click