summaryrefslogtreecommitdiffabout
path: root/kabc/addresseedialog.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kabc/addresseedialog.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kabc/addresseedialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseedialog.cpp51
1 files changed, 27 insertions, 24 deletions
diff --git a/kabc/addresseedialog.cpp b/kabc/addresseedialog.cpp
index 671787e..bda1b9e 100644
--- a/kabc/addresseedialog.cpp
+++ b/kabc/addresseedialog.cpp
@@ -11,44 +11,47 @@
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 <q3groupbox.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qvbox.h> 26#include <q3vbox.h>
27#include <qlabel.h> 27#include <qlabel.h>
28//Added by qt3to4:
29#include <Q3ValueList>
30#include <Q3VBoxLayout>
28 31
29#include <klocale.h> 32#include <klocale.h>
30#include <kdebug.h> 33#include <kdebug.h>
31#include <kglobalsettings.h> 34#include <kglobalsettings.h>
32 35
33#include "stdaddressbook.h" 36#include "stdaddressbook.h"
34 37
35#include "addresseedialog.h" 38#include "addresseedialog.h"
36#include "KDGanttMinimizeSplitter.h" 39#include "KDGanttMinimizeSplitter.h"
37//#include "addresseedialog.moc" 40//#include "addresseedialog.moc"
38 41
39using namespace KABC; 42using namespace KABC;
40 43
41AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) : 44AddresseeItem::AddresseeItem( Q3ListView *parent, const Addressee &addressee ) :
42 QListViewItem( parent ), 45 Q3ListViewItem( parent ),
43 mAddressee( addressee ) 46 mAddressee( addressee )
44{ 47{
45 setText( Name,addressee.realName()); 48 setText( Name,addressee.realName());
46 setText( Email, addressee.preferredEmail() ); 49 setText( Email, addressee.preferredEmail() );
47 setText( Category, addressee.categories().join(";") ); 50 setText( Category, addressee.categories().join(";") );
48} 51}
49 52
50QString AddresseeItem::key( int column, bool ) const 53QString AddresseeItem::key( int column, bool ) const
51{ 54{
52 55
53 if (column == Email) { 56 if (column == Email) {
54 QString value = text(Email); 57 QString value = text(Email);
@@ -62,80 +65,80 @@ AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) :
62 KDialogBase( KDialogBase::Plain, i18n("Select Addressee"), 65 KDialogBase( KDialogBase::Plain, i18n("Select Addressee"),
63 Ok|Cancel, No, parent ), mMultiple( multiple ) 66 Ok|Cancel, No, parent ), mMultiple( multiple )
64{ 67{
65 qDebug("NEW AddresseeDialog "); 68 qDebug("NEW AddresseeDialog ");
66 69
67 70
68 KDGanttMinimizeSplitter* mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this ); 71 KDGanttMinimizeSplitter* mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this );
69 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 72 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
70 setMainWidget( mMiniSplitter ); 73 setMainWidget( mMiniSplitter );
71 74
72 QWidget *listWidget = new QWidget( mMiniSplitter ); 75 QWidget *listWidget = new QWidget( mMiniSplitter );
73 76
74 QVBoxLayout *listLayout = new QVBoxLayout (listWidget) ; 77 Q3VBoxLayout *listLayout = new Q3VBoxLayout (listWidget) ;
75 //topLayout->addLayout( listLayout ); 78 //topLayout->addLayout( listLayout );
76 79
77 mAddresseeList = new KListView( listWidget ); 80 mAddresseeList = new KListView( listWidget );
78 mAddresseeList->addColumn( i18n("Name") ); 81 mAddresseeList->addColumn( i18n("Name") );
79 mAddresseeList->addColumn( i18n("Email") ); 82 mAddresseeList->addColumn( i18n("Email") );
80 mAddresseeList->addColumn( i18n("Category") ); 83 mAddresseeList->addColumn( i18n("Category") );
81 mAddresseeList->setAllColumnsShowFocus( true ); 84 mAddresseeList->setAllColumnsShowFocus( true );
82 mAddresseeList->setFullWidth( true ); 85 mAddresseeList->setFullWidth( true );
83 listLayout->addWidget( mAddresseeList ); 86 listLayout->addWidget( mAddresseeList );
84 connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ), 87 connect( mAddresseeList, SIGNAL( doubleClicked( Q3ListViewItem * ) ),
85 SLOT( slotOk() ) ); 88 SLOT( slotOk() ) );
86 //QHBox* searchBox = new QHBox ( listWidget ); 89 //QHBox* searchBox = new QHBox ( listWidget );
87 QHBox * hb = new QHBox ( listWidget ); 90 Q3HBox * hb = new Q3HBox ( listWidget );
88 listLayout->addWidget ( hb ); 91 listLayout->addWidget ( hb );
89 mAddresseeEdit = new QLineEdit( hb ); 92 mAddresseeEdit = new QLineEdit( hb );
90 connect( mAddresseeEdit, SIGNAL( returnPressed() ), 93 connect( mAddresseeEdit, SIGNAL( returnPressed() ),
91 SLOT( loadAddressBook() ) ); 94 SLOT( loadAddressBook() ) );
92 mAddresseeEdit->setFocus(); 95 mAddresseeEdit->setFocus();
93 QPushButton *searchButton = new QPushButton( i18n("Search!"), hb ); 96 QPushButton *searchButton = new QPushButton( i18n("Search!"), hb );
94 connect ( searchButton, SIGNAL( clicked() ), SLOT( loadAddressBook() ) ); 97 connect ( searchButton, SIGNAL( clicked() ), SLOT( loadAddressBook() ) );
95 if ( mMultiple ) { 98 if ( mMultiple ) {
96 99
97 mSelectedList = new KListView( mMiniSplitter ); 100 mSelectedList = new KListView( mMiniSplitter );
98 mSelectedList->addColumn( i18n("Selected Name") ); 101 mSelectedList->addColumn( i18n("Selected Name") );
99 mSelectedList->addColumn( i18n("Email") ); 102 mSelectedList->addColumn( i18n("Email") );
100 mSelectedList->setAllColumnsShowFocus( true ); 103 mSelectedList->setAllColumnsShowFocus( true );
101 mSelectedList->setFullWidth( true ); 104 mSelectedList->setFullWidth( true );
102 //connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ), 105 //connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ),
103 // SLOT( removeSelected() ) ); 106 // SLOT( removeSelected() ) );
104 connect( mSelectedList, SIGNAL( clicked( QListViewItem * ) ), 107 connect( mSelectedList, SIGNAL( clicked( Q3ListViewItem * ) ),
105 SLOT( removeSelected() ) ); 108 SLOT( removeSelected() ) );
106 connect( mSelectedList, SIGNAL( returnPressed( QListViewItem *) ), 109 connect( mSelectedList, SIGNAL( returnPressed( Q3ListViewItem *) ),
107 SLOT( removeSelected() ) ); 110 SLOT( removeSelected() ) );
108 111
109#if 0 112#if 0
110 QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup ); 113 QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup );
111 connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) ); 114 connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) );
112 115
113#endif 116#endif
114 connect( mAddresseeList, SIGNAL( clicked( QListViewItem * ) ), 117 connect( mAddresseeList, SIGNAL( clicked( Q3ListViewItem * ) ),
115 SLOT( addSelected( QListViewItem * ) ) ); 118 SLOT( addSelected( Q3ListViewItem * ) ) );
116 connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ), 119 connect( mAddresseeList, SIGNAL( returnPressed( Q3ListViewItem * ) ),
117 SLOT( selectNextItem( QListViewItem * ) ) ); 120 SLOT( selectNextItem( Q3ListViewItem * ) ) );
118 121
119 } 122 }
120 123
121 mAddressBook = StdAddressBook::self( true ); 124 mAddressBook = StdAddressBook::self( true );
122 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ), 125 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ),
123 SLOT( addressBookChanged() ) ); 126 SLOT( addressBookChanged() ) );
124#if 0 127#if 0
125 connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ), 128 connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ),
126 SLOT( addressBookChanged() ) ); 129 SLOT( addressBookChanged() ) );
127#endif 130#endif
128 loadAddressBook(); 131 loadAddressBook();
129 QValueList<int> splitterSize; 132 Q3ValueList<int> splitterSize;
130 splitterSize.append( ( width() / 5 ) * 3 ); 133 splitterSize.append( ( width() / 5 ) * 3 );
131 splitterSize.append( ( width() / 5 ) *2 ); 134 splitterSize.append( ( width() / 5 ) *2 );
132 mMiniSplitter->setSizes( splitterSize ); 135 mMiniSplitter->setSizes( splitterSize );
133} 136}
134 137
135AddresseeDialog::~AddresseeDialog() 138AddresseeDialog::~AddresseeDialog()
136{ 139{
137 qDebug("DELETE AddresseeDialog "); 140 qDebug("DELETE AddresseeDialog ");
138} 141}
139 142
140void AddresseeDialog::loadAddressBook() 143void AddresseeDialog::loadAddressBook()
141{ 144{
@@ -163,82 +166,82 @@ void AddresseeDialog::loadAddressBook()
163 QString name = (*it).realName(); 166 QString name = (*it).realName();
164 name += (*it).preferredEmail(); 167 name += (*it).preferredEmail();
165 name += (*it).categories().join(";"); 168 name += (*it).categories().join(";");
166#if QT_VERSION >= 0x030000 169#if QT_VERSION >= 0x030000
167 if (re.search(name) != -1) 170 if (re.search(name) != -1)
168#else 171#else
169 if (re.match(name) != -1) 172 if (re.match(name) != -1)
170#endif 173#endif
171 AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) ); 174 AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) );
172 } 175 }
173} 176}
174 177
175void AddresseeDialog::addCompletionItem( const QString &str, QListViewItem *item ) 178void AddresseeDialog::addCompletionItem( const QString &str, Q3ListViewItem *item )
176{ 179{
177 if ( str.isEmpty() ) return; 180 if ( str.isEmpty() ) return;
178 181
179 mItemDict.insert( str, item ); 182 mItemDict.insert( str, item );
180 //mAddresseeEdit->completionObject()->addItem( str ); 183 //mAddresseeEdit->completionObject()->addItem( str );
181} 184}
182 185
183void AddresseeDialog::selectItem( const QString &str ) 186void AddresseeDialog::selectItem( const QString &str )
184{ 187{
185 if ( str.isEmpty() ) return; 188 if ( str.isEmpty() ) return;
186 189
187 QListViewItem *item = mItemDict.find( str ); 190 Q3ListViewItem *item = mItemDict.find( str );
188 if ( item ) { 191 if ( item ) {
189 mAddresseeList->blockSignals( true ); 192 mAddresseeList->blockSignals( true );
190 mAddresseeList->setSelected( item, true ); 193 mAddresseeList->setSelected( item, true );
191 mAddresseeList->ensureItemVisible( item ); 194 mAddresseeList->ensureItemVisible( item );
192 mAddresseeList->blockSignals( false ); 195 mAddresseeList->blockSignals( false );
193 } 196 }
194} 197}
195 198
196void AddresseeDialog::updateEdit( QListViewItem *item ) 199void AddresseeDialog::updateEdit( Q3ListViewItem *item )
197{ 200{
198 mAddresseeEdit->setText( item->text( 0 ) ); 201 mAddresseeEdit->setText( item->text( 0 ) );
199 mAddresseeEdit->setSelection( 0, item->text( 0 ).length() ); 202 mAddresseeEdit->setSelection( 0, item->text( 0 ).length() );
200} 203}
201 204
202void AddresseeDialog::selectNextItem( QListViewItem *item ) 205void AddresseeDialog::selectNextItem( Q3ListViewItem *item )
203{ 206{
204 addSelected( item ); 207 addSelected( item );
205 QListViewItem *next = item->nextSibling(); 208 Q3ListViewItem *next = item->nextSibling();
206 if ( next ) { 209 if ( next ) {
207 next->setSelected( true ); 210 next->setSelected( true );
208 item->setSelected( false ); 211 item->setSelected( false );
209 mAddresseeList->setCurrentItem( next ); 212 mAddresseeList->setCurrentItem( next );
210 } 213 }
211} 214}
212void AddresseeDialog::addSelected( QListViewItem *item ) 215void AddresseeDialog::addSelected( Q3ListViewItem *item )
213{ 216{
214 AddresseeItem *addrItem = (AddresseeItem *)( item ); 217 AddresseeItem *addrItem = (AddresseeItem *)( item );
215 if ( !addrItem ) return; 218 if ( !addrItem ) return;
216 219
217 Addressee a = addrItem->addressee(); 220 Addressee a = addrItem->addressee();
218 221
219 QListViewItem *selectedItem = mSelectedDict.find( a.uid() ); 222 Q3ListViewItem *selectedItem = mSelectedDict.find( a.uid() );
220 if ( !selectedItem ) { 223 if ( !selectedItem ) {
221 selectedItem = new AddresseeItem( mSelectedList, a ); 224 selectedItem = new AddresseeItem( mSelectedList, a );
222 mSelectedDict.insert( a.uid(), selectedItem ); 225 mSelectedDict.insert( a.uid(), selectedItem );
223 } 226 }
224 227
225} 228}
226 229
227void AddresseeDialog::removeSelected() 230void AddresseeDialog::removeSelected()
228{ 231{
229 QListViewItem *item = mSelectedList->selectedItem(); 232 Q3ListViewItem *item = mSelectedList->selectedItem();
230 AddresseeItem *addrItem = (AddresseeItem *)( item ); 233 AddresseeItem *addrItem = (AddresseeItem *)( item );
231 if ( !addrItem ) return; 234 if ( !addrItem ) return;
232 QListViewItem *next = item->nextSibling(); 235 Q3ListViewItem *next = item->nextSibling();
233 mSelectedDict.remove( addrItem->addressee().uid() ); 236 mSelectedDict.remove( addrItem->addressee().uid() );
234 delete addrItem; 237 delete addrItem;
235 if ( next ) 238 if ( next )
236 next->setSelected( true ); 239 next->setSelected( true );
237} 240}
238 241
239Addressee AddresseeDialog::addressee() 242Addressee AddresseeDialog::addressee()
240{ 243{
241 AddresseeItem *aItem = 0; 244 AddresseeItem *aItem = 0;
242 245
243 if ( mMultiple ) 246 if ( mMultiple )
244 aItem = (AddresseeItem *)( mSelectedList->firstChild() ); 247 aItem = (AddresseeItem *)( mSelectedList->firstChild() );
@@ -246,25 +249,25 @@ Addressee AddresseeDialog::addressee()
246 aItem = (AddresseeItem *)( mAddresseeList->selectedItem() ); 249 aItem = (AddresseeItem *)( mAddresseeList->selectedItem() );
247 250
248 if (aItem) return aItem->addressee(); 251 if (aItem) return aItem->addressee();
249 return Addressee(); 252 return Addressee();
250} 253}
251 254
252Addressee::List AddresseeDialog::addressees() 255Addressee::List AddresseeDialog::addressees()
253{ 256{
254 Addressee::List al; 257 Addressee::List al;
255 AddresseeItem *aItem = 0; 258 AddresseeItem *aItem = 0;
256 259
257 if ( mMultiple ) { 260 if ( mMultiple ) {
258 QListViewItem *item = mSelectedList->firstChild(); 261 Q3ListViewItem *item = mSelectedList->firstChild();
259 while( item ) { 262 while( item ) {
260 aItem = (AddresseeItem *)( item ); 263 aItem = (AddresseeItem *)( item );
261 if ( aItem ) al.append( aItem->addressee() ); 264 if ( aItem ) al.append( aItem->addressee() );
262 item = item->nextSibling(); 265 item = item->nextSibling();
263 } 266 }
264 } 267 }
265 else 268 else
266 { 269 {
267 aItem = (AddresseeItem *)( mAddresseeList->selectedItem() ); 270 aItem = (AddresseeItem *)( mAddresseeList->selectedItem() );
268 if (aItem) al.append( aItem->addressee() ); 271 if (aItem) al.append( aItem->addressee() );
269 } 272 }
270 273