summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2005-06-18 09:37:58 (UTC)
committer zautrix <zautrix>2005-06-18 09:37:58 (UTC)
commit2cbe93f970eddb6b61d3fc42ccff1a500e806723 (patch) (unidiff)
treec4a76544776f9d046e9560fb6d0eb9eb3cc050a1 /kabc
parent252c62bffc34f2c71002c71abea480807fa1455a (diff)
downloadkdepimpi-2cbe93f970eddb6b61d3fc42ccff1a500e806723.zip
kdepimpi-2cbe93f970eddb6b61d3fc42ccff1a500e806723.tar.gz
kdepimpi-2cbe93f970eddb6b61d3fc42ccff1a500e806723.tar.bz2
fixx
Diffstat (limited to 'kabc') (more/less context) (show whitespace changes)
-rw-r--r--kabc/addresseedialog.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/kabc/addresseedialog.cpp b/kabc/addresseedialog.cpp
index 19b52bb..e89584d 100644
--- a/kabc/addresseedialog.cpp
+++ b/kabc/addresseedialog.cpp
@@ -1,96 +1,93 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qpushbutton.h> 22#include <qpushbutton.h>
23#include <qgroupbox.h> 23#include <qgroupbox.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qvbox.h> 26#include <qvbox.h>
27#include <qlabel.h> 27#include <qlabel.h>
28 28
29#include <klocale.h> 29#include <klocale.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kglobalsettings.h> 31#include <kglobalsettings.h>
32 32
33#include "stdaddressbook.h" 33#include "stdaddressbook.h"
34 34
35#include "addresseedialog.h" 35#include "addresseedialog.h"
36#include "KDGanttMinimizeSplitter.h" 36#include "KDGanttMinimizeSplitter.h"
37//#include "addresseedialog.moc" 37//#include "addresseedialog.moc"
38 38
39using namespace KABC; 39using namespace KABC;
40 40
41AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) : 41AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) :
42 QListViewItem( parent ), 42 QListViewItem( parent ),
43 mAddressee( addressee ) 43 mAddressee( addressee )
44{ 44{
45 QString name = addressee.familyName()+", "+ addressee.givenName(); 45 setText( Name,addressee.realName());
46 if ( name.length() == 2 )
47 name = addressee.organization();
48 setText( Name,name);
49 setText( Email, addressee.preferredEmail() ); 46 setText( Email, addressee.preferredEmail() );
50} 47}
51 48
52QString AddresseeItem::key( int column, bool ) const 49QString AddresseeItem::key( int column, bool ) const
53{ 50{
54 51
55 if (column == Email) { 52 if (column == Email) {
56 QString value = text(Email); 53 QString value = text(Email);
57 int val = value.findRev("@"); 54 int val = value.findRev("@");
58 return value.mid( val) + value.left( val ); 55 return value.mid( val) + value.left( val );
59 } 56 }
60 return text(column).lower(); 57 return text(column).lower();
61} 58}
62 59
63AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : 60AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) :
64 KDialogBase( KDialogBase::Plain, i18n("Select Addressee"), 61 KDialogBase( KDialogBase::Plain, i18n("Select Addressee"),
65 Ok|Cancel, No, parent ), mMultiple( multiple ) 62 Ok|Cancel, No, parent ), mMultiple( multiple )
66{ 63{
67 qDebug("NEW AddresseeDialog "); 64 qDebug("NEW AddresseeDialog ");
68 QWidget *topWidget = plainPage(); 65 QWidget *topWidget = plainPage();
69 66
70 QBoxLayout *topLayout = new QHBoxLayout( topWidget ); 67 QBoxLayout *topLayout = new QHBoxLayout( topWidget );
71 68
72 69
73 KDGanttMinimizeSplitter* mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, topWidget); 70 KDGanttMinimizeSplitter* mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, topWidget);
74 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 71 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
75 72
76 topLayout->addWidget(mMiniSplitter ); 73 topLayout->addWidget(mMiniSplitter );
77 74
78 QWidget *listWidget = new QWidget( mMiniSplitter ); 75 QWidget *listWidget = new QWidget( mMiniSplitter );
79 76
80 QBoxLayout *listLayout = new QVBoxLayout (listWidget) ; 77 QBoxLayout *listLayout = new QVBoxLayout (listWidget) ;
81 //topLayout->addLayout( listLayout ); 78 //topLayout->addLayout( listLayout );
82 79
83 mAddresseeList = new KListView( listWidget ); 80 mAddresseeList = new KListView( listWidget );
84 mAddresseeList->addColumn( i18n("Name") ); 81 mAddresseeList->addColumn( i18n("Name") );
85 mAddresseeList->addColumn( i18n("Email") ); 82 mAddresseeList->addColumn( i18n("Email") );
86 mAddresseeList->setAllColumnsShowFocus( true ); 83 mAddresseeList->setAllColumnsShowFocus( true );
87 mAddresseeList->setFullWidth( true ); 84 mAddresseeList->setFullWidth( true );
88 listLayout->addWidget( mAddresseeList ); 85 listLayout->addWidget( mAddresseeList );
89 connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ), 86 connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ),
90 SLOT( slotOk() ) ); 87 SLOT( slotOk() ) );
91 88
92 mAddresseeEdit = new QLineEdit( listWidget ); 89 mAddresseeEdit = new QLineEdit( listWidget );
93 connect( mAddresseeEdit, SIGNAL( returnPressed() ), 90 connect( mAddresseeEdit, SIGNAL( returnPressed() ),
94 SLOT( loadAddressBook() ) ); 91 SLOT( loadAddressBook() ) );
95 mAddresseeEdit->setFocus(); 92 mAddresseeEdit->setFocus();
96 93
@@ -120,99 +117,97 @@ AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) :
120 SLOT( addSelected( QListViewItem * ) ) ); 117 SLOT( addSelected( QListViewItem * ) ) );
121 connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ), 118 connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ),
122 SLOT( selectNextItem( QListViewItem * ) ) ); 119 SLOT( selectNextItem( QListViewItem * ) ) );
123 120
124 } 121 }
125 122
126 mAddressBook = StdAddressBook::self( true ); 123 mAddressBook = StdAddressBook::self( true );
127 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ), 124 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ),
128 SLOT( addressBookChanged() ) ); 125 SLOT( addressBookChanged() ) );
129#if 0 126#if 0
130 connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ), 127 connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ),
131 SLOT( addressBookChanged() ) ); 128 SLOT( addressBookChanged() ) );
132#endif 129#endif
133 loadAddressBook(); 130 loadAddressBook();
134 QValueList<int> splitterSize; 131 QValueList<int> splitterSize;
135 splitterSize.append( ( width() / 5 ) * 3 ); 132 splitterSize.append( ( width() / 5 ) * 3 );
136 splitterSize.append( ( width() / 5 ) *2 ); 133 splitterSize.append( ( width() / 5 ) *2 );
137 mMiniSplitter->setSizes( splitterSize ); 134 mMiniSplitter->setSizes( splitterSize );
138} 135}
139 136
140AddresseeDialog::~AddresseeDialog() 137AddresseeDialog::~AddresseeDialog()
141{ 138{
142 qDebug("DELETE AddresseeDialog "); 139 qDebug("DELETE AddresseeDialog ");
143} 140}
144 141
145void AddresseeDialog::loadAddressBook() 142void AddresseeDialog::loadAddressBook()
146{ 143{
147 mAddresseeList->clear(); 144 mAddresseeList->clear();
148 mItemDict.clear(); 145 mItemDict.clear();
149 if ( mAddresseeEdit->text().isEmpty() ) { 146 if ( mAddresseeEdit->text().isEmpty() ) {
150 AddressBook::Iterator it; 147 AddressBook::Iterator it;
151 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 148 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
152 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 149 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
153 continue; 150 continue;
154 new AddresseeItem( mAddresseeList, (*it) ); 151 new AddresseeItem( mAddresseeList, (*it) );
155 } 152 }
156 return; 153 return;
157 } 154 }
158 //mAddresseeEdit->completionObject()->clear(); 155 //mAddresseeEdit->completionObject()->clear();
159 QRegExp re; 156 QRegExp re;
160 re.setWildcard(true); // most people understand these better. 157 re.setWildcard(true); // most people understand these better.
161 re.setCaseSensitive(false); 158 re.setCaseSensitive(false);
162 re.setPattern( "*"+ mAddresseeEdit->text() + "*"); 159 re.setPattern( "*"+ mAddresseeEdit->text() + "*");
163 160
164 AddressBook::Iterator it; 161 AddressBook::Iterator it;
165 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 162 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
166 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 163 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
167 continue; 164 continue;
168 QString name = (*it).familyName()+", "+ (*it).givenName(); 165 QString name = (*it).realName();
169 if ( name.length() == 2 )
170 name = (*it).realName();
171 name += (*it).preferredEmail(); 166 name += (*it).preferredEmail();
172#if QT_VERSION >= 0x030000 167#if QT_VERSION >= 0x030000
173 if (re.search(name) != -1) 168 if (re.search(name) != -1)
174#else 169#else
175 if (re.match(name) != -1) 170 if (re.match(name) != -1)
176#endif 171#endif
177 AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) ); 172 AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) );
178 } 173 }
179} 174}
180 175
181void AddresseeDialog::addCompletionItem( const QString &str, QListViewItem *item ) 176void AddresseeDialog::addCompletionItem( const QString &str, QListViewItem *item )
182{ 177{
183 if ( str.isEmpty() ) return; 178 if ( str.isEmpty() ) return;
184 179
185 mItemDict.insert( str, item ); 180 mItemDict.insert( str, item );
186 //mAddresseeEdit->completionObject()->addItem( str ); 181 //mAddresseeEdit->completionObject()->addItem( str );
187} 182}
188 183
189void AddresseeDialog::selectItem( const QString &str ) 184void AddresseeDialog::selectItem( const QString &str )
190{ 185{
191 if ( str.isEmpty() ) return; 186 if ( str.isEmpty() ) return;
192 187
193 QListViewItem *item = mItemDict.find( str ); 188 QListViewItem *item = mItemDict.find( str );
194 if ( item ) { 189 if ( item ) {
195 mAddresseeList->blockSignals( true ); 190 mAddresseeList->blockSignals( true );
196 mAddresseeList->setSelected( item, true ); 191 mAddresseeList->setSelected( item, true );
197 mAddresseeList->ensureItemVisible( item ); 192 mAddresseeList->ensureItemVisible( item );
198 mAddresseeList->blockSignals( false ); 193 mAddresseeList->blockSignals( false );
199 } 194 }
200} 195}
201 196
202void AddresseeDialog::updateEdit( QListViewItem *item ) 197void AddresseeDialog::updateEdit( QListViewItem *item )
203{ 198{
204 mAddresseeEdit->setText( item->text( 0 ) ); 199 mAddresseeEdit->setText( item->text( 0 ) );
205 mAddresseeEdit->setSelection( 0, item->text( 0 ).length() ); 200 mAddresseeEdit->setSelection( 0, item->text( 0 ).length() );
206} 201}
207 202
208void AddresseeDialog::selectNextItem( QListViewItem *item ) 203void AddresseeDialog::selectNextItem( QListViewItem *item )
209{ 204{
210 addSelected( item ); 205 addSelected( item );
211 QListViewItem *next = item->nextSibling(); 206 QListViewItem *next = item->nextSibling();
212 if ( next ) { 207 if ( next ) {
213 next->setSelected( true ); 208 next->setSelected( true );
214 item->setSelected( false ); 209 item->setSelected( false );
215 mAddresseeList->setCurrentItem( next ); 210 mAddresseeList->setCurrentItem( next );
216 } 211 }
217} 212}
218void AddresseeDialog::addSelected( QListViewItem *item ) 213void AddresseeDialog::addSelected( QListViewItem *item )